def setSlotImage(self, gagImage):
     if self.gagImage:
         self.gagImage.destroy()
         self.gagImage = None
     self.gagImage = OnscreenImage(image=gagImage, parent=self)
     self.gagImage.setTransparency(TransparencyAttrib.MAlpha)
     return
Example #2
0
    def createGui(self):
        self.deleteGui()
        phase = 'phase_3.5/maps/'
        posGroup = self.threeSlotsPos
        self.inventoryFrame = DirectFrame(parent=base.a2dRightCenter, pos=(-0.2, 0, 0))
        if self.defaultSlots == 4:
            posGroup = self.fourSlotPos
        for slot in range(len(posGroup) + 1):
            if slot == 3:
                posGroup = self.fourSlotPos
            slotIdle = loader.loadTexture(phase + 'slot_%s_idle.png' % str(slot + 1))
            slotObj = Slot(slot + 1, posGroup[slot], self.inventoryFrame)
            slotOutline = OnscreenImage(image=slotIdle, color=(1, 1, 1, 0.5), parent=slotObj)
            slotOutline.setTransparency(TransparencyAttrib.MAlpha)
            slotObj.setOutline(slotOutline)
            self.slots.append(slotObj)
            if slot == 3:
                slotObj.hide()

        self.ammoLabel = DirectLabel(text='Ammo: 0', text_fg=(1, 1, 1, 1), relief=None, text_shadow=(0, 0, 0, 1), text_scale=0.08, pos=(0.2, 0, 0.35), parent=base.a2dBottomLeft)
        self.ammoLabel.hide()
        self.enableWeaponSwitch()
        self.resetScroll()
        self.update()
        return
Example #3
0
 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 _addedToMap(self, map):
     self.mapGeom.setScale(aspect2d, 0.3)
     overlayNode = map.getOverlayNode()
     worldNode = map.getWorldNode()
     transform = self.mapGeom.getTransform(overlayNode)
     self.hpMeter = HpMeter(width=0.4, 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.1
     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.1, 0.15, -0.03, 0.03), helpText=PLocalizer.CapturePointNames[self.holidayId][self.zone], helpPos=(0.1, 0, -0.08), helpDelay=0, helpOpaque=True, sortOrder=MinimapShop.SORT)
     return
Example #5
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)
Example #6
0
    def start(self):
        self.fullyChargedSound = base.loadSfx('phase_4/audio/sfx/ring_get.ogg')
        self.rechargeSound = base.loadSfx(
            'phase_4/audio/sfx/MG_sfx_travel_game_blue_arrow.ogg')
        self.batteryFrame = DirectFrame(parent=base.a2dBottomRight,
                                        pos=(-0.2, 0, 0.1),
                                        scale=(0.8, 0, 1))
        self.batteryBg = OnscreenImage(
            image='phase_4/maps/battery_charge_frame.png',
            parent=self.batteryFrame)
        self.batteryBg.setTransparency(1)
        self.batteryBg.setX(0.03)
        self.batteryBg.setScale(0.17, 0, 0.05)
        self.batteryBg.setColorScale(0, 0, 0, 1)
        self.batteryBar = DirectWaitBar(value=0,
                                        range=5,
                                        barColor=(1, 1, 1, 1),
                                        relief=None,
                                        scale=(0.12, 0.0, 0.3),
                                        parent=self.batteryFrame)

        self.viewfinder = Viewfinder(1.0)

        base.localAvatar.walkControls.setWalkSpeed(CIGlobals.ToonForwardSpeed,
                                                   0.0,
                                                   CIGlobals.ToonReverseSpeed,
                                                   CIGlobals.ToonRotateSpeed)
        FirstPerson.start(self)
Example #7
0
 def makeGui(self):
     self.destroyGui()
     self.guiFrame = DirectFrame(parent = base.a2dBottomRight, pos=(-0.55, 0, 0.15))
     self.guiBg = OnscreenImage(image = "phase_4/maps/turret_gui_bg.png", scale = (0.15, 0, 0.075), parent = self.guiFrame)
     self.guiBg.setTransparency(True)
     self.guiLabel = DirectLabel(text = "Turret", text_fg = (1, 0, 0, 1), relief = None, text_scale = 0.05, text_font = loader.loadFont("phase_3/models/fonts/ImpressBT.ttf"), pos = (0, 0, 0.025), parent = self.guiFrame)
     self.guiBar = DirectWaitBar(range = self.myTurret.getMaxHealth(), value = self.myTurret.getHealth(), scale = 0.125, parent = self.guiFrame, pos = (0, 0, -0.01))
 def createGui(self):
     self.deleteGui()
     gui = loader.loadModel("phase_3.5/models/gui/weapon_gui.bam")
     self.gui_dict = {CIGlobals.WholeCreamPie: {"idle": gui.find('**/tart_idle'),
                         "selected": gui.find('**/tart_selected'),
                         "disabled": gui.find('**/tart_disabled')},
                     CIGlobals.BirthdayCake: {"idle": gui.find('**/cake_idle'),
                         "selected": gui.find('**/cake_selected'),
                         "disabled": gui.find('**/cake_disabled')},
                     CIGlobals.CreamPieSlice: {"idle": gui.find('**/slice_idle'),
                         "selected": gui.find('**/slice_selected'),
                         "disabled": gui.find('**/slice_disabled')},
                     CIGlobals.TNT: {"idle": gui.find('**/tnt_idle'),
                         "selected": gui.find('**/tnt_selected'),
                         "disabled": gui.find('**/tnt_idle')}}
     self.guiPos = {"noTnt": [(0, 0, -0.5),
                             (0, 0, 0),
                             (0, 0, 0.5)],
                 "tnt": [(0, 0, -0.15),
                         (0, 0, 0.15),
                         (0, 0, 0.45),
                         (0, 0, -0.45)]}
     self.guiFrame = DirectFrame(parent=base.a2dRightCenter, pos=(-0.2, 0, 0))
     self.gagOrder = [CIGlobals.BirthdayCake, CIGlobals.WholeCreamPie, CIGlobals.CreamPieSlice, CIGlobals.TNT]
     img1 = OnscreenImage(image=gui.find('**/cake_idle'), pos=(0, 0, -0.5), scale=0.3, parent=self.guiFrame)
     img2 = OnscreenImage(image=gui.find('**/tart_selected'), pos=(0, 0, 0.0), scale=0.3, parent=self.guiFrame)
     img3 = OnscreenImage(image=gui.find('**/slice_idle'), pos=(0, 0, 0.5), scale=0.3, parent=self.guiFrame)
     img4 = OnscreenImage(image=gui.find('**/tnt_idle'), pos=(0, 0, -0.75), scale=0.3, parent=self.guiFrame)
     self.ammo_lbl = DirectLabel(text="Ammo: %s" % self.backpack.getSupply(), text_fg=(1,1,1,1), relief=None, text_shadow=(0,0,0,1), text_scale=0.08, pos=(0.2, 0, 0.35), parent=base.a2dBottomLeft)
     self.gui_list = {CIGlobals.BirthdayCake : img1, CIGlobals.WholeCreamPie : img2, CIGlobals.CreamPieSlice : img3, CIGlobals.TNT : img4}
     self.enableWeaponSwitch()
     gui.remove_node()
     self.update()
     del gui
 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 setup(self, title='CHOOSE WHAT YOU WANT TO BUY'):
     font = CIGlobals.getMickeyFont()
     txtFg = (0, 0, 0, 1)
     txtScale = 0.05
     txtPos = (0, -0.1)
     buttons = loader.loadModel('phase_3.5/models/gui/QT_buttons.bam')
     self.window = OnscreenImage(image=self.bgImage,
                                 scale=(0.9, 1, 0.7),
                                 parent=self)
     self.title = DirectLabel(text=title,
                              relief=None,
                              pos=(0, 0, 0.5),
                              text_wordwrap=10,
                              text_font=font,
                              text_fg=(1, 1, 0, 1),
                              scale=0.1,
                              parent=self)
     self.updateTurretCount()
     self.infoLbl = DirectLabel(text='Welcome!',
                                relief=None,
                                text_scale=0.075,
                                text_fg=txtFg,
                                text_shadow=(0, 0, 0, 0),
                                pos=(0, 0, 0.215))
     self.okBtn = DirectButton(geom=CIGlobals.getOkayBtnGeom(),
                               relief=None,
                               text='OK',
                               text_fg=txtFg,
                               text_scale=txtScale,
                               text_pos=txtPos,
                               pos=(-0.1, 0, -0.5),
                               parent=self)
     self.clBtn = DirectButton(geom=CIGlobals.getCancelBtnGeom(),
                               relief=None,
                               text='Cancel',
                               text_fg=txtFg,
                               text_scale=txtScale,
                               text_pos=txtPos,
                               pos=(0.1, 0, -0.5),
                               parent=self)
     buttonGeom = (buttons.find('**/QT_back'), buttons.find('**/QT_back'),
                   buttons.find('**/QT_back'), buttons.find('**/QT_back'))
     self.backBtn = DirectButton(geom=buttonGeom,
                                 relief=None,
                                 scale=0.05,
                                 pos=(-0.3, 0, -0.25),
                                 parent=self,
                                 command=self.changePage,
                                 extraArgs=[0])
     self.nextBtn = DirectButton(geom=buttonGeom,
                                 relief=None,
                                 scale=0.05,
                                 pos=(0.3, 0, -0.25),
                                 hpr=(0, 0, 180),
                                 command=self.changePage,
                                 extraArgs=[1],
                                 parent=self)
     self.hideInfo()
     return
    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 __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()
Example #13
0
 def createGui(self):
     self.deleteGui()
     self.root = base.a2dBottomLeft.attachNewNode('moneyroot')
     self.root.setScale(0.8)
     self.root.setBin('gui-popup', 60)
     self.frame = DirectFrame(parent=self.root, pos=(0.43, 0, 0.16))
     gui = loader.loadModel("phase_3.5/models/gui/jar_gui.bam")
     self.jar = OnscreenImage(image=gui, scale=0.5, parent=self.frame)
     mf = loader.loadFont("phase_3/models/fonts/MickeyFont.bam")
     self.money_lbl = DirectLabel(text="", text_font=mf, text_fg=(1,1,0,1), parent=self.jar, text_scale=0.2, relief=None, pos=(0, 0, -0.1))
     gui.remove_node()
Example #14
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.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.325),
                                  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=(89.0 / 255, 95.0 / 255, 98.0 / 255,
                                        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=(89.0 / 255, 95.0 / 255,
                                             98.0 / 255, 1.0),
                                    text_font=CIGlobals.getMinnieFont(),
                                    parent=hidden,
                                    text_shadow=(0, 0, 0, 1))
Example #15
0
 def __init__(self, shop, image):
     OnscreenImage.__init__(self, image = image, scale = (0.9, 1, 0.7))
     self.shop = shop
     self.title = None
     self.okBtn = None
     self.clBtn = None
     self.infoLbl = None
     self.nPage = -1
     self.nPages = 0
     self.nextPage = 1
     self.prevPage = 0
     self.pages = []
     self.isSetup = False
 def load(self):
     self.unload()
     timer = loader.loadModel("phase_3.5/models/gui/clock_gui.bam")
     self.timer = OnscreenImage(image=timer.find('**/alarm_clock'),
                                parent=self)
     self.timeLbl = DirectLabel(text="0",
                                parent=self,
                                text_scale=0.3,
                                text_pos=(-0.05, -0.13),
                                text_fg=(0, 0, 0, 1),
                                relief=None,
                                text_align=TextNode.ACenter)
     timer.removeNode()
     del timer
 def makeSelectionGUI(self):
     font = CIGlobals.getMickeyFont()
     box = loader.loadModel('phase_3/models/gui/dialog_box_gui.bam')
     imp = CIGlobals.getToonFont()
     geom = CIGlobals.getDefaultBtnGeom()
     self.container = DirectFrame()
     self.bg = OnscreenImage(image=box,
                             color=(1, 1, 0.75, 1),
                             scale=(1.9, 1.4, 1.4),
                             parent=self.container)
     self.title = OnscreenText(text='Join  a  Team',
                               pos=(0, 0.5, 0),
                               font=font,
                               scale=0.12,
                               parent=self.container,
                               fg=(1, 0.9, 0.3, 1))
     self.btnFrame = DirectFrame(parent=self.container, pos=(0.14, 0, 0))
     self.team1BtnFrame = DirectFrame(parent=self.btnFrame,
                                      pos=(-0.5, 0, 0))
     self.team2BtnFrame = DirectFrame(parent=self.btnFrame,
                                      pos=(0.22, 0, 0))
     self.team1Btn = DirectButton(parent=self.team1BtnFrame,
                                  relief=None,
                                  pressEffect=0,
                                  image=self.team1BtnImg,
                                  image_scale=(0.9, 1, 1),
                                  scale=0.4,
                                  command=self.choseTeam,
                                  extraArgs=[TEAM1])
     self.team1Plyrs_Lbl = OnscreenText(parent=self.team1BtnFrame,
                                        text=str(self.playersByTeam[TEAM1]),
                                        pos=(0, -0.46, 0),
                                        font=imp)
     self.team2Btn = DirectButton(parent=self.team2BtnFrame,
                                  relief=None,
                                  pressEffect=0,
                                  image=self.team2BtnImg,
                                  image_scale=(0.9, 1, 1),
                                  scale=0.4,
                                  command=self.choseTeam,
                                  extraArgs=[TEAM2])
     self.team2Plyrs_Lbl = OnscreenText(parent=self.team2BtnFrame,
                                        text=str(self.playersByTeam[TEAM2]),
                                        pos=(0, -0.46, 0),
                                        font=imp)
     self.teamFull_Lbl = OnscreenText(parent=self.container,
                                      text='',
                                      pos=(0, -0.6, 0),
                                      font=imp)
     return
    def __init__(self):
        DirectObject.__init__(self)

        base.setBackgroundColor(0, 0, 0)

        self.textParent = base.credits2d.attachNewNode('textParent')
        self.textParent.setBin("gui-popup", 61)
        self.textParent.setDepthWrite(False)
        self.textParent.setTransparency(True)

        self.logoImage = OnscreenImage('phase_3/maps/CogInvasion_Logo.png',
                                       parent=self.textParent,
                                       scale=(0.685, 1.0, 0.325))
        self.logoImage.setTransparency(1)

        text = self.buildCreditsText()
        self.creditsText = OnscreenText(parent=self.textParent,
                                        font=CIGlobals.getToonFont(),
                                        fg=(1, 1, 1, 1),
                                        scale=0.065,
                                        pos=(0, -0.5, 0),
                                        text=text,
                                        shadow=(0, 0, 0, 1))

        self.posInterval = None

        self.backgroundImg = OnscreenImage('phase_3/maps/credits_fade.png',
                                           parent=render2d)
        self.backgroundImg.setTransparency(True)
        self.backgroundImg.setColor(0, 0, 0, 1.0)
        self.backgroundImg.setBin("gui-popup", 62)
        self.backgroundImg.setDepthWrite(False)

        self.exitText = OnscreenText(parent=base.credits2d,
                                     font=CIGlobals.getToonFont(),
                                     fg=(1.0, 0, 0, 1.0),
                                     shadow=(0, 0, 0, 1),
                                     scale=0.085,
                                     pos=(0, -0.96, 0),
                                     text='Press any key to exit')
        self.exitText.hide()
        self.exitText.setBin("gui-popup", 63)
        self.exitText.setDepthWrite(False)
        self.exitText.setTransparency(True)

        self.creditsAudioMgr = AudioManager.createAudioManager()
        self.creditsAudioMgr.setVolume(0.65)
        self.bgm = self.creditsAudioMgr.getSound(
            'phase_4/audio/bgm/new_years_fireworks_music.ogg')
Example #19
0
 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
Example #20
0
def getLogoImage(parent = None, size = 1, pos = (0, 0, 0)):
    from direct.gui.DirectGui import OnscreenImage

    if not parent:
        parent = aspect2d

    logo = loader.loadTexture("phase_3/maps/CogInvasion_Logo.png")
    logoNode = parent.attachNewNode('logoNode')
    logoNode.setScale(size)
    logoNode.setPos(pos)
    factor = 0.315
    logoImg = OnscreenImage(image = logo, scale = (1.920 * factor, 0, 1.080 * factor), parent = logoNode)
    logoImg.setTransparency(1)

    return [logoNode, logoImg]
 def createGui(self):
     self.deleteGui()
     self.frame = DirectFrame(parent=base.a2dBottomLeft,
                              pos=(0.45, 0, 0.155))
     gui = loader.loadModel("phase_3.5/models/gui/jar_gui.bam")
     self.jar = OnscreenImage(image=gui, scale=0.5, parent=self.frame)
     mf = loader.loadFont("phase_3/models/fonts/MickeyFont.bam")
     self.money_lbl = DirectLabel(text="",
                                  text_font=mf,
                                  text_fg=(1, 1, 0, 1),
                                  parent=self.jar,
                                  text_scale=0.2,
                                  relief=None,
                                  pos=(0, 0, -0.1))
     gui.remove_node()
