diff --git a/toontown/shtiker/SuitPage.py b/toontown/shtiker/SuitPage.py index 08deae1d..73e93e49 100755 --- a/toontown/shtiker/SuitPage.py +++ b/toontown/shtiker/SuitPage.py @@ -351,13 +351,12 @@ class SuitPage(ShtikerPage.ShtikerPage): panel.shadow = None panel.count = 0 panel.summonButton = None - panel.hoverButton = DirectButton(parent=panel, relief=None, image_scale=(0.15, 0, 0.225), image='phase_3/maps/invisible.png') + panel.hoverButton = DirectButton(parent=panel, relief=None, image_scale=(0.15, 0, 0.225), image='phase_3/maps/invisible.png', pressEffect=0) panel.hoverButton.setTransparency(True) panel.hoverButton.panel = panel self.addCogRadarLabel(panel) self.panels.append(panel) base.panels.append(panel) - return def showInfo(self, panel, text, extra): self.rolloverFrame.reparentTo(panel) diff --git a/toontown/toon/DistributedToon.py b/toontown/toon/DistributedToon.py index 3401332d..f1264188 100755 --- a/toontown/toon/DistributedToon.py +++ b/toontown/toon/DistributedToon.py @@ -490,6 +490,9 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute def getNPCFriendsDict(self): return self.NPCFriendsDict + + def getNPCFriendCount(self, npcId): + return self.NPCFriendsDict.get(npcId, 0) def setNPCFriendsDict(self, NPCFriendsList): NPCFriendsDict = {} diff --git a/toontown/toonbase/TTLocalizerEnglish.py b/toontown/toonbase/TTLocalizerEnglish.py index 2ed21536..a6563639 100755 --- a/toontown/toonbase/TTLocalizerEnglish.py +++ b/toontown/toonbase/TTLocalizerEnglish.py @@ -8730,6 +8730,10 @@ SuitPageAttackFormat = 'Levels: %s-%s\n\n\x01androidGreen\x01Group attacks:\x02\ SuitPageNoAttacks = 'None' BattleGagPopup = '%s: %s\nGags left: %s' +BattleSOSPopup = '\x01azure\x01%s\x02\n%s\n%s%s stars\nSOS left: %s' +BattleSOSPopupHeal = 'Heals' +BattleSOSPopupHarm = 'Deals' +BattleSOSPopupHP = '%s %s HP\n' Blacklist = [ "$1ut", diff --git a/toontown/town/TownBattle.py b/toontown/town/TownBattle.py index b44cdc32..7b949a3a 100755 --- a/toontown/town/TownBattle.py +++ b/toontown/town/TownBattle.py @@ -18,7 +18,7 @@ from toontown.toonbase import ToontownTimer from direct.showbase import PythonUtil from toontown.toonbase import TTLocalizer from toontown.pets import PetConstants -from direct.gui.DirectGui import DGG +from direct.gui.DirectGui import * from toontown.battle import FireCogPanel class TownBattle(StateData.StateData): @@ -122,7 +122,10 @@ class TownBattle(StateData.StateData): self.SOSPetInfoPanel = TownBattleSOSPetInfoPanel.TownBattleSOSPetInfoPanel(self.SOSPetInfoPanelDoneEvent) self.fireCogPanelDoneEvent = 'fire-cog-panel-done' self.FireCogPanel = FireCogPanel.FireCogPanel(self.fireCogPanelDoneEvent) - self.toonPanels = [TownBattleToonPanel.TownBattleToonPanel(i) for i in xrange(4)] + self.toonRolloverFrame = DirectFrame(aspect2d, relief=None, geom=DGG.getDefaultDialogGeom(), geom_color=(0.6, 1.0, 0.4, 1), geom_scale=(0.5, 0.3, 0.2), text_scale=0.05, text_pos=(0, 0.0125), text='', text_fg=(0, 0, 0, 1), pos=(0.4, 0, 0)) + self.toonRolloverFrame.setBin('gui-popup', 0) + self.toonRolloverFrame.hide() + self.toonPanels = [TownBattleToonPanel.TownBattleToonPanel(self) for i in xrange(4)] self.cogPanels = [TownBattleCogPanel.TownBattleCogPanel(i) for i in xrange(4)] self.timer = ToontownTimer.ToontownTimer() self.timer.posInTopRightCorner() @@ -143,6 +146,7 @@ class TownBattle(StateData.StateData): del self.FireCogPanel del self.SOSPetSearchPanel del self.SOSPetInfoPanel + del self.toonRolloverFrame for panel in self.toonPanels + self.cogPanels: panel.cleanup() @@ -214,6 +218,14 @@ class TownBattle(StateData.StateData): self.time = time self.timer.setTime(time) return None + + def scaleToonRolloverFrame(self, scale, textPos, z): + self.toonRolloverFrame['geom_scale'] = scale + self.toonRolloverFrame['text_pos'] = textPos + self.toonRolloverFrame.setZ(z) + + def hideToonRolloverFrame(self, extra=None): + self.toonRolloverFrame.hide() def __enterPanels(self, num, localNum): self.notify.debug('enterPanels() num: %d localNum: %d' % (num, localNum)) diff --git a/toontown/town/TownBattleToonPanel.py b/toontown/town/TownBattleToonPanel.py index 388ec7c6..aab508f1 100755 --- a/toontown/town/TownBattleToonPanel.py +++ b/toontown/town/TownBattleToonPanel.py @@ -3,7 +3,7 @@ from toontown.toonbase import ToontownGlobals from toontown.toonbase.ToontownBattleGlobals import * from direct.directnotify import DirectNotifyGlobal import string -from toontown.toon import LaffMeter +from toontown.toon import LaffMeter, NPCToons from toontown.battle import BattleBase from direct.gui.DirectGui import * from toontown.toonbase import TTLocalizer @@ -11,12 +11,14 @@ from toontown.toon.NPCFriendPanel import createNPCToonHead class TownBattleToonPanel(DirectFrame): notify = DirectNotifyGlobal.directNotify.newCategory('TownBattleToonPanel') + sosTracks = Tracks + NPCTracks - def __init__(self, id): + def __init__(self, battle): gui = loader.loadModel('phase_3.5/models/gui/battle_gui') DirectFrame.__init__(self, relief=None, image=gui.find('**/ToonBtl_Status_BG'), image_color=Vec4(0.5, 0.9, 0.5, 0.7)) self.setScale(0.8) self.initialiseoptions(TownBattleToonPanel) + self.battle = battle self.avatar = None self.sosText = DirectLabel(parent=self, relief=None, pos=(0.1, 0, 0.015), text=TTLocalizer.TownBattleToonSOS, text_scale=0.06) self.sosText.hide() @@ -40,28 +42,33 @@ class TownBattleToonPanel(DirectFrame): self.passNode.hide() self.laffMeter = None self.whichText = DirectLabel(parent=self, text='', pos=(0.1, 0, -0.08), text_scale=0.05) + self.hoverButton = DirectButton(parent=self, relief=None, image_scale=(0.07, 0, 0.06), pos=(0.105, 0, 0.05), image='phase_3/maps/invisible.png', pressEffect=0) + self.hoverButton.setTransparency(True) + self.hoverButton.bind(DGG.EXIT, self.battle.hideToonRolloverFrame) self.hide() gui.removeNode() def setLaffMeter(self, avatar): self.notify.debug('setLaffMeter: new avatar %s' % avatar.doId) + if self.avatar == avatar: messenger.send(self.avatar.uniqueName('hpChange'), [avatar.hp, avatar.maxHp, 1]) - return None - else: - if self.avatar or self.laffMeter: - self.cleanupLaffMeter() - self.avatar = avatar - self.laffMeter = LaffMeter.LaffMeter(avatar.style, avatar.hp, avatar.maxHp) - self.laffMeter.setAvatar(self.avatar) - self.laffMeter.reparentTo(self) - self.laffMeter.setPos(-0.06, 0, 0.05) - self.laffMeter.setScale(0.045) - self.laffMeter.start() - self.setHealthText(avatar.hp, avatar.maxHp) - self.hpChangeEvent = self.avatar.uniqueName('hpChange') - self.accept(self.hpChangeEvent, self.setHealthText) - return None + return + + if self.avatar or self.laffMeter: + self.cleanupLaffMeter() + self.cleanupSosHead() + + self.avatar = avatar + self.laffMeter = LaffMeter.LaffMeter(avatar.style, avatar.hp, avatar.maxHp) + self.laffMeter.setAvatar(self.avatar) + self.laffMeter.reparentTo(self) + self.laffMeter.setPos(-0.06, 0, 0.05) + self.laffMeter.setScale(0.045) + self.laffMeter.start() + self.setHealthText(avatar.hp, avatar.maxHp) + self.hpChangeEvent = self.avatar.uniqueName('hpChange') + self.accept(self.hpChangeEvent, self.setHealthText) def setHealthText(self, hp, maxHp, quietly = 0): self.healthText['text'] = TTLocalizer.TownBattleHealthText % {'hitPoints': hp, @@ -97,6 +104,7 @@ class TownBattleToonPanel(DirectFrame): self.whichText.hide() self.passNode.hide() self.cleanupSosHead() + self.hoverButton.unbind(DGG.ENTER) self.whichText.setPos(0.1, 0, -0.08) self.whichText['text_scale'] = 0.05 if self.hasGag: @@ -115,6 +123,22 @@ class TownBattleToonPanel(DirectFrame): self.sosHead.reparentTo(self) self.sosHead.setPos(0.1, 0, 0.045) self.sosHead.setScale(0.24) + track, level, hp, rarity = NPCToons.getNPCTrackLevelHpRarity(targetIndex) + sosType = self.sosTracks[track] + + if track == NPC_RESTOCK_GAGS: + if level == -1: + sosType += ' All' + else: + sosType += ' ' + self.sosTracks[level] + + if hp: + hpString = TTLocalizer.BattleSOSPopupHP % (TTLocalizer.BattleSOSPopupHeal if track == HEAL_TRACK else TTLocalizer.BattleSOSPopupHarm, hp) + + sosType = TextEncoder.upper(sosType) + count = max(0, self.avatar.getNPCFriendCount(targetIndex) - 1) + info = TTLocalizer.BattleSOSPopup % (sosType, NPCToons.getNPCName(targetIndex), hpString if hp else '', rarity, count) + self.hoverButton.bind(DGG.ENTER, self.showInfo, extraArgs=[(0.5, 0.3, 0.3), (0, 0.08), 0.1, info]) elif track == BattleBase.SOS or track == BattleBase.PETSOS: self.sosText.show() elif track >= MIN_TRACK_INDEX and track <= MAX_TRACK_INDEX: @@ -126,8 +150,16 @@ class TownBattleToonPanel(DirectFrame): self.gag.setScale(0.8) self.gag.setPos(0, 0, 0.02) self.hasGag = 1 - if self.avatar is not None and self.avatar.checkGagBonus(track, level): - self.gag.setColor((1, 0, 0, 1) if track == 1 and level == 5 else (0, 1, 0, 1)) + if self.avatar: + curExp, nextExp = self.avatar.inventory.getCurAndNextExpValues(track) + organic = self.avatar.checkGagBonus(track, level) + damage = int(getAvPropDamage(track, level, curExp, organic)) + numItems = max(0, self.avatar.inventory.numItem(track, level) - 1) + info = TTLocalizer.BattleGagPopup % (self.avatar.inventory.getToonupDmgStr(track, 0), damage, numItems) + self.hoverButton.bind(DGG.ENTER, self.showInfo, extraArgs=[(0.5, 0.3, 0.2), (0, 0.0125), 0, info]) + + if self.avatar.checkGagBonus(track, level): + self.gag.setColor((1, 0, 0, 1) if track == 1 and level == 5 else (0, 1, 0, 1)) if numTargets is not None and targetIndex is not None and localNum is not None: self.whichText.show() self.whichText['text'] = self.determineWhichText(numTargets, targetIndex, localNum, index) @@ -144,6 +176,12 @@ class TownBattleToonPanel(DirectFrame): else: self.notify.error('Bad track value: %s' % track) + + def showInfo(self, scale, textPos, z, text, extra): + self.battle.scaleToonRolloverFrame(scale, textPos, z) + self.battle.toonRolloverFrame.reparentTo(self) + self.battle.toonRolloverFrame.show() + self.battle.toonRolloverFrame['text'] = text def determineWhichText(self, numTargets, targetIndex, localNum, index): returnStr = '' @@ -175,6 +213,8 @@ class TownBattleToonPanel(DirectFrame): del self.gag self.gagNode.removeNode() del self.gagNode + self.hoverButton.removeNode() + del self.hoverButton self.cleanupSosHead() DirectFrame.destroy(self)