Poodletooth-iLand/toontown/cogdominium/CogdoMemoGui.py

42 lines
1.7 KiB
Python
Raw Normal View History

2015-03-03 16:10:12 -06:00
from direct.gui.DirectGui import DGG, DirectFrame, DirectLabel
from pandac.PandaModules import TextNode
from toontown.toonbase import ToontownGlobals
from toontown.toonbase import ToontownIntervals
from toontown.toonbase import TTLocalizer
import CogdoUtil
import CogdoGameConsts
MEMOICON_SCALE = 0.2
class CogdoMemoGui(DirectFrame):
2015-03-06 20:46:05 -06:00
def __init__(self, parent, type='joke_card'):
2015-03-03 16:10:12 -06:00
DirectFrame.__init__(self, parent=parent, relief=None, state=DGG.NORMAL, sortOrder=DGG.BACKGROUND_SORT_INDEX)
2015-03-06 20:46:05 -06:00
self._initModel(type)
2015-03-03 16:10:12 -06:00
self.hide()
return
def destroy(self):
ToontownIntervals.cleanup('memocount_pulse')
self._countLabel.removeNode()
del self._countLabel
self._memoIcon.removeNode()
del self._memoIcon
DirectFrame.destroy(self)
def posNextToLaffMeter(self):
2015-04-28 02:07:50 -05:00
self.reparentTo(base.a2dBottomLeft)
self.setPos(0.358, 0, 0.125)
2015-03-03 16:10:12 -06:00
2015-03-06 20:46:05 -06:00
def _initModel(self, type='joke_card'):
2015-03-03 16:10:12 -06:00
self._countLabel = DirectLabel(parent=self, relief=None, pos=(0.0625, 0, -0.025), scale=CogdoGameConsts.MemoGuiTextScale, text=str(0), text_fg=CogdoGameConsts.MemoGuiTextColor, text_shadow=(0.2, 0.2, 0.2, 1), text_align=TextNode.ALeft, text_font=ToontownGlobals.getToonFont())
2015-03-06 20:46:05 -06:00
self._memoIcon = CogdoUtil.loadModel(type, game='shared', group='gui')
2015-03-03 16:10:12 -06:00
self._memoIcon.reparentTo(self)
self._memoIcon.setScale(MEMOICON_SCALE)
return
def setCount(self, count):
self._countLabel['text'] = str(count)
self._countLabel.setText()
ToontownIntervals.cleanup('memocount_pulse')
ToontownIntervals.start(ToontownIntervals.getPulseLargerIval(self._memoIcon, 'memocount_pulse', scale=MEMOICON_SCALE))