mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-23 19:52:37 -06:00
Gifting update!!!
This commit is contained in:
parent
a89e89f99a
commit
61705bbf20
20 changed files with 242 additions and 301 deletions
2
dependencies/astron/dclass/stride.dc
vendored
2
dependencies/astron/dclass/stride.dc
vendored
|
@ -2093,6 +2093,8 @@ dclass DistributedPhone : DistributedFurnitureItem {
|
||||||
requestGiftPurchaseMessage(uint16, uint32, blob, int32) airecv clsend;
|
requestGiftPurchaseMessage(uint16, uint32, blob, int32) airecv clsend;
|
||||||
requestGiftPurchaseResponse(uint16, int8);
|
requestGiftPurchaseResponse(uint16, int8);
|
||||||
purchaseItemComplete();
|
purchaseItemComplete();
|
||||||
|
requestGiftAvatar(uint32) airecv clsend;
|
||||||
|
setGiftAvatar(blob);
|
||||||
};
|
};
|
||||||
|
|
||||||
dclass DistributedFireworkShow : DistributedObject {
|
dclass DistributedFireworkShow : DistributedObject {
|
||||||
|
|
|
@ -230,3 +230,10 @@ WHISPER_COLORS = {
|
||||||
),
|
),
|
||||||
# TODO: WTToontownBoardingGroup
|
# TODO: WTToontownBoardingGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def getFriendColor(handle):
|
||||||
|
if handle.isAdmin():
|
||||||
|
return CCAdmin
|
||||||
|
elif settings['trueFriends'] and base.localAvatar.isTrueFriends(handle.doId):
|
||||||
|
return CCNormal
|
||||||
|
return CCSpeedChat
|
|
@ -64,8 +64,6 @@ class CatalogAccessoryItem(CatalogItem.CatalogItem):
|
||||||
return 1
|
return 1
|
||||||
if avatar.mailboxContents.count(self) != 0:
|
if avatar.mailboxContents.count(self) != 0:
|
||||||
return 1
|
return 1
|
||||||
if self in avatar.awardMailboxContents or self in avatar.onAwardOrder:
|
|
||||||
return 1
|
|
||||||
str = AccessoryTypes[self.accessoryType][ATString]
|
str = AccessoryTypes[self.accessoryType][ATString]
|
||||||
if self.isHat():
|
if self.isHat():
|
||||||
defn = ToonDNA.HatStyles[str]
|
defn = ToonDNA.HatStyles[str]
|
||||||
|
|
|
@ -16,9 +16,7 @@ class CatalogBeanItem(CatalogItem.CatalogItem):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def reachedPurchaseLimit(self, avatar):
|
def reachedPurchaseLimit(self, avatar):
|
||||||
if self in avatar.onOrder or self in avatar.mailboxContents or self in avatar.onGiftOrder or self in avatar.awardMailboxContents or self in avatar.onAwardOrder:
|
return self in avatar.onOrder or self in avatar.mailboxContents or self in avatar.onGiftOrder
|
||||||
return 1
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def getAcceptItemErrorText(self, retcode):
|
def getAcceptItemErrorText(self, retcode):
|
||||||
if retcode == ToontownGlobals.P_ItemAvailable:
|
if retcode == ToontownGlobals.P_ItemAvailable:
|
||||||
|
|
|
@ -15,9 +15,7 @@ class CatalogChatItem(CatalogItem.CatalogItem):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def reachedPurchaseLimit(self, avatar):
|
def reachedPurchaseLimit(self, avatar):
|
||||||
if self in avatar.onOrder or self in avatar.mailboxContents or self in avatar.onGiftOrder or self in avatar.awardMailboxContents or self in avatar.onAwardOrder:
|
return self in avatar.onOrder or self in avatar.mailboxContents or self in avatar.onGiftOrder or avatar.customMessages.count(self.customIndex) != 0
|
||||||
return 1
|
|
||||||
return avatar.customMessages.count(self.customIndex) != 0
|
|
||||||
|
|
||||||
def getTypeName(self):
|
def getTypeName(self):
|
||||||
return TTLocalizer.ChatTypeName
|
return TTLocalizer.ChatTypeName
|
||||||
|
|
|
@ -338,8 +338,6 @@ class CatalogClothingItem(CatalogItem.CatalogItem):
|
||||||
return 1
|
return 1
|
||||||
if avatar.mailboxContents.count(self) != 0:
|
if avatar.mailboxContents.count(self) != 0:
|
||||||
return 1
|
return 1
|
||||||
if self in avatar.awardMailboxContents or self in avatar.onAwardOrder:
|
|
||||||
return 1
|
|
||||||
str = ClothingTypes[self.clothingType][CTString]
|
str = ClothingTypes[self.clothingType][CTString]
|
||||||
dna = avatar.getStyle()
|
dna = avatar.getStyle()
|
||||||
if self.isShirt():
|
if self.isShirt():
|
||||||
|
|
|
@ -17,7 +17,7 @@ class CatalogEmoteItem(CatalogItem.CatalogItem):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def reachedPurchaseLimit(self, avatar):
|
def reachedPurchaseLimit(self, avatar):
|
||||||
if self in avatar.onOrder or self in avatar.mailboxContents or self in avatar.onGiftOrder or self in avatar.awardMailboxContents or self in avatar.onAwardOrder:
|
if self in avatar.onOrder or self in avatar.mailboxContents or self in avatar.onGiftOrder:
|
||||||
return 1
|
return 1
|
||||||
if self.emoteIndex >= len(avatar.emoteAccess):
|
if self.emoteIndex >= len(avatar.emoteAccess):
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -22,11 +22,6 @@ class CatalogGardenItem(CatalogItem.CatalogItem):
|
||||||
else:
|
else:
|
||||||
return 100
|
return 100
|
||||||
|
|
||||||
def reachedPurchaseLimit(self, avatar):
|
|
||||||
if self in avatar.onOrder or self in avatar.mailboxContents or self in avatar.onGiftOrder or self in avatar.awardMailboxContents or self in avatar.onAwardOrder:
|
|
||||||
return 1
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def getAcceptItemErrorText(self, retcode):
|
def getAcceptItemErrorText(self, retcode):
|
||||||
if retcode == ToontownGlobals.P_ItemAvailable:
|
if retcode == ToontownGlobals.P_ItemAvailable:
|
||||||
return TTLocalizer.CatalogAcceptGarden
|
return TTLocalizer.CatalogAcceptGarden
|
||||||
|
|
|
@ -16,9 +16,7 @@ class CatalogGardenStarterItem(CatalogItem.CatalogItem):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def reachedPurchaseLimit(self, avatar):
|
def reachedPurchaseLimit(self, avatar):
|
||||||
if self in avatar.onOrder or self in avatar.mailboxContents or self in avatar.onGiftOrder or self in avatar.awardMailboxContents or self in avatar.onAwardOrder or hasattr(avatar, 'gardenStarted') and avatar.getGardenStarted():
|
return self in avatar.onOrder or self in avatar.mailboxContents or hasattr(avatar, 'gardenStarted') and avatar.getGardenStarted()
|
||||||
return 1
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def saveHistory(self):
|
def saveHistory(self):
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -402,11 +402,10 @@ class CatalogItemPanel(DirectFrame):
|
||||||
'item': self['item'].getName(),
|
'item': self['item'].getName(),
|
||||||
'price': self['item'].getPrice(self['type'])}
|
'price': self['item'].getPrice(self['type'])}
|
||||||
else:
|
else:
|
||||||
friendIndex = self.parentCatalogScreen.friendGiftIndex
|
|
||||||
friendText = 'Error'
|
friendText = 'Error'
|
||||||
numFriends = len(base.localAvatar.friendsList) + len(base.cr.avList) - 1
|
numFriends = len(base.localAvatar.friendsList) + len(base.cr.avList) - 1
|
||||||
if numFriends > 0:
|
if numFriends > 0:
|
||||||
friendText = self.parentCatalogScreen.receiverName
|
friendText = self.parentCatalogScreen.friendName
|
||||||
message = TTLocalizer.CatalogVerifyGift % {'item': self['item'].getName(),
|
message = TTLocalizer.CatalogVerifyGift % {'item': self['item'].getName(),
|
||||||
'price': self['item'].getPrice(self['type']),
|
'price': self['item'].getPrice(self['type']),
|
||||||
'friend': friendText}
|
'friend': friendText}
|
||||||
|
@ -456,8 +455,8 @@ class CatalogItemPanel(DirectFrame):
|
||||||
auxText = TTLocalizer.CatalogNotAGift
|
auxText = TTLocalizer.CatalogNotAGift
|
||||||
self.auxText['text'] = auxText
|
self.auxText['text'] = auxText
|
||||||
return
|
return
|
||||||
elif self.parentCatalogScreen.gotAvatar == 1:
|
elif self.parentCatalogScreen.friend:
|
||||||
avatar = self.parentCatalogScreen.giftAvatar
|
avatar = self.parentCatalogScreen.friend
|
||||||
if self['item'].forBoysOnly() and avatar.getStyle().getGender() == 'f' or self['item'].forGirlsOnly() and avatar.getStyle().getGender() == 'm':
|
if self['item'].forBoysOnly() and avatar.getStyle().getGender() == 'f' or self['item'].forGirlsOnly() and avatar.getStyle().getGender() == 'm':
|
||||||
self.giftButton.show()
|
self.giftButton.show()
|
||||||
self.giftButton['state'] = DGG.DISABLED
|
self.giftButton['state'] = DGG.DISABLED
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
|
||||||
from direct.showbase.DirectObject import DirectObject
|
|
||||||
|
|
||||||
from toontown.catalog import CatalogItem, CatalogItemList
|
|
||||||
|
|
||||||
class CatalogManagerUD(DirectObject):
|
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory('CatalogManagerUD')
|
|
||||||
TIMEOUT = 15
|
|
||||||
|
|
||||||
def __init__(self, air):
|
|
||||||
self.air = air
|
|
||||||
|
|
||||||
self.accept('CATALOG_addGift_AI2UD', self.__handleCatalogAddGift)
|
|
||||||
self.accept('CATALOG_addGift_UD2Toon_resp', self.__handleToonResp)
|
|
||||||
|
|
||||||
self.__context = 0
|
|
||||||
|
|
||||||
def __handleCatalogAddGift(self, avId, blob):
|
|
||||||
ctx = self.__context
|
|
||||||
self.__context += 1
|
|
||||||
self.air.sendNetEvent('CATALOG_addGift_UD2Toon_%d' % avId, [blob, ctx])
|
|
||||||
taskMgr.doMethodLater(self.TIMEOUT, self.__doTimeout, 'catalogMgr-timeout-%d' % ctx, [blob, avId])
|
|
||||||
|
|
||||||
def __handleToonResp(self, avId, ctx):
|
|
||||||
self.notify.info('%d is online, gift deliver order handled by AI' % avId)
|
|
||||||
taskMgr.remove('catalogMgr-timeout-%d' % ctx)
|
|
||||||
|
|
||||||
def __doTimeout(self, blob, avId):
|
|
||||||
self.notify.info('%d is offline, adding order to database' % avId)
|
|
||||||
self.air.dbInterface.queryObject(self.air.dbId, avId, lambda a, b: self.__handleRetrieve(a, b, avId, blob))
|
|
||||||
|
|
||||||
def __handleRetrieve(self, dclass, fields, avId, blob):
|
|
||||||
if dclass != self.air.dclassesByName['DistributedToonUD']:
|
|
||||||
self.notify.warning('Unable to deliver gift: avId is not a DistributedToon!')
|
|
||||||
return
|
|
||||||
|
|
||||||
store = CatalogItem.Customization | CatalogItem.DeliveryDate
|
|
||||||
giftOnOrder = CatalogItemList.CatalogItemList(fields.get('setGiftSchedule', [''])[0], store=store)
|
|
||||||
giftOnOrder.append(CatalogItem.getItem(blob, store=store | CatalogItem.GiftTag))
|
|
||||||
fields['setGiftSchedule'] = (giftOnOrder.getBlob(store=store),)
|
|
||||||
|
|
||||||
self.air.dbInterface.updateObject(self.air.dbId, avId, self.air.dclassesByName['DistributedToonUD'], fields)
|
|
||||||
self.notify.info('Successfully delivered gift to %d' % avId)
|
|
|
@ -17,7 +17,7 @@ class CatalogNametagItem(CatalogItem.CatalogItem):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def reachedPurchaseLimit(self, avatar):
|
def reachedPurchaseLimit(self, avatar):
|
||||||
if self in avatar.onOrder or self in avatar.mailboxContents or self in avatar.onGiftOrder or self in avatar.awardMailboxContents or self in avatar.onAwardOrder:
|
if self in avatar.onOrder or self in avatar.mailboxContents or self in avatar.onGiftOrder:
|
||||||
return 1
|
return 1
|
||||||
if avatar.nametagStyle == self.nametagStyle:
|
if avatar.nametagStyle == self.nametagStyle:
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -17,7 +17,7 @@ class CatalogPetTrickItem(CatalogItem.CatalogItem):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def reachedPurchaseLimit(self, avatar):
|
def reachedPurchaseLimit(self, avatar):
|
||||||
if self in avatar.onOrder or self in avatar.mailboxContents or self in avatar.onGiftOrder or self in avatar.awardMailboxContents or self in avatar.onAwardOrder or not hasattr(avatar, 'petTrickPhrases'):
|
if self in avatar.onOrder or self in avatar.mailboxContents or self in avatar.onGiftOrder or not hasattr(avatar, 'petTrickPhrases'):
|
||||||
return 1
|
return 1
|
||||||
return self.trickId in avatar.petTrickPhrases
|
return self.trickId in avatar.petTrickPhrases
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,7 @@ class CatalogRentalItem(CatalogItem.CatalogItem):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def reachedPurchaseLimit(self, avatar):
|
def reachedPurchaseLimit(self, avatar):
|
||||||
if self in avatar.onOrder or self in avatar.mailboxContents or self in avatar.onGiftOrder or self in avatar.awardMailboxContents or self in avatar.onAwardOrder:
|
return self in avatar.onOrder or self in avatar.mailboxContents or self in avatar.onGiftOrder
|
||||||
return 1
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def saveHistory(self):
|
def saveHistory(self):
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -15,7 +15,7 @@ import random
|
||||||
from toontown.toon import DistributedToon
|
from toontown.toon import DistributedToon
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
from otp.nametag.ChatBalloon import ChatBalloon
|
from otp.nametag.ChatBalloon import ChatBalloon
|
||||||
from otp.nametag import NametagGroup
|
from otp.nametag import NametagGroup, NametagConstants
|
||||||
|
|
||||||
NUM_CATALOG_ROWS = 3
|
NUM_CATALOG_ROWS = 3
|
||||||
NUM_CATALOG_COLS = 2
|
NUM_CATALOG_COLS = 2
|
||||||
|
@ -31,6 +31,7 @@ class CatalogScreen(DirectFrame):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory('CatalogScreen')
|
notify = DirectNotifyGlobal.directNotify.newCategory('CatalogScreen')
|
||||||
|
|
||||||
def __init__(self, parent = aspect2d, **kw):
|
def __init__(self, parent = aspect2d, **kw):
|
||||||
|
self.gifting = -1
|
||||||
guiItems = loader.loadModel('phase_5.5/models/gui/catalog_gui')
|
guiItems = loader.loadModel('phase_5.5/models/gui/catalog_gui')
|
||||||
background = guiItems.find('**/catalog_background')
|
background = guiItems.find('**/catalog_background')
|
||||||
background.setBin("background", 10)
|
background.setBin("background", 10)
|
||||||
|
@ -44,19 +45,11 @@ class CatalogScreen(DirectFrame):
|
||||||
('relief', None, None))
|
('relief', None, None))
|
||||||
self.defineoptions(kw, optiondefs)
|
self.defineoptions(kw, optiondefs)
|
||||||
DirectFrame.__init__(self, parent)
|
DirectFrame.__init__(self, parent)
|
||||||
self.friendGiftIndex = 0
|
self.friend = None
|
||||||
self.friendGiftHandle = None
|
self.friendAvId = None
|
||||||
self.frienddoId = None
|
self.friendName = 'Error Nameless Toon'
|
||||||
self.receiverName = 'Error Nameless Toon'
|
self.friendList = []
|
||||||
self.friends = {}
|
self.friends = []
|
||||||
self.family = {}
|
|
||||||
self.ffList = []
|
|
||||||
self.textRolloverColor = Vec4(1, 1, 0, 1)
|
|
||||||
self.textDownColor = Vec4(0.5, 0.9, 1, 1)
|
|
||||||
self.textDisabledColor = Vec4(0.4, 0.8, 0.4, 1)
|
|
||||||
self.giftAvatar = None
|
|
||||||
self.gotAvatar = 0
|
|
||||||
self.allowGetDetails = 1
|
|
||||||
self.load(guiItems, guiButton, guiBack)
|
self.load(guiItems, guiButton, guiBack)
|
||||||
self.initialiseoptions(CatalogScreen)
|
self.initialiseoptions(CatalogScreen)
|
||||||
self.enableBackorderCatalogButton()
|
self.enableBackorderCatalogButton()
|
||||||
|
@ -66,10 +59,8 @@ class CatalogScreen(DirectFrame):
|
||||||
self.hide()
|
self.hide()
|
||||||
self.clarabelleChatNP = None
|
self.clarabelleChatNP = None
|
||||||
self.clarabelleChatBalloon = None
|
self.clarabelleChatBalloon = None
|
||||||
self.gifting = -1
|
|
||||||
self.createdGiftGui = None
|
self.createdGiftGui = None
|
||||||
self.viewing = None
|
self.viewing = None
|
||||||
return
|
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
self.accept('CatalogItemPurchaseRequest', self.__handlePurchaseRequest)
|
self.accept('CatalogItemPurchaseRequest', self.__handlePurchaseRequest)
|
||||||
|
@ -91,10 +82,6 @@ class CatalogScreen(DirectFrame):
|
||||||
|
|
||||||
taskMgr.doMethodLater(1.0, clarabelleGreeting, 'clarabelleGreeting')
|
taskMgr.doMethodLater(1.0, clarabelleGreeting, 'clarabelleGreeting')
|
||||||
taskMgr.doMethodLater(12.0, clarabelleHelpText1, 'clarabelleHelpText1')
|
taskMgr.doMethodLater(12.0, clarabelleHelpText1, 'clarabelleHelpText1')
|
||||||
if hasattr(self, 'giftToggle'):
|
|
||||||
self.giftToggle['state'] = DGG.DISABLED
|
|
||||||
self.giftToggle['text'] = TTLocalizer.CatalogGiftToggleWait
|
|
||||||
self.__handleUDack()
|
|
||||||
|
|
||||||
def hide(self):
|
def hide(self):
|
||||||
self.ignore('CatalogItemPurchaseRequest')
|
self.ignore('CatalogItemPurchaseRequest')
|
||||||
|
@ -544,16 +531,15 @@ class CatalogScreen(DirectFrame):
|
||||||
-2.0,
|
-2.0,
|
||||||
-1.45), image_scale=(1.0, 1.0, smash), image_pos=(0.0, 0.0, -1.9 + lift), image=backDown, pressEffect=0, command=self.showEmblemItems, text=TTLocalizer.CatalogEmblem, text_font=ToontownGlobals.getSignFont(), text_pos=(1.75, 0.132), text_scale=0.065, text_fg=(0.353, 0.627, 0.627, 1.0), text2_fg=(0.353, 0.427, 0.427, 1.0))
|
-1.45), image_scale=(1.0, 1.0, smash), image_pos=(0.0, 0.0, -1.9 + lift), image=backDown, pressEffect=0, command=self.showEmblemItems, text=TTLocalizer.CatalogEmblem, text_font=ToontownGlobals.getSignFont(), text_pos=(1.75, 0.132), text_scale=0.065, text_fg=(0.353, 0.627, 0.627, 1.0), text2_fg=(0.353, 0.427, 0.427, 1.0))
|
||||||
self.emblemCatalogButton2.hide()
|
self.emblemCatalogButton2.hide()
|
||||||
self.__makeFFlist()
|
self.__makeFriendList()
|
||||||
print self.ffList
|
if len(self.friendList) > 0:
|
||||||
if len(self.ffList) > 0:
|
|
||||||
if config.GetBool('want-gifting', True):
|
if config.GetBool('want-gifting', True):
|
||||||
self.giftToggle = DirectButton(self.base, relief=None, pressEffect=0, image=(giftToggleUp, giftToggleDown, giftToggleUp), image_scale=(1.0, 1, 0.7), command=self.__giftToggle, text=TTLocalizer.CatalogGiftToggleOff, text_font=ToontownGlobals.getSignFont(), text_pos=TTLocalizer.CSgiftTogglePos, text_scale=TTLocalizer.CSgiftToggle, text_fg=(0.353, 0.627, 0.627, 1.0), text3_fg=(0.15, 0.3, 0.3, 1.0), text2_fg=(0.353, 0.427, 0.427, 1.0), image_color=Vec4(1.0, 1.0, 0.2, 1.0), image1_color=Vec4(0.9, 0.85, 0.2, 1.0), image2_color=Vec4(0.9, 0.85, 0.2, 1.0), image3_color=Vec4(0.5, 0.45, 0.2, 1.0))
|
self.giftToggle = DirectButton(self.base, relief=None, pressEffect=0, image=(giftToggleUp, giftToggleDown, giftToggleUp), image_scale=(1.0, 1, 0.7), command=self.__giftToggle, text=TTLocalizer.CatalogGiftToggleOff, text_font=ToontownGlobals.getSignFont(), text_pos=TTLocalizer.CSgiftTogglePos, text_scale=TTLocalizer.CSgiftToggle, text_fg=(0.353, 0.627, 0.627, 1.0), text3_fg=(0.15, 0.3, 0.3, 1.0), text2_fg=(0.353, 0.427, 0.427, 1.0), image_color=Vec4(1.0, 1.0, 0.2, 1.0), image1_color=Vec4(0.9, 0.85, 0.2, 1.0), image2_color=Vec4(0.9, 0.85, 0.2, 1.0), image3_color=Vec4(0.5, 0.45, 0.2, 1.0))
|
||||||
self.giftToggle.setPos(0.0, 0, -0.035)
|
self.giftToggle.setPos(0.0, 0, -0.035)
|
||||||
self.giftLabel = DirectLabel(self.base, relief=None, image=giftFriends, image_scale=(1.15, 1, 1.14), text=' ', text_font=ToontownGlobals.getSignFont(), text_pos=(1.2, -0.97), text_scale=0.07, text_fg=(0.392, 0.549, 0.627, 1.0), sortOrder=100, textMayChange=1)
|
self.giftLabel = DirectLabel(self.base, relief=None, image=giftFriends, image_scale=(1.15, 1, 1.14), text=' ', text_font=ToontownGlobals.getSignFont(), text_pos=(1.2, -0.97), text_scale=0.07, text_fg=(0.392, 0.549, 0.627, 1.0), sortOrder=100, textMayChange=1)
|
||||||
self.giftLabel.setPos(-0.15, 0, 0.08)
|
self.giftLabel.setPos(-0.15, 0, 0.08)
|
||||||
self.giftLabel.hide()
|
self.giftLabel.hide()
|
||||||
self.friendLabel = DirectLabel(self.base, relief=None, text='Friend Name', text_font=ToontownGlobals.getSignFont(), text_pos=(-0.25, 0.132), text_scale=0.068, text_align=TextNode.ALeft, text_fg=(0.992, 0.949, 0.327, 1.0), sortOrder=100, textMayChange=1)
|
self.friendLabel = DirectLabel(self.base, relief=None, text=TTLocalizer.CatalogGiftChoose, text_font=ToontownGlobals.getSignFont(), text_pos=(-0.25, 0.132), text_scale=0.068, text_align=TextNode.ALeft, text_fg=(0.992, 0.949, 0.327, 1.0), sortOrder=100, textMayChange=1)
|
||||||
self.friendLabel.setPos(0.5, 0, -0.42)
|
self.friendLabel.setPos(0.5, 0, -0.42)
|
||||||
self.friendLabel.hide()
|
self.friendLabel.hide()
|
||||||
gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui')
|
gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui')
|
||||||
|
@ -572,9 +558,6 @@ class CatalogScreen(DirectFrame):
|
||||||
clipNP = self.scrollList.attachNewNode(clipper)
|
clipNP = self.scrollList.attachNewNode(clipper)
|
||||||
self.scrollList.setClipPlane(clipNP)
|
self.scrollList.setClipPlane(clipNP)
|
||||||
self.__makeScrollList()
|
self.__makeScrollList()
|
||||||
friendId = self.ffList[0]
|
|
||||||
self.__chooseFriend(self.ffList[0][0], self.ffList[0][1])
|
|
||||||
self.update()
|
|
||||||
self.createdGiftGui = 1
|
self.createdGiftGui = 1
|
||||||
for i in xrange(4):
|
for i in xrange(4):
|
||||||
self.newCatalogButton.component('text%d' % i).setR(90)
|
self.newCatalogButton.component('text%d' % i).setR(90)
|
||||||
|
@ -831,8 +814,6 @@ class CatalogScreen(DirectFrame):
|
||||||
taskMgr.remove('clarabelleGreeting')
|
taskMgr.remove('clarabelleGreeting')
|
||||||
taskMgr.remove('clarabelleHelpText1')
|
taskMgr.remove('clarabelleHelpText1')
|
||||||
taskMgr.remove('clarabelleAskAnythingElse')
|
taskMgr.remove('clarabelleAskAnythingElse')
|
||||||
if self.giftAvatar:
|
|
||||||
base.cr.cancelAvatarDetailsRequest(self.giftAvatar)
|
|
||||||
self.hide()
|
self.hide()
|
||||||
self.hangup.hide()
|
self.hangup.hide()
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
@ -864,16 +845,12 @@ class CatalogScreen(DirectFrame):
|
||||||
del self.giftLabel
|
del self.giftLabel
|
||||||
del self.friendLabel
|
del self.friendLabel
|
||||||
del self.scrollList
|
del self.scrollList
|
||||||
|
del self.friend
|
||||||
|
del self.friends
|
||||||
self.unloadClarabelle()
|
self.unloadClarabelle()
|
||||||
if self.responseDialog:
|
if self.responseDialog:
|
||||||
self.responseDialog.cleanup()
|
self.responseDialog.cleanup()
|
||||||
self.responseDialog = None
|
self.responseDialog = None
|
||||||
if self.giftAvatar:
|
|
||||||
if hasattr(self.giftAvatar, 'doId'):
|
|
||||||
self.giftAvatar.delete()
|
|
||||||
else:
|
|
||||||
self.giftAvatar = None
|
|
||||||
return
|
|
||||||
|
|
||||||
def unloadClarabelle(self):
|
def unloadClarabelle(self):
|
||||||
base.win.removeDisplayRegion(self.cDr)
|
base.win.removeDisplayRegion(self.cDr)
|
||||||
|
@ -891,8 +868,6 @@ class CatalogScreen(DirectFrame):
|
||||||
del self.clarabelleChatBalloon
|
del self.clarabelleChatBalloon
|
||||||
|
|
||||||
def hangUp(self):
|
def hangUp(self):
|
||||||
if hasattr(self, 'giftAvatar') and self.giftAvatar:
|
|
||||||
self.giftAvatar.disable()
|
|
||||||
self.setClarabelleChat(random.choice(TTLocalizer.CatalogGoodbyeList), type='goodbye')
|
self.setClarabelleChat(random.choice(TTLocalizer.CatalogGoodbyeList), type='goodbye')
|
||||||
self.setPageIndex(-1)
|
self.setPageIndex(-1)
|
||||||
self.showPageItems()
|
self.showPageItems()
|
||||||
|
@ -921,9 +896,8 @@ class CatalogScreen(DirectFrame):
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def update(self, task = None):
|
def update(self, task = None):
|
||||||
if not hasattr(self.giftAvatar, 'doId'):
|
if (not self.friend) and self.gifting == 1:
|
||||||
if self.gifting == 1:
|
self.__giftToggle()
|
||||||
self.__giftToggle()
|
|
||||||
if hasattr(self, 'beanBank'):
|
if hasattr(self, 'beanBank'):
|
||||||
self.beanBank['text'] = str(base.localAvatar.getTotalMoney())
|
self.beanBank['text'] = str(base.localAvatar.getTotalMoney())
|
||||||
for item in self.panelList + self.backPanelList + self.specialPanelList + self.emblemPanelList:
|
for item in self.panelList + self.backPanelList + self.specialPanelList + self.emblemPanelList:
|
||||||
|
@ -935,7 +909,7 @@ class CatalogScreen(DirectFrame):
|
||||||
taskMgr.remove('clarabelleAskAnythingElse')
|
taskMgr.remove('clarabelleAskAnythingElse')
|
||||||
|
|
||||||
def __handleGiftPurchaseRequest(self, item):
|
def __handleGiftPurchaseRequest(self, item):
|
||||||
item.requestGiftPurchase(self['phone'], self.frienddoId, self.__handleGiftPurchaseResponse)
|
item.requestGiftPurchase(self['phone'], self.friendAvId, self.__handleGiftPurchaseResponse)
|
||||||
taskMgr.remove('clarabelleAskAnythingElse')
|
taskMgr.remove('clarabelleAskAnythingElse')
|
||||||
|
|
||||||
def __handlePurchaseResponse(self, retCode, item):
|
def __handlePurchaseResponse(self, retCode, item):
|
||||||
|
@ -954,7 +928,7 @@ class CatalogScreen(DirectFrame):
|
||||||
return
|
return
|
||||||
if self.isEmpty() or self.isHidden():
|
if self.isEmpty() or self.isHidden():
|
||||||
return
|
return
|
||||||
self.setClarabelleChat(item.getRequestGiftPurchaseErrorText(retCode) % self.receiverName)
|
self.setClarabelleChat(item.getRequestGiftPurchaseErrorText(retCode) % self.friendName)
|
||||||
self.__loadFriend()
|
self.__loadFriend()
|
||||||
|
|
||||||
def askAnythingElse(task):
|
def askAnythingElse(task):
|
||||||
|
@ -1010,85 +984,56 @@ class CatalogScreen(DirectFrame):
|
||||||
self.silverLabel.hide()
|
self.silverLabel.hide()
|
||||||
self.goldLabel.hide()
|
self.goldLabel.hide()
|
||||||
|
|
||||||
def checkFamily(self, doId):
|
def __makeFriendList(self):
|
||||||
test = 0
|
for av in base.cr.avList:
|
||||||
for familyMember in base.cr.avList:
|
if av.id != base.localAvatar.doId:
|
||||||
if familyMember.id == doId:
|
self.friendList.append((av.id, av.name, NametagGroup.CCNonPlayer))
|
||||||
test = 1
|
|
||||||
|
|
||||||
return test
|
|
||||||
|
|
||||||
def __makeFFlist(self):
|
|
||||||
for familyMember in base.cr.avList:
|
|
||||||
if familyMember.id != base.localAvatar.doId:
|
|
||||||
newFF = (familyMember.id, familyMember.name, NametagGroup.CCNonPlayer)
|
|
||||||
self.ffList.append(newFF)
|
|
||||||
|
|
||||||
for id, handle in base.cr.friendsMap.items():
|
for id, handle in base.cr.friendsMap.items():
|
||||||
if isinstance(handle, FriendHandle.FriendHandle):
|
if isinstance(handle, FriendHandle.FriendHandle):
|
||||||
self.ffList.append((id, handle.getName(), None))#NametagGlobals.getFriendColor(handle)))
|
self.friendList.append((id, handle.getName(), NametagConstants.getFriendColor(handle)))
|
||||||
|
|
||||||
def __makeScrollList(self):
|
def __makeScrollList(self):
|
||||||
for ff in self.ffList:
|
for friend in self.friendList:
|
||||||
ffbutton = self.makeFamilyButton(ff[0], ff[1], ff[2])
|
button = self.makeFriendButton(*friend)
|
||||||
if ffbutton:
|
self.scrollList.addItem(button, refresh=0)
|
||||||
self.scrollList.addItem(ffbutton, refresh=0)
|
self.friends.append(button)
|
||||||
self.friends[ff] = ffbutton
|
|
||||||
|
|
||||||
self.scrollList.refresh()
|
self.scrollList.refresh()
|
||||||
|
|
||||||
def makeFamilyButton(self, familyId, familyName, colorCode):
|
def makeFriendButton(self, avId, name, colorCode):
|
||||||
# fg = NametagGlobals.getNameFg(colorCode, PGButton.SInactive)
|
color = NametagConstants.NAMETAG_COLORS[colorCode]
|
||||||
return DirectButton(
|
|
||||||
relief=None,
|
|
||||||
text=familyName,
|
|
||||||
text_scale=0.04,
|
|
||||||
text_align=TextNode.ALeft,
|
|
||||||
# text_fg=fg,
|
|
||||||
text1_bg=self.textDownColor,
|
|
||||||
text2_bg=self.textRolloverColor,
|
|
||||||
text3_fg=self.textDisabledColor,
|
|
||||||
textMayChange=0,
|
|
||||||
command=self.__chooseFriend,
|
|
||||||
extraArgs=[familyId, familyName]
|
|
||||||
)
|
|
||||||
|
|
||||||
def __chooseFriend(self, friendId, friendName):
|
return DirectButton(relief=None, text=name, text_scale=0.04, text_align=TextNode.ALeft, text_fg=color[0][0], text1_bg=(1, 1, 0, 1),
|
||||||
|
text2_bg=(0.5, 0.9, 1, 1), text3_fg=(0.4, 0.8, 0.4, 1), command=self.__chooseFriend, extraArgs=[avId, name])
|
||||||
|
|
||||||
|
def __chooseFriend(self, avId, name):
|
||||||
messenger.send('wakeup')
|
messenger.send('wakeup')
|
||||||
self.frienddoId = friendId
|
|
||||||
self.receiverName = friendName
|
if self.friendAvId == avId:
|
||||||
self.friendLabel['text'] = TTLocalizer.CatalogGiftTo % self.receiverName
|
return
|
||||||
|
|
||||||
|
self.friendAvId = avId
|
||||||
|
self.friendName = name
|
||||||
self.__loadFriend()
|
self.__loadFriend()
|
||||||
|
|
||||||
def __loadFriend(self):
|
def __loadFriend(self):
|
||||||
if self.allowGetDetails == 0:
|
if not self.friendAvId:
|
||||||
CatalogScreen.notify.warning('smashing requests')
|
|
||||||
if self.frienddoId and self.allowGetDetails:
|
|
||||||
if self.giftAvatar:
|
|
||||||
if hasattr(self.giftAvatar, 'doId'):
|
|
||||||
self.giftAvatar.disable()
|
|
||||||
self.giftAvatar.delete()
|
|
||||||
self.giftAvatar = None
|
|
||||||
self.giftAvatar = DistributedToon.DistributedToon(base.cr)
|
|
||||||
self.giftAvatar.doId = self.frienddoId
|
|
||||||
self.giftAvatar.forceAllowDelayDelete()
|
|
||||||
self.giftAvatar.generate()
|
|
||||||
base.cr.getAvatarDetails(self.giftAvatar, self.__handleAvatarDetails, 'DistributedToon')
|
|
||||||
self.gotAvatar = 0
|
|
||||||
self.allowGetDetails = 0
|
|
||||||
self.scrollList['state'] = DGG.DISABLED
|
|
||||||
return
|
|
||||||
|
|
||||||
def __handleAvatarDetails(self, gotData, avatar, dclass):
|
|
||||||
if self.giftAvatar.doId != avatar.doId or gotData == 0:
|
|
||||||
CatalogScreen.notify.error('Get Gift Avatar Failed')
|
|
||||||
self.gotAvatar = 0
|
|
||||||
return
|
return
|
||||||
else:
|
|
||||||
self.gotAvatar = 1
|
for friendButton in self.friends:
|
||||||
self.giftAvatar = avatar
|
friendButton['state'] = DGG.DISABLED
|
||||||
self.scrollList['state'] = DGG.NORMAL
|
|
||||||
self.allowGetDetails = 1
|
self.friend = None
|
||||||
|
self.friendLabel['text'] = TTLocalizer.CatalogGiftUpdating
|
||||||
|
self['phone'].requestGiftAvatar(self.friendAvId)
|
||||||
|
|
||||||
|
def setFriendReady(self, friend):
|
||||||
|
for friendButton in self.friends:
|
||||||
|
friendButton['state'] = DGG.NORMAL
|
||||||
|
|
||||||
|
self.friend = friend
|
||||||
|
self.friendLabel['text'] = TTLocalizer.CatalogGiftTo % self.friendName
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def __giftToggle(self):
|
def __giftToggle(self):
|
||||||
|
@ -1102,20 +1047,13 @@ class CatalogScreen(DirectFrame):
|
||||||
self.giftToggle['text'] = TTLocalizer.CatalogGiftToggleOn
|
self.giftToggle['text'] = TTLocalizer.CatalogGiftToggleOn
|
||||||
self.__loadFriend()
|
self.__loadFriend()
|
||||||
else:
|
else:
|
||||||
|
self.friend = None
|
||||||
|
self.friendAvId = 0
|
||||||
|
self.friendName = None
|
||||||
self.gifting = -1
|
self.gifting = -1
|
||||||
self.giftLabel.hide()
|
self.giftLabel.hide()
|
||||||
self.friendLabel.hide()
|
self.friendLabel.hide()
|
||||||
self.scrollList.hide()
|
self.scrollList.hide()
|
||||||
self.showEmblems()
|
self.showEmblems()
|
||||||
self.giftToggle['text'] = TTLocalizer.CatalogGiftToggleOff
|
self.giftToggle['text'] = TTLocalizer.CatalogGiftToggleOff
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def __handleUDack(self, caller = None):
|
|
||||||
taskMgr.remove('ackTimeOut')
|
|
||||||
if hasattr(self, 'giftToggle') and self.giftToggle:
|
|
||||||
self.giftToggle['state'] = DGG.NORMAL
|
|
||||||
self.giftToggle['text'] = TTLocalizer.CatalogGiftToggleOff
|
|
||||||
|
|
||||||
def __handleNoAck(self, caller = None):
|
|
||||||
if hasattr(self, 'giftToggle') and self.giftToggle:
|
|
||||||
self.giftToggle['text'] = TTLocalizer.CatalogGiftToggleNoAck
|
|
|
@ -2,6 +2,7 @@ from toontown.toonbase import ToontownGlobals
|
||||||
import PhoneGlobals
|
import PhoneGlobals
|
||||||
from toontown.catalog import CatalogScreen
|
from toontown.catalog import CatalogScreen
|
||||||
from toontown.catalog import CatalogItem
|
from toontown.catalog import CatalogItem
|
||||||
|
from toontown.catalog import GiftAvatar
|
||||||
from toontown.toontowngui import TTDialog
|
from toontown.toontowngui import TTDialog
|
||||||
from toontown.toonbase import TTLocalizer
|
from toontown.toonbase import TTLocalizer
|
||||||
import DistributedHouseInterior
|
import DistributedHouseInterior
|
||||||
|
@ -13,7 +14,6 @@ from direct.showutil import Rope
|
||||||
from direct.directnotify.DirectNotifyGlobal import *
|
from direct.directnotify.DirectNotifyGlobal import *
|
||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
from direct.interval.IntervalGlobal import *
|
from direct.interval.IntervalGlobal import *
|
||||||
import string
|
|
||||||
from toontown.quest import Quests
|
from toontown.quest import Quests
|
||||||
from direct.task import Task
|
from direct.task import Task
|
||||||
|
|
||||||
|
@ -274,7 +274,6 @@ class DistributedPhone(DistributedFurnitureItem.DistributedFurnitureItem):
|
||||||
self.sendUpdate('requestPurchaseMessage', [context, blob, optional])
|
self.sendUpdate('requestPurchaseMessage', [context, blob, optional])
|
||||||
|
|
||||||
def requestGiftPurchase(self, item, targetDoID, callback, optional = -1):
|
def requestGiftPurchase(self, item, targetDoID, callback, optional = -1):
|
||||||
print 'in the client phone'
|
|
||||||
blob = item.getBlob(store=CatalogItem.Customization)
|
blob = item.getBlob(store=CatalogItem.Customization)
|
||||||
context = self.getCallbackContext(callback, [item])
|
context = self.getCallbackContext(callback, [item])
|
||||||
self.sendUpdate('requestGiftPurchaseMessage', [context, targetDoID, blob, optional])
|
self.sendUpdate('requestGiftPurchaseMessage', [context, targetDoID, blob, optional])
|
||||||
|
@ -382,3 +381,15 @@ class DistributedPhone(DistributedFurnitureItem.DistributedFurnitureItem):
|
||||||
ringIval = Parallel(Func(base.playSfx, self.ringSfx), shakeSeq, Func(phone.setR, 0))
|
ringIval = Parallel(Func(base.playSfx, self.ringSfx), shakeSeq, Func(phone.setR, 0))
|
||||||
self.playInterval(ringIval, 0.0, None)
|
self.playInterval(ringIval, 0.0, None)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def requestGiftAvatar(self, doId):
|
||||||
|
if not self.phoneGui:
|
||||||
|
return
|
||||||
|
|
||||||
|
self.sendUpdate('requestGiftAvatar', [doId])
|
||||||
|
|
||||||
|
def setGiftAvatar(self, fields):
|
||||||
|
if not self.phoneGui:
|
||||||
|
return
|
||||||
|
|
||||||
|
self.phoneGui.setFriendReady(GiftAvatar.createFromJson(fields))
|
|
@ -4,20 +4,53 @@ from toontown.estate.DistributedFurnitureItemAI import DistributedFurnitureItemA
|
||||||
from PhoneGlobals import *
|
from PhoneGlobals import *
|
||||||
|
|
||||||
from toontown.toonbase import ToontownGlobals
|
from toontown.toonbase import ToontownGlobals
|
||||||
from toontown.catalog import CatalogItem, CatalogInvalidItem
|
from toontown.catalog import CatalogItem, CatalogInvalidItem, GiftAvatar
|
||||||
from toontown.catalog.CatalogItemList import CatalogItemList
|
from toontown.catalog.CatalogItemList import CatalogItemList
|
||||||
from toontown.uberdog import TopToonsGlobals
|
from toontown.uberdog import TopToonsGlobals
|
||||||
|
|
||||||
|
import base64
|
||||||
|
import json
|
||||||
import time
|
import time
|
||||||
|
|
||||||
MAX_MAILBOX = 10
|
MAX_MAILBOX = 10
|
||||||
MAX_ON_ORDER = 10
|
MAX_ON_ORDER = 10
|
||||||
|
|
||||||
|
class LoadGiftAvatar:
|
||||||
|
|
||||||
|
def __init__(self, phone, avId, targetId, optional, callback):
|
||||||
|
self.air = phone.air
|
||||||
|
self.phone = phone
|
||||||
|
self.avId = avId
|
||||||
|
self.targetId = targetId
|
||||||
|
self.optional = optional
|
||||||
|
self.callback = callback
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
self.air.dbInterface.queryObject(self.air.dbId, self.targetId, self.__gotAvatar)
|
||||||
|
|
||||||
|
def copyDict(self, dict, *keys):
|
||||||
|
return {key: dict[key] for key in keys}
|
||||||
|
|
||||||
|
def __gotAvatar(self, dclass, fields):
|
||||||
|
if dclass != self.air.dclassesByName['DistributedToonAI']:
|
||||||
|
return
|
||||||
|
|
||||||
|
for key in ('setDNAString', 'setMailboxContents', 'setGiftSchedule', 'setDeliverySchedule'):
|
||||||
|
fields[key] = base64.b64encode(fields[key][0])
|
||||||
|
|
||||||
|
newDict = self.copyDict(fields, 'setDNAString', 'setMailboxContents', 'setGiftSchedule', 'setDeliverySchedule', 'setHat', 'setGlasses', 'setBackpack',
|
||||||
|
'setShoes', 'setHatList', 'setGlassesList', 'setBackpackList', 'setShoes', 'setShoesList', 'setCustomMessages', 'setEmoteAccess',
|
||||||
|
'setClothesTopsList', 'setClothesBottomsList', 'setPetTrickPhrases')
|
||||||
|
|
||||||
|
self.callback(self.avId, self.targetId, newDict, self.optional)
|
||||||
|
del self.phone.fsms[self.avId]
|
||||||
|
|
||||||
class DistributedPhoneAI(DistributedFurnitureItemAI):
|
class DistributedPhoneAI(DistributedFurnitureItemAI):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedPhoneAI")
|
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedPhoneAI")
|
||||||
|
|
||||||
def __init__(self, air, furnitureMgr, catalogItem):
|
def __init__(self, air, furnitureMgr, catalogItem):
|
||||||
DistributedFurnitureItemAI.__init__(self, air, furnitureMgr, catalogItem)
|
DistributedFurnitureItemAI.__init__(self, air, furnitureMgr, catalogItem)
|
||||||
|
self.fsms = {}
|
||||||
self.initialScale = (0.8, 0.8, 0.8)
|
self.initialScale = (0.8, 0.8, 0.8)
|
||||||
self.inUse = False
|
self.inUse = False
|
||||||
self.currAvId = 0
|
self.currAvId = 0
|
||||||
|
@ -100,111 +133,135 @@ class DistributedPhoneAI(DistributedFurnitureItemAI):
|
||||||
return
|
return
|
||||||
|
|
||||||
return av
|
return av
|
||||||
|
|
||||||
|
def checkPurchaseLimit(self, recipient, item):
|
||||||
|
if len(recipient.onOrder) >= MAX_ON_ORDER:
|
||||||
|
return ToontownGlobals.P_ReachedPurchaseLimit
|
||||||
|
elif len(recipient.mailboxContents) >= MAX_MAILBOX:
|
||||||
|
return ToontownGlobals.P_MailboxFull
|
||||||
|
elif item.reachedPurchaseLimit(recipient):
|
||||||
|
return ToontownGlobals.P_ReachedPurchaseLimit
|
||||||
|
|
||||||
def attemptPurchase(self, avBuying, recepient, blob, optional, payMethod, gifting=False):
|
return ToontownGlobals.P_ItemOnOrder
|
||||||
avId = avBuying.doId
|
|
||||||
|
def chargeAvatar(self, av, money, emblems):
|
||||||
|
av.takeMoney(money)
|
||||||
|
av.subtractEmblems(emblems)
|
||||||
|
|
||||||
|
def attemptPurchase(self, context, av, blob, optional, gifting=False):
|
||||||
|
avId = av.doId
|
||||||
item = CatalogItem.getItem(blob, CatalogItem.Customization)
|
item = CatalogItem.getItem(blob, CatalogItem.Customization)
|
||||||
|
|
||||||
if isinstance(item, CatalogInvalidItem.CatalogInvalidItem):
|
if isinstance(item, CatalogInvalidItem.CatalogInvalidItem):
|
||||||
self.air.writeServerEvent('suspicious', avId, 'tried purchasing invalid item')
|
self.air.writeServerEvent('suspicious', avId, 'tried purchasing invalid item')
|
||||||
self.notify.warning('%d tried purchasing invalid item' % avId)
|
self.notify.warning('%d tried purchasing invalid item' % avId)
|
||||||
return ToontownGlobals.P_NotInCatalog
|
return ToontownGlobals.P_NotInCatalog
|
||||||
|
elif (not item.hasEmblemPrices()) and item not in av.backCatalog and item not in av.weeklyCatalog and item not in av.monthlyCatalog:
|
||||||
if item in avBuying.backCatalog:
|
|
||||||
priceType = CatalogItem.CatalogTypeBackorder
|
|
||||||
|
|
||||||
elif item in avBuying.weeklyCatalog or item in avBuying.monthlyCatalog:
|
|
||||||
priceType = 0
|
|
||||||
|
|
||||||
elif item.__class__.__name__ == "CatalogHouseItem":
|
|
||||||
priceType = 0
|
|
||||||
|
|
||||||
else:
|
|
||||||
self.air.writeServerEvent('suspicious', avId, 'tried purchasing non-existing item')
|
self.air.writeServerEvent('suspicious', avId, 'tried purchasing non-existing item')
|
||||||
self.notify.warning('%d tried purchasing non-existing item' % avId)
|
self.notify.warning('%d tried purchasing non-existing item' % avId)
|
||||||
return ToontownGlobals.P_NotInCatalog
|
return ToontownGlobals.P_NotInCatalog
|
||||||
|
|
||||||
def _getEmblemPrices():
|
|
||||||
if config.GetBool('catalog-emblems-OR', False):
|
|
||||||
ep = list(item.getEmblemPrices())
|
|
||||||
if len(ep) != 2:
|
|
||||||
return []
|
|
||||||
|
|
||||||
if all(ep):
|
|
||||||
ep[payMethod] = 0
|
|
||||||
|
|
||||||
else:
|
|
||||||
ep = item.getEmblemPrices()
|
|
||||||
|
|
||||||
return ep
|
|
||||||
|
|
||||||
def charge():
|
|
||||||
ep = _getEmblemPrices()
|
|
||||||
if ep:
|
|
||||||
avBuying.subtractEmblems(ep)
|
|
||||||
|
|
||||||
avBuying.takeMoney(item.getPrice(priceType))
|
|
||||||
|
|
||||||
if not gifting and item.reachedPurchaseLimit(recepient):
|
|
||||||
retcode = ToontownGlobals.P_ReachedPurchaseLimit
|
|
||||||
|
|
||||||
elif not gifting and len(recepient.onOrder) >= MAX_ON_ORDER:
|
|
||||||
retcode = ToontownGlobals.P_ReachedPurchaseLimit
|
|
||||||
|
|
||||||
elif not gifting and len(recepient.mailboxContents) >= MAX_MAILBOX:
|
|
||||||
retcode = ToontownGlobals.P_MailboxFull
|
|
||||||
|
|
||||||
elif item.getPrice(priceType) >= avBuying.getTotalMoney():
|
|
||||||
retcode = ToontownGlobals.P_NotEnoughMoney
|
|
||||||
|
|
||||||
elif not avBuying.isEnoughEmblemsToBuy(_getEmblemPrices()):
|
|
||||||
retcode = ToontownGlobals.P_NotEnoughMoney
|
|
||||||
|
|
||||||
elif gifting and not item.isGift():
|
|
||||||
retcode = ToontownGlobals.P_NotAGift
|
|
||||||
|
|
||||||
elif not item.getDeliveryTime() and not gifting:
|
|
||||||
retcode = item.recordPurchase(recepient, optional)
|
|
||||||
if retcode == ToontownGlobals.P_ItemAvailable:
|
|
||||||
|
|
||||||
charge()
|
|
||||||
|
|
||||||
else:
|
|
||||||
retcode = ToontownGlobals.P_ItemOnOrder
|
|
||||||
charge()
|
|
||||||
|
|
||||||
deliveryTime = item.getDeliveryTime()
|
if gifting and not item.isGift():
|
||||||
if config.GetBool('want-instant-delivery', False):
|
return ToontownGlobals.P_NotAGift
|
||||||
deliveryTime = 0
|
|
||||||
|
price = item.getPrice(CatalogItem.CatalogTypeBackorder if item in av.backCatalog else 0)
|
||||||
|
|
||||||
|
if price > av.getTotalMoney() or (item.hasEmblemPrices() and not av.isEnoughEmblemsToBuy(item.getEmblemPrices())):
|
||||||
|
return ToontownGlobals.P_NotEnoughMoney
|
||||||
|
|
||||||
|
if item.getDeliveryTime() or gifting:
|
||||||
|
deliveryTime = 0 if config.GetBool('want-instant-delivery', False) else item.getDeliveryTime()
|
||||||
item.deliveryDate = int(time.time() / 60. + deliveryTime + .5)
|
item.deliveryDate = int(time.time() / 60. + deliveryTime + .5)
|
||||||
|
|
||||||
if not gifting:
|
|
||||||
recepient.onOrder.append(item)
|
|
||||||
recepient.b_setDeliverySchedule(recepient.onOrder)
|
|
||||||
|
|
||||||
else:
|
|
||||||
item.giftTag = avBuying.doId
|
|
||||||
store = CatalogItem.Customization | CatalogItem.DeliveryDate | CatalogItem.GiftTag
|
|
||||||
self.air.sendNetEvent('CATALOG_addGift_AI2UD', [recepient, item.getBlob(store=store)])
|
|
||||||
|
|
||||||
return retcode
|
|
||||||
|
|
||||||
def requestPurchaseMessage(self, context, blob, optional, payMethod=0):
|
|
||||||
av = self.__getCaller()
|
|
||||||
if av:
|
|
||||||
retcode = self.attemptPurchase(av, av, blob, optional, payMethod)
|
|
||||||
if retcode in (ToontownGlobals.P_ItemOnOrder, ToontownGlobals.P_ItemAvailable):
|
|
||||||
messenger.send('topToonsManager-event', [av.doId, TopToonsGlobals.CAT_CATALOG, 1])
|
|
||||||
self.sendUpdateToAvatarId(av.doId, 'requestPurchaseResponse', [context, retcode])
|
|
||||||
|
|
||||||
def requestGiftPurchaseMessage(self, context, targetDoID, blob, optional, payMethod=0):
|
if gifting:
|
||||||
|
return self.requestGiftAvatarOperation(avId, gifting, [context, item, price], self.attemptGiftPurchase)
|
||||||
|
else:
|
||||||
|
returnCode = self.checkPurchaseLimit(av, item)
|
||||||
|
|
||||||
|
if returnCode != ToontownGlobals.P_ItemOnOrder:
|
||||||
|
return returnCode
|
||||||
|
|
||||||
|
if item.getDeliveryTime():
|
||||||
|
self.chargeAvatar(av, price, item.getEmblemPrices())
|
||||||
|
av.onOrder.append(item)
|
||||||
|
av.b_setDeliverySchedule(av.onOrder)
|
||||||
|
else:
|
||||||
|
returnCode = item.recordPurchase(av, optional)
|
||||||
|
|
||||||
|
if returnCode == ToontownGlobals.P_ItemAvailable:
|
||||||
|
self.chargeAvatar(av, price, item.getEmblemPrices())
|
||||||
|
|
||||||
|
return returnCode
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
def attemptGiftPurchase(self, avId, targetId, avatar, optional):
|
||||||
|
av = self.air.doId2do.get(avId)
|
||||||
|
|
||||||
|
if not av:
|
||||||
|
return
|
||||||
|
|
||||||
|
recipient = GiftAvatar.createFromFields(avatar)
|
||||||
|
context = optional[0]
|
||||||
|
item = optional[1]
|
||||||
|
returnCode = self.checkPurchaseLimit(recipient, item)
|
||||||
|
|
||||||
|
if returnCode != ToontownGlobals.P_ItemOnOrder:
|
||||||
|
self.sendGiftPurchaseResponse(context, avId, returnCode)
|
||||||
|
return
|
||||||
|
|
||||||
|
item.giftTag = avId
|
||||||
|
self.chargeAvatar(av, optional[2], item.getEmblemPrices())
|
||||||
|
recipient.onGiftOrder.append(item)
|
||||||
|
|
||||||
|
dg = self.air.dclassesByName['DistributedToonAI'].aiFormatUpdate('setGiftSchedule', targetId, targetId, self.air.ourChannel, [recipient.getGiftScheduleBlob()])
|
||||||
|
self.air.send(dg)
|
||||||
|
self.sendGiftPurchaseResponse(context, avId, ToontownGlobals.P_ItemOnOrder)
|
||||||
|
|
||||||
|
def sendGiftPurchaseResponse(self, context, avId, returnCode):
|
||||||
|
if returnCode in (ToontownGlobals.P_ItemOnOrder, ToontownGlobals.P_ItemAvailable):
|
||||||
|
messenger.send('topToonsManager-event', [avId, TopToonsGlobals.CAT_CATALOG | TopToonsGlobals.CAT_GIFTS, 1])
|
||||||
|
|
||||||
|
self.sendUpdateToAvatarId(avId, 'requestGiftPurchaseResponse', [context, returnCode])
|
||||||
|
|
||||||
|
def requestPurchaseMessage(self, context, blob, optional):
|
||||||
av = self.__getCaller()
|
av = self.__getCaller()
|
||||||
if av:
|
|
||||||
retcode = self.attemptPurchase(av, targetDoID, blob, optional, payMethod, gifting=True)
|
if not av:
|
||||||
if retcode in (ToontownGlobals.P_ItemOnOrder, ToontownGlobals.P_ItemAvailable):
|
return
|
||||||
messenger.send('topToonsManager-event', [av.doId, TopToonsGlobals.CAT_CATALOG | TopToonsGlobals.CAT_GIFTS, 1])
|
|
||||||
self.sendUpdateToAvatarId(av.doId, 'requestGiftPurchaseResponse', [context, retcode])
|
returnCode = self.attemptPurchase(context, av, blob, optional)
|
||||||
|
|
||||||
|
if returnCode in (ToontownGlobals.P_ItemOnOrder, ToontownGlobals.P_ItemAvailable):
|
||||||
|
messenger.send('topToonsManager-event', [av.doId, TopToonsGlobals.CAT_CATALOG, 1])
|
||||||
|
|
||||||
|
self.sendUpdateToAvatarId(av.doId, 'requestPurchaseResponse', [context, returnCode])
|
||||||
|
|
||||||
|
def requestGiftPurchaseMessage(self, context, targetId, blob, optional):
|
||||||
|
av = self.__getCaller()
|
||||||
|
|
||||||
|
if not av:
|
||||||
|
return
|
||||||
|
|
||||||
|
returnCode = self.attemptPurchase(context, av, blob, optional, gifting=targetId)
|
||||||
|
|
||||||
|
if returnCode:
|
||||||
|
self.sendGiftPurchaseResponse(context, av.doId, returnCode)
|
||||||
|
|
||||||
|
def requestGiftAvatar(self, doId):
|
||||||
|
self.requestGiftAvatarOperation(self.air.getAvatarIdFromSender(), doId, None, self.sendGiftAvatarResponse)
|
||||||
|
|
||||||
|
def requestGiftAvatarOperation(self, avId, doId, optional, callback):
|
||||||
|
if avId in self.fsms:
|
||||||
|
return
|
||||||
|
|
||||||
|
loadOperation = LoadGiftAvatar(self, avId, doId, optional, callback)
|
||||||
|
loadOperation.start()
|
||||||
|
self.fsms[avId] = loadOperation
|
||||||
|
return None
|
||||||
|
|
||||||
|
def sendGiftAvatarResponse(self, avId, targetId, avatar, optional):
|
||||||
|
self.sendUpdateToAvatarId(avId, 'setGiftAvatar', [json.dumps(avatar)])
|
||||||
|
|
||||||
def resetMovie(self, task):
|
def resetMovie(self, task):
|
||||||
self.d_setMovie(PHONE_MOVIE_CLEAR, 0)
|
self.d_setMovie(PHONE_MOVIE_CLEAR, 0)
|
||||||
|
|
|
@ -175,8 +175,6 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
|
||||||
from toontown.toon.DistributedNPCToonBaseAI import DistributedNPCToonBaseAI
|
from toontown.toon.DistributedNPCToonBaseAI import DistributedNPCToonBaseAI
|
||||||
if not isinstance(self, DistributedNPCToonBaseAI):
|
if not isinstance(self, DistributedNPCToonBaseAI):
|
||||||
self.sendUpdate('setDefaultShard', [self.air.districtId])
|
self.sendUpdate('setDefaultShard', [self.air.districtId])
|
||||||
|
|
||||||
self.accept('CATALOG_addGift_UD2Toon_%d' % self.doId, self.__handleAddGift)
|
|
||||||
|
|
||||||
def setLocation(self, parentId, zoneId):
|
def setLocation(self, parentId, zoneId):
|
||||||
DistributedPlayerAI.DistributedPlayerAI.setLocation(self, parentId, zoneId)
|
DistributedPlayerAI.DistributedPlayerAI.setLocation(self, parentId, zoneId)
|
||||||
|
@ -238,8 +236,6 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
|
||||||
PetLookerAI.PetLookerAI.destroy(self)
|
PetLookerAI.PetLookerAI.destroy(self)
|
||||||
del self.kart
|
del self.kart
|
||||||
self._sendExitServerEvent()
|
self._sendExitServerEvent()
|
||||||
|
|
||||||
self.ignore('CATALOG_addGift_UD2Toon_%d' % self.doId)
|
|
||||||
|
|
||||||
DistributedSmoothNodeAI.DistributedSmoothNodeAI.delete(self)
|
DistributedSmoothNodeAI.DistributedSmoothNodeAI.delete(self)
|
||||||
DistributedPlayerAI.DistributedPlayerAI.delete(self)
|
DistributedPlayerAI.DistributedPlayerAI.delete(self)
|
||||||
|
@ -2187,12 +2183,6 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
|
||||||
self.b_setCatalogNotify(self.catalogNotify, ToontownGlobals.NewItems)
|
self.b_setCatalogNotify(self.catalogNotify, ToontownGlobals.NewItems)
|
||||||
return Task.done
|
return Task.done
|
||||||
|
|
||||||
def __handleAddGift(self, blob, ctx):
|
|
||||||
store = CatalogItem.Customization | CatalogItem.DeliveryDate | CatalogItem.GiftTag
|
|
||||||
self.onGiftOrder.append(CatalogItem.getItem(blob, store=store))
|
|
||||||
self.b_setBothSchedules(self.onOrder, self.onGiftOrder)
|
|
||||||
self.air.sendNetEvent('CATALOG_addGift_UD2Toon_resp', [self.doId, ctx])
|
|
||||||
|
|
||||||
def __deliverPurchase(self, task):
|
def __deliverPurchase(self, task):
|
||||||
now = int(time.time() / 60 + 0.5)
|
now = int(time.time() / 60 + 0.5)
|
||||||
delivered, remaining = self.onOrder.extractDeliveryItems(now)
|
delivered, remaining = self.onOrder.extractDeliveryItems(now)
|
||||||
|
|
|
@ -5466,8 +5466,8 @@ CatalogGiftFor = 'Buy Gift for:'
|
||||||
CatalogGiftTo = 'To: %s'
|
CatalogGiftTo = 'To: %s'
|
||||||
CatalogGiftToggleOn = 'Stop Gifting'
|
CatalogGiftToggleOn = 'Stop Gifting'
|
||||||
CatalogGiftToggleOff = 'Buy Gifts'
|
CatalogGiftToggleOff = 'Buy Gifts'
|
||||||
CatalogGiftToggleWait = 'Trying!...'
|
CatalogGiftUpdating = 'Updating...'
|
||||||
CatalogGiftToggleNoAck = 'Unavailable'
|
CatalogGiftChoose = 'Choose a friend!'
|
||||||
CatalogPurchaseItemAvailable = 'Congratulations on your new purchase! You can start using it right away.'
|
CatalogPurchaseItemAvailable = 'Congratulations on your new purchase! You can start using it right away.'
|
||||||
CatalogPurchaseGiftItemAvailable = 'Excellent! %s can start using your gift right away.'
|
CatalogPurchaseGiftItemAvailable = 'Excellent! %s can start using your gift right away.'
|
||||||
CatalogPurchaseItemOnOrder = 'Congratulations! Your purchase will be delivered to your mailbox soon.'
|
CatalogPurchaseItemOnOrder = 'Congratulations! Your purchase will be delivered to your mailbox soon.'
|
||||||
|
@ -8601,7 +8601,7 @@ CEOSpeech = [
|
||||||
'And thus we, the Cog Nation, are striving.',
|
'And thus we, the Cog Nation, are striving.',
|
||||||
'I am very delighted by this news, I just wanted to thank you all for working so hard for this news.',
|
'I am very delighted by this news, I just wanted to thank you all for working so hard for this news.',
|
||||||
"Wait, what's going on? I can't see but I hear explosions."
|
"Wait, what's going on? I can't see but I hear explosions."
|
||||||
]
|
] # Len of words + 10
|
||||||
Blacklist = [
|
Blacklist = [
|
||||||
"$1ut",
|
"$1ut",
|
||||||
"$h1t",
|
"$h1t",
|
||||||
|
@ -9864,4 +9864,4 @@ Blacklist = [
|
||||||
"willy",
|
"willy",
|
||||||
"xrated",
|
"xrated",
|
||||||
"xxx"
|
"xxx"
|
||||||
] # Len of words + 10
|
]
|
|
@ -3,7 +3,6 @@ import urlparse
|
||||||
from otp.distributed.OtpDoGlobals import *
|
from otp.distributed.OtpDoGlobals import *
|
||||||
from otp.distributed.DistributedDirectoryAI import DistributedDirectoryAI
|
from otp.distributed.DistributedDirectoryAI import DistributedDirectoryAI
|
||||||
from toontown.distributed.ToontownInternalRepository import ToontownInternalRepository
|
from toontown.distributed.ToontownInternalRepository import ToontownInternalRepository
|
||||||
from toontown.catalog.CatalogManagerUD import CatalogManagerUD
|
|
||||||
import toontown.minigame.MinigameCreatorAI
|
import toontown.minigame.MinigameCreatorAI
|
||||||
|
|
||||||
if config.GetBool('want-rpc-server', False):
|
if config.GetBool('want-rpc-server', False):
|
||||||
|
@ -26,8 +25,6 @@ class ToontownUberRepository(ToontownInternalRepository):
|
||||||
self.mongo = pymongo.MongoClient(url)
|
self.mongo = pymongo.MongoClient(url)
|
||||||
db = (urlparse.urlparse(url).path or '/test')[1:]
|
db = (urlparse.urlparse(url).path or '/test')[1:]
|
||||||
self.mongodb = self.mongo[db]
|
self.mongodb = self.mongo[db]
|
||||||
|
|
||||||
self.catalogManager = CatalogManagerUD(self)
|
|
||||||
|
|
||||||
self.notify.setInfo(True)
|
self.notify.setInfo(True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue