2015-03-03 16:10:12 -06:00
|
|
|
import CatalogItem
|
|
|
|
from toontown.toonbase import ToontownGlobals
|
|
|
|
from toontown.toonbase import TTLocalizer
|
|
|
|
from otp.otpbase import OTPLocalizer
|
|
|
|
from direct.interval.IntervalGlobal import *
|
|
|
|
|
|
|
|
class CatalogEmoteItem(CatalogItem.CatalogItem):
|
|
|
|
sequenceNumber = 0
|
|
|
|
pictureToon = None
|
|
|
|
|
2015-07-23 15:00:50 -05:00
|
|
|
def makeNewItem(self, emoteIndex, isSpecial = False):
|
2015-03-03 16:10:12 -06:00
|
|
|
self.emoteIndex = emoteIndex
|
2015-07-23 15:00:50 -05:00
|
|
|
self.isSpecial = isSpecial
|
2015-03-03 16:10:12 -06:00
|
|
|
CatalogItem.CatalogItem.makeNewItem(self)
|
|
|
|
|
|
|
|
def getPurchaseLimit(self):
|
|
|
|
return 1
|
|
|
|
|
|
|
|
def reachedPurchaseLimit(self, avatar):
|
2015-07-23 15:00:50 -05:00
|
|
|
if self in avatar.onOrder or self in avatar.mailboxContents or self in avatar.onGiftOrder:
|
2015-03-03 16:10:12 -06:00
|
|
|
return 1
|
|
|
|
if self.emoteIndex >= len(avatar.emoteAccess):
|
|
|
|
return 0
|
|
|
|
return avatar.emoteAccess[self.emoteIndex] != 0
|
|
|
|
|
|
|
|
def getAcceptItemErrorText(self, retcode):
|
|
|
|
if retcode == ToontownGlobals.P_ItemAvailable:
|
|
|
|
return TTLocalizer.CatalogAcceptEmote
|
|
|
|
return CatalogItem.CatalogItem.getAcceptItemErrorText(self, retcode)
|
|
|
|
|
|
|
|
def saveHistory(self):
|
|
|
|
return 1
|
|
|
|
|
|
|
|
def getTypeName(self):
|
|
|
|
return TTLocalizer.EmoteTypeName
|
|
|
|
|
|
|
|
def getName(self):
|
|
|
|
return OTPLocalizer.EmoteList[self.emoteIndex]
|
|
|
|
|
|
|
|
def recordPurchase(self, avatar, optional):
|
|
|
|
if self.emoteIndex < 0 or self.emoteIndex > len(avatar.emoteAccess):
|
|
|
|
self.notify.warning('Invalid emote access: %s for avatar %s' % (self.emoteIndex, avatar.doId))
|
|
|
|
return ToontownGlobals.P_InvalidIndex
|
|
|
|
avatar.emoteAccess[self.emoteIndex] = 1
|
|
|
|
avatar.d_setEmoteAccess(avatar.emoteAccess)
|
|
|
|
return ToontownGlobals.P_ItemAvailable
|
|
|
|
|
|
|
|
def getPicture(self, avatar):
|
|
|
|
from toontown.toon import Toon
|
|
|
|
from toontown.toon import ToonHead
|
|
|
|
from toontown.toon import TTEmote
|
|
|
|
from otp.avatar import Emote
|
|
|
|
self.hasPicture = True
|
|
|
|
if self.emoteIndex in Emote.globalEmote.getHeadEmotes():
|
|
|
|
toon = ToonHead.ToonHead()
|
|
|
|
toon.setupHead(avatar.style, forGui=1)
|
|
|
|
else:
|
|
|
|
toon = Toon.Toon()
|
|
|
|
toon.setDNA(avatar.style)
|
|
|
|
toon.loop('neutral')
|
|
|
|
toon.setH(180)
|
|
|
|
model, ival = self.makeFrameModel(toon, 0)
|
|
|
|
track, duration = Emote.globalEmote.doEmote(toon, self.emoteIndex, volume=self.volume)
|
|
|
|
if duration == None:
|
|
|
|
duration = 0
|
|
|
|
name = 'emote-item-%s' % self.sequenceNumber
|
|
|
|
CatalogEmoteItem.sequenceNumber += 1
|
|
|
|
if track != None:
|
|
|
|
track = Sequence(Sequence(track, duration=0), Wait(duration + 2), name=name)
|
|
|
|
else:
|
|
|
|
track = Sequence(Func(Emote.globalEmote.doEmote, toon, self.emoteIndex), Wait(duration + 4), name=name)
|
|
|
|
self.pictureToon = toon
|
|
|
|
return (model, track)
|
|
|
|
|
|
|
|
def changeIval(self, volume):
|
|
|
|
from toontown.toon import Toon
|
|
|
|
from toontown.toon import ToonHead
|
|
|
|
from toontown.toon import TTEmote
|
|
|
|
from otp.avatar import Emote
|
|
|
|
self.volume = volume
|
|
|
|
if not hasattr(self, 'pictureToon'):
|
|
|
|
return Sequence()
|
|
|
|
track, duration = Emote.globalEmote.doEmote(self.pictureToon, self.emoteIndex, volume=self.volume)
|
|
|
|
if duration == None:
|
|
|
|
duration = 0
|
|
|
|
name = 'emote-item-%s' % self.sequenceNumber
|
|
|
|
CatalogEmoteItem.sequenceNumber += 1
|
|
|
|
if track != None:
|
|
|
|
track = Sequence(Sequence(track, duration=0), Wait(duration + 2), name=name)
|
|
|
|
else:
|
|
|
|
track = Sequence(Func(Emote.globalEmote.doEmote, toon, self.emoteIndex), Wait(duration + 4), name=name)
|
|
|
|
return track
|
|
|
|
|
|
|
|
def cleanupPicture(self):
|
|
|
|
CatalogItem.CatalogItem.cleanupPicture(self)
|
|
|
|
self.pictureToon.emote.finish()
|
|
|
|
self.pictureToon.emote = None
|
|
|
|
self.pictureToon.delete()
|
|
|
|
self.pictureToon = None
|
|
|
|
return
|
|
|
|
|
|
|
|
def output(self, store = -1):
|
|
|
|
return 'CatalogEmoteItem(%s%s)' % (self.emoteIndex, self.formatOptionalData(store))
|
|
|
|
|
|
|
|
def compareTo(self, other):
|
|
|
|
return self.emoteIndex - other.emoteIndex
|
|
|
|
|
|
|
|
def getHashContents(self):
|
|
|
|
return self.emoteIndex
|
|
|
|
|
|
|
|
def getBasePrice(self):
|
|
|
|
return 550
|
|
|
|
|
|
|
|
def decodeDatagram(self, di, versionNumber, store):
|
|
|
|
CatalogItem.CatalogItem.decodeDatagram(self, di, versionNumber, store)
|
|
|
|
self.emoteIndex = di.getUint8()
|
2015-07-23 15:00:50 -05:00
|
|
|
self.isSpecial = di.getBool()
|
2015-03-03 16:10:12 -06:00
|
|
|
if self.emoteIndex > len(OTPLocalizer.EmoteList):
|
|
|
|
raise ValueError
|
|
|
|
|
|
|
|
def encodeDatagram(self, dg, store):
|
|
|
|
CatalogItem.CatalogItem.encodeDatagram(self, dg, store)
|
|
|
|
dg.addUint8(self.emoteIndex)
|
2015-07-23 15:00:50 -05:00
|
|
|
dg.addBool(self.isSpecial)
|
2015-05-16 23:52:07 -05:00
|
|
|
|
|
|
|
def isGift(self):
|
2015-07-23 15:00:50 -05:00
|
|
|
return not self.getEmblemPrices()
|