def _press_select(self, gamepad=False): base.assume_gamepad = gamepad if self._selected is None: self._press_down() else: self.buttons[self._selected]['command']() DGG.getDefaultClickSound().play()
def load(self): guiModel = loader.loadModel('phase_3/models/gui/tt_m_gui_ups_logo_noText') leftLocator = guiModel.find('**/bubbleLeft_locator') rightLocator = guiModel.find('**/bubbleRight_locator') haveFunNode = TextNode('Have Fun') haveFunNode.setText(TTLocalizer.TeaserHaveFun) haveFunNode.setTextColor(0, 0, 0, 1) haveFunNode.setWordwrap(6) haveFunNode.setAlign(TextNode.ACenter) haveFunNode.setFont(DirectGuiGlobals.getDefaultFont()) haveFun = NodePath(haveFunNode) haveFun.reparentTo(rightLocator) haveFun.setScale(TTLocalizer.TPhaveFun) JoinUsNode = TextNode('Join Us') JoinUsNode.setText(TTLocalizer.TeaserJoinUs) JoinUsNode.setTextColor(0, 0, 0, 1) JoinUsNode.setWordwrap(6) JoinUsNode.setAlign(TextNode.ACenter) JoinUsNode.setFont(DirectGuiGlobals.getDefaultFont()) JoinUs = NodePath(JoinUsNode) JoinUs.reparentTo(leftLocator) JoinUs.setPos(0, 0, -0.025) JoinUs.setScale(TTLocalizer.TPjoinUs) for page in PageOrder: textInfo = Pages.get(page) textInfo = textInfo[0] + TTLocalizer.TeaserDefault panel = DirectFrame(parent=self, relief=None, image=guiModel, image_scale=(0.65, 0.65, 0.65), image_pos=(0, 0, 0.0), text_align=TextNode.ACenter, text=textInfo, text_scale=TTLocalizer.TPpanel, text_pos=TTLocalizer.TPpanelPos) self.addItem(panel) guiModel.removeNode() return
def __init__(base): ShowBase.__init__(base) base.rootDirectory = os.getcwd() base.MainGlobals = MainGlobals base.tkinter = tkinter from gui import AddDialog from gui import AddText from loaders import FontLoader from loaders import GlobalsImporter from loaders import ZoneImporter from other import Database from other import FileIO base.AddDialog = AddDialog base.AddText = AddText base.Fonts = FontLoader base.Globals = GlobalsImporter base.Zones = ZoneImporter base.Database = Database base.FileIO = FileIO DirectGuiGlobals.setDefaultFontFunc( lambda: base.loadFont(base.MainGlobals.DefaultFontPath)) base.setDefaultBackgroundColor() base.disableMouse() base.existsList = [] if MainGlobals.DEBUGENABLED: base.commandCheck() base.currentZoneModule = None base.removeZoneExempt = False from other import Startup
def __init__(self): ShowBase.__init__(self) self.base = ShowBase DirectGuiGlobals.setDefaultFont( loader.loadFont(GameGlobals.InterfaceFont)) base.enableParticles() self.NEWintroButtons() #self.config = self.loadConfig() #self.debug = self.config["settings"]['want-debug-mode'] #print(self.debug) base.disableMouse() self.debug = True if self.debug: print("Debug mode enabled!") self.accept('f4', base.oobe) if __debug__: try: from src.debug.OTPInjectorDev import Injector self.injector = Injector() except ImportError: print("You don't have wxPython or psutil installed.") print("You need them to use the injector!") except: import traceback traceback.print_exc()
def initNametagGlobals(self): arrow = loader.loadModel('phase_3/models/props/arrow') card = loader.loadModel('phase_3/models/props/panel') speech3d = ChatBalloon(loader.loadModel('phase_3/models/props/chatbox')) thought3d = ChatBalloon(loader.loadModel('phase_3/models/props/chatbox_thought_cutout')) speech2d = ChatBalloon(loader.loadModel('phase_3/models/props/chatbox_noarrow')) chatButtonGui = loader.loadModel('phase_3/models/gui/chat_button_gui') NametagGlobals.setCamera(self.cam) NametagGlobals.setArrowModel(arrow) NametagGlobals.setNametagCard(card, VBase4(-0.5, 0.5, -0.5, 0.5)) if self.mouseWatcherNode: NametagGlobals.setMouseWatcher(self.mouseWatcherNode) NametagGlobals.setSpeechBalloon3d(speech3d) NametagGlobals.setThoughtBalloon3d(thought3d) NametagGlobals.setSpeechBalloon2d(speech2d) NametagGlobals.setThoughtBalloon2d(thought3d) NametagGlobals.setPageButton(PGButton.SReady, chatButtonGui.find('**/Horiz_Arrow_UP')) NametagGlobals.setPageButton(PGButton.SDepressed, chatButtonGui.find('**/Horiz_Arrow_DN')) NametagGlobals.setPageButton(PGButton.SRollover, chatButtonGui.find('**/Horiz_Arrow_Rllvr')) NametagGlobals.setQuitButton(PGButton.SReady, chatButtonGui.find('**/CloseBtn_UP')) NametagGlobals.setQuitButton(PGButton.SDepressed, chatButtonGui.find('**/CloseBtn_DN')) NametagGlobals.setQuitButton(PGButton.SRollover, chatButtonGui.find('**/CloseBtn_Rllvr')) rolloverSound = DirectGuiGlobals.getDefaultRolloverSound() if rolloverSound: NametagGlobals.setRolloverSound(rolloverSound) clickSound = DirectGuiGlobals.getDefaultClickSound() if clickSound: NametagGlobals.setClickSound(clickSound) NametagGlobals.setToon(self.cam) self.marginManager = MarginManager() self.margins = self.aspect2d.attachNewNode(self.marginManager, DirectGuiGlobals.MIDGROUND_SORT_INDEX + 1) mm = self.marginManager # TODO: Dynamicaly add more and reposition cells padding = 0.0225 # Order: Top to bottom self.leftCells = [ mm.addGridCell(0.2 + padding, -0.45, base.a2dTopLeft), # Above boarding groups mm.addGridCell(0.2 + padding, -0.9, base.a2dTopLeft), # 1 mm.addGridCell(0.2 + padding, -1.35, base.a2dTopLeft) # Below Boarding Groups ] # Order: Left to right self.bottomCells = [ mm.addGridCell(-0.87, 0.2 + padding, base.a2dBottomCenter), # To the right of the laff meter mm.addGridCell(-0.43, 0.2 + padding, base.a2dBottomCenter), # 1 mm.addGridCell(0.01, 0.2 + padding, base.a2dBottomCenter), # 2 mm.addGridCell(0.45, 0.2 + padding, base.a2dBottomCenter), # 3 mm.addGridCell(0.89, 0.2 + padding, base.a2dBottomCenter) # To the left of the shtiker book ] # Order: Bottom to top self.rightCells = [ mm.addGridCell(-0.2 - padding, -1.35, base.a2dTopRight), # Above the street map mm.addGridCell(-0.2 - padding, -0.9, base.a2dTopRight), # Below the friends list mm.addGridCell(-0.2 - padding, -0.45, base.a2dTopRight) # Behind the friends list ]
def initNametagGlobals(self): arrow = loader.loadModel('phase_3/models/props/arrow') card = loader.loadModel('phase_3/models/props/panel') speech3d = ChatBalloon( loader.loadModel('phase_3/models/props/chatbox')) thought3d = ChatBalloon( loader.loadModel('phase_3/models/props/chatbox_thought_cutout')) speech2d = ChatBalloon( loader.loadModel('phase_3/models/props/chatbox_noarrow')) chatButtonGui = loader.loadModel('phase_3/models/gui/chat_button_gui') NametagGlobals.setCamera(self.cam) NametagGlobals.setArrowModel(arrow) NametagGlobals.setNametagCard(card, VBase4(-0.5, 0.5, -0.5, 0.5)) if self.mouseWatcherNode: NametagGlobals.setMouseWatcher(self.mouseWatcherNode) NametagGlobals.setSpeechBalloon3d(speech3d) NametagGlobals.setThoughtBalloon3d(thought3d) NametagGlobals.setSpeechBalloon2d(speech2d) NametagGlobals.setThoughtBalloon2d(thought3d) NametagGlobals.setPageButton(PGButton.SReady, chatButtonGui.find('**/Horiz_Arrow_UP')) NametagGlobals.setPageButton(PGButton.SDepressed, chatButtonGui.find('**/Horiz_Arrow_DN')) NametagGlobals.setPageButton( PGButton.SRollover, chatButtonGui.find('**/Horiz_Arrow_Rllvr')) NametagGlobals.setQuitButton(PGButton.SReady, chatButtonGui.find('**/CloseBtn_UP')) NametagGlobals.setQuitButton(PGButton.SDepressed, chatButtonGui.find('**/CloseBtn_DN')) NametagGlobals.setQuitButton(PGButton.SRollover, chatButtonGui.find('**/CloseBtn_Rllvr')) rolloverSound = DirectGuiGlobals.getDefaultRolloverSound() if rolloverSound: NametagGlobals.setRolloverSound(rolloverSound) clickSound = DirectGuiGlobals.getDefaultClickSound() if clickSound: NametagGlobals.setClickSound(clickSound) NametagGlobals.setToon(self.cam) self.marginManager = MarginManager() self.margins = self.aspect2d.attachNewNode( self.marginManager, DirectGuiGlobals.MIDGROUND_SORT_INDEX + 1) mm = self.marginManager self.leftCells = [ mm.addGridCell(0.25, -0.6, base.a2dTopLeft), mm.addGridCell(0.25, -1.0, base.a2dTopLeft), mm.addGridCell(0.25, -1.4, base.a2dTopLeft) ] self.bottomCells = [ mm.addGridCell(0.4, 0.2, base.a2dBottomCenter), mm.addGridCell(-0.4, 0.2, base.a2dBottomCenter), mm.addGridCell(-1.0, 0.2, base.a2dBottomCenter), mm.addGridCell(1.0, 0.2, base.a2dBottomCenter) ] self.rightCells = [ mm.addGridCell(-0.25, -0.6, base.a2dTopRight), mm.addGridCell(-0.25, -1.0, base.a2dTopRight), mm.addGridCell(-0.25, -1.4, base.a2dTopRight) ]
def _press_up(self, gamepad=False): base.assume_gamepad = gamepad if self._selected is None: self._selected = len(self.buttons) - 1 else: self._unfocus_button(self._selected) self._selected = (self._selected - 1) % len(self.buttons) self._focus_button(self._selected) DGG.getDefaultRolloverSound().play()
def __init__(self): ShowBase.__init__(self) # Increase the texture resolution on DirectGui default_font = DirectGuiGlobals.getDefaultFont() default_font.clear() default_font.setPixelsPerUnit(64) DirectGuiGlobals.setDefaultFont(default_font) self.accept("f1", sys.exit) self.win.setCloseRequestEvent("f1") self.background = OnscreenImage(parent=self.render2dp, image="art/menu_background.png") self.cam2dp.node().getDisplayRegion(0).setSort(-20) # Setup camera self.disableMouse() self.camera.setPos(0, -5, 2.25) self.camera.setHpr(0, -10, 0) self.camLens.setFov(65) # Setup saves self.save_dir = os.path.join(appdirs.user_data_dir('ThorGame', roaming=True), 'saves') if not os.path.exists(self.save_dir): os.makedirs(self.save_dir) self.saved_trainer_ids = [i.split('.')[0] for i in os.listdir(self.save_dir)] # Setup UI self.ui = CEFPanda() src_dir = _file_dir template_folder = os.path.join(src_dir, 'ui') self.ui_env = Environment(loader=FileSystemLoader(template_folder), trim_blocks=True) # HACK - CEFPython requires a regular LoadURL before LoadString works, # so we just give it something to work on. This doesn't render nicely, # but we replace it immediately with the UI for the first GameState. # CEFPython issue: https://code.google.com/p/chromiumembedded/issues/detail?id=763 self.ui.load('ui/base.html') # Load monster data data_folder = os.path.join(src_dir, 'data') self.monster_data = [] for i in os.listdir(data_folder): if i.startswith('race'): with open(os.path.join(data_folder, i)) as f: self.monster_data.append(json.load(f)) # Setup the default player and monster self.player = Trainer(dont_save=True) self.player.monster = Monster.new_from_race("ogre") # Setup game states self.game_state = TitleState(self) self.taskMgr.add(self.main_loop, "MainLoop")
def initNametagGlobals(self): NametagGlobals.setMe(base.cam) NametagGlobals.setCardModel('phase_3/models/props/panel.bam') NametagGlobals.setArrowModel('phase_3/models/props/arrow.bam') NametagGlobals.setChatBalloon3dModel( 'phase_3/models/props/chatbox.bam') NametagGlobals.setChatBalloon2dModel( 'phase_3/models/props/chatbox_noarrow.bam') NametagGlobals.setThoughtBalloonModel( 'phase_3/models/props/chatbox_thought_cutout.bam') chatButtonGui = loader.loadModel( 'phase_3/models/gui/chat_button_gui.bam') NametagGlobals.setPageButton( chatButtonGui.find('**/Horiz_Arrow_UP'), chatButtonGui.find('**/Horiz_Arrow_DN'), chatButtonGui.find('**/Horiz_Arrow_Rllvr'), chatButtonGui.find('**/Horiz_Arrow_UP')) NametagGlobals.setQuitButton(chatButtonGui.find('**/CloseBtn_UP'), chatButtonGui.find('**/CloseBtn_DN'), chatButtonGui.find('**/CloseBtn_Rllvr'), chatButtonGui.find('**/CloseBtn_UP')) chatButtonGui.removeNode() rolloverSound = DirectGuiGlobals.getDefaultRolloverSound() if rolloverSound is not None: NametagGlobals.setRolloverSound(rolloverSound) clickSound = DirectGuiGlobals.getDefaultClickSound() if clickSound is not None: NametagGlobals.setClickSound(clickSound) self.marginManager = MarginManager() self.margins = self.aspect2d.attachNewNode( self.marginManager, DirectGuiGlobals.MIDGROUND_SORT_INDEX + 1) self.leftCells = [ self.marginManager.addCell(0.1, -0.6, self.a2dTopLeft, 1), self.marginManager.addCell(0.1, -1.0, self.a2dTopLeft, 2), self.marginManager.addCell(0.1, -1.4, self.a2dTopLeft, 3) ] self.bottomCells = [ self.marginManager.addCell(0.4, 0.1, self.a2dBottomCenter, 4), self.marginManager.addCell(-0.4, 0.1, self.a2dBottomCenter, 5), self.marginManager.addCell(-1.0, 0.1, self.a2dBottomCenter, 6), self.marginManager.addCell(1.0, 0.1, self.a2dBottomCenter, 7) ] self.rightCells = [ self.marginManager.addCell(-0.1, -0.6, self.a2dTopRight, 8), self.marginManager.addCell(-0.1, -1.0, self.a2dTopRight, 9), self.marginManager.addCell(-0.1, -1.4, self.a2dTopRight, 10) ]
def draw_set_font(font_name=None, font_size=None): if font_name is not None: fonts = DRAW_DATA.get("fonts") fonts.update({"_active": font_name}) if font_size is not None: fonts.update({"_size": font_size}) font = draw_get_font() DGG.setDefaultFont(font[0]) return font
def load(self): # load up the images # upsellModel = loader.loadModel("phase_3/models/gui/tt_m_gui_ups_mainGui") # guiModel = upsellModel.find("**/tt_t_gui_ups_logo_noBubbles") guiModel = loader.loadModel( "phase_3/models/gui/tt_m_gui_ups_logo_noText") leftLocator = guiModel.find("**/bubbleLeft_locator") rightLocator = guiModel.find("**/bubbleRight_locator") haveFunNode = TextNode("Have Fun") haveFunNode.setText(TTLocalizer.TeaserHaveFun) haveFunNode.setTextColor(0, 0, 0, 1) haveFunNode.setWordwrap(6) haveFunNode.setAlign(TextNode.ACenter) haveFunNode.setFont(DirectGuiGlobals.getDefaultFont()) haveFun = NodePath(haveFunNode) haveFun.reparentTo(rightLocator) haveFun.setScale(TTLocalizer.TPhaveFun) JoinUsNode = TextNode("Join Us") JoinUsNode.setText(TTLocalizer.TeaserJoinUs) JoinUsNode.setTextColor(0, 0, 0, 1) JoinUsNode.setWordwrap(6) JoinUsNode.setAlign(TextNode.ACenter) JoinUsNode.setFont(DirectGuiGlobals.getDefaultFont()) JoinUs = NodePath(JoinUsNode) JoinUs.reparentTo(leftLocator) JoinUs.setPos(0, 0, -0.025) JoinUs.setScale(TTLocalizer.TPjoinUs) # axis = loader.loadModel("models/misc/xyzAxis") # axis.reparentTo(guiModel) # make a panel for each feature for page in PageOrder: textInfo = Pages.get(page) textInfo = textInfo[0] + TTLocalizer.TeaserDefault panel = DirectFrame( parent=self, relief=None, image=guiModel, image_scale=(0.65, 0.65, 0.65), image_pos=(0, 0, 0.0), text_align=TextNode.ACenter, text=textInfo, text_scale=TTLocalizer.TPpanel, text_pos=TTLocalizer.TPpanelPos, ) self.addItem(panel) guiModel.removeNode()
def initNametagGlobals(self): NametagGlobals.setMe(base.cam) NametagGlobals.setCardModel('phase_3/models/props/panel.bam') NametagGlobals.setArrowModel('phase_3/models/props/arrow.bam') NametagGlobals.setChatBalloon3dModel('phase_3/models/props/chatbox.bam') NametagGlobals.setChatBalloon2dModel( 'phase_3/models/props/chatbox_noarrow.bam') NametagGlobals.setThoughtBalloonModel( 'phase_3/models/props/chatbox_thought_cutout.bam') chatButtonGui = loader.loadModel( 'phase_3/models/gui/chat_button_gui.bam') NametagGlobals.setPageButton( chatButtonGui.find('**/Horiz_Arrow_UP'), chatButtonGui.find('**/Horiz_Arrow_DN'), chatButtonGui.find('**/Horiz_Arrow_Rllvr'), chatButtonGui.find('**/Horiz_Arrow_UP')) NametagGlobals.setQuitButton( chatButtonGui.find('**/CloseBtn_UP'), chatButtonGui.find('**/CloseBtn_DN'), chatButtonGui.find('**/CloseBtn_Rllvr'), chatButtonGui.find('**/CloseBtn_UP')) chatButtonGui.removeNode() rolloverSound = DirectGuiGlobals.getDefaultRolloverSound() if rolloverSound is not None: NametagGlobals.setRolloverSound(rolloverSound) clickSound = DirectGuiGlobals.getDefaultClickSound() if clickSound is not None: NametagGlobals.setClickSound(clickSound) self.marginManager = MarginManager() self.margins = self.aspect2d.attachNewNode( self.marginManager, DirectGuiGlobals.MIDGROUND_SORT_INDEX + 1) self.leftCells = [ self.marginManager.addCell(0.1, -0.6, self.a2dTopLeft), self.marginManager.addCell(0.1, -1.0, self.a2dTopLeft), self.marginManager.addCell(0.1, -1.4, self.a2dTopLeft) ] self.bottomCells = [ self.marginManager.addCell(0.4, 0.1, self.a2dBottomCenter), self.marginManager.addCell(-0.4, 0.1, self.a2dBottomCenter), self.marginManager.addCell(-1.0, 0.1, self.a2dBottomCenter), self.marginManager.addCell(1.0, 0.1, self.a2dBottomCenter) ] self.rightCells = [ self.marginManager.addCell(-0.1, -0.6, self.a2dTopRight), self.marginManager.addCell(-0.1, -1.0, self.a2dTopRight), self.marginManager.addCell(-0.1, -1.4, self.a2dTopRight) ]
def initNametagGlobals(self): arrow = loader.loadModel('phase_3/models/props/arrow') card = loader.loadModel('phase_3/models/props/panel') speech3d = ChatBalloon(loader.loadModel('phase_3/models/props/chatbox')) thought3d = ChatBalloon(loader.loadModel('phase_3/models/props/chatbox_thought_cutout')) speech2d = ChatBalloon(loader.loadModel('phase_3/models/props/chatbox_noarrow')) chatButtonGui = loader.loadModel('phase_3/models/gui/chat_button_gui') NametagGlobals.setCamera(self.cam) NametagGlobals.setArrowModel(arrow) NametagGlobals.setNametagCard(card, VBase4(-0.5, 0.5, -0.5, 0.5)) if self.mouseWatcherNode: NametagGlobals.setMouseWatcher(self.mouseWatcherNode) NametagGlobals.setSpeechBalloon3d(speech3d) NametagGlobals.setThoughtBalloon3d(thought3d) NametagGlobals.setSpeechBalloon2d(speech2d) NametagGlobals.setThoughtBalloon2d(thought3d) NametagGlobals.setPageButton(PGButton.SReady, chatButtonGui.find('**/Horiz_Arrow_UP')) NametagGlobals.setPageButton(PGButton.SDepressed, chatButtonGui.find('**/Horiz_Arrow_DN')) NametagGlobals.setPageButton(PGButton.SRollover, chatButtonGui.find('**/Horiz_Arrow_Rllvr')) NametagGlobals.setQuitButton(PGButton.SReady, chatButtonGui.find('**/CloseBtn_UP')) NametagGlobals.setQuitButton(PGButton.SDepressed, chatButtonGui.find('**/CloseBtn_DN')) NametagGlobals.setQuitButton(PGButton.SRollover, chatButtonGui.find('**/CloseBtn_Rllvr')) rolloverSound = DirectGuiGlobals.getDefaultRolloverSound() if rolloverSound: NametagGlobals.setRolloverSound(rolloverSound) clickSound = DirectGuiGlobals.getDefaultClickSound() if clickSound: NametagGlobals.setClickSound(clickSound) NametagGlobals.setToon(self.cam) self.marginManager = MarginManager() self.margins = self.aspect2d.attachNewNode(self.marginManager, DirectGuiGlobals.MIDGROUND_SORT_INDEX + 1) mm = self.marginManager self.leftCells = [ mm.addGridCell(0.25, -0.6, base.a2dTopLeft), mm.addGridCell(0.25, -1.0, base.a2dTopLeft), mm.addGridCell(0.25, -1.4, base.a2dTopLeft) ] self.bottomCells = [ mm.addGridCell(0.4, 0.2, base.a2dBottomCenter), mm.addGridCell(-0.4, 0.2, base.a2dBottomCenter), mm.addGridCell(-1.0, 0.2, base.a2dBottomCenter), mm.addGridCell(1.0, 0.2, base.a2dBottomCenter) ] self.rightCells = [ mm.addGridCell(-0.25, -0.6, base.a2dTopRight), mm.addGridCell(-0.25, -1.0, base.a2dTopRight), mm.addGridCell(-0.25, -1.4, base.a2dTopRight) ]
def labelCells(self): if self.cellLabelParent: self.cellLabelParent.removeNode() self.cellLabelParent = self.attachNewNode('cellLabels') cw = self.cellWidth scale = cw / 10.0 dx = cw * self.gridSize * .5 font = DirectGuiGlobals.getDefaultFont() color = self.gridColor for i in range(self.gridSize): for j in range(self.gridSize): zoneId = self.startingZone + ((j * self.gridSize) + i) zoneStr = str(zoneId) textNode = TextNode(zoneStr) textNode.setText(zoneStr) textNode.setFont(font) textNode.setTextColor(color) textNode.setAlign(TextNode.ACenter) genTextNode = textNode.generate() textNodePath = self.cellLabelParent.attachNewNode( genTextNode) # Place the text node in the center of the cell textNodePath.setPosHprScale( (i * cw - dx) + (cw * 0.5), # x (j * cw - dx) + (cw * 0.5), # y GRID_Z_OFFSET + 3.0, # z # Lay them down flat 0, -90, 0, # hpr scale, scale, scale) self.cellLabelParent.flattenLight()
def labelCells(self): if self.cellLabelParent: self.cellLabelParent.removeNode() self.cellLabelParent = self.attachNewNode('cellLabels') cw = self.cellWidth scale = cw / 10.0 dx = cw * self.gridSize * .5 font = DirectGuiGlobals.getDefaultFont() color = self.gridColor for i in range(self.gridSize): for j in range(self.gridSize): zoneId = self.startingZone + ((j * self.gridSize) + i) zoneStr = str(zoneId) textNode = TextNode(zoneStr) textNode.setText(zoneStr) textNode.setFont(font) textNode.setTextColor(color) textNode.setAlign(TextNode.ACenter) genTextNode = textNode.generate() textNodePath = self.cellLabelParent.attachNewNode(genTextNode) # Place the text node in the center of the cell textNodePath.setPosHprScale((i * cw - dx) + (cw * 0.5), # x (j * cw - dx) + (cw * 0.5), # y GRID_Z_OFFSET+3.0, # z # Lay them down flat 0, -90, 0, # hpr scale, scale, scale) self.cellLabelParent.flattenLight()
def __init__(self): ShowBase.__init__(self) DirectGuiGlobals.setDefaultFont( loader.loadFont(GameGlobals.InterfaceFont)) self.accept('f4', base.oobe) if __debug__: try: from src.debug.OTPInjectorDev import Injector self.injector = Injector() except ImportError: print("You don't have wxPython or psutil installed.") print("You need them to use the injector!") except: import traceback traceback.print_exc() self.dia = Dialogue.Dialogue(ShowBase) self.dia.load()
def __init__(self, parent=None, **kw): optiondefs = ( # Define type of DirectGuiWidget ('pgFunc', PGButton, None), ('numStates', 4, None), ('state', DGG.NORMAL, None), ('relief', None, None), ('invertedFrames', (1, ), None), ('frameSize', (-1, 1, -1, 1), None), ('scale', 0.05, None), # Command to be called on button click ('command', None, None), ('extraArgs', [], None), # Which mouse buttons can be used to click the button ('commandButtons', (DGG.LMB, ), self.setCommandButtons), # Sounds to be used for button events ('rolloverSound', DGG.getDefaultRolloverSound(), self.setRolloverSound), ('clickSound', DGG.getDefaultClickSound(), self.setClickSound), # Can only be specified at time of widget contruction # Do the text/graphics appear to move when the button is clicked ('pressEffect', 1, DGG.INITOPT), ('uncheckedImage', 'ui/default/checkbox_unchecked.png', self.setUncheckedImage), ('checkedImage', 'ui/default/checkbox_checked.png', self.setCheckedImage), ('uncheckedGeom', None, None), ('checkedGeom', None, None), ('isChecked', False, self.renewgeom), ) # Merge keyword options with default options self.defineoptions(kw, optiondefs) DirectButton.__init__(self, parent) self.__checkstatedumpnp = NodePath('checkstatenp') self.initialiseoptions(SDirectCheckBox)
def __init__(self, parent = None, **kw): optiondefs = ( # Define type of DirectGuiWidget ('pgFunc', PGButton, None), ('numStates', 4, None), ('state', DGG.NORMAL, None), ('relief', None, None), ('invertedFrames', (1,), None), ('frameSize', (-1,1,-1,1),None), ('scale', 0.05, None), # Command to be called on button click ('command', None, None), ('extraArgs', [], None), # Which mouse buttons can be used to click the button ('commandButtons', (DGG.LMB,), self.setCommandButtons), # Sounds to be used for button events ('rolloverSound', DGG.getDefaultRolloverSound(), self.setRolloverSound), ('clickSound', DGG.getDefaultClickSound(), self.setClickSound), # Can only be specified at time of widget contruction # Do the text/graphics appear to move when the button is clicked ('pressEffect', 1, DGG.INITOPT), ('uncheckedImage', 'ui/default/checkbox_unchecked.png', self.setUncheckedImage), ('checkedImage', 'ui/default/checkbox_checked.png', self.setCheckedImage), ('uncheckedGeom', None, None), ('checkedGeom', None, None), ('isChecked', False, self.renewgeom), ) # Merge keyword options with default options self.defineoptions(kw, optiondefs) DirectButton.__init__(self,parent) self.__checkstatedumpnp = NodePath('checkstatenp') self.initialiseoptions(SDirectCheckBox)
def __init__(self): main_dir = core.ExecutionEnvironment.get_environment_variable( "MAIN_DIR") main_dir = core.Filename.from_os_specific(main_dir) core.load_prc_file(core.Filename(main_dir, "settings.prc")) ShowBase.__init__(self) self.disable_mouse() # Workaround for failure to load simplepbr shaders on macOS if getattr(sys, 'frozen', False) and sys.platform == 'darwin': simplepbr.__file__ = self.main_dir + '/' self.assume_gamepad = False DGG.setDefaultRolloverSound(loader.load_sfx('sfx/ui-a.ogg')) DGG.setDefaultClickSound(loader.load_sfx('sfx/ui-b.ogg')) base.setBackgroundColor((0, 0, 0, 1)) self.quality_menu = Menu('quality.', [ ('high.', self.setup_high), ('medium.', self.setup_medium), ('low.', self.setup_low), ('none.', self.setup_potato), ]) self.quality_menu.show() self.gamepads = set() for dev in self.devices.get_devices( core.InputDevice.DeviceClass.gamepad): self._device_connected(dev) self.assume_gamepad = False self.accept('connect-device', self._device_connected) self.accept('disconnect-device', self._device_disconnected)
base.transitions.IrisModelName = "phase_3/models/misc/iris.bam" base.transitions.FadeModelName = "phase_3/models/misc/fade.bam" base.setFrameRateMeter(False) base.accept("f9", base.screenshot, ["screenshots/screenshot"]) from direct.filter.CommonFilters import CommonFilters print "CIStart: Setting display preferences..." sm.applySettings(jsonfile) if base.win == None: print "CIStart: Unable to open window; aborting." sys.exit() else: print "CIStart: Successfully opened window." ConfigVariableDouble("decompressor-step-time").setValue(0.01) ConfigVariableDouble("extractor-step-time").setValue(0.01) DirectGuiGlobals.setDefaultFontFunc(CIGlobals.getToonFont) DirectGuiGlobals.setDefaultFont(CIGlobals.getToonFont()) DirectGuiGlobals.setDefaultRolloverSound(loader.loadSfx("phase_3/audio/sfx/GUI_rollover.mp3")) DirectGuiGlobals.setDefaultClickSound(loader.loadSfx("phase_3/audio/sfx/GUI_create_toon_fwd.mp3")) DirectGuiGlobals.setDefaultDialogGeom(loader.loadModel("phase_3/models/gui/dialog_box_gui.bam")) def maybeDoSomethingWithMusic(condition): width, height, fs, music, sfx, tex_detail, model_detail, aa, af = sm.getSettings(jsonfile) if condition == 0: if music == True: base.enableMusic(False) elif condition == 1: if music == True: base.enableMusic(True)
def __init__(self, doneEvent): self.doneEvent = doneEvent DirectFrame.__init__(self) self.reparentTo(aspect2d) self.setPos(0.0, 0.0, 0.16) self.stash() publicPartyGui = loader.loadModel( 'phase_4/models/parties/publicPartyGUI') self.frame = DirectFrame( parent=self, geom=publicPartyGui.find('**/activities_background'), geom_pos=(-0.80000000000000004, 0.0, 0.20000000000000001), geom_scale=2.0, relief=None) self.earnedLabel = DirectLabel( parent=self, relief=None, text=str(0), text_align=TextNode.ACenter, text_pos=(0.0, -0.070000000000000007), text_scale=0.20000000000000001, text_fg=(0.94999999999999996, 0.94999999999999996, 0.0, 1.0), text_font=ToontownGlobals.getSignFont(), textMayChange=True, image=DirectGuiGlobals.getDefaultDialogGeom(), image_scale=(0.33000000000000002, 1.0, 0.33000000000000002), pos=(-0.29999999999999999, 0.0, 0.20000000000000001), scale=0.90000000000000002) purchaseModels = loader.loadModel('phase_4/models/gui/purchase_gui') jarImage = purchaseModels.find('**/Jar') self.jarLabel = DirectLabel( parent=self, relief=None, text=str(0), text_align=TextNode.ACenter, text_pos=(0.0, -0.070000000000000007), text_scale=0.20000000000000001, text_fg=JellybeanRewardGui.JarLabelTextColor, text_font=ToontownGlobals.getSignFont(), textMayChange=True, image=jarImage, scale=0.69999999999999996, pos=(0.29999999999999999, 0.0, 0.17000000000000001)) purchaseModels.removeNode() del purchaseModels jarImage.removeNode() del jarImage self.messageLabel = DirectLabel(parent=self, relief=None, text='', text_align=TextNode.ALeft, text_wordwrap=16.0, text_scale=0.070000000000000007, pos=(-0.52000000000000002, 0.0, -0.10000000000000001), textMayChange=True) self.doubledJellybeanLabel = DirectLabel( parent=self, relief=None, text=TTLocalizer.PartyRewardDoubledJellybean, text_align=TextNode.ACenter, text_wordwrap=12.0, text_scale=0.089999999999999997, text_fg=(1.0, 0.125, 0.125, 1.0), pos=(0.0, 0.0, -0.46500000000000002), textMayChange=False) self.doubledJellybeanLabel.hide() self.closeButton = DirectButton( parent=self, relief=None, text=TTLocalizer.PartyJellybeanRewardOK, text_align=TextNode.ACenter, text_scale=0.065000000000000002, text_pos=(0.0, -0.625), geom=(publicPartyGui.find('**/startButton_up'), publicPartyGui.find('**/startButton_down'), publicPartyGui.find('**/startButton_rollover'), publicPartyGui.find('**/startButton_inactive')), geom_pos=(-0.39000000000000001, 0.0, 0.125), command=self._close) publicPartyGui.removeNode() del publicPartyGui self.countSound = base.loadSfx( 'phase_13/audio/sfx/tick_counter_short.mp3') self.overMaxSound = base.loadSfx( 'phase_13/audio/sfx/tick_counter_overflow.mp3')
def enterReward(self): numToons = 0 toonLayouts = ((2,), (1, 3), (0, 2, 4), (0, 1, 3, 4)) toonPositions = (5.0, 1.75, -0.25, -1.75, -5.0) self.toons = [] self.toonsKeep = [] self.counters = [] self.totalCounters = [] camera.reparentTo(render) base.camLens.setFov(ToontownGlobals.DefaultCameraFov) camera.setPos(0, 16.0, 2.0) camera.lookAt(0, 0, 0.75) base.transitions.irisIn(0.40000000000000002) self.title.reparentTo(aspect2d) self.foreground.reparentTo(render) self.backgroundL.reparentTo(render) self.backgroundR.reparentTo(render) self.sidewalk.reparentTo(render) self.door.reparentTo(render) size = 20 z = -2.5 floor = CollisionPolygon(Point3(-size, -size, z), Point3(size, -size, z), Point3(size, size, z), Point3(-size, size, z)) floor.setTangible(1) floorNode = CollisionNode('collision_floor') floorNode.addSolid(floor) self.collisionFloor = render.attachNewNode(floorNode) NametagGlobals.setOnscreenChatForced(1) for index in range(len(self.ids)): avId = self.ids[index] if self.states[index] != PURCHASE_NO_CLIENT_STATE and self.states[index] != PURCHASE_DISCONNECTED_STATE and avId in base.cr.doId2do: numToons += 1 toon = base.cr.doId2do[avId] toon.stopSmooth() self.toons.append(toon) self.toonsKeep.append(DelayDelete.DelayDelete(toon, 'Purchase.enterReward')) counter = DirectLabel(parent = hidden, relief = None, pos = (0.0, 0.0, 0.0), text = str(0), text_scale = 0.20000000000000001, text_fg = (0.94999999999999996, 0.94999999999999996, 0, 1), text_pos = (0, -0.10000000000000001, 0), text_font = ToontownGlobals.getSignFont()) counter['image'] = DGG.getDefaultDialogGeom() counter['image_scale'] = (0.33000000000000002, 1, 0.33000000000000002) counter.setScale(0.5) counter.count = 0 counter.max = self.pointsArray[index] self.counters.append(counter) money = self.playerMoney[index] totalCounter = DirectLabel(parent = hidden, relief = None, pos = (0.0, 0.0, 0.0), text = str(money), text_scale = 0.20000000000000001, text_fg = (0.94999999999999996, 0.94999999999999996, 0, 1), text_pos = (0, -0.10000000000000001, 0), text_font = ToontownGlobals.getSignFont(), image = self.jarImage) totalCounter.setScale(0.5) totalCounter.count = money totalCounter.max = toon.getMaxMoney() self.totalCounters.append(totalCounter) continue self.accept('clientCleanup', self._handleClientCleanup) pos = 0 toonLayout = toonLayouts[numToons - 1] for toon in self.toons: thisPos = toonPositions[toonLayout[pos]] toon.setPos(Vec3(thisPos, 1.0, -2.5)) toon.setHpr(Vec3(0, 0, 0)) toon.setAnimState('neutral', 1) toon.setShadowHeight(0) if not toon.isDisabled(): toon.reparentTo(render) self.counters[pos].setPos(thisPos * -0.17000000000000001, 0, toon.getHeight() / 10 + 0.25) self.counters[pos].reparentTo(aspect2d) self.totalCounters[pos].setPos(thisPos * -0.17000000000000001, 0, -0.82499999999999996) self.totalCounters[pos].reparentTo(aspect2d) pos += 1 self.maxPoints = max(self.pointsArray) if self.votesArray: self.maxVotes = max(self.votesArray) numToons = len(self.toons) self.voteMultiplier = TravelGameGlobals.PercentOfVotesConverted[numToons] / 100.0 self.maxBeansFromVotes = int(self.voteMultiplier * self.maxVotes) else: self.maxVotes = 0 self.maxBeansFromVotes = 0 def reqCountUp(state): self.countUp() return Task.done countUpDelay = DELAY_BEFORE_COUNT_UP taskMgr.doMethodLater(countUpDelay, reqCountUp, 'countUpTask') def reqCountDown(state): self.countDown() return Task.done countDownDelay = countUpDelay + COUNT_UP_DURATION + DELAY_AFTER_COUNT_UP taskMgr.doMethodLater(countDownDelay, reqCountDown, 'countDownTask') def celebrate(task): for counter in task.counters: counter.hide() winningPoints = max(task.pointsArray) for i in range(len(task.ids)): if task.pointsArray[i] == winningPoints: avId = task.ids[i] if base.cr.doId2do.has_key(avId): toon = base.cr.doId2do[avId] toon.setAnimState('jump', 1.0) base.cr.doId2do.has_key(avId) base.playSfx(task.celebrateSound) return Task.done celebrateDelay = countDownDelay + COUNT_DOWN_DURATION + DELAY_AFTER_COUNT_DOWN celebrateTask = taskMgr.doMethodLater(celebrateDelay, celebrate, 'celebrate') celebrateTask.counters = self.counters celebrateTask.pointsArray = self.pointsArray celebrateTask.ids = self.ids celebrateTask.celebrateSound = self.celebrateSound def reqCountVotesUp(state): self.countVotesUp() return Task.done def reqCountVotesDown(state): self.countVotesDown() return Task.done if self.metagameRound == TravelGameGlobals.FinalMetagameRoundIndex: countVotesUpDelay = celebrateDelay + DELAY_AFTER_CELEBRATE taskMgr.doMethodLater(countVotesUpDelay, reqCountVotesUp, 'countVotesUpTask') countVotesUpTime = self.maxVotes * COUNT_UP_RATE + DELAY_AFTER_COUNT_UP countVotesDownDelay = countVotesUpDelay + countVotesUpTime taskMgr.doMethodLater(countVotesDownDelay, reqCountVotesDown, 'countVotesDownTask') celebrateDelay += countVotesUpTime + self.maxVotes * COUNT_DOWN_RATE + DELAY_AFTER_COUNT_DOWN def reqPurchase(state): self.fsm.request('purchase') return Task.done purchaseDelay = celebrateDelay + DELAY_AFTER_CELEBRATE taskMgr.doMethodLater(purchaseDelay, reqPurchase, 'purchase-trans') if base.skipMinigameReward: self.fsm.request('purchase')
def initNametagGlobals(self): """ Should be called once during startup to initialize a few defaults for the Nametags. """ arrow = loader.loadModel('phase_3/models/props/arrow') card = loader.loadModel('phase_3/models/props/panel') speech3d = ChatBalloon(loader.loadModelNode('phase_3/models/props/chatbox')) thought3d = ChatBalloon(loader.loadModelNode('phase_3/models/props/chatbox_thought_cutout')) speech2d = ChatBalloon(loader.loadModelNode('phase_3/models/props/chatbox_noarrow')) chatButtonGui = loader.loadModel("phase_3/models/gui/chat_button_gui") NametagGlobals.setCamera(self.cam) NametagGlobals.setArrowModel(arrow) NametagGlobals.setNametagCard(card, VBase4(-0.5, 0.5, -0.5, 0.5)) if self.mouseWatcherNode: NametagGlobals.setMouseWatcher(self.mouseWatcherNode) NametagGlobals.setSpeechBalloon3d(speech3d) NametagGlobals.setThoughtBalloon3d(thought3d) NametagGlobals.setSpeechBalloon2d(speech2d) NametagGlobals.setThoughtBalloon2d(thought3d) NametagGlobals.setPageButton(PGButton.SReady, chatButtonGui.find("**/Horiz_Arrow_UP")) NametagGlobals.setPageButton(PGButton.SDepressed, chatButtonGui.find("**/Horiz_Arrow_DN")) NametagGlobals.setPageButton(PGButton.SRollover, chatButtonGui.find("**/Horiz_Arrow_Rllvr")) NametagGlobals.setQuitButton(PGButton.SReady, chatButtonGui.find("**/CloseBtn_UP")) NametagGlobals.setQuitButton(PGButton.SDepressed, chatButtonGui.find("**/CloseBtn_DN")) NametagGlobals.setQuitButton(PGButton.SRollover, chatButtonGui.find("**/CloseBtn_Rllvr")) rolloverSound = DirectGuiGlobals.getDefaultRolloverSound() if rolloverSound: NametagGlobals.setRolloverSound(rolloverSound) clickSound = DirectGuiGlobals.getDefaultClickSound() if clickSound: NametagGlobals.setClickSound(clickSound) # For now, we'll leave the Toon at the same point as the # camera. When we have a real toon later, we'll change it. NametagGlobals.setToon(self.cam) # We need a node to be the parent of all of the 2-d onscreen # messages along the margins. This should be in front of many # things, but not all things. self.marginManager = MarginManager() self.margins = \ self.aspect2d.attachNewNode(self.marginManager, DirectGuiGlobals.MIDGROUND_SORT_INDEX + 1) # And define a bunch of cells along the margins. mm = self.marginManager self.leftCells = [ mm.addGridCell(0, 1, base.a2dLeft, base.a2dRight, base.a2dBottom, base.a2dTop), mm.addGridCell(0, 2, base.a2dLeft, base.a2dRight, base.a2dBottom, base.a2dTop), mm.addGridCell(0, 3, base.a2dLeft, base.a2dRight, base.a2dBottom, base.a2dTop) ] self.bottomCells = [ mm.addGridCell(0.5, 0, base.a2dLeft, base.a2dRight, base.a2dBottom, base.a2dTop), mm.addGridCell(1.5, 0, base.a2dLeft, base.a2dRight, base.a2dBottom, base.a2dTop), mm.addGridCell(2.5, 0, base.a2dLeft, base.a2dRight, base.a2dBottom, base.a2dTop), mm.addGridCell(3.5, 0, base.a2dLeft, base.a2dRight, base.a2dBottom, base.a2dTop), mm.addGridCell(4.5, 0, base.a2dLeft, base.a2dRight, base.a2dBottom, base.a2dTop) ] self.rightCells = [ mm.addGridCell(5, 2, base.a2dLeft, base.a2dRight, base.a2dBottom, base.a2dTop), mm.addGridCell(5, 1, base.a2dLeft, base.a2dRight, base.a2dBottom, base.a2dTop) ]
import random import __builtin__ import gc gc.disable() try: launcher except: print 'Creating PiratesDummyLauncher' from pirates.launcher.PiratesDummyLauncher import PiratesDummyLauncher launcher = PiratesDummyLauncher() __builtin__.launcher = launcher from direct.gui import DirectGuiGlobals import PiratesGlobals DirectGuiGlobals.setDefaultFontFunc(PiratesGlobals.getInterfaceFont) launcher.setPandaErrorCode(7) from pandac.PandaModules import * import PiratesBase PiratesBase.PiratesBase() from direct.showbase.ShowBaseGlobal import * if base.config.GetBool('want-preloader', 0): base.preloader = PiratesPreloader.PiratesPreloader() if base.win == None: print 'Unable to open window; aborting.' sys.exit() launcher.setPandaErrorCode(0) launcher.setPandaWindowOpen() base.sfxPlayer.setCutoffDistance(500.0)
def __init__(self, doneEvent): self.doneEvent = doneEvent DirectFrame.__init__(self) self.reparentTo(aspect2d) self.setPos(0.0, 0.0, 0.16) self.stash() publicPartyGui = loader.loadModel('phase_4/models/parties/publicPartyGUI') self.frame = DirectFrame(parent=self, geom=publicPartyGui.find('**/activities_background'), geom_pos=(-0.8, 0.0, 0.2), geom_scale=2.0, relief=None) self.earnedLabel = DirectLabel(parent=self, relief=None, text=str(0), text_align=TextNode.ACenter, text_pos=(0.0, -0.07), text_scale=0.2, text_fg=(0.95, 0.95, 0.0, 1.0), text_font=ToontownGlobals.getSignFont(), textMayChange=True, image=DirectGuiGlobals.getDefaultDialogGeom(), image_scale=(0.33, 1.0, 0.33), pos=(-0.3, 0.0, 0.2), scale=0.9) purchaseModels = loader.loadModel('phase_4/models/gui/purchase_gui') jarImage = purchaseModels.find('**/Jar') self.jarLabel = DirectLabel(parent=self, relief=None, text=str(0), text_align=TextNode.ACenter, text_pos=(0.0, -0.07), text_scale=0.2, text_fg=JellybeanRewardGui.JarLabelTextColor, text_font=ToontownGlobals.getSignFont(), textMayChange=True, image=jarImage, scale=0.7, pos=(0.3, 0.0, 0.17)) purchaseModels.removeNode() del purchaseModels jarImage.removeNode() del jarImage self.messageLabel = DirectLabel(parent=self, relief=None, text='', text_align=TextNode.ALeft, text_wordwrap=16.0, text_scale=0.07, pos=(-0.52, 0.0, -0.1), textMayChange=True) self.doubledJellybeanLabel = DirectLabel(parent=self, relief=None, text=TTLocalizer.PartyRewardDoubledJellybean, text_align=TextNode.ACenter, text_wordwrap=12.0, text_scale=0.09, text_fg=(1.0, 0.125, 0.125, 1.0), pos=(0.0, 0.0, -0.465), textMayChange=False) self.doubledJellybeanLabel.hide() self.closeButton = DirectButton(parent=self, relief=None, text=TTLocalizer.PartyJellybeanRewardOK, text_align=TextNode.ACenter, text_scale=0.065, text_pos=(0.0, -0.625), geom=(publicPartyGui.find('**/startButton_up'), publicPartyGui.find('**/startButton_down'), publicPartyGui.find('**/startButton_rollover'), publicPartyGui.find('**/startButton_inactive')), geom_pos=(-0.39, 0.0, 0.125), command=self._close) publicPartyGui.removeNode() del publicPartyGui self.countSound = base.loadSfx('phase_13/audio/sfx/tick_counter_short.mp3') self.overMaxSound = base.loadSfx('phase_13/audio/sfx/tick_counter_overflow.mp3') return
def enterReward(self): numToons = 0 toonLayouts = ((2, ), (1, 3), (0, 2, 4), (0, 1, 3, 4)) toonPositions = (5.0, 1.75, -0.25, -1.75, -5.0) self.toons = [] self.toonsKeep = [] self.counters = [] self.totalCounters = [] camera.reparentTo(render) base.camLens.setFov(ToontownGlobals.DefaultCameraFov) camera.setPos(0, 16.0, 2.0) camera.lookAt(0, 0, 0.75) base.transitions.irisIn(0.4) self.title.reparentTo(aspect2d) self.foreground.reparentTo(render) self.backgroundL.reparentTo(render) self.backgroundR.reparentTo(render) self.sidewalk.reparentTo(render) self.door.reparentTo(render) size = 20 z = -2.5 floor = CollisionPolygon(Point3(-size, -size, z), Point3(size, -size, z), Point3(size, size, z), Point3(-size, size, z)) floor.setTangible(1) floorNode = CollisionNode('collision_floor') floorNode.addSolid(floor) self.collisionFloor = render.attachNewNode(floorNode) NametagGlobals.setOnscreenChatForced(1) for index in range(len(self.ids)): avId = self.ids[index] if self.states[index] != PURCHASE_NO_CLIENT_STATE and self.states[ index] != PURCHASE_DISCONNECTED_STATE and avId in base.cr.doId2do: numToons += 1 toon = base.cr.doId2do[avId] toon.stopSmooth() self.toons.append(toon) self.toonsKeep.append( DelayDelete.DelayDelete(toon, 'Purchase.enterReward')) counter = DirectLabel(parent=hidden, relief=None, pos=(0.0, 0.0, 0.0), text=str(0), text_scale=0.2, text_fg=(0.95, 0.95, 0, 1), text_pos=(0, -0.1, 0), text_font=ToontownGlobals.getSignFont()) counter['image'] = DGG.getDefaultDialogGeom() counter['image_scale'] = (0.33, 1, 0.33) counter.setScale(0.5) counter.count = 0 counter.max = self.pointsArray[index] self.counters.append(counter) money = self.playerMoney[index] totalCounter = DirectLabel( parent=hidden, relief=None, pos=(0.0, 0.0, 0.0), text=str(money), text_scale=0.2, text_fg=(0.95, 0.95, 0, 1), text_pos=(0, -0.1, 0), text_font=ToontownGlobals.getSignFont(), image=self.jarImage) totalCounter.setScale(0.5) totalCounter.count = money totalCounter.max = toon.getMaxMoney() self.totalCounters.append(totalCounter) self.accept('clientCleanup', self._handleClientCleanup) pos = 0 toonLayout = toonLayouts[numToons - 1] for toon in self.toons: thisPos = toonPositions[toonLayout[pos]] toon.setPos(Vec3(thisPos, 1.0, -2.5)) toon.setHpr(Vec3(0, 0, 0)) toon.setAnimState('neutral', 1) toon.setShadowHeight(0) if not toon.isDisabled(): toon.reparentTo(render) self.counters[pos].setPos(thisPos * -0.17, 0, toon.getHeight() / 10 + 0.25) self.counters[pos].reparentTo(aspect2d) self.totalCounters[pos].setPos(thisPos * -0.17, 0, -0.825) self.totalCounters[pos].reparentTo(aspect2d) pos += 1 self.maxPoints = max(self.pointsArray) if self.votesArray: self.maxVotes = max(self.votesArray) numToons = len(self.toons) self.voteMultiplier = TravelGameGlobals.PercentOfVotesConverted[ numToons] / 100.0 self.maxBeansFromVotes = int(self.voteMultiplier * self.maxVotes) else: self.maxVotes = 0 self.maxBeansFromVotes = 0 def reqCountUp(state): self.countUp() return Task.done countUpDelay = DELAY_BEFORE_COUNT_UP taskMgr.doMethodLater(countUpDelay, reqCountUp, 'countUpTask') def reqCountDown(state): self.countDown() return Task.done countDownDelay = countUpDelay + COUNT_UP_DURATION + DELAY_AFTER_COUNT_UP taskMgr.doMethodLater(countDownDelay, reqCountDown, 'countDownTask') def celebrate(task): for counter in task.counters: counter.hide() winningPoints = max(task.pointsArray) for i in range(len(task.ids)): if task.pointsArray[i] == winningPoints: avId = task.ids[i] if avId in base.cr.doId2do: toon = base.cr.doId2do[avId] toon.setAnimState('jump', 1.0) base.playSfx(task.celebrateSound) return Task.done celebrateDelay = countDownDelay + COUNT_DOWN_DURATION + DELAY_AFTER_COUNT_DOWN celebrateTask = taskMgr.doMethodLater(celebrateDelay, celebrate, 'celebrate') celebrateTask.counters = self.counters celebrateTask.pointsArray = self.pointsArray celebrateTask.ids = self.ids celebrateTask.celebrateSound = self.celebrateSound def reqCountVotesUp(state): self.countVotesUp() return Task.done def reqCountVotesDown(state): self.countVotesDown() return Task.done if self.metagameRound == TravelGameGlobals.FinalMetagameRoundIndex: countVotesUpDelay = celebrateDelay + DELAY_AFTER_CELEBRATE taskMgr.doMethodLater(countVotesUpDelay, reqCountVotesUp, 'countVotesUpTask') countVotesUpTime = self.maxVotes * COUNT_UP_RATE + DELAY_AFTER_COUNT_UP countVotesDownDelay = countVotesUpDelay + countVotesUpTime taskMgr.doMethodLater(countVotesDownDelay, reqCountVotesDown, 'countVotesDownTask') celebrateDelay += countVotesUpTime + self.maxVotes * COUNT_DOWN_RATE + DELAY_AFTER_COUNT_DOWN def reqPurchase(state): self.fsm.request('purchase') return Task.done purchaseDelay = celebrateDelay + DELAY_AFTER_CELEBRATE taskMgr.doMethodLater(purchaseDelay, reqPurchase, 'purchase-trans') if base.skipMinigameReward: self.fsm.request('purchase') return
while not launcher.getGame2Done(): time.sleep(pollingDelay) print 'ToontownStart: Game2 is finished.' print 'ToontownStart: Starting the game.' from pandac.PandaModules import * if launcher.isDummy(): http = HTTPClient() else: http = launcher.http tempLoader = PandaLoader() backgroundNode = tempLoader.loadSync( Filename('phase_3/models/gui/loading-background')) from direct.gui import DirectGuiGlobals print 'ToontownStart: setting default font' import ToontownGlobals DirectGuiGlobals.setDefaultFontFunc( ToontownGlobals.getInterfaceFont) # GUI font launcher.setPandaErrorCode(7) import ToonBase ToonBase.ToonBase() from pandac.PandaModules import * if base.win == None: print 'Unable to open window; aborting.' sys.exit() launcher.setPandaErrorCode(0) launcher.setPandaWindowOpen() ConfigVariableDouble('decompressor-step-time').setValue(0.01) ConfigVariableDouble('extractor-step-time').setValue(0.01) backgroundNodePath = aspect2d.attachNewNode(backgroundNode, 0) backgroundNodePath.setPos(0.0, 0.0, 0.0) backgroundNodePath.setScale(render2d, VBase3(1))
from src.coginvasion.globals import CIGlobals CIGlobals.SettingsMgr = sm sm.loadFile(jsonFile) sm.doSunriseFor(sunrise=SHOWBASE_PREINIT) from src.mod.ModBase import ModBase base = ModBase() sm.doSunriseFor(sunrise=SHOWBASE_POSTINIT) ConfigVariableDouble('decompressor-step-time').setValue(0.01) ConfigVariableDouble('extractor-step-time').setValue(0.01) from direct.gui import DirectGuiGlobals DirectGuiGlobals.setDefaultFontFunc(CIGlobals.getToonFont) DirectGuiGlobals.setDefaultFont(CIGlobals.getToonFont()) DirectGuiGlobals.setDefaultRolloverSound( loader.loadSfx("phase_3/audio/sfx/GUI_rollover.ogg")) DirectGuiGlobals.setDefaultClickSound( loader.loadSfx("phase_3/audio/sfx/GUI_create_toon_fwd.ogg")) DirectGuiGlobals.setDefaultDialogGeom( loader.loadModel("phase_3/models/gui/dialog_box_gui.bam")) from src.coginvasion.nametag import NametagGlobals NametagGlobals.setMe(base.cam) NametagGlobals.setCardModel('phase_3/models/props/panel.bam') NametagGlobals.setArrowModel('phase_3/models/props/arrow.bam') NametagGlobals.setChatBalloon3dModel('phase_3/models/props/chatbox.bam') NametagGlobals.setChatBalloon2dModel( 'phase_3/models/props/chatbox_noarrow.bam')
def enterReward(self): assert self.notify.debugStateCall(self) numToons = 0 toonLayouts = ( (2, ), (1, 3), (0, 2, 4), (0, 1, 3, 4), ) toonPositions = (5.0, 1.75, -0.25, -1.75, -5.0) self.toons = [] self.toonsKeep = [] self.counters = [] self.totalCounters = [] # put the camera in a reasonable position camera.reparentTo(render) base.camLens.setMinFov(ToontownGlobals.DefaultCameraFov) camera.setPos(0, 16.0, 2.0) camera.lookAt(0, 0, 0.75) base.transitions.irisIn(0.4) # show background elements self.title.reparentTo(aspect2d) self.foreground.reparentTo(render) self.backgroundL.reparentTo(render) self.backgroundR.reparentTo(render) self.sidewalk.reparentTo(render) self.door.reparentTo(render) # The backdrop in this scene is not really under our feet - it is a # bit of an optical illusion. So to make the physics behave a bit # better, we'll actually put a floor directly under the toons so # they stay put and their shadows stay put size = 20 z = -2.5 floor = CollisionPolygon(Point3(-size, -size, z), Point3(size, -size, z), Point3(size, size, z), Point3(-size, size, z)) floor.setTangible(1) floorNode = CollisionNode("collision_floor") floorNode.addSolid(floor) self.collisionFloor = render.attachNewNode(floorNode) # the bean counters take up a lot of real estate: clamp the whisper bubbles NametagGlobals.setOnscreenChatForced(1) # find out how many toons there are, make point counters for # them and get their models for index in range(len(self.ids)): avId = self.ids[index] if ((self.states[index] != PURCHASE_NO_CLIENT_STATE) and (self.states[index] != PURCHASE_DISCONNECTED_STATE) and (avId in base.cr.doId2do)): numToons += 1 toon = base.cr.doId2do[avId] toon.stopSmooth() self.toons.append(toon) self.toonsKeep.append( DelayDelete.DelayDelete(toon, 'Purchase.enterReward')) # counter for beans won counter = DirectLabel( parent=hidden, relief=None, pos=(0.0, 0.0, 0.0), text=str(0), text_scale=0.2, text_fg=(0.95, 0.95, 0, 1), text_pos=(0, -0.1, 0), text_font=ToontownGlobals.getSignFont(), ) counter['image'] = DGG.getDefaultDialogGeom() counter['image_scale'] = (0.33, 1, 0.33) counter.setScale(0.5) counter.count = 0 counter.max = self.pointsArray[index] self.counters.append(counter) # counter for total beans carried money = self.playerMoney[index] totalCounter = DirectLabel( parent=hidden, relief=None, pos=(0.0, 0.0, 0.0), text=str(money), text_scale=0.2, text_fg=(0.95, 0.95, 0, 1), text_pos=(0, -0.1, 0), text_font=ToontownGlobals.getSignFont(), image=self.jarImage, ) totalCounter.setScale(0.5) totalCounter.count = money totalCounter.max = toon.getMaxMoney() self.totalCounters.append(totalCounter) # add a hook when user unexpectedly closes toontown window self.accept('clientCleanup', self._handleClientCleanup) # display the toons and jars pos = 0 toonLayout = toonLayouts[numToons - 1] for toon in self.toons: thisPos = toonPositions[toonLayout[pos]] toon.setPos(Vec3(thisPos, 1.0, -2.5)) toon.setHpr(Vec3(0, 0, 0)) toon.setAnimState("neutral", 1) toon.setShadowHeight(0) if not toon.isDisabled(): toon.reparentTo(render) self.counters[pos].setPos(thisPos * -0.17, 0, toon.getHeight() / 10 + 0.25) self.counters[pos].reparentTo(aspect2d) self.totalCounters[pos].setPos(thisPos * -0.17, 0, -0.825) self.totalCounters[pos].reparentTo(aspect2d) pos += 1 # find the max points won self.maxPoints = max(self.pointsArray) #find the maxVotes left if self.votesArray: self.maxVotes = max(self.votesArray) numToons = len(self.toons) self.voteMultiplier = TravelGameGlobals.PercentOfVotesConverted[ numToons] / 100.0 self.maxBeansFromVotes = int(self.voteMultiplier * self.maxVotes) else: self.maxVotes = 0 self.maxBeansFromVotes = 0 def reqCountUp(state): self.countUp() return Task.done countUpDelay = DELAY_BEFORE_COUNT_UP taskMgr.doMethodLater(countUpDelay, reqCountUp, "countUpTask") def reqCountDown(state): self.countDown() return Task.done countDownDelay = (countUpDelay + self.maxPoints * COUNT_UP_RATE + DELAY_AFTER_COUNT_UP) taskMgr.doMethodLater(countDownDelay, reqCountDown, "countDownTask") # play the jump animation for the winner(s) def celebrate(task): # hide the counters before we jump! for counter in task.counters: counter.hide() winningPoints = max(task.pointsArray) for i in range(len(task.ids)): if task.pointsArray[i] == winningPoints: avId = task.ids[i] if avId in base.cr.doId2do: toon = base.cr.doId2do[avId] toon.setAnimState("jump", 1.0) base.playSfx(task.celebrateSound) return Task.done celebrateDelay = (countDownDelay + self.maxPoints * COUNT_DOWN_RATE + DELAY_AFTER_COUNT_DOWN) celebrateTask = taskMgr.doMethodLater(celebrateDelay, celebrate, "celebrate") celebrateTask.counters = self.counters celebrateTask.pointsArray = self.pointsArray celebrateTask.ids = self.ids celebrateTask.celebrateSound = self.celebrateSound def reqCountVotesUp(state): self.countVotesUp() return Task.done def reqCountVotesDown(state): self.countVotesDown() return Task.done # show the player the votes left being converted to beans if self.metagameRound == TravelGameGlobals.FinalMetagameRoundIndex: countVotesUpDelay = celebrateDelay + DELAY_AFTER_CELEBRATE taskMgr.doMethodLater(countVotesUpDelay, reqCountVotesUp, "countVotesUpTask") countVotesUpTime = (self.maxVotes * COUNT_UP_RATE) + DELAY_AFTER_COUNT_UP countVotesDownDelay = countVotesUpDelay + countVotesUpTime taskMgr.doMethodLater(countVotesDownDelay, reqCountVotesDown, "countVotesDownTask") celebrateDelay += countVotesUpTime + \ (self.maxVotes * COUNT_DOWN_RATE) + DELAY_AFTER_COUNT_DOWN # transition to the purchase after the countup is finished def reqPurchase(state): self.fsm.request("purchase") return Task.done purchaseDelay = (celebrateDelay + DELAY_AFTER_CELEBRATE) taskMgr.doMethodLater(purchaseDelay, reqPurchase, "purchase-trans") if base.skipMinigameReward: self.fsm.request('purchase')
def initNametagGlobals(self): arrow = loader.loadModel('phase_3/models/props/arrow') card = loader.loadModel('phase_3/models/props/panel') speech3d = ChatBalloon( loader.loadModel('phase_3/models/props/chatbox').node()) thought3d = ChatBalloon( loader.loadModel( 'phase_3/models/props/chatbox_thought_cutout').node()) exclaim3d = ChatBalloon( loader.loadModel( 'phase_3/models/props/chatbox_exclaim_cutout').node()) exclaim3d.m_hscale = 1.25 speech2dNode = loader.loadModel('phase_3/models/props/chatbox_noarrow') if base.classicVisuals == 2: speech2dNode.find('**/bottom').setTextureOff(1) speech2dNode.find('**/middle').setTextureOff(1) speech2dNode.find('**/top').setTextureOff(1) speech2d = ChatBalloon(speech2dNode.node()) speech2dNode.removeNode() chatButtonGui = loader.loadModel('phase_3/models/gui/chat_button_gui') NametagGlobals.setCamera(self.cam) NametagGlobals.setArrowModel(arrow) NametagGlobals.setNametagCard(card, VBase4(-0.5, 0.5, -0.5, 0.5)) if self.mouseWatcherNode: NametagGlobals.setMouseWatcher(self.mouseWatcherNode) NametagGlobals.setSpeechBalloon3d(speech3d) NametagGlobals.setThoughtBalloon3d(thought3d) NametagGlobals.setExclaimBalloon3d(exclaim3d) NametagGlobals.setSpeechBalloon2d(speech2d) NametagGlobals.setThoughtBalloon2d(thought3d) NametagGlobals.setExclaimBalloon2d(speech2d) NametagGlobals.setPageButton(PGButton.SReady, chatButtonGui.find('**/Horiz_Arrow_UP')) NametagGlobals.setPageButton(PGButton.SDepressed, chatButtonGui.find('**/Horiz_Arrow_DN')) NametagGlobals.setPageButton( PGButton.SRollover, chatButtonGui.find('**/Horiz_Arrow_Rllvr')) NametagGlobals.setQuitButton(PGButton.SReady, chatButtonGui.find('**/CloseBtn_UP')) NametagGlobals.setQuitButton(PGButton.SDepressed, chatButtonGui.find('**/CloseBtn_DN')) NametagGlobals.setQuitButton(PGButton.SRollover, chatButtonGui.find('**/CloseBtn_Rllvr')) rolloverSound = DirectGuiGlobals.getDefaultRolloverSound() if rolloverSound: NametagGlobals.setRolloverSound(rolloverSound) clickSound = DirectGuiGlobals.getDefaultClickSound() if clickSound: NametagGlobals.setClickSound(clickSound) NametagGlobals.setToon(self.cam) self.marginManager = MarginManager() self.margins = self.aspect2d.attachNewNode( self.marginManager, DirectGuiGlobals.MIDGROUND_SORT_INDEX + 1) mm = self.marginManager self.leftCells = [ mm.addGridCell(0, 1, -1.33333333333, 1.33333333333, -1.0, 1.0, base.a2dTopLeft, (0.222222, 0, -1.5)), mm.addGridCell(0, 2, -1.33333333333, 1.33333333333, -1.0, 1.0, base.a2dTopLeft, (0.222222, 0, -1.16667)), mm.addGridCell(0, 3, -1.33333333333, 1.33333333333, -1.0, 1.0, base.a2dTopLeft, (0.222222, 0, -0.833333)) ] self.bottomCells = [ mm.addGridCell(0.5, 0, -1.33333333333, 1.33333333333, -1.0, 1.0, base.a2dBottomCenter, (-0.888889, 0, 0.166667)), mm.addGridCell(1.5, 0, -1.33333333333, 1.33333333333, -1.0, 1.0, base.a2dBottomCenter, (-0.444444, 0, 0.166667)), mm.addGridCell(2.5, 0, -1.33333333333, 1.33333333333, -1.0, 1.0, base.a2dBottomCenter, (0, 0, 0.166667)), mm.addGridCell(3.5, 0, -1.33333333333, 1.33333333333, -1.0, 1.0, base.a2dBottomCenter, (0.444444, 0, 0.166667)), mm.addGridCell(4.5, 0, -1.33333333333, 1.33333333333, -1.0, 1.0, base.a2dBottomCenter, (0.888889, 0, 0.166667)) ] self.rightCells = [ mm.addGridCell(5, 2, -1.33333333333, 1.33333333333, -1.0, 1.0, base.a2dTopRight, (-0.222222, 0, -1.16667)), mm.addGridCell(5, 1, -1.33333333333, 1.33333333333, -1.0, 1.0, base.a2dTopRight, (-0.222222, 0, -1.5)) ]
__builtin__.launcher = launcher notify.info("Loading Clients") notify.info('Starting Toontown Planet...') if launcher.isDummy(): http = HTTPClient() else: http = launcher.http tempLoader = Loader() backgroundNode = tempLoader.loadSync(Filename('phase_3/models/gui/loading-background')) from direct.gui import DirectGuiGlobals from direct.gui.DirectGui import * notify.info('Setting the default Toontown Planet font...') import ToontownGlobals DirectGuiGlobals.setDefaultFontFunc(ToontownGlobals.getInterfaceFont) launcher.setPandaErrorCode(7) import ToonBase ToonBase.ToonBase() from pandac.PandaModules import * if base.win is None: notify.error('Unable to open window; aborting.') launcher.setPandaErrorCode(0) launcher.setPandaWindowOpen() ConfigVariableDouble('decompressor-step-time').setValue(0.01) ConfigVariableDouble('extractor-step-time').setValue(0.01) backgroundNodePath = aspect2d.attachNewNode(backgroundNode, 0) backgroundNodePath.setPos(0.0, 0.0, 0.0) backgroundNodePath.setScale(render2d, VBase3(1)) backgroundNodePath.find('**/fg').hide() logo = OnscreenImage(
def __init__(self, doneEvent): self.doneEvent = doneEvent DirectFrame.__init__(self) self.reparentTo(aspect2d) self.setPos(0.0, 0.0, 0.16) self.stash() # load the public party gui and extract the sub-chunk of the model that # we will use as the background for this gui publicPartyGui = loader.loadModel( "phase_4/models/parties/publicPartyGUI") # create a top level DirectFrame to hold everything else self.frame = DirectFrame( parent=self, geom=publicPartyGui.find("**/activities_background"), geom_pos=(-0.8, 0.0, 0.2), geom_scale=2.0, relief=None, ) # counter for beans won in the activity self.earnedLabel = DirectLabel( parent=self, relief=None, text=str(0), text_align=TextNode.ACenter, text_pos=(0.0, -0.07), text_scale=0.2, text_fg=(0.95, 0.95, 0.0, 1.0), text_font=ToontownGlobals.getSignFont(), textMayChange=True, image=DirectGuiGlobals.getDefaultDialogGeom(), image_scale=(0.33, 1.0, 0.33), pos=(-0.3, 0.0, 0.2), scale=0.9, ) # counter with jellybean jar in the background for beans in the # "pocketbook" (the beans you carry around with you that are not in your # home bank) purchaseModels = loader.loadModel("phase_4/models/gui/purchase_gui") jarImage = purchaseModels.find("**/Jar") self.jarLabel = DirectLabel( parent=self, relief=None, text=str(0), text_align=TextNode.ACenter, text_pos=(0.0, -0.07), text_scale=0.2, text_fg=JellybeanRewardGui.JarLabelTextColor, text_font=ToontownGlobals.getSignFont(), textMayChange=True, image=jarImage, scale=0.7, pos=(0.3, 0.0, 0.17), ) purchaseModels.removeNode() del purchaseModels jarImage.removeNode() del jarImage # message text self.messageLabel = DirectLabel( parent=self, relief=None, text="", text_align=TextNode.ALeft, text_wordwrap=16.0, text_scale=0.07, pos=(-0.52, 0.0, -0.1), textMayChange=True, ) self.doubledJellybeanLabel = DirectLabel( parent=self, relief=None, text=TTLocalizer.PartyRewardDoubledJellybean, text_align=TextNode.ACenter, text_wordwrap=12.0, text_scale=0.09, text_fg=(1.0, 0.125, 0.125, 1.0), pos=(0.0, 0.0, -0.465), textMayChange=False, ) self.doubledJellybeanLabel.hide() # button to close the gui when the player is done reading it self.closeButton = DirectButton( parent=self, relief=None, text=TTLocalizer.PartyJellybeanRewardOK, text_align=TextNode.ACenter, text_scale=0.065, text_pos=(0.0, -0.625), geom=( publicPartyGui.find("**/startButton_up"), publicPartyGui.find("**/startButton_down"), publicPartyGui.find("**/startButton_rollover"), publicPartyGui.find("**/startButton_inactive"), ), geom_pos=(-0.39, 0.0, 0.125), # place the geom to line up with the text command=self._close, ) publicPartyGui.removeNode() del publicPartyGui self.countSound = base.loadSfx( "phase_13/audio/sfx/tick_counter_short.mp3") self.overMaxSound = base.loadSfx( "phase_13/audio/sfx/tick_counter_overflow.mp3")
import sys reload(sys) sys.setdefaultencoding('latin-1') from toontown.launcher.TTLauncher import TTLauncher __builtin__.launcher = TTLauncher() print 'ToontownStart: Starting the game.' tempLoader = Loader() backgroundNode = tempLoader.loadSync( Filename('phase_3/models/gui/loading-background')) from direct.gui import DirectGuiGlobals import ToontownGlobals DirectGuiGlobals.setDefaultFontFunc(ToontownGlobals.getInterfaceFont) launcher.setPandaErrorCode(7) # base import ToonBase ToonBase.ToonBase() base.loadSettings() if base.win == None: print 'Unable to open window; aborting.' sys.exit() launcher.setPandaErrorCode(0) launcher.setPandaWindowOpen()
from lib.coginvasion.nametag import NametagGlobals from direct.gui import DirectGuiGlobals NametagGlobals.setMe(base.cam) NametagGlobals.setCardModel('phase_3/models/props/panel.bam') NametagGlobals.setArrowModel('phase_3/models/props/arrow.bam') NametagGlobals.setChatBalloon3dModel('phase_3/models/props/chatbox.bam') NametagGlobals.setChatBalloon2dModel('phase_3/models/props/chatbox_noarrow.bam') NametagGlobals.setThoughtBalloonModel('phase_3/models/props/chatbox_thought_cutout.bam') chatButtonGui = loader.loadModel('phase_3/models/gui/chat_button_gui.bam') NametagGlobals.setPageButton(chatButtonGui.find('**/Horiz_Arrow_UP'), chatButtonGui.find('**/Horiz_Arrow_DN'), chatButtonGui.find('**/Horiz_Arrow_Rllvr'), chatButtonGui.find('**/Horiz_Arrow_UP')) NametagGlobals.setQuitButton(chatButtonGui.find('**/CloseBtn_UP'), chatButtonGui.find('**/CloseBtn_DN'), chatButtonGui.find('**/CloseBtn_Rllvr'), chatButtonGui.find('**/CloseBtn_UP')) soundRlvr = DirectGuiGlobals.getDefaultRolloverSound() NametagGlobals.setRolloverSound(soundRlvr) soundClick = DirectGuiGlobals.getDefaultClickSound() NametagGlobals.setClickSound(soundClick) from lib.coginvasion.toon.LocalToon import LocalToon from lib.coginvasion.login.AvChoice import AvChoice class Standalone: def __init__(self): self.process = 'client' __builtin__.game = self base.cr = ClientRepository(['phase_3/etc/direct.dc', 'phase_3/etc/toon.dc']) base.cr.isShowingPlayerIds = None
def initNametagGlobals(self): arrow = loader.loadModel('phase_3/models/props/arrow') card = loader.loadModel('phase_3/models/props/panel') speech3d = ChatBalloon( loader.loadModel('phase_3/models/props/chatbox')) thought3d = ChatBalloon( loader.loadModel('phase_3/models/props/chatbox_thought_cutout')) exclaim3d = ChatBalloon( loader.loadModel('phase_3/models/props/chatbox_exclaim_cutout')) speech2d = ChatBalloon( loader.loadModel('phase_3/models/props/chatbox_noarrow')) if config.GetBool('want-retro-mode', False): rtex = loader.loadTexture( 'phase_3/maps/avatar_palette_1llla_1_retro.jpg') speech3d.model.setTexture(rtex, 1) thought3d.model.setTexture(rtex, 1) speech2d.model.setTexture(rtex, 1) exclaim3d.model.setTexture( loader.loadTexture('phase_3/maps/spikey_bubble_retro.jpg'), 1) chatButtonGui = loader.loadModel('phase_3/models/gui/chat_button_gui') NametagGlobals.setCamera(self.cam) NametagGlobals.setArrowModel(arrow) NametagGlobals.setNametagCard(card, VBase4(-0.5, 0.5, -0.5, 0.5)) if self.mouseWatcherNode: NametagGlobals.setMouseWatcher(self.mouseWatcherNode) NametagGlobals.setSpeechBalloon3d(speech3d) NametagGlobals.setThoughtBalloon3d(thought3d) NametagGlobals.setExclaimBalloon3d(exclaim3d) NametagGlobals.setSpeechBalloon2d(speech2d) NametagGlobals.setThoughtBalloon2d(thought3d) NametagGlobals.setExclaimBalloon2d(speech2d) NametagGlobals.setPageButton(PGButton.SReady, chatButtonGui.find('**/Horiz_Arrow_UP')) NametagGlobals.setPageButton(PGButton.SDepressed, chatButtonGui.find('**/Horiz_Arrow_DN')) NametagGlobals.setPageButton( PGButton.SRollover, chatButtonGui.find('**/Horiz_Arrow_Rllvr')) NametagGlobals.setQuitButton(PGButton.SReady, chatButtonGui.find('**/CloseBtn_UP')) NametagGlobals.setQuitButton(PGButton.SDepressed, chatButtonGui.find('**/CloseBtn_DN')) NametagGlobals.setQuitButton(PGButton.SRollover, chatButtonGui.find('**/CloseBtn_Rllvr')) rolloverSound = DirectGuiGlobals.getDefaultRolloverSound() if rolloverSound: NametagGlobals.setRolloverSound(rolloverSound) clickSound = DirectGuiGlobals.getDefaultClickSound() if clickSound: NametagGlobals.setClickSound(clickSound) NametagGlobals.setToon(self.cam) self.marginManager = MarginManager() self.margins = self.aspect2d.attachNewNode( self.marginManager, DirectGuiGlobals.MIDGROUND_SORT_INDEX + 1) mm = self.marginManager padding = 0.0225 self.leftCells = [ mm.addGridCell(0.2 + padding, -0.45, base.a2dTopLeft), mm.addGridCell(0.2 + padding, -0.9, base.a2dTopLeft), mm.addGridCell(0.2 + padding, -1.35, base.a2dTopLeft) ] self.bottomCells = [ mm.addGridCell(-0.87, 0.2 + padding, base.a2dBottomCenter), mm.addGridCell(-0.43, 0.2 + padding, base.a2dBottomCenter), mm.addGridCell(0.01, 0.2 + padding, base.a2dBottomCenter), mm.addGridCell(0.45, 0.2 + padding, base.a2dBottomCenter), mm.addGridCell(0.89, 0.2 + padding, base.a2dBottomCenter) ] self.rightCells = [ mm.addGridCell(-0.2 - padding, -1.35, base.a2dTopRight), mm.addGridCell(-0.2 - padding, -0.9, base.a2dTopRight), mm.addGridCell(-0.2 - padding, -0.45, base.a2dTopRight) ]
vfs = VirtualFileSystem.getGlobalPtr() vfs.mount(Filename("phase_3.mf"), ".", VirtualFileSystem.MFReadOnly) vfs.mount(Filename("phase_3.5.mf"), ".", VirtualFileSystem.MFReadOnly) vfs.mount(Filename("phase_4.mf"), ".", VirtualFileSystem.MFReadOnly) vfs.mount(Filename("phase_5.mf"), ".", VirtualFileSystem.MFReadOnly) vfs.mount(Filename("phase_5.5.mf"), ".", VirtualFileSystem.MFReadOnly) vfs.mount(Filename("phase_6.mf"), ".", VirtualFileSystem.MFReadOnly) vfs.mount(Filename("phase_7.mf"), ".", VirtualFileSystem.MFReadOnly) vfs.mount(Filename("phase_8.mf"), ".", VirtualFileSystem.MFReadOnly) vfs.mount(Filename("phase_9.mf"), ".", VirtualFileSystem.MFReadOnly) vfs.mount(Filename("phase_10.mf"), ".", VirtualFileSystem.MFReadOnly) vfs.mount(Filename("phase_11.mf"), ".", VirtualFileSystem.MFReadOnly) vfs.mount(Filename("phase_12.mf"), ".", VirtualFileSystem.MFReadOnly) vfs.mount(Filename("phase_13.mf"), ".", VirtualFileSystem.MFReadOnly) DirectGuiGlobals.setDefaultRolloverSound( base.loadSfx("phase_5/audio/sfx/GUI_battlerollover.ogg")) DirectGuiGlobals.setDefaultClickSound( base.loadSfx("phase_5/audio/sfx/GUI_battleselect.ogg")) cbm = CullBinManager.getGlobalPtr() cbm.addBin('ground', CullBinManager.BTUnsorted, 18) cbm.addBin('shadow', CullBinManager.BTBackToFront, 19) cbm.addBin('gui-popup', CullBinManager.BTUnsorted, 60) port = base.config.GetInt('server-port') ADMIN_ACCESS = 28001 class ServerBase(DirectObject): def __init__(self):
def __init__(self): self.settings = core.load_prc_file(core.Filename.expand_from("$MAIN_DIR/settings.prc")) ShowBase.__init__(self, windowType='none') # Try opening "gl-version 3 2" window props = core.WindowProperties.get_default() have_window = False try: self.open_default_window(props=props) have_window = True except Exception: pass if not have_window: print("Failed to open window with OpenGL 3.2; falling back to older OpenGL.") core.load_prc_file_data("", "gl-version") self.open_default_window(props=props) print("The window seemed to have opened this time around.") gsg = self.win.gsg gl_version = (gsg.driver_version_major, gsg.driver_version_minor) self.has_fixed_function = gl_version < (3, 0) or gsg.max_lights > 0 print("OpenGL version: {0}.{1} ({2})".format(*gl_version, 'compat' if self.has_fixed_function else 'core')) print("OpenGL renderer: {0}".format(gsg.driver_renderer)) self.accept('escape', sys.exit) self.accept('f12', self.screenshot) self.disable_mouse() self.camLens.set_far(50) # Load in background self.set_background_color((0.31, 0.42, 0.53)) if not self.win.get_fb_properties().srgb_color: print("Did not get an sRGB framebuffer. The game may appear too dark.") # Load fonts self.symbol_font = loader.load_font("font/FreeSerif.otf") self.symbol_font.set_pixels_per_unit(64) self.regular_font = loader.load_font("font/Quicksand-Regular.otf") self.regular_font.set_pixels_per_unit(64) self.title_font = loader.load_font("font/Quicksand-Light.otf") self.title_font.set_pixels_per_unit(128) self.icon_fonts = { 'solid': loader.load_font("font/font-awesome5-solid.otf"), 'regular': loader.load_font("font/font-awesome5-regular.otf"), } for font in self.icon_fonts.values(): font.set_pixels_per_unit(64) # Load sounds DGG.setDefaultClickSound(loader.load_sfx('sfx/menu-interact.wav')) DGG.setDefaultRolloverSound(loader.load_sfx('sfx/menu-focus.wav')) self.endtile_sound = loader.load_sfx('sfx/endtile.wav') self.move_sound = loader.load_sfx('sfx/die-move.wav') self.impassable_sound = loader.load_sfx('sfx/impassable.wav') self.button_sound = loader.load_sfx('sfx/button-press.wav') self.transport_sound = loader.load_sfx('sfx/transport-engage.wav') self.slide_sound = loader.load_sfx('sfx/ice-slide.wav') self.wind_sound = loader.load_sfx('sfx/wind.ogg') self.crack_sound = loader.load_sfx('sfx/tile-crack.wav') self.collapse_sound = loader.load_sfx('sfx/tile-collapse.wav') self.restart_sound = loader.load_sfx('sfx/menu-interact.wav') self.music = { 'menu': loader.load_music('music/theme.ogg'), 'one': loader.load_music('music/world1.ogg'), 'two': loader.load_music('music/world2.ogg'), 'three': loader.load_music('music/world3.ogg'), 'four': loader.load_music('music/world4.ogg'), 'five': loader.load_music('music/world5.ogg'), 'six': loader.load_music('music/world6.ogg'), } self.playing_music = None self.music_on = True self.blur_shader = core.Shader.load(core.Shader.SL_GLSL, "shader/blur.vert", "shader/blur.frag") self.blur_scale = core.PTA_float([1.0]) self.blurred_tex = None self.quality = None screen = ui.Screen("select quality") ui.Button(screen, 'sublime', pos=(0.0, 0), command=self.setup_game, extraArgs=[3]) ui.Button(screen, 'mediocre', pos=(0.0, -0.15), command=self.setup_game, extraArgs=[2]) ui.Button(screen, 'terrible', pos=(0.0, -0.3), command=self.setup_game, extraArgs=[1]) self.quality_screen = screen screen.show_now() self.game_setup = False self.have_save = False self.blurred = True self.accept('connect-device', self.on_connect_device) self.accept('disconnect-device', self.on_disconnect_device) self.gamepads = set() dev_mgr = core.InputDeviceManager.get_global_ptr() for device in dev_mgr.get_devices(core.InputDevice.DeviceClass.gamepad): self.on_connect_device(device) self.gamepad_lstick_angle = None self.win_input = self.win.get_input_device(0) self.task_mgr.add(self.process_input) sys.stdout.flush() sys.stderr.flush()
import sys import random import __builtin__ import gc gc.disable() try: launcher except: from pirates.launcher.PiratesOnlineLauncher import PiratesOnlineLauncher launcher = PiratesOnlineLauncher() __builtin__.launcher = launcher from direct.gui import DirectGuiGlobals import PiratesGlobals DirectGuiGlobals.setDefaultFontFunc(PiratesGlobals.getInterfaceFont) launcher.setPandaErrorCode(7) import PiratesBase PiratesBase.PiratesBase() from direct.showbase.ShowBaseGlobal import * if base.config.GetBool('want-preloader', 0): base.preloader = PiratesPreloader.PiratesPreloader() if base.win == None: print 'Unable to open window; aborting.' sys.exit() launcher.setPandaErrorCode(0) launcher.setPandaWindowOpen() base.sfxPlayer.setCutoffDistance(500.0) from pirates.audio import SoundGlobals