mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-23 11:42:39 -06:00
DANIEL: New npc friends page
This commit is contained in:
parent
7c0ba851c7
commit
7bad238cbe
7 changed files with 72 additions and 135 deletions
1
dependencies/astron/dclass/stride.dc
vendored
1
dependencies/astron/dclass/stride.dc
vendored
|
@ -637,7 +637,6 @@ dclass DistributedToon : DistributedPlayer {
|
|||
setTrackProgress(int8 = -1, uint32 = 0) required ownrecv db;
|
||||
setTrackBonusLevel(int8[] = [-1,-1,-1,-1,-1,-1,-1]) required broadcast ownrecv db;
|
||||
setInventory(blob = [0*7, 0*7, 0*7, 0*7, 0, 0*6, 0, 0*6, 0*7]) required ownrecv db;
|
||||
setMaxNPCFriends(uint16 = 16) required ownrecv db;
|
||||
setNPCFriendsDict(FriendEntry[] = []) required ownrecv db;
|
||||
setDefaultShard(uint32 = 0) required ownrecv broadcast db;
|
||||
setDefaultZone(uint32 = 0) required ownrecv broadcast db;
|
||||
|
|
|
@ -11,7 +11,7 @@ class NPCFriendPage(ShtikerPage.ShtikerPage):
|
|||
|
||||
def load(self):
|
||||
self.title = DirectLabel(parent=self, relief=None, text=TTLocalizer.NPCFriendPageTitle, text_scale=0.12, textMayChange=0, pos=(0, 0, 0.6))
|
||||
self.friendPanel = NPCFriendPanel.NPCFriendPanel(parent=self)
|
||||
self.friendPanel = NPCFriendPanel.NPCFriendPanel(parent=self, callable=False)
|
||||
self.friendPanel.setScale(0.1225)
|
||||
self.friendPanel.setZ(-0.03)
|
||||
return
|
||||
|
@ -22,7 +22,8 @@ class NPCFriendPage(ShtikerPage.ShtikerPage):
|
|||
del self.friendPanel
|
||||
|
||||
def updatePage(self):
|
||||
self.friendPanel.update(base.localAvatar.NPCFriendsDict, fCallable=0)
|
||||
self.friendPanel.setFriends(base.localAvatar.NPCFriendsDict)
|
||||
self.friendPanel.update()
|
||||
|
||||
def enter(self):
|
||||
self.updatePage()
|
||||
|
|
|
@ -149,7 +149,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
|
|||
self.maxMoney = 0
|
||||
self.maxBankMoney = 0
|
||||
self.emblems = [0, 0]
|
||||
self.maxNPCFriends = 16
|
||||
self.petId = 0
|
||||
self.petTutorialDone = False
|
||||
self.fishBingoTutorialDone = False
|
||||
|
@ -552,17 +551,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
|
|||
if chatString:
|
||||
self.displayWhisper(fromId, chatString, WTQuickTalker)
|
||||
|
||||
def setMaxNPCFriends(self, max):
|
||||
max &= 32767
|
||||
if max != self.maxNPCFriends:
|
||||
self.maxNPCFriends = max
|
||||
messenger.send(self.uniqueName('maxNPCFriendsChange'))
|
||||
else:
|
||||
self.maxNPCFriends = max
|
||||
|
||||
def getMaxNPCFriends(self):
|
||||
return self.maxNPCFriends
|
||||
|
||||
def getNPCFriendsDict(self):
|
||||
return self.NPCFriendsDict
|
||||
|
||||
|
|
|
@ -516,31 +516,6 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
|
|||
self.friendsList.append(friendId)
|
||||
self.air.questManager.toonMadeFriend(self)
|
||||
|
||||
def d_setMaxNPCFriends(self, max):
|
||||
self.sendUpdate('setMaxNPCFriends', [max])
|
||||
|
||||
def setMaxNPCFriends(self, max):
|
||||
if max & 32768:
|
||||
self.b_setSosPageFlag(1)
|
||||
max &= 32767
|
||||
configMax = simbase.config.GetInt('max-sos-cards', 16)
|
||||
if configMax != max:
|
||||
if self.sosPageFlag == 0:
|
||||
self.b_setMaxNPCFriends(configMax)
|
||||
else:
|
||||
self.b_setMaxNPCFriends(configMax | 32768)
|
||||
else:
|
||||
self.maxNPCFriends = max
|
||||
if self.maxNPCFriends != 8 and self.maxNPCFriends != 16:
|
||||
self.notify.warning('Wrong max SOS cards %s, %d' % (self.maxNPCFriends, self.doId))
|
||||
|
||||
def b_setMaxNPCFriends(self, max):
|
||||
self.setMaxNPCFriends(max)
|
||||
self.d_setMaxNPCFriends(max)
|
||||
|
||||
def getMaxNPCFriends(self):
|
||||
return self.maxNPCFriends
|
||||
|
||||
def getBattleId(self):
|
||||
if self.battleId >= 0:
|
||||
return self.battleId
|
||||
|
@ -591,8 +566,6 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
|
|||
if npcFriend in self.NPCFriendsDict:
|
||||
self.NPCFriendsDict[npcFriend] += numCalls
|
||||
elif npcFriend in npcFriends:
|
||||
if len(self.NPCFriendsDict.keys()) >= self.maxNPCFriends:
|
||||
return 0
|
||||
self.NPCFriendsDict[npcFriend] = numCalls
|
||||
else:
|
||||
self.notify.warning('invalid NPC: %d' % npcFriend)
|
||||
|
@ -600,8 +573,6 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
|
|||
if self.NPCFriendsDict[npcFriend] > self.maxCallsPerNPC:
|
||||
self.NPCFriendsDict[npcFriend] = self.maxCallsPerNPC
|
||||
self.d_setNPCFriendsDict(self.NPCFriendsDict)
|
||||
if self.sosPageFlag == 0:
|
||||
self.b_setMaxNPCFriends(self.maxNPCFriends | 32768)
|
||||
self.air.questManager.toonMadeNPCFriend(self, numCalls, method)
|
||||
return 1
|
||||
|
||||
|
|
|
@ -55,9 +55,6 @@ class DistributedToonUD(DistributedObjectUD):
|
|||
def setInventory(self, todo0):
|
||||
pass
|
||||
|
||||
def setMaxNPCFriends(self, todo0):
|
||||
pass
|
||||
|
||||
def setNPCFriendsDict(self, todo0):
|
||||
pass
|
||||
|
||||
|
|
|
@ -1,79 +1,86 @@
|
|||
from direct.gui.DirectGui import *
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from pandac.PandaModules import *
|
||||
import NPCToons
|
||||
import ToonHead
|
||||
import ToonDNA
|
||||
from toontown.toonbase import TTLocalizer
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
from toontown.toonbase import ToontownBattleGlobals
|
||||
from toontown.toon import LaughingManGlobals
|
||||
from toontown.toonbase import TTLocalizer, ToontownGlobals, ToontownBattleGlobals
|
||||
import NPCToons, ToonDNA, ToonHead
|
||||
|
||||
class NPCFriendPanel(DirectFrame):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('NPCFriendPanel')
|
||||
|
||||
def __init__(self, parent = aspect2d, **kw):
|
||||
def __init__(self, parent = aspect2d, callable = False, **kw):
|
||||
optiondefs = (('relief', None, None), ('doneEvent', None, None))
|
||||
self.defineoptions(kw, optiondefs)
|
||||
DirectFrame.__init__(self, parent=parent)
|
||||
base.cr.lol = self
|
||||
self.callable = callable
|
||||
self.cardList = []
|
||||
self.friendDict = {}
|
||||
self.pos = 0
|
||||
self.updateLayout()
|
||||
self.initialiseoptions(NPCFriendPanel)
|
||||
self.accept(localAvatar.uniqueName('maxNPCFriendsChange'), self.updateLayout)
|
||||
return None
|
||||
|
||||
def update(self, friendDict, fCallable = 0):
|
||||
friendList = friendDict.keys()
|
||||
for i in xrange(self.maxNPCFriends):
|
||||
card = self.cardList[i]
|
||||
try:
|
||||
NPCID = friendList[i]
|
||||
count = friendDict[NPCID]
|
||||
except IndexError:
|
||||
NPCID = None
|
||||
count = 0
|
||||
gui = loader.loadModel('phase_3.5/models/gui/battle_gui')
|
||||
buttonImage = (gui.find('**/PckMn_BackBtn'), gui.find('**/PckMn_BackBtn_Dn'), gui.find('**/PckMn_BackBtn_Rlvr'))
|
||||
self.leftArrow = DirectButton(parent=self, relief=None, image=buttonImage, pos=(-6.8, 0, 0), scale=3.8, command=self.addPageIndex, extraArgs=[-1])
|
||||
self.rightArrow = DirectButton(parent=self, relief=None, image=buttonImage, pos=(6.8, 0, 0), scale=-3.8, command=self.addPageIndex, extraArgs=[1])
|
||||
gui.removeNode()
|
||||
|
||||
card.update(NPCID, count, fCallable)
|
||||
self.leftArrow.hide()
|
||||
|
||||
return
|
||||
def addPageIndex(self, index):
|
||||
self.pos += (16 * index)
|
||||
|
||||
if self.pos > 0:
|
||||
self.leftArrow.show()
|
||||
else:
|
||||
self.leftArrow.hide()
|
||||
|
||||
self.update()
|
||||
|
||||
def update(self):
|
||||
friendList = self.friendDict.keys()
|
||||
cardNum = 0
|
||||
|
||||
for i in xrange(self.pos, self.pos + 16):
|
||||
card = self.cardList[cardNum]
|
||||
|
||||
if len(friendList) > i:
|
||||
npcId = friendList[i]
|
||||
card.update(npcId, self.friendDict[npcId], self.callable)
|
||||
self.rightArrow.show()
|
||||
else:
|
||||
card.update(None, 0, self.callable)
|
||||
self.rightArrow.hide()
|
||||
|
||||
cardNum += 1
|
||||
|
||||
def updateLayout(self):
|
||||
for card in self.cardList:
|
||||
card.destroy()
|
||||
|
||||
self.cardList = []
|
||||
self.maxNPCFriends = localAvatar.getMaxNPCFriends()
|
||||
rotateCard = False
|
||||
if self.maxNPCFriends == 8:
|
||||
rotateCard = True
|
||||
xOffset = -5.25
|
||||
yOffset = 2.3
|
||||
yOffset2 = -4.7
|
||||
elif self.maxNPCFriends == 16:
|
||||
xOffset = -5.2
|
||||
yOffset = 3.5
|
||||
yOffset2 = -2.45
|
||||
else:
|
||||
self.notify.error('got wrong max SOS cards %s' % self.maxNPCFriends)
|
||||
xOffset = -5.2
|
||||
yOffset = 3.5
|
||||
count = 0
|
||||
for i in xrange(self.maxNPCFriends):
|
||||
card = NPCFriendCard(parent=self, rotateCard=rotateCard, doneEvent=self['doneEvent'])
|
||||
|
||||
for i in xrange(16):
|
||||
card = NPCFriendCard(parent=self, doneEvent=self['doneEvent'])
|
||||
self.cardList.append(card)
|
||||
card.setPos(xOffset, 1, yOffset)
|
||||
card.setScale(0.75)
|
||||
xOffset += 3.5
|
||||
count += 1
|
||||
|
||||
if count % 4 == 0:
|
||||
xOffset = -5.25
|
||||
yOffset += yOffset2
|
||||
yOffset += -2.45
|
||||
|
||||
def setFriends(self, friends):
|
||||
self.friendDict = friends
|
||||
|
||||
class NPCFriendCard(DirectFrame):
|
||||
normalTextColor = (0.3, 0.25, 0.2, 1)
|
||||
maxRarity = 5
|
||||
sosTracks = ToontownBattleGlobals.Tracks + ToontownBattleGlobals.NPCTracks
|
||||
|
||||
def __init__(self, parent = aspect2dp, rotateCard = False, **kw):
|
||||
def __init__(self, parent = aspect2dp, **kw):
|
||||
optiondefs = (('NPCID', 'Uninitialized', None), ('relief', None, None), ('doneEvent', None, None))
|
||||
self.defineoptions(kw, optiondefs)
|
||||
DirectFrame.__init__(self, parent=parent)
|
||||
|
@ -81,41 +88,10 @@ class NPCFriendCard(DirectFrame):
|
|||
cardModel = loader.loadModel('phase_3.5/models/gui/playingCard')
|
||||
self.front = DirectFrame(parent=self, relief=None, image=cardModel.find('**/card_front'))
|
||||
self.front.hide()
|
||||
self.back = DirectFrame(parent=self, relief=None, image=cardModel.find('**/card_back'), geom=cardModel.find('**/logo'))
|
||||
callButtonPosZ = -0.9
|
||||
textWordWrap = 16.0
|
||||
textScale = 0.35
|
||||
textPosZ = 1.15
|
||||
nameScale = 0.4
|
||||
namePosZ = -0.45
|
||||
rarityScale = 0.2
|
||||
rarityPosZ = -1.2
|
||||
self.NPCHeadDim = 1.2
|
||||
self.NPCHeadPosZ = 0.45
|
||||
self.sosCountInfoPosZ = -0.9
|
||||
self.sosCountInfoScale = 0.4
|
||||
self.sosCountInfo2PosZ = -0.9
|
||||
self.sosCountInfo2Scale = 0.5
|
||||
if rotateCard:
|
||||
self.front.component('image0').configure(pos=(0, 0, 0.22), hpr=(0, 0, -90), scale=1.35)
|
||||
self.back.component('image0').configure(hpr=(0, 0, -90), scale=(-1.35, 1.35, 1.35))
|
||||
callButtonPosZ = -2.1
|
||||
textWordWrap = 7.0
|
||||
textScale = 0.5
|
||||
textPosZ = 2.0
|
||||
nameScale = 0.5
|
||||
namePosZ = -0.89
|
||||
rarityScale = 0.25
|
||||
rarityPosZ = -2.4
|
||||
self.NPCHeadDim = 1.8
|
||||
self.NPCHeadPosZ = 0.4
|
||||
self.sosCountInfoPosZ = -2.1
|
||||
self.sosCountInfoScale = 0.4
|
||||
self.sosCountInfo2PosZ = -2.0
|
||||
self.sosCountInfo2Scale = 0.55
|
||||
self.sosTypeInfo = DirectLabel(parent=self.front, relief=None, text='', text_font=ToontownGlobals.getMinnieFont(), text_fg=self.normalTextColor, text_scale=textScale, text_align=TextNode.ACenter, text_wordwrap=textWordWrap, pos=(0, 0, textPosZ))
|
||||
self.back = DirectFrame(parent=self, relief=None, image=cardModel.find('**/card_back'))
|
||||
self.sosTypeInfo = DirectLabel(parent=self.front, relief=None, text='', text_font=ToontownGlobals.getMinnieFont(), text_fg=self.normalTextColor, text_scale=0.35, text_align=TextNode.ACenter, text_wordwrap=16.0, pos=(0, 0, 1.15))
|
||||
self.NPCHead = None
|
||||
self.NPCName = DirectLabel(parent=self.front, relief=None, text='', text_fg=self.normalTextColor, text_scale=nameScale, text_align=TextNode.ACenter, text_wordwrap=8.0, pos=(0, 0, namePosZ))
|
||||
self.NPCName = DirectLabel(parent=self.front, relief=None, text='', text_fg=self.normalTextColor, text_scale=0.4, text_align=TextNode.ACenter, text_wordwrap=8.0, pos=(0, 0, -0.45))
|
||||
buttonModels = loader.loadModel('phase_3.5/models/gui/inventory_gui')
|
||||
upButton = buttonModels.find('**/InventoryButtonUp')
|
||||
downButton = buttonModels.find('**/InventoryButtonDown')
|
||||
|
@ -123,18 +99,17 @@ class NPCFriendCard(DirectFrame):
|
|||
self.sosCallButton = DirectButton(parent=self.front, relief=None, text=TTLocalizer.NPCCallButtonLabel, text_fg=self.normalTextColor, text_scale=0.28, text_align=TextNode.ACenter, image=(upButton,
|
||||
downButton,
|
||||
rolloverButton,
|
||||
upButton), image_color=(1.0, 0.2, 0.2, 1), image0_color=Vec4(1.0, 0.4, 0.4, 1), image3_color=Vec4(1.0, 0.4, 0.4, 0.4), image_scale=(4.4, 1, 3.6), image_pos=Vec3(0, 0, 0.08), pos=(-1.15, 0, callButtonPosZ), scale=1.25, command=self.__chooseNPCFriend)
|
||||
upButton), image_color=(1.0, 0.2, 0.2, 1), image0_color=Vec4(1.0, 0.4, 0.4, 1), image3_color=Vec4(1.0, 0.4, 0.4, 0.4), image_scale=(4.4, 1, 3.6), image_pos=Vec3(0, 0, 0.08), pos=(-1.15, 0, -0.9), scale=1.25, command=self.__chooseNPCFriend)
|
||||
self.sosCallButton.hide()
|
||||
self.sosCountInfo = DirectLabel(parent=self.front, relief=None, text='', text_fg=self.normalTextColor, text_scale=0.75, text_align=TextNode.ALeft, textMayChange=1, pos=(0.0, 0, -1.0))
|
||||
star = loader.loadModel('phase_3.5/models/gui/name_star')
|
||||
self.rarityStars = []
|
||||
|
||||
for i in xrange(self.maxRarity):
|
||||
label = DirectLabel(parent=self.front, relief=None, image=star, image_scale=rarityScale, image_color=Vec4(0.502, 0.251, 0.251, 1.0), pos=(1.1 - i * 0.24, 0, rarityPosZ))
|
||||
label = DirectLabel(parent=self.front, relief=None, image=star, image_scale=0.2, image_color=Vec4(0.502, 0.251, 0.251, 1.0), pos=(1.1 - i * 0.24, 0, -1.2))
|
||||
label.hide()
|
||||
self.rarityStars.append(label)
|
||||
|
||||
return
|
||||
|
||||
def __chooseNPCFriend(self):
|
||||
if self['NPCID'] and self['doneEvent']:
|
||||
doneStatus = {}
|
||||
|
@ -146,11 +121,13 @@ class NPCFriendCard(DirectFrame):
|
|||
if self.NPCHead:
|
||||
self.NPCHead.detachNode()
|
||||
self.NPCHead.delete()
|
||||
|
||||
DirectFrame.destroy(self)
|
||||
|
||||
def update(self, NPCID, count = 0, fCallable = 0):
|
||||
oldNPCID = self['NPCID']
|
||||
self['NPCID'] = NPCID
|
||||
|
||||
if NPCID != oldNPCID:
|
||||
if self.NPCHead:
|
||||
self.NPCHead.detachNode()
|
||||
|
@ -158,14 +135,16 @@ class NPCFriendCard(DirectFrame):
|
|||
if NPCID is None:
|
||||
self.showBack()
|
||||
return
|
||||
|
||||
self.front.show()
|
||||
self.back.hide()
|
||||
self.NPCName['text'] = TTLocalizer.NPCToonNames[NPCID]
|
||||
self.NPCHead = self.createNPCToonHead(NPCID, dimension=self.NPCHeadDim)
|
||||
self.NPCHead = self.createNPCToonHead(NPCID, dimension=1.2)
|
||||
self.NPCHead.reparentTo(self.front)
|
||||
self.NPCHead.setZ(self.NPCHeadPosZ)
|
||||
self.NPCHead.setZ(0.45)
|
||||
track, level, hp, rarity = NPCToons.getNPCTrackLevelHpRarity(NPCID)
|
||||
sosText = self.sosTracks[track]
|
||||
|
||||
if track == ToontownBattleGlobals.NPC_RESTOCK_GAGS:
|
||||
if level == -1:
|
||||
sosText += ' All'
|
||||
|
@ -173,6 +152,7 @@ class NPCFriendCard(DirectFrame):
|
|||
sosText += ' ' + self.sosTracks[level]
|
||||
sosText = TextEncoder.upper(sosText)
|
||||
self.sosTypeInfo['text'] = sosText
|
||||
|
||||
for i in xrange(self.maxRarity):
|
||||
if i < rarity:
|
||||
self.rarityStars[i].show()
|
||||
|
@ -181,13 +161,13 @@ class NPCFriendCard(DirectFrame):
|
|||
|
||||
if fCallable:
|
||||
self.sosCallButton.show()
|
||||
self.sosCountInfo.setPos(-0.4, 0, self.sosCountInfoPosZ)
|
||||
self.sosCountInfo['text_scale'] = self.sosCountInfoScale
|
||||
self.sosCountInfo.setPos(-0.4, 0, -0.9)
|
||||
self.sosCountInfo['text_scale'] = 0.4
|
||||
self.sosCountInfo['text_align'] = TextNode.ALeft
|
||||
else:
|
||||
self.sosCallButton.hide()
|
||||
self.sosCountInfo.setPos(0, 0, self.sosCountInfo2PosZ)
|
||||
self.sosCountInfo['text_scale'] = self.sosCountInfo2Scale
|
||||
self.sosCountInfo.setPos(0, 0, -0.9)
|
||||
self.sosCountInfo['text_scale'] = 0.5
|
||||
self.sosCountInfo['text_align'] = TextNode.ACenter
|
||||
if count > 0:
|
||||
countText = TTLocalizer.NPCFriendPanelRemaining % count
|
||||
|
|
|
@ -40,7 +40,7 @@ class TownBattleSOSPanel(DirectFrame, StateData.StateData):
|
|||
self['image_pos'] = (0.0, 0.1, -0.08)
|
||||
self.setScale(0.3)
|
||||
self.title = DirectLabel(parent=self, relief=None, text=TTLocalizer.TownBattleSOSNoFriends, text_scale=0.4, text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), pos=(0.0, 0.0, 1.5))
|
||||
self.NPCFriendPanel = NPCFriendPanel.NPCFriendPanel(parent=self, doneEvent=self.doneEvent)
|
||||
self.NPCFriendPanel = NPCFriendPanel.NPCFriendPanel(parent=self, callable=True, doneEvent=self.doneEvent)
|
||||
self.NPCFriendPanel.setPos(-0.75, 0, -0.15)
|
||||
self.NPCFriendPanel.setScale(0.325)
|
||||
self.NPCFriendsLabel = DirectLabel(parent=self, relief=None, text=TTLocalizer.TownBattleSOSNPCFriends, text_scale=0.3, text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), pos=(-0.75, 0.0, -2.0))
|
||||
|
@ -195,7 +195,8 @@ class TownBattleSOSPanel(DirectFrame, StateData.StateData):
|
|||
else:
|
||||
self.NPCFriends[friend] = count
|
||||
|
||||
self.NPCFriendPanel.update(self.NPCFriends, fCallable=1)
|
||||
self.NPCFriendPanel.setFriends(self.NPCFriends)
|
||||
self.NPCFriendPanel.update()
|
||||
|
||||
def __updateTitleText(self):
|
||||
isEmpty = (len(self.friends) == 0 and len(self.NPCFriends) == 0)
|
||||
|
|
Loading…
Reference in a new issue