Added GUI for glove NPC :D

This commit is contained in:
Daniel 2015-03-08 15:01:05 +02:00
parent 44fe794599
commit 2afe7135e6
3 changed files with 99 additions and 9 deletions

View file

@ -2,7 +2,6 @@
title TTU Game Launcher title TTU Game Launcher
set /P PPYTHON_PATH=<PPYTHON_PATH set /P PPYTHON_PATH=<PPYTHON_PATH
rem Get the user input:
echo Choose your game server! echo Choose your game server!
echo #1 - Localhost echo #1 - Localhost
echo #2 - DenialMC echo #2 - DenialMC

View file

@ -8,7 +8,8 @@ from DistributedNPCToonBase import *
from toontown.chat.ChatGlobals import * from toontown.chat.ChatGlobals import *
from toontown.effects import DustCloud from toontown.effects import DustCloud
from toontown.nametag.NametagGlobals import * from toontown.nametag.NametagGlobals import *
from toontown.toonbase import TTLocalizer from toontown.toonbase import TTLocalizer, ToontownGlobals
from toontown.toon.ToonDNA import allColorsList
def getDustCloud(toon): def getDustCloud(toon):
dustCloud = DustCloud.DustCloud(fBillboard=0) dustCloud = DustCloud.DustCloud(fBillboard=0)
@ -32,11 +33,80 @@ class DistributedNPCGlove(DistributedNPCToonBase):
], 'off', 'off') ], 'off', 'off')
self.fsm.enterInitialState() self.fsm.enterInitialState()
self.title = None
self.notice = None
self.color = None
self.buyButton = None
self.cancelButton = None
self.leftButton = None
self.rightButton = None
self.index = 0
self.gui = loader.loadModel('phase_3/models/gui/tt_m_gui_mat_mainGui')
self.shuffleArrowUp = self.gui.find('**/tt_t_gui_mat_shuffleArrowUp')
self.shuffleArrowDown = self.gui.find('**/tt_t_gui_mat_shuffleArrowDown')
self.shuffleUp = self.gui.find('**/tt_t_gui_mat_shuffleUp')
self.shuffleDown = self.gui.find('**/tt_t_gui_mat_shuffleDown')
def disable(self): def disable(self):
self.ignoreAll() self.ignoreAll()
self.destroyGui()
self.nextCollision = 0 self.nextCollision = 0
DistributedNPCToonBase.disable(self) DistributedNPCToonBase.disable(self)
def destroyGui(self):
for element in [self.title, self.notice, self.color, self.buyButton, self.cancelButton, self.leftButton, self.rightButton]:
if element:
element.destroy()
element = None
self.index = 0
def createGui(self):
self.title = DirectLabel(aspect2d, relief=None, text=TTLocalizer.GloveGuiTitle,
text_fg=(0, 1, 0, 1), text_scale=0.21, text_font=ToontownGlobals.getSignFont(),
pos=(0, 0, -0.30), text_shadow=(1, 1, 1, 1))
self.notice = DirectLabel(aspect2d, relief=None, text=TTLocalizer.GloveGuiNotice % ToontownGlobals.GloveCost,
text_fg=(1, 0, 0, 1), text_scale=0.11, text_font=ToontownGlobals.getSignFont(),
pos=(0, 0, -0.45), text_shadow=(1, 1, 1, 1))
self.color = DirectLabel(aspect2d, relief=None, text='',
text_scale=0.11, text_font=ToontownGlobals.getSignFont(),
pos=(0, 0, -0.70), text_shadow=(1, 1, 1, 1))
self.buyButton = DirectButton(aspect2d, relief=None, image=(self.shuffleUp, self.shuffleDown),
text=TTLocalizer.GloveGuiBuy, text_font=ToontownGlobals.getInterfaceFont(),
text_scale=0.11, text_pos=(0, -0.02), pos=(-0.60, 0, -0.90), text_fg=(1, 1, 1, 1),
text_shadow=(0, 0, 0, 1), command=self.handleBuy)
self.cancelButton = DirectButton(aspect2d, relief=None, image=(self.shuffleUp, self.shuffleDown),
text=TTLocalizer.GloveGuiCancel, text_font=ToontownGlobals.getInterfaceFont(),
text_scale=0.11, text_pos=(0, -0.02), pos=(0.60, 0, -0.90), text_fg=(1, 1, 1, 1),
text_shadow=(0, 0, 0, 1), command=self.leave)
self.leftButton = DirectButton(aspect2d, relief=None, image=(self.shuffleArrowUp, self.shuffleArrowDown),
pos=(-0.60, 0, -0.66), command=self.handleSetIndex, extraArgs=[-1])
self.rightButton = DirectButton(aspect2d, relief=None, image=(self.shuffleArrowUp, self.shuffleArrowDown),
pos=(0.60, 0, -0.66), scale=-1, command=self.handleSetIndex, extraArgs=[1])
self.updateGuiByIndex()
def handleSetIndex(self, offset):
newIndex = self.index + offset
if newIndex > -1 and newIndex < len(TTLocalizer.NumToColor):
self.index = newIndex
self.updateGuiByIndex()
def updateGuiByIndex(self):
self.color['text'] = TTLocalizer.NumToColor[self.index]
self.color['text_fg'] = allColorsList[self.index]
def handleBuy(self):
self.d_requestTransformation(self.index)
def initToonState(self): def initToonState(self):
self.setAnimState('neutral', 1.05, None, None) self.setAnimState('neutral', 1.05, None, None)
self.setPosHpr(101, -14, 4, -305, 0, 0) self.setPosHpr(101, -14, 4, -305, 0, 0)
@ -46,8 +116,10 @@ class DistributedNPCGlove(DistributedNPCToonBase):
def handleCollisionSphereEnter(self, collEntry): def handleCollisionSphereEnter(self, collEntry):
self.currentTime = time.time() self.currentTime = time.time()
if self.nextCollision <= self.currentTime: if self.nextCollision <= self.currentTime:
self.fsm.request('pickColor') self.fsm.request('pickColor')
self.nextCollision = self.currentTime + 2 self.nextCollision = self.currentTime + 2
def enterOff(self): def enterOff(self):
@ -58,20 +130,28 @@ class DistributedNPCGlove(DistributedNPCToonBase):
def enterPickColor(self): def enterPickColor(self):
base.cr.playGame.getPlace().setState('stopped') base.cr.playGame.getPlace().setState('stopped')
taskMgr.doMethodLater(15, self.reset, 'npcSleepTask-%s' % self.doId) taskMgr.doMethodLater(45, self.exitPickColor, 'npcSleepTask-%s' % self.doId)
self.setChatAbsolute('', CFSpeech)
if base.localAvatar.getMoney() < ToontownGlobals.GloveCost:
self.setChatAbsolute(self.getMessageById(2), CFSpeech|CFTimeout)
self.reset()
else:
self.popupPickColorGUI() self.popupPickColorGUI()
def exitPickColor(self, task=None): def exitPickColor(self, task=None):
taskMgr.remove('npcSleepTask-%s' % self.doId) taskMgr.remove('npcSleepTask-%s' % self.doId)
self.destroyGui()
taskMgr.doMethodLater(0.5, self.reset, 'avatarRecover-%s-%s' % (self.doId, base.localAvatar.doId))
if task is not None: if task is not None:
return task.done return task.done
def popupPickColorGUI(self): def popupPickColorGUI(self):
self.setChatAbsolute('', CFSpeech) self.setChatAbsolute('', CFSpeech)
self.setChatAbsolute("Hi fucker", CFSpeech) self.setChatAbsolute(TTLocalizer.GlovePickColorMessage, CFSpeech)
base.setCellsActive(base.bottomCells, 0) base.setCellsActive(base.bottomCells, 0)
self.d_requestTransformation(8) self.createGui()
def getMessageById(self, response): def getMessageById(self, response):
if response == 1: if response == 1:
@ -97,6 +177,11 @@ class DistributedNPCGlove(DistributedNPCToonBase):
self.sendUpdate('requestTransformation', [color]) self.sendUpdate('requestTransformation', [color])
self.reset() self.reset()
def leave(self):
self.setChatAbsolute('', CFSpeech)
self.setChatAbsolute(TTLocalizer.GloveByeMessage, CFSpeech|CFTimeout)
self.reset()
def reset(self, task=None): def reset(self, task=None):
self.fsm.request('off') self.fsm.request('off')
base.cr.playGame.getPlace().setState('walk') base.cr.playGame.getPlace().setState('walk')

View file

@ -9786,9 +9786,15 @@ InteractivePropTrackBonusTerms = {0: 'Super Toon-Up!',
5: 'Super Squirt!', 5: 'Super Squirt!',
6: ''} 6: ''}
PlayingCardUnknown = 'Card Name is unknown' PlayingCardUnknown = 'Card Name is unknown'
GloveSameColorMessage = 'You already have that glove!' GloveSameColorMessage = 'You already have those gloves!'
GloveNoMoneyMessage = "You don't have enough jellybeans!" GloveNoMoneyMessage = "You don't have enough jellybeans!"
GloveSuccessMessage = 'Have fun with your new glove!' GloveSuccessMessage = 'Have fun with your new gloves!'
GloveByeMessage = 'See you later!'
GlovePickColorMessage = 'Feel free to choose!'
GloveGuiTitle = 'Choose a glove color!'
GloveGuiNotice = 'Costs %s jellybeans.'
GloveGuiBuy = 'Buy'
GloveGuiCancel = 'Cancel'
# Buffs # Buffs