mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2025-01-09 17:53:50 +00:00
Group Manager
This commit is contained in:
parent
e3c34e4fe8
commit
d4557e69fa
17 changed files with 134 additions and 456 deletions
19
dependencies/astron/dclass/stride.dc
vendored
19
dependencies/astron/dclass/stride.dc
vendored
|
@ -230,7 +230,6 @@ 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
|
||||
from toontown.shtiker import NewbiePurchaseManager/AI
|
||||
|
@ -556,6 +555,7 @@ dclass ToontownDistrictStats : DistributedObject {
|
|||
setDistrictId(uint32) broadcast required ram;
|
||||
setAvatarCount(uint32) broadcast required ram;
|
||||
setInvasionStatus(uint8) broadcast required ram;
|
||||
setGroupAvCount(uint32[]) broadcast required ram;
|
||||
};
|
||||
|
||||
dclass DistributedAnimatedProp : DistributedObject {
|
||||
|
@ -1471,23 +1471,6 @@ dclass DeleteManager : DistributedObject {
|
|||
setInventory(blob) airecv clsend;
|
||||
};
|
||||
|
||||
dclass GroupManager : DistributedObject {
|
||||
setChildId() clsend airecv;
|
||||
isPlayerGrouped(uint32);
|
||||
isInGroup(uint32, uint32);
|
||||
updateInfo() clsend airecv;
|
||||
requestInfo() broadcast ram;
|
||||
getTypeFromId(uint32);
|
||||
setGroups(string) broadcast ram;
|
||||
getGroups();
|
||||
setGroupPlayers(string) broadcast ram;
|
||||
getGroupPlayers(uint32);
|
||||
createGroup(uint32, string) clsend airecv;
|
||||
closeGroup(uint32) clsend airecv;
|
||||
addPlayerToGroup(uint32, uint32) clsend airecv;
|
||||
removePlayerFromGroup(uint32, uint32) clsend airecv;
|
||||
};
|
||||
|
||||
dclass NewsManager : DistributedObject {
|
||||
startHoliday(uint8) broadcast;
|
||||
endHoliday(uint8) broadcast;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from direct.directnotify.DirectNotifyGlobal import directNotify
|
||||
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
|
||||
class DistributedDistrictAI(DistributedObjectAI):
|
||||
notify = directNotify.newCategory('DistributedDistrictAI')
|
||||
|
@ -8,16 +7,6 @@ class DistributedDistrictAI(DistributedObjectAI):
|
|||
name = 'District'
|
||||
available = 0
|
||||
|
||||
def announceGenerate(self):
|
||||
DistributedObjectAI.announceGenerate(self)
|
||||
doId = self.doId - (self.doId % 100000000 % 1000000)
|
||||
self.air.groupManager.shardGroups[doId] = {
|
||||
ToontownGlobals.SellbotHQ: ['VP Group', []],
|
||||
ToontownGlobals.CashbotHQ: ['CFO Group', []],
|
||||
ToontownGlobals.LawbotHQ: ['CJ Group', []],
|
||||
ToontownGlobals.BossbotHQ: ['CEO Group', []],
|
||||
}
|
||||
|
||||
def setName(self, name):
|
||||
self.name = name
|
||||
|
||||
|
|
|
@ -1071,7 +1071,7 @@ class OTPClientRepository(ClientRepositoryBase):
|
|||
|
||||
for s in self.activeDistrictMap.values():
|
||||
if s.available:
|
||||
list.append((s.doId, s.name, s.avatarCount, s.invasionStatus))
|
||||
list.append((s.doId, s.name, s.avatarCount, s.invasionStatus, s.groupAvCount))
|
||||
|
||||
return list
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ OTP_DO_ID_FRIEND_MANAGER = 4501
|
|||
OTP_DO_ID_TOONTOWN = 1337
|
||||
OTP_DO_ID_CLIENT_SERVICES_MANAGER = 4665
|
||||
OTP_DO_ID_TTS_FRIENDS_MANAGER = 4666
|
||||
OPT_DO_ID_GROUP_MANAGER = 4667
|
||||
OTP_DO_ID_GLOBAL_PARTY_MANAGER = 4477
|
||||
OTP_DO_ID_GLOBAL_LOBBY_MANAGER = 4478
|
||||
OTP_DO_ID_CHAT_MANAGER = 4681
|
||||
|
|
|
@ -46,7 +46,6 @@ from toontown.racing.LeaderboardMgrAI import LeaderboardMgrAI
|
|||
from toontown.pets.PetManagerAI import PetManagerAI
|
||||
from toontown.safezone.SafeZoneManagerAI import SafeZoneManagerAI
|
||||
from toontown.suit.SuitInvasionManagerAI import SuitInvasionManagerAI
|
||||
from toontown.groups.GroupManagerAI import GroupManagerAI
|
||||
from toontown.toon import NPCToons
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
from toontown.tutorial.TutorialManagerAI import TutorialManagerAI
|
||||
|
@ -72,7 +71,6 @@ class ToontownAIRepository(ToontownInternalRepository):
|
|||
self.mintMgr = None
|
||||
self.lawOfficeMgr = None
|
||||
self.countryClubMgr = None
|
||||
self.groupManager = GroupManagerAI(self)
|
||||
|
||||
self.zoneAllocator = UniqueIdAllocator(ToontownGlobals.DynamicZonesBegin,
|
||||
ToontownGlobals.DynamicZonesEnd)
|
||||
|
@ -121,7 +119,6 @@ class ToontownAIRepository(ToontownInternalRepository):
|
|||
self.codeRedemptionMgr.generateWithRequired(2)
|
||||
self.buildingQueryMgr = DistributedBuildingQueryMgrAI(self)
|
||||
self.buildingQueryMgr.generateWithRequired(2)
|
||||
self.groupManager.generateWithRequired(2)
|
||||
if self.wantTopToons:
|
||||
self.topToonsMgr = TopToonsManagerAI(self)
|
||||
if self.wantKarts:
|
||||
|
|
|
@ -10,3 +10,4 @@ class ToontownDistrict(DistributedDistrict.DistributedDistrict):
|
|||
self.avatarCount = 0
|
||||
self.invasionStatus = 0
|
||||
self.suitStatus = ''
|
||||
self.groupAvCount = []
|
||||
|
|
|
@ -75,7 +75,14 @@ class ToontownDistrictStats(DistributedObject.DistributedObject):
|
|||
def setAvatarCount(self, avatarCount):
|
||||
if self.districtId in self.cr.activeDistrictMap:
|
||||
self.cr.activeDistrictMap[self.districtId].avatarCount = avatarCount
|
||||
messenger.send('shardInfoUpdated')
|
||||
|
||||
def setInvasionStatus(self, invasionStatus):
|
||||
if self.districtId in self.cr.activeDistrictMap:
|
||||
self.cr.activeDistrictMap[self.districtId].invasionStatus = invasionStatus
|
||||
messenger.send('shardInfoUpdated')
|
||||
|
||||
def setGroupAvCount(self, groupAvCount):
|
||||
if self.districtId in self.cr.activeDistrictMap:
|
||||
self.cr.activeDistrictMap[self.districtId].groupAvCount = groupAvCount=
|
||||
messenger.send('shardInfoUpdated')
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from direct.directnotify.DirectNotifyGlobal import directNotify
|
||||
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
from toontown.toon import DistributedToonAI
|
||||
|
||||
class ToontownDistrictStatsAI(DistributedObjectAI):
|
||||
notify = directNotify.newCategory('ToontownDistrictStatsAI')
|
||||
|
@ -7,13 +9,19 @@ class ToontownDistrictStatsAI(DistributedObjectAI):
|
|||
districtId = 0
|
||||
avatarCount = 0
|
||||
invasionStatus = 0
|
||||
groupAvCount = [0] * len(ToontownGlobals.GROUP_ZONES)
|
||||
|
||||
def announceGenerate(self):
|
||||
DistributedObjectAI.announceGenerate(self)
|
||||
|
||||
# We want to handle shard status queries so that a ShardStatusReceiver
|
||||
# being created after we're generated will know where we're at:
|
||||
self.air.accept('shardStatus', self.handleShardStatusQuery)
|
||||
self.air.accept('queryShardStatus', self.handleShardStatusQuery)
|
||||
taskMgr.doMethodLater(15, self.__countGroups, self.uniqueName('countGroups'))
|
||||
|
||||
def delete(self):
|
||||
taskMgr.remove(self.uniqueName('countGroups'))
|
||||
DistributedObjectAI.delete(self)
|
||||
|
||||
def handleShardStatusQuery(self):
|
||||
# Send a shard status update containing our population:
|
||||
|
@ -62,3 +70,27 @@ class ToontownDistrictStatsAI(DistributedObjectAI):
|
|||
|
||||
def getInvasionStatus(self):
|
||||
return self.invasionStatus
|
||||
|
||||
def setGroupAvCount(self, groupAvCount):
|
||||
self.groupAvCount = groupAvCount
|
||||
|
||||
def d_setGroupAvCount(self, groupAvCount):
|
||||
self.sendUpdate('setGroupAvCount', [groupAvCount])
|
||||
|
||||
def b_setGroupAvCount(self, groupAvCount):
|
||||
self.setGroupAvCount(groupAvCount)
|
||||
self.d_setGroupAvCount(groupAvCount)
|
||||
|
||||
def getGroupAvCount(self):
|
||||
return self.groupAvCount
|
||||
|
||||
def __countGroups(self, task):
|
||||
zones = ToontownGlobals.GROUP_ZONES
|
||||
self.groupAvCount = [0] * len(zones)
|
||||
|
||||
for av in self.air.doId2do.values():
|
||||
if isinstance(av, DistributedToonAI.DistributedToonAI) and av.isPlayerControlled() and av.zoneId in zones:
|
||||
self.groupAvCount[zones.index(av.zoneId)] += 1
|
||||
|
||||
taskMgr.doMethodLater(15, self.__countGroups, self.uniqueName('countGroups'))
|
||||
self.b_setGroupAvCount(self.groupAvCount)
|
|
@ -1,20 +0,0 @@
|
|||
class GlobalGroup:
|
||||
|
||||
def __init__(self, groupType, groupId):
|
||||
self.activePlayers = []
|
||||
self.groupType = groupType
|
||||
self.groupId = groupId
|
||||
|
||||
def getGroupPlayers(self):
|
||||
return self.activePlayers
|
||||
|
||||
def isInGroup(self, avId):
|
||||
if avId in self.activePlayers:
|
||||
return True
|
||||
return False
|
||||
|
||||
def addPlayerToGroup(self, avId):
|
||||
self.activePlayers.append(avId)
|
||||
|
||||
def removePlayerFromGroup(self, avId):
|
||||
self.activePlayers.remove(avId)
|
|
@ -1,78 +0,0 @@
|
|||
from panda3d.core import *
|
||||
from direct.distributed import DistributedObject
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from toontown.toonbase.ToontownGlobals import *
|
||||
|
||||
class GroupManager(DistributedObject.DistributedObject):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('GroupManager')
|
||||
neverDisable = 1
|
||||
|
||||
def __init__(self, cr):
|
||||
DistributedObject.DistributedObject.__init__(self, cr)
|
||||
self.shardGroups = {}
|
||||
self.groupPlayers = {}
|
||||
self.id2type = {
|
||||
SellbotHQ: 'VP',
|
||||
CashbotHQ: 'CFO',
|
||||
LawbotHQ: 'CJ',
|
||||
BossbotHQ: 'CEO',
|
||||
}
|
||||
|
||||
def announceGenerate(self):
|
||||
DistributedObject.DistributedObject.announceGenerate(self)
|
||||
self.cr.groupManager = self
|
||||
self.d_setChildId()
|
||||
|
||||
def delete(self):
|
||||
DistributedObject.DistributedObject.delete(self)
|
||||
self.cr.groupManager = None
|
||||
|
||||
def d_setChildId(self):
|
||||
self.sendUpdate('setChildId', [])
|
||||
|
||||
def isPlayerGrouped(self, avId):
|
||||
for group in self.groupPlayers.values():
|
||||
if avId in group:
|
||||
return True
|
||||
return False
|
||||
|
||||
def isInGroup(self, avId, groupId):
|
||||
group = self.groupPlayers.get(groupId)
|
||||
if group is None:
|
||||
return False
|
||||
if avId in group:
|
||||
return True
|
||||
return False
|
||||
|
||||
def requestInfo(self):
|
||||
self.sendUpdate('updateInfo', [])
|
||||
|
||||
def getTypeFromId(self, groupId):
|
||||
return self.id2type.get(groupId)
|
||||
|
||||
def setGroups(self, shardGroups):
|
||||
self.shardGroups = eval(shardGroups)
|
||||
|
||||
def getGroups(self):
|
||||
return self.shardGroups
|
||||
|
||||
def setGroupPlayers(self, groupPlayers):
|
||||
self.groupPlayers = eval(groupPlayers)
|
||||
|
||||
def getGroupPlayers(self, groupId):
|
||||
group = self.groupPlayers.get(groupId)
|
||||
if group is None:
|
||||
return []
|
||||
return group
|
||||
|
||||
def d_createGroup(self, groupId, groupType):
|
||||
self.sendUpdate('createGroup', [groupId, groupType])
|
||||
|
||||
def d_closeGroup(self, groupId):
|
||||
self.sendUpdate('closeGroup', [groupId])
|
||||
|
||||
def d_addPlayerToGroup(self, groupId, avId):
|
||||
self.sendUpdate('addPlayerToGroup', [groupId, avId])
|
||||
|
||||
def d_removePlayerFromGroup(self, groupId, avId):
|
||||
self.sendUpdate('removePlayerFromGroup', [groupId, avId])
|
|
@ -1,129 +0,0 @@
|
|||
from panda3d.core import *
|
||||
from direct.task import Task
|
||||
from direct.distributed import DistributedObjectAI
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from toontown.toonbase.ToontownGlobals import *
|
||||
from GlobalGroup import GlobalGroup
|
||||
|
||||
class GroupManagerAI(DistributedObjectAI.DistributedObjectAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('GroupManagerAI')
|
||||
|
||||
def __init__(self, air):
|
||||
DistributedObjectAI.DistributedObjectAI.__init__(self, air)
|
||||
self.sellGroup = GlobalGroup('VP', SellbotHQ)
|
||||
self.cashGroup = GlobalGroup('CFO', CashbotHQ)
|
||||
self.lawGroup = GlobalGroup('CJ', LawbotHQ)
|
||||
self.bossGroup = GlobalGroup('CEO', BossbotHQ)
|
||||
self.shardGroups = {
|
||||
SellbotHQ: self.sellGroup,
|
||||
CashbotHQ: self.cashGroup,
|
||||
LawbotHQ: self.lawGroup,
|
||||
BossbotHQ: self.bossGroup,
|
||||
}
|
||||
self.groupPlayers = {
|
||||
SellbotHQ: [],
|
||||
CashbotHQ: [],
|
||||
LawbotHQ: [],
|
||||
BossbotHQ: [],
|
||||
}
|
||||
self.id2type = {
|
||||
SellbotHQ: 'VP',
|
||||
CashbotHQ: 'CFO',
|
||||
LawbotHQ: 'CJ',
|
||||
BossbotHQ: 'CEO',
|
||||
}
|
||||
self.childId = None
|
||||
|
||||
def announceGenerate(self):
|
||||
DistributedObjectAI.DistributedObjectAI.announceGenerate(self)
|
||||
self.air.groupManager = self
|
||||
self.confirmActiveToons = taskMgr.doMethodLater(45, self.confirmToonsInGroup, 'confirmActiveToons')
|
||||
|
||||
def delete(self):
|
||||
DistributedObjectAI.DistributedObjectAI.delete(self)
|
||||
taskMgr.remove('confirmActiveToons')
|
||||
self.air.groupManager = None
|
||||
|
||||
def setChildId(self):
|
||||
doId = self.air.getAvatarIdFromSender()
|
||||
self.childId = doId
|
||||
self.sendUpdateToAvatarId(self.childId, 'requestInfo', [])
|
||||
|
||||
def isPlayerGrouped(self, avId):
|
||||
for group in self.shardGroups.values():
|
||||
if avId in group.getGroupPlayers():
|
||||
return True
|
||||
return False
|
||||
|
||||
def isInGroup(self, avId, groupId):
|
||||
group = self.shardGroups.get(groupId)
|
||||
if group is None:
|
||||
return False
|
||||
if avId in group.getGroupPlayers():
|
||||
return True
|
||||
return False
|
||||
|
||||
def confirmToonsInGroup(self, task):
|
||||
for groupId, group in self.groupPlayers.items():
|
||||
for player in group:
|
||||
toon = simbase.air.doId2do.get(player)
|
||||
if (toon.zoneId != groupId) or (toon.zoneId + 100 != groupId):
|
||||
self.removePlayerFromGroup(groupId, player)
|
||||
return task.again
|
||||
|
||||
def updateInfo(self):
|
||||
self.d_setGroupPlayers(str(self.groupPlayers))
|
||||
self.d_setGroups(str(self.id2type))
|
||||
|
||||
def getTypeFromId(self, groupId):
|
||||
return self.id2type.get(groupId)
|
||||
|
||||
def d_setGroups(self, shardGroups):
|
||||
self.sendUpdateToAvatarId(self.childId, 'setGroups', [shardGroups])
|
||||
|
||||
def getGroups(self):
|
||||
return self.shardGroups
|
||||
|
||||
def d_setGroupPlayers(self, groupPlayers):
|
||||
self.sendUpdateToAvatarId(self.childId, 'setGroupPlayers', [groupPlayers])
|
||||
|
||||
def getGroupPlayers(self, groupId):
|
||||
group = self.shardGroups.get(groupId)
|
||||
if group is None:
|
||||
return []
|
||||
players = group.getGroupPlayers()
|
||||
return players
|
||||
|
||||
def createGroup(self, groupId, groupType):
|
||||
group = self.shardGroups.get(groupId)
|
||||
if group is not None:
|
||||
newGroup = DistributedGlobalGroupAI(self.air, groupType, groupId)
|
||||
self.shardGroups.update(groupId, newGroup)
|
||||
players = {groupId: self.getGroupPlayers(groupId)}
|
||||
self.groupPlayers.update(players)
|
||||
self.updateInfo()
|
||||
|
||||
def closeGroup(self, groupId):
|
||||
group = self.shardGroups.get(groupId)
|
||||
if group is not None:
|
||||
self.shardGroups.pop(groupId)
|
||||
self.groupPlayers.pop(groupId)
|
||||
self.updateInfo()
|
||||
|
||||
def addPlayerToGroup(self, groupId, avId):
|
||||
group = self.shardGroups.get(groupId)
|
||||
if group is not None:
|
||||
if not group.isInGroup(avId):
|
||||
group.addPlayerToGroup(avId)
|
||||
players = {groupId: self.getGroupPlayers(groupId)}
|
||||
self.groupPlayers.update(players)
|
||||
self.updateInfo()
|
||||
|
||||
def removePlayerFromGroup(self, groupId, avId):
|
||||
group = self.shardGroups.get(groupId)
|
||||
if group is not None:
|
||||
if group.isInGroup(avId):
|
||||
group.removePlayerFromGroup(avId)
|
||||
players = {groupId: self.getGroupPlayers(groupId)}
|
||||
self.groupPlayers.update(players)
|
||||
self.updateInfo()
|
|
@ -1,14 +0,0 @@
|
|||
from direct.distributed import DistributedObjectUD
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
|
||||
class GroupManagerUD(DistributedObjectUD.DistributedObjectUD):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('GroupManagerUD')
|
||||
|
||||
def __init__(self, air):
|
||||
DistributedObjectUD.DistributedObjectUD.__init__(self, air)
|
||||
|
||||
def announceGenerate(self):
|
||||
DistributedObjectUD.DistributedObjectUD.announceGenerate(self)
|
||||
|
||||
def delete(self):
|
||||
DistributedObjectUD.DistributedObjectUD.delete(self)
|
|
@ -82,8 +82,9 @@ class ShardPage(ShtikerPage.ShtikerPage):
|
|||
self.showPop = config.GetBool('show-population', 0)
|
||||
self.showTotalPop = config.GetBool('show-total-population', 0)
|
||||
self.noTeleport = config.GetBool('shard-page-disable', 0)
|
||||
self.shardGroups = None
|
||||
self.currentGroupJoined = None
|
||||
self.shardGroups = []
|
||||
self.shardText = []
|
||||
self.groupDialog = None
|
||||
|
||||
def load(self):
|
||||
main_text_scale = 0.06
|
||||
|
@ -117,7 +118,7 @@ class ShardPage(ShtikerPage.ShtikerPage):
|
|||
curShardTuples.sort(compareShardTuples)
|
||||
actualShardId = base.localAvatar.defaultShard
|
||||
for i in xrange(len(curShardTuples)):
|
||||
shardId, name, pop, invasionStatus = curShardTuples[i]
|
||||
shardId, name, pop, invasionStatus, groupAvCount = curShardTuples[i]
|
||||
if shardId == actualShardId:
|
||||
self.currentBTP = buttonTuple[0]
|
||||
self.currentBTL = buttonTuple[1]
|
||||
|
@ -126,7 +127,7 @@ class ShardPage(ShtikerPage.ShtikerPage):
|
|||
self.currentO = [pop, name, shardId]
|
||||
self.currentBTL['state'] = DGG.DISABLED
|
||||
self.currentBTR['state'] = DGG.DISABLED
|
||||
self.reloadRightBrain(pop, name, shardId, buttonTuple)
|
||||
self.reloadRightBrain(pop, name, groupAvCount, shardId, buttonTuple)
|
||||
|
||||
def unload(self):
|
||||
self.gui.removeNode()
|
||||
|
@ -165,7 +166,7 @@ class ShardPage(ShtikerPage.ShtikerPage):
|
|||
taskMgr.doMethodLater(self.ShardInfoUpdateInterval, self.askForShardInfoUpdate, 'ShardPageUpdateTask-doLater')
|
||||
return Task.done
|
||||
|
||||
def makeShardButton(self, shardId, shardName, shardPop):
|
||||
def makeShardButton(self, shardId, groupAvCount, shardName, shardPop):
|
||||
shardButtonParent = DirectFrame()
|
||||
shardButtonL = DirectButton(parent=shardButtonParent, relief=None, text=shardName, text_scale=0.06, text_align=TextNode.ALeft, text_fg=Vec4(0, 0, 0, 1), text3_fg=self.textDisabledColor, text1_bg=self.textDownColor, text2_bg=self.textRolloverColor, textMayChange=0, command=self.reloadRightBrain)
|
||||
popText = str(shardPop)
|
||||
|
@ -191,59 +192,62 @@ class ShardPage(ShtikerPage.ShtikerPage):
|
|||
invasionMarker.reparentTo(shardButtonParent)
|
||||
|
||||
buttonTuple = (shardButtonParent, shardButtonR, shardButtonL, invasionMarker)
|
||||
shardButtonL['extraArgs'] = extraArgs=[shardPop, shardName, shardId, buttonTuple]
|
||||
shardButtonR['extraArgs'] = extraArgs=[shardPop, shardName, shardId, buttonTuple]
|
||||
shardButtonL['extraArgs'] = extraArgs=[shardPop, shardName, groupAvCount, shardId, buttonTuple]
|
||||
shardButtonR['extraArgs'] = extraArgs=[shardPop, shardName, groupAvCount, shardId, buttonTuple]
|
||||
|
||||
return buttonTuple
|
||||
|
||||
def makeGroupButton(self, groupId, groupType):
|
||||
groupPop = len(base.cr.groupManager.getGroupPlayers(groupId))
|
||||
def makeGroupButton(self, shardId, group, population):
|
||||
groupButtonParent = DirectFrame()
|
||||
groupButtonL = DirectButton(parent=groupButtonParent, relief=None, text=groupType, text_pos=(0.0, -0.0225), text_scale=0.06, text_align=TextNode.ALeft, text_fg=Vec4(0, 0, 0, 1), text3_fg=self.textDisabledColor, text1_bg=self.textDownColor, text2_bg=self.textRolloverColor, textMayChange=0, command=self.joinGroup)
|
||||
popText = str(groupPop)
|
||||
if popText is None:
|
||||
return
|
||||
model = loader.loadModel('phase_3.5/models/gui/matching_game_gui')
|
||||
button = model.find('**/minnieCircle')
|
||||
groupButtonL = DirectButton(parent=groupButtonParent, relief=None, text=TTLocalizer.GlobalStreetNames[group][-1], text_pos=(0.0, -0.0225), text_scale=0.048, text_align=TextNode.ALeft, text_fg=Vec4(0, 0, 0, 1), text3_fg=self.textDisabledColor, text1_bg=self.textDownColor, text2_bg=self.textRolloverColor, command=self.joinGroup, extraArgs=[group, shardId])
|
||||
|
||||
groupButtonR = DirectButton(parent=groupButtonParent, relief=None,
|
||||
image=button,
|
||||
image_scale=(0.3, 1, 0.3),
|
||||
image2_scale=(0.35, 1, 0.35),
|
||||
image_color=Vec4(0, 0.8, 0, 1),
|
||||
pos=(0.58, 0, -0.0125),
|
||||
text=popText,
|
||||
text=str(population),
|
||||
text_scale=0.055,
|
||||
text_align=TextNode.ACenter,
|
||||
text_pos=(-0.00575, -0.0125), text_fg=Vec4(0, 0, 0, 1), text3_fg=Vec4(0, 0, 0, 1), text1_bg=self.textRolloverColor, text2_bg=self.textRolloverColor, textMayChange=1)
|
||||
command=self.joinGroup,
|
||||
extraArgs=[group, shardId],
|
||||
text_pos=(-0.00575, -0.0125), text_fg=Vec4(0, 0, 0, 1), text3_fg=Vec4(0, 0, 0, 1), text1_bg=self.textRolloverColor, text2_bg=self.textRolloverColor)
|
||||
|
||||
leaveButton = DirectButton(parent=groupButtonParent, relief=None,
|
||||
image=button,
|
||||
image_scale=(0.3, 1, 0.3),
|
||||
image2_scale=(0.35, 1, 0.35),
|
||||
image_color=Vec4(0, 0.8, 0, 1),
|
||||
pos=(0.50, 0, -0.0125),
|
||||
text='Leave',
|
||||
text_scale=0.055,
|
||||
text_align=TextNode.ACenter,
|
||||
text_pos=(-0.00575, -0.0125),
|
||||
text_fg=Vec4(0, 0, 0, 0),
|
||||
text2_fg=Vec4(0, 0, 0, 1),
|
||||
command=self.leaveGroup)
|
||||
return (groupButtonParent, groupButtonL, groupButtonR)
|
||||
|
||||
leaveButton.hide()
|
||||
model.removeNode()
|
||||
button.removeNode()
|
||||
def joinGroup(self, group, shardId):
|
||||
canonicalHoodId = ZoneUtil.getCanonicalHoodId(group)
|
||||
shardName = base.cr.activeDistrictMap[shardId].name
|
||||
hoodName = TTLocalizer.GlobalStreetNames[canonicalHoodId]
|
||||
teleportAccess = base.localAvatar.hasTeleportAccess(canonicalHoodId)
|
||||
|
||||
buttonTuple = (groupButtonParent, groupButtonR, groupButtonL, leaveButton)
|
||||
groupButtonL['extraArgs'] = [groupId, buttonTuple]
|
||||
leaveButton['extraArgs'] = [groupId, buttonTuple]
|
||||
return buttonTuple
|
||||
if teleportAccess:
|
||||
message = TTLocalizer.GroupAskAccess
|
||||
elif base.localAvatar.defaultShard == shardId:
|
||||
self.acceptOnce('groupDialogDone', self.cleanupGroupDialog)
|
||||
self.groupDialog = TTDialog.TTGlobalDialog(style=TTDialog.Acknowledge, text=TTLocalizer.GroupAskNoAccessSame % (hoodName[0], hoodName[-1]), doneEvent='groupDialogDone')
|
||||
self.groupDialog.show()
|
||||
return
|
||||
else:
|
||||
message = TTLocalizer.GroupAskNoAccess
|
||||
|
||||
self.acceptOnce('groupDialogDone', self.__handleGroupDialog, extraArgs=[canonicalHoodId if teleportAccess else base.localAvatar.lastHood, shardId])
|
||||
self.groupDialog = TTDialog.TTGlobalDialog(style=TTDialog.TwoChoice, text=message % (hoodName[0], hoodName[-1], shardName), doneEvent='groupDialogDone')
|
||||
self.groupDialog.show()
|
||||
|
||||
def cleanupGroupDialog(self):
|
||||
self.ignore('groupDialogDone')
|
||||
self.groupDialog.cleanup()
|
||||
del self.groupDialog
|
||||
|
||||
def __handleGroupDialog(self, canonicalHoodId, shardId):
|
||||
response = self.groupDialog.doneStatus
|
||||
self.cleanupGroupDialog()
|
||||
|
||||
if response == 'ok':
|
||||
self.requestTeleport(canonicalHoodId, shardId)
|
||||
|
||||
def removeRightBrain(self):
|
||||
self.districtInfo.find('**/*district-info').removeNode()
|
||||
|
||||
def reloadRightBrain(self, shardPop, shardName, shardId, buttonTuple):
|
||||
def reloadRightBrain(self, shardPop, shardName, groupAvCount, shardId, buttonTuple):
|
||||
self.currentRightBrain = (shardPop, shardName, shardId, buttonTuple)
|
||||
if self.districtInfo.find('**/*district-info'):
|
||||
self.removeRightBrain()
|
||||
|
@ -272,36 +276,31 @@ class ShardPage(ShtikerPage.ShtikerPage):
|
|||
if shardId == base.localAvatar.defaultShard:
|
||||
self.shardTeleportButton['state'] = DGG.DISABLED
|
||||
|
||||
if self.shardGroups is not None:
|
||||
for button in self.shardGroups:
|
||||
button.detachNode()
|
||||
for button in self.shardGroups + self.shardText:
|
||||
button.removeNode()
|
||||
|
||||
self.shardGroups = []
|
||||
self.shardText = []
|
||||
|
||||
for gid, gtype in base.cr.groupManager.id2type.items():
|
||||
btuple = self.makeGroupButton(gid, gtype)
|
||||
if base.cr.groupManager.isInGroup(base.localAvatar.doId, gid):
|
||||
for i, group in enumerate(ToontownGlobals.GROUP_ZONES):
|
||||
btuple = self.makeGroupButton(shardId, group, groupAvCount[i])
|
||||
if ZoneUtil.getCanonicalHoodId(base.localAvatar.zoneId) == ZoneUtil.getCanonicalHoodId(group):
|
||||
btuple[1]['state'] = DGG.DISABLED
|
||||
btuple[2]['state'] = DGG.DISABLED
|
||||
btuple[3].show()
|
||||
self.shardGroups.append(btuple[0])
|
||||
self.shardText.append(btuple[2])
|
||||
|
||||
buttonImage = (self.gui.find('**/FndsLst_ScrollUp'), self.gui.find('**/FndsLst_ScrollDN'), self.gui.find('**/FndsLst_ScrollUp_Rllvr'), self.gui.find('**/FndsLst_ScrollUp'))
|
||||
self.districtGroups = DirectScrolledList(parent=districtInfoNode, relief=None,
|
||||
pos=(0.38, 0, -0.34),
|
||||
incButton_image=(self.gui.find('**/FndsLst_ScrollUp'),
|
||||
self.gui.find('**/FndsLst_ScrollDN'),
|
||||
self.gui.find('**/FndsLst_ScrollUp_Rllvr'),
|
||||
self.gui.find('**/FndsLst_ScrollUp')),
|
||||
incButton_image=buttonImage,
|
||||
incButton_relief=None,
|
||||
incButton_scale=(self.arrowButtonScale,
|
||||
self.arrowButtonScale,
|
||||
-self.arrowButtonScale),
|
||||
incButton_pos=(self.buttonXstart + 0.005, 0, -0.125),
|
||||
incButton_image3_color=Vec4(1, 1, 1, 0.2),
|
||||
decButton_image=(self.gui.find('**/FndsLst_ScrollUp'),
|
||||
self.gui.find('**/FndsLst_ScrollDN'),
|
||||
self.gui.find('**/FndsLst_ScrollUp_Rllvr'),
|
||||
self.gui.find('**/FndsLst_ScrollUp')),
|
||||
decButton_image=buttonImage,
|
||||
decButton_relief=None,
|
||||
decButton_scale=(self.arrowButtonScale,
|
||||
self.arrowButtonScale,
|
||||
|
@ -317,103 +316,10 @@ class ShardPage(ShtikerPage.ShtikerPage):
|
|||
(self.listZorigin + self.listFrameSizeZ)/2.1),
|
||||
itemFrame_frameColor=(0.85, 0.95, 1, 1),
|
||||
itemFrame_borderWidth=(0.01, 0.01),
|
||||
numItemsVisible=15,
|
||||
numItemsVisible=7,
|
||||
forceHeight=0.065,
|
||||
items=self.shardGroups)
|
||||
|
||||
def joinGroup(self, groupId, buttonTuple):
|
||||
self.acceptOnce('confJoin', self.confirmJoinGroup, extraArgs=[groupId, buttonTuple])
|
||||
self.joinDialog = TTDialog.TTGlobalDialog(message='Would you like to join this group?', doneEvent='confJoin', style=4)
|
||||
|
||||
def rejectGroup(self, reason, suitType=0):
|
||||
self.acceptOnce('remRjD', self.doneReject)
|
||||
if reason == 1:
|
||||
self.rejectDialog = TTDialog.TTGlobalDialog(message='You need more suit parts!', doneEvent='remRjD', style=1)
|
||||
elif reason == 2:
|
||||
if suitType == 0:
|
||||
meritType = 'Stock Options'
|
||||
elif suitType == 1:
|
||||
meritType = 'Merits'
|
||||
elif suitType == 2:
|
||||
meritType = 'Cogbucks'
|
||||
elif suitType == 3:
|
||||
meritType = 'Notices'
|
||||
self.rejectDialog = TTDialog.TTGlobalDialog(message='You need more %s!'%meritType, doneEvent='remRjD', style=1)
|
||||
elif reason == 3:
|
||||
self.rejectDialog = TTDialog.TTGlobalDialog(message='That group is full!', doneEvent='remRjD', style=1)
|
||||
elif reason == 4:
|
||||
self.rejectDialog = TTDialog.TTGlobalDialog(message='You\'re already in a group!', doneEvent='remRjD', style=1)
|
||||
elif reason == 5:
|
||||
self.rejectDialog = TTDialog.TTGlobalDialog(message='You can\'t leave the district while you\'re in a group!', doneEvent='remRjD', style=1)
|
||||
|
||||
def doneReject(self):
|
||||
self.rejectDialog.cleanup()
|
||||
del self.rejectDialog
|
||||
|
||||
def confirmJoinGroup(self, groupId, buttonTuple):
|
||||
doneStatus = self.joinDialog.doneStatus
|
||||
self.joinDialog.cleanup()
|
||||
del self.joinDialog
|
||||
if doneStatus is not 'ok':
|
||||
return
|
||||
for gid in base.cr.groupManager.id2type.keys():
|
||||
if base.cr.groupManager.isInGroup(base.localAvatar.doId, gid):
|
||||
self.rejectGroup(4)
|
||||
return
|
||||
#if len(base.cr.groupManager.getGroupPlayers(groupId)) >= 8:
|
||||
# self.rejectGroup(3)
|
||||
# return
|
||||
suitIdx = -1
|
||||
gids = {10000:0, 11000:1, 12000:2, 13000:3}
|
||||
suitIdx = gids.get(groupId)
|
||||
if suitIdx is not None:
|
||||
merits = base.localAvatar.cogMerits[suitIdx]
|
||||
if CogDisguiseGlobals.getTotalMerits(base.localAvatar, suitIdx) > merits:
|
||||
self.rejectGroup(2, suitIdx)
|
||||
return
|
||||
parts = base.localAvatar.getCogParts()
|
||||
if not CogDisguiseGlobals.isSuitComplete(parts, suitIdx):
|
||||
self.rejectGroup(1)
|
||||
return
|
||||
base.cr.groupManager.d_addPlayerToGroup(groupId, base.localAvatar.doId)
|
||||
self.currentGroupJoined = groupId
|
||||
try:
|
||||
place = base.cr.playGame.getPlace()
|
||||
except:
|
||||
try:
|
||||
place = base.cr.playGame.hood.loader.place
|
||||
except:
|
||||
place = base.cr.playGame.hood.place
|
||||
place.requestTeleport(groupId, groupId, base.localAvatar.defaultShard, -1)
|
||||
|
||||
def leaveGroup(self, groupId, buttonTuple):
|
||||
self.acceptOnce('confLeave', self.confirmLeaveGroup, extraArgs=[groupId, buttonTuple])
|
||||
self.joinDialog = TTDialog.TTGlobalDialog(message='Are you sure you want to leave this group?', doneEvent='confLeave', style=4)
|
||||
|
||||
def confirmLeaveGroup(self, groupId, buttonTuple):
|
||||
doneStatus = self.joinDialog.doneStatus
|
||||
self.joinDialog.cleanup()
|
||||
del self.joinDialog
|
||||
if doneStatus is not 'ok':
|
||||
return
|
||||
if not base.cr.groupManager.isInGroup(base.localAvatar.doId, groupId):
|
||||
return
|
||||
base.cr.groupManager.d_removePlayerFromGroup(groupId, base.localAvatar.doId)
|
||||
self.currentGroupJoined = None
|
||||
try:
|
||||
place = base.cr.playGame.getPlace()
|
||||
except:
|
||||
try:
|
||||
place = base.cr.playGame.hood.loader.place
|
||||
except:
|
||||
place = base.cr.playGame.hood.place
|
||||
hoodId = -1
|
||||
gids = {10000:1000, 11000:5000, 12000:9000, 13000:3000}
|
||||
hoodId = gids.get(groupId)
|
||||
if hoodId is None:
|
||||
return
|
||||
place.requestTeleport(hoodId, hoodId, base.localAvatar.defaultShard, -1)
|
||||
|
||||
def getPopColor(self, pop):
|
||||
if pop <= self.lowPop:
|
||||
newColor = POP_COLORS[0]
|
||||
|
@ -483,7 +389,7 @@ class ShardPage(ShtikerPage.ShtikerPage):
|
|||
|
||||
for i in xrange(len(curShardTuples)):
|
||||
|
||||
shardId, name, pop, invasionStatus = curShardTuples[i]
|
||||
shardId, name, pop, invasionStatus, groupAvCount = curShardTuples[i]
|
||||
|
||||
if shardId == actualShardId:
|
||||
actualShardName = name
|
||||
|
@ -493,16 +399,19 @@ class ShardPage(ShtikerPage.ShtikerPage):
|
|||
buttonTuple = self.shardButtonMap.get(shardId)
|
||||
|
||||
if buttonTuple == None:
|
||||
buttonTuple = self.makeShardButton(shardId, name, pop)
|
||||
buttonTuple = self.makeShardButton(shardId, groupAvCount, name, pop)
|
||||
self.shardButtonMap[shardId] = buttonTuple
|
||||
anyChanges = 1
|
||||
else:
|
||||
buttonTuple[1]['image_color'] = self.getPopColor(pop)
|
||||
buttonTuple[1]['text'] = str(pop)
|
||||
buttonTuple[1]['command'] = self.reloadRightBrain
|
||||
buttonTuple[1]['extraArgs'] = [pop, name, shardId, buttonTuple]
|
||||
buttonTuple[1]['extraArgs'] = [pop, name, groupAvCount, shardId, buttonTuple]
|
||||
buttonTuple[2]['command'] = self.reloadRightBrain
|
||||
buttonTuple[2]['extraArgs'] = [pop, name, shardId, buttonTuple]
|
||||
buttonTuple[2]['extraArgs'] = [pop, name, groupAvCount, shardId, buttonTuple]
|
||||
|
||||
for i, button in enumerate(self.shardText):
|
||||
button['text'] = str(groupAvCount[i])
|
||||
|
||||
self.shardButtons.append(buttonTuple[0])
|
||||
|
||||
|
@ -563,21 +472,18 @@ class ShardPage(ShtikerPage.ShtikerPage):
|
|||
del self.confirm
|
||||
|
||||
def choseShard(self, shardId):
|
||||
zoneId = self.getCurrentZoneId()
|
||||
canonicalHoodId = ZoneUtil.getCanonicalHoodId(base.localAvatar.lastHood)
|
||||
currentShardId = base.localAvatar.defaultShard
|
||||
if not base.localAvatar.defaultShard == shardId:
|
||||
self.requestTeleport(base.localAvatar.lastHood, shardId)
|
||||
|
||||
if self.currentGroupJoined:
|
||||
self.rejectGroup(5)
|
||||
return
|
||||
if shardId == currentShardId:
|
||||
return
|
||||
else:
|
||||
def requestTeleport(self, hood, shardId):
|
||||
canonicalHoodId = ZoneUtil.getCanonicalHoodId(hood)
|
||||
|
||||
try:
|
||||
place = base.cr.playGame.getPlace()
|
||||
except:
|
||||
try:
|
||||
place = base.cr.playGame.getPlace()
|
||||
place = base.cr.playGame.hood.loader.place
|
||||
except:
|
||||
try:
|
||||
place = base.cr.playGame.hood.loader.place
|
||||
except:
|
||||
place = base.cr.playGame.hood.place
|
||||
place.requestTeleport(canonicalHoodId, canonicalHoodId, shardId, -1)
|
||||
place = base.cr.playGame.hood.place
|
||||
|
||||
place.requestTeleport(canonicalHoodId, canonicalHoodId, shardId, -1)
|
|
@ -95,23 +95,23 @@ GlobalStreetNames = {20000: ('to', 'on', 'Tutorial Terrace'),
|
|||
9100: ('to', 'on', 'Lullaby Lane'),
|
||||
9200: ('to', 'on', 'Pajama Place'),
|
||||
9300: ('to', 'on', 'Bedtime Boulevard'),
|
||||
10000: ('to', 'in', 'Bossbot HQ Country Club'),
|
||||
10000: ('to the', 'in the', 'Bossbot HQ Country Club'),
|
||||
10100: ('to the', 'in the', 'Bossbot HQ Lobby'),
|
||||
10200: ('to the', 'in the', 'The Clubhouse'),
|
||||
10500: ('to the', 'in the', 'The Front Three'),
|
||||
10600: ('to the', 'in the', 'The Middle Six'),
|
||||
10700: ('to the', 'in the', 'The Back Nine'),
|
||||
10200: ('to', 'in', 'The Clubhouse'),
|
||||
10500: ('to', 'in', 'The Front Three'),
|
||||
10600: ('to', 'in', 'The Middle Six'),
|
||||
10700: ('to', 'in', 'The Back Nine'),
|
||||
11000: ('to the', 'in the', 'Sellbot HQ Courtyard'),
|
||||
11100: ('to the', 'in the', 'Sellbot HQ Lobby'),
|
||||
11200: ('to the', 'in the', 'Sellbot Factory'),
|
||||
11500: ('to the', 'in the', 'Sellbot Factory'),
|
||||
11600: ('to the', 'in the', 'Sellbot Megacorp'),
|
||||
12000: ('to', 'in', 'Cashbot Train Yard'),
|
||||
12000: ('to the', 'in the', 'Cashbot Train Yard'),
|
||||
12100: ('to the', 'in the', 'Cashbot HQ Lobby'),
|
||||
12500: ('to the', 'in the', 'Cashbot Coin Mint'),
|
||||
12600: ('to the', 'in the', 'Cashbot Dollar Mint'),
|
||||
12700: ('to the', 'in the', 'Cashbot Bullion Mint'),
|
||||
13000: ('to', 'in', 'Lawbot HQ Courtyard'),
|
||||
13000: ('to the', 'in the', 'Lawbot HQ Courtyard'),
|
||||
13100: ('to the', 'in the', 'Courthouse Lobby'),
|
||||
13200: ('to the', 'in the', "DA's Office Lobby"),
|
||||
13300: ('to the', 'in the', 'Lawbot A Office'),
|
||||
|
@ -8671,6 +8671,10 @@ FriendSecretEnteredSecretSelf = 'You just typed in your own True Friend Code!'
|
|||
FriendSecretTooFast = 'You are redeeming codes too fast! Please wait a few seconds.'
|
||||
FriendSecretNowFriends = 'You are now True Friends with %s!'
|
||||
|
||||
GroupAskNoAccess = 'Sorry, but you have no teleport access %s %s.\n\nWould you still like to teleport to %s?'
|
||||
GroupAskNoAccessSame = 'Sorry, but you have no teleport access %s %s.'
|
||||
GroupAskAccess = 'Would you like to teleport %s %s in %s?'
|
||||
|
||||
Blacklist = [
|
||||
"$1ut",
|
||||
"$h1t",
|
||||
|
|
|
@ -1685,3 +1685,5 @@ TF_FRIENDS_LIST_FULL_HIM = 5
|
|||
TF_ALREADY_FRIENDS = 6
|
||||
TF_ALREADY_FRIENDS_NAME = 7
|
||||
TF_SUCCESS = 8
|
||||
|
||||
GROUP_ZONES = [11000, 11100, 11200, 12000, 12100, 13000, 13100, 13200, 10000, 10100]
|
|
@ -39,7 +39,6 @@ class ToontownUberRepository(ToontownInternalRepository):
|
|||
self.chatAgent = simbase.air.generateGlobalObject(OTP_DO_ID_CHAT_MANAGER, 'ChatAgent')
|
||||
self.friendsManager = simbase.air.generateGlobalObject(OTP_DO_ID_TTS_FRIENDS_MANAGER, 'TTSFriendsManager')
|
||||
self.globalPartyMgr = simbase.air.generateGlobalObject(OTP_DO_ID_GLOBAL_PARTY_MANAGER, 'GlobalPartyManager')
|
||||
self.groupManager = simbase.air.generateGlobalObject(OPT_DO_ID_GROUP_MANAGER, 'GroupManager')
|
||||
if self.wantTopToons:
|
||||
self.topToonsMgr = TopToonsManagerUD(self)
|
||||
|
||||
|
|
Loading…
Reference in a new issue