Confirm dialog for Delete All button

This commit is contained in:
John 2015-08-28 12:00:31 +03:00
parent d906d45312
commit 2662ca6d3f
2 changed files with 26 additions and 6 deletions

View file

@ -7,6 +7,7 @@ from toontown.quest import BlinkingArrows
from direct.interval.IntervalGlobal import * from direct.interval.IntervalGlobal import *
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
from toontown.toonbase import ToontownGlobals from toontown.toonbase import ToontownGlobals
from toontown.toontowngui import TTDialog
from otp.otpbase import OTPGlobals from otp.otpbase import OTPGlobals
class InventoryNew(InventoryBase.InventoryBase, DirectFrame): class InventoryNew(InventoryBase.InventoryBase, DirectFrame):
@ -159,6 +160,8 @@ class InventoryNew(InventoryBase.InventoryBase, DirectFrame):
del self.detailAmountLabel del self.detailAmountLabel
del self.detailDataLabel del self.detailDataLabel
del self.totalLabel del self.totalLabel
self.cleanupDialog()
for row in self.trackRows: for row in self.trackRows:
row.destroy() row.destroy()
@ -172,7 +175,11 @@ class InventoryNew(InventoryBase.InventoryBase, DirectFrame):
del self.buttons del self.buttons
InventoryBase.InventoryBase.unload(self) InventoryBase.InventoryBase.unload(self)
DirectFrame.destroy(self) DirectFrame.destroy(self)
return
def cleanupDialog(self):
if self.dialog:
self.dialog.cleanup()
self.dialog = None
def load(self): def load(self):
self.notify.debug('Loading Inventory for %d' % self.toon.doId) self.notify.debug('Loading Inventory for %d' % self.toon.doId)
@ -200,7 +207,7 @@ class InventoryNew(InventoryBase.InventoryBase, DirectFrame):
trashcanGui = loader.loadModel('phase_3/models/gui/trashcan_gui') trashcanGui = loader.loadModel('phase_3/models/gui/trashcan_gui')
trashcanImage = (trashcanGui.find('**/TrashCan_CLSD'), trashcanGui.find('**/TrashCan_OPEN'), trashcanGui.find('**/TrashCan_RLVR')) trashcanImage = (trashcanGui.find('**/TrashCan_CLSD'), trashcanGui.find('**/TrashCan_OPEN'), trashcanGui.find('**/TrashCan_RLVR'))
self.deleteEnterButton = DirectButton(parent=self.invFrame, image=trashcanImage, text=('', TTLocalizer.InventoryDelete, TTLocalizer.InventoryDelete), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.1, text_pos=(0, -0.1), text_font=getInterfaceFont(), textMayChange=0, relief=None, pos=(-1, 0, -0.35), scale=1.0) self.deleteEnterButton = DirectButton(parent=self.invFrame, image=trashcanImage, text=('', TTLocalizer.InventoryDelete, TTLocalizer.InventoryDelete), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.1, text_pos=(0, -0.1), text_font=getInterfaceFont(), textMayChange=0, relief=None, pos=(-1, 0, -0.35), scale=1.0)
self.deleteAllButton = DirectButton(parent=self.invFrame, image=trashcanImage, text=('', TTLocalizer.InventoryDeleteAll, TTLocalizer.InventoryDeleteAll), text_fg=(1, 0, 0, 1), text_shadow=(1, 1, 1, 1), text_scale=0.1, text_pos=(0, -0.1), text_font=getInterfaceFont(), textMayChange=0, relief=None, pos=(-0.3, 0, -0.91), scale=0.75, command=self.__zeroInvAndUpdate) self.deleteAllButton = DirectButton(parent=self.invFrame, image=trashcanImage, text=('', TTLocalizer.InventoryDeleteAll, TTLocalizer.InventoryDeleteAll), text_fg=(1, 0, 0, 1), text_shadow=(1, 1, 1, 1), text_scale=0.1, text_pos=(0, -0.1), text_font=getInterfaceFont(), textMayChange=0, relief=None, pos=(-0.3, 0, -0.91), scale=0.75, command=self.__zeroInvConfirm)
self.deleteExitButton = DirectButton(parent=self.invFrame, image=(trashcanGui.find('**/TrashCan_OPEN'), trashcanGui.find('**/TrashCan_CLSD'), trashcanGui.find('**/TrashCan_RLVR')), text=('', TTLocalizer.InventoryDone, TTLocalizer.InventoryDone), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.1, text_pos=(0, -0.1), text_font=getInterfaceFont(), textMayChange=0, relief=None, pos=(-1, 0, -0.35), scale=1.0) self.deleteExitButton = DirectButton(parent=self.invFrame, image=(trashcanGui.find('**/TrashCan_OPEN'), trashcanGui.find('**/TrashCan_CLSD'), trashcanGui.find('**/TrashCan_RLVR')), text=('', TTLocalizer.InventoryDone, TTLocalizer.InventoryDone), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.1, text_pos=(0, -0.1), text_font=getInterfaceFont(), textMayChange=0, relief=None, pos=(-1, 0, -0.35), scale=1.0)
trashcanGui.removeNode() trashcanGui.removeNode()
self.deleteHelpText = DirectLabel(parent=self.invFrame, relief=None, pos=(0.272, 0.3, -0.907), text=TTLocalizer.InventoryDeleteHelp, text_fg=(0, 0, 0, 1), text_scale=0.08, textMayChange=0) self.deleteHelpText = DirectLabel(parent=self.invFrame, relief=None, pos=(0.272, 0.3, -0.907), text=TTLocalizer.InventoryDeleteHelp, text_fg=(0, 0, 0, 1), text_scale=0.08, textMayChange=0)
@ -212,6 +219,7 @@ class InventoryNew(InventoryBase.InventoryBase, DirectFrame):
self.detailCreditLabel = DirectLabel(parent=self.detailFrame, text=TTLocalizer.InventorySkillCreditNone, text_fg=(0.05, 0.14, 0.4, 1), scale=0.04, pos=(-0.22, 0, -0.365), text_font=getInterfaceFont(), text_align=TextNode.ALeft, relief=None) self.detailCreditLabel = DirectLabel(parent=self.detailFrame, text=TTLocalizer.InventorySkillCreditNone, text_fg=(0.05, 0.14, 0.4, 1), scale=0.04, pos=(-0.22, 0, -0.365), text_font=getInterfaceFont(), text_align=TextNode.ALeft, relief=None)
self.detailCreditLabel.hide() self.detailCreditLabel.hide()
self.totalLabel = DirectLabel(text='', parent=self.detailFrame, pos=(0, 0, -0.095), scale=0.05, text_fg=(0.05, 0.14, 0.4, 1), text_font=getInterfaceFont(), relief=None) self.totalLabel = DirectLabel(text='', parent=self.detailFrame, pos=(0, 0, -0.095), scale=0.05, text_fg=(0.05, 0.14, 0.4, 1), text_font=getInterfaceFont(), relief=None)
self.dialog = None
self.updateTotalPropsText() self.updateTotalPropsText()
self.trackRows = [] self.trackRows = []
self.trackNameLabels = [] self.trackNameLabels = []
@ -277,9 +285,17 @@ class InventoryNew(InventoryBase.InventoryBase, DirectFrame):
def __handleBackToPlayground(self): def __handleBackToPlayground(self):
messenger.send('inventory-back-to-playground') messenger.send('inventory-back-to-playground')
def __zeroInvAndUpdate(self): def __zeroInvConfirm(self):
self.zeroInv() self.cleanupDialog()
self.updateGUI() self.dialog = TTDialog.TTDialog(style=TTDialog.YesNo, text=TTLocalizer.InventoryDeleteConfirm, command=self.__zeroInvAndUpdate)
self.dialog.show()
def __zeroInvAndUpdate(self, value):
self.cleanupDialog()
if value > 0:
self.zeroInv()
self.updateGUI()
def showDetail(self, track, level, event = None): def showDetail(self, track, level, event = None):
self.totalLabel.hide() self.totalLabel.hide()
@ -391,6 +407,7 @@ class InventoryNew(InventoryBase.InventoryBase, DirectFrame):
self.enableUberGags() self.enableUberGags()
def deactivateButtons(self): def deactivateButtons(self):
self.cleanupDialog()
if self.previousActivateMode == 'purchaseDelete': if self.previousActivateMode == 'purchaseDelete':
self.purchaseDeleteDeactivateButtons() self.purchaseDeleteDeactivateButtons()
elif self.previousActivateMode == 'purchase': elif self.previousActivateMode == 'purchase':
@ -411,6 +428,7 @@ class InventoryNew(InventoryBase.InventoryBase, DirectFrame):
self.plantTreeDeactivateButtons() self.plantTreeDeactivateButtons()
def __activateButtons(self): def __activateButtons(self):
self.cleanupDialog()
if hasattr(self, 'activateMode'): if hasattr(self, 'activateMode'):
if self.activateMode == 'book': if self.activateMode == 'book':
self.bookActivateButtons() self.bookActivateButtons()

