Stats page update!

This commit is contained in:
John 2015-08-27 20:34:48 +03:00
parent 1f9dddf534
commit b2688c9107
4 changed files with 58 additions and 58 deletions

View file

@ -76,8 +76,8 @@ InterfaceFont = None
InterfaceFontPath = None
SignFont = None
SignFontPath = None
FancyFont = None
FancyFontPath = None
ChalkFont = None
ChalkFontPath = None
NametagFonts = {}
NametagFontPaths = {}
DialogClass = None
@ -115,20 +115,20 @@ def setSignFont(path):
global SignFontPath
SignFontPath = path
def getFancyFont():
global FancyFontPath
global FancyFont
if FancyFont == None:
if FancyFontPath == None:
def getChalkFont():
global ChalkFontPath
global ChalkFont
if ChalkFont == None:
if ChalkFontPath == None:
InterfaceFont = TextNode.getDefaultFont()
FancyFont = TextNode.getDefaultFont()
ChalkFont = TextNode.getDefaultFont()
else:
FancyFont = loader.loadFont(FancyFontPath, lineHeight=1.0)
return FancyFont
ChalkFont = loader.loadFont(ChalkFontPath, lineHeight=1.0)
return ChalkFont
def setFancyFont(path):
global FancyFontPath
FancyFontPath = path
def setChalkFont(path):
global ChalkFontPath
ChalkFontPath = path
def getNametagFont(index):
global NametagFontPaths

View file

@ -63,7 +63,7 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository):
self._playerAvDclass = self.dclassesByName['DistributedToon']
setInterfaceFont(TTLocalizer.InterfaceFont)
setSignFont(TTLocalizer.SignFont)
setFancyFont(TTLocalizer.FancyFont)
setChalkFont(TTLocalizer.ChalkFont)
for i in xrange(len(TTLocalizer.NametagFonts)):
setNametagFont(i, TTLocalizer.NametagFonts[i])

View file

@ -1,24 +1,22 @@
from direct.gui.DirectGui import *
from toontown.toonbase import TTLocalizer
from toontown.toonbase import TTLocalizer, ToontownGlobals
from toontown.toontowngui import TTDialog
import ShtikerPage
STATS = ['cog', 'v2', 'skele', 'beanSpent', 'beanEarnt', 'task', 'vp', 'cfo', 'cj', 'ceo', 'sad', 'bldg', 'cogdo', 'item', 'fish', 'flower', 'race', 'golf', 'sos', 'unite', 'slip', 'gag']
class StatPage(ShtikerPage.ShtikerPage):
def __init__(self):
ShtikerPage.ShtikerPage.__init__(self)
self.dialog = None
self.chunkCount = 11
base.cr.lol = self
def load(self):
guiButton = loader.loadModel('phase_3/models/gui/quit_button')
self.rows = [None] * 2
self.title = DirectLabel(parent=self, relief=None, text=TTLocalizer.StatPageTitle, text_scale=0.12, textMayChange=0, pos=(0, 0, 0.6))
self.rows[0] = DirectLabel(parent=self, relief=None, text_align=TextNode.ALeft, text='', text_scale=0.06, text_wordwrap=16, pos=(-0.8, 0, 0.515))
self.rows[1] = DirectLabel(parent=self, relief=None, text_align=TextNode.ALeft, text='', text_scale=0.06, text_wordwrap=16, pos=(0.05, 0, 0.515))
self.resetButton = empty = DirectButton(parent=self, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale=(1.1, 1, 1), text='Reset stats', text_scale=0.055, text_pos=(0, -0.02), pos=(-0.55, 0.0, 0.65), command=self.__showDialog)
self.rows = [self.createRow(pos) for pos in ((-0.8, 0, 0.435), (0.08, 0, 0.435))]
self.title = DirectLabel(parent=self, relief=None, text=TTLocalizer.StatPageTitle, text_scale=0.12, textMayChange=0, pos=(-0.625, 0, 0.625))
self.resetButton = DirectButton(parent=self, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale=(1.1, 1, 1), text=TTLocalizer.StatPageClear, text_scale=0.055, text_pos=(0, -0.02), pos=(0.605, 0, 0.66), command=self.__showDialog)
guiButton.removeNode()
def enter(self):
@ -47,25 +45,26 @@ class StatPage(ShtikerPage.ShtikerPage):
if self.dialog:
self.dialog.destroy()
self.dialog = None
def createRow(self, pos):
row = DirectLabel(parent=self, relief=None, text_align=TextNode.ALeft, text='', text_scale=0.045, text_wordwrap=16, text_font=ToontownGlobals.getChalkFont(), text_fg=(1, 1, 1, 1), image='phase_3/maps/stat_board.png', image_scale=(0.42, 0, 0.6), image_pos=(0.35, 0, -0.45))
row.setPos(pos)
return row
def cutToChunks(self, list, size):
for i in xrange(0, len(list), size):
yield list[i:i+size]
def updateStats(self):
dict = {}
stats = base.localAvatar.stats
for i, string in enumerate(STATS):
dict[string] = "{:,}".format(stats[i])
textChunks = list(self.cutToChunks(TTLocalizer.Stats, 11))
allStats = [TTLocalizer.Stats[i] % stats[i] for i in xrange(len(stats))]
textChunks = list(self.cutToChunks(allStats, self.chunkCount))
for i, chunk in enumerate(textChunks):
self.rows[i]['text'] = '\n\n'.join(chunk) % dict
self.rows[i]['text'] = '\n\n'.join(chunk)
def __showDialog(self):
self.dialog = TTDialog.TTDialog(style=TTDialog.TwoChoice, text=TTLocalizer.StatResetAsk, text_wordwrap=15, command=self.__handleDialogResponse)
self.dialog = TTDialog.TTDialog(style=TTDialog.TwoChoice, text=TTLocalizer.StatPageClearAsk, text_wordwrap=15, command=self.__handleDialogResponse)
self.dialog.show()
def __handleDialogResponse(self, response):
@ -75,5 +74,5 @@ class StatPage(ShtikerPage.ShtikerPage):
return
base.localAvatar.wipeStats()
self.dialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=TTLocalizer.StatResetDone, text_wordwrap=15, command=self.unloadDialog)
self.dialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=TTLocalizer.StatPageClearDone, text_wordwrap=15, command=self.unloadDialog)
self.dialog.show()

View file

@ -12,7 +12,7 @@ ToonFont = 'phase_3/models/fonts/ImpressBT.ttf'
SuitFont = 'phase_3/models/fonts/vtRemingtonPortable.ttf'
SignFont = 'phase_3/models/fonts/MickeyFont'
MinnieFont = 'phase_3/models/fonts/MinnieFont'
FancyFont = 'phase_3/models/fonts/Comedy'
ChalkFont = 'phase_3/models/fonts/Chawp.ttf'
BuildingNametagFont = 'phase_3/models/fonts/MickeyFont'
BuildingNametagShadow = None
NametagFonts = (
@ -3978,7 +3978,6 @@ EmoteHappy = 'Happy'
EmoteSad = 'Sad'
EmoteAnnoyed = 'Annoyed'
EmoteSleep = 'Sleepy'
StatPageTitle = 'Statistics'
SuitBaseNameWithLevel = '%(name)s\n%(dept)s\nLevel %(level)s'
HealthForceAcknowledgeMessage = 'You cannot leave the playground until your Laff meter is smiling!'
InventoryTotalGags = 'Total gags\n%d / %d'
@ -8656,31 +8655,33 @@ CrateClothingPrize = "Congratulations! You've received a new clothing item. Chec
CrateAccessoryPrize = 'Congratulations! You found a new accessory for your Toon. Check your mailbox and rock it!'
Stats = [
'Cogs defeated: %(cog)s',
'V2.0 cogs defeated: %(v2)s',
'Skelecogs defeated: %(skele)s',
'Jellybeans spent: %(beanSpent)s',
'Jellybeans earnt: %(beanEarnt)s',
'Tasks completed: %(task)s',
'Total VP defeats: %(vp)s',
'Total CFO defeats: %(cfo)s',
'Total CJ defeats: %(cj)s',
'Total CEO defeats: %(ceo)s',
'Gone sad: %(sad)s times',
'Buildings liberated: %(bldg)s',
'Field Offices defeated: %(cogdo)s',
'Items purchased: %(item)s',
'Fish caught: %(fish)s',
'Flowers picked: %(flower)s',
'Races completed: %(race)s',
'Golf holes played: %(golf)s',
'Total SOS cards: %(sos)s',
'Total unites: %(unite)s',
'Total pink slips: %(slip)s',
'Total gags used: %(gag)s'
'Cogs defeated: %s',
'V2.0 cogs defeated: %s',
'Skelecogs defeated: %s',
'Jellybeans spent: %s',
'Jellybeans earnt: %s',
'Tasks completed: %s',
'Total VP defeats: %s',
'Total CFO defeats: %s',
'Total CJ defeats: %s',
'Total CEO defeats: %s',
'Gone sad: %s times',
'Buildings liberated: %s',
'Offices defeated: %s',
'Items ordered: %s',
'Fish caught: %s',
'Flowers picked: %s',
'Races completed: %s',
'Golf holes played: %s',
'Total SOS cards: %s',
'Total unites: %s',
'Total pink slips: %s',
'Total gags used: %s'
]
StatResetAsk = 'Are you sure you want to reset your stats? This is an irreversible action!'
StatResetDone = 'Your stats have been reset.'
StatPageTitle = 'Statistics'
StatPageClear = 'Clear'
StatPageClearAsk = 'Are you sure you want to clear your stats? This is an irreversible action!'
StatPageClearDone = 'Your stats have been cleared.'
ChairAskToUse = 'Would you like to sit on this chair?'