快捷切换多语言

This commit is contained in:
xiekaidong 2023-07-07 11:39:30 +08:00
parent e580b332a9
commit a34edc2fd7
2 changed files with 42 additions and 0 deletions

View File

@ -420,6 +420,47 @@ if NOT_PUBLISH then
end end
end end
if Input.GetKeyDown(KeyCode.LeftArrow) and Input.GetKey(KeyCode.RightControl)then
local curLanguage = I18N:getCurLanguage()
local languageList = I18N:getSupportLanguageList()
local curIndex = 1
for index, language in ipairs(languageList) do
if language == curLanguage then
curIndex = index + 1
break
end
end
if not languageList[curIndex] then
curIndex = 1
end
local language = languageList[curIndex]
local changeStatus = I18N:setLanguage(language)
if changeStatus then
local FontManager = require "app/common/font_manager"
FontManager:changeLanguage(I18N:getCurLanguage() or GConst.LANGUAGE.ENGLISH, function()
local topUi = UIManager:getTopUIObj()
if topUi:getUIIndex() == UIManager.UI_PATH.MAINCITY_UI then
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.I18N_CHANGE_LANGUAGE)
UIManager:closeAllUI()
UIManager:hideToastAndMessageBox()
UIManager:clearUIPrefabCache()
UIManager:refreshOnChangeLanguage()
ModuleManager.MaincityManager:showMainCityUI()
else
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.I18N_CHANGE_LANGUAGE)
UIManager:hideToastAndMessageBox()
UIManager:clearUIPrefabCache()
UIManager:refreshOnChangeLanguage()
for _, obj in ipairs(UIManager:getUIList()) do
obj:onClose()
obj:onLoadRootComplete()
obj:onRefresh()
end
end
end)
end
end
if (Input.GetKeyDown(KeyCode.RightArrow) or Input.GetKeyDown(KeyCode.LeftArrow)) and Input.GetKey(KeyCode.LeftControl) then if (Input.GetKeyDown(KeyCode.RightArrow) or Input.GetKeyDown(KeyCode.LeftArrow)) and Input.GetKey(KeyCode.LeftControl) then
if not ModuleManager.DevToolManager.set_board_info then if not ModuleManager.DevToolManager.set_board_info then
Logger.logHighlight("请先去gm面板设置浏览的棋盘信息!") Logger.logHighlight("请先去gm面板设置浏览的棋盘信息!")

View File

@ -105,6 +105,7 @@ end
function MainCityUI:onClose() function MainCityUI:onClose()
self.subComps[GConst.MainCityConst.BOTTOM_PAGE.MAIN]:onClose() self.subComps[GConst.MainCityConst.BOTTOM_PAGE.MAIN]:onClose()
self.subComps = nil
end end
function MainCityUI:refreshAllSideBars() function MainCityUI:refreshAllSideBars()