mirror of
https://github.com/luanti-org/luanti.git
synced 2026-01-01 10:45:32 +01:00
Show proper default key name in reset tooltip on keybindings menu (#16777)
* implement 'core.scancode_to_keyname()' and use it to fix something * fix whitespaces and fix another thing * ._. * lol * rename to get_key_description * add case for keybindings whose defaults are not bound * apply y5nw's suggestions * lmao I'm so dumb
This commit is contained in:
@@ -52,6 +52,16 @@ int ModApiMenuCommon::l_normalize_keycode(lua_State *L)
|
||||
}
|
||||
|
||||
|
||||
int ModApiMenuCommon::l_get_key_description(lua_State *L)
|
||||
{
|
||||
const char *keystr = luaL_checkstring(L, 1);
|
||||
KeyPress kp(keystr);
|
||||
std::string name = kp.name();
|
||||
lua_pushstring(L, name.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void ModApiMenuCommon::Initialize(lua_State *L, int top)
|
||||
{
|
||||
API_FCT(gettext);
|
||||
@@ -59,6 +69,7 @@ void ModApiMenuCommon::Initialize(lua_State *L, int top)
|
||||
API_FCT(driver_supports_shadows);
|
||||
API_FCT(irrlicht_device_supports_touch);
|
||||
API_FCT(normalize_keycode);
|
||||
API_FCT(get_key_description);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ private:
|
||||
static int l_driver_supports_shadows(lua_State *L);
|
||||
static int l_irrlicht_device_supports_touch(lua_State *L);
|
||||
static int l_normalize_keycode(lua_State *L);
|
||||
static int l_get_key_description(lua_State *L);
|
||||
|
||||
public:
|
||||
static void Initialize(lua_State *L, int top);
|
||||
|
||||
Reference in New Issue
Block a user