Gag/SOS detail panel popup on battle gui

This commit is contained in:
John 2015-08-17 11:11:38 +03:00
parent 794d1298ee
commit 3f12bc6500
5 changed files with 81 additions and 23 deletions

View file

@ -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)

View file

@ -491,6 +491,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 = {}
for friendPair in NPCFriendsList:

View file

@ -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",

View file

@ -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()
@ -215,6 +219,14 @@ class TownBattle(StateData.StateData):
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))
for toonPanel in self.toonPanels:

View file

@ -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,17 +42,23 @@ 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:
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)
@ -61,7 +69,6 @@ class TownBattleToonPanel(DirectFrame):
self.setHealthText(avatar.hp, avatar.maxHp)
self.hpChangeEvent = self.avatar.uniqueName('hpChange')
self.accept(self.hpChangeEvent, self.setHealthText)
return None
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,7 +150,15 @@ 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):
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()
@ -145,6 +177,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 = ''
targetList = range(numTargets)
@ -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)