class DialogMask(DirectButton): '''used to generate a full-screen mask to prevent button-clicking below the focused window/dialog Added some tricks to make panda3d mouse events still available ''' B1PRESS = PGButton.getPressPrefix() + MouseButton.one().getName() + '-' B2PRESS = PGButton.getPressPrefix() + MouseButton.two().getName() + '-' B3PRESS = PGButton.getPressPrefix() + MouseButton.three().getName() + '-' B4PRESS = PGButton.getPressPrefix() + MouseButton.four().getName() + '-' B5PRESS = PGButton.getPressPrefix() + MouseButton.five().getName() + '-' WHEELUP = PGButton.getReleasePrefix() + MouseButton.wheelUp().getName( ) + '-' WHEELDOWN = PGButton.getReleasePrefix() + MouseButton.wheelDown().getName( ) + '-' WHEELLEFT = PGButton.getReleasePrefix() + MouseButton.wheelLeft().getName( ) + '-' WHEELRIGHT = PGButton.getReleasePrefix() + MouseButton.wheelRight( ).getName() + '-' B1RELEASE = PGButton.getReleasePrefix() + MouseButton.one().getName() + '-' B2RELEASE = PGButton.getReleasePrefix() + MouseButton.two().getName() + '-' B3RELEASE = PGButton.getReleasePrefix() + MouseButton.three().getName( ) + '-' B4RELEASE = PGButton.getReleasePrefix() + MouseButton.four().getName( ) + '-' B5RELEASE = PGButton.getReleasePrefix() + MouseButton.five().getName( ) + '-' def __init__(self): DirectButton.__init__(self, parent=aspect2d, frameColor=(1, 1, 1, 0), relief=DGG.FLAT, commandButtons=[]) self.accept('window-event', self.windowResize) self.windowResize(None) #trick: make this re-throw mouse events self.bind(self.B1PRESS, self.rethrowEvent, ['mouse1']) self.bind(self.B2PRESS, self.rethrowEvent, ['mouse2']) self.bind(self.B3PRESS, self.rethrowEvent, ['mouse3']) self.bind(self.B4PRESS, self.rethrowEvent, ['mouse4']) self.bind(self.B5PRESS, self.rethrowEvent, ['mouse5']) self.bind(self.WHEELUP, self.rethrowEvent, ['wheel_up']) self.bind(self.WHEELDOWN, self.rethrowEvent, ['wheel_down']) self.bind(self.WHEELLEFT, self.rethrowEvent, ['wheel_left']) self.bind(self.WHEELRIGHT, self.rethrowEvent, ['wheel_right']) self.bind(self.B1RELEASE, self.rethrowEvent, ['mouse1-up']) self.bind(self.B2RELEASE, self.rethrowEvent, ['mouse2-up']) self.bind(self.B3RELEASE, self.rethrowEvent, ['mouse3-up']) self.bind(self.B4RELEASE, self.rethrowEvent, ['mouse4-up']) self.bind(self.B5RELEASE, self.rethrowEvent, ['mouse5-up']) def windowResize(self, arg): #fill the screen aspect = base.getAspectRatio() if aspect > 1: self['frameSize'] = (-aspect, aspect, -1, 1) elif aspect: hh = 1.0 / aspect self['frameSize'] = (-1, 1, -hh, hh) def setCommandButtons(self, *args, **kwargs): #inherited pass def rethrowEvent(self, sevent, event): messenger.send(sevent) def destroy(self): self.ignoreAll() DirectButton.destroy(self)
from direct.gui.OnscreenText import OnscreenText from direct.gui.DirectFrame import DirectFrame from direct.gui.DirectButton import DirectButton from direct.gui.DirectScrolledFrame import DirectScrolledFrame from runtime_data import game_settings from sogal_form import SogalForm, SogalDialog from gui.layout import HLayout, VLayout import gui.color_themes as color_themes from sogal_form import ConfirmDialog import runtime_data WHEELUP = PGButton.getReleasePrefix() + MouseButton.wheelUp().getName() + '-' WHEELDOWN = PGButton.getReleasePrefix() + MouseButton.wheelDown().getName( ) + '-' WHEELLEFT = PGButton.getReleasePrefix() + MouseButton.wheelLeft().getName( ) + '-' WHEELRIGHT = PGButton.getReleasePrefix() + MouseButton.wheelRight().getName( ) + '-' #pos = (-0.57,0,0.67) MAX_SAVE = 200 hspacing = 1.33 vspacing = 0.4 FRAMESIZE = (-1.35, 1.35, -0.95, 0.95) LOAD_CANVAS_SIZE = ( -0.05, 2.55, math.ceil( -vspacing * (MAX_SAVE + runtime_data.MAX_AUTOSAVE + runtime_data.MAX_QUICKSAVE) / 2.0), vspacing / 2) SAVE_CANVAS_SIZE = (-0.05, 2.55, math.ceil(-vspacing * MAX_SAVE / 2.0),
from direct.gui.OnscreenText import OnscreenText from direct.gui.DirectFrame import DirectFrame from direct.gui.DirectButton import DirectButton from direct.gui.DirectScrolledFrame import DirectScrolledFrame from runtime_data import game_settings from sogal_form import SogalForm,SogalDialog from gui.layout import HLayout,VLayout import gui.color_themes as color_themes from sogal_form import ConfirmDialog import runtime_data WHEELUP = PGButton.getReleasePrefix() + MouseButton.wheelUp().getName() + '-' WHEELDOWN = PGButton.getReleasePrefix() + MouseButton.wheelDown().getName() + '-' WHEELLEFT = PGButton.getReleasePrefix() + MouseButton.wheelLeft().getName() + '-' WHEELRIGHT = PGButton.getReleasePrefix() + MouseButton.wheelRight().getName() + '-' #pos = (-0.57,0,0.67) MAX_SAVE = 200 hspacing = 1.33 vspacing = 0.4 FRAMESIZE = (-1.35,1.35,-0.95,0.95) LOAD_CANVAS_SIZE = (-0.05,2.55,math.ceil( -vspacing*(MAX_SAVE +runtime_data.MAX_AUTOSAVE + runtime_data.MAX_QUICKSAVE)/2.0 ) ,vspacing/2) SAVE_CANVAS_SIZE = (-0.05,2.55,math.ceil(-vspacing*MAX_SAVE/2.0) ,vspacing/2) LOAD_ROLL_SPEED = -LOAD_CANVAS_SIZE[2]/5100.0 SAVE_ROLL_SPEED = -SAVE_CANVAS_SIZE[2]/5100.0 AUTO_HIDE_SCROLLBARS = True class SavingInfo(object):