View file

@ -3986,7 +3986,6 @@ InventoryPinkSlip = '1 Pink Slip'
InventoryCrateKeys = '%s Crate Keys' InventoryCrateKeys = '%s Crate Keys'
InventoryCrateKey = '1 Crate Key' InventoryCrateKey = '1 Crate Key'
InventoryDelete = 'DELETE' InventoryDelete = 'DELETE'
InventoryDeleteAll = 'DELETE ALL'
InventoryDone = 'DONE' InventoryDone = 'DONE'
InventoryDeleteHelp = 'Click on a gag to DELETE it.' InventoryDeleteHelp = 'Click on a gag to DELETE it.'
InventorySkillCredit = 'Skill credit: %s' InventorySkillCredit = 'Skill credit: %s'
@ -8750,6 +8749,9 @@ TeleportLabelOn = 'Accepting teleports.'
TeleportLabelOff = 'Not accepting teleports.' TeleportLabelOff = 'Not accepting teleports.'
TeleportPanelNoTeleport = '%s needs some time alone right now.' TeleportPanelNoTeleport = '%s needs some time alone right now.'
InventoryDeleteAll = 'DELETE ALL'
InventoryDeleteConfirm = "Are you sure you want to delete all your gags? Don't worry, your level 7 gags are safe!"
Blacklist = [ Blacklist = [
"$1ut", "$1ut",
"$h1t", "$h1t",