Clickable browser whispers + cleanup

This commit is contained in:
John 2015-08-14 19:30:11 +03:00
parent 09c412ea74
commit 2689789ab1
10 changed files with 31 additions and 189 deletions

View file

@ -14,12 +14,14 @@ from direct.task import Task
import math
from panda3d.core import *
import random
import webbrowser
import numbers
import DistributedAvatar
from otp.ai.MagicWordGlobal import *
from otp.otpbase import OTPGlobals
from otp.otpbase import OTPLocalizer
from otp.nametag.NametagConstants import *
from otp.margins.WhisperPopup import *
from toontown.toonbase import ToontownGlobals
@ -893,16 +895,20 @@ class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.Dis
def displayWhisper(self, fromId, chatString, whisperType):
sender = None
sfx = self.soundWhisper
if isinstance(fromId, numbers.Number):
sender = base.cr.identifyAvatar(fromId)
if whisperType == WTNormal:
if sender == None:
return
chatString = sender.getName() + ': ' + chatString
chatString = '%s: %s' % (sender.getName(), chatString)
whisper = WhisperPopup(chatString, OTPGlobals.getInterfaceFont(), whisperType)
if sender != None:
whisper.setClickable(sender.getName(), fromId)
if sender or isinstance(fromId, basestring):
whisper.setClickable(fromId)
whisper.manage(base.marginManager)
base.playSfx(sfx)
base.playSfx(self.soundSystemMessage if whisperType == WTSystem else self.soundWhisper)
def setAnimMultiplier(self, value):
self.animMultiplier = value
@ -1069,7 +1075,6 @@ class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.Dis
def stopChat(self):
self.chatMgr.stop()
self.ignore(OTPGlobals.WhisperIncomingEvent)
self.ignore(OTPGlobals.ThinkPosHotkey)
if self.__enableMarkerPlacement:
self.ignore(OTPGlobals.PlaceMarkerHotkey)
@ -1107,6 +1112,10 @@ class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.Dis
self.setSystemMessage(0, OTPLocalizer.WhisperFriendLoggedOut % friend.getName())
def clickedWhisper(self, doId):
if isinstance(doId, basestring):
webbrowser.open(doId, new=2, autoraise=True)
return
friend = base.cr.identifyFriend(doId)
if friend != None:

View file

@ -65,7 +65,7 @@ class WhisperPopup(MarginPopup, ClickablePopup):
if self.active and self.fromId:
self.setClickRegionEvent('clickedWhisper', clickArgs=[self.fromId])
def setClickable(self, senderName, fromId, todo=0):
def setClickable(self, fromId):
self.active = True
self.fromId = fromId

View file

@ -288,13 +288,3 @@ PeriodOnlyAfterLetter = 'You can use a period in your name, but only after a let
ApostropheOnlyAfterLetter = 'You can use an apostrophe in your name, but only after a letter.'
NoNumbersInTheMiddle = 'Numeric digits may not appear in the middle of a word.'
ThreeWordsOrLess = 'Your name must be three words or fewer.'
AvatarFriendAddEvent = 'avatarFriendAddEvent'
AvatarNewFriendAddEvent = 'avatarNewFriendAddEvent'
AvatarFriendUpdateEvent = 'avatarFriendUpdateEvent'
AvatarFriendRemoveEvent = 'avatarFriendRemoveEvent'
AvatarFriendConsideringEvent = 'avatarFriendConsideringEvent'
AvatarFriendInvitationEvent = 'avatarFriendInvitationEvent'
AvatarFriendRejectInviteEvent = 'avatarFriendRejectInviteEvent'
AvatarFriendRetractInviteEvent = 'avatarFriendRetractInviteEvent'
AvatarFriendRejectRemoveEvent = 'avatarFriendRejectRemoveEvent'
WhisperIncomingEvent = 'whisperIncomingEvent'

View file

@ -222,7 +222,6 @@ SCMenuIdesOfMarch = 'GREEN'
ScMenuBugs = 'Bugs'
FriendInviteeTooManyFriends = '%s would like to be your friend, but you already have too many friends on your list!'
FriendInviteeInvitation = '%s would like to be your friend.'
FriendNotifictation = '%s is now your friend.'
FriendInviteeOK = lOK
FriendInviteeNo = lNo
FriendOnline = 'has come online.'

View file

@ -1,59 +0,0 @@
from panda3d.core import *
from toontown.toonbase.ToontownGlobals import *
from direct.showbase import DirectObject
from direct.directnotify import DirectNotifyGlobal
from toontown.toontowngui import TTDialog
from otp.otpbase import OTPLocalizer
from toontown.toontowngui import ToonHeadDialog
from direct.gui.DirectGui import DGG
from otp.otpbase import OTPGlobals
class FriendNotifier(ToonHeadDialog.ToonHeadDialog):
notify = DirectNotifyGlobal.directNotify.newCategory('FriendNotifier')
def __init__(self, avId, avName, avDNA, context, **kw):
self.avId = avId
self.avName = avName
self.avDNA = avDNA
self.context = context
text = OTPLocalizer.FriendNotifictation % self.avName
style = TTDialog.Acknowledge
buttonText = [OTPLocalizer.FriendInviteeOK, OTPLocalizer.FriendInviteeOK]
command = self.__handleButton
optiondefs = (('dialogName', 'FriendInvitee', None),
('text', text, None),
('style', style, None),
('buttonText', buttonText, None),
('command', command, None),
('image_color', (1.0, 0.89, 0.77, 1.0), None),
('geom_scale', 0.2, None),
('geom_pos', (-0.1, 0, -0.025), None),
('pad', (0.075, 0.075), None),
('topPad', 0, None),
('midPad', 0, None),
('pos', (0.45, 0, 0.75), None),
('scale', 0.75, None))
self.defineoptions(kw, optiondefs)
ToonHeadDialog.ToonHeadDialog.__init__(self, self.avDNA)
self.initialiseoptions(FriendNotifier)
self.show()
return
def cleanup(self):
ToonHeadDialog.ToonHeadDialog.cleanup(self)
def __handleButton(self, value):
if value == DGG.DIALOG_OK:
pass
self.context = None
self.cleanup()
return
def __handleOhWell(self, value):
self.cleanup()
def __handleCancelFromAbove(self, context = None):
if context == None or context == self.context:
self.context = None
self.cleanup()
return

View file

@ -2,7 +2,6 @@ from panda3d.core import *
import FriendsListPanel
import FriendInviter
import FriendInvitee
import FriendNotifier
from direct.directnotify import DirectNotifyGlobal
from toontown.toon import ToonTeleportPanel
from toontown.friends import ToontownFriendSecret
@ -25,10 +24,9 @@ class FriendsListManager:
self._preserveFriendsList = False
self._entered = False
self.friendsRequestQueue = []
return
def load(self):
self.accept(OTPGlobals.AvatarNewFriendAddEvent, self.__friendAdded)
pass
def unload(self):
self.exitFLM()
@ -135,13 +133,3 @@ class FriendsListManager:
def preserveFriendsList(self):
self.notify.debug('Preserving Friends List')
self._preserveFriendsList = True
def __friendAdded(self, avId):
if FriendInviter.globalFriendInviter != None:
messenger.send('FriendsListManagerAddEvent', [avId])
else:
friendToon = base.cr.doId2do.get(avId)
if friendToon:
dna = friendToon.getStyle()
FriendNotifier.FriendNotifier(avId, friendToon.getName(), dna, None)
return

View file

@ -827,7 +827,6 @@ class ExtraOptionsTabPage(DirectFrame):
chooser = self.optionChoosers['pole']
if resetIndex:
print 'resetting index'
chooser.setIndex(base.localAvatar.getFishingRod())
chooser.setDisplayText(TTLocalizer.FishingRodNameDict[chooser.index])

View file

@ -2211,10 +2211,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
from toontown.shtiker import EventsPage
if hasattr(self, 'eventsPage') and base.localAvatar.book.entered and base.localAvatar.book.isOnPage(self.eventsPage) and self.eventsPage.getMode() == EventsPage.EventsPage_Host:
base.localAvatar.eventsPage.loadHostedPartyInfo()
if hasattr(self, 'displaySystemClickableWhisper'):
self.displaySystemClickableWhisper(0, TTLocalizer.PartyCanStart, whisperType=WTSystem)
else:
self.setSystemMessage(0, TTLocalizer.PartyCanStart)
self.setSystemMessage(0, TTLocalizer.PartyCanStart, WTSystem)
def setPartyStatus(self, partyId, newStatus):
DistributedToon.partyNotify.debug('setPartyCanStatus called passing in partyId=%s status=%s' % (partyId, newStatus))
@ -2232,7 +2229,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
from toontown.shtiker import EventsPage
if hasattr(self, 'eventsPage') and base.localAvatar.book.entered and base.localAvatar.book.isOnPage(self.eventsPage) and self.eventsPage.getMode() == EventsPage.EventsPage_Invited:
base.localAvatar.eventsPage.loadInvitations()
if newStatus == PartyStatus.Started and hasattr(self, 'displaySystemClickableWhisper'):
if newStatus == PartyStatus.Started and hasattr(self, 'setSystemMessage'):
invite = self.getInviteForPartyId(partyId)
if invite:
name = ' '
@ -2241,10 +2238,9 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
name = host.getName()
if invite.status == InviteStatus.Accepted:
displayStr = TTLocalizer.PartyHasStartedAcceptedInvite % TTLocalizer.GetPossesive(name)
self.displaySystemClickableWhisper(-1, displayStr, whisperType=WTSystem)
else:
displayStr = TTLocalizer.PartyHasStartedNotAcceptedInvite % TTLocalizer.GetPossesive(name)
self.setSystemMessage(partyInfo.hostId, displayStr, whisperType=WTSystem)
self.setSystemMessage(partyInfo.hostId, displayStr, WTSystem)
break
if not found:

View file

@ -11,8 +11,6 @@ from panda3d.core import *
import random
import re
import time
import zlib
import DistributedToon
import LaffMeter
import Toon
@ -144,9 +142,6 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
self.guiConflict = 0
self.lastElevatorLeft = 0
self.elevatorNotifier = ElevatorNotifier.ElevatorNotifier()
self.accept(OTPGlobals.AvatarFriendAddEvent, self.sbFriendAdd)
self.accept(OTPGlobals.AvatarFriendUpdateEvent, self.sbFriendUpdate)
self.accept(OTPGlobals.AvatarFriendRemoveEvent, self.sbFriendRemove)
self._zoneId = None
self.accept('system message aknowledge', self.systemWarning)
self.systemMsgAckGuiDoneEvent = 'systemMsgAckGuiDoneEvent'
@ -416,12 +411,11 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
return
if base.whiteList:
chat = base.whiteList.processThroughAll(chat, sender, self.chatGarbler)
chat = base.whiteList.processThroughAll(chat, sender, sender.chatGarbler)
name = sender.getName()
chatString = '%s: %s' % (name, chat)
chatString = '%s: %s' % (sender.getName(), chat)
whisper = WhisperPopup(chatString, OTPGlobals.getInterfaceFont(), WTNormal)
whisper.setClickable(name, avId)
whisper.setClickable(avId)
whisper.manage(base.marginManager)
base.playSfx(self.soundWhisper)
@ -778,73 +772,9 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
else:
self.__pieButton['text'] = str(self.numPies)
self.__pieButtonCount = self.numPies
return
def displayWhisper(self, fromId, chatString, whisperType):
sender = None
sfx = self.soundWhisper
if fromId == TTLocalizer.Clarabelle:
chatString = TTLocalizer.Clarabelle + ': ' + chatString
sfx = self.soundPhoneRing
elif fromId != 0:
sender = base.cr.identifyAvatar(fromId)
if whisperType == WTNormal:
if sender == None:
return
chatString = sender.getName() + ': ' + chatString
elif whisperType == WTSystem:
sfx = self.soundSystemMessage
whisper = WhisperPopup(chatString, OTPGlobals.getInterfaceFont(), whisperType)
if sender != None:
whisper.setClickable(sender.getName(), fromId)
whisper.manage(base.marginManager)
base.playSfx(sfx)
return
def displaySystemClickableWhisper(self, fromId, chatString, whisperType):
sender = None
sfx = self.soundWhisper
if fromId == TTLocalizer.Clarabelle:
chatString = TTLocalizer.Clarabelle + ': ' + chatString
sfx = self.soundPhoneRing
elif fromId != 0:
sender = base.cr.identifyAvatar(fromId)
if whisperType == WTNormal:
if sender == None:
return
chatString = sender.getName() + ': ' + chatString
elif whisperType == WTSystem:
sfx = self.soundSystemMessage
whisper = WhisperPopup(chatString, OTPGlobals.getInterfaceFont(), whisperType)
whisper.setClickable('', fromId)
whisper.manage(base.marginManager)
base.playSfx(sfx)
return
def clickedWhisper(self, doId):
if doId > 0:
LocalAvatar.LocalAvatar.clickedWhisper(self, doId)
else:
foundCanStart = False
for partyInfo in self.hostedParties:
if partyInfo.status == PartyGlobals.PartyStatus.CanStart:
foundCanStart = True
break
if base.cr and base.cr.playGame and base.cr.playGame.getPlace() and base.cr.playGame.getPlace().fsm:
fsm = base.cr.playGame.getPlace().fsm
curState = fsm.getCurrentState().getName()
if curState == 'walk':
if hasattr(self, 'eventsPage'):
desiredMode = -1
if doId == -1:
desiredMode = EventsPage.EventsPage_Invited
elif foundCanStart:
desiredMode = EventsPage.EventsPage_Host
if desiredMode >= 0:
self.book.setPage(self.eventsPage)
self.eventsPage.setMode(desiredMode)
fsm.request('stickerBook')
LocalAvatar.LocalAvatar.displayWhisper(self, fromId, chatString, whisperType)
def loadFurnitureGui(self):
if self.__furnitureGui:
@ -861,7 +791,6 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
bMoveStartUp], text=['', TTLocalizer.HDMoveFurnitureButton, TTLocalizer.HDMoveFurnitureButton], text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_font=ToontownGlobals.getInterfaceFont(), pos=(-0.3, 0, 9.4), command=self.__startMoveFurniture)
self.__furnitureGui.hide()
guiModels.removeNode()
return
def showFurnitureGui(self):
self.loadFurnitureGui()
@ -1630,15 +1559,6 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
self.notify.info('closing shard...')
base.cr.gameFSM.request('closeShard', ['afkTimeout'])
def sbFriendAdd(self, id, info):
print 'sbFriendAdd'
def sbFriendUpdate(self, id, info):
print 'sbFriendUpdate'
def sbFriendRemove(self, id):
print 'sbFriendRemove'
def addGolfPage(self):
if self.hasPlayedGolf():
if hasattr(self, 'golfPage') and self.golfPage != None:

View file

@ -3303,7 +3303,7 @@ PartyTimeFormat = '%d:%.2d %s'
PartyTimeFormatMeridiemAM = 'am'
PartyTimeFormatMeridiemPM = 'pm'
PartyCanStart = "It's Party Time, click Start Party in your Shticker Book Hosting page!"
PartyHasStartedAcceptedInvite = '%s party has started! Click the host then "Go To Party" in the Shticker Book Invites page.'
PartyHasStartedAcceptedInvite = '%s party has started! Teleport to the host!'
PartyHasStartedNotAcceptedInvite = '%s party has started! You can still go to it by teleporting to the host.'
EventsPageName = 'Events'
EventsPageCalendarTabName = 'Calendar'