def __init__(self, phone, doneEvent=None): NodePath.__init__(self, aspect2d.attachNewNode('CatalogGUI')) DirectObject.__init__(self) CatalogGlobals.CatalogNodePath.find('**/CATALOG_GUI_BKGD').copyTo(self) self.setScale(CatalogGlobals.CatalogBKGDScale) self.phone = phone self.doneEvent = doneEvent self.arrowButtons = {} self.createArrowButtons() self.currentTab = None self.tabButtons = {} self.createTabButtons() self.radioButtons = [] # self.createRadioButtons() self.activePage = 0 self.gifting = -1 guiItems = loader.loadModel('phase_5.5/models/gui/catalog_gui') hangupGui = guiItems.find('**/hangup') hangupRolloverGui = guiItems.find('**/hangup_rollover') self.hangup = DirectButton(self, relief=None, pos=(2.28, 0, -1.3), image=[hangupGui, hangupRolloverGui, hangupRolloverGui, hangupGui], text=['', TTLocalizer.CatalogHangUp, TTLocalizer.CatalogHangUp], text_fg=Vec4(1), text_scale=0.07, text_pos=(0.0, 0.14), command=self.hangUp) guiItems.removeNode()
def __init__(self): DirectObject.__init__(self) self.pathSmoothening = False self.showWaypoints = True self.showCollisions = False self.accept("escape", sys.exit) self.__setupEnvironment() self.__setupCollisions() self.__setupGravity() self.__setupLevel() self.__setupTarget() self.__setupNPC() self.__setupCamera() self.__setupTasks() self.setKeymap() self.__NPC.pathSmoothening = self.pathSmoothening if(self.showWaypoints): print("Showing waypoints") for w in self.roomWaypoints: w.draw()
def __init__(self, name, worldNode, mapGeom): DirectObject.__init__(self) self.map = None self.worldNode = worldNode self.mapNode = NodePath(name) self.mapGeom = mapGeom.copyTo(self.mapNode) self.overlayNode = NodePath(name)
def __init__(self,gmap,gaming_zone): DirectObject.__init__(self) #gaming zone (used for mouse movement), as a tools.Rectangle self.gaming_zone=gaming_zone #actual camera node self.p3dcam=base.camera #what the cam is oriented to self._target=base.render.attachNewNode('GaminCam.target') #range=[0,1] between min and max closeness to ground self.level=.7 # #keys_down acts as a pool containing keys (+mouse buttons) currently down self.keys_down=[] update_list.append(self.update) #setup for mouse picking picker_node=CollisionNode('gcam_to_mouse_ray')#general collision node picker_node.setFromCollideMask(GeomNode.getDefaultCollideMask()) self.picker_ray=CollisionRay()#solid ray to attach to coll node picker_node.addSolid(self.picker_ray) self.picker_np=self.p3dcam.attachNewNode(picker_node)#attach this node to gcam self.collision_queue=CollisionHandlerQueue()#stores collisions self.collision_traverser=CollisionTraverser('gcam_traverser')#actual computer self.collision_traverser.addCollider(self.picker_np,self.collision_queue) base.cTrav=self.collision_traverser self.gmap=gmap #stack of states (state=pos+zoom) self.states_stack=[] #enable the cam to move according to keyboard and mouse self.move_enabled=True
def __init__( self, *args, **kwargs ): DirectObject.__init__( self ) # Default camera to base camera if None is specified self.camera = kwargs.pop( 'camera', base.camera ) # Default root node to render if None is specified self.rootNp = kwargs.pop( 'rootNp', render ) # Default root 2d node to render2d if None is specified self.root2d = kwargs.pop( 'root2d', render2d ) # Default root aspect 2d node to aspect2d if None is specified self.rootA2d = kwargs.pop( 'rootA2d', aspect2d ) # Default root pixel 2d node to pixel2d if None is specified self.rootP2d = kwargs.pop( 'rootP2d', pixel2d ) # Default win to base.win if None specified. self.win = kwargs.pop( 'win', base.win ) # Default mouse watcher node to base.win if None specified. self.mouseWatcherNode = kwargs.pop( 'mouseWatcherNode', base.mouseWatcherNode )
def __init__( self ): DirectObject.__init__( self ) self.keyMap = {} self.initKeys() self.baseNode = None self.watchNode = None self.rotating = False
def __init__(self, camera, parent): """Arguments: camera -- Camera to be used parent -- Aeroplane which the camera should follow """ self.notifier = DirectNotify().newCategory("azure-camera") self.camera = camera self.parent = parent # This gets replaced by a NodePath with all available cameras as # children and plane node as parent in createCamNodes() self.cameras = None #if parent.__class__.__name__ is not "Aeroplane": if not isinstance(self.parent, Aeroplane): raise ParamError, "Parent must be an Aeroplane instance, " + \ "but is %s" % type(self.parent) FSM.__init__(self, "PlaneCamera: %s" % self.parent.name) DirectObject.__init__(self) self.cameras = self.parent.node.find("cameras") if self.cameras.isEmpty(): self.createCamNodes() self.updateCamArray() self.sideview_direction = 0 # Set up the default camera self.setView("ThirdPerson")
def Kampf(self,spieler,gegner): """Startet einen Kampf zwischen Spieler und Gegner, bis einer der beiden keine Energie mehr hat Usereingaben sind moeglich wie Item oder Angriff""" aktion = "angriff" aktNr = 0 pos = [0,0] keyhandler = DirectObject() keyMap = {"angriff":0,"item":0} spieler = self.werteBerechnen(spieler) DirectObject.accept(keyhandler,"a", self.setKey, ["angriff",1]) DirectObject.accept(keyhandler,"i", self.setKey, ["item",1]) if (keyMap["angriff"]!=0): aktion = angriff if (keyMap["item"]!=0): aktion = item if spieler.energie <= 0: print "Spieler tot" self.active = False return [spieler,gegner] elif gegner.energie <= 0: print "Gegner besiegt" self.active = False return [spieler,gegner] print "Spieler greift an" self.eventhandleSpieler(aktion,spieler,gegner,aktNr,pos) aktion = "angriff" print "Gegner greift an" self.eventhandleGegner(spieler,gegner) self.anzeigen(spieler,gegner) self.active = True return [spieler,gegner]
def __init__(self): DirectObject.__init__(self) self.data = dict() for key in POLLKEYS: self.accept( key, self.event, [key, True] ) self.accept( key+"-up", self.event, [key, False] ) self.data[key] = False
def __init__(self): DirectObject.__init__(self) self.base = ShowBase() resolution = (1024, 768) wp = WindowProperties() wp.setSize(int(resolution[0]), int(resolution[1])) wp.setOrigin(0, 0) self.base.win.requestProperties(wp) # depth completely doesn't matter for this, since just 2d, and no layers self.depth = 0 self.base.setBackgroundColor(115 / 255, 115 / 255, 115 / 255) # set up a 2d camera camera = self.base.camList[0] lens = OrthographicLens() lens.setFilmSize(int(resolution[0]), int(resolution[1])) lens.setNearFar(-100, 100) camera.node().setLens(lens) camera.reparentTo(self.base.render) self.accept("escape", sys.exit) # spread out some positions self.positions = [(-200, 0, -200), (0, 0, -200), (200, 0, -200), (-200, 0, 0), (0, 0, 0), (200, 0, 0), (-200, 0, 200), (0, 0, 200), (200, 0, 200)] self.all_smiles()
def __init__(self, level, showBase): DirectObject.__init__(self) self.showBase = showBase self.levelName = level mySound = base.loader.loadSfx("../resources/audio/Game Jam - Stefan Putzinger - Theme 02.wav") mySound.setVolume(0.5) mySound.play()
def __init__(self,*args,**kwargs): DirectObject.__init__(self) kwargs['fill']=165,255,121 kwargs['layout']=HLayout Frame.__init__(self,*args,**kwargs) self.read_keys_from_config() #'type','unit','conf' self.state='type' self.launch_btn=Button( pref_w=self.h*2, pref_h=self.h, p3dobject=DirectButton( geom=(self.resources['cancel_btn']), borderWidth=(0,0), command=self.cancel), parent=self) self.accept(self.keys['cancel']+'-up',self.cancel) #graphical aspect: [cancel_btn | unit_type_panel | unit_selection_panel | unit_configuration_panel | launch_btn] self.type_pan=UnitTypePanel(self) self.type_pan.focus() self.sel_pan=UnitSelectionPanel(self) self.sel_pan.request('Blank') self.conf_pan=UnitConfigurationPanel(self) self.conf_pan.request('Blank') Spacer(parent=self) self.launch_btn=Button( pref_w=self.h*2, pref_h=self.h, p3dobject=DirectButton(geom=(self.resources['launch_btn']), borderWidth=(0,0), command=self.launch_unit), parent=self) self.accept('enter-up',self.launch_unit) self.accept(self.keys['launch']+'-up',self.launch_unit) self.accept('mouse3-up',self.launch_unit)
def __init__(self, name): FSM.__init__(self, name) PandaNode.__init__(self, name) DirectObject.__init__(self) self.active = True self.lastClickState = PGButton.SReady self.clickState = PGButton.SReady self.__hovering = False self.clickEvent = '' self.clickExtraArgs = [] self.contents = NodePath.anyPath(self).attachNewNode('contents') # Create a MouseWatcherRegion: self.regionName = self.getUniqueName() + '-region' self.region = MouseWatcherRegion(self.regionName, 0, 0, 0, 0) base.mouseWatcherNode.addRegion(self.region) # Accept the mouse events: enterPattern = base.mouseWatcherNode.getEnterPattern() leavePattern = base.mouseWatcherNode.getLeavePattern() buttonDownPattern = base.mouseWatcherNode.getButtonDownPattern() buttonUpPattern = base.mouseWatcherNode.getButtonUpPattern() self.accept(enterPattern.replace('%r', self.regionName), self.__handleMouseEnter) self.accept(leavePattern.replace('%r', self.regionName), self.__handleMouseLeave) self.accept(buttonDownPattern.replace('%r', self.regionName), self.__handleMouseDown) self.accept(buttonUpPattern.replace('%r', self.regionName), self.__handleMouseUp)
def __init__(self, res = (32, 16), unwrap_state = 0.0, unwrap_target = 0.0, unwrap_time = 0.4, base_zoom = 0.02, base_zoom_max_dist = 1.0, camera_max_dist = 4.0, camera_min_dist = 0.15, camera_dist = 3.0, ): DirectObject.__init__(self) self.res = res self.unwrap_state = unwrap_state self.unwrap_target = unwrap_target self.unwrap_time = unwrap_time self.base_zoom = base_zoom self.base_zoom_max_dist = base_zoom_max_dist self.camera_max_dist = camera_max_dist self.camera_min_dist = camera_min_dist self.camera_dist = camera_dist # Bases base.taskMgr.add(self.refresh_geosphere, 'refresh_geosphere', sort = 10) self.bases = [] self.connections = [] # Camera management base.camera.set_pos(0, -10, 0) base.camera.look_at(0, 0, 0) self.camera_position = [0.5, 0.8] self.camera_movement = [0.0, 0.0] self.camera_distance = 3.0 self.camera_controlled = False
def __init__(self): DirectObject.__init__(self) base.disableMouse() self.default() self.accept('1',self.front) self.accept('2',self.top) self.accept('0',self.default)
def __init__(self, version='n/a'): DirectObject.__init__(self) self.backgroundNodePath = render2d.attachNewNode('background', 0) self.backgroundModel = loader.loadModel( 'phase_3/models/gui/loading-background.bam') self.backgroundModel.reparentTo(self.backgroundNodePath) self.backgroundNodePath.find('**/fg').removeNode() self.backgroundNodePath.setScale(1, 1, 1) self.logo = OnscreenImage( parent=base.a2dTopCenter, image='phase_3/maps/toontown-logo.png', scale=(1.0, 1, 0.5), pos=(0, 0, -0.85)) self.logo.setTransparency(TransparencyAttrib.MAlpha) self.label = OnscreenText( TTLocalizer.ClickToStartLabel, parent=base.a2dBottomCenter, font=ToontownGlobals.getMinnieFont(), fg=Vec4(1, 1, 1, 1), scale=0.1, align=TextNode.ACenter) self.label.setZ(0.35) self.versionLabel = OnscreenText( '\x01white_shadow\x01%s\x02' % version, parent=base.a2dBottomRight, font=ToontownGlobals.getMinnieFont(), fg=Vec4(0, 0, 0, 1), scale=0.06, align=TextNode.ARight) self.versionLabel.setPos(-0.025, 0.025) self.setColorScale(Vec4(0, 0, 0, 0)) self.fadeTrack = None self.logoPosTrack = None self.logoScaleTrack = None self.labelPosTrack = None self.labelColorScaleTrack = None
def __init__(self, *args, **kwargs): NodePath.__init__(self, *args, **kwargs) DirectObject.__init__(self) self.scale_signal = Signal() self.reset()
def __init__(self): DirectObject.__init__(self) base.setBackgroundColor(0,0,0,1) self.gameStarted = 0 self.gamePaused = 0 self.timeLeft = 100 self.speed = 2 self.obstacle_count = 10 self.keyMap = {"left":0, "right":0, "forward":0, "backward":0, "cam-left":0, "cam-right":0} self.musicDir = {"intro":"", "playing_game":"", "game_over":""} self.acceptOnce('f1', self.startGame) self.accept("escape", sys.exit) self.accept("arrow_left", self.setKey, ["cam-left",1]) self.accept("arrow_right", self.setKey, ["cam-right",1]) self.accept("w", self.setKey, ["forward",1]) self.accept("a", self.setKey, ["left",1]) self.accept("s", self.setKey, ["backward", 1]) self.accept("d", self.setKey, ["right",1]) self.accept("arrow_left-up", self.setKey, ["cam-left",0]) self.accept("arrow_right-up", self.setKey, ["cam-right",0]) self.accept("w-up", self.setKey, ["forward",0]) self.accept("a-up", self.setKey, ["left",0]) self.accept("s-up", self.setKey, ["backward", 0]) self.accept("d-up", self.setKey, ["right",0]) # Songs self.loadSongs() self.showIntroPage()
def __init__(self, name, radius = 1, scrollFactor = 1, camera = base.cam, frame = Vec4(-1, 1, -1, 1), keepUpright = 0, mouseDownEvent = 'mouse1', mouseUpEvent = 'mouse1-up', *args, **kwargs): NodePath.__init__(self, name, *args, **kwargs) DirectObject.__init__(self) self._rNode = self.attachNewNode('rotateNode') self._setRadius(radius, False) self._setScrollFactor(scrollFactor, False) self._setCamera(camera, False) self._setFrame(frame, False) self._setKeepUpright(keepUpright) self._setMouseEvents(mouseDownEvent, mouseUpEvent) self.setRotateMode(0) self._setControlButtonState(0) self._setTiltLimit(25 * math.pi / 180, False) self.saveNorth() self._colBitMask = BitMask32(1 << 16) self._colNode = self.attachNewNode(CollisionNode(name + '-cNode')) self._colNode.node().addSolid(CollisionSphere(0, 0, 0, 1)) self._colNode.node().setIntoCollideMask(self._colBitMask) self._mouseEnabled = True self._initCollisions() self.geom_node_path = self.attachNewNode('arrow') self.geom_node_path.setBin('fixed', 100) self.geom_node_path.setDepthTest(0) self.geom_node_path.setTransparency(1) self.head_geom_node = GeomNode('head') self.head_geom_node_path = self.geom_node_path.attachNewNode(self.head_geom_node) self.tail_geom_node = GeomNode('tail') self.tail_geom_node_path = self.geom_node_path.attachNewNode(self.tail_geom_node) self._ballIval = None
def __init__(self): DirectObject.__init__(self) self.close=lambda:None #create main window base=ShowBase() __builtin__.base=base props = WindowProperties() #props.setTitle(ConfigVariableString('win-title').getValue()) props.setFullscreen(ConfigVariableBool('fullscreen').getValue()) props.setSize(ConfigVariableInt('win-width').getValue(),ConfigVariableInt('win-height').getValue()) base.win.requestProperties(props) self.width=base.win.getXSize() self.height=base.win.getYSize() print 'size=',self.width,'x',self.height self.accept('window-event',self.on_resize) base.disableMouse() #set fps limit globalClock=ClockObject.getGlobalClock() globalClock.setMode(ClockObject.MLimited) globalClock.setFrameRate(ConfigVariableDouble('clock-frame-rate').getValue()) __builtin__.screen=self __builtin__.gui=pixel2d.attachNewNode('Screen.gui') #gui is the node for 2d rendering, scaled to the screen resolution, #with origin at bottom-left, and max at top-right gui.setZ(gui,-self.height) __builtin__.console=Console(print_messenger_events=False) __builtin__.out=console.out console.request('Open') __builtin__.mouse=base.pointerWatcherNodes[0] #is used as a stack. stores frames showed to the user (top at the front of the screen) self.frames=[]
def __init__( self, name, size=Vec2(512, 512) * 2.0, camAspectRatio=1.0, clearColor=Vec4(0.84999999999999998, 0.84999999999999998, 0.84999999999999998, 1.0), sceneGraph=None, ): DirectObject.__init__(self) self.name = name self.size = size if not sceneGraph: self._SceneBuffer__sceneGraph = NodePath(self.name + "-render") else: self._SceneBuffer__sceneGraph = sceneGraph self.camera = self._SceneBuffer__sceneGraph.attachNewNode(Camera(self.name + "camera")) self.camNode = self.camera.node() self.camLens = PerspectiveLens() self.camLens.setFov(30, 30) self.camNode.setLens(self.camLens) self._SceneBuffer__texture = Texture(self.name) self._SceneBuffer__buffer = None self._SceneBuffer__createBuffer() self.accept("close_main_window", self._SceneBuffer__destroyBuffer) self.accept("open_main_window", self._SceneBuffer__createBuffer)
def __init__(self, cr = None): DirectObject.__init__(self) self.cr = cr self.centralHood = TTCHood(self.cr) self.homeHood = HomeHood() self.minigameHood = MinigameHood(self.cr) self.progressScreen = ToontownProgressScreen()
def __init__(self): DirectObject.__init__(self) self.sound = {} self.sound['death'] = loader.loadSfx('arena/sound/invisibility.wav') self.music = {} self.music['complex'] = loader.loadMusic('arena/music/The Complex.mp3') self.currentMusic = None
def __init__(self): DirectObject.__init__(self) self.accept("escape", self.quit) self.lastConnection = None self.cManager = QueuedConnectionManager() self.cListener = QueuedConnectionListener(self.cManager, 0) self.cReader = QueuedConnectionReader(self.cManager, 0) self.cWriter = ConnectionWriter(self.cManager,0) self.tcpSocket = self.cManager.openTCPServerRendezvous(SERVER_PORT, 1) self.cListener.addConnection(self.tcpSocket) taskMgr.add(self.listenTask, "serverListenTask", -40) taskMgr.add(self.readTask, "serverReadTask", -39) self.gameLogic = GameLogic() self.gameLogic.delegate = self; blackmaker = CardMaker("blackmaker") blackmaker.setColor(0,0,0,1) blackmaker.setFrame(-1.0, 1.0, -1.0, 1.0) instcard = NodePath(blackmaker.generate()) instcard.reparentTo(render2d) self.screenText = OnscreenText(text="Server started ...\n", style=1, fg=(1,1,1,1), pos=(-1.31, 0.925), scale = .06) self.screenText.setAlign(0)
def __init__(self, cline): # DiOb init DirectObject.__init__(self) # Stash the relavant stuff from the GUI self.cline = cline self.stack = [] # What are we doing, after all? self.commands = { "r": ("Build Room", { "c": ("Corridor", self.build_corridor), "b": ("Baggage Area", self.build_corridor), "t": ("Toilets", self.build_corridor), }), "b": ("Build Item", { "r": ("Runway", { "1": ("1km Runway", self.build_corridor), "2": ("2km Runway", self.build_corridor), }), "b": ("Baggage Area", self.build_corridor), "t": ("Toilets", self.build_corridor), }), } # Attach to a lot of signals for char in "brtc12": self.accept(char, (lambda char: lambda: self.letter_down(char))(char)) # Python scope fix.
def __init__(self, url): DirectObject.__init__(self) self.url = URLSpec(url) self.image = None # Create a condition variable so we can block on load. self.cvar = threading.Condition() self.done = False # Create an initial 1x1 white texture. self.tex = Texture(Filename(self.url.getPath()).getBasename()) p = PNMImage(1, 1) p.fill(0.5, 0.5, 1) self.tex.load(p) if self.url.getScheme() == 'maze': # Here's a special case: instead of querying an HTTP # server, we get the local poster data from the maze # object. self.loadPlayerPoster() elif self.url.getScheme() == '': # Another special case: this is a local file. This should # only happen from the local player. self.loadLocalPoster() else: # Otherwise, we get the poster data from the internet. self.loadingTask = taskMgr.add(self.load, 'loadPoster', taskChain = 'loadPoster')
def __init__(self, gsg = None, limit = None): DirectObject.__init__(self) self.name = 'tex-mem%s' % TexMemWatcher.NextIndex TexMemWatcher.NextIndex += 1 self.cleanedUp = False self.top = 1.0 self.quantize = 1 self.maxHeight = base.config.GetInt('tex-mem-max-height', 300) self.totalSize = 0 self.placedSize = 0 self.placedQSize = 0 if gsg is None: gsg = base.win.getGsg() elif isinstance(gsg, GraphicsOutput): gsg = gsg.getGsg() self.gsg = gsg size = ConfigVariableInt('tex-mem-win-size', '300 300') origin = ConfigVariableInt('tex-mem-win-origin', '100 100') self.winSize = (size[0], size[1]) name = 'Texture Memory' props = WindowProperties() props.setOrigin(origin[0], origin[1]) props.setSize(*self.winSize) props.setTitle(name) props.setFullscreen(False) props.setUndecorated(False) fbprops = FrameBufferProperties.getDefault() flags = GraphicsPipe.BFFbPropsOptional | GraphicsPipe.BFRequireWindow self.pipe = None moduleName = base.config.GetString('tex-mem-pipe', '') if moduleName: self.pipe = base.makeModulePipe(moduleName) if not self.pipe: self.pipe = base.pipe self.win = base.graphicsEngine.makeOutput(self.pipe, name, 0, fbprops, props, flags) self.win.setSort(10000) self.win.setClearColorActive(False) self.win.setClearDepthActive(False) eventName = '%s-window' % self.name self.win.setWindowEvent(eventName) self.accept(eventName, self.windowEvent) self.accept('graphics_memory_limit_changed', self.graphicsMemoryLimitChanged) self.mouse = base.dataRoot.attachNewNode(MouseAndKeyboard(self.win, 0, '%s-mouse' % self.name)) bt = ButtonThrower('%s-thrower' % self.name) self.mouse.attachNewNode(bt) bt.setPrefix('button-%s-' % self.name) self.accept('button-%s-mouse1' % self.name, self.mouseClick) self.setupGui() self.setupCanvas() self.background = None self.nextTexRecordKey = 0 self.rollover = None self.isolate = None self.isolated = None self.needsRepack = False updateInterval = base.config.GetDouble('tex-mem-update-interval', 0.5) self.task = taskMgr.doMethodLater(updateInterval, self.updateTextures, 'TexMemWatcher') self.setLimit(limit) return
def __init__(self, mg): DirectObject.__init__(self) self.actualAvatar = base.localAvatar self.beansCollected = 0 self.moneyGui = None self.mg = mg self.toonFPS = FactorySneakGameToonFPS(mg) return
def __init__(self): DirectObject.__init__(self) self.collisionRay = CollisionRay() self.collisionNode = CollisionNode('mouseray') self.collisionNode.set_into_collide_mask(0) self.collisionNode.addSolid(self.collisionRay) self.collisionNodePath = base.camera.attachNewNode(self.collisionNode) base.cTrav.addCollider(self.collisionNodePath,base.collisionHandlerEvent)
def __init__(self): DirectObject.__init__(self) # No avatar yet. self.av = None # No pellets either. self.pellets = [] # The list of keys that we will be monitoring. self.moveKeyList = [ 'arrow_left', 'arrow_right', 'arrow_up', 'arrow_down' ] # Initially, all keys are up. Construct a dictionary that # maps each of the above keys to False, and hang the event to # manage that state. self.moveKeys = {} for key in self.moveKeyList: self.moveKeys[key] = False self.accept(key, self.moveKeyStateChanged, extraArgs = [key, True]) self.accept(key + '-up', self.moveKeyStateChanged, extraArgs = [key, False]) tcpPort = base.config.GetInt('server-port', 4400) hostname = base.config.GetString('server-host', '127.0.0.1') self.url = URLSpec('http://%s:%s' % (hostname, tcpPort)) self.cr = MyClientRepository() self.cr.connect([self.url], successCallback = self.connectSuccess, failureCallback = self.connectFailure) self.waitingText = OnscreenText( 'Connecting to %s.\nPress ESC to cancel.' % (self.url), scale = 0.1, fg = (1, 1, 1, 1), shadow = (0, 0, 0, 1)) self.accept('escape', self.escape) # Oobe mode is handy to have on all the time. Why not? base.oobe()
def __init__(self, name, nametag=None): PandaNode.__init__(self, name) DirectObject.__init__(self) self.fsm = ClassicFSM(name, [ State('off', self.enterOff, self.exitOff), State('rollover', self.enterRollover, self.exitRollover), State('ready', self.enterReady, self.exitReady), State('depressed', self.enterDepressed, self.exitDepressed), State('inactive', self.enterInactive, self.exitInactive) ], 'off', 'off') self.fsm.enterInitialState() self.nametag = nametag self.avatar = None self.active = True self.lastClickState = PGButton.SReady self.clickState = PGButton.SReady self.__hovering = False self.clickEvent = '' self.clickExtraArgs = [] self.contents = NodePath.anyPath(self).attachNewNode('contents') # Create a MouseWatcherRegion: self.regionName = self.getUniqueName() + '-region' self.region = MouseWatcherRegion(self.regionName, 0, 0, 0, 0) base.mouseWatcherNode.addRegion(self.region) # Accept the mouse events: enterPattern = base.mouseWatcherNode.getEnterPattern() leavePattern = base.mouseWatcherNode.getLeavePattern() buttonDownPattern = base.mouseWatcherNode.getButtonDownPattern() buttonUpPattern = base.mouseWatcherNode.getButtonUpPattern() self.accept(enterPattern.replace('%r', self.regionName), self.__handleMouseEnter) self.accept(leavePattern.replace('%r', self.regionName), self.__handleMouseLeave) self.accept(buttonDownPattern.replace('%r', self.regionName), self.__handleMouseDown) self.accept(buttonUpPattern.replace('%r', self.regionName), self.__handleMouseUp)
def __init__(self, name, radius=1, scrollFactor=1, camera=base.cam, frame=Vec4(-1, 1, -1, 1), keepUpright=0, mouseDownEvent='mouse1', mouseUpEvent='mouse1-up', *args, **kwargs): NodePath.__init__(self, name, *args, **args) DirectObject.__init__(self) self._rNode = self.attachNewNode('rotateNode') self._setRadius(radius, False) self._setScrollFactor(scrollFactor, False) self._setCamera(camera, False) self._setFrame(frame, False) self._setKeepUpright(keepUpright) self._setMouseEvents(mouseDownEvent, mouseUpEvent) self.setRotateMode(0) self._setControlButtonState(0) self._setTiltLimit(25 * math.pi / 180, False) self.saveNorth() self._colBitMask = BitMask32(1 << 16) self._colNode = self.attachNewNode(CollisionNode(name + '-cNode')) self._colNode.node().addSolid(CollisionSphere(0, 0, 0, 1)) self._colNode.node().setIntoCollideMask(self._colBitMask) self._mouseEnabled = True self._initCollisions() self.geom_node_path = self.attachNewNode('arrow') self.geom_node_path.setBin('fixed', 100) self.geom_node_path.setDepthTest(0) self.geom_node_path.setTransparency(1) self.head_geom_node = GeomNode('head') self.head_geom_node_path = self.geom_node_path.attachNewNode( self.head_geom_node) self.tail_geom_node = GeomNode('tail') self.tail_geom_node_path = self.geom_node_path.attachNewNode( self.tail_geom_node) self._ballIval = None
def __init__(self): DirectObject.__init__(self) base.setBackgroundColor(0, 0, 0) disclaimerText = "Project Altis is a not-for-profit fanmade parody made under Fair Use. Project Altis is not affiliated with The Walt Disney Company and/or the Disney Interactive Media Group (collectively referred to as \"Disney\") by clicking I agree you hereby agree that you acknowledge this fact." self.disclaimer = OnscreenText(text=disclaimerText, font=ToontownGlobals.getMinnieFont(), style=3, wordwrap=30, scale=.08, pos=(0, .3, 0)) gui = loader.loadModel('phase_3/models/gui/tt_m_gui_mat_mainGui.bam') yesUp = gui.find('**/tt_t_gui_mat_okUp') yesDown = gui.find('**/tt_t_gui_mat_okDown') noUp = gui.find('**/tt_t_gui_mat_closeUp') noDown = gui.find('**/tt_t_gui_mat_closeDown') self.accept = DirectButton(parent=aspect2d, relief=None, image=(yesUp, yesDown, yesUp), image_scale=(0.6, 0.6, 0.6), image1_scale=(0.7, 0.7, 0.7), image2_scale=(0.7, 0.7, 0.7), text=('', 'I Agree', 'I Agree'), text_pos=(0, -0.175), text_style=3, text_scale=0.08, pos=(.4, 0, -.5), command=self.accept) self.deny = DirectButton(parent=aspect2d, relief=None, image=(noUp, noDown, noUp), image_scale=(0.6, 0.6, 0.6), image1_scale=(0.7, 0.7, 0.7), image2_scale=(0.7, 0.7, 0.7), text=('', 'I Disagree', 'I Disagree'), text_pos=(0, -0.175), text_style=3, text_scale=0.08, pos=(-.4, 0, -.5), command=self.deny)
def __init__(self, callback): NodePath.__init__(self, 'thump') DirectObject.__init__(self) self.geom = self.attachNewNode(self.cm.generate()) self.geom.setP(-90) self.geom.setTransparency(1) self.geom.setDepthWrite(0) self.geom.setDepthTest(0) self.geom.setBin('shadow', 0) self.geom.setTexture(loader.loadTexture('phase_4/maps/shockwave.jpg', 'phase_4/maps/shockwave_a.rgb')) self.collisionName = 'thumpCollide-%d' % id(self) self.collision = self.attachNewNode(CollisionNode(self.collisionName)) csphere = CollisionSphere(0,0,0,1) csphere.setTangible(0) self.collision.node().addSolid(csphere) self.collision.node().setIntoCollideMask(ToontownGlobals.WallBitmask) self.callback = callback
def __init__(self): DirectObject.__init__(self) self.collisionSphere = CollisionSphere(0, 0, 0, 1) self.collisionNode = CollisionNode('pandaren') self.collisionNode.setCollideMask(BitMask32.bit(1)) self.collisionNode.addSolid(self.collisionSphere) self.collisionNodePath = render.attachNewNode(self.collisionNode) self.collisionNodePath.setPos(9, -5, 1) self.actor = Actor("arena/pandaren/panda", {"walk": "arena/pandaren/panda-walk"}) self.actor.setScale(0.2, 0.2, 0.2) self.actor.setPos(0, 0.3, -1) self.actor.reparentTo(self.collisionNodePath) self.actor.loop("walk") self.actor.showThrough() LerpPosInterval(self.collisionNodePath, 10, Point3(9, 5, 1)).loop() LerpHprInterval(self.collisionNodePath, 5, Vec3(360, 0, 0)).loop() base.cTrav.addCollider(self.collisionNodePath, base.collisionHandlerEvent) self.accept('mouseray-i-pandaren', self.collideIn) self.accept('mouseray-o-pandaren', self.collideOut)
def __init__(self, air): DirectObject.__init__(self) self.air = air self.invading = False self.start = 0 self.remaining = 0 self.total = 0 self.suitDeptIndex = None self.suitTypeIndex = None self.flags = 0 self.accept('startInvasion', self.handleStartInvasion) self.accept('stopInvasion', self.handleStopInvasion) # We want to handle shard status queries so that a ShardStatusReceiver # being created after we're created will know where we're at: self.accept('queryShardStatus', self.sendInvasionStatus) self.accept('requestShards', self.sendRequestResponse) self.sendInvasionStatus()
def __init__(self, version='n/a'): DirectObject.__init__(self) self.backgroundNodePath = render2d.attachNewNode('background', 0) self.backgroundModel = loader.loadModel( 'phase_3/models/gui/loading-background.bam') self.backgroundModel.reparentTo(self.backgroundNodePath) self.backgroundNodePath.find('**/fg').removeNode() self.backgroundNodePath.setScale(1, 1, 1) self.logo = OnscreenImage(parent=base.a2dTopCenter, image='phase_3/maps/toontown-logo.png', scale=(1.0, 1, 0.5), pos=(0, 0, -0.85)) self.logo.setTransparency(TransparencyAttrib.MAlpha) self.label = OnscreenText(TTLocalizer.ClickToStartLabel, parent=base.a2dBottomCenter, font=ToontownGlobals.getMinnieFont(), fg=Vec4(1, 1, 1, 1), scale=0.1, align=TextNode.ACenter) self.label.setZ(0.35) self.versionLabel = OnscreenText('\x01white_shadow\x01%s\x02' % version, parent=base.a2dBottomRight, font=ToontownGlobals.getMinnieFont(), fg=Vec4(0, 0, 0, 1), scale=0.06, align=TextNode.ARight) self.versionLabel.setPos(-0.025, 0.025) self.setColorScale(Vec4(0, 0, 0, 0)) self.fadeTrack = None self.logoPosTrack = None self.logoScaleTrack = None self.labelPosTrack = None self.labelColorScaleTrack = None
def __init__(self, parent, customNodeMap={}, customExporterMap={}): DirectObject.__init__(self) fn = Filename.fromOsSpecific(os.path.dirname(__file__)) fn.makeTrueCase() self.icon_dir = str(fn) + "/" loadPrcFileData("", f"model-path {self.icon_dir}") # # NODE VIEW # self.viewNP = aspect2d.attachNewNode("viewNP") self.viewNP.setScale(0.5) # # NODE MANAGER # self.nodeMgr = NodeManager(self.viewNP, customNodeMap) # Drag view self.mouseSpeed = 1 self.mousePos = None self.startCameraMovement = False # Box select # variables to store the start and current pos of the mousepointer self.startPos = LPoint2f(0, 0) self.lastPos = LPoint2f(0, 0) # variables for the to be drawn box self.boxCardMaker = CardMaker("SelectionBox") self.boxCardMaker.setColor(1, 1, 1, 0.25) self.box = None # # MENU BAR # self.mainView = MainView(parent, customNodeMap, customExporterMap) self.enable_editor()
def __init__(self, _cWriter, _cManager, _cReader): DirectObject.__init__(self) # notify self.notify = directNotify.newCategory("level_holder") # so we can send messages self.messager = Messager(_cWriter, _cManager, _cReader, self) # Create stuff we don't want to keep recreating because of their permanence self.players = {} self.day = 0 self.killer = False self.red_room = 0 self.vfs = VirtualFileSystem.getGlobalPtr() # these are used in nearly every level, just keep it loaded self.vfs.mount(Filename("mf/pawns.mf"), ".", VirtualFileSystem.MFReadOnly) self.vfs.mount(Filename("mf/timer.mf"), ".", VirtualFileSystem.MFReadOnly) # console self.console = None self.accept("`", self.pressed_tilda) # Levels self.levels = { MAINMENU: MainMenuLevel(self), LOBBY: LobbyLevel(self), DAY: DayLevel(self), NIGHT: NightLevel(self) } # Set active level self.active_level = MAINMENU self.levels[self.active_level].create() atexit.register(self.exit_game) self.notify.debug("[__init__] Created level_holder")
def __init__(self, interpreter_locals={}): DirectObject.__init__(self) self.gui_window = ConsoleGUI(self) BufferingInterpreter.__init__( self, lambda mode, data: self.gui_window.write(data, mode), locals=interpreter_locals) self.window = base.win self.visible = False self.gui_window.set_visible(self.visible) self.accept("toggle_console", self.toggle_visibility) #self.accept("window-event", self.window_event) self.fake_io = FakeIO() self.history = [] self.color_stack = False lorem_ipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec rhoncus velit sit amet dolor auctor consequat. Donec pretium lectus sed tortor pharetra tristique. Aliquam vel pharetra ligula. Sed eget neque quis velit imperdiet molestie. Cras a sapien vitae ligula maximus tincidunt. Aenean sit amet felis velit. Fusce consectetur ante lacinia nunc varius tristique. Pellentesque sollicitudin vehicula dictum. Nulla auctor erat placerat blandit molestie. Donec quam enim, vestibulum at elit id, elementum vestibulum nulla. In nec efficitur magna. Morbi facilisis ante non nulla fermentum, quis commodo mauris elementum. Pellentesque rutrum tellus purus, quis posuere velit tincidunt in." banner = "Python console. Have fun!" self.set_write_mode("font_color_banner") self.write(banner) self.flush()
def __init__(self): DirectObject.__init__(self) self.collisionSphere = CollisionSphere(0, 0, 0, 1) self.collisionNode = CollisionNode('frowney') self.collisionNode.setCollideMask(BitMask32.bit(1)) self.collisionNode.addSolid(self.collisionSphere) self.collisionNodePath = render.attachNewNode(self.collisionNode) self.collisionNodePath.setPos(13, 10, 1) base.cTrav.addCollider(self.collisionNodePath, base.collisionHandlerEvent) self.model = loader.loadModel('arena/balls/frowney') self.model.reparentTo(self.collisionNodePath) self.model.setScale(1, 1, 1) self.model.showThrough() base.cTrav.addCollider(self.collisionNodePath, base.collisionHandlerEvent) self.accept('mouseray-i-frowney', self.collideIn) self.accept('mouseray-o-frowney', self.collideOut) self.interval = LerpHprInterval(self.collisionNodePath, 1, Vec3(-360, 0, 0)) self.interval.loop()
def __init__(self, parent_node, width=0.3, height=0.21, x=0, y=0, line_spacing=0.02, text_scale=0.01, n_lines=9, bg_color=(1, 1, 1, 0), fg_color=(1, 1, 1, 1), text_x=0.005, text_y=0.025): DirectObject.__init__(self) self.node = parent_node.attach_new_node("text log node") self.width = width self.height = height self.x = x self.y = y self.text_x = text_x self.text_y = text_y self.line_spacing = line_spacing self.text_scale = text_scale self.frame = Frame(parent_node=self.node, color=(0, 0, 0, 0.6), width=self.width, height=self.height) self.frame.frame.set_bin('fixed', 30) font = MainFont() self.entry_node = self.node.attach_new_node("entry node") self.text_nodes = [] # create node for each line of text, so it can be displaced when resizing the window for i in range(n_lines): self.text_nodes.append(self.node.attach_new_node(f"text node {i}")) # lines of text that are going to be displayed in the terminal self.lines_queue = ["" for i in range(n_lines)] self.direct_labels = [] for i in range(n_lines): self.direct_labels.append( DirectLabel( text=self.lines_queue[i], text_align=TextNode.ALeft, text_font=font, text_fg=fg_color, text_bg=bg_color, frameColor=bg_color, parent=self.text_nodes[i], ) ) self.accept("aspectRatioChanged", self.aspect_ratio_change_update)
def __init__(self, base): self.base = base DirectObject.__init__(self) # joystick js_count = 0 self.joystick = None if pygame: pygame.init() js_count = pygame.joystick.get_count() if js_count > 1: raise NotImplementedError("More than one Joystick is connected") elif js_count == 1: self.joystick = pygame.joystick.Joystick(0) print 'using joystick' self.joystick.init() # print self.joystick.get_numaxes() # threshold for joystick self.threshold = 0.1 else: print 'Not using a joystick' self.key_map = {'r': None, 'f': None} self.setup_inputs()
def input_init(self): self.DO = DirectObject() self.DO.accept('mouse1', self.mouse_click, ["1-down"]) self.DO.accept('mouse1-up', self.mouse_click, ["1-up"]) self.DO.accept('mouse3', self.mouse_click, ["3-down"]) self.DO.accept('0', self.placement_ghost.change_player, [0]) self.DO.accept('1', self.placement_ghost.change_player, [1]) self.DO.accept('2', self.placement_ghost.change_player, [2]) self.DO.accept('a', self.placement_ghost.change_type, ["army"]) self.DO.accept('t', self.placement_ghost.change_type, ["tower"]) self.DO.accept('control-s', base.xml_manager.save) self.DO.accept('mray-into-army', self.col_in_object) self.DO.accept('mray-out-army', self.col_out_object) self.DO.accept('mray-into-tower', self.col_in_object) self.DO.accept('mray-out-tower', self.col_out_object) self.DO.accept('ray_again_all', self.col_against_object)
def __init__(self, i): DirectObject.__init__(self) self.collisionSphere = CollisionSphere(0, 0, 0, 1) self.collisionNode = CollisionNode('spider' + i) self.collisionNode.setIntoCollideMask(BitMask32.bit(1)) self.collisionNode.addSolid(self.collisionSphere) self.collisionNodePath = render.attachNewNode(self.collisionNode) self.collisionNodePath.setPos(0, 9, 1) base.cTrav.addCollider(self.collisionNodePath, base.collisionHandlerEvent) self.actor = Actor( "arena/spider/spider", { "walk": "arena/spider/spider-walk", "run": "arena/spider/spider-run", "death": "arena/spider/spider-death" }) self.actor.setScale(0.4, 0.4, 0.9) self.actor.setPos(-0.3, -0.2, -1) self.actor.reparentTo(self.collisionNodePath) self.actor.loop("run") self.accept('sonic-i-spider' + i, self.die) self.accept('tails-i-spider' + i, self.die)
def __init__(self, avatarList, parentFSM, doneEvent): DirectObject.__init__(self) self.toonList = { i: (i in [x.position for x in avatarList]) for i in xrange(6) } self.avatarList = avatarList self.selectedToon = 0 self.doneEvent = doneEvent self.jumpIn = None self.background2d = OnscreenImage( image='phase_3.5/maps/loading/toon.jpg', parent=aspect2d) self.background2d.setScale(2, 1, 1) self.background2d.setBin('background', 1) self.background2d.setTransparency(1) self.background2d.setColorScale(.6, .1, .1, 0) # self.optionsMgr = PickAToonOptions.PickAToonOptions() self.optionsMgr = PickAToonOptions.NewPickAToonOptions( ) # This is for the revamped options screen self.shardPicker = ShardPicker.ShardPicker() self.buttonList = [] self.quitConfirmation = DMenuQuit.DMenuQuit()
def __init__(self): NodePath.__init__(self, 'VineSpider') DirectObject.__init__(self) pos = Point3(0, 0, 0) serialNum = 0 gameId = 0 self.serialNum = serialNum gameAssets = loader.loadModel('phase_4/models/minigames/vine_game') spider2 = gameAssets.find('**/spider_3') spider1 = gameAssets.find('**/spider_2') seqNode = SequenceNode('spider') seqNode.addChild(spider1.node()) seqNode.addChild(spider2.node()) seqNode.setFrameRate(2) seqNode.loop(False) self.spiderModel = self.attachNewNode(seqNode) self.spiderModel.reparentTo(self) gameAssets.removeNode() self.spiderModelIcon = self.attachNewNode('spiderIcon') self.spiderModel.copyTo(self.spiderModelIcon) regularCamMask = BitMask32.bit(0) self.spiderModelIcon.hide(regularCamMask) self.spiderModelIcon.show(VineGameGlobals.RadarCameraBitmask) self.spiderModel.setScale(0.2) self.spiderModelIcon.setScale(0.75) self.setPos(-100, 0, 0) center = Point3(0, 0, 0) self.sphereName = 'spiderSphere-%s-%s' % (gameId, self.serialNum) self.collSphere = CollisionSphere(center[0], center[1], center[2], self.RADIUS) self.collSphere.setTangible(0) self.collNode = CollisionNode(self.sphereName) self.collNode.setIntoCollideMask(VineGameGlobals.SpiderBitmask) self.collNode.addSolid(self.collSphere) self.collNodePath = self.attachNewNode(self.collNode) self.collNodePath.hide() self.accept('enter' + self.sphereName, self._VineSpider__handleEnterSphere) self.reparentTo(render)
def __init__(self): DirectObject.__init__(self) self.collisionPlane = CollisionPlane( Plane(Vec3(0, 0, 1), Point3(0, 0, 0))) self.collisionNode = CollisionNode('ground') self.collisionNode.addSolid(self.collisionPlane) self.collisionNode.setCollideMask(BitMask32.bit(2)) self.collisionNodePath = render.attachNewNode(self.collisionNode) base.cTrav.addCollider(self.collisionNodePath, base.collisionHandlerEvent) self.model = loader.loadModel("arena/environment/environment") self.model.setTwoSided(True) self.model.reparentTo(self.collisionNodePath) self.model.setScale(0.035, 0.035, 0.035) self.model.setPos(-0.7, 5.7, -0.1) self.model.showThrough() self.model.findAllMatches("**/TreeTrunk*").hide() self.model.findAllMatches("**/Cylinder*").hide() self.model.findAllMatches("**/Rock*").hide() self.model.findAllMatches("**/Bamboo*").hide() self.model.findAllMatches("**/Branch*").hide() self.model.findAllMatches("**/Plane*").hide()
def __init__(self, main): DirectObject.__init__(self) self.showbase = main self.status = OnscreenText(text="", pos=Vec3(0, -0.35, 0), scale=0.05, fg=(1, 0, 0, 1), align=TextNode.ACenter, mayChange=True) self.background = DirectFrame( frameSize=(-1, 1, -1, 1), frameTexture='media/gui/mainmenu/menu.png', parent=self.showbase.render2d, ) self.title = OnscreenText(text='Main Menu', fg=(1, 1, 1, 1), parent=self.background, pos=(-0.6, 0.1), scale=0.06) self.buttons = [] controlButtons = Vec3(-0.60, 0, -0.79) # Toggle ready p = controlButtons + Vec3(-0.25, 0, 0) self.toggleReadyButton = DirectButton( text='Ready/Unready', pos=p, scale=0.048, relief=DGG.GROOVE, command=self.toggleReady, ) self.ready = False self.showbase.users = []
def __init__(self, interestMgr, name, doneEvent=None, recurse=True, start=True, mustCollect=False, doCollectionMgr=None): DirectObject.__init__(self) self._interestMgr = interestMgr if doCollectionMgr is None: doCollectionMgr = interestMgr self._doCollectionMgr = doCollectionMgr self._eGroup = EventGroup(name, doneEvent=doneEvent) self._doneEvent = self._eGroup.getDoneEvent() self._gotEvent = False self._recurse = recurse if self._recurse: # this will hold a dict of parentId to set(zoneIds) that are closing self.closingParent2zones = {} if start: self.startCollect(mustCollect)
def initPlayerAbilities(self): DO = DirectObject() DO.accept('1', self.fireAbility, [1]) DO.accept('2', self.fireAbility, [2]) DO.accept('3', self.fireAbility, [3]) DO.accept('4', self.fireAbility, [4]) self.abilityDict = {'offensive':1, 'defensive':1, 'evasive':1, 'area':1}
def __init__(self, base): DirectObject.__init__(self) self.base = base GUISystem.gui_system = self # Register events self.accept("window-event", self.handle_window) self.accept("mouse1", self.handle_left_mouse_pressed) self.accept("mouse1-up", self.handle_left_mouse_released) self.accept("mouse3", self.handle_right_mouse_pressed) self.accept("mouse3-up", self.handle_right_mouse_released) self.base.buttonThrowers[0].node().setKeystrokeEvent("keystroke") self.accept("keystroke", self.handle_keystroke) self.accept("backspace", self.handle_backspace) self.accept("backspace-repeat", self.handle_backspace) self.accept("arrow_left", self.handle_arrow_left) self.accept("arrow_left-repeat", self.handle_arrow_left) self.accept("arrow_right", self.handle_arrow_right) self.accept("arrow_right-repeat", self.handle_arrow_right) self.accept("delete", self.handle_delete) self.accept("delete-repeat", self.handle_delete) self.accept("enter", self.handle_enter) # Update GUIUtils GUIUtils.window_width = self.base.win.getXSize() GUIUtils.window_height = self.base.win.getYSize() # Set up GUI components self.window = GUIWindow() self.window.add_render() self.target_component = self.window # the target is the component the cursor is currently over self.focus_component = self.window # the focus component is the component that's currently focused self.drag_component = self.window # the drag component is the component that's being dragged # Set up mouse polling self.cursor_x = 0 self.cursor_y = 0 self.addTask(self.poll_cursor)
def __init__(self, air, zoneId=None, flags=MONITOR_DELETION | MONITOR_ZONE_CHANGE | MONITOR_HEALTH | MONITOR_CRASHED): DirectObject.__init__(self) self.air = air # We want to have a useful notifier name so we can easily identify where issues are arising from. self.notify = directNotify.newCategory('{0}::AvatarWatcher'.format( self.__class__.__name__)) # This is a list of the avatar ids we're watching. self.watchingAvatarIds = [] self.avId2instance = {} # This is the zone ID we're working in. self.zoneId = zoneId # These are the flags we're working with. self.flags = flags assert self.air != None, "Must have a valid pointer to AI!"
def __init__(self, phone, doneEvent=None): NodePath.__init__(self, aspect2d.attachNewNode('CatalogGUI')) DirectObject.__init__(self) CatalogGlobals.CatalogNodePath.find('**/CATALOG_GUI_BKGD').copyTo(self) self.setScale(CatalogGlobals.CatalogBKGDScale) self.phone = phone self.doneEvent = doneEvent self.arrowButtons = {} self.createArrowButtons() self.currentTab = None self.tabButtons = {} self.createTabButtons() self.radioButtons = [] # self.createRadioButtons() self.activePage = 0 self.gifting = -1 guiItems = loader.loadModel('phase_5.5/models/gui/catalog_gui') hangupGui = guiItems.find('**/hangup') hangupRolloverGui = guiItems.find('**/hangup_rollover') self.hangup = DirectButton( self, relief=None, pos=(2.28, 0, -1.3), image=[hangupGui, hangupRolloverGui, hangupRolloverGui, hangupGui], text=['', TTLocalizer.CatalogHangUp, TTLocalizer.CatalogHangUp], text_fg=Vec4(1), text_scale=0.07, text_pos=(0.0, 0.14), command=self.hangUp) guiItems.removeNode()
def __init__(self): DirectObject.__init__(self) self.filename = None self.unsaved = False self.idGenerator = IDGenerator() self.world = None self.isOpen = False self.gsg = None self.page = None self.shaderGenerator = None self.numlights = 0 # Each document has its own message bus, task manager, and event manager. self.taskMgr = TaskManager() self.taskMgr.mgr = AsyncTaskManager("documentTaskMgr") self.messenger = Messenger(self.taskMgr) self.eventMgr = EventManager(messenger=self.messenger, taskMgr=self.taskMgr) self.messenger.setEventMgr(self.eventMgr) self.render = NodePath("docRender") self.render.setAttrib(LightRampAttrib.makeIdentity()) #self.render.setShaderAuto() self.viewportMgr = ViewportManager(self) self.toolMgr = ToolManager(self) self.selectionMgr = SelectionManager(self) self.actionMgr = ActionManager(self) # Create the page that the document is viewed in. self.page = DocumentWindow(self) #self.createShaderGenerator() self.toolMgr.addTools() self.eventMgr.restart()
def __init__(self, *args, **kwargs): DirectObject.__init__(self) # Default camera to base camera if None is specified self.camera = kwargs.pop('camera', base.camera) # Default root node to render if None is specified self.rootNp = kwargs.pop('rootNp', render) # Default root 2d node to render2d if None is specified self.root2d = kwargs.pop('root2d', render2d) # Default root aspect 2d node to aspect2d if None is specified self.rootA2d = kwargs.pop('rootA2d', aspect2d) # Default root pixel 2d node to pixel2d if None is specified self.rootP2d = kwargs.pop('rootP2d', pixel2d) # Default win to base.win if None specified. self.win = kwargs.pop('win', base.win) # Default mouse watcher node to base.win if None specified. self.mouseWatcherNode = kwargs.pop('mouseWatcherNode', base.mouseWatcherNode)
def __init__(self, name): FSM.state = '_Off' # Hacky bug fix for Panda3D 1.11. FSM.__init__(self, name) PandaNode.__init__(self, name) DirectObject.__init__(self) self.active = True self.lastClickState = PGButton.SReady self.clickState = PGButton.SReady self.__hovering = False self.clickEvent = '' self.clickExtraArgs = [] self.contents = NodePath.anyPath(self).attachNewNode('contents') # Create a MouseWatcherRegion: self.regionName = self.getUniqueName() + '-region' self.region = MouseWatcherRegion(self.regionName, 0, 0, 0, 0) base.mouseWatcherNode.addRegion(self.region) # Accept the mouse events: enterPattern = base.mouseWatcherNode.getEnterPattern() leavePattern = base.mouseWatcherNode.getLeavePattern() buttonDownPattern = base.mouseWatcherNode.getButtonDownPattern() buttonUpPattern = base.mouseWatcherNode.getButtonUpPattern() self.accept(enterPattern.replace('%r', self.regionName), self.__handleMouseEnter) self.accept(leavePattern.replace('%r', self.regionName), self.__handleMouseLeave) self.accept(buttonDownPattern.replace('%r', self.regionName), self.__handleMouseDown) self.accept(buttonUpPattern.replace('%r', self.regionName), self.__handleMouseUp)
def __init__(self): QtWidgets.QMainWindow.__init__(self) DirectObject.__init__(self) self.dockLocations = { "right": QtCore.Qt.RightDockWidgetArea, "left": QtCore.Qt.LeftDockWidgetArea, "top": QtCore.Qt.TopDockWidgetArea, "bottom": QtCore.Qt.BottomDockWidgetArea } from bsp.leveleditor.ui.mainwindow import Ui_LevelEditor self.ui = Ui_LevelEditor() self.ui.setupUi(self) self.setWindowTitle(LEGlobals.AppName) base.leftBar = self.ui.leftBar base.statusBar = self.ui.statusbar self.selectedLabel = self.addPaneLabel(300, "No selection.") self.coordsLabel = self.addPaneLabel(100) self.zoomLabel = self.addPaneLabel(90) self.gridSnapLabel = self.addPaneLabel(135) self.fpsLabel = self.addPaneLabel(135) self.toolBar = self.ui.leftBar self.toolBar.setIconSize(QtCore.QSize(48, 48)) base.toolBar = self.toolBar base.menuBar = self.ui.menubar self.docArea = self.ui.documentArea base.docArea = self.docArea self.docArea.subWindowActivated.connect(self.__docActivated)
def __init__(self, cam=None): PandaNode.__init__(self, 'popup') DirectObject.__init__(self) self.__mwn = NametagGlobals.mouseWatcher self.__name = 'clickregion-%d' % id(self) self.__cam = cam self.__region = MouseWatcherRegion(self.__name, 0, 0, 0, 0) self.__mwn.addRegion(self.__region) self.__disabled = False self.__clicked = False self.__hovered = False self.__onscreen = False self.__clickState = 0 self.__clickArgs = [] self.__clickEvent = '' self.accept(self.__getEvent(self.__mwn.getEnterPattern()), self.__mouseEnter) self.accept(self.__getEvent(self.__mwn.getLeavePattern()), self.__mouseLeave) self.accept(self.__getEvent(self.__mwn.getButtonDownPattern()), self.__buttonDown) self.accept(self.__getEvent(self.__mwn.getButtonUpPattern()), self.__buttonUp)