diff --git a/astron/dclass/stride.dc b/astron/dclass/stride.dc index 93672371..1c74b38c 100644 --- a/astron/dclass/stride.dc +++ b/astron/dclass/stride.dc @@ -295,6 +295,7 @@ from toontown.estate import DistributedEstate/AI from toontown.estate import DistributedHouse/AI from toontown.estate import DistributedHouseInterior/AI from toontown.estate import DistributedGarden/AI +from toontown.shtiker import DeleteManager/AI from toontown.groups import GroupManager/AI/UD from toontown.ai import NewsManager/AI from toontown.shtiker import PurchaseManager/AI @@ -302,6 +303,7 @@ from toontown.shtiker import NewbiePurchaseManager/AI from toontown.safezone import SafeZoneManager/AI from toontown.tutorial import TutorialManager/AI from toontown.catalog import CatalogManager/AI +from toontown.catalog import AccountDate/AI from toontown.safezone import DistributedTreasure/AI from toontown.coghq import DistributedCashbotBossTreasure/AI from toontown.building import DistributedTrophyMgr/AI @@ -1543,6 +1545,10 @@ dclass DistributedPartyTugOfWarActivity : DistributedPartyTeamActivity { updateToonPositions(int16/1000) broadcast; }; +dclass DeleteManager : DistributedObject { + setInventory(blob) airecv clsend; +}; + dclass GroupManager : DistributedObject { setChildId() clsend airecv; isPlayerGrouped(uint32); @@ -1653,6 +1659,11 @@ dclass CatalogManager : DistributedObject { startCatalog() airecv clsend; }; +dclass AccountDate : DistributedObject { + requestDate() airecv clsend; + requestDateResult(string); +}; + dclass DistributedTreasure : DistributedObject { setTreasureType(uint16) required broadcast ram; setPosition(int16/10, int16/10, int16/10) required broadcast ram; diff --git a/otp/distributed/DCClassImports.py b/otp/distributed/DCClassImports.py index 3088f5a8..ceb8bf75 100644 --- a/otp/distributed/DCClassImports.py +++ b/otp/distributed/DCClassImports.py @@ -2,7 +2,11 @@ from pandac.PandaModules import * +<<<<<<< HEAD hashVal = 4040859151L +======= +hashVal = 2005027427 +>>>>>>> parent of 0f4521a... Initial work on gifting (still broken right now), and sry zach 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 @@ -11,7 +15,7 @@ from toontown.building import DistributedAnimatedProp, DistributedTrophyMgr, Dis from toontown.uberdog.DistributedPartyManager import DistributedPartyManager from otp.friends import FriendManager from otp.level import DistributedLevel, DistributedEntity, DistributedInteractiveEntity -from toontown.shtiker import PurchaseManager, NewbiePurchaseManager +from toontown.shtiker import DeleteManager, PurchaseManager, NewbiePurchaseManager from toontown.groups import GroupManager from toontown.uberdog.ClientServicesManager import ClientServicesManager from toontown.ai import WelcomeValleyManager, NewsManager, DistributedAprilToonsMgr, DistributedBlackCatMgr, DistributedReportMgr, DistributedPolarPlaceEffectMgr, DistributedGreenToonEffectMgr, DistributedResistanceEmoteMgr, DistributedScavengerHuntTarget, DistributedTrickOrTreatTarget, DistributedWinterCarolingTarget, DistributedJorElCam @@ -25,7 +29,7 @@ from toontown.safezone import DistributedTrolley, DistributedPartyGate, Distribu from toontown.fishing import DistributedFishingPond, DistributedFishingTarget, DistributedPondBingoManager from toontown.minigame import DistributedMinigame, DistributedMinigameTemplate, DistributedRaceGame, DistributedCannonGame, DistributedPatternGame, DistributedRingGame, DistributedTagGame, DistributedMazeGame, DistributedTugOfWarGame, DistributedCatchGame, DistributedDivingGame, DistributedTargetGame, DistributedVineGame, DistributedIceGame, DistributedCogThiefGame, DistributedTwoDGame from toontown.racing import DistributedVehicle, DistributedStartingBlock, DistributedRace, DistributedKartPad, DistributedRacePad, DistributedViewPad, DistributedStartingBlock, DistributedLeaderBoard, DistributedGag, DistributedProjectile -from toontown.catalog import CatalogManager +from toontown.catalog import CatalogManager, AccountDate from toontown.parties import DistributedParty, DistributedPartyActivity, DistributedPartyTeamActivity, DistributedPartyCannon, DistributedPartyCannonActivity, DistributedPartyCatchActivity, DistributedPartyWinterCatchActivity, DistributedPartyCogActivity, DistributedPartyWinterCogActivity, DistributedPartyFireworksActivity, DistributedPartyDanceActivityBase, DistributedPartyDanceActivity, DistributedPartyDance20Activity, DistributedPartyValentineDanceActivity, DistributedPartyValentineDance20Activity, DistributedPartyTrampolineActivity, DistributedPartyValentineTrampolineActivity, DistributedPartyVictoryTrampolineActivity, DistributedPartyWinterTrampolineActivity, DistributedPartyTugOfWarActivity, DistributedPartyJukeboxActivityBase, DistributedPartyJukeboxActivity, DistributedPartyJukebox40Activity, DistributedPartyValentineJukeboxActivity, DistributedPartyValentineJukebox40Activity from toontown.pets.DistributedPet import * from toontown.friends import TTSFriendsManager diff --git a/toontown/ai/ToontownAIRepository.py b/toontown/ai/ToontownAIRepository.py index 5fc1715b..77c1e344 100644 --- a/toontown/ai/ToontownAIRepository.py +++ b/toontown/ai/ToontownAIRepository.py @@ -16,6 +16,7 @@ from toontown.ai.NewsManagerAI import NewsManagerAI from toontown.ai.QuestManagerAI import QuestManagerAI from toontown.ai.DistributedBlackCatMgrAI import DistributedBlackCatMgrAI from toontown.ai.DistributedReportMgrAI import DistributedReportMgrAI +from toontown.catalog.AccountDateAI import AccountDateAI from toontown.building.DistributedBuildingQueryMgrAI import DistributedBuildingQueryMgrAI from toontown.building.DistributedTrophyMgrAI import DistributedTrophyMgrAI from toontown.catalog.CatalogManagerAI import CatalogManagerAI @@ -120,6 +121,8 @@ class ToontownAIRepository(ToontownInternalRepository): self.holidayManager = HolidayManagerAI(self) self.codeRedemptionMgr = TTCodeRedemptionMgrAI(self) self.codeRedemptionMgr.generateWithRequired(2) + self.accountDateMgr = AccountDateAI(self) + self.accountDateMgr.generateWithRequired(2) self.buildingQueryMgr = DistributedBuildingQueryMgrAI(self) self.buildingQueryMgr.generateWithRequired(2) self.groupManager.generateWithRequired(2) diff --git a/toontown/catalog/AccountDate.py b/toontown/catalog/AccountDate.py new file mode 100644 index 00000000..610227e1 --- /dev/null +++ b/toontown/catalog/AccountDate.py @@ -0,0 +1,39 @@ +from direct.distributed.DistributedObject import DistributedObject +from direct.directnotify.DirectNotifyGlobal import directNotify +from datetime import datetime + +class AccountDate(DistributedObject): + neverDisable = 1 + notify = directNotify.newCategory('AccountDate') + + def __init__(self, cr): + DistributedObject.__init__(self, cr) + self.accountDays = 0 + + def announceGenerate(self): + DistributedObject.announceGenerate(self) + base.cr.accountDateMgr = self + taskMgr.doMethodLater(10, self.requestDate, 'request-task') + + def delete(self): + if hasattr(base.cr, 'accountDateMgr'): + if base.cr.accountDateMgr is self: + del base.cr.accountDateMgr + DistributedObject.delete(self) + + def getAccountDays(self): + return self.accountDays + + def requestDate(self, task=None): + self.sendUpdate('requestDate') + + if task is not None: + return task.done + + def requestDateResult(self, result): + if result is None: + notify.warning('Invalid response from server.') + self.accountDays = 0 + else: + date = datetime.strptime(result, "%a %b %d %H:%M:%S %Y") + self.accountDays = (datetime.now() - date).days \ No newline at end of file diff --git a/toontown/catalog/AccountDateAI.py b/toontown/catalog/AccountDateAI.py new file mode 100644 index 00000000..654048ea --- /dev/null +++ b/toontown/catalog/AccountDateAI.py @@ -0,0 +1,23 @@ +from direct.directnotify import DirectNotifyGlobal +from direct.distributed.DistributedObjectAI import DistributedObjectAI + +class AccountDateAI(DistributedObjectAI): + notify = DirectNotifyGlobal.directNotify.newCategory("AccountDateAI") + + def announceGenerate(self): + DistributedObjectAI.announceGenerate(self) + + def requestDate(self): + avId = self.air.getAvatarIdFromSender() + av = self.air.doId2do.get(avId) + + if not av: + return + + def callback(dclass, fields): + if dclass is not None and dclass == self.air.dclassesByName['AccountAI'] and fields.has_key('CREATED'): + self.sendUpdateToAvatarId(avId, 'requestDateResult', [fields.get('CREATED')]) + else: + self.sendUpdateToAvatarId(avId, 'requestDateResult', [None]) + + self.air.dbInterface.queryObject(self.air.dbId, av.DISLid, callback) \ No newline at end of file diff --git a/toontown/catalog/CatalogAccessoryItem.py b/toontown/catalog/CatalogAccessoryItem.py index 3b12563a..4f8f13f8 100644 --- a/toontown/catalog/CatalogAccessoryItem.py +++ b/toontown/catalog/CatalogAccessoryItem.py @@ -363,6 +363,9 @@ class CatalogAccessoryItem(CatalogItem.CatalogItem): dg.addUint16(self.accessoryType) dg.addBool(self.isSpecial) + def isGift(self): + return not self.getEmblemPrices() + def getAllAccessories(*accessoryTypes): list = [] for accessoryType in accessoryTypes: diff --git a/toontown/catalog/CatalogClothingItem.py b/toontown/catalog/CatalogClothingItem.py index 0f4865f0..5124da5a 100644 --- a/toontown/catalog/CatalogClothingItem.py +++ b/toontown/catalog/CatalogClothingItem.py @@ -548,6 +548,9 @@ class CatalogClothingItem(CatalogItem.CatalogItem): dg.addUint8(self.colorIndex) dg.addBool(self.isSpecial) + def isGift(self): + return not self.getEmblemPrices() + def getAllClothes(*clothingTypes): list = [] for clothingType in clothingTypes: diff --git a/toontown/catalog/CatalogEmoteItem.py b/toontown/catalog/CatalogEmoteItem.py index a5c16f0a..fa173bc6 100644 --- a/toontown/catalog/CatalogEmoteItem.py +++ b/toontown/catalog/CatalogEmoteItem.py @@ -121,4 +121,7 @@ class CatalogEmoteItem(CatalogItem.CatalogItem): def encodeDatagram(self, dg, store): CatalogItem.CatalogItem.encodeDatagram(self, dg, store) dg.addUint8(self.emoteIndex) - dg.addBool(self.isSpecial) \ No newline at end of file + dg.addBool(self.isSpecial) + + def isGift(self): + return not self.getEmblemPrices() \ No newline at end of file diff --git a/toontown/catalog/CatalogItem.py b/toontown/catalog/CatalogItem.py index efce112a..bba97cda 100644 --- a/toontown/catalog/CatalogItem.py +++ b/toontown/catalog/CatalogItem.py @@ -115,7 +115,9 @@ class CatalogItem: return self.saleItem def isGift(self): - return not self.getEmblemPrices() + if self.getEmblemPrices(): + return 0 + return 1 def isRental(self): return 0 diff --git a/toontown/catalog/CatalogScreen.py b/toontown/catalog/CatalogScreen.py index 449de623..36eb9d3c 100644 --- a/toontown/catalog/CatalogScreen.py +++ b/toontown/catalog/CatalogScreen.py @@ -45,10 +45,11 @@ class CatalogScreen(DirectFrame): DirectFrame.__init__(self, parent) self.friendGiftIndex = 0 self.friendGiftHandle = None - self.friendDoId = None + self.frienddoId = None self.receiverName = 'Error Nameless Toon' self.friends = {} - self.friendList = [] + 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) @@ -91,7 +92,7 @@ class CatalogScreen(DirectFrame): taskMgr.doMethodLater(12.0, clarabelleHelpText1, 'clarabelleHelpText1') if hasattr(self, 'giftToggle'): self.giftToggle['state'] = DGG.NORMAL - self.giftToggle['text'] = TTLocalizer.CatalogGiftToggleOff + self.giftToggle['text'] = TTLocalizer.CatalogGiftToggleOn def hide(self): self.ignore('CatalogItemPurchaseRequest') @@ -541,8 +542,8 @@ class CatalogScreen(DirectFrame): -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)) self.emblemCatalogButton2.hide() - self.__makeFriendList() - if len(self.friendList) > 0: + self.__makeFFlist() + if len(self.ffList) > 0: 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.setPos(0.0, 0, -0.035) @@ -568,8 +569,8 @@ class CatalogScreen(DirectFrame): clipNP = self.scrollList.attachNewNode(clipper) self.scrollList.setClipPlane(clipNP) self.__makeScrollList() - friendId = self.friendList[0] - self.__chooseFriend(self.friendList[0][0], self.friendList[0][1]) + friendId = self.ffList[0] + self.__chooseFriend(self.ffList[0][0], self.ffList[0][1]) self.update() self.createdGiftGui = 1 for i in range(4): @@ -864,7 +865,11 @@ class CatalogScreen(DirectFrame): if self.responseDialog: self.responseDialog.cleanup() self.responseDialog = None - self.unloadFriend() + if self.giftAvatar: + if hasattr(self.giftAvatar, 'doId'): + self.giftAvatar.delete() + else: + self.giftAvatar = None return def unloadClarabelle(self): @@ -928,7 +933,7 @@ class CatalogScreen(DirectFrame): taskMgr.remove('clarabelleAskAnythingElse') def __handleGiftPurchaseRequest(self, item): - item.requestGiftPurchase(self['phone'], self.friendDoId, self.__handleGiftPurchaseResponse) + item.requestGiftPurchase(self['phone'], self.frienddoId, self.__handleGiftPurchaseResponse) taskMgr.remove('clarabelleAskAnythingElse') def __handlePurchaseResponse(self, retCode, item): @@ -1010,61 +1015,61 @@ class CatalogScreen(DirectFrame): self.silverLabel.hide() self.goldLabel.hide() - def __makeFriendList(self): - for av in base.cr.avList: - if localAvatar.doId == av.id: - continue - self.friendList.append((av.id, av.name, NametagGlobals.CCNormal)) + def checkFamily(self, doId): + test = 0 + for familyMember in base.cr.avList: + if familyMember.id == doId: + test = 1 + + return test + + def __makeFFlist(self): for id, handle in base.cr.friendsMap.items(): - self.friendList.append((id, handle.getName(), NametagGlobals.getFriendColor(handle.commonChatFlags))) + self.ffList.append((id, handle.getName(), NametagGlobals.CCFreeChat)) def __makeScrollList(self): - for friend in self.friendList: - friendButton = self.makeFriendButton(friend[0], friend[1], friend[2]) - if friendButton: - self.scrollList.addItem(friendButton, refresh=0) - self.friends[friend] = friendButton + for ff in self.ffList: + ffbutton = self.makeFamilyButton(ff[0], ff[1], ff[2]) + if ffbutton: + self.scrollList.addItem(ffbutton, refresh=0) + self.friends[ff] = ffbutton self.scrollList.refresh() - def makeFriendButton(self, avId, avName, colorCode): + def makeFamilyButton(self, familyId, familyName, colorCode): + # fg = NametagGlobals.getNameFg(colorCode, PGButton.SInactive) return DirectButton( relief=None, - text=avName, + text=familyName, text_scale=0.04, text_align=TextNode.ALeft, - text_fg=NametagGlobals.NametagColors[colorCode][0][0], + # text_fg=fg, text1_bg=self.textDownColor, text2_bg=self.textRolloverColor, text3_fg=self.textDisabledColor, textMayChange=0, command=self.__chooseFriend, - extraArgs=[avId, avName] - ) + extraArgs=[familyId, familyName] + ) def __chooseFriend(self, friendId, friendName): - if self.friendDoId and self.friendDoId == friendId: - return messenger.send('wakeup') - self.friendDoId = friendId + self.frienddoId = friendId self.receiverName = friendName self.friendLabel['text'] = TTLocalizer.CatalogGiftTo % self.receiverName self.__loadFriend() - def unloadFriend(self): - if self.giftAvatar: - if hasattr(self.giftAvatar, 'doId'): - self.giftAvatar.disable() - self.giftAvatar.delete() - self.giftAvatar = None - def __loadFriend(self): if self.allowGetDetails == 0: CatalogScreen.notify.warning('smashing requests') - if self.friendDoId and self.allowGetDetails: - self.unloadFriend() + 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.doId = self.frienddoId self.giftAvatar.forceAllowDelayDelete() self.giftAvatar.generate() base.cr.getAvatarDetails(self.giftAvatar, self.__handleAvatarDetails, 'DistributedToon') diff --git a/toontown/nametag/NametagGlobals.py b/toontown/nametag/NametagGlobals.py index a0b866d5..b8b62a6c 100644 --- a/toontown/nametag/NametagGlobals.py +++ b/toontown/nametag/NametagGlobals.py @@ -135,8 +135,6 @@ def getModelWidthHeight(model): height = maxPoint.getZ() - minPoint.getZ() return (width, height) -def getFriendColor(flag): - return CCNormal if flag == 1 and settings['trueFriends'] else CCFreeChat # Foreground, background: NametagColors = { diff --git a/toontown/shtiker/DeleteManager.py b/toontown/shtiker/DeleteManager.py new file mode 100644 index 00000000..46af28fe --- /dev/null +++ b/toontown/shtiker/DeleteManager.py @@ -0,0 +1,21 @@ +from pandac.PandaModules import * +from direct.distributed import DistributedObject +from direct.directnotify import DirectNotifyGlobal + +class DeleteManager(DistributedObject.DistributedObject): + notify = DirectNotifyGlobal.directNotify.newCategory('DeleteManager') + neverDisable = 1 + + def __init__(self, cr): + DistributedObject.DistributedObject.__init__(self, cr) + + def generate(self): + DistributedObject.DistributedObject.generate(self) + self.accept('deleteItems', self.d_setInventory) + + def disable(self): + self.ignore('deleteItems') + DistributedObject.DistributedObject.disable(self) + + def d_setInventory(self, newInventoryString): + self.sendUpdate('setInventory', [newInventoryString]) diff --git a/toontown/shtiker/DeleteManagerAI.py b/toontown/shtiker/DeleteManagerAI.py new file mode 100644 index 00000000..fcc249f2 --- /dev/null +++ b/toontown/shtiker/DeleteManagerAI.py @@ -0,0 +1,9 @@ +from direct.directnotify import DirectNotifyGlobal +from direct.distributed.DistributedObjectAI import DistributedObjectAI + +class DeleteManagerAI(DistributedObjectAI): + notify = DirectNotifyGlobal.directNotify.newCategory("DeleteManagerAI") + + def setInventory(self, todo0): + pass + diff --git a/toontown/toon/LocalToon.py b/toontown/toon/LocalToon.py index b7e3f309..baee8074 100644 --- a/toontown/toon/LocalToon.py +++ b/toontown/toon/LocalToon.py @@ -1687,6 +1687,9 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar): def setPinkSlips(self, pinkSlips): DistributedToon.DistributedToon.setPinkSlips(self, pinkSlips) self.inventory.updateTotalPropsText() + + def getAccountDays(self): + return base.cr.accountDateMgr.getAccountDays() def hasActiveBoardingGroup(self): if hasattr(localAvatar, 'boardingParty') and localAvatar.boardingParty: