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

View file

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

View file

@ -1,24 +1,22 @@
from direct.gui.DirectGui import * from direct.gui.DirectGui import *
from toontown.toonbase import TTLocalizer from toontown.toonbase import TTLocalizer, ToontownGlobals
from toontown.toontowngui import TTDialog from toontown.toontowngui import TTDialog
import ShtikerPage 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): class StatPage(ShtikerPage.ShtikerPage):
def __init__(self): def __init__(self):
ShtikerPage.ShtikerPage.__init__(self) ShtikerPage.ShtikerPage.__init__(self)
self.dialog = None self.dialog = None
self.chunkCount = 11
base.cr.lol = self
def load(self): def load(self):
guiButton = loader.loadModel('phase_3/models/gui/quit_button') guiButton = loader.loadModel('phase_3/models/gui/quit_button')
self.rows = [None] * 2 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, 0, 0.6)) self.title = DirectLabel(parent=self, relief=None, text=TTLocalizer.StatPageTitle, text_scale=0.12, textMayChange=0, pos=(-0.625, 0, 0.625))
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.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)
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)
guiButton.removeNode() guiButton.removeNode()
def enter(self): def enter(self):
@ -48,24 +46,25 @@ class StatPage(ShtikerPage.ShtikerPage):
self.dialog.destroy() self.dialog.destroy()
self.dialog = None 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): def cutToChunks(self, list, size):
for i in xrange(0, len(list), size): for i in xrange(0, len(list), size):
yield list[i:i+size] yield list[i:i+size]
def updateStats(self): def updateStats(self):
dict = {}
stats = base.localAvatar.stats stats = base.localAvatar.stats
allStats = [TTLocalizer.Stats[i] % stats[i] for i in xrange(len(stats))]
for i, string in enumerate(STATS): textChunks = list(self.cutToChunks(allStats, self.chunkCount))
dict[string] = "{:,}".format(stats[i])
textChunks = list(self.cutToChunks(TTLocalizer.Stats, 11))
for i, chunk in enumerate(textChunks): 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): 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() self.dialog.show()
def __handleDialogResponse(self, response): def __handleDialogResponse(self, response):
@ -75,5 +74,5 @@ class StatPage(ShtikerPage.ShtikerPage):
return return
base.localAvatar.wipeStats() 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() self.dialog.show()

View file

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