class DirectionalDamageIndicator(NodePath):
    def __init__(self, damagePos):
        NodePath.__init__(self, 'dir-damage-indicator')
        self.reparentTo(aspect2d)
        self.damagePos = damagePos
        self.task = taskMgr.add(self.__update, 'ddi-update')
        self.img = OnscreenImage(image='materials/ui/damage_indicator.png',
                                 parent=self)
        self.setTransparency(True)
        self.setColorScale((1, 1, 1, 0.5))
        self.setScale(0.25)
        self.time = globalClock.getFrameTime()

        self.track = Sequence(
            Wait(1.5),
            LerpColorScaleInterval(self, 0.5, (1, 1, 1, 0), (1, 1, 1, 0.5)),
            Func(self.removeNode))
        self.track.start()

        DDIByPos[self.damagePos] = self

    @staticmethod
    def make(damagePos):
        if damagePos in DDIByPos:
            DDIByPos[damagePos].removeNode()
        DirectionalDamageIndicator(damagePos)

    def removeNode(self):
        del DDIByPos[self.damagePos]

        self.track.pause()
        self.track = None
        self.img.destroy()
        self.img = None
        self.time = None
        self.damagePos = None
        self.task.remove()
        self.task = None
        NodePath.removeNode(self)

    def __update(self, task):
        camSpacePos = base.cam.getRelativePoint(render, self.damagePos)

        arrowRadians = math.atan2(camSpacePos[0], camSpacePos[1])
        arrowDegrees = (arrowRadians / math.pi) * 180
        self.setR(arrowDegrees)

        return task.cont
Example #23
0
    def __init__(self):

        self.enabled = True

        sMgr = CIGlobals.getSettingsMgr()
        reso = sMgr.ReflectionQuality[sMgr.getSetting("refl").getValue()]
        if reso == 0:
            self.enabled = False
            return

        self.waterPlaneNP = None

        self.waterNodes = []

        # Buffer and reflection camera
        buffer = base.win.makeTextureBuffer('waterBuffer', reso, reso)
        buffer.setClearColor(Vec4(0, 0, 0, 1))

        cfa = CullFaceAttrib.makeReverse()
        rs = RenderState.make(cfa)

        self.watercamNP = base.makeCamera(buffer)
        self.watercamNP.reparentTo(render)

        self.makePlane(0.0)

        cam = self.watercamNP.node()
        cam.getLens().setFov(base.camLens.getFov())
        cam.getLens().setNear(1)
        cam.getLens().setFar(5000)
        cam.setInitialState(rs)
        cam.setTagStateKey('Clipped')

        self.ts0 = TextureStage("tex_0")
        self.tex0 = buffer.getTexture()
        self.tex0.setWrapU(Texture.WMClamp)
        self.tex0.setWrapV(Texture.WMClamp)

        self.ts1 = TextureStage("tex_1")
        self.waterTex = loader.loadTexture('phase_3/maps/water_distort.png')
        self.waterQuad = None

        self.waterStage = TextureStage("waterStage")

        image0 = OnscreenImage(image=self.tex0, scale=0.3, pos=(-0.5, 0, 0.7))
        image1 = OnscreenImage(image=waterTex, scale=0.3, pos=(0.5, 0, 0.7))

        taskMgr.add(self.update, "waterTask")
Example #24
0
 def start(self):
     self.fullyChargedSound = base.loadSfx('phase_4/audio/sfx/MG_pairing_match.mp3')
     self.rechargeSound = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_blue_arrow.mp3')
     self.batteryFrame = DirectFrame(parent=base.a2dBottomRight, pos=(-0.2, 0, 0.1), scale=(0.8, 0, 1))
     self.batteryBg = OnscreenImage(image='phase_4/maps/battery_charge_frame.png', parent=self.batteryFrame)
     self.batteryBg.setTransparency(1)
     self.batteryBg.setX(0.03)
     self.batteryBg.setScale(0.17, 0, 0.05)
     self.batteryBar = DirectWaitBar(value=0, range=5, barColor=(1, 1, 1, 1), relief=None, scale=(0.12, 0.0, 0.3), parent=self.batteryFrame)
     self.cameraFocus = loader.loadModel('phase_4/models/minigames/photo_game_viewfinder.bam')
     self.cameraFocus.reparentTo(base.aspect2d)
     self.focusCollHandler = CollisionHandlerEvent()
     self.focusCollHandler.setInPattern('%fn-into')
     self.focusCollHandler.setOutPattern('%fn-out')
     self.focusCollNode = CollisionNode('mouseRay')
     self.focusCollNP = base.camera.attachNewNode(self.focusCollNode)
     self.focusCollNode.setCollideMask(BitMask32(0))
     self.focusCollNode.setFromCollideMask(CIGlobals.WallBitmask)
     self.focusRay = CollisionRay()
     self.focusRay.setFromLens(base.camNode, 0.0, 0.0)
     self.focusCollNode.addSolid(self.focusRay)
     base.cTrav.addCollider(self.focusCollNP, self.focusCollHandler)
     base.localAvatar.walkControls.setWalkSpeed(CIGlobals.ToonForwardSpeed, 0.0, CIGlobals.ToonReverseSpeed, CIGlobals.ToonRotateSpeed)
     FirstPerson.start(self)
     return
    def __init__(self, version='n/a'):
        DirectObject.__init__(self)

        self.backgroundNodePath = render2d.attachNewNode('background', 0)
        self.backgroundModel = loader.loadModel(
            'phase_3/models/gui/loading-background.bam')
        self.backgroundModel.reparentTo(self.backgroundNodePath)
        self.backgroundNodePath.find('**/fg').removeNode()
        self.backgroundNodePath.setScale(1, 1, 1)

        self.logo = OnscreenImage(
            parent=base.a2dTopCenter, image='phase_3/maps/toontown-logo.png',
            scale=(1.0, 1, 0.5), pos=(0, 0, -0.85))
        self.logo.setTransparency(TransparencyAttrib.MAlpha)

        self.label = OnscreenText(
            TTLocalizer.ClickToStartLabel, parent=base.a2dBottomCenter,
            font=ToontownGlobals.getMinnieFont(), fg=Vec4(1, 1, 1, 1),
            scale=0.1, align=TextNode.ACenter)
        self.label.setZ(0.35)

        self.versionLabel = OnscreenText(
            '\x01white_shadow\x01%s\x02' % version, parent=base.a2dBottomRight,
            font=ToontownGlobals.getMinnieFont(), fg=Vec4(0, 0, 0, 1),
            scale=0.06, align=TextNode.ARight)
        self.versionLabel.setPos(-0.025, 0.025)

        self.setColorScale(Vec4(0, 0, 0, 0))

        self.fadeTrack = None
        self.logoPosTrack = None
        self.logoScaleTrack = None
        self.labelPosTrack = None
        self.labelColorScaleTrack = None
    def __init__(self):
        # 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()
Example #27
0
    def goto_home(self):
        self.soft_destroy()

        LerpPosHprInterval(base.camera, 0.35, Point3(0, 0, 0),
                           Point3(0, 0, 0)).start()

        logo = OnscreenImage(image=loader.loadTexture('mainmenu/logo.png'),
                             pos=(0, 0, 0.625),
                             scale=(1, 1, 0.4))
        logo.setTransparency(TransparencyAttrib.MAlpha)

        exit_button = DirectButton(
            geom=(self.sprites.find('**/mm-exit-ready'),
                  self.sprites.find('**/mm-exit-click'),
                  self.sprites.find('**/mm-exit-hover'),
                  self.sprites.find('**/mm-exit-disabled')),
            relief=None,
            geom_scale=(0.666, 0, 0.25),
            geom_pos=(0, 0, -0.75),
            command=self.level_holder.exit_game)
        settings_button = DirectButton(
            geom=(self.sprites.find('**/mm-settings-ready'),
                  self.sprites.find('**/mm-settings-click'),
                  self.sprites.find('**/mm-settings-hover'),
                  self.sprites.find('**/mm-settings-disabled')),
            relief=None,
            geom_scale=(0.666, 0, 0.25),
            geom_pos=(0, 0, -0.4),
            command=self.goto_settings)
        play_button = DirectButton(
            geom=(self.sprites.find('**/mm-play-ready'),
                  self.sprites.find('**/mm-play-click'),
                  self.sprites.find('**/mm-play-hover'),
                  self.sprites.find('**/mm-play-disabled')),
            relief=None,
            geom_scale=(1, 0, 0.3),
            geom_pos=(0, 0, 0.1),
            command=self.goto_play)

        if not self.level_holder.check_connection():
            play_button["state"] = DGG.DISABLED

        self.images["img_logo"] = logo
        self.gui["btn_exit"] = exit_button
        self.gui["btn_settings"] = settings_button
        self.gui["btn_play"] = play_button
