def getCrosshair(scale=0.04, color=(1, 1, 1, 1), hidden=True): crosshair = OnscreenImage(image="phase_4/maps/crosshair.png", scale=scale, color=color) crosshair.setTransparency(True) if hidden: crosshair.hide() return crosshair
class SplashScreen: def __init__(self, doneCallback): self.cioimg = OnscreenImage( image='materials/engine/coginvasiononline.png') self.cioimg.hide() self.cioimg.setColorScale(0, 0, 0, 1) self.pandaimg = OnscreenImage( image='materials/engine/powered_by_panda3d.png') self.pandaimg.hide() self.pandaimg.setColorScale(0, 0, 0, 1) self.discimg = OnscreenImage(image='materials/engine/disclaimer.png') self.discimg.hide() self.discimg.setColorScale(0, 0, 0, 1) self.doneCallback = doneCallback self.splashIval = Sequence( Func(self.cioimg.show), Wait(1.0), Func(base.playMusic, "encntr_suit_HQ_nbrhood"), LerpColorScaleInterval(self.cioimg, 1.0, (1, 1, 1, 1), (0, 0, 0, 1)), Wait(3), LerpColorScaleInterval(self.cioimg, 1.0, (0, 0, 0, 1), (1, 1, 1, 1)), Func(self.cioimg.hide), Func(self.pandaimg.show), LerpColorScaleInterval(self.pandaimg, 1.0, (1, 1, 1, 1), (0, 0, 0, 1)), Wait(1.0), LerpColorScaleInterval(self.pandaimg, 1.0, (0, 0, 0, 1), (1, 1, 1, 1)), Func(self.pandaimg.hide), Func(self.discimg.show), LerpColorScaleInterval(self.discimg, 1.0, (1, 1, 1, 1), (0, 0, 0, 1)), Wait(3.5), LerpColorScaleInterval(self.discimg, 1.0, (0, 0, 0, 1), (1, 1, 1, 1)), Func(self.discimg.hide), Func(self.cleanup), Func(self.doneCallback)) self.splashIval.start() base.accept('space', self.splashIval.finish) def cleanup(self): base.ignore('space') self.splashIval.finish() self.splashIval = None self.pandaimg.destroy() self.pandaimg = None self.cioimg.destroy() self.cioimg = None self.discimg.destroy() self.discimg = None
class MinimapCapturePoint(MinimapObject): SORT = 4 def __init__(self, worldNode, holiday, zone): MinimapObject.__init__(self, 'capturePoint-%d' % zone, worldNode, NodePath('capturePoint')) self.holidayId = holiday self.zone = zone self.hpMeter = None self.barricadeIcon = None self.barricadeDestroyed = None self.blinker = None self.sentRemove = False self.hp = 0 self.maxHp = 0 whiteColor = (1.0, 1.0, 1.0, 1.0) self.blinker = Sequence(Func(self.setBarColor, whiteColor), Wait(0.20000000000000001), Func(self.setBarColor), Wait(0.20000000000000001), Func(self.setBarColor, whiteColor), Wait(0.20000000000000001), Func(self.setBarColor), Wait(0.20000000000000001), Func(self.setBarColor, whiteColor), Wait(0.20000000000000001), Func(self.setBarColor), Wait(0.20000000000000001), Func(self.setBarColor, whiteColor), Wait(0.20000000000000001), Func(self.setBarColor), Wait(0.20000000000000001), Func(self.setBarColor, whiteColor), Wait(0.20000000000000001), Func(self.setBarColor), Wait(0.20000000000000001), Func(self.setBarColor, whiteColor), Wait(0.20000000000000001), Func(self.setBarColor), Wait(0.20000000000000001), Func(self.setBarColor, whiteColor), Wait(0.20000000000000001), Func(self.setBarColor), Wait(0.20000000000000001), Func(self.setBarColor, whiteColor), Wait(0.20000000000000001), Func(self.setBarColor), Wait(0.20000000000000001), Func(self.setBarColor, whiteColor), Wait(0.20000000000000001), Func(self.setBarColor), Wait(0.20000000000000001), Func(self.setBarColor, whiteColor), Wait(0.20000000000000001), Func(self.setBarColor)) def setHp(self, hp, maxHp): if self.hpMeter: if hp != self.hpMeter.meter['value']: pass hpMismatch = hp != maxHp self.hp = hp self.maxHp = hp self.hpMeter.update(hp, maxHp) if hpMismatch: if self.blinker: self.blinker.finish() self.blinker.start() if hp <= 0 and maxHp >= 0 and not (self.sentRemove): self.sentRemove = True if self.hpMeter: self.hpMeter.destroy() self.hpMeter = None if self.blinker: self.blinker.pause() self.blinker = None if self.barricadeIcon: self.barricadeIcon.destroy() self.barricadeIcon = None if self.barricadeDestroyed and self.zone != InvasionGlobals.getTotalCapturePoints(self.holidayId): self.barricadeDestroyed.show() return True else: return False def setBarColor(self, color = None): if self.barricadeIcon: if color: barricadeColor = color else: barricadeColor = (1.0, 0.5, 0.0, 1) self.barricadeIcon.setColor(barricadeColor) if self.hpMeter: if not color: if self.maxHp <= 0: hpFraction = 0 else: hpFraction = float(self.hp) / float(self.maxHp) if hpFraction >= 0.5: color = (0.10000000000000001, 0.69999999999999996, 0.10000000000000001, 1) elif hpFraction >= 0.25: color = (1.0, 1.0, 0.10000000000000001, 1) else: color = (1.0, 0.0, 0.0, 1) self.hpMeter.meter['barColor'] = color if color == PiratesGuiGlobals.TextFG2: self.hpMeter.categoryLabel['text_fg'] = color else: self.hpMeter.categoryLabel['text_fg'] = PiratesGuiGlobals.TextFG1 def _addedToMap(self, map): self.mapGeom.setScale(aspect2d, 0.29999999999999999) overlayNode = map.getOverlayNode() worldNode = map.getWorldNode() transform = self.mapGeom.getTransform(overlayNode) self.hpMeter = HpMeter(width = 0.40000000000000002, parent = overlayNode) self.hpMeter.setP(-90) if self.zone != InvasionGlobals.getTotalCapturePoints(self.holidayId): self.hpMeter.setPos(transform.getPos() + (50, 0, 0)) else: self.hpMeter.setPos(InvasionGlobals.getMainCapturePointHpPos(self.holidayId)) self.hpMeter.setScale(transform.getScale()) self.hpMeter['sortOrder'] = MinimapCapturePoint.SORT self.hpMeter.setAlphaScale(1, 1) self.hpMeter.categoryLabel['text_scale'] = 0.10000000000000001 self.hpMeter.update(1, 1) topGui = loader.loadModel('models/gui/toplevel_gui') if self.zone != InvasionGlobals.getTotalCapturePoints(self.holidayId): self.barricadeIcon = OnscreenImage(parent = self.mapGeom, image = topGui.find('**/pir_t_gui_gen_barricade'), scale = 1.5, hpr = (0, 90, 0), color = (1.0, 0.5, 0.0, 1)) self.barricadeDestroyed = OnscreenImage(parent = overlayNode, image = topGui.find('**/pir_t_gui_gen_Xred'), scale = transform.getScale() * 4.0, pos = transform.getPos(), hpr = (0, -90, 0)) self.barricadeDestroyed.hide() topGui.removeNode() self.mouseOver = GuiButton(parent = self.hpMeter, relief = None, state = DGG.NORMAL, scale = 3.0, image = None, frameSize = (-0.10000000000000001, 0.14999999999999999, -0.029999999999999999, 0.029999999999999999), helpText = PLocalizer.CapturePointNames[self.holidayId][self.zone], helpPos = (0.10000000000000001, 0, -0.080000000000000002), helpDelay = 0, helpOpaque = True, sortOrder = MinimapShop.SORT) def _removedFromMap(self, map): if self.blinker: self.blinker.pause() self.blinker = None if self.hpMeter: self.hpMeter.destroy() self.hpMeter = None if self.barricadeIcon: self.barricadeIcon.destroy() self.barricadeIcon = None if self.barricadeDestroyed: self.barricadeDestroyed.destroy() self.barricadeDestroyed = None def getZone(self): return self.zone
class CIProgressScreen: Color = (118 / 255.0, 121 / 255.0, 127 / 255.0, 1.0) BarColor = (152 / 255.0, 129 / 255.0, 64 / 255.0, 1.0) def __init__(self): self.defaultLogoScale = 1 self.defaultLogoZ = 0.65 self.bgm = loader.loadModel( "phase_3/models/gui/progress-background.bam") self.bgm.find('**/logo').stash() self.barShadow = OnscreenImage(image=self.bgm.find("**/bar_shadow"), parent=hidden) self.bgm.find("**/bar_shadow").removeNode() self.bg = self.bgm.find('**/bg') self.defaultBgTexture = self.bg.findTexture('*') self.logoNode, self.logoImg = CIGlobals.getLogoImage( hidden, self.defaultLogoScale, (0, 0, self.defaultLogoZ)) self.bg_img = OnscreenImage(image=self.bg, parent=hidden) self.bg_img.setSx(1.35) self.bg_img.hide() self.progress_bar = DirectWaitBar(value=0, pos=(0, 0, -0.85), parent=hidden, text_pos=(0, 0, 0.2)) self.progress_bar.setSx(1.064) self.progress_bar.setSz(0.38) toontipgui = loader.loadModel( 'phase_3.5/models/gui/stickerbook_gui.bam') poster = toontipgui.find('**/questCard') self.toontipFrame = DirectFrame(image=poster, image_scale=(1.4, 1, 1), parent=hidden, relief=None, pos=(0, 0, -0.1), scale=0.85) self.toontipLbl = OnscreenText(text="", parent=self.toontipFrame, fg=(89.0 / 255, 95.0 / 255, 98.0 / 255, 1), font=CIGlobals.getToonFont(), wordwrap=13, pos=(-0.59, 0.25), align=TextNode.ALeft, scale=0.08) self.loading_lbl = DirectLabel(text="", relief=None, scale=0.08, pos=(-1.0725, 0, -0.79), text_align=TextNode.ALeft, sortOrder=100, text_fg=(1, 1, 1, 1), text_font=CIGlobals.getMinnieLogoFont(), parent=hidden, text_shadow=(0, 0, 0, 0)) # This is useful when the user has chosen to hide aspect2d before the loading screen. # However, we want to show the loading screen all the time, so we need to restore the # previous state after the loading screen ends. self.mustRestoreHiddenAspect2d = False def begin(self, hood, range, wantGui): render.hide() NametagGlobals.setWant2dNametags(False) if base.aspect2d.isHidden(): base.aspect2d.show() self.mustRestoreHiddenAspect2d = True self.renderFrames() base.setBackgroundColor(0, 0, 0) if hood == "localAvatarEnterGame": self.loading_lbl['text'] = "Entering..." elif hood == "init": self.loading_lbl['text'] = "Loading..." else: self.loading_lbl['text'] = "Heading to %s..." % hood self.progress_bar['barColor'] = self.BarColor self.progress_bar['range'] = range self.bgm.reparentTo(aspect2d) ZoneUtil.Hood2ZoneId.keys() # We only want to show special loading screens for actual in-game locations. if hood in ZoneUtil.Hood2ZoneId.keys(): abbr = ZoneUtil.ZoneId2HoodAbbr.get( ZoneUtil.Hood2ZoneId.get(hood)).lower() bgTexture = loader.loadTexture( 'phase_14/maps/{0}_loading.png'.format(abbr), okMissing=True) if bgTexture: self.bg.setTexture(bgTexture, 1) self.barShadow.reparentTo(aspect2d) self.bg.reparentTo(render2d) self.bg_img.reparentTo(hidden) self.loading_lbl.reparentTo(aspect2d) self.logoNode.reparentTo(aspect2d) self.progress_bar.reparentTo(aspect2d) tip = random.choice(CIGlobals.ToonTips) self.toontipLbl.setText("TOON TIP:\n" + tip) self.toontipFrame.reparentTo(aspect2d) self.__count = 0 self.__expectedCount = range self.progress_bar.update(self.__count) def renderFramesTask(self, task): self.renderFrames() return task.cont def end(self): base.setBackgroundColor(CIGlobals.DefaultBackgroundColor) taskMgr.remove("renderFrames") render.show() if self.mustRestoreHiddenAspect2d: base.aspect2d.hide() self.mustRestoreHiddenAspect2d = False self.progress_bar.finish() self.bg_img.reparentTo(hidden) self.logoNode.reparentTo(hidden) self.barShadow.reparentTo(hidden) self.bg.reparentTo(hidden) # Let's get rid of the extra texture stage. self.bg.setTexture(self.defaultBgTexture, 1) self.bgm.reparentTo(hidden) self.loading_lbl.reparentTo(hidden) self.progress_bar.reparentTo(hidden) self.toontipFrame.reparentTo(hidden) base.transitions.fadeScreen(1.0) NametagGlobals.setWant2dNametags(True) self.renderFrames() def destroy(self): self.bg.removeNode() del self.bg self.bgm.removeNode() del self.bgm self.bg_img.destroy() self.barShadow.destroy() del self.barShadow self.loading_lbl.destroy() self.progress_bar.destroy() self.bgm.destroy() self.mustRestoreHiddenAspect2d = False del self.bg_img del self.loading_lbl del self.progress_bar del self.bgm del self.defaultBgTexture del self.mustRestoreHiddenAspect2d def renderFrames(self): base.graphicsEngine.renderFrame() base.graphicsEngine.renderFrame() def tick(self): self.__count += 1 self.progress_bar.update(self.__count)
class GagWidget(DirectButton): Idle = (0, 115 / 255.0, 194 / 255.0, 1) Selected = (0, 115 / 255.0 * 1.5, 194 / 255.0 * 1.5, 1) NoAmmoIdle = (0, 115 / 255.0 / 1.75, 194 / 255.0 / 1.75, 1) NoAmmoSelected = (0, 115 / 255.0 / 1.75, 194 / 255.0 / 1.75, 1) LockedIdle = (0.5, 0.5, 0.5, 1.0) LockedSelected = (0.5, 0.5, 0.5, 1.0) def __init__(self, track, gagId): self.track = track self.gagId = gagId self.gagName = base.cr.attackMgr.getAttackName(gagId) self.lastScale = 1.0 self.goalScale = 1.0 self.scaleLerpTask = taskMgr.add(self.__scaleLerp, "scaleLerp") self.locked = False DirectButton.__init__(self, scale=1, relief=None, pressEffect=False, rolloverSound=None, clickSound=None, command=self.track.gsg.selectCurrentGag) self['image'] = 'phase_14/maps/gag_box.png' self['image_scale'] = (0.115, 0, 0.114) self.bind(DGG.ENTER, self.mouseEnter) self.bind(DGG.EXIT, self.mouseExit) self.lockedImg = OnscreenImage(image='phase_14/maps/lock.png', scale=(0.061, 0, 0.089), parent=self, color=(1, 1, 1, 0.5)) invIcons = loader.loadModel("phase_3.5/models/gui/inventory_icons.bam") self.gagImg = OnscreenGeom(geom=invIcons.find( GagGlobals.InventoryIconByName[self.gagName]), scale=0.85, parent=self) invIcons.removeNode() del invIcons self.initialiseoptions(GagWidget) def mouseEnter(self, foo=None, bar=None): if self.track.gsg.getCurrentOrNextState() == 'Select': self.track.gsg.ignoreSelectionClick() self.track.gsg.resetTimeout() self.select() def mouseExit(self, foo=None, bar=None): if self.track.gsg.getCurrentOrNextState() == 'Select': self.track.gsg.acceptSelectionClick() self.track.gsg.resetTimeout() self.deselect() def cleanup(self): if self.scaleLerpTask: self.scaleLerpTask.remove() self.scaleLerpTask = None self.lastScale = None self.goalScale = None self.locked = None self.gagId = None self.gagName = None if self.lockedImg: self.lockedImg.destroy() self.lockedImg = None if self.gagImg: self.gagImg.destroy() self.gagImg = None self.destroy() def __scaleLerp(self, task): if self.lastScale == self.goalScale: return task.cont self.lastScale = CIGlobals.lerpWithRatio(self.goalScale, self.lastScale, 0.8) self.setScale(self.lastScale) return task.cont def stash(self): self.scaleLerpTask.remove() DirectButton.stash(self) def unstash(self): taskMgr.add(self.scaleLerpTask) DirectButton.unstash(self) def select(self): if self.locked: self['image_color'] = self.LockedSelected elif not self.hasAmmo(): self['image_color'] = self.NoAmmoSelected else: self['image_color'] = self.Selected self.goalScale = 1.15 if self.track.gsg.currentGag != self: if self.track.gsg.currentGag is not None: self.track.gsg.currentGag.deselect() self.track.gsg.currentGag = self self.track.gsg.update() def hasAmmo(self): if not base.localAvatar.hasAttackId(self.gagId): return False return base.localAvatar.getAttack(self.gagId).hasAmmo() def deselect(self): if self.locked: self['image_color'] = self.LockedIdle elif not self.hasAmmo(): self['image_color'] = self.NoAmmoIdle else: self['image_color'] = self.Idle self.goalScale = 1.0 if self.track.gsg.currentGag == self: self.track.gsg.currentGag = None def setLocked(self, flag): self.locked = flag if flag: self.lockedImg.show() self.gagImg.hide() self['image_color'] = self.LockedIdle self['state'] = DGG.DISABLED else: self.lockedImg.hide() self.gagImg.show() self['image_color'] = self.Idle self['state'] = DGG.NORMAL
class KOTHGui(DirectFrame): notify = directNotify.newCategory('KOTHGui') pointsSfx = None points = None def __init__(self): # Let's load up the DirectFrame DirectFrame.__init__(self, parent=base.a2dTopLeft, relief=None, pos=(0.275, 1, -0.7), sortOrder=0) # The variables we're going to be using. self.pointsSfx = loader.loadSfx('phase_4/audio/sfx/MG_maze_pickup.ogg') self.points = 0 # Background because it won't work for whatever reason. gui = loader.loadModel('phase_4/models/gui/purchase_gui.bam') panel = gui.find('**/yellowPanel') self.bg = OnscreenImage(image=panel, parent=self) # Let's setup the header text. self.title = OnscreenText(text='Capture Points', font=CIGlobals.getMinnieFont(), parent=self, scale=0.0475, pos=(0, 0.18), fg=(1, 0, 0, 1), shadow=(0.2, 0.2, 0.2, 1)) # Let's setup the amount text. self.amt_label = OnscreenText(text=str(self.points), font=CIGlobals.getToonFont(), parent=self, scale=0.15, pos=(0, 0.03525), shadow=(0.5, 0.5, 0.5, 0.6)) # Let's setup the info text. self.info = OnscreenText( text= 'First Toon to 100 points wins!\nEarn points by standing on the\nhill after capturing it.', parent=self, font=CIGlobals.getToonFont(), scale=0.035, pos=(0, -0.05), fg=(1.5, 0, 0, 1), shadow=(0.2, 0.2, 0.2, 1)) # We're not ready to show the GUI yet. self.hide() def show(self): self.title.show() self.amt_label.show() self.info.show() self.bg.show() def hide(self): self.title.hide() self.amt_label.hide() self.info.hide() self.bg.hide() def destroy(self): self.title.destroy() self.amt_label.destroy() self.info.destroy() self.bg.destroy() self.title = None self.amt_label = None self.info = None self.bg = None # Let's get rid of the sound. self.pointsSfx.stop() self.pointsSfx = None self.points = None DirectFrame.destroy(self) def setPoints(self, points): self.points = points self.amt_label.setText(str(self.points)) self.pointsSfx.play() def getPoints(self): return self.points
class KOTHGui(DirectFrame): notify = directNotify.newCategory('KOTHGui') pointsSfx = None points = None def __init__(self): DirectFrame.__init__(self, parent=base.a2dTopLeft, relief=None, pos=(0.275, 1, -0.7), sortOrder=0) self.pointsSfx = loader.loadSfx('phase_4/audio/sfx/MG_maze_pickup.ogg') self.points = 0 gui = loader.loadModel('phase_4/models/gui/purchase_gui.bam') panel = gui.find('**/yellowPanel') self.bg = OnscreenImage(image=panel, parent=self) self.title = OnscreenText(text='Capture Points', font=CIGlobals.getMinnieFont(), parent=self, scale=0.0475, pos=(0, 0.18), fg=(1, 0, 0, 1), shadow=(0.2, 0.2, 0.2, 1)) self.amt_label = OnscreenText(text=str(self.points), font=CIGlobals.getToonFont(), parent=self, scale=0.15, pos=(0, 0.03525), shadow=(0.5, 0.5, 0.5, 0.6)) self.info = OnscreenText( text= 'First Toon to 100 points wins!\nEarn points by standing on the\nhill after capturing it.', parent=self, font=CIGlobals.getToonFont(), scale=0.035, pos=(0, -0.05), fg=(1.5, 0, 0, 1), shadow=(0.2, 0.2, 0.2, 1)) self.hide() return def show(self): self.title.show() self.amt_label.show() self.info.show() self.bg.show() def hide(self): self.title.hide() self.amt_label.hide() self.info.hide() self.bg.hide() def destroy(self): self.title.destroy() self.amt_label.destroy() self.info.destroy() self.bg.destroy() self.title = None self.amt_label = None self.info = None self.bg = None self.pointsSfx.stop() self.pointsSfx = None self.points = None DirectFrame.destroy(self) return def setPoints(self, points): self.points = points self.amt_label.setText(str(self.points)) self.pointsSfx.play() def getPoints(self): return self.points
class CIProgressScreen: def __init__(self): self.bgm = loader.loadModel('phase_3/models/gui/progress-background.bam') self.bgm.find('**/logo').stash() self.bg = self.bgm.find('**/bg') self.logo = loader.loadTexture('phase_3/maps/CogInvasion_Logo.png') self.logoImg = OnscreenImage(image=self.logo, scale=(0.5, 0, 0.3), pos=(0, 0, 0), parent=hidden) self.logoImg.setTransparency(True) self.bg_img = OnscreenImage(image=self.bg, parent=hidden) self.bg_img.setSx(1.35) self.bg_img.hide() self.progress_bar = DirectWaitBar(value=0, pos=(0, 0, -0.85), parent=hidden, text_pos=(0, 0, 0.2)) self.progress_bar.setSx(1.064) self.progress_bar.setSz(0.38) self.loading_lbl = DirectLabel(text='', relief=None, scale=0.08, pos=(-1.0725, 0, -0.79), text_align=TextNode.ALeft, sortOrder=100, text_fg=(0.343, 0.343, 0.343, 1.0), text_font=CIGlobals.getMinnieFont(), parent=hidden, text_shadow=(0, 0, 0, 1)) return def begin(self, hood, range, wantGui): render.hide() self.renderFrames() base.setBackgroundColor(0, 0, 0) if hood == 'localAvatarEnterGame': self.loading_lbl['text'] = 'Entering...' elif hood == 'init': self.loading_lbl['text'] = 'Loading...' else: self.loading_lbl['text'] = 'Heading to %s...' % hood self.progress_bar['barColor'] = (0.343, 0.343, 0.343, 1.0) self.progress_bar['range'] = range self.bgm.reparentTo(aspect2d) self.bg.reparentTo(render2d) self.bg_img.reparentTo(hidden) self.loading_lbl.reparentTo(aspect2d) self.logoImg.reparentTo(aspect2d) self.progress_bar.reparentTo(aspect2d) self.__count = 0 self.__expectedCount = range self.progress_bar.update(self.__count) def renderFramesTask(self, task): self.renderFrames() return task.cont def end(self): base.setBackgroundColor(CIGlobals.DefaultBackgroundColor) taskMgr.remove('renderFrames') render.show() self.progress_bar.finish() self.bg_img.reparentTo(hidden) self.logoImg.reparentTo(hidden) self.bg.reparentTo(hidden) self.bgm.reparentTo(hidden) self.loading_lbl.reparentTo(hidden) self.progress_bar.reparentTo(hidden) self.renderFrames() def destroy(self): self.bg.removeNode() del self.bg self.bgm.removeNode() del self.bgm self.bg_img.destroy() self.loading_lbl.destroy() self.progress_bar.destroy() self.bgm.destroy() del self.bg_img del self.loading_lbl del self.progress_bar del self.bgm def renderFrames(self): base.graphicsEngine.renderFrame() base.graphicsEngine.renderFrame() def tick(self): self.__count += 1 self.progress_bar.update(self.__count)
class CIProgressScreen: def __init__(self): self.defaultLogoScale = 0.85 self.defaultLogoZ = 0.65 self.bgm = loader.loadModel('phase_3/models/gui/progress-background.bam') self.bgm.find('**/logo').stash() self.bg = self.bgm.find('**/bg') self.logo = loader.loadTexture('phase_3/maps/CogInvasion_Logo.png') self.logoNode = hidden.attachNewNode('logoNode') self.logoNode.setScale(self.defaultLogoScale) self.logoNode.setPos(0, self.defaultLogoZ, 0) self.logoImg = OnscreenImage(image=self.logo, scale=(0.685, 0, 0.3), parent=self.logoNode) self.logoImg.setTransparency(True) self.bg_img = OnscreenImage(image=self.bg, parent=hidden) self.bg_img.setSx(1.35) self.bg_img.hide() self.progress_bar = DirectWaitBar(value=0, pos=(0, 0, -0.85), parent=hidden, text_pos=(0, 0, 0.2)) self.progress_bar.setSx(1.064) self.progress_bar.setSz(0.38) toontipgui = loader.loadModel('phase_3.5/models/gui/stickerbook_gui.bam') poster = toontipgui.find('**/questCard') self.toontipFrame = DirectFrame(image=poster, image_scale=(1.4, 1, 1), parent=hidden, relief=None, pos=(0, 0, -0.1), scale=0.85) self.toontipLbl = OnscreenText(text='', parent=self.toontipFrame, fg=(0.35, 0.35, 0.35, 1), font=CIGlobals.getToonFont(), wordwrap=14.5, pos=(-0.59, 0.25), align=TextNode.ALeft, scale=0.08) self.loading_lbl = DirectLabel(text='', relief=None, scale=0.08, pos=(-1.0725, 0, -0.79), text_align=TextNode.ALeft, sortOrder=100, text_fg=(0.343, 0.343, 0.343, 1.0), text_font=CIGlobals.getMinnieFont(), parent=hidden, text_shadow=(0, 0, 0, 1)) return def begin(self, hood, range, wantGui): render.hide() self.renderFrames() base.setBackgroundColor(0, 0, 0) if hood == 'localAvatarEnterGame': self.loading_lbl['text'] = 'Entering...' else: if hood == 'init': self.loading_lbl['text'] = 'Loading...' else: self.loading_lbl['text'] = 'Heading to %s...' % hood self.progress_bar['barColor'] = (0.343, 0.343, 0.343, 1.0) self.progress_bar['range'] = range self.bgm.reparentTo(aspect2d) self.bg.reparentTo(render2d) self.bg_img.reparentTo(hidden) self.loading_lbl.reparentTo(aspect2d) self.logoNode.reparentTo(aspect2d) self.progress_bar.reparentTo(aspect2d) tip = random.choice(CIGlobals.ToonTips) self.toontipLbl.setText('TOON TIP:\n' + tip) self.toontipFrame.reparentTo(aspect2d) self.__count = 0 self.__expectedCount = range self.progress_bar.update(self.__count) def renderFramesTask(self, task): self.renderFrames() return task.cont def end(self): base.setBackgroundColor(CIGlobals.DefaultBackgroundColor) taskMgr.remove('renderFrames') render.show() self.progress_bar.finish() self.bg_img.reparentTo(hidden) self.logoNode.reparentTo(hidden) self.bg.reparentTo(hidden) self.bgm.reparentTo(hidden) self.loading_lbl.reparentTo(hidden) self.progress_bar.reparentTo(hidden) self.toontipFrame.reparentTo(hidden) self.renderFrames() def destroy(self): self.bg.removeNode() del self.bg self.bgm.removeNode() del self.bgm self.bg_img.destroy() self.loading_lbl.destroy() self.progress_bar.destroy() self.bgm.destroy() del self.bg_img del self.loading_lbl del self.progress_bar del self.bgm def renderFrames(self): base.graphicsEngine.renderFrame() base.graphicsEngine.renderFrame() def tick(self): self.__count += 1 self.progress_bar.update(self.__count)
class DMenuScreen(DirectObject): notify = directNotify.newCategory('DMenuScreen') def __init__(self):#, avatarList, parentFSM, doneEvent): DirectObject.__init__(self) base.disableMouse() #base.cr.avChoice = None fadeSequence = Sequence( Wait(.5), Func(base.transitions.fadeIn, .5), Wait(1)).start()#, #base.camera.posHprInterval(1, Point3(MAIN_POS), VBase3(MAIN_HPR), blendType = 'easeInOut')).start() #self.background = loader.loadModel('phase_4/models/neighborhoods/toontown_central_full') #self.background.reparentTo(render) #for frame in render.findAllMatches('*/doorFrame*'): # frame.removeNode() #self.sky = loader.loadModel('phase_3.5/models/props/TT_sky') #SkyUtil.startCloudSky(self) #base.camera.setPosHpr(INIT_POS, INIT_HPR) self.background = OnscreenImage(image = DMenuResources.MenuBackground, parent = aspect2d) self.background.setBin('background', 1) self.background.reparentTo(aspect2d) self.background.setScale(2, 1, 1) self.logo = OnscreenImage(image = DMenuResources.GameLogo, scale = (1, 1, .5)) self.logo.reparentTo(aspect2d) self.logo.setTransparency(TransparencyAttrib.MAlpha) scale = self.logo.getScale() self.logo.setPos(0, 0, .5) self.logo.setColorScale(Vec4(0, 0, 0, 0)) #fadeInBackground = (LerpColorScaleInterval(self.background, 1, Vec4(1, 1, 1, 1), Vec4(1, 1, 1, 0))).start() fadeInLogo = (LerpColorScaleInterval(self.logo, 1, Vec4(1, 1, 1, 1), Vec4(1, 1, 1, 0))).start() self.createButtons() self.fadeOut = None self.optionsMgr = DMenuOptions.DMenuOptions() self.quitConfirmation = DMenuQuit.DMenuQuit() # TT: We need these to run the Pick A Toon screen #self.patAvList = avatarList #self.patFSM = parentFSM #self.patDoneEvent = doneEvent self.transcircle = Resources.transcircle self.transcircle.setTransparency(TransparencyAttrib.MAlpha) self.transcircle.setScale(VBase3(0.01, 0.01, 0.01)) self.transcircle.setBin('background', 3) self.savemgr = LOTASaveMgr.LOTASaveMgr() # Get the save data self.savePos = self.savemgr.loadSaveData() self.titleMusic = Resources.titleMusic self.titleMusic.setLoop(1) self.setMusicNormal() def skyTrack(self, task): # return SkyUtil.cloudSkyTrack(task) pass def createButtons(self): self.PlayButton = DirectButton(relief = None, text_style = 3, text_fg = (1, 1, 1, 1), text = DMenuLocalizer.PlayGame, text_scale = .1, scale = 0.95, command = self.playGame) self.PlayButton.reparentTo(aspect2d) self.PlayButton.setPos(PlayBtnHidePos) self.PlayButton.show() self.OptionsButton = DirectButton(relief = None, text_style = 3, text_fg = (1, 1, 1, 1), text = DMenuLocalizer.Options, text_scale = .1, scale = 0.95, command = self.openOptions) self.OptionsButton.reparentTo(aspect2d) self.OptionsButton.setPos(OptionsBtnHidePos) self.OptionsButton.show() self.QuitButton = DirectButton(relief = None, text_style = 3, text_fg = (1, 1, 1, 1), text = DMenuLocalizer.Quit, text_scale = .1, scale = 0.95, command = self.quitGame) self.QuitButton.reparentTo(aspect2d) self.QuitButton.setPos(QuitBtnHidePos) self.QuitButton.show() # self.BRButton = DirectButton(text = 'REPORT BUG', text_scale = .1, scale=0.95) # self.BRButton.reparentTo(aspect2d) # self.BRButton.setPos(-.9, 0, -.9) # self.BRButton.show() self.buttonInAnimation() # Slap on the saves menu from the old main menu until a proper implementation to DMENU is made self.SavesButton = DirectButton(relief = None, text = AmdLocalizerEnglish.LOTA_SAVES, image_scale = 2, text_scale = .1, scale = 0.95, command = self.openSavesMenu) self.SavesButton.reparentTo(aspect2d) self.SavesButton.setPos(0, 0, -.5) self.SavesButton.show() def murder(self): if self.logo is not None: self.logo.destroy() self.logo = None if self.background is not None: self.background.hide() self.background.reparentTo(hidden) self.background.removeNode() self.background = None if self.PlayButton is not None: self.PlayButton.destroy() self.PlayButton = None if self.OptionsButton is not None: self.OptionsButton.destroy() self.OptionsButton = None if self.QuitButton is not None: self.QuitButton.destroy() self.QuitButton = None if self.SavesButton is not None: self.SavesButton.destroy() self.SavesButton = None if self.titleMusic is not None: self.titleMusic.stop() #taskMgr.remove('skyTrack') #self.sky.reparentTo(hidden) def openOptions(self): self.optionsMgr.showOptions() self.closeOptionsButton = DirectButton(relief = None, text = "< Back", text_fg = (0.977, 0.816, 0.133, 1), text_pos = (0, -0.035), scale = .1, command = self.hideOptions) self.closeOptionsButton.reparentTo(base.a2dTopLeft) self.closeOptionsButton.setPos(0.5, 0, -0.07) Parallel( self.PlayButton.posInterval(.5, Point3(PlayBtnHidePos), blendType = 'easeInOut'), self.OptionsButton.posInterval(.5, Point3(OptionsBtnHidePos), blendType = 'easeInOut'), self.QuitButton.posInterval(.5, Point3(QuitBtnHidePos), blendType = 'easeInOut'), self.logo.posInterval(0.5, Point3(0, 0, 2.5), blendType = 'easeInOut')).start() #base.camera.posHprInterval(0.5, Point3(HQ_POS), VBase3(HQ_HPR), blendType = 'easeInOut').start() #self.setMusicCalm() def hideOptions(self): self.optionsMgr.hideOptions() self.closeOptionsButton.hide() Parallel( self.PlayButton.posInterval(.5, Point3(PlayBtnPos), blendType = 'easeInOut'), self.OptionsButton.posInterval(.5, Point3(OptionsBtnPos), blendType = 'easeInOut'), self.QuitButton.posInterval(.5, Point3(QuitBtnPos), blendType = 'easeInOut'), self.logo.posInterval(.5, Point3(0, 0, .5), blendType = 'easeInOut')).start() base.camera.posHprInterval(0.5, Point3(MAIN_POS), VBase3(MAIN_HPR), blendType = 'easeInOut').start() #self.setMusicNormal() def playGame(self): if self.fadeOut is not None: self.fadeOut.finish() self.fadeOut = None self.fadeOut = base.transitions.getFadeOutIval(t = 1) #base.camera.posHprInterval(1, Point3(TOON_HALL_POS), VBase3(TOON_HALL_HPR), blendType = 'easeInOut').start() Sequence( Func(self.doPlayButton), #Func(self.fadeOut.start), Wait(1), Func(self.murder), Wait(1), Func(self.enterGame)).start()#, #Func(base.transitions.fadeIn, 1)).start() def enterOptions(self): pass def enterGame(self): #base.cr.avChoice = AvatarChooser.AvatarChooser(self.patAvList, self.patFSM, self.patDoneEvent) #base.cr.avChoice.load(1) #base.cr.avChoice.enter() from Game.NewGame.Scenes import SceneOne # Hamburger Menu Button #self.hbButton = DirectButton(image = "phase_3/maps/dmenu/dmhbmenu.png", relief = None, text = ' ', command=self.showHamburgerMenu) #self.hbButton.reparentTo(base.a2dTopLeft) #self.hbButton.setPos(0.05, 0, -0.05) #self.hbButton.setScale(0.04) # Hamburger Menu Hide Button #self.hbHideButton = DirectButton(image = "phase_3/maps/dmenu/close_window.png", relief = None, text = ' ', command=self.hideHamburgerMenu) #self.hbHideButton.reparentTo(base.a2dTopLeft) #self.hbHideButton.setPos(0.05, 0, -0.05) #self.hbHideButton.setScale(0.04) #self.hbHideButton.hide() # TODO: Add options and stuff to the hamburger menu def doPlayButton(self): Parallel( self.PlayButton.posInterval(1, Point3(PlayBtnHidePos), blendType = 'easeInOut'), self.OptionsButton.posInterval(1, Point3(OptionsBtnHidePos), blendType = 'easeInOut'), self.QuitButton.posInterval(1, Point3(QuitBtnHidePos), blendType = 'easeInOut'), self.logo.posInterval(0.5, Point3(0, 0, 2.5), blendType = 'easeInOut')).start() def quitGame(self): self.showQuitConfirmation() def showQuitConfirmation(self): self.quitConfirmation.showConfirmation() #base.exitFunc() def setMusicNormal(self): #LerpFunctionInterval(base.cr.music.setVolume, fromData = 0, toData = .9, duration = 1).start() #LerpFunctionInterval(base.cr.musicCalm.setVolume, fromData = .9, toData = 0, duration = 1).start() self.titleMusic.play() def setMusicCalm(self): LerpFunctionInterval(base.cr.music.setVolume, fromData = .9, toData = 0, duration = 1).start() LerpFunctionInterval(base.cr.musicCalm.setVolume, fromData = 0, toData = .9, duration = 1).start() def openSavesMenu(self): self.saveOne = DirectButton(relief=None, text = 'Save One: ' + '(Scene ' + str(self.savePos) + ')', scale=0.3, command=self.saveLoader, parent=aspect2d, pos=(0, 0, -.6), text_scale = .5) self.saveOne.hide() self.transcircle.show() self.exitLoadButton = DirectButton(relief=None, text = '< Back', scale=0.3, command=self.closeSavesMenu, parent=base.a2dBottomCenter, pos=(0, 0, -.4), text_scale = .5) self.exitLoadButton.show() self.openSavesMenuSequence = Parallel( self.transcircle.scaleInterval(0.5, VBase3(3, 3, 3), blendType = 'easeInOut'), self.exitLoadButton.posInterval(0.5, Point3(0, 0, .4), blendType = 'easeInOut'), Func(self.saveOne.show), self.saveOne.posInterval(0.5, Point3(0, 0, .2), blendType = 'easeInOut')) self.openSavesMenuSequence.start() def closeSavesMenu(self): self.hideThings = Sequence( Wait(0.5), Func(self.saveOne.hide), Func(self.transcircle.hide)) self.closeSavesMenuSequence = Parallel( self.saveOne.posInterval(0.5, Point3(0, 0, -.6), blendType = 'easeInOut'), self.transcircle.scaleInterval(0.5, VBase3(0.01, 0.01, 0.01), blendType = 'easeInOut'), self.exitLoadButton.posInterval(0.5, Point3(0, 0, -.4), blendType = 'easeInOut'), Func(self.hideThings.start)) self.closeSavesMenuSequence.start() self.exitLoadButton.removeNode() del self.exitLoadButton def saveLoader(self): # this was thrown together in like 10 seconds. how the f**k does this work # TODO: Make this save to a file thats not easily editable self.saveOne.hide() self.background.hide() self.transcircle.hide() if self.savePos == '1': from Game.NewGame.Scenes import SceneOne elif self.savePos == '2': from Game import SceneTwo elif self.savePos == '3': from Game import SceneThree elif self.savePos == '4': from Game import SceneFour elif self.savePos == '5': from Game import SceneFive else: print ("\n\n Save data is set to an unknown scene!!\n\n") def buttonInAnimation(self): logo = self.logo.posInterval(.5, Point3(0, 0, .5), blendType = 'easeInOut') play = self.PlayButton.posInterval(.5, Point3(PlayBtnPos), blendType = 'easeInOut') opt = self.OptionsButton.posInterval(.5, Point3(OptionsBtnPos), blendType = 'easeInOut') quit = self.QuitButton.posInterval(.5, Point3(QuitBtnPos), blendType = 'easeInOut') Sequence( Func(logo.start), Wait(0.1), Func(play.start), Wait(0.2), Func(opt.start), Wait(0.2), Func(quit.start)).start() def showHamburgerMenu(self): self.hbButton.hide() self.hbHideButton.show() def hideHamburgerMenu(self): self.hbButton.show() self.hbHideButton.hide()