summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-10-18 02:29:06 +0200
committerest31 <MTest31@outlook.com>2015-10-18 02:29:06 +0200
commit6b0cae5a9d6e220b9f1ecf8e6a821d84961564fd (patch)
tree67a2bcef1cb55d45665d5e39bc27b6a6afca2da6
parentf3d82567c9dc98d5b1fa8724055727956ed351eb (diff)
downloadminetest-6b0cae5a9d6e220b9f1ecf8e6a821d84961564fd.tar.gz
minetest-6b0cae5a9d6e220b9f1ecf8e6a821d84961564fd.tar.bz2
minetest-6b0cae5a9d6e220b9f1ecf8e6a821d84961564fd.zip
Remove wstrgettext
Everywhere where wstrgettext was used, its output was converted back to utf8. As wstrgettext internally converts the return value from utf8 to wstring, it has been a waste. Remove the function, and use strgettext instead.
-rw-r--r--src/game.cpp64
-rw-r--r--src/gettext.h8
-rw-r--r--src/script/lua_api/l_mainmenu.cpp4
3 files changed, 34 insertions, 42 deletions
diff --git a/src/game.cpp b/src/game.cpp
index e966920a6..aa2fe8a00 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -1048,7 +1048,7 @@ static void show_chat_menu(GUIFormSpecMenu **cur_formspec,
FORMSPEC_VERSION_STRING
SIZE_TAG
"field[3,2.35;6,0.5;f_text;;" + text + "]"
- "button_exit[4,3;3,0.5;btn_send;" + wide_to_utf8(wstrgettext("Proceed")) + "]"
+ "button_exit[4,3;3,0.5;btn_send;" + strgettext("Proceed") + "]"
;
/* Create menu */
@@ -1088,32 +1088,32 @@ static void show_pause_menu(GUIFormSpecMenu **cur_formspec,
bool singleplayermode)
{
#ifdef __ANDROID__
- std::string control_text = wide_to_utf8(wstrgettext("Default Controls:\n"
- "No menu visible:\n"
- "- single tap: button activate\n"
- "- double tap: place/use\n"
- "- slide finger: look around\n"
- "Menu/Inventory visible:\n"
- "- double tap (outside):\n"
- " -->close\n"
- "- touch stack, touch slot:\n"
- " --> move stack\n"
- "- touch&drag, tap 2nd finger\n"
- " --> place single item to slot\n"
- ));
+ std::string control_text = strgettext("Default Controls:\n"
+ "No menu visible:\n"
+ "- single tap: button activate\n"
+ "- double tap: place/use\n"
+ "- slide finger: look around\n"
+ "Menu/Inventory visible:\n"
+ "- double tap (outside):\n"
+ " -->close\n"
+ "- touch stack, touch slot:\n"
+ " --> move stack\n"
+ "- touch&drag, tap 2nd finger\n"
+ " --> place single item to slot\n"
+ );
#else
- std::string control_text = wide_to_utf8(wstrgettext("Default Controls:\n"
- "- WASD: move\n"
- "- Space: jump/climb\n"
- "- Shift: sneak/go down\n"
- "- Q: drop item\n"
- "- I: inventory\n"
- "- Mouse: turn/look\n"
- "- Mouse left: dig/punch\n"
- "- Mouse right: place/use\n"
- "- Mouse wheel: select item\n"
- "- T: chat\n"
- ));
+ std::string control_text = strgettext("Default Controls:\n"
+ "- WASD: move\n"
+ "- Space: jump/climb\n"
+ "- Shift: sneak/go down\n"
+ "- Q: drop item\n"
+ "- I: inventory\n"
+ "- Mouse: turn/look\n"
+ "- Mouse left: dig/punch\n"
+ "- Mouse right: place/use\n"
+ "- Mouse wheel: select item\n"
+ "- T: chat\n"
+ );
#endif
float ypos = singleplayermode ? 0.5 : 0.1;
@@ -1121,23 +1121,23 @@ static void show_pause_menu(GUIFormSpecMenu **cur_formspec,
os << FORMSPEC_VERSION_STRING << SIZE_TAG
<< "button_exit[4," << (ypos++) << ";3,0.5;btn_continue;"
- << wide_to_utf8(wstrgettext("Continue")) << "]";
+ << strgettext("Continue") << "]";
if (!singleplayermode) {
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_change_password;"
- << wide_to_utf8(wstrgettext("Change Password")) << "]";
+ << strgettext("Change Password") << "]";
}
#ifndef __ANDROID__
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_sound;"
- << wide_to_utf8(wstrgettext("Sound Volume")) << "]";
+ << strgettext("Sound Volume") << "]";
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_key_config;"
- << wide_to_utf8(wstrgettext("Change Keys")) << "]";
+ << strgettext("Change Keys") << "]";
#endif
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_exit_menu;"
- << wide_to_utf8(wstrgettext("Exit to Menu")) << "]";
+ << strgettext("Exit to Menu") << "]";
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_exit_os;"
- << wide_to_utf8(wstrgettext("Exit to OS")) << "]"
+ << strgettext("Exit to OS") << "]"
<< "textarea[7.5,0.25;3.9,6.25;;" << control_text << ";]"
<< "textarea[0.4,0.25;3.5,6;;" << PROJECT_NAME_C "\n"
<< g_build_info << "\n"
diff --git a/src/gettext.h b/src/gettext.h
index 0170d1c45..cb3a14160 100644
--- a/src/gettext.h
+++ b/src/gettext.h
@@ -48,14 +48,6 @@ inline const wchar_t *wgettext(const char *str)
return utf8_to_wide_c(gettext(str));
}
-inline std::wstring wstrgettext(const std::string &text)
-{
- const wchar_t *tmp = wgettext(text.c_str());
- std::wstring retval = (std::wstring)tmp;
- delete[] tmp;
- return retval;
-}
-
inline std::string strgettext(const std::string &text)
{
return gettext(text.c_str());
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp
index 8478cf48a..c924a5d9c 100644
--- a/src/script/lua_api/l_mainmenu.cpp
+++ b/src/script/lua_api/l_mainmenu.cpp
@@ -1059,8 +1059,8 @@ int ModApiMainMenu::l_get_video_modes(lua_State *L)
/******************************************************************************/
int ModApiMainMenu::l_gettext(lua_State *L)
{
- std::wstring wtext = wstrgettext((std::string) luaL_checkstring(L, 1));
- lua_pushstring(L, wide_to_utf8(wtext).c_str());
+ std::string text = strgettext(std::string(luaL_checkstring(L, 1)));
+ lua_pushstring(L, text.c_str());
return 1;
}