Add proper count for wardrobe and done it for trunk too

This commit is contained in:
John 2015-08-28 22:39:10 +03:00
parent c9e0f0deac
commit 06d4c8320a
3 changed files with 36 additions and 27 deletions

View file

@ -11,7 +11,7 @@ from toontown.toonbase import TTLocalizer
class ClosetGUI(ClothesGUI.ClothesGUI):
notify = directNotify.newCategory('ClosetGUI')
def __init__(self, isOwner, doneEvent, cancelEvent, swapEvent, deleteEvent, topList = None, botList = None):
def __init__(self, isOwner, doneEvent, cancelEvent, swapEvent, deleteEvent, topList = None, botList = None, maxClothes = 0):
ClothesGUI.ClothesGUI.__init__(self, ClothesGUI.CLOTHES_CLOSET, doneEvent, swapEvent)
self.toon = None
self.topsList = topList
@ -20,8 +20,8 @@ class ClosetGUI(ClothesGUI.ClothesGUI):
self.deleteEvent = deleteEvent
self.cancelEvent = cancelEvent
self.genderChange = 0
self.maxClothes = maxClothes
self.verify = None
return
def load(self):
ClothesGUI.ClothesGUI.load(self)
@ -110,6 +110,7 @@ class ClosetGUI(ClothesGUI.ClothesGUI):
if self.isOwner:
self.updateTrashButtons()
self.setupButtons()
self.updateCount()
def updateCount(self, clothes, maxClothes):
self.countFrame['text'] = TTLocalizer.ClothesGUICount % (clothes, maxClothes)
@ -128,6 +129,11 @@ class ClosetGUI(ClothesGUI.ClothesGUI):
self.bottomTrashButton['text'] = TTLocalizer.ClosetDeleteSkirt
else:
self.bottomTrashButton['text'] = TTLocalizer.ClosetDeleteShorts
self.updateCount()
def updateCount(self):
clothes = (len(self.tops) + len(self.bottoms)) - 2
self.countFrame['text'] = TTLocalizer.ClothesGUICount % (clothes, self.maxClothes)
def setGender(self, gender):
self.ownerGender = gender

View file

@ -236,9 +236,9 @@ class DistributedCloset(DistributedFurnitureItem.DistributedFurnitureItem):
if self.isOwner:
self.accept(self.deleteEvent, self.__handleDelete)
if not self.closetGUI:
self.closetGUI = ClosetGUI.ClosetGUI(self.isOwner, self.purchaseDoneEvent, self.cancelEvent, self.swapEvent, self.deleteEvent, self.topList, self.botList)
maxClothes = CatalogFurnitureItem.ClosetToClothes.get(self.item.furnitureType)
self.closetGUI = ClosetGUI.ClosetGUI(self.isOwner, self.purchaseDoneEvent, self.cancelEvent, self.swapEvent, self.deleteEvent, self.topList, self.botList, maxClothes)
self.closetGUI.load()
self.updateCount()
if self.gender != self.ownerGender:
self.closetGUI.setGender(self.ownerGender)
self.closetGUI.enter(base.localAvatar)
@ -319,7 +319,6 @@ class DistributedCloset(DistributedFurnitureItem.DistributedFurnitureItem):
self.sendUpdate('removeItem', [trashItem, t_or_b])
swapFunc(0)
self.closetGUI.updateTrashButtons()
self.updateCount()
else:
self.notify.warning("cant delete this item(type = %s), since we don't have a replacement" % t_or_b)
@ -355,11 +354,6 @@ class DistributedCloset(DistributedFurnitureItem.DistributedFurnitureItem):
self.av.swapToonTorso(self.av.style.torso, genClothes=0)
self.av.loop('neutral', 0)
self.av.generateToonClothes()
def updateCount(self):
maxClothes = CatalogFurnitureItem.ClosetToClothes.get(self.item.furnitureType)
clothes = int(len(self.topList) / 4) + int(len(self.botList) / 2)
self.closetGUI.updateCount(clothes, maxClothes)
def printInfo(self):
print 'avid: %s, gender: %s' % (self.av.doId, self.av.style.gender)

View file

