1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-12-04 14:45:26 +01:00

Show warning in mainmenu when debug build

This commit is contained in:
sfan5
2025-11-25 17:34:21 +01:00
committed by GitHub
parent f5f26bff66
commit 7579b27ed1
4 changed files with 40 additions and 13 deletions

View File

@@ -29,6 +29,7 @@
#include "client/sound/sound_openal.h"
#endif
#include <algorithm>
#include <csignal>
@@ -638,9 +639,13 @@ void GUIEngine::setTopleftText(const std::string &text)
/******************************************************************************/
void GUIEngine::updateTopLeftTextSize()
{
core::rect<s32> rect(0, 0, g_fontengine->getTextWidth(m_toplefttext.c_str()),
g_fontengine->getTextHeight());
rect += v2s32(4, 0);
const auto &str = m_toplefttext.getString();
u32 lines = std::count(str.begin(), str.end(), L'\n') + 1;
core::rect<s32> rect(0, 0,
g_fontengine->getTextWidth(str.c_str()),
g_fontengine->getTextHeight() * lines
);
rect += v2s32(4, 4);
m_irr_toplefttext->remove();
m_irr_toplefttext = gui::StaticText::add(m_rendering_engine->get_gui_env(),

View File

@@ -5,6 +5,7 @@
#include "lua_api/l_mainmenu.h"
#include "lua_api/l_internal.h"
#include "common/c_content.h"
#include "config.h"
#include "scripting_mainmenu.h"
#include "gui/guiEngine.h"
#include "gui/guiMainMenu.h"
@@ -657,11 +658,10 @@ int ModApiMainMenu::l_delete_world(lua_State *L)
int ModApiMainMenu::l_set_topleft_text(lua_State *L)
{
GUIEngine* engine = getGuiEngine(L);
sanity_check(engine != NULL);
sanity_check(engine);
std::string text;
if (!lua_isnone(L,1) && !lua_isnil(L,1))
if (!lua_isnoneornil(L, 1))
text = luaL_checkstring(L, 1);
engine->setTopleftText(text);
@@ -964,12 +964,11 @@ int ModApiMainMenu::l_get_active_irrlicht_device(lua_State *L)
}
}();
if (auto version = device->getVersionString(); !version.empty())
device_name.append(" " + version);
device_name.append(" ").append(version);
lua_pushstring(L, device_name.c_str());
return 1;
}
/******************************************************************************/
int ModApiMainMenu::l_get_min_supp_proto(lua_State *L)
{
lua_pushinteger(L, CLIENT_PROTOCOL_VERSION_MIN);
@@ -982,14 +981,25 @@ int ModApiMainMenu::l_get_max_supp_proto(lua_State *L)
return 1;
}
/******************************************************************************/
int ModApiMainMenu::l_get_formspec_version(lua_State *L)
{
lua_pushinteger(L, FORMSPEC_API_VERSION);
return 1;
}
/******************************************************************************/
int ModApiMainMenu::l_is_debug_build(lua_State *L)
{
bool ret = false;
// We can't know for sure, but as far as our own build types go the following
// two use -O0. Check NDEBUG too to definitely exclude release builds.
#ifndef NDEBUG
if (strcmp(BUILD_TYPE, "Debug") == 0 || strcmp(BUILD_TYPE, "None") == 0)
ret = true;
#endif
lua_pushboolean(L, ret);
return 1;
}
int ModApiMainMenu::l_open_url(lua_State *L)
{
std::string url = luaL_checkstring(L, 1);
@@ -1109,6 +1119,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
API_FCT(get_min_supp_proto);
API_FCT(get_max_supp_proto);
API_FCT(get_formspec_version);
API_FCT(is_debug_build);
API_FCT(open_url);
API_FCT(open_url_dialog);
API_FCT(open_dir);
@@ -1141,8 +1152,9 @@ void ModApiMainMenu::InitializeAsync(lua_State *L, int top)
API_FCT(extract_zip);
API_FCT(may_modify_path);
API_FCT(download_file);
API_FCT(get_language);
API_FCT(get_min_supp_proto);
API_FCT(get_max_supp_proto);
API_FCT(get_formspec_version);
API_FCT(get_language);
API_FCT(is_debug_build);
}

View File

@@ -133,6 +133,8 @@ private:
static int l_get_formspec_version(lua_State *L);
static int l_is_debug_build(lua_State *L);
// other
static int l_open_url(lua_State *L);