Fallback fonts + localizations (#262)
* Fallback fonts + localizations * cannot find address on h1 [skip] * fix build * fix language menu * small fix * improved regular font * format LUI stuff [skip ci] Co-authored-by: m <mjkzyalt@gmail.com>
This commit is contained in:
@ -1,20 +1,22 @@
|
||||
require("language")
|
||||
|
||||
if (game:issingleplayer()) then
|
||||
return
|
||||
return
|
||||
end
|
||||
|
||||
if (Engine.InFrontend()) then
|
||||
require("shader_dialog")
|
||||
require("gamemodes")
|
||||
require("no_mode_switch")
|
||||
require("disable_useless_things")
|
||||
require("shader_dialog")
|
||||
require("gamemodes")
|
||||
require("no_mode_switch")
|
||||
require("disable_useless_things")
|
||||
end
|
||||
|
||||
-- defined in mp_hud/hudutils.lua
|
||||
function GetGameModeName()
|
||||
return Engine.Localize(Engine.TableLookup(GameTypesTable.File,
|
||||
GameTypesTable.Cols.Ref, GameX.GetGameMode(), GameTypesTable.Cols.Name))
|
||||
return Engine.Localize(Engine.TableLookup(GameTypesTable.File, GameTypesTable.Cols.Ref, GameX.GetGameMode(),
|
||||
GameTypesTable.Cols.Name))
|
||||
end
|
||||
|
||||
function NeverAllowChangeTeams()
|
||||
return false
|
||||
return false
|
||||
end
|
||||
|
97
data/cdata/ui_scripts/patches/language.lua
Normal file
97
data/cdata/ui_scripts/patches/language.lua
Normal file
@ -0,0 +1,97 @@
|
||||
local available_languages = {"english", "english_safe", "french", "german", "italian", "polish", "portuguese",
|
||||
"russian", "spanish", "simplified_chinese", "traditional_chinese", "japanese_partial",
|
||||
"korean"}
|
||||
local current_language = "english"
|
||||
|
||||
LUI.UIButtonText.IsOffsetedLanguage = function()
|
||||
return false
|
||||
end
|
||||
|
||||
function get_current_language()
|
||||
current_language = game:getcurrentgamelanguage()
|
||||
end
|
||||
|
||||
function set_language(value)
|
||||
local file_path = "players2/default/language"
|
||||
local file = io.open(file_path, "w")
|
||||
file:write(value)
|
||||
file:close()
|
||||
end
|
||||
|
||||
function does_zone_folder_exists(language)
|
||||
return io.directoryexists("zone/" .. language)
|
||||
end
|
||||
|
||||
get_current_language()
|
||||
|
||||
LUI.addmenubutton("pc_controls", {
|
||||
index = 4,
|
||||
text = "@MENU_LANGUAGE",
|
||||
description = Engine.Localize("@LUA_MENU_CHOOSE_LANGUAGE"),
|
||||
callback = function()
|
||||
LUI.FlowManager.RequestAddMenu(nil, "choose_language_menu")
|
||||
end
|
||||
})
|
||||
|
||||
LUI.MenuBuilder.registerType("choose_language_menu", function(a1)
|
||||
local menu = LUI.MenuTemplate.new(a1, {
|
||||
menu_title = "@LUA_MENU_CHOOSE_LANGUAGE",
|
||||
menu_list_divider_top_offset = -(LUI.H1MenuTab.tabChangeHoldingElementHeight + H1MenuDims.spacing),
|
||||
uppercase_title = true
|
||||
})
|
||||
|
||||
function createdivider(menu, text)
|
||||
local element = LUI.UIElement.new({
|
||||
leftAnchor = true,
|
||||
rightAnchor = false,
|
||||
left = 10,
|
||||
right = 0,
|
||||
topAnchor = true,
|
||||
bottomAnchor = false,
|
||||
top = 0,
|
||||
bottom = 33.33
|
||||
})
|
||||
|
||||
element.scrollingToNext = true
|
||||
element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", {
|
||||
title_bar_text = text
|
||||
}))
|
||||
|
||||
menu.list:addElement(element)
|
||||
end
|
||||
|
||||
createdivider(menu, "^2" .. Engine.Localize("@LUA_MENU_DOWNLOAD") .. ": ^7https://docs.h1.gg/languages")
|
||||
|
||||
for i = 1, #available_languages do
|
||||
if does_zone_folder_exists(available_languages[i]) then
|
||||
menu:AddButton(Engine.Localize(string.format("MENU_%s", available_languages[i])), function()
|
||||
LUI.yesnopopup({
|
||||
title = Engine.Localize("@MENU_NOTICE"),
|
||||
text = Engine.Localize("MENU_" .. current_language) .. " → " ..
|
||||
Engine.Localize("MENU_" .. available_languages[i]) .. "\n\n" ..
|
||||
Engine.Localize("@LUA_MENU_CONFIRM_LANGUAGE") .. " " ..
|
||||
Engine.Localize("@MENU_APPLY_LANGUAGE_SETTINGS"),
|
||||
callback = function(result)
|
||||
if (result) then
|
||||
set_language(available_languages[i])
|
||||
updater.relaunch()
|
||||
else
|
||||
LUI.FlowManager.RequestLeaveMenu(popup)
|
||||
end
|
||||
end
|
||||
})
|
||||
end, available_languages[i] == current_language, true, nil, {
|
||||
desc_text = Engine.Localize("LOCALE_" .. (available_languages[i]))
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
LUI.Options.InitScrollingList(menu.list, nil, {
|
||||
rows = 12
|
||||
})
|
||||
|
||||
LUI.Options.AddOptionTextInfo(menu)
|
||||
menu:AddBackButton()
|
||||
|
||||
return menu
|
||||
end)
|
@ -1,25 +1,25 @@
|
||||
LUI.MenuBuilder.registerPopupType("ShaderCacheDialog_original", LUI.ShaderCacheDialog.new)
|
||||
|
||||
local function dialog(...)
|
||||
if (game:sharedget("has_accepted_shader_caching") == "1") then
|
||||
return LUI.ShaderCacheDialog.new(...)
|
||||
end
|
||||
if (game:sharedget("has_accepted_shader_caching") == "1") then
|
||||
return LUI.ShaderCacheDialog.new(...)
|
||||
end
|
||||
|
||||
return LUI.MenuBuilder.BuildRegisteredType("generic_yesno_popup", {
|
||||
popup_title = Engine.Localize("@MENU_WARNING"),
|
||||
message_text = Engine.Localize("@PLATFORM_SHADER_PRECACHE_ASK"),
|
||||
yes_action = function()
|
||||
game:sharedset("has_accepted_shader_caching", "1")
|
||||
LUI.FlowManager.RequestAddMenu(nil, "ShaderCacheDialog_original")
|
||||
end,
|
||||
yes_text = Engine.Localize("@MENU_YES"),
|
||||
no_text = Engine.Localize("@MENU_NO_DONT_ASK"),
|
||||
no_action = function()
|
||||
Engine.SetDvarInt("r_preloadShadersFrontendAllow", 0)
|
||||
end,
|
||||
default_focus_index = 2,
|
||||
cancel_will_close = false
|
||||
})
|
||||
return LUI.MenuBuilder.BuildRegisteredType("generic_yesno_popup", {
|
||||
popup_title = Engine.Localize("@MENU_WARNING"),
|
||||
message_text = Engine.Localize("@PLATFORM_SHADER_PRECACHE_ASK"),
|
||||
yes_action = function()
|
||||
game:sharedset("has_accepted_shader_caching", "1")
|
||||
LUI.FlowManager.RequestAddMenu(nil, "ShaderCacheDialog_original")
|
||||
end,
|
||||
yes_text = Engine.Localize("@MENU_YES"),
|
||||
no_text = Engine.Localize("@MENU_NO_DONT_ASK"),
|
||||
no_action = function()
|
||||
Engine.SetDvarInt("r_preloadShadersFrontendAllow", 0)
|
||||
end,
|
||||
default_focus_index = 2,
|
||||
cancel_will_close = false
|
||||
})
|
||||
end
|
||||
|
||||
LUI.MenuBuilder.m_types_build["ShaderCacheDialog"] = dialog
|
||||
|
Reference in New Issue
Block a user