mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-23 11:42:39 -06:00
Add language selector in choose-a-toon
This commit is contained in:
parent
528817b1d3
commit
603fa38aec
6 changed files with 91 additions and 12 deletions
|
@ -12,7 +12,7 @@ from otp.otpbase.OTPLocalizerEnglish import *
|
||||||
if language != 'English':
|
if language != 'English':
|
||||||
l = {}
|
l = {}
|
||||||
g = {}
|
g = {}
|
||||||
module = 'otp.optbase.OTPLocalizer' + language
|
module = 'otp.otpbase.OTPLocalizer' + language
|
||||||
englishModule = __import__('otp.otpbase.OTPLocalizerEnglish', g, l)
|
englishModule = __import__('otp.otpbase.OTPLocalizerEnglish', g, l)
|
||||||
foreignModule = __import__(module, g, l)
|
foreignModule = __import__(module, g, l)
|
||||||
for key, val in englishModule.__dict__.items():
|
for key, val in englishModule.__dict__.items():
|
||||||
|
|
72
toontown/language/LanguageSelector.py
Normal file
72
toontown/language/LanguageSelector.py
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
from direct.gui.DirectGui import OnscreenImage, DirectLabel, DirectButton
|
||||||
|
from toontown.toonbase import ToontownGlobals, TTLocalizer
|
||||||
|
from toontown.toontowngui import TTDialog
|
||||||
|
import os
|
||||||
|
|
||||||
|
class LanguageSelector:
|
||||||
|
|
||||||
|
def __init__(self, leaveFunction):
|
||||||
|
self.title = None
|
||||||
|
self.current = None
|
||||||
|
self.available = None
|
||||||
|
self.english = None
|
||||||
|
self.french = None
|
||||||
|
self.backButton = None
|
||||||
|
self.confirmDialog = None
|
||||||
|
self.leaveFunction = leaveFunction
|
||||||
|
|
||||||
|
def create(self):
|
||||||
|
self.background = OnscreenImage(parent=render2d, image="phase_3.5/maps/blackboardEmpty.jpg")
|
||||||
|
self.gui = loader.loadModel('phase_3/models/gui/tt_m_gui_mat_mainGui')
|
||||||
|
self.shuffleUp = self.gui.find('**/tt_t_gui_mat_shuffleUp')
|
||||||
|
self.shuffleDown = self.gui.find('**/tt_t_gui_mat_shuffleDown')
|
||||||
|
|
||||||
|
self.title = DirectLabel(aspect2d, relief=None, text=TTLocalizer.LanguageSelectorTitle,
|
||||||
|
text_fg=(0, 1, 0, 1), text_scale=0.15, text_font=ToontownGlobals.getSuitFont(),
|
||||||
|
pos=(0, 0, 0.70), text_shadow=(0, 0.392, 0, 1))
|
||||||
|
|
||||||
|
self.current = DirectLabel(aspect2d, relief=None, text=TTLocalizer.LanguageSelectorCurrent % settings['language'],
|
||||||
|
text_fg=(0, 1, 0, 1), text_scale=0.09, text_font=ToontownGlobals.getSuitFont(),
|
||||||
|
pos=(0, 0, 0.55), text_shadow=(0, 0.392, 0, 1))
|
||||||
|
|
||||||
|
self.available = DirectLabel(aspect2d, relief=None, text=TTLocalizer.LanguageSelectorAvailable,
|
||||||
|
text_fg=(1, 0, 0, 1), text_scale=0.09, text_font=ToontownGlobals.getSuitFont(),
|
||||||
|
pos=(0, 0, 0), text_shadow=(0.545, 0, 0, 1))
|
||||||
|
|
||||||
|
self.english = DirectButton(aspect2d, relief=None, text='English',
|
||||||
|
text_fg=(1, 0.549, 0, 1), text_scale=0.09, text_font=ToontownGlobals.getSuitFont(),
|
||||||
|
pos=(0, 0, -0.15), text_shadow=(1, 0.27, 0, 1), command=self.switchLanguage, extraArgs=['English'])
|
||||||
|
|
||||||
|
self.french = DirectButton(aspect2d, relief=None, text='French',
|
||||||
|
text_fg=(1, 0.549, 0, 1), text_scale=0.09, text_font=ToontownGlobals.getSuitFont(),
|
||||||
|
pos=(0, 0, -0.25), text_shadow=(1, 0.27, 0, 1), command=self.switchLanguage, extraArgs=['French'])
|
||||||
|
|
||||||
|
self.backButton = DirectButton(aspect2d, relief=None, image=(self.shuffleUp, self.shuffleDown),
|
||||||
|
text=TTLocalizer.LanguageSelectorBack, text_font=ToontownGlobals.getInterfaceFont(),
|
||||||
|
text_scale=0.11, text_pos=(0, -0.02), pos=(0, 0, -0.75), text_fg=(1, 1, 1, 1),
|
||||||
|
text_shadow=(0, 0, 0, 1), command=self.destroy)
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
for element in [self.background, self.title, self.current, self.available, self.english, self.french, self.backButton, self.confirmDialog]:
|
||||||
|
if element:
|
||||||
|
element.destroy()
|
||||||
|
element = None
|
||||||
|
|
||||||
|
self.leaveFunction()
|
||||||
|
|
||||||
|
def switchLanguage(self, language):
|
||||||
|
if language == settings['language']:
|
||||||
|
self.confirmDialog = TTDialog.TTDialog(style=TTDialog.Acknowledge, text=TTLocalizer.LanguageSelectorSameLanguage, command=self.cleanupDialog)
|
||||||
|
else:
|
||||||
|
self.confirmDialog = TTDialog.TTDialog(style=TTDialog.YesNo, text=TTLocalizer.LanguageSelectorConfirm % language, command=self.confirmSwitchLanguage, extraArgs=[language])
|
||||||
|
self.confirmDialog.show()
|
||||||
|
|
||||||
|
def confirmSwitchLanguage(self, value, language):
|
||||||
|
if value > 0:
|
||||||
|
settings['language'] = language
|
||||||
|
os._exit(1)
|
||||||
|
else:
|
||||||
|
self.cleanupDialog()
|
||||||
|
|
||||||
|
def cleanupDialog(self, value=0):
|
||||||
|
self.confirmDialog.cleanup()
|
0
toontown/language/__init__.py
Normal file
0
toontown/language/__init__.py
Normal file
|
@ -5,6 +5,7 @@ from direct.fsm import StateData
|
||||||
from direct.fsm import ClassicFSM, State
|
from direct.fsm import ClassicFSM, State
|
||||||
from direct.fsm import State
|
from direct.fsm import State
|
||||||
from toontown.launcher import DownloadForceAcknowledge
|
from toontown.launcher import DownloadForceAcknowledge
|
||||||
|
from toontown.language import LanguageSelector
|
||||||
from direct.gui.DirectGui import *
|
from direct.gui.DirectGui import *
|
||||||
from pandac.PandaModules import *
|
from pandac.PandaModules import *
|
||||||
from toontown.toonbase import TTLocalizer
|
from toontown.toonbase import TTLocalizer
|
||||||
|
@ -45,8 +46,7 @@ class AvatarChooser(StateData.StateData):
|
||||||
base.disableMouse()
|
base.disableMouse()
|
||||||
self.title.reparentTo(aspect2d)
|
self.title.reparentTo(aspect2d)
|
||||||
self.quitButton.show()
|
self.quitButton.show()
|
||||||
if base.cr.loginInterface.supportsRelogin():
|
self.languageButton.show()
|
||||||
self.logoutButton.show()
|
|
||||||
self.pickAToonBG.setBin('background', 1)
|
self.pickAToonBG.setBin('background', 1)
|
||||||
self.pickAToonBG.reparentTo(aspect2d)
|
self.pickAToonBG.reparentTo(aspect2d)
|
||||||
base.setBackgroundColor(Vec4(0.145, 0.368, 0.78, 1))
|
base.setBackgroundColor(Vec4(0.145, 0.368, 0.78, 1))
|
||||||
|
@ -66,7 +66,7 @@ class AvatarChooser(StateData.StateData):
|
||||||
self.ignoreAll()
|
self.ignoreAll()
|
||||||
self.title.reparentTo(hidden)
|
self.title.reparentTo(hidden)
|
||||||
self.quitButton.hide()
|
self.quitButton.hide()
|
||||||
self.logoutButton.hide()
|
self.languageButton.hide()
|
||||||
self.pickAToonBG.reparentTo(hidden)
|
self.pickAToonBG.reparentTo(hidden)
|
||||||
base.setBackgroundColor(ToontownGlobals.DefaultBackgroundColor)
|
base.setBackgroundColor(ToontownGlobals.DefaultBackgroundColor)
|
||||||
return None
|
return None
|
||||||
|
@ -85,8 +85,8 @@ class AvatarChooser(StateData.StateData):
|
||||||
quitHover = gui.find('**/QuitBtn_RLVR')
|
quitHover = gui.find('**/QuitBtn_RLVR')
|
||||||
self.quitButton = DirectButton(image=(quitHover, quitHover, quitHover), relief=None, text=TTLocalizer.AvatarChooserQuit, text_font=ToontownGlobals.getSignFont(), text_fg=(0.977, 0.816, 0.133, 1), text_pos=TTLocalizer.ACquitButtonPos, text_scale=TTLocalizer.ACquitButton, image_scale=1, image1_scale=1.05, image2_scale=1.05, scale=1.05, pos=(-0.25, 0, 0.075), command=self.__handleQuit)
|
self.quitButton = DirectButton(image=(quitHover, quitHover, quitHover), relief=None, text=TTLocalizer.AvatarChooserQuit, text_font=ToontownGlobals.getSignFont(), text_fg=(0.977, 0.816, 0.133, 1), text_pos=TTLocalizer.ACquitButtonPos, text_scale=TTLocalizer.ACquitButton, image_scale=1, image1_scale=1.05, image2_scale=1.05, scale=1.05, pos=(-0.25, 0, 0.075), command=self.__handleQuit)
|
||||||
self.quitButton.reparentTo(base.a2dBottomRight)
|
self.quitButton.reparentTo(base.a2dBottomRight)
|
||||||
self.logoutButton = DirectButton(relief=None, image=(quitHover, quitHover, quitHover), text=TTLocalizer.OptionsPageLogout, text_font=ToontownGlobals.getSignFont(), text_fg=(0.977, 0.816, 0.133, 1), text_scale=TTLocalizer.AClogoutButton, text_pos=(0, -0.035), pos=(0.15, 0, 0.05), image_scale=1.15, image1_scale=1.15, image2_scale=1.18, scale=0.5, command=self.__handleLogoutWithoutConfirm)
|
self.languageButton = DirectButton(relief=None, image=(quitHover, quitHover, quitHover), text=TTLocalizer.LanguageButtonText, text_font=ToontownGlobals.getSignFont(), text_fg=(0.977, 0.816, 0.133, 1), text_scale=TTLocalizer.AClanguageButton, text_pos=(0, -0.025), pos=(0.25, 0, 0.075), image_scale=1.05, image1_scale=1.05, image2_scale=1.05, scale=1.05, command=self.openLanguageGui)
|
||||||
self.logoutButton.reparentTo(base.a2dBottomLeft)
|
self.languageButton.reparentTo(base.a2dBottomLeft)
|
||||||
gui.removeNode()
|
gui.removeNode()
|
||||||
gui2.removeNode()
|
gui2.removeNode()
|
||||||
newGui.removeNode()
|
newGui.removeNode()
|
||||||
|
@ -198,8 +198,8 @@ class AvatarChooser(StateData.StateData):
|
||||||
del self.title
|
del self.title
|
||||||
self.quitButton.destroy()
|
self.quitButton.destroy()
|
||||||
del self.quitButton
|
del self.quitButton
|
||||||
self.logoutButton.destroy()
|
self.languageButton.destroy()
|
||||||
del self.logoutButton
|
del self.languageButton
|
||||||
self.pickAToonBG.removeNode()
|
self.pickAToonBG.removeNode()
|
||||||
del self.pickAToonBG
|
del self.pickAToonBG
|
||||||
del self.avatarList
|
del self.avatarList
|
||||||
|
@ -266,5 +266,6 @@ class AvatarChooser(StateData.StateData):
|
||||||
else:
|
else:
|
||||||
self.fsm.request('Choose')
|
self.fsm.request('Choose')
|
||||||
|
|
||||||
def __handleLogoutWithoutConfirm(self):
|
def openLanguageGui(self):
|
||||||
base.cr.loginFSM.request('login')
|
self.exit()
|
||||||
|
LanguageSelector.LanguageSelector(self.enter).create()
|
||||||
|
|
|
@ -4609,7 +4609,6 @@ MapPageGoTo = 'Go To\n%s'
|
||||||
OptionsPageTitle = 'Options'
|
OptionsPageTitle = 'Options'
|
||||||
OptionsTabTitle = 'Options\n& Codes'
|
OptionsTabTitle = 'Options\n& Codes'
|
||||||
OptionsPagePurchase = 'Subscribe'
|
OptionsPagePurchase = 'Subscribe'
|
||||||
OptionsPageLogout = 'Logout'
|
|
||||||
OptionsPageExitToontown = 'Exit Toontown'
|
OptionsPageExitToontown = 'Exit Toontown'
|
||||||
OptionsPageMusicOnLabel = 'Music is on.'
|
OptionsPageMusicOnLabel = 'Music is on.'
|
||||||
OptionsPageMusicOffLabel = 'Music is off.'
|
OptionsPageMusicOffLabel = 'Music is off.'
|
||||||
|
@ -9745,6 +9744,13 @@ GloveGuiTitle = 'Choose a glove color!'
|
||||||
GloveGuiNotice = 'Costs %s jellybeans.'
|
GloveGuiNotice = 'Costs %s jellybeans.'
|
||||||
GloveGuiBuy = 'Buy'
|
GloveGuiBuy = 'Buy'
|
||||||
GloveGuiCancel = 'Cancel'
|
GloveGuiCancel = 'Cancel'
|
||||||
|
LanguageButtonText = 'Language'
|
||||||
|
LanguageSelectorTitle = 'Choose your language!'
|
||||||
|
LanguageSelectorCurrent = 'Current language: %s'
|
||||||
|
LanguageSelectorAvailable = 'Available languages:'
|
||||||
|
LanguageSelectorBack = 'Back'
|
||||||
|
LanguageSelectorConfirm = 'Are you sure you want to change your language to %s? This will close your game.'
|
||||||
|
LanguageSelectorSameLanguage = "You're already using that language!"
|
||||||
|
|
||||||
# Buffs
|
# Buffs
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ ACdeleteWithPasswordFrame = 0.06
|
||||||
ACstatusText = 1.0
|
ACstatusText = 1.0
|
||||||
ACtitle = 0.15
|
ACtitle = 0.15
|
||||||
ACquitButton = 0.1
|
ACquitButton = 0.1
|
||||||
AClogoutButton = 0.1
|
AClanguageButton = 0.075
|
||||||
ACquitButtonPos = (0, -0.035)
|
ACquitButtonPos = (0, -0.035)
|
||||||
MASPscoreText = 0.1
|
MASPscoreText = 0.1
|
||||||
MASPnameText = 0.055
|
MASPnameText = 0.055
|
||||||
|
|
Loading…
Reference in a new issue