Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 96d4df9
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 745 deletions.
1 change: 0 additions & 1 deletion src/gui/CMakeLists.txt
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions src/gui/guiChatConsole.cpp
Expand Up @@ -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;
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/gui/guiConfirmRegistration.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down
23 changes: 1 addition & 22 deletions src/gui/guiEditBox.cpp
Expand Up @@ -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;
Expand Down
23 changes: 7 additions & 16 deletions src/gui/guiFormSpecMenu.cpp
Expand Up @@ -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"

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 96d4df9

Please sign in to comment.