Some fixes

This commit is contained in:
Federico Cecchetto 2022-03-20 00:41:25 +01:00
parent 0b50ac734d
commit 769d2c74cb
4 changed files with 81 additions and 76 deletions

View File

@ -1,3 +1,28 @@
game:addlocalizedstring("MENU_GENERAL", "General")
game:addlocalizedstring("MENU_GENERAL_DESC", "Set the client's settings.")
game:addlocalizedstring("LUA_MENU_AUTO_UPDATE", "Automatic updates")
game:addlocalizedstring("LUA_MENU_CHECK_UPDATES", "Check for updates")
game:addlocalizedstring("LUA_MENU_CHECK_UPDATES_DESC", "Check for updates.")
game:addlocalizedstring("LUA_MENU_DRAWING", "Drawing")
game:addlocalizedstring("LUA_MENU_UPDATES", "Updates")
game:addlocalizedstring("LUA_MENU_RENDERING", "Rendering")
game:addlocalizedstring("LUA_MENU_DRAW_FPS", "Draw FPS")
game:addlocalizedstring("LUA_MENU_DRAW_FPS_DESC", "Enable or disable drawing fps or viewpos on screen.")
game:addlocalizedstring("LUA_MENU_FPS_ONLY", "FPS only")
game:addlocalizedstring("LUA_MENU_FPS_AND_VIEWPOS", "FPS and View Pos")
game:addlocalizedstring("LUA_MENU_DRAW_SPEED", "Draw speed")
game:addlocalizedstring("LUA_MENU_DRAW_SPEED_DESC", "Enable or disable drawing the player speed on screen.")
game:addlocalizedstring("LUA_MENU_DRAW_SPEEDGRAPH", "Draw speed graph")
game:addlocalizedstring("LUA_MENU_DRAW_SPEEDGRAPH_DESC", "Enable or disable the speed graph.")
game:addlocalizedstring("LUA_MENU_R_FULLBRIGHT", "Fullbright")
game:addlocalizedstring("LUA_MENU_R_FULLBRIGHT_DESC", "Change the fullbright mode.")
game:addlocalizedstring("LUA_MENU_MODE2", "Mode 2")
game:addlocalizedstring("LUA_MENU_MODE3", "Mode 3")
function createdivider(menu, text) function createdivider(menu, text)
local element = LUI.UIElement.new({ local element = LUI.UIElement.new({
leftAnchor = true, leftAnchor = true,
@ -20,8 +45,8 @@ end
LUI.addmenubutton("pc_controls", { LUI.addmenubutton("pc_controls", {
index = 4, index = 4,
text = "$_GENERAL", text = "@MENU_GENERAL",
description = "Set the client's settings.", description = "@MENU_GENERAL_DESC",
callback = function() callback = function()
LUI.FlowManager.RequestAddMenu(nil, "settings_menu") LUI.FlowManager.RequestAddMenu(nil, "settings_menu")
end end
@ -29,134 +54,118 @@ LUI.addmenubutton("pc_controls", {
LUI.MenuBuilder.m_types_build["settings_menu"] = function(a1) LUI.MenuBuilder.m_types_build["settings_menu"] = function(a1)
local menu = LUI.MenuTemplate.new(a1, { local menu = LUI.MenuTemplate.new(a1, {
menu_title = "$_GENERAL", menu_title = "@MENU_GENERAL",
menu_list_divider_top_offset = -(LUI.H1MenuTab.tabChangeHoldingElementHeight + luiglobals.H1MenuDims.spacing), menu_list_divider_top_offset = -(LUI.H1MenuTab.tabChangeHoldingElementHeight + luiglobals.H1MenuDims.spacing),
menu_width = luiglobals.GenericMenuDims.OptionMenuWidth menu_width = luiglobals.GenericMenuDims.OptionMenuWidth
}) })
Engine.SetDvarFromString("ui_cg_autoUpdate", Engine.GetDvarBool("cg_autoUpdate") and "1" or "0") createdivider(menu, "@LUA_MENU_UPDATES")
Engine.SetDvarFromString("ui_cg_drawFps", Engine.GetDvarInt("cg_drawFps") .. "")
Engine.SetDvarFromString("ui_cg_speedGraph", Engine.GetDvarBool("cg_speedGraph") and "1" or "0")
Engine.SetDvarFromString("ui_cg_drawSpeed", Engine.GetDvarBool("cg_drawSpeed") and "1" or "0")
Engine.SetDvarFromString("ui_r_fullbright", Engine.GetDvarInt("r_fullbright") .. "")
createdivider(menu, "$_UPDATES")
LUI.Options.CreateOptionButton( LUI.Options.CreateOptionButton(
menu, menu,
"ui_cg_autoUpdate", "cg_autoUpdate",
"$_AUTOMATIC UPDATES", "@LUA_MENU_AUTO_UPDATE",
"Enable or disable automatic updates on startup.", "Enable or disable automatic updates on startup.",
{ {
{ {
text = "$_ENABLED", text = "@LUA_MENU_ENABLED",
value = "1" value = true
}, },
{ {
text = "$_DISABLED", text = "@LUA_MENU_DISABLED",
value = "0" value = false
} }
}, nil, nil, function(value) }
Engine.SetDvarBool("cg_autoUpdate", Engine.GetDvarString("ui_cg_autoUpdate") == "1")
end
) )
menu:AddButton("$_CHECK FOR UPDATES", function() menu:AddButton("@LUA_MENU_CHECK_UPDATES", function()
LUI.tryupdating(false) LUI.tryupdating(false)
end, nil, true, nil, { end, nil, true, nil, {
desc_text = "Check for updates." desc_text = Engine.Localize("@LUA_MENU_CHECK_UPDATES_DESC")
}) })
createdivider(menu, "$_DRAWING") createdivider(menu, "@LUA_MENU_DRAWING")
LUI.Options.CreateOptionButton( LUI.Options.CreateOptionButton(
menu, menu,
"ui_cg_drawFps", "cg_drawFps",
"$_DRAW FPS", "@LUA_MENU_DRAW_FPS",
"Enable or disable drawing fps or viewpos on screen.", "@LUA_MENU_DRAW_FPS_DESC",
{ {
{ {
text = "$_DISABLED", text = "@LUA_MENU_DISABLED",
value = "0" value = 0
}, },
{ {
text = "$_FPS ONLY", text = "@LUA_MENU_FPS_ONLY",
value = "1" value = 1
}, },
{ {
text = "$_FPS AND VIEWPOS", text = "@LUA_MENU_FPS_AND_VIEWPOS",
value = "2" value = 2
} }
}, nil, nil, function(value) }
Engine.SetDvarInt("cg_drawFps", tonumber(Engine.GetDvarString("ui_cg_drawFps")))
end
) )
LUI.Options.CreateOptionButton( LUI.Options.CreateOptionButton(
menu, menu,
"ui_cg_drawSpeed", "cg_drawSpeed",
"$_DRAW SPEED", "@LUA_MENU_DRAW_SPEED",
"Enable or disable drawing the player speed on screen.", "Enable or disable drawing the player speed on screen.",
{ {
{ {
text = "$_DISABLED", text = "@LUA_MENU_ENABLED",
value = "0" value = true
}, },
{ {
text = "$_ENABLED", text = "@LUA_MENU_DISABLED",
value = "1" value = false
} }
}, nil, nil, function(value) }
Engine.SetDvarBool("cg_drawSpeed", Engine.GetDvarString("ui_cg_drawSpeed") == "1")
end
) )
LUI.Options.CreateOptionButton( LUI.Options.CreateOptionButton(
menu, menu,
"ui_cg_speedGraph", "cg_speedGraph",
"$_DRAW SPEED GRAPH", "@LUA_MENU_DRAW_SPEEDGRAPH",
"Enable or disable the speed graph.", "@LUA_MENU_DRAW_SPEEDGRAPH_DESC",
{ {
{ {
text = "$_DISABLED", text = "@LUA_MENU_ENABLED",
value = "0" value = true
}, },
{ {
text = "$_ENABLED", text = "@LUA_MENU_DISABLED",
value = "1" value = false
} }
}, nil, nil, function(value) }
Engine.SetDvarBool("cg_speedGraph", Engine.GetDvarString("ui_cg_speedGraph") == "1")
end
) )
createdivider(menu, "$_RENDERING") createdivider(menu, "@LUA_MENU_RENDERING")
LUI.Options.CreateOptionButton( LUI.Options.CreateOptionButton(
menu, menu,
"ui_r_fullbright", "r_fullbright",
"$_FULLBRIGHT", "@LUA_MENU_R_FULLBRIGHT",
"Change the fullbright mode.", "@LUA_MENU_R_FULLBRIGHT_DESC",
{ {
{ {
text = "$_DISABLED", text = "@LUA_MENU_DISABLED",
value = "0" value = 0
}, },
{ {
text = "$_ENABLED", text = "@LUA_MENU_ENABLED",
value = "1" value = 1
}, },
{ {
text = "$_MODE 2", text = "@LUA_MENU_MODE2",
value = "2" value = 2
}, },
{ {
text = "$_MODE 3", text = "@LUA_MENU_MODE3",
value = "3" value = 3
} }
}, nil, nil, function(value) }
Engine.SetDvarInt("r_fullbright", tonumber(Engine.GetDvarString("ui_r_fullbright")))
end
) )
LUI.Options.InitScrollingList(menu.list, nil) LUI.Options.InitScrollingList(menu.list, nil)

View File

@ -352,7 +352,7 @@ namespace updater
if (!is_update_check_done() || !get_update_check_status() || is_update_cancelled()) if (!is_update_check_done() || !get_update_check_status() || is_update_cancelled())
{ {
return; return;
}// }
scheduler::once([]() scheduler::once([]()
{ {

View File

@ -74,7 +74,7 @@ namespace ui_scripting::lua::engine
get_scripts().clear(); get_scripts().clear();
load_code(lui_common); load_code(lui_common);
// load_code(lui_updater); load_code(lui_updater);
for (const auto& path : filesystem::get_search_paths()) for (const auto& path : filesystem::get_search_paths())
{ {

View File

@ -89,11 +89,7 @@ function startupdatedownload(popup, autoclose)
end end
}) })
else else
if (LUI.mp_menus) then Engine.Exec("lui_restart")
Engine.Exec("lui_restart; lui_open mp_main_menu")
else
Engine.Exec("lui_restart")
end
end end
if (autoclose) then if (autoclose) then
@ -160,5 +156,5 @@ function tryautoupdate()
end end
end end
LUI.onmenuopen("mp_main_menu", tryautoupdate) LUI.tryupdating = tryupdate
LUI.onmenuopen("main_lockout", tryautoupdate) LUI.onmenuopen("main_lockout", tryautoupdate)