Initial work on gifting (still broken right now), and sry zach

This commit is contained in:
DenialMC 2015-05-16 13:23:30 +03:00
parent 87a77a8740
commit 0f4521a19e
14 changed files with 45 additions and 168 deletions

View file

@ -295,7 +295,6 @@ 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
@ -303,7 +302,6 @@ 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
@ -1545,10 +1543,6 @@ dclass DistributedPartyTugOfWarActivity : DistributedPartyTeamActivity {
updateToonPositions(int16/1000) broadcast;
};
dclass DeleteManager : DistributedObject {
setInventory(blob) airecv clsend;
};
dclass GroupManager : DistributedObject {
setChildId() clsend airecv;
isPlayerGrouped(uint32);
@ -1659,11 +1653,6 @@ 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;

View file

@ -2,7 +2,7 @@
from pandac.PandaModules import *
hashVal = 2005027427
hashVal = 3860069384L
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 +11,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 DeleteManager, PurchaseManager, NewbiePurchaseManager
from toontown.shtiker import 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 +25,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, AccountDate
from toontown.catalog import CatalogManager
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 TTUFriendsManager

View file

@ -16,7 +16,6 @@ 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
@ -121,8 +120,6 @@ 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)

View file

@ -1,39 +0,0 @@
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

View file

@ -1,23 +0,0 @@
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)

View file

@ -363,9 +363,6 @@ 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:

View file

@ -548,9 +548,6 @@ 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:

View file

@ -121,7 +121,4 @@ class CatalogEmoteItem(CatalogItem.CatalogItem):
def encodeDatagram(self, dg, store):
CatalogItem.CatalogItem.encodeDatagram(self, dg, store)
dg.addUint8(self.emoteIndex)
dg.addBool(self.isSpecial)
def isGift(self):
return not self.getEmblemPrices()
dg.addBool(self.isSpecial)

View file

@ -115,9 +115,7 @@ class CatalogItem:
return self.saleItem
def isGift(self):
if self.getEmblemPrices():
return 0
return 1
return not self.getEmblemPrices()
def isRental(self):
return 0

View file

@ -45,11 +45,10 @@ 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.family = {}
self.ffList = []
self.friendList = []
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)
@ -92,7 +91,7 @@ class CatalogScreen(DirectFrame):
taskMgr.doMethodLater(12.0, clarabelleHelpText1, 'clarabelleHelpText1')
if hasattr(self, 'giftToggle'):
self.giftToggle['state'] = DGG.NORMAL
self.giftToggle['text'] = TTLocalizer.CatalogGiftToggleOn
self.giftToggle['text'] = TTLocalizer.CatalogGiftToggleOff
def hide(self):
self.ignore('CatalogItemPurchaseRequest')
@ -542,8 +541,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.__makeFFlist()
if len(self.ffList) > 0:
self.__makeFriendList()
if len(self.friendList) > 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)
@ -569,8 +568,8 @@ class CatalogScreen(DirectFrame):
clipNP = self.scrollList.attachNewNode(clipper)
self.scrollList.setClipPlane(clipNP)
self.__makeScrollList()
friendId = self.ffList[0]
self.__chooseFriend(self.ffList[0][0], self.ffList[0][1])
friendId = self.friendList[0]
self.__chooseFriend(self.friendList[0][0], self.friendList[0][1])
self.update()
self.createdGiftGui = 1
for i in range(4):
@ -865,11 +864,7 @@ class CatalogScreen(DirectFrame):
if self.responseDialog:
self.responseDialog.cleanup()
self.responseDialog = None
if self.giftAvatar:
if hasattr(self.giftAvatar, 'doId'):
self.giftAvatar.delete()
else:
self.giftAvatar = None
self.unloadFriend()
return
def unloadClarabelle(self):
@ -933,7 +928,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):
@ -1015,61 +1010,61 @@ class CatalogScreen(DirectFrame):
self.silverLabel.hide()
self.goldLabel.hide()
def checkFamily(self, doId):
test = 0
for familyMember in base.cr.avList:
if familyMember.id == doId:
test = 1
return test
def __makeFFlist(self):
def __makeFriendList(self):
for av in base.cr.avList:
if localAvatar.doId == av.id:
continue
self.friendList.append((av.id, av.name, NametagGlobals.CCNormal))
for id, handle in base.cr.friendsMap.items():
self.ffList.append((id, handle.getName(), NametagGlobals.CCFreeChat))
self.friendList.append((id, handle.getName(), NametagGlobals.getFriendColor(handle.commonChatFlags)))
def __makeScrollList(self):
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
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
self.scrollList.refresh()
def makeFamilyButton(self, familyId, familyName, colorCode):
# fg = NametagGlobals.getNameFg(colorCode, PGButton.SInactive)
def makeFriendButton(self, avId, avName, colorCode):
return DirectButton(
relief=None,
text=familyName,
text=avName,
text_scale=0.04,
text_align=TextNode.ALeft,
# text_fg=fg,
text_fg=NametagGlobals.NametagColors[colorCode][0][0],
text1_bg=self.textDownColor,
text2_bg=self.textRolloverColor,
text3_fg=self.textDisabledColor,
textMayChange=0,
command=self.__chooseFriend,
extraArgs=[familyId, familyName]
)
extraArgs=[avId, avName]
)
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:
if self.giftAvatar:
if hasattr(self.giftAvatar, 'doId'):
self.giftAvatar.disable()
self.giftAvatar.delete()
self.giftAvatar = None
if self.friendDoId and self.allowGetDetails:
self.unloadFriend()
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')

View file

@ -135,6 +135,8 @@ 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 = {

View file

@ -1,21 +0,0 @@
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])

View file

@ -1,9 +0,0 @@
from direct.directnotify import DirectNotifyGlobal
from direct.distributed.DistributedObjectAI import DistributedObjectAI
class DeleteManagerAI(DistributedObjectAI):
notify = DirectNotifyGlobal.directNotify.newCategory("DeleteManagerAI")
def setInventory(self, todo0):
pass

View file

@ -1687,9 +1687,6 @@ 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: