Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jedediah/mcedit
Browse files Browse the repository at this point in the history
  • Loading branch information
TkTech committed Apr 15, 2012
2 parents c2747e1 + 634b263 commit 18778d2
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion leveleditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ def __init__(self, editor):

self.cameraVector = self._cameraVector()

# A state machine to dodge an apparent bug in pygame that generates erroneous mouse move events
# 0 = bad event already happened
# 1 = app just started or regained focus since last bad event
# 2 = mouse cursor was hidden after state 1, next event will be bad
self.avoidMouseJumpBug = 1

Settings.drawSky.addObserver(self)
Settings.drawFog.addObserver(self)
Settings.showCeiling.addObserver(self)
Expand Down Expand Up @@ -579,6 +585,9 @@ def mouseLookOn(self):
self.focus_switch = None
self.startingMousePosition = mouse.get_pos()

if self.avoidMouseJumpBug == 1:
self.avoidMouseJumpBug = 2

def mouseLookOff(self):
root.get_root().capture_mouse(None)
if self.startingMousePosition:
Expand Down Expand Up @@ -1022,6 +1031,10 @@ def mouse_drag(self, evt):
lastRendererUpdate = datetime.now()

def mouse_move(self, evt):
if self.avoidMouseJumpBug == 2:
self.avoidMouseJumpBug = 0
return

def sensitivityAdjust(d):
return d * ControlSettings.mouseSpeed.get() / 10.0

Expand All @@ -1046,6 +1059,10 @@ def sensitivityAdjust(d):
# event.get(MOUSEMOTION)
# self.oldMousePosition = (self.startingMousePosition)

def activeevent(self, evt):
if evt.state & 0x2 and evt.gain != 0:
self.avoidMouseJumpBug = 1

@property
def tooltipText(self):
return self.editor.currentTool.worldTooltipText
Expand Down Expand Up @@ -2178,6 +2195,8 @@ def idleevent(self, e):
self.doWorkUnit()

def activeevent(self, evt):
self.mainViewport.activeevent(evt)

if evt.state & 0x4: # minimized
if evt.gain == 0:
logging.debug("Offscreen")
Expand Down Expand Up @@ -2273,7 +2292,7 @@ def mouseDragOn(self):
self.dragInProgress = True
self.dragStartPoint = (x,y)
self.currentOperation.dragStart(x,y)
'
def mouseDragOff(self):
if self.dragInProgress:
self.dragInProgress = False
Expand Down

0 comments on commit 18778d2

Please sign in to comment.