changeset 257:f2195628947b

* Cursor will now respect image shift values when drawing the cursor * Editor now have cursors showing what mode the editor is in
author cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
date Mon, 08 Jun 2009 19:56:54 +0000
parents e893afb4963b
children 0b1992a3dfe7
files clients/editor/scripts/gui/mapeditor.py clients/editor/scripts/gui/resizablebase.py engine/core/video/cursor.cpp
diffstat 3 files changed, 53 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/clients/editor/scripts/gui/mapeditor.py	Mon Jun 08 16:57:39 2009 +0000
+++ b/clients/editor/scripts/gui/mapeditor.py	Mon Jun 08 19:56:54 2009 +0000
@@ -62,9 +62,10 @@
 		events.mouseDragged.connect(self.mouseDragged)
 		events.mouseReleased.connect(self.mouseReleased)
 		events.mouseMoved.connect(self.mouseMoved)
+		events.mouseEntered.connect(self.mouseEntered)
+		events.mouseExited.connect(self.mouseExited)
 		events.mouseWheelMovedUp.connect(self.mouseWheelMovedUp)
 		events.mouseWheelMovedDown.connect(self.mouseWheelMovedDown)
-		events.mouseExited.connect(self.mouseExited)
 		events.onPump.connect(self.pump)
 		
 	def _clear(self):
@@ -77,14 +78,55 @@
 		events.mouseDragged.disconnect(self.mouseDragged)
 		events.mouseReleased.disconnect(self.mouseReleased)
 		events.mouseMoved.disconnect(self.mouseMoved)
+		events.mouseExited.disconnect(self.mouseExited)
+		events.mouseEntered.disconnect(self.mouseEntered)
 		events.mouseWheelMovedUp.disconnect(self.mouseWheelMovedUp)
 		events.mouseWheelMovedDown.disconnect(self.mouseWheelMovedDown)
-		events.mouseExited.disconnect(self.mouseExited)
 		events.onPump.disconnect(self.pump)
 		
 	def _mapChanged(self, sender, mapview):
 		self.setController(mapview.getController())
 		
+	def _setCursor(self):
+		engine = self._editor.getEngine()
+		cursor = engine.getCursor()
+		
+		id = -1
+		if self._mode == SELECTING:
+			id = engine.getImagePool().addResourceFromFile("gui/icons/select_instance.png")
+			image = engine.getImagePool().getImage(id)
+			image.setXShift(-16)
+			image.setYShift(-15)
+		elif self._mode == INSERTING:
+			id = engine.getImagePool().addResourceFromFile("gui/icons/add_instance.png")
+			image = engine.getImagePool().getImage(id)
+			image.setXShift(-2)
+			image.setYShift(-20)
+		elif self._mode == REMOVING:
+			id = engine.getImagePool().addResourceFromFile("gui/icons/erase_instance.png")
+			image = engine.getImagePool().getImage(id)
+			image.setXShift(-2)
+			image.setYShift(-19)
+		elif self._mode == MOVING:
+			id = engine.getImagePool().addResourceFromFile("gui/icons/move_instance.png")
+			image = engine.getImagePool().getImage(id)
+			image.setXShift(-11)
+			image.setYShift(-11)
+		elif self._mode == OBJECTPICKER:
+			id = engine.getImagePool().addResourceFromFile("gui/icons/objectpicker.png")
+			image = engine.getImagePool().getImage(id)
+			image.setXShift(-0)
+			image.setYShift(-22)
+			
+		if id < 0:
+			self._resetCursor()
+		else:
+			cursor.set(fife.CURSOR_IMAGE, id)
+			
+	def _resetCursor(self):
+		cursor = self._editor.getEngine().getCursor()
+		cursor.set(fife.CURSOR_NATIVE, fife.NC_ARROW)
+		
 	def setObject(self, object):
 		self._object = object
 		
@@ -180,6 +222,7 @@
 		self._mode = mode
 		print "Entered mode " + mode
 		self._statusbar.setText(mode.replace('_', ' ').capitalize())
+		self._setCursor()
 		
 	def _buttonToggled(self, sender, toggled):
 		if self._controller is None: return
@@ -201,10 +244,6 @@
 
 		self._setMode(mode)
 		
-	def mouseExited(self, sender, event):
-		pass
-
-
 	def mousePressed(self, sender, event):
 		if event.isConsumedByWidgets():
 			return
@@ -360,6 +399,12 @@
 
 	def mouseMoved(self, sender, event):
 		pass
+		
+	def mouseEntered(self, sender, event):
+		self._setCursor()
+		
+	def mouseExited(self, sender, event):
+		self._resetCursor()
 				
 	def mouseWheelMovedUp(self, event):
 		if self._eventlistener.controlPressed and self._controller._camera:
--- a/clients/editor/scripts/gui/resizablebase.py	Mon Jun 08 16:57:39 2009 +0000
+++ b/clients/editor/scripts/gui/resizablebase.py	Mon Jun 08 19:56:54 2009 +0000
@@ -50,7 +50,6 @@
 			titleheight = self.real_widget.getTitleBarHeight()
 
 		cursor = self._engine.getCursor()
-		cursor.set(fife.CURSOR_NATIVE, fife.NC_RESIZENW)
 		
 		left	= event.getX() < 5 and self.resizable_left
 		right	= event.getX() > self.width-5 and self.resizable_right
--- a/engine/core/video/cursor.cpp	Mon Jun 08 16:57:39 2009 +0000
+++ b/engine/core/video/cursor.cpp	Mon Jun 08 19:56:54 2009 +0000
@@ -136,7 +136,7 @@
  			img = anim.getFrameByTimestamp(animtime);
 		}
 		if (img) {
-			Rect area(mx + m_drag_offset_x, my + m_drag_offset_y, img->getWidth(), img->getHeight());
+			Rect area(mx + m_drag_offset_x + img->getXShift(), my + m_drag_offset_y + img->getYShift(), img->getWidth(), img->getHeight());
 			m_renderbackend->pushClipArea(area, false);
 			img->render(area);
 			m_renderbackend->popClipArea();
@@ -152,7 +152,7 @@
 			img = anim.getFrameByTimestamp(animtime);
 		}
 		if (img) {
-			Rect area(mx, my, img->getWidth(), img->getHeight());
+			Rect area(mx + img->getXShift(), my + img->getYShift(), img->getWidth(), img->getHeight());
 			m_renderbackend->pushClipArea(area, false);
 			img->render(area);
 			m_renderbackend->popClipArea();