Skip to content
Permalink
Browse files

Drop old text input workarounds (#11089)

* Drop unused intlGUIEditBox

* Drop unnecessary Linux text input workarounds
  • Loading branch information
sfan5 committed Mar 19, 2021
1 parent 285ba74 commit 96d4df995c1baf364217699cd43e5ab71918c9d8
@@ -23,7 +23,6 @@ set(gui_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/guiTable.cpp
${CMAKE_CURRENT_SOURCE_DIR}/guiHyperText.cpp
${CMAKE_CURRENT_SOURCE_DIR}/guiVolumeChange.cpp
${CMAKE_CURRENT_SOURCE_DIR}/intlGUIEditBox.cpp
${CMAKE_CURRENT_SOURCE_DIR}/modalMenu.cpp
${CMAKE_CURRENT_SOURCE_DIR}/profilergraph.cpp
PARENT_SCOPE
@@ -607,13 +607,7 @@ bool GUIChatConsole::OnEvent(const SEvent& event)
prompt.nickCompletion(names, backwards);
return true;
} else if (!iswcntrl(event.KeyInput.Char) && !event.KeyInput.Control) {
#if defined(__linux__) && (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 9)
wchar_t wc = L'_';
mbtowc( &wc, (char *) &event.KeyInput.Char, sizeof(event.KeyInput.Char) );
prompt.input(wc);
#else
prompt.input(event.KeyInput.Char);
#endif
prompt.input(event.KeyInput.Char);
return true;
}
}
@@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <IGUIButton.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
#include "intlGUIEditBox.h"
#include "guiEditBoxWithScrollbar.h"
#include "porting.h"

#include "gettext.h"
@@ -109,10 +109,9 @@ void GUIConfirmRegistration::regenerateGui(v2u32 screensize)
porting::mt_snprintf(info_text_buf, sizeof(info_text_buf),
info_text_template.c_str(), m_playername.c_str());

wchar_t *info_text_buf_wide = utf8_to_wide_c(info_text_buf);
gui::IGUIEditBox *e = new gui::intlGUIEditBox(info_text_buf_wide, true,
Environment, this, ID_intotext, rect2, false, true);
delete[] info_text_buf_wide;
std::wstring info_text_w = utf8_to_wide(info_text_buf);
gui::IGUIEditBox *e = new GUIEditBoxWithScrollBar(info_text_w.c_str(),
true, Environment, this, ID_intotext, rect2, false, true);
e->drop();
e->setMultiLine(true);
e->setWordWrap(true);
@@ -208,31 +208,10 @@ bool GUIEditBox::OnEvent(const SEvent &event)
}
}
break;
case EET_KEY_INPUT_EVENT: {
#if (defined(__linux__) || defined(__FreeBSD__)) || defined(__DragonFly__)
// ################################################################
// ValkaTR:
// This part is the difference from the original intlGUIEditBox
// It converts UTF-8 character into a UCS-2 (wchar_t)
wchar_t wc = L'_';
mbtowc(&wc, (char *)&event.KeyInput.Char,
sizeof(event.KeyInput.Char));

// printf( "char: %lc (%u) \r\n", wc, wc );

SEvent irrevent(event);
irrevent.KeyInput.Char = wc;
// ################################################################

if (processKey(irrevent))
return true;
#else
case EET_KEY_INPUT_EVENT:
if (processKey(event))
return true;
#endif // defined(linux)

break;
}
case EET_MOUSE_INPUT_EVENT:
if (processMouse(event))
return true;
@@ -65,7 +65,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "guiInventoryList.h"
#include "guiItemImage.h"
#include "guiScrollContainer.h"
#include "intlGUIEditBox.h"
#include "guiHyperText.h"
#include "guiScene.h"

@@ -1547,21 +1546,13 @@ void GUIFormSpecMenu::createTextField(parserData *data, FieldSpec &spec,
}

gui::IGUIEditBox *e = nullptr;
static constexpr bool use_intl_edit_box = USE_FREETYPE &&
IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 9;

if (use_intl_edit_box && g_settings->getBool("freetype")) {
e = new gui::intlGUIEditBox(spec.fdefault.c_str(), true, Environment,
data->current_parent, spec.fid, rect, is_editable, is_multiline);
} else {
if (is_multiline) {
e = new GUIEditBoxWithScrollBar(spec.fdefault.c_str(), true, Environment,
data->current_parent, spec.fid, rect, is_editable, true);
} else if (is_editable) {
e = Environment->addEditBox(spec.fdefault.c_str(), rect, true,
data->current_parent, spec.fid);
e->grab();
}
if (is_multiline) {
e = new GUIEditBoxWithScrollBar(spec.fdefault.c_str(), true, Environment,
data->current_parent, spec.fid, rect, is_editable, true);
} else if (is_editable) {
e = Environment->addEditBox(spec.fdefault.c_str(), rect, true,
data->current_parent, spec.fid);
e->grab();
}

auto style = getDefaultStyleForElement(is_multiline ? "textarea" : "field", spec.fname);

0 comments on commit 96d4df9

Please sign in to comment.