Example #28
0
 def __init__(self):
     NodePath.__init__(self, 'waterBar')
     
     self.range = 100
     self.value = 100
     
     self.back = OnscreenImage("phase_14/maps/backv2.png", scale = (0.289, 1, 0.813), parent = self)
     self.bar = OnscreenImage("phase_14/maps/frontv2.png", scale = (0.233, 1, 0.740), parent = self)
     self.setTransparency(1)
     
     barSh = loader.loadShader("shaders/progress_bar.sha")
     self.bar.setShader(barSh)
     self.bar.setShaderInput("tex", loader.loadTexture("phase_14/maps/frontv2.png"))
     self.bar.setShaderInput("perct", float(self.value) / float(self.range))
     self.bar.setShaderInput("dir", 0)
     self.bar.setShaderInput("alpha", 1.0)
     
     self.task = taskMgr.add(self.__update, "WaterBar.update")
    def __init__(self, damagePos):
        NodePath.__init__(self, 'dir-damage-indicator')
        self.reparentTo(aspect2d)
        self.damagePos = damagePos
        self.task = taskMgr.add(self.__update, 'ddi-update')
        self.img = OnscreenImage(image='materials/ui/damage_indicator.png',
                                 parent=self)
        self.setTransparency(True)
        self.setColorScale((1, 1, 1, 0.5))
        self.setScale(0.25)
        self.time = globalClock.getFrameTime()

        self.track = Sequence(
            Wait(1.5),
            LerpColorScaleInterval(self, 0.5, (1, 1, 1, 0), (1, 1, 1, 0.5)),
            Func(self.removeNode))
        self.track.start()

        DDIByPos[self.damagePos] = self
 def updateTurretCount(self):
     if self.turretLabel:
         self.turretLabel.destroy()
     if self.wantTurretCount:
         maxTurrets = CogBattleGlobals.MAX_TURRETS
         if not self.turretImg:
             self.turretImg = OnscreenImage(
                 image='phase_3.5/maps/cannon-icon.png',
                 scale=(0.05, 1, 0.05),
                 pos=(-0.22, 0, 0.275))
             self.turretImg.setTransparency(TransparencyAttrib.MAlpha)
         self.turretLabel = DirectLabel(
             text='Turrets: %s/%s' %
             (str(self.turretCount), str(maxTurrets)),
             relief=None,
             text_scale=0.07,
             text_fg=(0, 0, 0, 1),
             text_shadow=(0, 0, 0, 0),
             pos=(0, 0, 0.265))
     return
 def __init__(self):
     ShowBase.__init__(self)
     depth = Texture("depth")
     depth.setWrapU(Texture.WMClamp)
     depth.setWrapV(Texture.WMClamp)
     self.fmgr = FilterManager(self.win, self.cam)
     depthQuad = self.fmgr.renderQuadInto(depthtex=depth)
     #depthQuad.hide()
     smiley = loader.loadModel("models/smiley.egg.pz")
     smiley.reparentTo(render)
     img = OnscreenImage(image=depth, scale=0.3, pos=(0, 0, -0.7))
Example #32
0
 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
Example #33
0
    def __init__(self, version='n/a'):
        DirectObject.__init__(self)

        self.backgroundNodePath = render2d.attachNewNode('background', 0)
        self.backgroundModel = loader.loadModel(
            'phase_3/models/gui/loading-background.bam')
        self.backgroundModel.reparentTo(self.backgroundNodePath)
        self.backgroundNodePath.find('**/fg').removeNode()
        self.backgroundNodePath.setScale(1, 1, 1)

        self.logo = OnscreenImage(parent=base.a2dTopCenter,
                                  image='phase_3/maps/toontown-logo.png',
                                  scale=(1.0, 1, 0.5),
                                  pos=(0, 0, -0.85))
        self.logo.setTransparency(TransparencyAttrib.MAlpha)

        self.label = OnscreenText(TTLocalizer.ClickToStartLabel,
                                  parent=base.a2dBottomCenter,
                                  font=ToontownGlobals.getMinnieFont(),
                                  fg=Vec4(1, 1, 1, 1),
                                  scale=0.1,
                                  align=TextNode.ACenter)
        self.label.setZ(0.35)

        self.versionLabel = OnscreenText('\x01white_shadow\x01%s\x02' %
                                         version,
                                         parent=base.a2dBottomRight,
                                         font=ToontownGlobals.getMinnieFont(),
                                         fg=Vec4(0, 0, 0, 1),
                                         scale=0.06,
                                         align=TextNode.ARight)
        self.versionLabel.setPos(-0.025, 0.025)

        self.setColorScale(Vec4(0, 0, 0, 0))

        self.fadeTrack = None
        self.logoPosTrack = None
        self.logoScaleTrack = None
        self.labelPosTrack = None
        self.labelColorScaleTrack = None
    def start(self):
        self.fullyChargedSound = base.loadSfx(
            'phase_4/audio/sfx/MG_pairing_match.ogg')
        self.rechargeSound = base.loadSfx(
            'phase_4/audio/sfx/MG_sfx_travel_game_blue_arrow.ogg')
        self.batteryFrame = DirectFrame(parent=base.a2dBottomRight,
                                        pos=(-0.2, 0, 0.1),
                                        scale=(0.8, 0, 1))
        self.batteryBg = OnscreenImage(
            image='phase_4/maps/battery_charge_frame.png',
            parent=self.batteryFrame)
        self.batteryBg.setTransparency(1)
        self.batteryBg.setX(0.03)
        self.batteryBg.setScale(0.17, 0, 0.05)
        self.batteryBar = DirectWaitBar(value=0,
                                        range=5,
                                        barColor=(1, 1, 1, 1),
                                        relief=None,
                                        scale=(0.12, 0.0, 0.3),
                                        parent=self.batteryFrame)
        self.cameraFocus = loader.loadModel(
            "phase_4/models/minigames/photo_game_viewfinder.bam")
        self.cameraFocus.reparentTo(base.aspect2d)

        self.focusTrav = CollisionTraverser('CSFP.focusTrav')
        ray = CollisionRay()
        rayNode = CollisionNode('CSFP.rayNode')
        rayNode.addSolid(ray)
        rayNode.setCollideMask(BitMask32(0))
        rayNode.setFromCollideMask(CIGlobals.WallBitmask)
        self.focusRay = ray
        self.focusRayNode = base.camera.attachNewNode(rayNode)
        self.focusHandler = CollisionHandlerQueue()
        self.focusTrav.addCollider(self.focusRayNode, self.focusHandler)

        base.localAvatar.walkControls.setWalkSpeed(CIGlobals.ToonForwardSpeed,
                                                   0.0,
                                                   CIGlobals.ToonReverseSpeed,
                                                   CIGlobals.ToonRotateSpeed)
        FirstPerson.start(self)
Example #35
0
class MoneyGUI:

    def createGui(self):
        self.deleteGui()
        self.root = base.a2dBottomLeft.attachNewNode('moneyroot')
        self.root.setScale(0.8)
        self.root.setBin('gui-popup', 60)
        self.frame = DirectFrame(parent=self.root, pos=(0.43, 0, 0.16))
        gui = loader.loadModel("phase_3.5/models/gui/jar_gui.bam")
        self.jar = OnscreenImage(image=gui, scale=0.5, parent=self.frame)
        mf = loader.loadFont("phase_3/models/fonts/MickeyFont.bam")
        self.money_lbl = DirectLabel(text="", text_font=mf, text_fg=(1,1,0,1), parent=self.jar, text_scale=0.2, relief=None, pos=(0, 0, -0.1))
        gui.remove_node()

    def deleteGui(self):
        if hasattr(self, 'jar'):
            self.jar.destroy()
            del self.jar
        if hasattr(self, 'money_lbl'):
            self.money_lbl.destroy()
            del self.money_lbl
        if hasattr(self, 'frame'):
            self.frame.destroy()
            del self.frame

    def update(self, newMoney, oldMoney = 0):
        delta = newMoney - oldMoney
        if delta != 0:
            CIGlobals.makeDeltaTextEffect(delta, base.a2dBottomLeft, (0.173, 0, 0.12))
            if delta > 0:
                ToontownIntervals.start(ToontownIntervals.getPulseLargerIval(self.frame, 'money-effect'))
            else:
                ToontownIntervals.start(ToontownIntervals.getPulseSmallerIval(self.frame, 'money-effect'))
            
        if hasattr(self, 'money_lbl'):
            if newMoney <= 0:
                self.money_lbl['text_fg'] = (1, 0, 0, 1)
            else:
                self.money_lbl['text_fg'] = (1, 1, 0, 1)
            self.money_lbl['text'] = str(newMoney)
 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)
