2015-06-22 02:23:46 -05:00
|
|
|
from direct.distributed.DistributedObject import DistributedObject
|
2015-04-09 06:05:29 -05:00
|
|
|
from toontown.estate import Estate
|
2015-06-22 02:23:46 -05:00
|
|
|
from toontown.toonbase import ToontownGlobals
|
|
|
|
import HolidayGlobals
|
2015-03-03 16:10:12 -06:00
|
|
|
|
2015-06-22 02:23:46 -05:00
|
|
|
class NewsManager(DistributedObject):
|
2015-03-03 16:10:12 -06:00
|
|
|
neverDisable = 1
|
|
|
|
|
|
|
|
def __init__(self, cr):
|
2015-06-22 02:23:46 -05:00
|
|
|
DistributedObject.__init__(self, cr)
|
2015-06-24 08:49:20 -05:00
|
|
|
print 'NewsMgr - GEN!'
|
2015-06-22 02:23:46 -05:00
|
|
|
self.invading = False
|
|
|
|
self.activeHolidays = []
|
2015-03-03 16:10:12 -06:00
|
|
|
base.localAvatar.inventory.setInvasionCreditMultiplier(1)
|
2015-06-22 02:23:46 -05:00
|
|
|
base.cr.newsManager = self
|
2015-03-03 16:10:12 -06:00
|
|
|
|
|
|
|
def delete(self):
|
|
|
|
self.cr.newsManager = None
|
2015-06-22 02:23:46 -05:00
|
|
|
DistributedObject.delete(self)
|
2015-03-03 16:10:12 -06:00
|
|
|
|
2015-06-22 02:23:46 -05:00
|
|
|
def isHolidayRunning(self, id):
|
|
|
|
return id in self.activeHolidays
|
2015-06-16 12:26:44 -05:00
|
|
|
|
2015-06-24 08:49:20 -05:00
|
|
|
def setActiveHolidays(self, ids):
|
|
|
|
print 'set active holidays %s' % ids
|
2015-06-22 02:23:46 -05:00
|
|
|
for id in ids:
|
|
|
|
self.startHoliday(id, True)
|
2015-04-04 03:20:42 -05:00
|
|
|
|
2015-06-22 02:23:46 -05:00
|
|
|
def broadcastHoliday(self, holiday, type):
|
|
|
|
if type in holiday:
|
|
|
|
base.localAvatar.setSystemMessage(0, holiday[type])
|
2015-06-16 12:26:44 -05:00
|
|
|
|
2015-06-22 02:23:46 -05:00
|
|
|
def startHoliday(self, id, ongoing=False):
|
|
|
|
if id in self.activeHolidays or id not in HolidayGlobals.Holidays:
|
|
|
|
return
|
2015-04-28 23:01:52 -05:00
|
|
|
|
2015-06-22 02:23:46 -05:00
|
|
|
holiday = HolidayGlobals.getHoliday(id)
|
|
|
|
|
|
|
|
self.activeHolidays.append(id)
|
|
|
|
self.broadcastHoliday(holiday, 'ongoingMessage' if ongoing else 'startMessage')
|
|
|
|
self.startSpecialHoliday(id)
|
2015-04-28 23:01:52 -05:00
|
|
|
|
2015-06-22 02:23:46 -05:00
|
|
|
def endHoliday(self, id):
|
|
|
|
if id not in self.activeHolidays or id not in HolidayGlobals.Holidays:
|
|
|
|
return
|
2015-04-28 23:01:52 -05:00
|
|
|
|
2015-06-22 02:23:46 -05:00
|
|
|
holiday = HolidayGlobals.getHoliday(id)
|
2015-04-04 03:20:42 -05:00
|
|
|
|
2015-06-22 02:23:46 -05:00
|
|
|
self.activeHolidays.remove(id)
|
|
|
|
self.broadcastHoliday(holiday, 'endMessage')
|
|
|
|
self.endSpecialHoliday(id)
|
2015-04-28 23:01:52 -05:00
|
|
|
|
2015-06-22 02:23:46 -05:00
|
|
|
def startSpecialHoliday(self, id):
|
|
|
|
if id == ToontownGlobals.LAUGHING_MAN:
|
|
|
|
for toon in base.cr.toons.values():
|
|
|
|
toon.generateLaughingMan()
|
2015-04-09 06:05:29 -05:00
|
|
|
elif id == ToontownGlobals.APRIL_TOONS_WEEK:
|
|
|
|
if isinstance(base.cr.playGame.getPlace(), Estate.Estate):
|
|
|
|
base.localAvatar.startAprilToonsControls()
|
|
|
|
|
|
|
|
base.localAvatar.chatMgr.chatInputSpeedChat.addAprilToonsMenu()
|
2015-06-23 07:27:14 -05:00
|
|
|
elif id == ToontownGlobals.IDES_OF_MARCH:
|
|
|
|
base.localAvatar.chatMgr.chatInputSpeedChat.addIdesOfMarchMenu()
|
2015-06-24 08:49:20 -05:00
|
|
|
elif id == ToontownGlobals.HALLOWEEN:
|
2015-06-23 15:20:41 -05:00
|
|
|
base.localAvatar.chatMgr.chatInputSpeedChat.addHalloweenMenu()
|
2015-06-24 08:49:20 -05:00
|
|
|
elif id == ToontownGlobals.CHRISTMAS:
|
2015-06-23 15:20:41 -05:00
|
|
|
base.localAvatar.chatMgr.chatInputSpeedChat.addWinterMenu()
|
2015-04-28 23:01:52 -05:00
|
|
|
|
2015-06-22 02:23:46 -05:00
|
|
|
def endSpecialHoliday(self, id):
|
|
|
|
if id == ToontownGlobals.LAUGHING_MAN:
|
|
|
|
for toon in base.cr.toons.values():
|
2015-04-09 06:05:29 -05:00
|
|
|
toon.swapToonHead(laughingMan=toon.getWantLaughingMan())
|
|
|
|
elif id == ToontownGlobals.APRIL_TOONS_WEEK:
|
|
|
|
if isinstance(base.cr.playGame.getPlace(), Estate.Estate):
|
|
|
|
base.localAvatar.stopAprilToonsControls()
|
|
|
|
|
2015-06-23 07:27:14 -05:00
|
|
|
base.localAvatar.chatMgr.chatInputSpeedChat.removeAprilToonsMenu()
|
|
|
|
elif id == ToontownGlobals.IDES_OF_MARCH:
|
2015-06-23 15:20:41 -05:00
|
|
|
base.localAvatar.chatMgr.chatInputSpeedChat.removeIdesOfMarchMenu()
|
2015-06-24 08:49:20 -05:00
|
|
|
elif id == ToontownGlobals.HALLOWEEN:
|
2015-06-23 15:20:41 -05:00
|
|
|
base.localAvatar.chatMgr.chatInputSpeedChat.removeHalloweenMenu()
|
2015-06-24 08:49:20 -05:00
|
|
|
elif id == ToontownGlobals.CHRISTMAS:
|
2015-06-23 15:20:41 -05:00
|
|
|
base.localAvatar.chatMgr.chatInputSpeedChat.removeWinterMenu()
|