mirror of
https://github.com/luanti-org/luanti.git
synced 2026-01-02 19:25:20 +01:00
Translate key names in KeyPress::name() (#16779)
* Make KeyPress::name() return translated key names * minor
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
// Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
// Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||||
|
|
||||||
#include "keycode.h"
|
#include "keycode.h"
|
||||||
|
#include "gettext.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "renderingengine.h"
|
#include "renderingengine.h"
|
||||||
@@ -28,8 +29,6 @@ struct table_key {
|
|||||||
#define DEFINEKEY5(ch) /* key without Irrlicht keycode */ \
|
#define DEFINEKEY5(ch) /* key without Irrlicht keycode */ \
|
||||||
{ ch, KEY_KEY_CODES_COUNT, static_cast<wchar_t>(*ch), ch },
|
{ ch, KEY_KEY_CODES_COUNT, static_cast<wchar_t>(*ch), ch },
|
||||||
|
|
||||||
#define N_(text) text
|
|
||||||
|
|
||||||
static std::vector<table_key> table = {
|
static std::vector<table_key> table = {
|
||||||
// Keys that can be reliably mapped between Char and Key
|
// Keys that can be reliably mapped between Char and Key
|
||||||
DEFINEKEY3(0)
|
DEFINEKEY3(0)
|
||||||
@@ -224,9 +223,6 @@ static std::vector<table_key> table = {
|
|||||||
|
|
||||||
static const table_key invalid_key = {"", KEY_UNKNOWN, L'\0', ""};
|
static const table_key invalid_key = {"", KEY_UNKNOWN, L'\0', ""};
|
||||||
|
|
||||||
#undef N_
|
|
||||||
|
|
||||||
|
|
||||||
static const table_key &lookup_keychar(wchar_t Char)
|
static const table_key &lookup_keychar(wchar_t Char)
|
||||||
{
|
{
|
||||||
if (Char == L'\0')
|
if (Char == L'\0')
|
||||||
@@ -327,8 +323,10 @@ std::string KeyPress::name() const
|
|||||||
{
|
{
|
||||||
const auto &name = lookup_scancode(scancode).LangName;
|
const auto &name = lookup_scancode(scancode).LangName;
|
||||||
if (!name.empty())
|
if (!name.empty())
|
||||||
return name;
|
return strgettext(name);
|
||||||
return formatScancode();
|
if (auto scancode = getScancode())
|
||||||
|
return fmtgettext("Scancode: %d", scancode);
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
EKEY_CODE KeyPress::getKeycode() const
|
EKEY_CODE KeyPress::getKeycode() const
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ void GUIButtonKey::setKey(KeyPress kp)
|
|||||||
{
|
{
|
||||||
key_value = kp;
|
key_value = kp;
|
||||||
keysym = utf8_to_wide(kp.sym());
|
keysym = utf8_to_wide(kp.sym());
|
||||||
super::setText(wstrgettext(kp.name()).c_str());
|
super::setText(utf8_to_wide(kp.name()).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUIButtonKey::sendKey()
|
void GUIButtonKey::sendKey()
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ private:
|
|||||||
{
|
{
|
||||||
capturing = false;
|
capturing = false;
|
||||||
nostart |= inhibit_restart;
|
nostart |= inhibit_restart;
|
||||||
super::setText(wstrgettext(key_value.name()).c_str());
|
super::setText(utf8_to_wide(key_value.name()).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Sets the captured key and stop capturing
|
//! Sets the captured key and stop capturing
|
||||||
|
|||||||
Reference in New Issue
Block a user