Example #37
0
 def setup(self, title = 'CHOOSE WHAT YOU WANT TO BUY'):
     font = CIGlobals.getMickeyFont()
     txtFg = (0, 0, 0, 1)
     txtScale = 0.05
     txtPos = (0, -0.1)
     buttons = loader.loadModel('phase_3.5/models/gui/QT_buttons.bam')
     self.window = OnscreenImage(image=self.bgImage, scale=(0.9, 1, 0.7), parent=self)
     self.title = DirectLabel(text=title, relief=None, pos=(0, 0, 0.5), text_wordwrap=10, text_font=font, text_fg=(1, 1, 0, 1), scale=0.1, parent=self)
     self.infoLbl = DirectLabel(text='Welcome!', relief=None, text_scale=0.075, text_fg=txtFg, text_shadow=(0, 0, 0, 0), pos=(0, 0, 0.215))
     self.okBtn = DirectButton(geom=CIGlobals.getOkayBtnGeom(), relief=None, text='OK', text_fg=txtFg, text_scale=txtScale, text_pos=txtPos, pos=(-0.1, 0, -0.5), parent=self)
     self.clBtn = DirectButton(geom=CIGlobals.getCancelBtnGeom(), relief=None, text='Cancel', text_fg=txtFg, text_scale=txtScale, text_pos=txtPos, pos=(0.1, 0, -0.5), parent=self)
     buttonGeom = (buttons.find('**/QT_back'),
      buttons.find('**/QT_back'),
      buttons.find('**/QT_back'),
      buttons.find('**/QT_back'))
     self.backBtn = DirectButton(geom=buttonGeom, relief=None, scale=0.05, pos=(-0.3, 0, -0.25), parent=self, command=self.changePage, extraArgs=[0])
     self.nextBtn = DirectButton(geom=buttonGeom, relief=None, scale=0.05, pos=(0.3, 0, -0.25), hpr=(0, 0, 180), command=self.changePage, extraArgs=[1], parent=self)
     self.hideInfo()
     return
 def makeGui(self):
     self.destroyGui()
     self.guiFrame = DirectFrame(parent=base.a2dBottomRight, pos=(-0.55, 0, 0.15))
     self.guiBg = OnscreenImage(image="phase_4/maps/turret_gui_bg.png", scale=(0.15, 0, 0.075), parent=self.guiFrame)
     self.guiBg.setTransparency(True)
     self.guiLabel = DirectLabel(
         text="Turret",
         text_fg=(1, 0, 0, 1),
         relief=None,
         text_scale=0.05,
         text_font=loader.loadFont("phase_3/models/fonts/ImpressBT.ttf"),
         pos=(0, 0, 0.025),
         parent=self.guiFrame,
     )
     self.guiBar = DirectWaitBar(
         range=self.myTurret.getMaxHealth(),
         value=self.myTurret.getHealth(),
         scale=0.125,
         parent=self.guiFrame,
         pos=(0, 0, -0.01),
     )
     return
Example #39
0
class CameraShyFirstPerson(FirstPerson):
    toonInFocusColor = VBase4(0.25, 1.0, 0.25, 1.0)
    toonOutOfFocusColor = VBase4(1.0, 1.0, 1.0, 1.0)
    fullyChargedState = 5

    def __init__(self, mg):
        self.mg = mg
        self.cameraFocus = None
        self.batteryFrame = None
        self.batteryBg = None
        self.batteryBar = None
        self.rechargeSound = None
        self.fullyChargedSound = None
        self.hasToonInFocus = False
        self.toonToTakePicOf = None
        self.cameraRechargeState = None
        self.cameraRechargingLabel = None
        self.cameraFlashSeq = None
        self.camFSM = ClassicFSM('CameraFSM', [State('off', self.enterOff, self.exitOff), State('ready', self.enterCameraReady, self.exitCameraReady), State('recharge', self.enterCameraRecharge, self.exitCameraRecharge)], 'off', 'off')
        self.camFSM.enterInitialState()
        FirstPerson.__init__(self)
        return

    def movementTask(self, task):
        if not inputState.isSet('jump') and not base.localAvatar.walkControls.isAirborne and inputState.isSet('forward') or inputState.isSet('reverse') or inputState.isSet('slideLeft') or inputState.isSet('slideRight'):
            if base.localAvatar.getAnimState() != 'run':
                base.localAvatar.setAnimState('run')
                base.localAvatar.playMovementSfx('run')
                self.mg.sendUpdate('runningAvatar', [base.localAvatar.doId])
        elif inputState.isSet('jump') or base.localAvatar.walkControls.isAirborne:
            if base.localAvatar.getAnimState() != 'jump':
                base.localAvatar.setAnimState('jump')
                base.localAvatar.playMovementSfx(None)
                self.mg.sendUpdate('jumpingAvatar', [base.localAvatar.doId])
        elif base.localAvatar.getAnimState() != 'neutral':
            base.localAvatar.setAnimState('neutral')
            base.localAvatar.playMovementSfx(None)
            self.mg.sendUpdate('standingAvatar', [base.localAvatar.doId])
        return task.cont

    def enterOff(self):
        pass

    def exitOff(self):
        pass

    def enterCameraReady(self):
        self.acceptOnce('mouse1', self.__mouse1Pressed)

    def stopCameraFlash(self):
        if self.cameraFlashSeq:
            self.cameraFlashSeq.finish()
            self.cameraFlashSeq = None
        return

    def __mouse1Pressed(self):
        self.cameraFlashSeq = Sequence(Func(base.transitions.setFadeColor, 1, 1, 1), Func(base.transitions.fadeOut, 0.1), Wait(0.1), Func(base.transitions.fadeIn, 0.1), Wait(0.1), Func(base.transitions.setFadeColor, 0, 0, 0))
        self.cameraFlashSeq.start()
        self.mg.sendUpdate('remoteAvatarTakePicture', [base.localAvatar.doId])
        self.mg.myRemoteAvatar.takePicture()
        if self.hasToonInFocus and self.toonToTakePicOf:
            self.mg.sendUpdate('tookPictureOfToon', [self.toonToTakePicOf.doId])
        self.camFSM.request('recharge')

    def exitCameraReady(self):
        self.ignore('mouse1')

    def enterCameraRecharge(self):
        self.batteryBar.update(0)
        taskMgr.add(self.__rechargeNextState, 'rechargeCamera')

    def __rechargeNextState(self, task):
        if self.cameraRechargeState == None:
            self.cameraRechargeState = -1
        self.cameraRechargeState += 1
        if self.cameraRechargeState > 0:
            base.playSfx(self.rechargeSound)
        self.batteryBar.update(self.cameraRechargeState)
        if self.cameraRechargeState == self.fullyChargedState:
            base.playSfx(self.fullyChargedSound)
            self.camFSM.request('ready')
            return task.done
        else:
            task.delayTime = 1.0
            return task.again

    def exitCameraRecharge(self):
        taskMgr.remove('rechargeCamera')
        self.cameraRechargeState = None
        return

    def __handleRayInto(self, entry):
        intoNP = entry.getIntoNodePath()
        toonNP = intoNP.getParent()
        for key in base.cr.doId2do.keys():
            obj = base.cr.doId2do[key]
            if obj.__class__.__name__ == 'DistributedToon':
                if obj.getKey() == toonNP.getKey():
                    self.__handleToonInFocus(obj)

    def __handleRayOut(self, entry):
        intoNP = entry.getIntoNodePath()
        toonNP = intoNP.getParent()
        for key in base.cr.doId2do.keys():
            obj = base.cr.doId2do[key]
            if obj.__class__.__name__ == 'DistributedToon':
                if obj.getKey() == toonNP.getKey():
                    self.toonToTakePicOf = None
                    self.hasToonInFocus = False
                    if self.cameraFocus.getColorScale() == self.toonInFocusColor:
                        self.cameraFocus.setColorScale(self.toonOutOfFocusColor)

        return

    def __handleToonInFocus(self, toon):
        if not self.hasToonInFocus or self.toonToTakePicOf is not None or self.toonToTakePicOf.doId != toon.doId:
            self.toonToTakePicOf = toon
            self.hasToonInFocus = True
            self.cameraFocus.setColorScale(self.toonInFocusColor)
        return

    def start(self):
        self.fullyChargedSound = base.loadSfx('phase_4/audio/sfx/MG_pairing_match.mp3')
        self.rechargeSound = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_blue_arrow.mp3')
        self.batteryFrame = DirectFrame(parent=base.a2dBottomRight, pos=(-0.2, 0, 0.1), scale=(0.8, 0, 1))
        self.batteryBg = OnscreenImage(image='phase_4/maps/battery_charge_frame.png', parent=self.batteryFrame)
        self.batteryBg.setTransparency(1)
        self.batteryBg.setX(0.03)
        self.batteryBg.setScale(0.17, 0, 0.05)
        self.batteryBar = DirectWaitBar(value=0, range=5, barColor=(1, 1, 1, 1), relief=None, scale=(0.12, 0.0, 0.3), parent=self.batteryFrame)
        self.cameraFocus = loader.loadModel('phase_4/models/minigames/photo_game_viewfinder.bam')
        self.cameraFocus.reparentTo(base.aspect2d)
        self.focusCollHandler = CollisionHandlerEvent()
        self.focusCollHandler.setInPattern('%fn-into')
        self.focusCollHandler.setOutPattern('%fn-out')
        self.focusCollNode = CollisionNode('mouseRay')
        self.focusCollNP = base.camera.attachNewNode(self.focusCollNode)
        self.focusCollNode.setCollideMask(BitMask32(0))
        self.focusCollNode.setFromCollideMask(CIGlobals.WallBitmask)
        self.focusRay = CollisionRay()
        self.focusRay.setFromLens(base.camNode, 0.0, 0.0)
        self.focusCollNode.addSolid(self.focusRay)
        base.cTrav.addCollider(self.focusCollNP, self.focusCollHandler)
        base.localAvatar.walkControls.setWalkSpeed(CIGlobals.ToonForwardSpeed, 0.0, CIGlobals.ToonReverseSpeed, CIGlobals.ToonRotateSpeed)
        FirstPerson.start(self)
        return

    def reallyStart(self):
        self.accept('mouseRay-into', self.__handleRayInto)
        self.accept('mouseRay-out', self.__handleRayOut)
        self.camFSM.request('recharge')
        taskMgr.add(self.movementTask, 'movementTask')
        FirstPerson.reallyStart(self)

    def end(self):
        self.camFSM.request('off')
        taskMgr.remove('movementTask')
        self.ignore('mouseRay-into')
        self.ignore('mouseRay-out')
        FirstPerson.end(self)

    def reallyEnd(self):
        self.batteryBar.destroy()
        self.batteryBar = None
        self.batteryBg.destroy()
        self.batteryBg = None
        self.batteryFrame.destroy()
        self.batteryFrame = None
        self.cameraFocus.removeNode()
        self.cameraFocus = None
        self.focusCollHandler = None
        self.focusCollNode = None
        self.focusCollNP.removeNode()
        self.focusCollNP = None
        self.focusRay = None
        self.hasToonInFocus = None
        self.toonToTakePicOf = None
        self.fullyChargedSound = None
        self.rechargeSound = None
        self.stopCameraFlash()
        FirstPerson.reallyEnd(self)
        base.localAvatar.walkControls.setWalkSpeed(CIGlobals.ToonForwardSpeed, CIGlobals.ToonJumpForce, CIGlobals.ToonReverseSpeed, CIGlobals.ToonRotateSpeed)
        return

    def cleanup(self):
        self.camFSM.requestFinalState()
        self.camFSM = None
        FirstPerson.cleanup(self)
        return
