def __travMousePicker(self, task): if not base.mouseWatcherNode.hasMouse(): return task.cont else: mpos = base.mouseWatcherNode.getMouse() self.pickerRay.setFromLens(base.camNode, mpos.getX(), mpos.getY()) self.pickerTrav.traverse(render) if self.pickerHandler.getNumEntries() > 0: self.pickerHandler.sortEntries() pickedObject = self.pickerHandler.getEntry(0).getIntoNodePath() avatarId = pickedObject.getParent().getPythonTag('avatar') if avatarId != None: for do in self.cr.doId2do.values(): if do.__class__.__name__ == 'DistributedToon': if do.doId == avatarId: if do.nameTag.getClickable() == 1: if do.nameTag.fsm.getCurrentState().getName() != 'rollover' and do.nameTag.fsm.getCurrentState().getName() != 'down': do.nameTag.setPickerState('rollover') base.playSfx(DGG.getDefaultRolloverSound()) self.rolledOverTag = avatarId break elif do.__class__.__name__ == 'DistributedToon': if do.nameTag.fsm.getCurrentState().getName() != 'up': do.nameTag.setPickerState('up') elif self.rolledOverTag: avatar = self.cr.doId2do.get(self.rolledOverTag) if avatar: if avatar.nameTag.fsm.getCurrentState().getName() != 'up': avatar.nameTag.setPickerState('up') self.rolledOverTag = None return task.cont
def __init__(self, dna, **kw): self.dna = dna head = hidden.attachNewNode('head', 20) self.headModel = ToonHead.ToonHead() self.headModel.setupHead(self.dna, forGui=1) self.headModel.fitAndCenterHead(1.0, forGui=1) self.headModel.reparentTo(head) self.headModel.setName('headModel') self.headModel.startBlink() optiondefs = (('dialogName', 'ToonHeadDialog', None), ('style', TTDialog.NoButtons, None), ('geom', head, None), ('geom_scale', 0.35, None), ('geom_pos', (-0.25, 0, 0), None), ('text_wordwrap', 9, None), ('fadeScreen', 0, None), ('image', DGG.getDefaultDialogGeom(), None), ('relief', None, None)) self.defineoptions(kw, optiondefs) TTDialog.TTDialog.__init__(self, style=self['style']) self.initialiseoptions(ToonHeadDialog) self.postInitialiseFuncList.append(self.replaceHead) self.reparentTo(base.a2dTopRight) self.setPos(-0.85, 0, -0.25) return
def load(self): font = CIGlobals.getToonFont() box = DGG.getDefaultDialogGeom() self.finalScoreContainer = DirectFrame() self.finalScoreBg = OnscreenImage(image=box, color=(1, 1, 0.75, 1), scale=(1.9, 1.4, 1.4), parent=self.finalScoreContainer) self.finalScoreTitle = OnscreenText(text='Waiting for final scores...', pos=(0, 0.5, 0), font=font, scale=0.12, parent=self.finalScoreContainer) self.finalScoreNameLbl = OnscreenText(text='', scale=0.095, pos=(-0.85, 0.3, 0), font=font, align=TextNode.ALeft, parent=self.finalScoreContainer) self.finalScorePointLbl = OnscreenText(text='', scale=0.095, pos=(0.85, 0.3, 0), font=font, align=TextNode.ARight, parent=self.finalScoreContainer) self.finalScoreContainer.hide() self.finalScoreContainer.setBin('gui-popup', 60) del font del box
def __init__(self): DirectFrame.__init__(self, parent=aspect2d, relief=None, geom=DGG.getDefaultDialogGeom(), geom_color=ToontownGlobals.GlobalDialogColor, geom_scale=(1.33, 1, 1.3), pos=(0, 0, 0), text='', text_scale=0.07, text_pos=(0, 0.475)) self.initialiseoptions(LaffShopGui) self.additionalLaff = 0 self.timer = ToontownTimer.ToontownTimer() self.timer.reparentTo(aspect2d) self.timer.posInTopRightCorner() self.timer.countdown(LaffRestockGlobals.TIMER_SECONDS, self.__cancel, [LaffRestockGlobals.TIMER_END]) self.setupButtons() self.bindButtons() self.laffMeter = LaffMeter.LaffMeter(base.localAvatar.style, base.localAvatar.getHp(), base.localAvatar.getMaxHp()) self.laffMeter.reparentTo(self) self.laffMeter.setPos(0, 0, 0.065) self.laffMeter.setScale(0.13) self.__updateLaffMeter(1)
def __init__(self, numPlayers, avIdList, votes, directions, namesList, disconnectedList, directionToGo, directionReason, directionTotals, *args, **kwargs): opts = { 'relief': None, 'geom': DGG.getDefaultDialogGeom(), 'geom_color': ToontownGlobals.GlobalDialogColor[:3] + (0.80000000000000004,), 'geom_scale': (1.75, 1, 0.75), 'pos': (0, 0, 0.52500000000000002) } opts.update(kwargs) DirectFrame.__init__(self, *args, **args) self.initialiseoptions(VoteResultsPanel) listMultiplier = 1 if TravelGameGlobals.SpoofFour: listMultiplier = 4 self.avIdList = avIdList * listMultiplier self.numPlayers = numPlayers * listMultiplier self.votes = votes * listMultiplier self.directions = directions * listMultiplier self.namesList = namesList * listMultiplier self.disconnectedList = disconnectedList * listMultiplier self.directionToGo = directionToGo self.directionReason = directionReason self.directionTotals = directionTotals self.entryList = [] self.rowFrame = [] self.upDownFrame = DirectFrame(parent = self, relief = None, pos = self.getRowPos(-1)) self.upLabel = DirectLabel(parent = self.upDownFrame, relief = None, pos = (1.2, 0, 0.0), text = TTLocalizer.TravelGameDirections[0], text_fg = (0.0, 0.0, 1.0, 1.0), text_scale = 0.050000000000000003, text_align = TextNode.ARight) self.downLabel = DirectLabel(parent = self.upDownFrame, relief = None, pos = (1.4299999999999999, 0, 0.0), text = TTLocalizer.TravelGameDirections[1], text_fg = (1.0, 0.0, 0.0, 1.0), text_scale = 0.050000000000000003, text_align = TextNode.ARight) self.totalFrame = DirectFrame(parent = self, relief = None, pos = self.getRowPos(self.numPlayers)) self.totalText = DirectLabel(parent = self.totalFrame, relief = None, pos = (1.0, 0, 0.0), text = 'Total', text_fg = (0.0, 0.0, 0.0, 1.0), text_scale = 0.050000000000000003, text_align = TextNode.ARight) self.totalVotesUpLabel = DirectLabel(parent = self.totalFrame, relief = None, pos = (1.2, 0, 0.0), text = '', text_fg = (0.0, 0.0, 1.0, 1.0), text_scale = 0.050000000000000003, text_align = TextNode.ARight) self.totalVotesDownLabel = DirectLabel(parent = self.totalFrame, relief = None, pos = (1.4299999999999999, 0, 0.0), text = '', text_fg = (1.0, 0.0, 0.0, 1.0), text_scale = 0.050000000000000003, text_align = TextNode.ARight) self.totalVotesLabels = [ self.totalVotesUpLabel, self.totalVotesDownLabel] self.resultFrame = DirectFrame(parent = self, relief = None, pos = self.getRowPos(5)) self.resultLabel = DirectLabel(parent = self.resultFrame, text = '', text_scale = 0.059999999999999998, pos = (0.69999999999999996, 0, 0.0), text_align = TextNode.ACenter) self.setupResultLabel() for index in range(self.numPlayers): frame = DirectFrame(parent = self, relief = None, pos = self.getRowPos(index)) self.rowFrame.append(frame) nameLabel = DirectFrame(parent = frame, relief = None, pos = (0.46000000000000002, 0.0, 0.0), text = self.namesList[index], text_fg = (0.0, 0.0, 0.0, 1.0), text_scale = 0.050000000000000003, text_align = TextNode.ACenter, text_font = DGG.getDefaultFont()) votesUpLabel = DirectLabel(parent = frame, relief = None, pos = (1.2, 0.0, 0.0), text = '', text_fg = (0, 0, 1, 1), text_scale = 0.050000000000000003, text_align = TextNode.ARight, text_font = DGG.getDefaultFont()) votesDownLabel = DirectLabel(parent = frame, relief = None, pos = (1.4299999999999999, 0.0, 0.0), text = '', text_fg = (1, 0, 0, 1), text_scale = 0.050000000000000003, text_align = TextNode.ARight, text_font = DGG.getDefaultFont()) nameLabel.hide() self.entryList.append((nameLabel, votesUpLabel, votesDownLabel))
def __init__(self): DirectFrame.__init__(self, scale=1.2) self['image'] = DGG.getDefaultDialogGeom() self['image_hpr'] = (0, 0, -90) self['image_scale'] = (0.62, 0.9, 0.325) self['image_color'] = (1, 1, 0.75, 1) self['image_pos'] = (0, 0, -0.065) self['relief'] = None self.reparentTo(base.a2dTopRight) self.setPos(-0.235, 0.0, -0.325) self.hide() self.head = None self.laffMeter = None self.exitButton = None self.friendButton = None self.teleportButton = None self.nameText = None self.actionFrame = None self.actionFrameText = None self.actionFrameButton = None self.actionFrameButton2 = None self.avatarInfo = None self.action = None self.fsm = ClassicFSM.ClassicFSM('ToonPanel', [State.State('off', self.enterOff, self.exitOff), State.State('waitOnAvatarInfoResponse', self.enterWaitOnAvatarInfoResponse, self.exitWaitOnAvatarInfoResponse, ['panel']), State.State('panel', self.enterPanel, self.exitPanel, ['off'])], 'off', 'off') self.fsm.enterInitialState() self.actionFSM = ClassicFSM.ClassicFSM('ToonPanelActionFSM', [State.State('off', self.enterOff, self.exitOff), State.State('waitOnAvatarStatusResponse', self.enterWaitOnAvatarStatusResponse, self.exitWaitOnAvatarStatusResponse, ['waitOnAvatarTeleportResponse', 'waitOnAvatarFriendListResponse', 'avatarBusy', 'off']), State.State('avatarBusy', self.enterAvatarBusy, self.exitAvatarBusy, ['off']), State.State('waitOnAvatarTeleportResponse', self.enterWaitOnAvatarTeleportResponse, self.exitWaitOnAvatarTeleportResponse, ['unableToTP']), State.State('unableToTP', self.enterUnableToTP, self.exitUnableToTP, ['off']), State.State('waitOnAvatarFriendListResponse', self.enterWaitOnAvatarFriendListResponse, self.exitWaitOnAvatarFriendListResponse, ['fRequestA', 'fRequestR']), State.State('fRequestA', self.enterFriendRequestAccepted, self.exitFriendRequestAccepted, ['off']), State.State('fRequestR', self.enterFriendRequestRejected, self.exitFriendRequestRejected, ['off']), State.State('removeFriendConfirm', self.enterRemoveFriendConfirm, self.exitRemoveFriendConfirm, ['off', 'removedFriend']), State.State('removedFriend', self.enterRemovedFriend, self.exitRemovedFriend, ['off'])], 'off', 'off') self.actionFSM.enterInitialState() return
def __init__(self, avId, avName, avDNA, context, **kw): self.avId = avId self.avDNA = avDNA self.context = context self.avName = avName if len(base.localAvatar.friendsList) >= MaxFriends: base.cr.friendManager.up_inviteeFriendResponse(3, self.context) self.context = None text = OTPLocalizer.FriendInviteeTooManyFriends % self.avName style = TTDialog.Acknowledge buttonTextList = [OTPLocalizer.FriendInviteeOK] command = self.__handleOhWell else: text = OTPLocalizer.FriendInviteeInvitation % self.avName style = TTDialog.TwoChoice buttonTextList = [OTPLocalizer.FriendInviteeOK, OTPLocalizer.FriendInviteeNo] command = self.__handleButton optiondefs = (('image', DGG.getDefaultDialogGeom(), None), ('relief', None, None), ('dialogName', 'FriendInvitee', None), ('text', text, None), ('style', style, None), ('buttonTextList', buttonTextList, None), ('command', command, None), ('image_color', (1.0, 0.89, 0.77, 1.0), None), ('geom_scale', 0.2, None), ('geom_pos', (-0.1, 0, -0.025), None), ('pad', (0.075, 0.075), None), ('topPad', 0, None), ('midPad', 0, None), ('pos', (0.45, 0, 0.75), None), ('scale', 0.75, None)) self.defineoptions(kw, optiondefs) ToonHeadDialog.ToonHeadDialog.__init__(self, self.avDNA) self.accept('cancelFriendInvitation', self.__handleCancelFromAbove) self.initialiseoptions(FriendInvitee) self.show() return
def __init__(self, numPlayers, avIdList, votes, directions, namesList, disconnectedList, directionToGo, directionReason, directionTotals, *args, **kwargs): opts = { 'relief': None, 'geom': DGG.getDefaultDialogGeom(), 'geom_color': ToontownGlobals.GlobalDialogColor[:3] + (0.80, ), 'geom_scale': (1.75, 1, 0.75), 'pos': (0, 0, 0.525) } opts.update(kwargs) DirectFrame.__init__(self, *args, **opts) self.initialiseoptions(VoteResultsPanel) listMultiplier = 1 if TravelGameGlobals.SpoofFour: listMultiplier = 4 self.avIdList = avIdList * listMultiplier self.numPlayers = numPlayers * listMultiplier self.votes = votes * listMultiplier self.directions = directions * listMultiplier self.namesList = namesList * listMultiplier self.disconnectedList = disconnectedList * listMultiplier self.directionToGo = directionToGo self.directionReason = directionReason self.directionTotals = directionTotals self.entryList = [] self.rowFrame = [] self.upDownFrame = DirectFrame( parent=self, relief=None, pos=self.getRowPos(-1), ) self.upLabel = DirectLabel(parent=self.upDownFrame, relief=None, pos=(1.2, 0, 0.0), text=TTLocalizer.TravelGameDirections[0], text_fg=(0.0, 0.0, 1.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) self.downLabel = DirectLabel(parent=self.upDownFrame, relief=None, pos=(1.43, 0, 0.0), text=TTLocalizer.TravelGameDirections[1], text_fg=(1.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) self.totalFrame = DirectFrame( parent=self, relief=None, pos=self.getRowPos(self.numPlayers), ) self.totalText = DirectLabel(parent=self.totalFrame, relief=None, pos=(1.0, 0, 0.0), text='Total', text_fg=(0.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) self.totalVotesUpLabel = DirectLabel(parent=self.totalFrame, relief=None, pos=(1.2, 0, 0.0), text='', text_fg=(0.0, 0.0, 1.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) self.totalVotesDownLabel = DirectLabel(parent=self.totalFrame, relief=None, pos=(1.43, 0, 0.0), text='', text_fg=(1.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) self.totalVotesLabels = [ self.totalVotesUpLabel, self.totalVotesDownLabel ] self.resultFrame = DirectFrame( parent=self, relief=None, #pos = self.getRowPos(self.numPlayers+1), pos=self.getRowPos(5), ) self.resultLabel = DirectLabel(parent=self.resultFrame, text='', text_scale=0.06, pos=(0.7, 0, 0.0), text_align=TextNode.ACenter) self.setupResultLabel() for index in range(self.numPlayers): frame = DirectFrame( parent=self, relief=None, pos=self.getRowPos(index), ) self.rowFrame.append(frame) nameLabel = DirectFrame( parent=frame, relief=None, pos=(0.46, 0.0, 0.0), text=self.namesList[index], text_fg=(0.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ACenter, text_font=DGG.getDefaultFont() #ToontownGlobals.getSignFont(), ) votesUpLabel = DirectLabel( parent=frame, relief=None, pos=(1.2, 0.0, 0.0), text='', text_fg=(0, 0, 1, 1), text_scale=0.05, text_align=TextNode.ARight, text_font=DGG.getDefaultFont(), ) votesDownLabel = DirectLabel( parent=frame, relief=None, pos=(1.43, 0.0, 0.0), text='', text_fg=(1, 0, 0, 1), text_scale=0.05, text_align=TextNode.ARight, text_font=DGG.getDefaultFont(), ) nameLabel.hide() self.entryList.append((nameLabel, votesUpLabel, votesDownLabel))
def __init__(self): DirectFrame.__init__(self, scale=1.2) self['image'] = DGG.getDefaultDialogGeom() self['image_hpr'] = (0, 0, -90) self['image_scale'] = (0.67, 0.9, 0.325) self['image_color'] = (1, 1, 0.75, 1) self['image_pos'] = (0, 0, -0.09) self['relief'] = None self.reparentTo(base.a2dTopRight) self.setPos(-0.235, 0.0, -0.325) self.hide() self.head = None self.laffMeter = None self.exitButton = None self.friendButton = None self.teleportButton = None self.whisperButton = None self.nameText = None self.actionFrame = None self.actionFrameText = None self.actionFrameButton = None self.actionFrameButton2 = None self.avatarInfo = None self.action = None self.locationText = None self.shardText = None self.detailsExitBtn = None self.fsm = ClassicFSM.ClassicFSM('ToonPanel', [ State.State('off', self.enterOff, self.exitOff), State.State('waitOnAvatarInfoResponse', self.enterWaitOnAvatarInfoResponse, self.exitWaitOnAvatarInfoResponse, ['panel']), State.State('panel', self.enterPanel, self.exitPanel, ['off']) ], 'off', 'off') self.fsm.enterInitialState() self.actionFSM = ClassicFSM.ClassicFSM('ToonPanelActionFSM', [ State.State('off', self.enterOff, self.exitOff), State.State( 'waitOnAvatarStatusResponse', self.enterWaitOnAvatarStatusResponse, self.exitWaitOnAvatarStatusResponse, [ 'waitOnAvatarTeleportResponse', 'waitOnAvatarFriendListResponse', 'avatarBusy', 'off' ]), State.State('avatarBusy', self.enterAvatarBusy, self.exitAvatarBusy, ['off']), State.State('waitOnAvatarTeleportResponse', self.enterWaitOnAvatarTeleportResponse, self.exitWaitOnAvatarTeleportResponse, ['unableToTP']), State.State('unableToTP', self.enterUnableToTP, self.exitUnableToTP, ['off']), State.State('waitOnAvatarFriendListResponse', self.enterWaitOnAvatarFriendListResponse, self.exitWaitOnAvatarFriendListResponse, ['fRequestA', 'fRequestR']), State.State('fRequestA', self.enterFriendRequestAccepted, self.exitFriendRequestAccepted, ['off']), State.State('fRequestR', self.enterFriendRequestRejected, self.exitFriendRequestRejected, ['off']), State.State('removeFriendConfirm', self.enterRemoveFriendConfirm, self.exitRemoveFriendConfirm, ['off', 'removedFriend']), State.State('removedFriend', self.enterRemovedFriend, self.exitRemovedFriend, ['off']) ], 'off', 'off') self.actionFSM.enterInitialState()
def __init__(self, parent): global base if not logger.isEnabledFor(logging.DEBUG): global CONSOLE_MESSAGE CONSOLE_MESSAGE = ''' ----------------- Ship's Interface version 3.0.9_749 ------------------- Direct Ship Interface Enabled. Please use caution. Irresponsible use of this console may result in the ship's AI refusing access to this interface. type 'help' for basic commands. -------------------------------------------------------------------------''' # change up from parent/IC self.parent = parent localenv = globals() localenv['gameroot'] = self.parent self._iconsole = customConsoleClass(localsEnv=localenv) # line wrapper self.linewrap = textwrap.TextWrapper() self.linewrap.width = self.linelength # calculate window size # left = (self.h_pos) / self.scale # right = (self.h_pos + self.h_size) / self.scale # bottom = (self.v_pos) / self.scale # top = (self.v_pos + self.v_size) /self.scale # panda3d interface self.consoleFrame = DirectFrame(relief=DGG.GROOVE, frameColor=(200, 200, 200, 0.5), scale=self.scale, frameSize=(0, self.h_size / self.scale, 0, self.v_size / self.scale)) self.windowEvent(base.win) fixedWidthFont = None try: # try to load the defined font fixedWidthFont = parent.loader.loadFont(self.font) except Exception: traceback.print_exc() # if font is not valid use default font logger.warn('could not load the defined font %s" % str(self.font') fixedWidthFont = DGG.getDefaultFont() # text lines self._visibleLines = list( OnscreenText(parent=self.consoleFrame, text="", pos=(1, -i + 3 + self.numlines), align=TextNode.ALeft, mayChange=1, scale=1.0, fg=self.defaultTextColor) for i in range(self.numlines)) map(lambda x: x.setFont(fixedWidthFont), self._visibleLines) # text entry line self.consoleEntry = DirectEntry(self.consoleFrame, text="", command=self.submitTrigger, width=self.h_size / self.scale - 2, pos=(1, 0, 1.5), initialText="", numLines=1, focus=1, entryFont=fixedWidthFont) # self.console_output = ConsoleOutput(testme=True) self.echo(CONSOLE_MESSAGE) self.clipboard = pyperclip
def __init__(self, numPlayers, avIdList, votes, directions, namesList, disconnectedList, directionToGo, directionReason, directionTotals, *args, **kwargs): opts = { 'relief': None, 'geom': DGG.getDefaultDialogGeom(), 'geom_color': ToontownGlobals.GlobalDialogColor[:3] + (0.80, ), 'geom_scale': (1.75, 1, 0.25), 'pos': (0, 0, 0.825) } opts.update(kwargs) DirectFrame.__init__(self, *args, **opts) self.initialiseoptions(VoteResultsTrolleyPanel) listMultiplier = 1 if TravelGameGlobals.SpoofFour: listMultiplier = 4 self.avIdList = avIdList * listMultiplier self.numPlayers = numPlayers * listMultiplier self.votes = votes * listMultiplier self.directions = directions * listMultiplier self.namesList = namesList * listMultiplier self.disconnectedList = disconnectedList * listMultiplier self.directionToGo = directionToGo self.directionReason = directionReason self.directionTotals = directionTotals self.entryList = [] self.rowFrame = [] self.upDownFrame = DirectFrame( parent=self, relief=None, pos=self.getRowPos(-1), ) self.upLabel = DirectLabel(parent=self, relief=None, pos=(-0.5, 0, 0.06), text=TTLocalizer.TravelGameDirections[0] + ':', text_fg=(0.0, 0.0, 1.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) self.downLabel = DirectLabel(parent=self, relief=None, pos=(0.5, 0, 0.06), text=TTLocalizer.TravelGameDirections[1] + ':', text_fg=(1.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) self.totalVotesUpLabel = DirectLabel(parent=self.upLabel, relief=None, pos=(0.2, 0, 0.0), text='0', text_fg=(0.0, 0.0, 1.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) self.totalVotesDownLabel = DirectLabel(parent=self.downLabel, relief=None, pos=(0.2, 0, 0.0), text='0', text_fg=(1.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) self.totalFrame = DirectFrame( parent=self, relief=None, pos=self.getRowPos(self.numPlayers), ) self.totalVotesLabels = [ self.totalVotesUpLabel, self.totalVotesDownLabel ] self.resultFrame = DirectFrame( parent=self, relief=None, #pos = self.getRowPos(self.numPlayers+1), pos=self.getRowPos(0.5), ) self.resultLabel = DirectLabel(parent=self.resultFrame, text='', text_scale=0.06, pos=(0.7, 0, 0.0), text_align=TextNode.ACenter) self.setupResultLabel() for index in range(self.numPlayers): frame = DirectFrame( parent=self, relief=None, pos=self.getRowPos(index), ) self.rowFrame.append(frame) nameLabel = DirectFrame( parent=frame, relief=None, pos=(0.46, 0.0, 0.0), text=self.namesList[index], text_fg=(0.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ACenter, text_font=DGG.getDefaultFont() #ToontownGlobals.getSignFont(), ) votesUpLabel = DirectLabel( parent=frame, relief=None, pos=(1.2, 0.0, 0.0), text='', text_fg=(0, 0, 1, 1), text_scale=0.05, text_align=TextNode.ARight, text_font=DGG.getDefaultFont(), ) votesDownLabel = DirectLabel( parent=frame, relief=None, pos=(1.43, 0.0, 0.0), text='', text_fg=(1, 0, 0, 1), text_scale=0.05, text_align=TextNode.ARight, text_font=DGG.getDefaultFont(), ) nameLabel.hide() self.entryList.append((nameLabel, votesUpLabel, votesDownLabel)) self.avVotesLabel = {} self.avArrows = {} matchingGameGui = loader.loadModel( 'phase_3.5/models/gui/matching_game_gui') minnieArrow = matchingGameGui.find("**/minnieArrow") from toontown.minigame.DistributedTravelGame import map3dToAspect2d for index in range(self.numPlayers): avId = self.avIdList[index] av = base.cr.doId2do.get(avId) if av: height = av.getHeight() avPos = av.getPos(render) avPos.setZ(av.getZ() + 5) # height) labelPos = map3dToAspect2d(render, avPos) if not labelPos: continue labelPos.setZ(labelPos.getZ() + 0.3) arrow = None if self.votes[index] > 0: arrow = aspect2d.attachNewNode('avArrow') minnieArrow.copyTo(arrow) arrow.setScale(1.1, 1, 1.15) arrow.setPos(labelPos) if self.directions[index] == 0: arrow.setR(-90) arrow.setColorScale(0, 0, 1, 1) else: arrow.setR(90) arrow.setColorScale(1, 0, 0, 1) arrow.wrtReparentTo(self.resultFrame) arrow.hide() self.avArrows[index] = arrow fgColor = Vec4(0, 0, 0, 1) if self.votes[index] > 0: if self.directions[index] == 0: fgColor = Vec4(0, 0, 1, 1) else: fgColor = Vec4(1, 0, 0, 1) if self.votes[index] > 0: newLabel = DirectLabel( parent=aspect2d, #geom = DGG.getDefaultDialogGeom(), #geom_color =ToontownGlobals.GlobalDialogColor[:3]+(0.80,), #geom_scale = (0.1,1,0.1), relief=None, pos=labelPos, text='test', text_fg=(1, 1, 1, 1), #fgColor, text_scale=0.1, text_align=TextNode.ACenter, text_font=ToontownGlobals.getSignFont(), text_pos=(0, -0.01, 0)) else: newLabel = DirectLabel( parent=aspect2d, geom=DGG.getDefaultDialogGeom(), #geom_color =ToontownGlobals.GlobalDialogColor[:3]+(0.80,), geom_scale=(0.2, 1, 0.2), relief=None, pos=labelPos, text='test', text_fg=(0.5, 0.5, 0.5, 1), #fgColor, text_scale=0.1, text_align=TextNode.ACenter, text_font=ToontownGlobals.getSignFont(), text_pos=(0, -0.035, 0)) newLabel.wrtReparentTo(self.resultFrame) newLabel.hide() self.avVotesLabel[index] = newLabel matchingGameGui.removeNode() self.curArrowSfxIndex = 0 self.upArrowSfx = [] self.downArrowSfx = [] for i in range(5): self.upArrowSfx.append( base.loadSfx( "phase_4/audio/sfx/MG_sfx_travel_game_blue_arrow.mp3")) self.downArrowSfx.append( base.loadSfx( "phase_4/audio/sfx/MG_sfx_travel_game_red_arrow.mp3")) self.winVoteSfx = base.loadSfx( "phase_4/audio/sfx/MG_sfx_travel_game_win_vote.mp3") self.noVoteSfx = base.loadSfx( "phase_4/audio/sfx/MG_sfx_travel_game_square_no_vote_1.mp3") self.loseVoteSfx = base.loadSfx( "phase_4/audio/sfx/MG_sfx_travel_game_lose_vote.mp3") self.localAvatarWon = False self.localAvatarLost = False localIndex = self.avIdList.index(base.localAvatar.doId) localDirection = self.directions[localIndex] localVotes = self.votes[localIndex] if localVotes: if localDirection == self.directionToGo: if not TravelGameGlobals.ReverseWin: self.localAvatarWon = True else: self.localAvatarLost = True else: if not TravelGameGlobals.ReverseWin: self.localAvatarLost = True else: self.localAvatarWon = True
def load(self): self.ammo_gui = loader.loadModel( "phase_4/models/minigames/gun_ammo_gui.egg") self.ammo_gui.setScale(0.15) self.ammo_gui.setPos(0.38, 0, 0.1) self.hp_meter = DirectWaitBar( text=str(self.base.hp), text_roll=-90, text_scale=0.2, text_pos=(-0.025, 0), relief=DGG.RAISED, barColor=(1, 0, 0, 1), range=self.base.max_hp, value=self.base.hp, parent=base.a2dBottomRight, scale=0.4, pos=(-0.12, 0, 0.2), frameSize=(-0.4, 0.4, -0.2, 0.2), #borderWidth=(0.02, 0.02), ) self.hp_meter.setR(-90) self.hp_meter.hide() self.crosshair = getCrosshair() font = CIGlobals.getToonFont() box = DGG.getDefaultDialogGeom() if self.base.__class__.__name__ == "GunGameToonFPS": self.stats_container = DirectFrame(parent=base.a2dTopLeft, pos=(0.3, 0.2, -0.185)) self.stats_bg = OnscreenImage(image=box, color=(1, 1, 0.75, 1), scale=(0.5, 0.3, 0.3), parent=self.stats_container) self.stats_lbl = OnscreenText(font=font, text="Stats", pos=(-0.01, 0.08, 0), parent=self.stats_container) self.kills_lbl = OnscreenText(font=font, text="Kills: " + str(self.base.kills), pos=(-0.235, 0.025, 0), scale=0.055, parent=self.stats_container, align=TextNode.ALeft) self.deaths_lbl = OnscreenText(font=font, text="Deaths: " + str(self.base.deaths), pos=(-0.235, -0.04, 0), scale=0.055, parent=self.stats_container, align=TextNode.ALeft) self.points_lbl = OnscreenText(font=font, text="Points: " + str(self.base.points), pos=(-0.235, -0.105, 0), scale=0.055, parent=self.stats_container, align=TextNode.ALeft) self.stats_container.hide() del font del box
def __init__(self): ShowBase.__init__(self) self.setBackgroundColor(0, 0, 0) # make the font look nice at a big scale DGG.getDefaultFont().setPixelsPerUnit(100) # Store our mapping, with some sensible defaults. In a real game, you # will want to load these from a configuration file. self.mapping = InputMapping() self.mapping.mapAxis("Move forward", InputDevice.Axis.left_y) self.mapping.mapAxis("Move backward", InputDevice.Axis.left_y) self.mapping.mapAxis("Move left", InputDevice.Axis.left_x) self.mapping.mapAxis("Move right", InputDevice.Axis.left_x) self.mapping.mapButton("Jump", GamepadButton.face_a()) self.mapping.mapButton("Use", GamepadButton.face_b()) self.mapping.mapButton("Break", GamepadButton.face_x()) self.mapping.mapButton("Fix", GamepadButton.face_y()) # The geometry for our basic buttons maps = loader.loadModel("models/button_map") self.buttonGeom = ( maps.find("**/ready"), maps.find("**/click"), maps.find("**/hover"), maps.find("**/disabled")) # Change the default dialog skin. DGG.setDefaultDialogGeom("models/dialog.png") # create a sample title self.textscale = 0.1 self.title = DirectLabel( scale=self.textscale, pos=(base.a2dLeft + 0.05, 0.0, base.a2dTop - (self.textscale + 0.05)), frameColor=VBase4(0, 0, 0, 0), text="Button Mapping", text_align=TextNode.ALeft, text_fg=VBase4(1, 1, 1, 1), text_shadow=VBase4(0, 0, 0, 0.75), text_shadowOffset=Vec2(0.05, 0.05)) self.title.setTransparency(1) # Set up the list of actions that we can map keys to # create a frame that will create the scrollbars for us # Load the models for the scrollbar elements thumbMaps = loader.loadModel("models/thumb_map") thumbGeom = ( thumbMaps.find("**/thumb_ready"), thumbMaps.find("**/thumb_click"), thumbMaps.find("**/thumb_hover"), thumbMaps.find("**/thumb_disabled")) incMaps = loader.loadModel("models/inc_map") incGeom = ( incMaps.find("**/inc_ready"), incMaps.find("**/inc_click"), incMaps.find("**/inc_hover"), incMaps.find("**/inc_disabled")) decMaps = loader.loadModel("models/dec_map") decGeom = ( decMaps.find("**/dec_ready"), decMaps.find("**/dec_click"), decMaps.find("**/dec_hover"), decMaps.find("**/dec_disabled")) # create the scrolled frame that will hold our list self.lstActionMap = DirectScrolledFrame( # make the frame occupy the whole window frameSize=VBase4(base.a2dLeft, base.a2dRight, 0.0, 1.55), # make the canvas as big as the frame canvasSize=VBase4(base.a2dLeft, base.a2dRight, 0.0, 0.0), # set the frames color to white frameColor=VBase4(0, 0, 0.25, 0.75), pos=(0, 0, -0.8), verticalScroll_scrollSize=0.2, verticalScroll_frameColor=VBase4(0.02, 0.02, 0.02, 1), verticalScroll_thumb_relief=1, verticalScroll_thumb_geom=thumbGeom, verticalScroll_thumb_pressEffect=False, verticalScroll_thumb_frameColor=VBase4(0, 0, 0, 0), verticalScroll_incButton_relief=1, verticalScroll_incButton_geom=incGeom, verticalScroll_incButton_pressEffect=False, verticalScroll_incButton_frameColor=VBase4(0, 0, 0, 0), verticalScroll_decButton_relief=1, verticalScroll_decButton_geom=decGeom, verticalScroll_decButton_pressEffect=False, verticalScroll_decButton_frameColor=VBase4(0, 0, 0, 0),) # creat the list items idx = 0 self.listBGEven = base.loader.loadModel("models/list_item_even") self.listBGOdd = base.loader.loadModel("models/list_item_odd") self.actionLabels = {} for action in self.mapping.actions: mapped = self.mapping.formatMapping(action) item = self.__makeListItem(action, mapped, idx) item.reparentTo(self.lstActionMap.getCanvas()) idx += 1 # recalculate the canvas size to set scrollbars if necesary self.lstActionMap["canvasSize"] = ( base.a2dLeft+0.05, base.a2dRight-0.05, -(len(self.mapping.actions)*0.1), 0.09) self.lstActionMap.setCanvasSize()
def __init__(self): """initialise the engine""" ShowBase.__init__(self) FSM.__init__(self, "FSM-Game") # # BASIC APPLICATION CONFIGURATIONS # # disable pandas default camera driver self.disableMouse() # set background color to black self.setBackgroundColor(0, 0, 0) # set antialias for the complete sceen to automatic self.render.setAntialias(AntialiasAttrib.MAuto) # shader generator render.setShaderAuto() # Enhance font readability DGG.getDefaultFont().setPixelsPerUnit(100) # # CONFIGURATION LOADING # # load given variables or set defaults # check if audio should be muted mute = ConfigVariableBool("audio-mute", False).getValue() if mute: self.disableAllAudio() else: self.enableAllAudio() # check if particles should be enabled particles = ConfigVariableBool("particles-enabled", True).getValue() if particles: self.enableParticles() # check if the config file hasn't been created if not os.path.exists(prcFile): # get the displays width and height w = self.pipe.getDisplayWidth() h = self.pipe.getDisplayHeight() # set window properties # clear all properties not previously set base.win.clearRejectedProperties() # setup new window properties props = WindowProperties() # Fullscreen props.setFullscreen(True) # set the window size to the screen resolution props.setSize(w, h) # request the new properties base.win.requestProperties(props) elif base.appRunner: # As when the application is started as appRunner instance # it doesn't respect our loadPrcFile configurations specific # to the window, hence we need to manually set them here. for dec in range(mainConfig.getNumDeclarations()): #TODO: Check for all window specific variables like # fullscreen, screen size, title and window # decoration that you have in your configuration # and set them by your own. if mainConfig.getVariableName(dec) == "fullscreen": if not mainConfig.getDeclaration(dec).getBoolWord(0): break # get the displays width and height w = self.pipe.getDisplayWidth() h = self.pipe.getDisplayHeight() # set window properties # clear all properties not previously set base.win.clearRejectedProperties() # setup new window properties props = WindowProperties() # Fullscreen props.setFullscreen(True) # set the window size to the screen resolution props.setSize(w, h) # request the new properties base.win.requestProperties(props) break # automatically safe configuration at application exit base.exitFunc = self.__writeConfig # due to the delayed window resizing and switch to fullscreen # we wait some time until everything is set so we can savely # proceed with other setups like the menus if base.appRunner: # this behaviour only happens if run from p3d files and # hence the appRunner is enabled taskMgr.doMethodLater(0.5, self.postInit, "post initialization", extraArgs=[]) else: self.postInit()
def __init__(self, target, increment=0.01, hprIncrement=1.0, parent=None, pos=(0.0, 0.0, 0.0)): DirectFrame.__init__(self, parent or aspect2d) self.target = target self.increment = increment self.minimized = False self.mainFrame = DirectFrame( parent=self, relief=None, geom=DGG.getDefaultDialogGeom(), geom_color=(1, 1, 0.75, 1), geom_scale=self.ORIGINAL_SCALE, pos=pos, ) # Arrow gui (preload) gui = loader.loadModel('phase_3/models/gui/tt_m_gui_mat_mainGui.bam') # Set Bins self.mainFrame.setBin('gui-popup', 0) # Name name = self.target.getName() self.nameLabel = TTLabel(self.mainFrame, text='Target: %s' % name, pos=self.ORIG_NAME_POS, text_align=TextNode.ALeft, text_wordwrap=13) # Pos pos = self.target.getPos() self.posLabel = TTLabel(self.mainFrame, text='Position: ', pos=(-0.39, 0.0, 0.055), text_align=TextNode.ALeft) self.xPosSpinner = PlacerToolSpinner(self.mainFrame, value=pos[0], pos=(-0.085, 0.0, 0.06), increment=increment, callback=self.handleXChange) self.yPosSpinner = PlacerToolSpinner(self.mainFrame, value=pos[1], pos=(0.1, 0.0, 0.06), increment=increment, callback=self.handleYChange) self.zPosSpinner = PlacerToolSpinner(self.mainFrame, value=pos[2], pos=(0.28, 0.0, 0.06), increment=increment, callback=self.handleZChange) # hpr hpr = self.target.getHpr() self.hprLabel = TTLabel(self.mainFrame, text='HPR: ', pos=(-0.39, 0.0, -0.19), text_align=TextNode.ALeft) self.hSpinner = PlacerToolSpinner(self.mainFrame, value=hpr[0], pos=(-0.085, 0.0, -0.195), increment=hprIncrement, callback=self.handleHChange) self.pSpinner = PlacerToolSpinner(self.mainFrame, value=hpr[1], pos=(0.1, 0.0, -0.195), increment=hprIncrement, callback=self.handlePChange) self.rSpinner = PlacerToolSpinner(self.mainFrame, value=hpr[2], pos=(0.28, 0.0, -0.195), increment=hprIncrement, callback=self.handleRChange) # scale scale = [round(s, 3) for s in self.target.getScale()] self.scaleLabel = TTLabel(self.mainFrame, text='Scale: ', pos=(-0.39, 0.0, -0.4), text_align=TextNode.ALeft) self.sxSpinner = PlacerToolSpinner(self.mainFrame, value=hpr[0], pos=(-0.085, 0.0, -0.4), increment=increment, callback=self.handleSxChange) self.sySpinner = PlacerToolSpinner(self.mainFrame, value=hpr[1], pos=(0.1, 0.0, -0.4), increment=increment, callback=self.handleSyChange) self.szSpinner = PlacerToolSpinner(self.mainFrame, value=hpr[2], pos=(0.28, 0.0, -0.4), increment=increment, callback=self.handleSzChange) gui.removeNode() gui = loader.loadModel('phase_3/models/gui/tt_m_gui_mat_nameShop') thumb = gui.find('**/tt_t_gui_mat_namePanelCircle') self.dragButton = DirectButton(self.mainFrame, relief=None, image=thumb, image_scale=(0.5, 0.5, 0.5), pos=self.ORIG_DRAG_BUTTON_POS) self.minimizeButton = DirectButton(self.mainFrame, relief=None, image=thumb, image_scale=(0.5, 0.5, 0.5), image_color=(0.0, 0.0, 0.65, 1.0), pos=self.ORIG_MINI_BUTTON_POS, command=self.toggleMinimize, extraArgs=[]) self.dragButton.bind(DGG.B1PRESS, self.onPress) self.dragButton.bind(DGG.B1RELEASE, self.onRelease) if target is not None: self.setTarget(target)
def pickedSomething_down(self): if self.rolledOverTag: base.playSfx(DGG.getDefaultClickSound()) avatar = self.cr.doId2do.get(self.rolledOverTag) avatar.nameTag.setPickerState('down')
def __init__(self, offset, parent, unit_type, default_hp, hp, default_ap, ap): self.offset = offset self.frame = DirectFrame( relief = DGG.FLAT , scale = 1 , frameSize = (-0.5, 0.5, 0, -0.5) , parent = parent ) self.frame.setBillboardPointEye() self.frame.setLightOff() self.frame.setBin("fixed", 40) self.frame.setDepthTest(False) self.frame.setDepthWrite(False) fixedWidthFont = loader.loadFont(GUI_FONT)#@UndefinedVariable #fixedWidthFont.setPixelsPerUnit(60) #fixedWidthFont.setRenderMode(fontt.RMSolid) if not fixedWidthFont.isValid(): print "pandaInteractiveConsole.py :: could not load the defined font %s" % str(self.font) fixedWidthFont = DGG.getDefaultFont() self.label = OnscreenText( parent = self.frame , text = "" , pos = (offset.getX(),offset.getZ()+0.1) , align=TextNode.ACenter , mayChange=True , scale=0.1 , fg = (1,0,0,1) #, shadow = (0, 0, 0, 1) #, frame = (200,0,0,1) ) self.label.setFont( fixedWidthFont ) #self.label.setLightOff() self.all_icons = {} self.visible_icons = {} self.addIcon("overwatch") self.addIcon("set_up") self.ap_bar = DirectWaitBar(parent = self.frame , text = "" , range = default_ap , value = ap , pos = (offset.getX()+0.08,0,offset.getZ()-0.27) , barColor = (0,0,1,1) , frameColor = (0,0,0.5,0.2) , scale = (0.3,0.5,0.3)) self.hp_bar = DirectWaitBar(parent = self.frame , text = "" , range = default_hp , value = hp , pos = (offset.getX()+0.08,0,offset.getZ()-0.2) , barColor = (0,1,0,1) , frameColor = (1,0,0,0.9) , scale = (0.3,0.5,0.3)) self.insignia = OnscreenImage(parent = self.frame ,image = "unit_" + unit_type + "_big_transparent_32.png" #,pos = (offset.getX(),0,offset.getZ()+0.14) , pos = (offset.getX() - 0.31,0,offset.getZ()-0.23) ,scale = 0.09) self.insignia.setTransparency(TransparencyAttrib.MAlpha)
def __init__(self): ShowBase.__init__(self) self.setBackgroundColor(0, 0, 0) # make the font look nice at a big scale DGG.getDefaultFont().setPixelsPerUnit(100) # Store our mapping, with some sensible defaults. In a real game, you # will want to load these from a configuration file. self.mapping = InputMapping() self.mapping.mapAxis("Move forward", InputDevice.Axis.left_y) self.mapping.mapAxis("Move backward", InputDevice.Axis.left_y) self.mapping.mapAxis("Move left", InputDevice.Axis.left_x) self.mapping.mapAxis("Move right", InputDevice.Axis.left_x) self.mapping.mapButton("Jump", GamepadButton.face_a()) self.mapping.mapButton("Use", GamepadButton.face_b()) self.mapping.mapButton("Break", GamepadButton.face_x()) self.mapping.mapButton("Fix", GamepadButton.face_y()) # The geometry for our basic buttons maps = loader.loadModel("models/button_map") self.buttonGeom = (maps.find("**/ready"), maps.find("**/click"), maps.find("**/hover"), maps.find("**/disabled")) # Change the default dialog skin. DGG.setDefaultDialogGeom("models/dialog.png") # create a sample title self.textscale = 0.1 self.title = DirectLabel(scale=self.textscale, pos=(base.a2dLeft + 0.05, 0.0, base.a2dTop - (self.textscale + 0.05)), frameColor=VBase4(0, 0, 0, 0), text="Button Mapping", text_align=TextNode.ALeft, text_fg=VBase4(1, 1, 1, 1), text_shadow=VBase4(0, 0, 0, 0.75), text_shadowOffset=Vec2(0.05, 0.05)) self.title.setTransparency(1) # Set up the list of actions that we can map keys to # create a frame that will create the scrollbars for us # Load the models for the scrollbar elements thumbMaps = loader.loadModel("models/thumb_map") thumbGeom = (thumbMaps.find("**/thumb_ready"), thumbMaps.find("**/thumb_click"), thumbMaps.find("**/thumb_hover"), thumbMaps.find("**/thumb_disabled")) incMaps = loader.loadModel("models/inc_map") incGeom = (incMaps.find("**/inc_ready"), incMaps.find("**/inc_click"), incMaps.find("**/inc_hover"), incMaps.find("**/inc_disabled")) decMaps = loader.loadModel("models/dec_map") decGeom = (decMaps.find("**/dec_ready"), decMaps.find("**/dec_click"), decMaps.find("**/dec_hover"), decMaps.find("**/dec_disabled")) # create the scrolled frame that will hold our list self.lstActionMap = DirectScrolledFrame( # make the frame occupy the whole window frameSize=VBase4(base.a2dLeft, base.a2dRight, 0.0, 1.55), # make the canvas as big as the frame canvasSize=VBase4(base.a2dLeft, base.a2dRight, 0.0, 0.0), # set the frames color to white frameColor=VBase4(0, 0, 0.25, 0.75), pos=(0, 0, -0.8), verticalScroll_scrollSize=0.2, verticalScroll_frameColor=VBase4(0.02, 0.02, 0.02, 1), verticalScroll_thumb_relief=1, verticalScroll_thumb_geom=thumbGeom, verticalScroll_thumb_pressEffect=False, verticalScroll_thumb_frameColor=VBase4(0, 0, 0, 0), verticalScroll_incButton_relief=1, verticalScroll_incButton_geom=incGeom, verticalScroll_incButton_pressEffect=False, verticalScroll_incButton_frameColor=VBase4(0, 0, 0, 0), verticalScroll_decButton_relief=1, verticalScroll_decButton_geom=decGeom, verticalScroll_decButton_pressEffect=False, verticalScroll_decButton_frameColor=VBase4(0, 0, 0, 0), ) # creat the list items idx = 0 self.listBGEven = base.loader.loadModel("models/list_item_even") self.listBGOdd = base.loader.loadModel("models/list_item_odd") self.actionLabels = {} for action in self.mapping.actions: mapped = self.mapping.formatMapping(action) item = self.__makeListItem(action, mapped, idx) item.reparentTo(self.lstActionMap.getCanvas()) idx += 1 # recalculate the canvas size to set scrollbars if necesary self.lstActionMap["canvasSize"] = (base.a2dLeft + 0.05, base.a2dRight - 0.05, -(len(self.mapping.actions) * 0.1), 0.09) self.lstActionMap.setCanvasSize()
def makeActionPanel(self): self.actionFrame = DirectFrame(image=DGG.getDefaultDialogGeom(), image_scale=(0.7, 0.5, 0.45), image_color=(1, 1, 0.75, 1), relief=None) self.actionFrame.reparentTo(base.a2dTopRight) self.actionFrame.setPos(-0.815, 0, -0.31) self.actionFrameText = OnscreenText(text='', parent=self.actionFrame, scale=0.05, wordwrap=12, pos=(0, 0.1)) return
def __init__(self, mg, king, points): DirectFrame.__init__(self, parent = aspect2d) self.setBin('gui-popup', 60) self.mg = mg # Let's create the background box = DGG.getDefaultDialogGeom() self.bg = OnscreenImage(image = box, color = (1, 1, 0.75, 1), scale = (1.9, 1.4, 1.4), parent = self) # Let's create the header toonFont = CIGlobals.getToonFont() minnieFont = CIGlobals.getMinnieFont() name = 'Nobody' if king: name = king.getName() self.kingId = king.doId else: king = base.localAvatar self.kingId = 0 self.title = OnscreenText(text = '%s is King!' % name, pos = (0, 0.5, 0), font = toonFont, scale = 0.12, parent = self, shadow = (0.5, 0.5, 0.5, 0.6)) # Let's create the Toon head headFrame = self.attachNewNode('head') headFrame.setPosHprScale(0, 0, -0.1, 180, 0, 0, 0.3, 0.3, 0.3) head = ToonGlobals.generateGuiHead(king) head.reparentTo(headFrame) # Let's create the points text self.amt_label = OnscreenText(text = 'Your Points: 0', pos = (-0.012, -0.4, 0), font = toonFont, scale = 0.12, parent = self, shadow = (0.5, 0.5, 0.5, 0.6)) self.amt_label.hide() # Let's create the bad news text self.motivator = OnscreenText(text = 'Better luck next time!', pos = (0, -0.6, 0), font = minnieFont, scale = 0.125, parent = self, fg = (1, 0, 0, 1), shadow = (0.2, 0.2, 0.2, 1)) self.motivator.hide() self.easterEgg = False if 50 < points != 100: self.motivator['fg'] = (0, 1, 0, 1) self.motivator.setText('Great job!') elif points == 100: self.motivator['fg'] = (0, 1, 0, 1) if random.randint(0, 100) <= 10: self.motivator.setText('YOU THE REAL MVP!') self.easterEgg = True else: self.motivator.setText('AMAZING!') # Let's create the sound effects self.zeroPointsSfx = loader.loadSfx('phase_4/audio/sfx/MG_neg_buzzer.ogg') self.poorScoreSfx = loader.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_no_bonus.ogg') self.goodScoreSfx = loader.loadSfx('phase_4/audio/sfx/MG_pairing_match_bonus_both.ogg') self.stomperSfx = loader.loadSfx('phase_4/audio/sfx/CHQ_FACT_stomper_small.ogg') self.fireworkSfx = loader.loadSfx('phase_4/audio/sfx/firework_explosion_02.ogg') self.perfectSfx = loader.loadSfx('phase_5/audio/sfx/SZ_MM_fanfare.ogg') self.tick_fastSfx = loader.loadSfx('phase_4/audio/sfx/MG_maze_pickup.ogg') self.tick_slowSfx = loader.loadSfx('phase_3.5/audio/sfx/tick_counter.ogg') self.easterEggSfx = loader.loadSfx('phase_4/audio/sfx/avatar_emotion_very_sad.ogg') # Let's create the basic sequence self.pointsSeq = Sequence(Func(self.amt_label.show), Wait(0.25)) self.seqLevel = 0 self.fakeNumber = 0 self.points = points
def __init__(self, numPlayers, avIdList, votes, directions, namesList, disconnectedList, directionToGo, directionReason, directionTotals, *args, **kwargs): opts = {'relief': None, 'geom': DGG.getDefaultDialogGeom(), 'geom_color': ToontownGlobals.GlobalDialogColor[:3] + (0.8,), 'geom_scale': (1.75, 1, 0.25), 'pos': (0, 0, 0.825)} opts.update(kwargs) DirectFrame.__init__(self, *args, **opts) self.initialiseoptions(VoteResultsTrolleyPanel) listMultiplier = 1 if TravelGameGlobals.SpoofFour: listMultiplier = 4 self.avIdList = avIdList * listMultiplier self.numPlayers = numPlayers * listMultiplier self.votes = votes * listMultiplier self.directions = directions * listMultiplier self.namesList = namesList * listMultiplier self.disconnectedList = disconnectedList * listMultiplier self.directionToGo = directionToGo self.directionReason = directionReason self.directionTotals = directionTotals self.entryList = [] self.rowFrame = [] self.upDownFrame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(-1)) self.upLabel = DirectLabel(parent=self, relief=None, pos=(-0.5, 0, 0.06), text=TTLocalizer.TravelGameDirections[0] + ':', text_fg=(0.0, 0.0, 1.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) self.downLabel = DirectLabel(parent=self, relief=None, pos=(0.5, 0, 0.06), text=TTLocalizer.TravelGameDirections[1] + ':', text_fg=(1.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) self.totalVotesUpLabel = DirectLabel(parent=self.upLabel, relief=None, pos=(0.2, 0, 0.0), text='0', text_fg=(0.0, 0.0, 1.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) self.totalVotesDownLabel = DirectLabel(parent=self.downLabel, relief=None, pos=(0.2, 0, 0.0), text='0', text_fg=(1.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight) self.totalFrame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(self.numPlayers)) self.totalVotesLabels = [self.totalVotesUpLabel, self.totalVotesDownLabel] self.resultFrame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(0.5)) self.resultLabel = DirectLabel(parent=self.resultFrame, text='', text_scale=0.06, pos=(0.7, 0, 0.0), text_align=TextNode.ACenter) self.setupResultLabel() for index in range(self.numPlayers): frame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(index)) self.rowFrame.append(frame) nameLabel = DirectFrame(parent=frame, relief=None, pos=(0.46, 0.0, 0.0), text=self.namesList[index], text_fg=(0.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ACenter, text_font=DGG.getDefaultFont()) votesUpLabel = DirectLabel(parent=frame, relief=None, pos=(1.2, 0.0, 0.0), text='', text_fg=(0, 0, 1, 1), text_scale=0.05, text_align=TextNode.ARight, text_font=DGG.getDefaultFont()) votesDownLabel = DirectLabel(parent=frame, relief=None, pos=(1.43, 0.0, 0.0), text='', text_fg=(1, 0, 0, 1), text_scale=0.05, text_align=TextNode.ARight, text_font=DGG.getDefaultFont()) nameLabel.hide() self.entryList.append((nameLabel, votesUpLabel, votesDownLabel)) self.avVotesLabel = {} self.avArrows = {} matchingGameGui = loader.loadModel('phase_3.5/models/gui/matching_game_gui') minnieArrow = matchingGameGui.find('**/minnieArrow') from toontown.minigame.DistributedTravelGame import map3dToAspect2d for index in range(self.numPlayers): avId = self.avIdList[index] av = base.cr.doId2do.get(avId) if av: height = av.getHeight() avPos = av.getPos(render) avPos.setZ(av.getZ() + 5) labelPos = map3dToAspect2d(render, avPos) if not labelPos: continue labelPos.setZ(labelPos.getZ() + 0.3) arrow = None if self.votes[index] > 0: arrow = aspect2d.attachNewNode('avArrow') minnieArrow.copyTo(arrow) arrow.setScale(1.1, 1, 1.15) arrow.setPos(labelPos) if self.directions[index] == 0: arrow.setR(-90) arrow.setColorScale(0, 0, 1, 1) else: arrow.setR(90) arrow.setColorScale(1, 0, 0, 1) arrow.wrtReparentTo(self.resultFrame) arrow.hide() self.avArrows[index] = arrow fgColor = Vec4(0, 0, 0, 1) if self.votes[index] > 0: if self.directions[index] == 0: fgColor = Vec4(0, 0, 1, 1) else: fgColor = Vec4(1, 0, 0, 1) if self.votes[index] > 0: newLabel = DirectLabel(parent=aspect2d, relief=None, pos=labelPos, text='test', text_fg=(1, 1, 1, 1), text_scale=0.1, text_align=TextNode.ACenter, text_font=ToontownGlobals.getSignFont(), text_pos=(0, -0.01, 0)) else: newLabel = DirectLabel(parent=aspect2d, geom=DGG.getDefaultDialogGeom(), geom_scale=(0.2, 1, 0.2), relief=None, pos=labelPos, text='test', text_fg=(0.5, 0.5, 0.5, 1), text_scale=0.1, text_align=TextNode.ACenter, text_font=ToontownGlobals.getSignFont(), text_pos=(0, -0.035, 0)) newLabel.wrtReparentTo(self.resultFrame) newLabel.hide() self.avVotesLabel[index] = newLabel matchingGameGui.removeNode() self.curArrowSfxIndex = 0 self.upArrowSfx = [] self.downArrowSfx = [] for i in range(5): self.upArrowSfx.append(base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_blue_arrow.mp3')) self.downArrowSfx.append(base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_red_arrow.mp3')) self.winVoteSfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_win_vote.mp3') self.noVoteSfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_square_no_vote_1.mp3') self.loseVoteSfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_lose_vote.mp3') self.localAvatarWon = False self.localAvatarLost = False localIndex = self.avIdList.index(base.localAvatar.doId) localDirection = self.directions[localIndex] localVotes = self.votes[localIndex] if localVotes: if localDirection == self.directionToGo: if not TravelGameGlobals.ReverseWin: self.localAvatarWon = True else: self.localAvatarLost = True elif not TravelGameGlobals.ReverseWin: self.localAvatarLost = True else: self.localAvatarWon = True return
def __init__(self): """initialise the engine""" ShowBase.__init__(self) base.notify.info("Version {}".format(versionstring)) FSM.__init__(self, "FSM-Game") # # BASIC APPLICATION CONFIGURATIONS # # disable pandas default camera driver self.disableMouse() # set antialias for the complete sceen to automatic self.render.setAntialias(AntialiasAttrib.MAuto) # shader generator render.setShaderAuto() # Enhance font readability DGG.getDefaultFont().setPixelsPerUnit(100) # get the displays width and height for later usage self.dispWidth = self.pipe.getDisplayWidth() self.dispHeight = self.pipe.getDisplayHeight() self.win.setClearColor((0, 0, 0, 1)) # # CONFIGURATION LOADING # # load given variables or set defaults # check if particles should be enabled # NOTE: If you use the internal physics engine, this always has # to be enabled! #particles = ConfigVariableBool("particles-enabled", True).getValue() #if particles: # self.enableParticles() def setFullscreen(): """Helper function to set the window fullscreen with width and height set to the screens size""" # set window properties # clear all properties not previously set base.win.clearRejectedProperties() # setup new window properties props = WindowProperties() # Fullscreen props.setFullscreen(True) # set the window size to the screen resolution props.setSize(self.dispWidth, self.dispHeight) # request the new properties base.win.requestProperties(props) # Set the config variables so we correctly store the # new size and fullscreen setting later winSize = ConfigVariableString("win-size") winSize.setValue("{} {}".format(self.dispWidth, self.dispHeight)) fullscreen = ConfigVariableBool("fullscreen") fullscreen.setValue(True) # Render a frame to make sure the fullscreen is applied # before we do anything else self.taskMgr.step() # make sure to propagate the new aspect ratio properly so # the GUI and other things will be scaled appropriately aspectRatio = self.dispWidth / self.dispHeight self.adjustWindowAspectRatio(aspectRatio) # check if the config file hasn't been created if not os.path.exists(prcFile): setFullscreen() # automatically safe configuration at application exit base.exitFunc = self.__writeConfig # # INITIALIZE GAME CONTENT # self.titleMusic = loader.loadMusic( "audio/Golden_Antelope_-_Detective_Story.ogg") self.titleMusic.setLoop(True) self.titleMusic.play() # # EVENT HANDLING # # By default we accept the escape key self.accept("escape", self.__escape) # # ENTER GAMES INITIAL FSM STATE # self.request("Menu")
def __init__( self, parent ): self.parent = parent # line wrapper self.linewrap = textwrap.TextWrapper() self.linewrap.width = self.linelength # calculate window size left = (self.h_pos) / self.scale right = (self.h_pos + self.h_size) / self.scale bottom = (self.v_pos) / self.scale top = (self.v_pos + self.v_size) /self.scale # panda3d interface self.consoleFrame = DirectFrame ( relief = DGG.GROOVE , frameColor = (200, 200, 200, 0.5) , scale=self.scale , frameSize = (0, self.h_size / self.scale, 0, self.v_size / self.scale) ) self.windowEvent( base.win ) # try to load the defined font try: fixedWidthFont = loader.loadFont(self.font) except: print "pandaInteractiveConsole.py :: could not load the defined font %s" % str(self.font) fixedWidthFont = DGG.getDefaultFont() # if font is not valid use default font if not fixedWidthFont.isValid(): if self.font is None: print "pandaInteractiveConsole.py :: could not load the defined font %s" % str(self.font) fixedWidthFont = DGG.getDefaultFont() # text entry line self.consoleEntry = DirectEntry ( self.consoleFrame , text = "" , command = self.onEnterPress , width = self.h_size/self.scale - 2 , pos = (1, 0, 1.5) , initialText = "" , numLines = 1 , focus = 1 , entryFont = fixedWidthFont) # output lines self.consoleOutputList = list() for i in xrange( self.numlines ): label = OnscreenText( parent = self.consoleFrame , text = "" , pos = (1, -i+3+self.numlines) , align=TextNode.ALeft , mayChange=1 , scale=1.0 , fg = self.defaultTextColor ) label.setFont( fixedWidthFont ) self.consoleOutputList.append( label ) # list of the last commands of the user self.userCommandList = list() self.userCommandListLength = 100 for i in xrange(self.userCommandListLength): self.userCommandList.append('') self.userCommandPos = 0 # buffer for data self.textBuffer = list() self.textBufferLength = 1000 for i in xrange(self.textBufferLength): self.textBuffer.append(['', DEFAULT_COLOR]) self.textBufferPos = self.textBufferLength-self.numlines # toggle the window at least once to activate the events self.toggleConsole() self.toggleConsole() # call the help-command on start self.onEnterPress("help")
def load(self): base.cr.renderFrame() base.camLens.setMinFov(CIGlobals.DefaultCameraFov / (4./3.)) self.__setupStageToon() holidayMgr = base.cr.holidayManager self.props = [] self.world = loader.loadModel('phase_9/models/cogHQ/SellbotHQExterior.bam') self.world.reparentTo(base.render) self.world.setPos(0, 227.09, -25.36) self.sky = loader.loadModel('phase_9/models/cogHQ/cog_sky.bam') self.sky.setScale(1) self.sky.reparentTo(base.render) self.sky.find('**/InnerGroup').removeNode() self.fog = Fog('charSelectFog') self.fog.setColor(0.2, 0.2, 0.2) self.fog.setExpDensity(0.003) base.render.setFog(self.fog) # Let's fix the flickering doors. doors = self.world.find('**/doors').getChildren() for door in doors: for frameHole in door.findAllMatches('**/doorFrameHole*'): frameHole.removeNode() if holidayMgr.getHoliday() == HolidayType.CHRISTMAS: piles = { 'half' : {'pos' : (57.28, 86.47, -25.00), 'hpr' : (46.79, 0, 0)}, 'full' : {'pos' : (71.23, 85.2, -25.00), 'hpr' : (290.82, 0, 0)}, 'half_2' : {'pos' : (-15, 128.69, -25), 'hpr' : (60.26, 0, 0)} } for pileType, info in piles.items(): if '_' in pileType: pileType = pileType[:-2] pile = loader.loadModel('phase_8/models/props/snow_pile_%s.bam' % (pileType)) pile.reparentTo(render) pile.setPos(info['pos']) pile.setHpr(info['hpr']) self.props.append(pile) self.world.find('**/TopRocks').removeNode() snowTxt = loader.loadTexture('winter/maps/sbhq_snow.png') self.world.find('**/Ground').setTexture(snowTxt, 1) self.particles = ParticleLoader.loadParticleEffect('phase_8/etc/snowdisk.ptf') self.particles.setPos(0, 0, 5) self.particlesRender = self.world.attachNewNode('snowRender') self.particlesRender.setDepthWrite(0) self.particlesRender.setBin('fixed', 1) self.particles.start(parent = camera, renderParent = self.particlesRender) self.fog.setColor(0.486, 0.784, 1) self.fog.setExpDensity(0.006) base.render.setFog(self.fog) self.title = DirectLabel(text=self.TITLE, text_font=CIGlobals.getMickeyFont(), text_fg=(1, 0.9, 0.1, 1), relief=None, text_scale=0.13, pos=(0, 0, 0.82)) self.charNameLabel = OnscreenText(text = "", font = CIGlobals.getMickeyFont(), pos = (-0.25, 0.5, 0), fg = (1, 0.9, 0.1, 1.0)) self.charNameLabel.hide() self.frame = DirectFrame() self.frame['image'] = DGG.getDefaultDialogGeom() self.frame['image_color'] = CIGlobals.DialogColor self.frame['image_scale'] = (-0.9, -0.9, 0.8) self.frame['image_pos'] = (0.82, 0, -0.125) self.playOrCreateButton = DirectButton(text = "", pos = (0.8125, 0, -0.35), command = self.__action, geom = CIGlobals.getDefaultBtnGeom(), text_scale = 0.06, relief = None, text_pos = (0, -0.01)) self.playOrCreateButton.hide() self.deleteButton = DirectButton(text = "Delete", pos = (0.8125, 0, -0.45), command = self.__action, extraArgs = ['delete'], geom = CIGlobals.getDefaultBtnGeom(), text_scale = 0.06, relief = None, text_pos = (0, -0.01)) self.deleteButton.hide() self.quitButton = DirectButton(text = "Quit", pos = (-1.10, 0, -0.925), command = self.__action, extraArgs = ['quit'], text_scale = 0.06, geom = CIGlobals.getDefaultBtnGeom(), relief = None, text_pos = (0, -0.01)) textRolloverColor = Vec4(1, 1, 0, 1) textDownColor = Vec4(0.5, 0.9, 1, 1) textDisabledColor = Vec4(0.4, 0.8, 0.4, 1) for slot in range(6): if self.avChooser.hasToonInSlot(slot): choice = self.avChooser.getAvChoiceBySlot(slot) text = choice.name else: text = self.NO_TOON btn = DirectButton( relief=None, text = text, text_scale=0.06, text_align=TextNode.ALeft, text1_bg=textDownColor, text2_bg=textRolloverColor, text3_fg=textDisabledColor, textMayChange=0, command=self.__handleCharButton, extraArgs=[slot], text_pos = (0, 0, 0.0) ) btn.setPythonTag('slot', slot) self.charButtons.append(btn) btn['state'] = DGG.NORMAL gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui.bam') listXorigin = -0.02 listFrameSizeX = 0.625 listZorigin = -0.43 listFrameSizeZ = 0.51 arrowButtonScale = 0.0 itemFrameXorigin = -0.237 itemFrameZorigin = 0.365 buttonXstart = itemFrameXorigin + 0.293 self.charList = DirectScrolledList( relief=None, pos=(0.75, 0, -0.225), incButton_image=None, #incButton_relief=None, incButton_scale=(arrowButtonScale, arrowButtonScale, -arrowButtonScale), #incButton_pos=(buttonXstart, 0, itemFrameZorigin - 0.999), #incButton_image3_color=Vec4(1, 1, 1, 0.2), decButton_image=None, #decButton_relief=None, decButton_scale=(arrowButtonScale, arrowButtonScale, arrowButtonScale), #decButton_pos=(buttonXstart, 0, itemFrameZorigin + 0.125), #decButton_image3_color=Vec4(1, 1, 1, 0.2), itemFrame_pos=(itemFrameXorigin, 0, itemFrameZorigin), itemFrame_scale=1.0, itemFrame_relief=DGG.SUNKEN, itemFrame_frameSize=(listXorigin, listXorigin + listFrameSizeX, listZorigin, listZorigin + listFrameSizeZ), itemFrame_frameColor=(0.85, 0.95, 1, 1), itemFrame_borderWidth=(0.01, 0.01), numItemsVisible=15, forceHeight=0.075, items=self.charButtons, parent = self.frame ) base.camera.setPos(75.12, 63.22, -23) base.camera.setHpr(26.57, 9.62, 0)