mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-24 12:12:36 -06:00
an even more amazing GUI
This commit is contained in:
parent
b491ff1cfe
commit
861909b881
7 changed files with 211 additions and 64 deletions
|
@ -1959,7 +1959,7 @@ dclass DistributedNPCKartClerk : DistributedNPCToonBase {
|
||||||
|
|
||||||
dclass DistributedNPCLaffRestock : DistributedNPCToonBase {
|
dclass DistributedNPCLaffRestock : DistributedNPCToonBase {
|
||||||
setMovie(uint8, uint32, uint32, uint32[], int16) broadcast ram;
|
setMovie(uint8, uint32, uint32, uint32[], int16) broadcast ram;
|
||||||
restock(uint32, uint8) airecv clsend;
|
restock(uint32, uint8, uint8) airecv clsend;
|
||||||
transactionDone() airecv clsend;
|
transactionDone() airecv clsend;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from pandac.PandaModules import *
|
from pandac.PandaModules import *
|
||||||
|
|
||||||
|
|
||||||
hashVal = 630664315
|
hashVal = 2180409862L
|
||||||
|
|
||||||
|
|
||||||
from toontown.coghq import DistributedCashbotBossSafe, DistributedCashbotBossCrane, DistributedBattleFactory, DistributedCashbotBossTreasure, DistributedCogHQDoor, DistributedSellbotHQDoor, DistributedFactoryElevatorExt, DistributedMintElevatorExt, DistributedLawOfficeElevatorExt, DistributedLawOfficeElevatorInt, LobbyManager, DistributedMegaCorp, DistributedFactory, DistributedLawOffice, DistributedLawOfficeFloor, DistributedLift, DistributedDoorEntity, DistributedSwitch, DistributedButton, DistributedTrigger, DistributedCrushableEntity, DistributedCrusherEntity, DistributedStomper, DistributedStomperPair, DistributedLaserField, DistributedGolfGreenGame, DistributedSecurityCamera, DistributedMover, DistributedElevatorMarker, DistributedBarrelBase, DistributedGagBarrel, DistributedBeanBarrel, DistributedHealBarrel, DistributedGrid, ActiveCell, DirectionalCell, CrusherCell, DistributedCrate, DistributedSinkingPlatform, BattleBlocker, DistributedMint, DistributedMintRoom, DistributedMintBattle, DistributedStage, DistributedStageRoom, DistributedStageBattle, DistributedLawbotBossGavel, DistributedLawbotCannon, DistributedLawbotChair, DistributedCogKart, DistributedCountryClub, DistributedCountryClubRoom, DistributedMoleField, DistributedCountryClubBattle, DistributedMaze, DistributedFoodBelt, DistributedBanquetTable, DistributedGolfSpot
|
from toontown.coghq import DistributedCashbotBossSafe, DistributedCashbotBossCrane, DistributedBattleFactory, DistributedCashbotBossTreasure, DistributedCogHQDoor, DistributedSellbotHQDoor, DistributedFactoryElevatorExt, DistributedMintElevatorExt, DistributedLawOfficeElevatorExt, DistributedLawOfficeElevatorInt, LobbyManager, DistributedMegaCorp, DistributedFactory, DistributedLawOffice, DistributedLawOfficeFloor, DistributedLift, DistributedDoorEntity, DistributedSwitch, DistributedButton, DistributedTrigger, DistributedCrushableEntity, DistributedCrusherEntity, DistributedStomper, DistributedStomperPair, DistributedLaserField, DistributedGolfGreenGame, DistributedSecurityCamera, DistributedMover, DistributedElevatorMarker, DistributedBarrelBase, DistributedGagBarrel, DistributedBeanBarrel, DistributedHealBarrel, DistributedGrid, ActiveCell, DirectionalCell, CrusherCell, DistributedCrate, DistributedSinkingPlatform, BattleBlocker, DistributedMint, DistributedMintRoom, DistributedMintBattle, DistributedStage, DistributedStageRoom, DistributedStageBattle, DistributedLawbotBossGavel, DistributedLawbotCannon, DistributedLawbotChair, DistributedCogKart, DistributedCountryClub, DistributedCountryClubRoom, DistributedMoleField, DistributedCountryClubBattle, DistributedMaze, DistributedFoodBelt, DistributedBanquetTable, DistributedGolfSpot
|
||||||
|
|
|
@ -92,8 +92,8 @@ class DistributedNPCLaffRestock(DistributedNPCToonBase):
|
||||||
self.setChatAbsolute(TTLocalizer.RestockNoMoneyMessage, CFSpeech | CFTimeout)
|
self.setChatAbsolute(TTLocalizer.RestockNoMoneyMessage, CFSpeech | CFTimeout)
|
||||||
self.resetLaffClerk()
|
self.resetLaffClerk()
|
||||||
|
|
||||||
def __handleRestock(self, cost):
|
def __handleRestock(self, laff, cost):
|
||||||
self.sendUpdate('restock', [self.av.doId, cost])
|
self.sendUpdate('restock', [self.av.doId, laff, cost])
|
||||||
|
|
||||||
def __handleGuiDone(self, bTimedOut=False):
|
def __handleGuiDone(self, bTimedOut=False):
|
||||||
self.ignoreAll()
|
self.ignoreAll()
|
||||||
|
@ -107,5 +107,4 @@ class DistributedNPCLaffRestock(DistributedNPCToonBase):
|
||||||
self.setChatAbsolute('', CFSpeech)
|
self.setChatAbsolute('', CFSpeech)
|
||||||
self.accept('restockLaff', self.__handleRestock)
|
self.accept('restockLaff', self.__handleRestock)
|
||||||
self.acceptOnce('guiDone', self.__handleGuiDone)
|
self.acceptOnce('guiDone', self.__handleGuiDone)
|
||||||
self.laffGui = LaffShopGui(text=TTLocalizer.RestockAskMessage % (laff, cost),
|
self.laffGui = LaffShopGui(text=TTLocalizer.RestockAskMessage % (laff, cost))
|
||||||
extraArgs=[cost])
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ class DistributedNPCLaffRestockAI(DistributedNPCToonBaseAI):
|
||||||
self.d_setMovie(0, NPCToons.SELL_MOVIE_CLEAR)
|
self.d_setMovie(0, NPCToons.SELL_MOVIE_CLEAR)
|
||||||
return Task.done
|
return Task.done
|
||||||
|
|
||||||
def restock(self, avId, cost):
|
def restock(self, avId, laff, cost):
|
||||||
sendAvId = self.air.getAvatarIdFromSender()
|
sendAvId = self.air.getAvatarIdFromSender()
|
||||||
if self.busy != avId:
|
if self.busy != avId:
|
||||||
self.air.writeServerEvent('suspicious', avId, 'DistributedNPCLaffRestockAI.restock busy with %s' % self.busy)
|
self.air.writeServerEvent('suspicious', avId, 'DistributedNPCLaffRestockAI.restock busy with %s' % self.busy)
|
||||||
|
@ -91,4 +91,4 @@ class DistributedNPCLaffRestockAI(DistributedNPCToonBaseAI):
|
||||||
if av:
|
if av:
|
||||||
movieType = NPCToons.SELL_MOVIE_COMPLETE
|
movieType = NPCToons.SELL_MOVIE_COMPLETE
|
||||||
av.takeMoney(cost)
|
av.takeMoney(cost)
|
||||||
av.b_setHp(av.getMaxHp())
|
av.b_setHp(av.getHp() + laff)
|
||||||
|
|
|
@ -2,3 +2,5 @@ LAFFCLERK_TIMER = 30
|
||||||
FullLaff = 12
|
FullLaff = 12
|
||||||
NoMoney = 14
|
NoMoney = 14
|
||||||
Success = 1
|
Success = 1
|
||||||
|
GuiOk = 'Ok'
|
||||||
|
GuiCancel = 'Cancel'
|
||||||
|
|
|
@ -1,55 +1,201 @@
|
||||||
from pandac.PandaModules import *
|
from pandac.PandaModules import *
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
from direct.gui.DirectGui import *
|
from direct.gui.DirectGui import *
|
||||||
from direct.showbase import DirectObject
|
from direct.showbase import DirectObject
|
||||||
from toontown.toonbase import ToontownGlobals
|
from toontown.toonbase import ToontownGlobals
|
||||||
from toontown.toonbase import TTLocalizer
|
from toontown.toonbase import TTLocalizer
|
||||||
from toontown.toonbase import ToontownTimer
|
from direct.task.Task import Task
|
||||||
from toontown.toontowngui import TTDialog
|
from toontown.toonbase import ToontownTimer
|
||||||
import LaffRestockGlobals
|
import LaffRestockGlobals
|
||||||
|
from LaffMeter import LaffMeter
|
||||||
class LaffShopGui(object, DirectObject.DirectObject):
|
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory('LaffShopGui')
|
class LaffShopGui(DirectFrame):
|
||||||
|
|
||||||
def __init__(self, **kw):
|
def __init__(self, text):
|
||||||
self.dialog = None
|
DirectFrame.__init__(
|
||||||
self.timer = None
|
self,
|
||||||
self.timer = ToontownTimer.ToontownTimer()
|
parent=aspect2d,
|
||||||
self.timer.reparentTo(aspect2d)
|
relief=None,
|
||||||
self.timer.posInTopRightCorner()
|
geom=DGG.getDefaultDialogGeom(),
|
||||||
self.timer.accept('RESET_LAFFSHOP_TIMER', self.__resetTimer)
|
geom_color=ToontownGlobals.GlobalDialogColor,
|
||||||
self.timer.countdown(LaffRestockGlobals.LAFFCLERK_TIMER, self.__timerExpired)
|
geom_scale=(1.33, 1, 1.1),
|
||||||
self.__doDialog(**kw)
|
pos=(0, 0, 0),
|
||||||
|
text=text,
|
||||||
def destroy(self):
|
text_scale=0.07,
|
||||||
self.ignoreAll()
|
text_pos=(0, 0.475),
|
||||||
if self.timer:
|
)
|
||||||
self.timer.destroy()
|
self.initialiseoptions(LaffShopGui)
|
||||||
self.timer = None
|
self.text = text
|
||||||
if self.dialog:
|
self.timer = ToontownTimer.ToontownTimer()
|
||||||
self.dialog.destroy()
|
self.timer.reparentTo(aspect2d)
|
||||||
self.dialog = None
|
self.timer.posInTopRightCorner()
|
||||||
|
self.timer.accept('RESET_LAFFSHOP_TIMER', self.__resetTimer)
|
||||||
def __resetTimer(self):
|
self.timer.countdown(LaffRestockGlobals.LAFFCLERK_TIMER, self.__timerExpired)
|
||||||
if self.timer:
|
self.hp = base.localAvatar.getHp()
|
||||||
self.timer.stop()
|
self.maxHp = base.localAvatar.getMaxHp()
|
||||||
self.timer.countdown(LaffRestockGlobals.LAFFCLERK_TIMER, self.__timerExpired)
|
self.floorLimit = self.hp
|
||||||
|
self.ceilLimit = 0
|
||||||
def __timerExpired(self):
|
money = base.localAvatar.getTotalMoney()
|
||||||
messenger.send('guiDone', [True])
|
while self.ceilLimit * ToontownGlobals.CostPerLaffRestock < money:
|
||||||
|
self.ceilLimit += 1
|
||||||
def __destroyDialog(self, resp, cost):
|
self.__additionalLaff = 0
|
||||||
if self.timer:
|
self.__setupButtons()
|
||||||
self.ignoreAll()
|
self.__bindButtons()
|
||||||
if self.dialog:
|
self.laffMeter = LaffMeter(base.localAvatar.style, self.hp, self.maxHp)
|
||||||
self.dialog.destroy()
|
self.laffMeter.reparentTo(self)
|
||||||
self.dialog = None
|
self.laffMeter.setPos(0, 0, 0.15)
|
||||||
if resp == LaffRestockGlobals.Success:
|
self.laffMeter.setScale(0.13)
|
||||||
messenger.send('restockLaff', [cost])
|
self.__updateLaffMeter(0)
|
||||||
messenger.send('guiDone', [False])
|
|
||||||
|
def __setupButtons(self):
|
||||||
def __doDialog(self, **kw):
|
buttons = loader.loadModel('phase_3/models/gui/dialog_box_buttons_gui')
|
||||||
self.dialog = TTDialog.TTDialog(style=TTDialog.YesNo,
|
arrowGui = loader.loadModel('phase_3/models/gui/create_a_toon_gui')
|
||||||
command=self.__destroyDialog,
|
okImageList = (
|
||||||
**kw)
|
buttons.find('**/ChtBx_OKBtn_UP'),
|
||||||
self.dialog.show()
|
buttons.find('**/ChtBx_OKBtn_DN'),
|
||||||
|
buttons.find('**/ChtBx_OKBtn_Rllvr'),
|
||||||
|
)
|
||||||
|
cancelImageList = (
|
||||||
|
buttons.find('**/CloseBtn_UP'),
|
||||||
|
buttons.find('**/CloseBtn_DN'),
|
||||||
|
buttons.find('**/CloseBtn_Rllvr'),
|
||||||
|
)
|
||||||
|
arrowImageList = (
|
||||||
|
arrowGui.find('**/CrtATn_R_Arrow_UP'),
|
||||||
|
arrowGui.find('**/CrtATn_R_Arrow_DN'),
|
||||||
|
arrowGui.find('**/CrtATn_R_Arrow_RLVR'),
|
||||||
|
arrowGui.find('**/CrtATn_R_Arrow_UP'),
|
||||||
|
)
|
||||||
|
self.cancelButton = DirectButton(
|
||||||
|
parent=self,
|
||||||
|
relief=None,
|
||||||
|
image=cancelImageList,
|
||||||
|
pos=(-0.2, 0, -0.4),
|
||||||
|
text=LaffRestockGlobals.GuiCancel,
|
||||||
|
text_scale=0.06,
|
||||||
|
text_pos=(0, -0.1),
|
||||||
|
command=self.__cancel,
|
||||||
|
)
|
||||||
|
self.okButton = DirectButton(
|
||||||
|
parent=self,
|
||||||
|
relief=None,
|
||||||
|
image=okImageList,
|
||||||
|
pos=(0.2, 0, -0.4),
|
||||||
|
text=LaffRestockGlobals.GuiOk,
|
||||||
|
text_scale=0.06,
|
||||||
|
text_pos=(0, -0.1),
|
||||||
|
command=self.__requestLaff,
|
||||||
|
extraArgs=[],
|
||||||
|
)
|
||||||
|
self.upArrow = DirectButton(
|
||||||
|
parent=self,
|
||||||
|
relief=None,
|
||||||
|
image=arrowImageList,
|
||||||
|
image_scale=(1, 1, 1),
|
||||||
|
image3_color=Vec4(0.6, 0.6, 0.6, 0.25),
|
||||||
|
pos=(0.2, 0, -0.165),
|
||||||
|
)
|
||||||
|
self.downArrow = DirectButton(
|
||||||
|
parent=self,
|
||||||
|
relief=None,
|
||||||
|
image=arrowImageList,
|
||||||
|
image_scale=(-1, 1, 1),
|
||||||
|
image3_color=Vec4(0.6, 0.6, 0.6, 0.25),
|
||||||
|
pos=(-0.2, 0, -0.165),
|
||||||
|
)
|
||||||
|
buttons.removeNode()
|
||||||
|
arrowGui.removeNode()
|
||||||
|
|
||||||
|
def __bindButtons(self):
|
||||||
|
self.downArrow.bind(DGG.B1PRESS, self.__downButtonDown)
|
||||||
|
self.downArrow.bind(DGG.B1RELEASE, self.__downButtonUp)
|
||||||
|
self.upArrow.bind(DGG.B1PRESS, self.__upButtonDown)
|
||||||
|
self.upArrow.bind(DGG.B1RELEASE, self.__upButtonUp)
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
self.ignoreAll()
|
||||||
|
if self.timer:
|
||||||
|
self.timer.destroy()
|
||||||
|
taskMgr.remove(self.taskName('runCounter'))
|
||||||
|
DirectFrame.destroy(self)
|
||||||
|
|
||||||
|
def __resetTimer(self):
|
||||||
|
if self.timer:
|
||||||
|
self.timer.stop()
|
||||||
|
self.timer.countdown(LaffRestockGlobals.LAFFCLERK_TIMER, self.__timerExpired)
|
||||||
|
|
||||||
|
def __timerExpired(self):
|
||||||
|
self.destroy()
|
||||||
|
messenger.send('guiDone', [True])
|
||||||
|
|
||||||
|
def __cancel(self):
|
||||||
|
self.destroy()
|
||||||
|
messenger.send('guiDone', [False])
|
||||||
|
|
||||||
|
def __requestLaff(self):
|
||||||
|
if self.timer:
|
||||||
|
self.ignoreAll()
|
||||||
|
self.destroy()
|
||||||
|
cost = self.__additionalLaff * ToontownGlobals.CostPerLaffRestock
|
||||||
|
messenger.send('restockLaff', [self.__additionalLaff, cost])
|
||||||
|
messenger.send('guiDone', [False])
|
||||||
|
|
||||||
|
def __updateLaffMeter(self, amt):
|
||||||
|
hitLimit = 0
|
||||||
|
self.__additionalLaff += amt
|
||||||
|
newLaff = self.hp + self.__additionalLaff
|
||||||
|
cost = self.__additionalLaff * ToontownGlobals.CostPerLaffRestock
|
||||||
|
if newLaff <= self.floorLimit:
|
||||||
|
self.downArrow['state'] = DGG.DISABLED
|
||||||
|
hitLimit = 1
|
||||||
|
else:
|
||||||
|
self.downArrow['state'] = DGG.NORMAL
|
||||||
|
if newLaff >= self.maxHp or self.__additionalLaff >= self.ceilLimit:
|
||||||
|
self.upArrow['state'] = DGG.DISABLED
|
||||||
|
hitLimit = 1
|
||||||
|
else:
|
||||||
|
self.upArrow['state'] = DGG.NORMAL
|
||||||
|
self['text'] = TTLocalizer.RestockAskMessage % (self.__additionalLaff, cost)
|
||||||
|
self.laffMeter.hp = newLaff
|
||||||
|
self.laffMeter.start()
|
||||||
|
return (hitLimit, newLaff, self.__additionalLaff)
|
||||||
|
|
||||||
|
def __runCounter(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, laff, trans = self.__updateLaffMeter(task.delta)
|
||||||
|
if hitLimit:
|
||||||
|
return Task.done
|
||||||
|
else:
|
||||||
|
return Task.cont
|
||||||
|
|
||||||
|
def __downButtonUp(self, event):
|
||||||
|
messenger.send('wakeup')
|
||||||
|
taskMgr.remove(self.taskName('runCounter'))
|
||||||
|
|
||||||
|
def __downButtonDown(self, event):
|
||||||
|
messenger.send('wakeup')
|
||||||
|
task = Task(self.__runCounter)
|
||||||
|
task.delayTime = 0.4
|
||||||
|
task.prevTime = 0.0
|
||||||
|
task.delta = -1
|
||||||
|
hitLimit, laff, trans = self.__updateLaffMeter(task.delta)
|
||||||
|
if not hitLimit:
|
||||||
|
taskMgr.add(task, self.taskName('runCounter'))
|
||||||
|
|
||||||
|
def __upButtonUp(self, event):
|
||||||
|
messenger.send('wakeup')
|
||||||
|
taskMgr.remove(self.taskName('runCounter'))
|
||||||
|
|
||||||
|
def __upButtonDown(self, event):
|
||||||
|
messenger.send('wakeup')
|
||||||
|
task = Task(self.__runCounter)
|
||||||
|
task.delayTime = 0.4
|
||||||
|
task.prevTime = 0.0
|
||||||
|
task.delta = 1
|
||||||
|
hitLimit, laff, trans = self.__updateLaffMeter(task.delta)
|
||||||
|
if not hitLimit:
|
||||||
|
taskMgr.add(task, self.taskName('runCounter'))
|
||||||
|
|
|
@ -8449,4 +8449,4 @@ FireTalkMessage = "You're fired!"
|
||||||
RestockFullLaffMessage = "You're already happy!"
|
RestockFullLaffMessage = "You're already happy!"
|
||||||
RestockNoMoneyMessage = "You need more jellybeans to restock your laff!"
|
RestockNoMoneyMessage = "You need more jellybeans to restock your laff!"
|
||||||
RestockLaffMessage = "Have fun!"
|
RestockLaffMessage = "Have fun!"
|
||||||
RestockAskMessage = "Would you like to restock %s laff for %s jellybeans?"
|
RestockAskMessage = "Would you like to\nrestock %s laff for %s jellybeans?"
|
||||||
|
|
Loading…
Reference in a new issue