Example #40
0
class ShopWindow(DirectFrame):

    def __init__(self, shop, image):
        DirectFrame.__init__(self)
        self.shop = shop
        self.bgImage = image
        self.title = None
        self.okBtn = None
        self.clBtn = None
        self.infoLbl = None
        self.nPage = -1
        self.nPages = 0
        self.nextPage = 0
        self.prevPage = -1
        self.pages = []
        self.isSetup = False
        return

    def setup(self, title = 'CHOOSE WHAT YOU WANT TO BUY'):
        font = CIGlobals.getMickeyFont()
        txtFg = (0, 0, 0, 1)
        txtScale = 0.05
        txtPos = (0, -0.1)
        buttons = loader.loadModel('phase_3.5/models/gui/QT_buttons.bam')
        self.window = OnscreenImage(image=self.bgImage, scale=(0.9, 1, 0.7), parent=self)
        self.title = DirectLabel(text=title, relief=None, pos=(0, 0, 0.5), text_wordwrap=10, text_font=font, text_fg=(1, 1, 0, 1), scale=0.1, parent=self)
        self.infoLbl = DirectLabel(text='Welcome!', relief=None, text_scale=0.075, text_fg=txtFg, text_shadow=(0, 0, 0, 0), pos=(0, 0, 0.215))
        self.okBtn = DirectButton(geom=CIGlobals.getOkayBtnGeom(), relief=None, text='OK', text_fg=txtFg, text_scale=txtScale, text_pos=txtPos, pos=(-0.1, 0, -0.5), parent=self)
        self.clBtn = DirectButton(geom=CIGlobals.getCancelBtnGeom(), relief=None, text='Cancel', text_fg=txtFg, text_scale=txtScale, text_pos=txtPos, pos=(0.1, 0, -0.5), parent=self)
        buttonGeom = (buttons.find('**/QT_back'),
         buttons.find('**/QT_back'),
         buttons.find('**/QT_back'),
         buttons.find('**/QT_back'))
        self.backBtn = DirectButton(geom=buttonGeom, relief=None, scale=0.05, pos=(-0.3, 0, -0.25), parent=self, command=self.changePage, extraArgs=[0])
        self.nextBtn = DirectButton(geom=buttonGeom, relief=None, scale=0.05, pos=(0.3, 0, -0.25), hpr=(0, 0, 180), command=self.changePage, extraArgs=[1], parent=self)
        self.hideInfo()
        return

    def changePage(self, direction):
        var = self.prevPage
        if direction == 1:
            var = self.nextPage
        self.setPage(var)

    def __makeGagEntry(self, pos, item, values, page):
        itemImage = values.get('image')
        button = DirectButton(geom=itemImage, scale=1.3, pos=pos, relief=None, parent=page, command=self.shop.purchaseItem, extraArgs=[item])
        supply = base.localAvatar.getBackpack().getSupply(item().getName())
        maxSupply = base.localAvatar.getBackpack().getMaxSupply(item().getName())
        buttonLabel = DirectLabel(text='%s/%s\n%s JBS' % (str(supply), str(maxSupply), str(values.get('price'))), relief=None, parent=button, text_scale=0.05, pos=(0, 0, -0.11))
        self.addEntryToPage(page, item, values, button, buttonLabel)
        return

    def __makeUpgradeEntry(self, pos, item, values, page):
        itemImage = values.get('image')
        button = DirectButton(image=itemImage, scale=0.15, pos=pos, relief=None, parent=page, command=self.shop.purchaseItem, extraArgs=[item])
        button.setTransparency(TransparencyAttrib.MAlpha)
        upgradeID = values.get('upgradeID')
        supply = base.localAvatar.getPUInventory()[0]
        if supply < 0:
            supply = 0
        maxSupply = values.get('maxUpgrades')
        if upgradeID == 0 and base.localAvatar.getMyBattle().getTurretManager().myTurret:
            supply = 1
        buttonLabel = DirectLabel(text='%s\n%s/%s\n%s JBS' % (item,
         str(supply),
         str(maxSupply),
         str(values.get('price'))), relief=None, parent=button, text_scale=0.3, pos=(0, 0, -1.2))
        self.addEntryToPage(page, item, values, button, buttonLabel)
        return

    def __makeHealEntry(self, pos, item, values, page):
        label = '%s' % item
        itemImage = values.get('image')
        if 'showTitle' in values:
            label = '%s\n%s JBS' % (item, values.get('price'))
        button = DirectButton(image=itemImage, scale=0.105, pos=pos, relief=None, parent=page, command=self.shop.purchaseItem, extraArgs=[item])
        button.setTransparency(TransparencyAttrib.MAlpha)
        buttonLabel = DirectLabel(text=label, relief=None, parent=button, text_scale=0.55, pos=(0, 0, -1.6))
        self.addEntryToPage(page, item, values, button, buttonLabel)
        return

    def addEntryToPage(self, page, item, values, button, buttonLabel):
        page.addItemEntry(item, [button, buttonLabel])
        page.addItem({item: values})

    def makePages(self, items):
        newItems = dict(items)
        loadout = []
        for slot in base.localAvatar.getBackpack().gagGUI.getSlots():
            loadout.append(slot.getGag().getID())

        for item, values in newItems.items():
            if values.get('type') == ItemType.GAG:
                gag = item()
                if gag.getID() not in loadout or not base.localAvatar.getBackpack().isInBackpack(gag.getName()):
                    del newItems[item]

        self.nPages = int(len(newItems) / 4)
        if self.nPages % 4 != 0 and len(newItems) > 4:
            self.nPages += 1
        elif self.nPages == 0:
            self.nPages = 1
        itemPos = [(-0.45, 0, 0),
         (-0.15, 0, 0),
         (0.15, 0, 0),
         (0.45, 0, 0)]
        pageIndex = 0
        itemIndex = 0
        index = 1
        for _ in range(self.nPages):
            page = Page(self.shop, self)
            self.pages.append(page)

        for item, values in newItems.iteritems():
            pos = itemPos[itemIndex]
            page = self.pages[pageIndex]
            itemType = values.get('type')
            if itemType == ItemType.GAG:
                self.__makeGagEntry(pos, item, values, page)
            elif itemType == ItemType.UPGRADE:
                self.__makeUpgradeEntry(pos, item, values, page)
            elif itemType == ItemType.HEAL:
                self.__makeHealEntry(pos, item, values, page)
            if index % 4 == 0:
                index = 1
                pageIndex += 1
                itemIndex = 0
            else:
                itemIndex = itemIndex + 1
                index += 1

        if self.nPages == 1:
            self.backBtn.hide()
            self.nextBtn.hide()
        for page in self.pages:
            page.hide()
            page.update()

        self.isSetup = True

    def updatePages(self):
        for page in self.pages:
            page.update()

    def setPage(self, page):
        if self.nPage > -1:
            self.pages[self.nPage].hide()
        self.setBackBtn(True)
        self.setNextBtn(True)
        if page - 1 < 0:
            self.setBackBtn(False)
        elif page + 1 == self.nPages:
            self.setNextBtn(False)
        if page < 0 or page > self.nPages:
            return
        self.prevPage = page - 1
        self.nextPage = page + 1
        self.nPage = page
        self.pages[page].show()

    def setBackBtn(self, enabled):
        if self.backBtn:
            if enabled == False:
                self.backBtn.setColorScale(GRAYED_OUT_COLOR)
                self.backBtn['state'] = DGG.DISABLED
            else:
                self.backBtn.setColorScale(NORMAL_COLOR)
                self.backBtn['state'] = DGG.NORMAL

    def setNextBtn(self, enabled):
        if self.nextBtn:
            if enabled == False:
                self.nextBtn.setColorScale(GRAYED_OUT_COLOR)
                self.nextBtn['state'] = DGG.DISABLED
            else:
                self.nextBtn.setColorScale(NORMAL_COLOR)
                self.nextBtn['state'] = DGG.NORMAL

    def setOKCommand(self, command):
        if self.okBtn:
            self.okBtn['command'] = command

    def setCancelCommand(self, command):
        if self.clBtn:
            self.clBtn['command'] = command

    def showInfo(self, text, negative = 0, duration = -1):
        self.infoLbl.show()
        if negative:
            self.infoLbl['text_fg'] = (0.9, 0, 0, 1)
            self.infoLbl['text_shadow'] = (0, 0, 0, 1)
        else:
            self.infoLbl['text_fg'] = (0, 0, 0, 1)
            self.infoLbl['text_shadow'] = (0, 0, 0, 0)
        self.infoLbl['text'] = text
        if duration > -1:
            Sequence(Wait(duration), Func(self.hideInfo)).start()

    def hideInfo(self):
        if self.infoLbl:
            self.infoLbl.hide()

    def delete(self):
        elements = [self.title,
         self.okBtn,
         self.clBtn,
         self.infoLbl,
         self.backBtn,
         self.nextBtn]
        for element in elements:
            element.destroy()

        del elements
        for page in self.pages:
            page.destroy()
            self.pages.remove(page)

        self.title = None
        self.okBtn = None
        self.clBtn = None
        self.infoLbl = None
        self.backBtn = None
        self.nextBtn = None
        self.bgImage = None
        if self.window:
            self.window.destroy()
            self.window = None
        self.destroy()
        return
