mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2025-01-09 17:53:50 +00:00
DANIEL: Better glove NPC
This commit is contained in:
parent
a1b996ea49
commit
81728b339a
9 changed files with 262 additions and 238 deletions
4
dependencies/astron/dclass/stride.dc
vendored
4
dependencies/astron/dclass/stride.dc
vendored
|
@ -1973,8 +1973,8 @@ dclass DistributedNPCLaffRestock : DistributedNPCToonBase {
|
||||||
};
|
};
|
||||||
|
|
||||||
dclass DistributedNPCGlove : DistributedNPCToonBase {
|
dclass DistributedNPCGlove : DistributedNPCToonBase {
|
||||||
doTransformation(uint32 avId, uint32) broadcast;
|
changeGlove(uint8) airecv clsend;
|
||||||
requestTransformation(uint32) airecv clsend;
|
changeGloveResult(uint32 avId, uint8) broadcast;
|
||||||
};
|
};
|
||||||
|
|
||||||
dclass DistributedKnockKnockDoor : DistributedAnimatedProp {
|
dclass DistributedKnockKnockDoor : DistributedAnimatedProp {
|
||||||
|
|
|
@ -1,24 +1,5 @@
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
from direct.distributed import DistributedObject
|
from direct.distributed import DistributedObject
|
||||||
from direct.interval.IntervalGlobal import *
|
|
||||||
from toontown.effects import DustCloud
|
|
||||||
|
|
||||||
def getDustCloudIval(toon):
|
|
||||||
dustCloud = DustCloud.DustCloud(fBillboard=0)
|
|
||||||
dustCloud.setBillboardAxis(2.0)
|
|
||||||
dustCloud.setZ(3)
|
|
||||||
dustCloud.setScale(0.4)
|
|
||||||
dustCloud.createTrack()
|
|
||||||
|
|
||||||
if hasattr(toon, 'laffMeter'):
|
|
||||||
toon.laffMeter.color = toon.style.getBlackColor()
|
|
||||||
|
|
||||||
sequence = Sequence(Wait(0.5), Func(dustCloud.reparentTo, toon), dustCloud.track, Func(dustCloud.destroy))
|
|
||||||
|
|
||||||
if hasattr(toon, 'laffMeter'):
|
|
||||||
sequence.append(Func(toon.laffMeter.adjustFace, toon.hp, toon.maxHp))
|
|
||||||
|
|
||||||
return sequence
|
|
||||||
|
|
||||||
class DistributedBlackCatMgr(DistributedObject.DistributedObject):
|
class DistributedBlackCatMgr(DistributedObject.DistributedObject):
|
||||||
neverDisable = 1
|
neverDisable = 1
|
||||||
|
@ -36,4 +17,4 @@ class DistributedBlackCatMgr(DistributedObject.DistributedObject):
|
||||||
self.sendUpdate('requestBlackCatTransformation')
|
self.sendUpdate('requestBlackCatTransformation')
|
||||||
|
|
||||||
def doBlackCatTransformation(self):
|
def doBlackCatTransformation(self):
|
||||||
getDustCloudIval(base.localAvatar).start()
|
getDustCloudIval(base.localAvatar, color=base.localAvatar.style.getBlackColor()).start()
|
|
@ -1,191 +1,77 @@
|
||||||
from direct.fsm import ClassicFSM, State
|
from toontown.chat.ChatGlobals import CFSpeech, CFTimeout
|
||||||
from direct.gui.DirectGui import *
|
|
||||||
from direct.task.Task import Task
|
|
||||||
from pandac.PandaModules import *
|
|
||||||
import time
|
|
||||||
|
|
||||||
from DistributedNPCToonBase import *
|
|
||||||
from toontown.chat.ChatGlobals import *
|
|
||||||
from toontown.effects import DustCloud
|
|
||||||
from toontown.nametag.NametagGlobals import *
|
|
||||||
from toontown.toonbase import TTLocalizer, ToontownGlobals
|
from toontown.toonbase import TTLocalizer, ToontownGlobals
|
||||||
from toontown.toon.ToonDNA import allColorsList
|
from toontown.toon import NPCToons
|
||||||
|
from DistributedNPCToonBase import DistributedNPCToonBase
|
||||||
def getDustCloud(toon):
|
import GloveNPCGlobals, GloveShopGui, time
|
||||||
dustCloud = DustCloud.DustCloud(fBillboard=0)
|
|
||||||
|
|
||||||
dustCloud.setBillboardAxis(2.0)
|
|
||||||
dustCloud.setZ(3)
|
|
||||||
dustCloud.setScale(0.4)
|
|
||||||
dustCloud.createTrack()
|
|
||||||
return Sequence(Wait(0.5), Func(dustCloud.reparentTo, toon), dustCloud.track, Func(dustCloud.destroy))
|
|
||||||
|
|
||||||
class DistributedNPCGlove(DistributedNPCToonBase):
|
class DistributedNPCGlove(DistributedNPCToonBase):
|
||||||
|
|
||||||
def __init__(self, cr):
|
def __init__(self, cr):
|
||||||
DistributedNPCToonBase.__init__(self, cr)
|
DistributedNPCToonBase.__init__(self, cr)
|
||||||
self.nextCollision = 0
|
self.lastCollision = 0
|
||||||
|
self.gloveDialog = None
|
||||||
self.fsm = ClassicFSM.ClassicFSM(
|
|
||||||
'NPCGlove',
|
|
||||||
[
|
|
||||||
State.State('off', self.enterOff, self.exitOff, ['pickColor']),
|
|
||||||
State.State('pickColor', self.enterPickColor, self.exitPickColor, ['off'])
|
|
||||||
], 'off', 'off')
|
|
||||||
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.destroyDialog()
|
||||||
self.nextCollision = 0
|
|
||||||
DistributedNPCToonBase.disable(self)
|
DistributedNPCToonBase.disable(self)
|
||||||
|
|
||||||
def destroyGui(self):
|
def destroyDialog(self):
|
||||||
for element in [self.title, self.notice, self.color, self.buyButton, self.cancelButton, self.leftButton, self.rightButton]:
|
self.clearChat()
|
||||||
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.15, 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)
|
|
||||||
|
|
||||||
|
if self.gloveDialog:
|
||||||
|
self.gloveDialog.destroy()
|
||||||
|
self.gloveDialog = None
|
||||||
|
|
||||||
def initToonState(self):
|
def initToonState(self):
|
||||||
self.setAnimState('neutral', 1.05, None, None)
|
self.setAnimState('neutral', 0.9, None, None)
|
||||||
self.setPosHpr(101, -14, 4, -305, 0, 0)
|
|
||||||
|
if self.name in NPCToons.GlovePositions:
|
||||||
|
pos = NPCToons.GlovePositions[self.name]
|
||||||
|
self.setPos(*pos[0])
|
||||||
|
self.setH(pos[1])
|
||||||
|
|
||||||
def getCollSphereRadius(self):
|
def getCollSphereRadius(self):
|
||||||
return 1.0
|
return 1.25
|
||||||
|
|
||||||
def handleCollisionSphereEnter(self, collEntry):
|
def handleCollisionSphereEnter(self, collEntry):
|
||||||
self.currentTime = time.time()
|
if self.lastCollision > time.time():
|
||||||
|
|
||||||
if self.nextCollision <= self.currentTime:
|
|
||||||
self.fsm.request('pickColor')
|
|
||||||
|
|
||||||
self.nextCollision = self.currentTime + 2
|
|
||||||
|
|
||||||
def enterOff(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def exitOff(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def enterPickColor(self):
|
|
||||||
base.cr.playGame.getPlace().setState('stopped')
|
|
||||||
taskMgr.doMethodLater(45, self.leave, 'npcSleepTask-%s' % self.doId)
|
|
||||||
self.setChatAbsolute('', CFSpeech)
|
|
||||||
|
|
||||||
if base.localAvatar.getTotalMoney() < ToontownGlobals.GloveCost:
|
|
||||||
self.setChatAbsolute(self.getMessageById(2), CFSpeech|CFTimeout)
|
|
||||||
self.reset()
|
|
||||||
else:
|
|
||||||
self.popupPickColorGUI()
|
|
||||||
|
|
||||||
def exitPickColor(self, task=None):
|
|
||||||
taskMgr.remove('npcSleepTask-%s' % self.doId)
|
|
||||||
taskMgr.doMethodLater(0.5, self.reset, 'avatarRecover-%s-%s' % (self.doId, base.localAvatar.doId))
|
|
||||||
|
|
||||||
if task is not None:
|
|
||||||
return task.done
|
|
||||||
|
|
||||||
def popupPickColorGUI(self):
|
|
||||||
self.setChatAbsolute('', CFSpeech)
|
|
||||||
self.setChatAbsolute(TTLocalizer.GlovePickColorMessage, CFSpeech|CFTimeout)
|
|
||||||
base.setCellsActive(base.bottomCells, 0)
|
|
||||||
self.createGui()
|
|
||||||
|
|
||||||
def getMessageById(self, response):
|
|
||||||
if response == 1:
|
|
||||||
return TTLocalizer.GloveSameColorMessage
|
|
||||||
elif response == 2:
|
|
||||||
return TTLocalizer.GloveNoMoneyMessage
|
|
||||||
else:
|
|
||||||
return TTLocalizer.GloveSuccessMessage
|
|
||||||
|
|
||||||
def doTransformation(self, avId, response):
|
|
||||||
av = self.cr.doId2do.get(avId)
|
|
||||||
|
|
||||||
if not av:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if response == 3:
|
self.lastCollision = time.time() + ToontownGlobals.NPCCollisionDelay
|
||||||
getDustCloud(av).start()
|
|
||||||
|
if base.localAvatar.getTotalMoney() < ToontownGlobals.GloveCost:
|
||||||
self.setChatAbsolute('', CFSpeech)
|
self.setChatAbsolute(TTLocalizer.GloveMoreMoneyMessage % ToontownGlobals.GloveCost, CFSpeech|CFTimeout)
|
||||||
self.setChatAbsolute(self.getMessageById(response), CFSpeech|CFTimeout)
|
return
|
||||||
|
|
||||||
def d_requestTransformation(self, color):
|
base.cr.playGame.getPlace().fsm.request('stopped')
|
||||||
self.sendUpdate('requestTransformation', [color])
|
base.setCellsActive(base.bottomCells, 0)
|
||||||
self.reset()
|
self.setChatAbsolute(TTLocalizer.GlovePickColorMessage, CFSpeech|CFTimeout)
|
||||||
|
self.acceptOnce('gloveShopDone', self.__gloveShopDone)
|
||||||
def leave(self, task=None):
|
self.gloveDialog = GloveShopGui.GloveShopGui()
|
||||||
self.setChatAbsolute('', CFSpeech)
|
|
||||||
self.setChatAbsolute(TTLocalizer.GloveByeMessage, CFSpeech|CFTimeout)
|
def freeAvatar(self):
|
||||||
self.reset(task)
|
base.cr.playGame.getPlace().fsm.request('walk')
|
||||||
|
|
||||||
def reset(self, task=None):
|
|
||||||
self.fsm.request('off')
|
|
||||||
base.cr.playGame.getPlace().setState('walk')
|
|
||||||
base.setCellsActive(base.bottomCells, 1)
|
base.setCellsActive(base.bottomCells, 1)
|
||||||
self.destroyGui()
|
|
||||||
|
def __gloveShopDone(self, state, glove):
|
||||||
|
self.freeAvatar()
|
||||||
|
|
||||||
if task is not None:
|
if state == GloveNPCGlobals.TIMER_END:
|
||||||
return task.done
|
self.setChatAbsolute(TTLocalizer.STOREOWNER_TOOKTOOLONG, CFSpeech|CFTimeout)
|
||||||
|
return
|
||||||
|
elif state == GloveNPCGlobals.USER_CANCEL:
|
||||||
|
self.setChatAbsolute(TTLocalizer.STOREOWNER_GOODBYE, CFSpeech|CFTimeout)
|
||||||
|
return
|
||||||
|
elif state == GloveNPCGlobals.CHANGE:
|
||||||
|
self.sendUpdate('changeGlove', [glove])
|
||||||
|
|
||||||
|
def changeGloveResult(self, avId, state):
|
||||||
|
if state in GloveNPCGlobals.ChangeMessages:
|
||||||
|
self.setChatAbsolute(GloveNPCGlobals.ChangeMessages[state], CFSpeech|CFTimeout)
|
||||||
|
|
||||||
|
if state == GloveNPCGlobals.CHANGE_SUCCESSFUL:
|
||||||
|
av = self.cr.doId2do.get(avId)
|
||||||
|
|
||||||
|
if av:
|
||||||
|
av.getDustCloud().start()
|
|
@ -1,27 +1,27 @@
|
||||||
from DistributedNPCToonBaseAI import DistributedNPCToonBaseAI
|
|
||||||
from ToonDNA import ToonDNA
|
|
||||||
from toontown.toonbase import ToontownGlobals
|
from toontown.toonbase import ToontownGlobals
|
||||||
|
import DistributedNPCToonBaseAI, GloveNPCGlobals, ToonDNA
|
||||||
|
|
||||||
class DistributedNPCGloveAI(DistributedNPCToonBaseAI):
|
class DistributedNPCGloveAI(DistributedNPCToonBaseAI.DistributedNPCToonBaseAI):
|
||||||
|
|
||||||
def requestTransformation(self, color):
|
def changeGlove(self, color):
|
||||||
avId = self.air.getAvatarIdFromSender()
|
avId = self.air.getAvatarIdFromSender()
|
||||||
av = self.air.doId2do.get(avId)
|
av = self.air.doId2do.get(avId)
|
||||||
|
|
||||||
if av is None or not hasattr(av, 'dna'):
|
if av is None or not hasattr(av, 'dna'):
|
||||||
return
|
return
|
||||||
|
elif len(ToonDNA.allColorsList) <= color:
|
||||||
if av.dna.gloveColor == color:
|
self.sendUpdate('changeGloveResult', [avId, GloveNPCGlobals.INVALID_COLOR])
|
||||||
self.sendUpdate('doTransformation', [avId, 1])
|
|
||||||
return
|
return
|
||||||
|
elif av.dna.gloveColor == color:
|
||||||
if av.getTotalMoney() < ToontownGlobals.GloveCost:
|
self.sendUpdate('changeGloveResult', [avId, GloveNPCGlobals.SAME_COLOR])
|
||||||
self.sendUpdate('doTransformation', [avId, 2])
|
return
|
||||||
|
elif av.getTotalMoney() < ToontownGlobals.GloveCost:
|
||||||
|
self.sendUpdate('changeGloveResult', [avId, GloveNPCGlobals.NOT_ENOUGH_MONEY])
|
||||||
return
|
return
|
||||||
|
|
||||||
av.takeMoney(ToontownGlobals.GloveCost)
|
av.takeMoney(ToontownGlobals.GloveCost)
|
||||||
newDNA = ToonDNA()
|
newDNA = ToonDNA.ToonDNA()
|
||||||
newDNA.makeFromNetString(av.getDNAString())
|
newDNA.makeFromNetString(av.getDNAString())
|
||||||
newDNA.gloveColor = color
|
newDNA.gloveColor = color
|
||||||
taskMgr.doMethodLater(1.0, lambda task: av.b_setDNAString(newDNA.makeNetString()), 'transform-%d' % avId)
|
taskMgr.doMethodLater(1.0, lambda task: av.b_setDNAString(newDNA.makeNetString()), 'transform-%d' % avId)
|
||||||
self.sendUpdate('doTransformation', [avId, 3])
|
self.sendUpdate('changeGloveResult', [avId, GloveNPCGlobals.CHANGE_SUCCESSFUL])
|
21
toontown/toon/GloveNPCGlobals.py
Normal file
21
toontown/toon/GloveNPCGlobals.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
from toontown.toonbase import TTLocalizer
|
||||||
|
|
||||||
|
TIMER_SECONDS = 60
|
||||||
|
|
||||||
|
# Glove Shop GUI
|
||||||
|
TIMER_END = 0
|
||||||
|
USER_CANCEL = 1
|
||||||
|
CHANGE = 2
|
||||||
|
|
||||||
|
# Glove Results
|
||||||
|
INVALID_COLOR = 0
|
||||||
|
SAME_COLOR = 1
|
||||||
|
NOT_ENOUGH_MONEY = 2
|
||||||
|
CHANGE_SUCCESSFUL = 3
|
||||||
|
|
||||||
|
ChangeMessages = {
|
||||||
|
INVALID_COLOR: TTLocalizer.GloveInvalidColorMessage,
|
||||||
|
SAME_COLOR: TTLocalizer.GloveSameColorMessage,
|
||||||
|
NOT_ENOUGH_MONEY: TTLocalizer.GloveNoMoneyMessage,
|
||||||
|
CHANGE_SUCCESSFUL: TTLocalizer.GloveSuccessMessage
|
||||||
|
}
|
143
toontown/toon/GloveShopGui.py
Normal file
143
toontown/toon/GloveShopGui.py
Normal file
|
@ -0,0 +1,143 @@
|
||||||
|
from direct.gui.DirectGui import DirectButton, DirectLabel, DGG
|
||||||
|
from direct.task.Task import Task
|
||||||
|
from toontown.toon import ToonDNA
|
||||||
|
from toontown.toonbase import ToontownGlobals, TTLocalizer, ToontownTimer
|
||||||
|
import GloveNPCGlobals, time
|
||||||
|
|
||||||
|
class GloveShopGui:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.index = 0
|
||||||
|
self.id = time.time()
|
||||||
|
self.lastGlove = base.localAvatar.style.gloveColor
|
||||||
|
self.timer = ToontownTimer.ToontownTimer()
|
||||||
|
self.timer.reparentTo(aspect2d)
|
||||||
|
self.timer.posInTopRightCorner()
|
||||||
|
self.timer.countdown(GloveNPCGlobals.TIMER_SECONDS, self.__exit, [GloveNPCGlobals.TIMER_END])
|
||||||
|
self.setupButtons()
|
||||||
|
self.bindButtons()
|
||||||
|
self.__updateIndex(0)
|
||||||
|
|
||||||
|
def setupButtons(self):
|
||||||
|
gui = loader.loadModel('phase_3/models/gui/tt_m_gui_mat_mainGui')
|
||||||
|
arrowImage = (gui.find('**/tt_t_gui_mat_shuffleArrowUp'), gui.find('**/tt_t_gui_mat_shuffleArrowDown'))
|
||||||
|
buttonImage = (gui.find('**/tt_t_gui_mat_shuffleUp'), gui.find('**/tt_t_gui_mat_shuffleDown'))
|
||||||
|
|
||||||
|
self.title = DirectLabel(aspect2d, relief=None, text=TTLocalizer.GloveGuiTitle,
|
||||||
|
text_fg=(0, 1, 0, 1), text_scale=0.15, text_font=ToontownGlobals.getSignFont(),
|
||||||
|
pos=(0, 0, -0.30), text_shadow=(1, 1, 1, 1))
|
||||||
|
|
||||||
|
self.notice = DirectLabel(aspect2d, relief=None, text='', 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=buttonImage, 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.__exit, extraArgs=[GloveNPCGlobals.CHANGE])
|
||||||
|
|
||||||
|
self.cancelButton = DirectButton(aspect2d, relief=None, image=buttonImage, text=TTLocalizer.lCancel,
|
||||||
|
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.__exit, extraArgs=[GloveNPCGlobals.USER_CANCEL])
|
||||||
|
|
||||||
|
self.downArrow = DirectButton(aspect2d, relief=None, image=arrowImage, pos=(-0.60, 0, -0.66))
|
||||||
|
self.upArrow = DirectButton(aspect2d, relief=None, image=arrowImage, pos=(0.60, 0, -0.66), scale=-1)
|
||||||
|
|
||||||
|
gui.removeNode()
|
||||||
|
|
||||||
|
def bindButtons(self):
|
||||||
|
self.downArrow.bind(DGG.B1PRESS, self.__taskUpdate, extraArgs=[-1])
|
||||||
|
self.downArrow.bind(DGG.B1RELEASE, self.__taskDone)
|
||||||
|
self.upArrow.bind(DGG.B1PRESS, self.__taskUpdate, extraArgs=[1])
|
||||||
|
self.upArrow.bind(DGG.B1RELEASE, self.__taskDone)
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
if self.timer:
|
||||||
|
self.timer.destroy()
|
||||||
|
|
||||||
|
if not hasattr(self, 'title'):
|
||||||
|
return
|
||||||
|
|
||||||
|
# TODO: DirectDialog-ify
|
||||||
|
self.title.destroy()
|
||||||
|
self.notice.destroy()
|
||||||
|
self.color.destroy()
|
||||||
|
self.buyButton.destroy()
|
||||||
|
self.cancelButton.destroy()
|
||||||
|
self.downArrow.destroy()
|
||||||
|
self.upArrow.destroy()
|
||||||
|
del self.title
|
||||||
|
del self.notice
|
||||||
|
del self.color
|
||||||
|
del self.buyButton
|
||||||
|
del self.cancelButton
|
||||||
|
del self.downArrow
|
||||||
|
del self.upArrow
|
||||||
|
|
||||||
|
taskMgr.remove('runGloveCounter-%s' % self.id)
|
||||||
|
|
||||||
|
def setClientGlove(self, color):
|
||||||
|
dna = base.localAvatar.style
|
||||||
|
|
||||||
|
dna.gloveColor = color
|
||||||
|
base.localAvatar.setDNA(dna)
|
||||||
|
|
||||||
|
def __exit(self, state):
|
||||||
|
self.destroy()
|
||||||
|
self.setClientGlove(self.lastGlove)
|
||||||
|
messenger.send('gloveShopDone', [state, self.index if state == GloveNPCGlobals.CHANGE else 0])
|
||||||
|
|
||||||
|
def __updateIndex(self, offset):
|
||||||
|
self.index += offset
|
||||||
|
hitLimit = 0
|
||||||
|
|
||||||
|
if self.index <= 0:
|
||||||
|
self.downArrow['state'] = DGG.DISABLED
|
||||||
|
hitLimit = 1
|
||||||
|
else:
|
||||||
|
self.downArrow['state'] = DGG.NORMAL
|
||||||
|
|
||||||
|
if (self.index + 1) >= len(TTLocalizer.NumToColor):
|
||||||
|
self.upArrow['state'] = DGG.DISABLED
|
||||||
|
hitLimit = 1
|
||||||
|
else:
|
||||||
|
self.upArrow['state'] = DGG.NORMAL
|
||||||
|
|
||||||
|
if self.lastGlove == self.index:
|
||||||
|
self.buyButton['state'] = DGG.DISABLED
|
||||||
|
self.notice['text'] = TTLocalizer.GloveGuiSameColor
|
||||||
|
else:
|
||||||
|
self.buyButton['state'] = DGG.NORMAL
|
||||||
|
self.notice['text'] = TTLocalizer.GloveGuiNotice % ToontownGlobals.GloveCost
|
||||||
|
|
||||||
|
self.color['text'] = TTLocalizer.NumToColor[self.index]
|
||||||
|
self.color['text_fg'] = ToonDNA.allColorsList[self.index]
|
||||||
|
self.setClientGlove(self.index)
|
||||||
|
return hitLimit
|
||||||
|
|
||||||
|
def __runTask(self, task):
|
||||||
|
if task.time - task.prevTime < task.delayTime:
|
||||||
|
return Task.cont
|
||||||
|
else:
|
||||||
|
task.delayTime = max(0.05, task.delayTime * 0.75)
|
||||||
|
task.prevTime = task.time
|
||||||
|
hitLimit = self.__updateIndex(task.delta)
|
||||||
|
|
||||||
|
return Task.done if hitLimit else Task.cont
|
||||||
|
|
||||||
|
def __taskDone(self, event):
|
||||||
|
messenger.send('wakeup')
|
||||||
|
taskMgr.remove('runGloveCounter-%s' % self.id)
|
||||||
|
|
||||||
|
def __taskUpdate(self, delta, event):
|
||||||
|
messenger.send('wakeup')
|
||||||
|
|
||||||
|
task = Task(self.__runTask)
|
||||||
|
task.delayTime = 0.4
|
||||||
|
task.prevTime = 0.0
|
||||||
|
task.delta = delta
|
||||||
|
hitLimit = self.__updateIndex(delta)
|
||||||
|
|
||||||
|
if not hitLimit:
|
||||||
|
taskMgr.add(task, 'runGloveCounter-%s' % self.id)
|
|
@ -11699,6 +11699,7 @@ LaffRestockPositions = {lnames[11001]: ((-27.0, -170.0, -19.6), 215.0),
|
||||||
lnames[12001]: ((361.9, -394.4, -23.5), 113.5),
|
lnames[12001]: ((361.9, -394.4, -23.5), 113.5),
|
||||||
lnames[13001]: ((143.7, -381.4, -68.4), 0.0),
|
lnames[13001]: ((143.7, -381.4, -68.4), 0.0),
|
||||||
lnames[10001]: ((135.0, 128.8, 0.025), -212.8)}
|
lnames[10001]: ((135.0, 128.8, 0.025), -212.8)}
|
||||||
|
GlovePositions = {lnames[2021]: ((101, -14, 4), -305)}
|
||||||
del lnames
|
del lnames
|
||||||
zone2NpcDict = {}
|
zone2NpcDict = {}
|
||||||
|
|
||||||
|
|
|
@ -2258,17 +2258,9 @@ class Toon(Avatar.Avatar, ToonHead):
|
||||||
|
|
||||||
def __doPumpkinHeadSwitch(self, lerpTime, toPumpkin):
|
def __doPumpkinHeadSwitch(self, lerpTime, toPumpkin):
|
||||||
node = self.getGeomNode()
|
node = self.getGeomNode()
|
||||||
|
dust = self.getDustCloud(0.0)
|
||||||
def getDustCloudIval():
|
|
||||||
dustCloud = DustCloud.DustCloud(fBillboard=0, wantSound=1)
|
|
||||||
dustCloud.setBillboardAxis(2.0)
|
|
||||||
dustCloud.setZ(3)
|
|
||||||
dustCloud.setScale(0.4)
|
|
||||||
dustCloud.createTrack()
|
|
||||||
return Sequence(Func(dustCloud.reparentTo, self), dustCloud.track, Func(dustCloud.destroy), name='dustCloadIval')
|
|
||||||
|
|
||||||
dust = getDustCloudIval()
|
|
||||||
track = Sequence()
|
track = Sequence()
|
||||||
|
|
||||||
if toPumpkin:
|
if toPumpkin:
|
||||||
track.append(Func(self.stopBlink))
|
track.append(Func(self.stopBlink))
|
||||||
track.append(Func(self.closeEyes))
|
track.append(Func(self.closeEyes))
|
||||||
|
@ -2310,17 +2302,9 @@ class Toon(Avatar.Avatar, ToonHead):
|
||||||
|
|
||||||
def __doSnowManHeadSwitch(self, lerpTime, toSnowMan):
|
def __doSnowManHeadSwitch(self, lerpTime, toSnowMan):
|
||||||
node = self.getGeomNode()
|
node = self.getGeomNode()
|
||||||
|
dust = self.getDustCloud(0.0)
|
||||||
def getDustCloudIval():
|
|
||||||
dustCloud = DustCloud.DustCloud(fBillboard=0, wantSound=0)
|
|
||||||
dustCloud.setBillboardAxis(2.0)
|
|
||||||
dustCloud.setZ(3)
|
|
||||||
dustCloud.setScale(0.4)
|
|
||||||
dustCloud.createTrack()
|
|
||||||
return Sequence(Func(dustCloud.reparentTo, self), dustCloud.track, Func(dustCloud.destroy), name='dustCloadIval')
|
|
||||||
|
|
||||||
dust = getDustCloudIval()
|
|
||||||
track = Sequence()
|
track = Sequence()
|
||||||
|
|
||||||
if toSnowMan:
|
if toSnowMan:
|
||||||
track.append(Func(self.stopBlink))
|
track.append(Func(self.stopBlink))
|
||||||
track.append(Func(self.closeEyes))
|
track.append(Func(self.closeEyes))
|
||||||
|
@ -2370,16 +2354,8 @@ class Toon(Avatar.Avatar, ToonHead):
|
||||||
track = Sequence()
|
track = Sequence()
|
||||||
greenTrack = Parallel()
|
greenTrack = Parallel()
|
||||||
|
|
||||||
def getDustCloudIval():
|
|
||||||
dustCloud = DustCloud.DustCloud(fBillboard=0, wantSound=1)
|
|
||||||
dustCloud.setBillboardAxis(2.0)
|
|
||||||
dustCloud.setZ(3)
|
|
||||||
dustCloud.setScale(0.4)
|
|
||||||
dustCloud.createTrack()
|
|
||||||
return Sequence(Func(dustCloud.reparentTo, self), dustCloud.track, Func(dustCloud.destroy), name='dustCloadIval')
|
|
||||||
|
|
||||||
if lerpTime > 0.0:
|
if lerpTime > 0.0:
|
||||||
dust = getDustCloudIval()
|
dust = self.getDustCloud(0.0)
|
||||||
track.append(Func(dust.start))
|
track.append(Func(dust.start))
|
||||||
track.append(Wait(0.5))
|
track.append(Wait(0.5))
|
||||||
if toGreen:
|
if toGreen:
|
||||||
|
@ -3017,5 +2993,20 @@ class Toon(Avatar.Avatar, ToonHead):
|
||||||
|
|
||||||
return sequence
|
return sequence
|
||||||
|
|
||||||
|
def getDustCloud(self, delay=0.5, color=False):
|
||||||
|
dustCloud = DustCloud.DustCloud(fBillboard=0, wantSound=1)
|
||||||
|
|
||||||
|
dustCloud.setBillboardAxis(2.0)
|
||||||
|
dustCloud.setZ(3)
|
||||||
|
dustCloud.setScale(0.4)
|
||||||
|
dustCloud.createTrack()
|
||||||
|
sequence = Sequence(Wait(delay), Func(dustCloud.reparentTo, self), dustCloud.track, Func(dustCloud.destroy), name='dustCloudIval')
|
||||||
|
|
||||||
|
if color is not None and hasattr(self, 'laffMeter'):
|
||||||
|
self.laffMeter.color = color
|
||||||
|
sequence.append(Func(self.laffMeter.adjustFace, self.hp, self.maxHp))
|
||||||
|
|
||||||
|
return sequence
|
||||||
|
|
||||||
loadModels()
|
loadModels()
|
||||||
compileGlobalAnimList()
|
compileGlobalAnimList()
|
||||||
|
|
|
@ -8355,15 +8355,16 @@ InteractivePropTrackBonusTerms = {0: 'Super Toon-Up!',
|
||||||
4: 'Super Throw!',
|
4: 'Super Throw!',
|
||||||
5: 'Super Squirt!',
|
5: 'Super Squirt!',
|
||||||
6: ''}
|
6: ''}
|
||||||
GloveSameColorMessage = 'You already have those gloves!'
|
GloveInvalidColorMessage = "That's an unpainted color."
|
||||||
|
GloveSameColorMessage = "You're already wearing those gloves!"
|
||||||
GloveNoMoneyMessage = "You don't have enough jellybeans!"
|
GloveNoMoneyMessage = "You don't have enough jellybeans!"
|
||||||
|
GloveMoreMoneyMessage = 'You need %s jellybeans to buy new gloves!'
|
||||||
GloveSuccessMessage = 'Have fun with your new gloves!'
|
GloveSuccessMessage = 'Have fun with your new gloves!'
|
||||||
GloveByeMessage = 'See you later!'
|
|
||||||
GlovePickColorMessage = 'Feel free to choose!'
|
GlovePickColorMessage = 'Feel free to choose!'
|
||||||
GloveGuiTitle = 'Choose a glove color!'
|
GloveGuiTitle = 'Choose a glove color!'
|
||||||
GloveGuiNotice = 'Costs %s jellybeans.'
|
GloveGuiNotice = 'Costs %s jellybeans.'
|
||||||
GloveGuiBuy = 'Buy'
|
GloveGuiBuy = 'Buy'
|
||||||
GloveGuiCancel = 'Cancel'
|
GloveGuiSameColor = 'You already have these!'
|
||||||
LanguageButtonText = 'Language'
|
LanguageButtonText = 'Language'
|
||||||
LanguageSelectorTitle = 'Choose your language!'
|
LanguageSelectorTitle = 'Choose your language!'
|
||||||
LanguageSelectorCurrent = 'Current language: %s'
|
LanguageSelectorCurrent = 'Current language: %s'
|
||||||
|
|
Loading…
Reference in a new issue