Skip to content

Commit

Permalink
Consistent title bar + render information in mainmenu (#10764)
Browse files Browse the repository at this point in the history
  • Loading branch information
SmallJoker committed Mar 30, 2021
1 parent f345d00 commit f4118a4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
4 changes: 2 additions & 2 deletions builtin/mainmenu/init.lua
Expand Up @@ -49,7 +49,7 @@ local tabs = {}

tabs.settings = dofile(menupath .. DIR_DELIM .. "tab_settings.lua")
tabs.content = dofile(menupath .. DIR_DELIM .. "tab_content.lua")
tabs.credits = dofile(menupath .. DIR_DELIM .. "tab_credits.lua")
tabs.about = dofile(menupath .. DIR_DELIM .. "tab_about.lua")
tabs.local_game = dofile(menupath .. DIR_DELIM .. "tab_local.lua")
tabs.play_online = dofile(menupath .. DIR_DELIM .. "tab_online.lua")

Expand Down Expand Up @@ -98,7 +98,7 @@ local function init_globals()

tv_main:add(tabs.content)
tv_main:add(tabs.settings)
tv_main:add(tabs.credits)
tv_main:add(tabs.about)

tv_main:set_global_event_handler(main_event_handler)
tv_main:set_fixed_size(false)
Expand Down
Expand Up @@ -97,8 +97,8 @@ local function buildCreditList(source)
end

return {
name = "credits",
caption = fgettext("Credits"),
name = "about",
caption = fgettext("About"),
cbf_formspec = function(tabview, name, tabdata)
local logofile = defaulttexturedir .. "logo.png"
local version = core.get_version()
Expand All @@ -119,11 +119,16 @@ return {
buildCreditList(previous_contributors) .. "," ..
";1]"

-- Render information
fs = fs .. "label[0.75,4.9;" ..
fgettext("Active renderer:") .. "\n" ..
core.formspec_escape(core.get_screen_info().render_info) .. "]"

if PLATFORM ~= "Android" then
fs = fs .. "tooltip[userdata;" ..
fgettext("Opens the directory that contains user-provided worlds, games, mods,\n" ..
"and texture packs in a file manager / explorer.") .. "]"
fs = fs .. "button[0,4.75;3.5,1;userdata;" .. fgettext("Open User Data Directory") .. "]"
fs = fs .. "button[0,4;3.5,1;userdata;" .. fgettext("Open User Data Directory") .. "]"
end

return fs
Expand Down
3 changes: 2 additions & 1 deletion doc/menu_lua_api.txt
Expand Up @@ -204,7 +204,8 @@ core.get_screen_info()
display_width = <width of display>,
display_height = <height of display>,
window_width = <current window width>,
window_height = <current window height>
window_height = <current window height>,
render_info = <active render information>
}


Expand Down
12 changes: 12 additions & 0 deletions src/client/game.cpp
Expand Up @@ -1390,9 +1390,21 @@ bool Game::createClient(const GameStartData &start_data)
std::wstring str = utf8_to_wide(PROJECT_NAME_C);
str += L" ";
str += utf8_to_wide(g_version_hash);
{
const wchar_t *text = nullptr;
if (simple_singleplayer_mode)
text = wgettext("Singleplayer");
else
text = wgettext("Multiplayer");
str += L" [";
str += text;
str += L"]";
delete text;
}
str += L" [";
str += driver->getName();
str += L"]";

device->setWindowCaption(str.c_str());

LocalPlayer *player = client->getEnv().getLocalPlayer();
Expand Down
12 changes: 4 additions & 8 deletions src/script/lua_api/l_mainmenu.cpp
Expand Up @@ -856,14 +856,6 @@ int ModApiMainMenu::l_get_screen_info(lua_State *L)
lua_pushnumber(L,RenderingEngine::getDisplayDensity());
lua_settable(L, top);

lua_pushstring(L,"display_width");
lua_pushnumber(L,RenderingEngine::getDisplaySize().X);
lua_settable(L, top);

lua_pushstring(L,"display_height");
lua_pushnumber(L,RenderingEngine::getDisplaySize().Y);
lua_settable(L, top);

const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize();
lua_pushstring(L,"window_width");
lua_pushnumber(L, window_size.X);
Expand All @@ -872,6 +864,10 @@ int ModApiMainMenu::l_get_screen_info(lua_State *L)
lua_pushstring(L,"window_height");
lua_pushnumber(L, window_size.Y);
lua_settable(L, top);

lua_pushstring(L, "render_info");
lua_pushstring(L, wide_to_utf8(RenderingEngine::get_video_driver()->getName()).c_str());
lua_settable(L, top);
return 1;
}

Expand Down

0 comments on commit f4118a4

Please sign in to comment.