class DistributedPieTurretManager(DistributedObject):
    notify = directNotify.newCategory("DistributedPieTurretManager")

    def __init__(self, cr):
        DistributedObject.__init__(self, cr)
        self.myTurret = None
        self.guiFrame = None
        self.guiLabel = None
        self.guiBar = None
        self.guiBg = None
        self.turretGag = None
        return

    def announceGenerate(self):
        DistributedObject.announceGenerate(self)
        base.taskMgr.add(self.__pollMyBattle, "__pollMyBattle")

    def disable(self):
        base.taskMgr.remove("DPTM.pollTurret")
        base.taskMgr.remove("__pollMyBattle")
        if hasattr(self, "makeTurretBtn"):
            self.makeTurretBtn.destroy()
            del self.makeTurretBtn
        self.destroyGui()
        self.myTurret = None
        if base.localAvatar.getMyBattle():
            base.localAvatar.getMyBattle().setTurretManager(None)
        DistributedObject.disable(self)
        return

    def __pollTurret(self, turretId, task):
        turret = self.cr.doId2do.get(turretId)
        if turret != None:
            self.myTurret = turret
            self.turretGag = None
            self.makeGui()
            return Task.done
        else:
            return Task.cont

    def setGag(self, upgradeId):
        self.turretGag = upgradeId

    def d_requestPlace(self, posHpr):
        self.sendUpdate("requestPlace", [posHpr])

    def turretPlaced(self, turretId):
        turret = self.cr.doId2do.get(turretId)
        turret.b_setGag(self.turretGag)
        self.turretGag = None
        base.taskMgr.add(self.__pollTurret, "DPTM.pollTurret", extraArgs=[turretId], appendTask=True)
        return

    def yourTurretIsDead(self):
        base.taskMgr.remove("DPTM.pollTurret")
        self.destroyGui()
        self.myTurret = None
        if base.localAvatar.getPUInventory()[0] > 0:
            self.createTurretButton()
        return

    def makeGui(self):
        self.destroyGui()
        self.guiFrame = DirectFrame(parent=base.a2dBottomRight, pos=(-0.55, 0, 0.15))
        self.guiBg = OnscreenImage(image="phase_4/maps/turret_gui_bg.png", scale=(0.15, 0, 0.075), parent=self.guiFrame)
        self.guiBg.setTransparency(True)
        self.guiLabel = DirectLabel(
            text="Turret",
            text_fg=(1, 0, 0, 1),
            relief=None,
            text_scale=0.05,
            text_font=loader.loadFont("phase_3/models/fonts/ImpressBT.ttf"),
            pos=(0, 0, 0.025),
            parent=self.guiFrame,
        )
        self.guiBar = DirectWaitBar(
            range=self.myTurret.getMaxHealth(),
            value=self.myTurret.getHealth(),
            scale=0.125,
            parent=self.guiFrame,
            pos=(0, 0, -0.01),
        )
        return

    def createTurretButton(self):
        self.makeTurretBtn = DirectButton(
            relief=None,
            geom=CIGlobals.getDefaultBtnGeom(),
            text="Turret",
            text_scale=0.055,
            command=self.handleMakeTurretBtn,
            pos=(-0.47, 0, 0.1),
            geom_scale=(0.5, 1.0, 1.0),
            text_pos=(0, -0.01),
            parent=base.a2dBottomRight,
        )
        return

    def handleMakeTurretBtn(self):
        self.makeTurretBtn.destroy()
        del self.makeTurretBtn
        x, y, z = base.localAvatar.getPos()
        h, p, r = base.localAvatar.getHpr()
        self.d_requestPlace([x, y, z, h, p, r])
        base.localAvatar.sendUpdate("usedPU", [0])

    def __pollMyBattle(self, task):
        if base.localAvatar.getMyBattle():
            base.localAvatar.getMyBattle().setTurretManager(self)
            if base.localAvatar.getPUInventory()[0] > 0:
                self.createTurretButton()
            return Task.done
        return Task.cont

    def destroyGui(self):
        if self.guiBar:
            self.guiBar.destroy()
            self.guiBar = None
        if self.guiLabel:
            self.guiLabel.destroy()
            self.guiLabel = None
        if self.guiBg:
            self.guiBg.destroy()
            self.guiBg = None
        if self.guiFrame:
            self.guiFrame.destroy()
            self.guiFrame = None
        return

    def updateTurretGui(self):
        if self.guiBar:
            self.guiBar.update(self.myTurret.getHealth())