@ -31,25 +31,24 @@ class TrunkGUI(StateData.StateData):
self.cancelEvent = cancelEvent
self.genderChange = 0
self.verify = None
return
def load(self):
self.gui = loader.loadModel('phase_3/models/gui/tt_m_gui_mat_mainGui')
guiRArrowUp = self.gui.find('**/tt_t_gui_mat_arrowUp')
guiRArrowRollover = self.gui.find('**/tt_t_gui_mat_arrowUp')
guiRArrowDown = self.gui.find('**/tt_t_gui_mat_arrowDown')
guiRArrowDisabled = self.gui.find('**/tt_t_gui_mat_arrowDisabled')
guiArrowRotateUp = self.gui.find('**/tt_t_gui_mat_arrowRotateUp')
guiArrowRotateDown = self.gui.find('**/tt_t_gui_mat_arrowRotateDown')
shuffleFrame = self.gui.find('**/tt_t_gui_mat_shuffleFrame')
shuffleArrowUp = self.gui.find('**/tt_t_gui_mat_shuffleArrowUp')
shuffleArrowDown = self.gui.find('**/tt_t_gui_mat_shuffleArrowDown')
shuffleArrowRollover = self.gui.find('**/tt_t_gui_mat_shuffleArrowUp')
shuffleArrowDisabled = self.gui.find('**/tt_t_gui_mat_shuffleArrowDisabled')
self.parentFrame = DirectFrame(relief=DGG.RAISED, pos=(0.98, 0, 0.416), frameColor=(1, 0, 0, 0))
self.matGui = loader.loadModel('phase_3/models/gui/tt_m_gui_mat_mainGui')
guiRArrowUp = self.matGui.find('**/tt_t_gui_mat_arrowUp')
guiRArrowRollover = self.matGui.find('**/tt_t_gui_mat_arrowUp')
guiRArrowDown = self.matGui.find('**/tt_t_gui_mat_arrowDown')
guiRArrowDisabled = self.matGui.find('**/tt_t_gui_mat_arrowDisabled')
guiArrowRotateUp = self.matGui.find('**/tt_t_gui_mat_arrowRotateUp')
guiArrowRotateDown = self.matGui.find('**/tt_t_gui_mat_arrowRotateDown')
self.shuffleFrame = self.matGui.find('**/tt_t_gui_mat_shuffleFrame')
shuffleArrowUp = self.matGui.find('**/tt_t_gui_mat_shuffleArrowUp')
shuffleArrowDown = self.matGui.find('**/tt_t_gui_mat_shuffleArrowDown')
shuffleArrowRollover = self.matGui.find('**/tt_t_gui_mat_shuffleArrowUp')
shuffleArrowDisabled = self.matGui.find('**/tt_t_gui_mat_shuffleArrowDisabled')
self.parentFrame = DirectFrame(relief=DGG.RAISED, pos=(0.98, 0, 0.216), frameColor=(1, 0, 0, 0))
def addFrame(posZ, text):
return DirectFrame(parent=self.parentFrame, image=shuffleFrame, image_scale=halfButtonInvertScale, relief=None, pos=(0, 0, posZ), hpr=(0, 0, 3), scale=1.2, frameColor=(1, 1, 1, 1), text=text, text_scale=0.0575, text_pos=(-0.001, -0.015), text_fg=(1, 1, 1, 1))
return DirectFrame(parent=self.parentFrame, image=self.shuffleFrame, image_scale=halfButtonInvertScale, relief=None, pos=(0, 0, posZ), hpr=(0, 0, 3), scale=1.2, frameColor=(1, 1, 1, 1), text=text, text_scale=0.0575, text_pos=(-0.001, -0.015), text_fg=(1, 1, 1, 1))
def addButton(parent, scale, hoverScale, posX, command, extraArg):
return DirectButton(parent=parent, relief=None, image=(shuffleArrowUp,
@ -57,6 +56,7 @@ class TrunkGUI(StateData.StateData):
shuffleArrowRollover,
shuffleArrowDisabled), image_scale=scale, image1_scale=hoverScale, image2_scale=hoverScale, pos=(posX, 0, 0), command=command, extraArgs=[extraArg])
self.countFrame = addFrame(0.37, TTLocalizer.ClothesGUICount % (0, 0))
self.hatFrame = addFrame(0.1, TTLocalizer.TrunkHatGUI)
self.hatLButton = addButton(self.hatFrame, halfButtonScale, halfButtonHoverScale, -0.2, self.swapHat, -1)
self.hatRButton = addButton(self.hatFrame, halfButtonInvertScale, halfButtonInvertHoverScale, 0.2, self.swapHat, 1)
@ -103,7 +103,6 @@ class TrunkGUI(StateData.StateData):
self.shoesTrashButton = addTrashButton(-0.4, TTLocalizer.TrunkDeleteShoes, ToonDNA.SHOES)
self.button = DirectButton(relief=None, image=(self.gui.find('**/CrtAtoon_Btn1_UP'), self.gui.find('**/CrtAtoon_Btn1_DOWN'), self.gui.find('**/CrtAtoon_Btn1_RLLVR')), pos=(-0.15, 0, -0.85), command=self.__handleButton, text=('', TTLocalizer.MakeAToonDone, TTLocalizer.MakeAToonDone), text_font=ToontownGlobals.getInterfaceFont(), text_scale=0.08, text_pos=(0, -0.03), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1))
trashcanGui.removeNode()
return
def unload(self):
taskMgr.remove(self.taskName('rotateL'))
@ -111,7 +110,11 @@ class TrunkGUI(StateData.StateData):
self.ignore('verifyDone')
self.gui.removeNode()
del self.gui
self.matGui.removeNode()
del self.matGui
del self.shuffleFrame
self.parentFrame.destroy()
self.countFrame.destroy()
self.hatFrame.destroy()
self.glassesFrame.destroy()
self.backpackFrame.destroy()
@ -124,6 +127,7 @@ class TrunkGUI(StateData.StateData):
self.backpackRButton.destroy()
self.shoesLButton.destroy()
self.shoesRButton.destroy()
del self.countFrame
del self.parentFrame
del self.hatFrame
del self.glassesFrame
@ -286,7 +290,7 @@ class TrunkGUI(StateData.StateData):
self.swapShoes(0)
self.updateTrashButtons()
self.setupButtons()
return
self.updateCountFrame()
def updateTrashButtons(self):
if not self.isOwner:
@ -307,6 +311,11 @@ class TrunkGUI(StateData.StateData):
self.shoesTrashButton['state'] = DGG.DISABLED
else:
self.shoesTrashButton['state'] = DGG.NORMAL
self.updateCountFrame()
def updateCountFrame(self):
accessories = (len(self.hats) + len(self.glasses) + len(self.backpacks) + len(self.shoes)) - 4
self.countFrame['text'] = TTLocalizer.ClothesGUICount % (accessories, ToontownGlobals.MaxAccessories)
def rotateToonL(self, task):
self.toon.setH(self.toon.getH() - 4)