class ClickToStart(DirectObject):
    notify = directNotify.newCategory('ClickToStart')

    def __init__(self, version='n/a'):
        DirectObject.__init__(self)

        self.backgroundNodePath = render2d.attachNewNode('background', 0)
        self.backgroundModel = loader.loadModel(
            'phase_3/models/gui/loading-background.bam')
        self.backgroundModel.reparentTo(self.backgroundNodePath)
        self.backgroundNodePath.find('**/fg').removeNode()
        self.backgroundNodePath.setScale(1, 1, 1)

        self.logo = OnscreenImage(
            parent=base.a2dTopCenter, image='phase_3/maps/toontown-logo.png',
            scale=(1.0, 1, 0.5), pos=(0, 0, -0.85))
        self.logo.setTransparency(TransparencyAttrib.MAlpha)

        self.label = OnscreenText(
            TTLocalizer.ClickToStartLabel, parent=base.a2dBottomCenter,
            font=ToontownGlobals.getMinnieFont(), fg=Vec4(1, 1, 1, 1),
            scale=0.1, align=TextNode.ACenter)
        self.label.setZ(0.35)

        self.versionLabel = OnscreenText(
            '\x01white_shadow\x01%s\x02' % version, parent=base.a2dBottomRight,
            font=ToontownGlobals.getMinnieFont(), fg=Vec4(0, 0, 0, 1),
            scale=0.06, align=TextNode.ARight)
        self.versionLabel.setPos(-0.025, 0.025)

        self.setColorScale(Vec4(0, 0, 0, 0))

        self.fadeTrack = None
        self.logoPosTrack = None
        self.logoScaleTrack = None
        self.labelPosTrack = None
        self.labelColorScaleTrack = None

    def delete(self):
        if self.labelColorScaleTrack is not None:
            self.labelColorScaleTrack.finish()
            self.labelColorScaleTrack = None

        if self.labelPosTrack is not None:
            self.labelPosTrack.finish()
            self.labelPosTrack = None

        if self.logoScaleTrack is not None:
            self.logoScaleTrack.finish()
            self.logoScaleTrack = None

        if self.logoPosTrack is not None:
            self.logoPosTrack.finish()
            self.logoPosTrack = None

        if self.fadeTrack is not None:
            self.fadeTrack.finish()
            self.fadeTrack = None

        if self.versionLabel is not None:
            self.versionLabel.destroy()
            self.versionLabel = None

        if self.label is not None:
            self.label.destroy()
            self.label = None

        if self.logo is not None:
            self.logo.destroy()
            self.logo = None

        if self.backgroundNodePath is not None:
            self.backgroundNodePath.removeNode()
            self.backgroundNodePath = None

        if self.backgroundModel is not None:
            self.backgroundModel.removeNode()
            self.backgroundModel = None

    def start(self):
        base.transitions.fadeOut(t=0)

        self.setColorScale(Vec4(1, 1, 1, 1))

        if self.fadeTrack is not None:
            self.fadeTrack.finish()
            self.fadeTrack = None

        self.fadeTrack = base.transitions.getFadeInIval(t=2)
        self.fadeTrack.start()

        if self.logoScaleTrack is not None:
            self.logoScaleTrack.finish()
            self.logoScaleTrack = None

        self.logoScaleTrack = Sequence(
            LerpScaleInterval(self.logo, 2, Vec3(1.1, 1, 0.55), Vec3(1, 1, 0.5),
                              blendType='easeInOut'),
            LerpScaleInterval(self.logo, 2, Vec3(1, 1, 0.5), Vec3(1.1, 1, 0.55),
                              blendType='easeInOut')
        )

        if self.logoPosTrack is not None:
            self.logoPosTrack.finish()
            self.logoPosTrack = None

        self.logoPosTrack = Sequence(
            LerpPosInterval(self.logo, 2, Point3(0, 0, -0.85),
                            Point3(0, 0, -0.7), blendType='easeOut'),
            Func(self.logoScaleTrack.loop)
        )
        self.logoPosTrack.start()

        if self.labelColorScaleTrack is not None:
            self.labelColorScaleTrack.finish()
            self.labelColorScaleTrack = None

        self.labelColorScaleTrack = Sequence(
            LerpColorScaleInterval(self.label, 1, Vec4(1, 1, 1, 0.6),
                                   Vec4(1, 1, 1, 1)),
            LerpColorScaleInterval(self.label, 1, Vec4(1, 1, 1, 1),
                                   Vec4(1, 1, 1, 0.6))
        )

        if self.labelPosTrack is not None:
            self.labelPosTrack.finish()
            self.labelPosTrack = None

        self.labelPosTrack = Sequence(
            LerpPosInterval(self.label, 2, Point3(0, 0, 0.35),
                            Point3(0, 0, 0.15), blendType='easeOut'),
            Func(self.labelColorScaleTrack.loop)
        )
        self.labelPosTrack.start()

        self.acceptOnce('mouse1', self.begin)

    def stop(self):
        self.ignore('mouse1')

        if self.labelPosTrack is not None:
            self.labelPosTrack.finish()
            self.labelPosTrack = None

        if self.labelColorScaleTrack is not None:
            self.labelColorScaleTrack.finish()
            self.labelColorScaleTrack = None

        if self.logoPosTrack is not None:
            self.logoPosTrack.finish()
            self.logoPosTrack = None

        if self.logoScaleTrack is not None:
            self.logoScaleTrack.finish()
            self.logoScaleTrack = None

        if self.fadeTrack is not None:
            self.fadeTrack.finish()
            self.fadeTrack = None

        self.setColorScale(Vec4(0, 0, 0, 0))

    def begin(self):
        base.cr.introDone = True

        if self.fadeTrack is not None:
            self.fadeTrack.finish()
            self.fadeTrack = None

        self.fadeTrack = base.transitions.getFadeOutIval(t=2)

        Sequence(
            Func(self.fadeTrack.start),
            Wait(2),
            Func(self.delete),
            Func(base.cr.introduction.delete),
            Func(base.cr.loginFSM.request, 'chooseAvatar', [base.cr.avList]),
            Func(base.transitions.fadeIn, 2)
        ).start()

    def setColorScale(self, *args, **kwargs):
        self.backgroundNodePath.setColorScale(*args, **kwargs)
        self.logo.setColorScale(*args, **kwargs)
        self.label.setColorScale(*args, **kwargs)
        self.versionLabel.setColorScale(*args, **kwargs)
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
Example #44
0
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)
launcher.setPandaWindowOpen()

ConfigVariableDouble('decompressor-step-time').setValue(0.01)
ConfigVariableDouble('extractor-step-time').setValue(0.01)

# loading screen
backgroundNodePath = aspect2d.attachNewNode(backgroundNode, 0)
backgroundNodePath.setPos(0.0, 0.0, 0.0)
backgroundNodePath.setScale(render2d, VBase3(1))
backgroundNodePath.find('**/bg').setBin('fixed', 10)

# change the logo
backgroundNodePath.find('**/fg').stash()

from direct.gui.DirectGui import OnscreenImage
logo = OnscreenImage('phase_3/maps/toontown-logo-new.png')
logo.reparentTo(backgroundNodePath)
logo.setBin('fixed', 20)
logo.setTransparency(TransparencyAttrib.MAlpha)

base.graphicsEngine.renderFrame()

# default DGG stuff
DirectGuiGlobals.setDefaultRolloverSound(base.loadSfx('phase_3/audio/sfx/GUI_rollover.ogg'))
DirectGuiGlobals.setDefaultClickSound(base.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.ogg'))
DirectGuiGlobals.setDefaultDialogGeom(loader.loadModel('phase_3/models/gui/dialog_box_gui'))

# localizer
import TTLocalizer
from otp.otpbase import OTPGlobals
OTPGlobals.setDefaultProductPrefix(TTLocalizer.ProductPrefix)
Example #46
0
class FinalScoreGUI:
    notify = directNotify.newCategory('FinalScoreGUI')

    def __init__(self):
        self.finalScoreBg = None
        self.finalScoreTitle = None
        self.finalScoreNameLbl = None
        self.finalScorePointLbl = None
        self.finalScoreContainer = None
        self.finalScores = []
        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 unload(self):
        if self.finalScoreContainer:
            self.finalScoreContainer.destroy()
            self.finalScoreContainer = None
        if self.finalScoreBg:
            self.finalScoreBg.destroy()
            self.finalScoreBg = None
        if self.finalScoreTitle:
            self.finalScoreTitle.destroy()
            self.finalScoreTitle = None
        if self.finalScoreNameLbl:
            self.finalScoreNameLbl.destroy()
            self.finalScoreNameLbl = None
        if self.finalScorePointLbl:
            self.finalScorePointLbl.destroy()
            self.finalScorePointLbl = None
        return

    def showFinalScores(self):
        self.finalScoreContainer.show()
        base.transitions.fadeScreen(0.5)

    def hideFinalScores(self):
        base.transitions.noTransitions()
        self.finalScoreContainer.hide()

    def handleFinalScores(self, avIdList, scoreList):
        for avId in avIdList:
            score = scoreList[avIdList.index(avId)]
            scoreObj = FinalScore(avId, score)
            self.finalScores.append(scoreObj)

        self.finalScores.sort(key=lambda x: x.score, reverse=True)
        for scoreObj in self.finalScores:
            name = base.cr.doId2do.get(scoreObj.avId).getName()
            self.finalScoreNameLbl['text'] += name + '\n'
            self.finalScorePointLbl['text'] += str(scoreObj.score) + ' Points\n'

        self.finalScoreTitle['text'] = 'Final Scores'