summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/CMakeLists.txt1
-rw-r--r--src/gui/guiButton.cpp7
-rw-r--r--src/gui/guiButton.h35
-rw-r--r--src/gui/guiChatConsole.cpp8
-rw-r--r--src/gui/guiConfirmRegistration.cpp9
-rw-r--r--src/gui/guiEditBox.cpp23
-rw-r--r--src/gui/guiFormSpecMenu.cpp31
-rw-r--r--src/gui/guiKeyChangeMenu.cpp6
-rw-r--r--src/gui/guiScene.cpp15
-rw-r--r--src/gui/guiScene.h1
-rw-r--r--src/gui/intlGUIEditBox.cpp626
-rw-r--r--src/gui/intlGUIEditBox.h68
-rw-r--r--src/gui/touchscreengui.cpp18
-rw-r--r--src/gui/touchscreengui.h8
14 files changed, 77 insertions, 779 deletions
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index fdd36914a..5552cebea 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -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
diff --git a/src/gui/guiButton.cpp b/src/gui/guiButton.cpp
index b98e5de82..d6dbddf54 100644
--- a/src/gui/guiButton.cpp
+++ b/src/gui/guiButton.cpp
@@ -506,6 +506,13 @@ video::SColor GUIButton::getOverrideColor() const
return OverrideColor;
}
+#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR > 8
+video::SColor GUIButton::getActiveColor() const
+{
+ return video::SColor(0,0,0,0); // unused?
+}
+#endif
+
void GUIButton::enableOverrideColor(bool enable)
{
OverrideColorEnabled = enable;
diff --git a/src/gui/guiButton.h b/src/gui/guiButton.h
index 4e1b04aac..834405f51 100644
--- a/src/gui/guiButton.h
+++ b/src/gui/guiButton.h
@@ -69,6 +69,12 @@ using namespace irr;
class ISimpleTextureSource;
+#if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR <= 8)
+#define OVERRIDE_19
+#else
+#define OVERRIDE_19 override
+#endif
+
class GUIButton : public gui::IGUIButton
{
public:
@@ -97,22 +103,27 @@ public:
virtual gui::IGUIFont* getActiveFont() const override;
//! Sets another color for the button text.
- virtual void setOverrideColor(video::SColor color);
+ virtual void setOverrideColor(video::SColor color) OVERRIDE_19;
//! Gets the override color
- virtual video::SColor getOverrideColor(void) const;
+ virtual video::SColor getOverrideColor(void) const OVERRIDE_19;
+
+ #if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR > 8
+ //! Gets the currently used text color
+ virtual video::SColor getActiveColor() const override;
+ #endif
//! Sets if the button text should use the override color or the color in the gui skin.
- virtual void enableOverrideColor(bool enable);
+ virtual void enableOverrideColor(bool enable) OVERRIDE_19;
//! Checks if an override color is enabled
- virtual bool isOverrideColorEnabled(void) const;
+ virtual bool isOverrideColorEnabled(void) const OVERRIDE_19;
// PATCH
//! Sets an image which should be displayed on the button when it is in the given state.
virtual void setImage(gui::EGUI_BUTTON_IMAGE_STATE state,
video::ITexture* image=nullptr,
- const core::rect<s32>& sourceRect=core::rect<s32>(0,0,0,0));
+ const core::rect<s32>& sourceRect=core::rect<s32>(0,0,0,0)) OVERRIDE_19;
//! Sets an image which should be displayed on the button when it is in normal state.
virtual void setImage(video::ITexture* image=nullptr) override;
@@ -141,7 +152,7 @@ public:
*/
virtual void setSprite(gui::EGUI_BUTTON_STATE state, s32 index,
video::SColor color=video::SColor(255,255,255,255),
- bool loop=false, bool scale=false);
+ bool loop=false, bool scale=false) OVERRIDE_19;
#if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR <= 8)
void setSprite(gui::EGUI_BUTTON_STATE state, s32 index, video::SColor color, bool loop) override {
@@ -150,16 +161,16 @@ public:
#endif
//! Get the sprite-index for the given state or -1 when no sprite is set
- virtual s32 getSpriteIndex(gui::EGUI_BUTTON_STATE state) const;
+ virtual s32 getSpriteIndex(gui::EGUI_BUTTON_STATE state) const OVERRIDE_19;
//! Get the sprite color for the given state. Color is only used when a sprite is set.
- virtual video::SColor getSpriteColor(gui::EGUI_BUTTON_STATE state) const;
+ virtual video::SColor getSpriteColor(gui::EGUI_BUTTON_STATE state) const OVERRIDE_19;
//! Returns if the sprite in the given state does loop
- virtual bool getSpriteLoop(gui::EGUI_BUTTON_STATE state) const;
+ virtual bool getSpriteLoop(gui::EGUI_BUTTON_STATE state) const OVERRIDE_19;
//! Returns if the sprite in the given state is scaled
- virtual bool getSpriteScale(gui::EGUI_BUTTON_STATE state) const;
+ virtual bool getSpriteScale(gui::EGUI_BUTTON_STATE state) const OVERRIDE_19;
//! Sets if the button should behave like a push button. Which means it
//! can be in two states: Normal or Pressed. With a click on the button,
@@ -199,13 +210,13 @@ public:
virtual bool isScalingImage() const override;
//! Get if the shift key was pressed in last EGET_BUTTON_CLICKED event
- virtual bool getClickShiftState() const
+ virtual bool getClickShiftState() const OVERRIDE_19
{
return ClickShiftState;
}
//! Get if the control key was pressed in last EGET_BUTTON_CLICKED event
- virtual bool getClickControlState() const
+ virtual bool getClickControlState() const OVERRIDE_19
{
return ClickControlState;
}
diff --git a/src/gui/guiChatConsole.cpp b/src/gui/guiChatConsole.cpp
index 6330d95d4..fd92cf298 100644
--- a/src/gui/guiChatConsole.cpp
+++ b/src/gui/guiChatConsole.cpp
@@ -635,13 +635,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;
}
}
diff --git a/src/gui/guiConfirmRegistration.cpp b/src/gui/guiConfirmRegistration.cpp
index 4a798c39b..4ca9a64ed 100644
--- a/src/gui/guiConfirmRegistration.cpp
+++ b/src/gui/guiConfirmRegistration.cpp
@@ -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);
diff --git a/src/gui/guiEditBox.cpp b/src/gui/guiEditBox.cpp
index 79979dbc3..cd5a0868d 100644
--- a/src/gui/guiEditBox.cpp
+++ b/src/gui/guiEditBox.cpp
@@ -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;
diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp
index 5aa6dc9ae..fd35f2d84 100644
--- a/src/gui/guiFormSpecMenu.cpp
+++ b/src/gui/guiFormSpecMenu.cpp
@@ -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);
@@ -2746,7 +2737,7 @@ void GUIFormSpecMenu::parseModel(parserData *data, const std::string &element)
{
std::vector<std::string> parts = split(element, ';');
- if (parts.size() < 5 || (parts.size() > 9 &&
+ if (parts.size() < 5 || (parts.size() > 10 &&
m_formspec_version <= FORMSPEC_API_VERSION)) {
errorstream << "Invalid model element (" << parts.size() << "): '" << element
<< "'" << std::endl;
@@ -2754,8 +2745,8 @@ void GUIFormSpecMenu::parseModel(parserData *data, const std::string &element)
}
// Avoid length checks by resizing
- if (parts.size() < 9)
- parts.resize(9);
+ if (parts.size() < 10)
+ parts.resize(10);
std::vector<std::string> v_pos = split(parts[0], ',');
std::vector<std::string> v_geom = split(parts[1], ',');
@@ -2766,6 +2757,7 @@ void GUIFormSpecMenu::parseModel(parserData *data, const std::string &element)
bool inf_rotation = is_yes(parts[6]);
bool mousectrl = is_yes(parts[7]) || parts[7].empty(); // default true
std::vector<std::string> frame_loop = split(parts[8], ',');
+ std::string speed = unescape_string(parts[9]);
MY_CHECKPOS("model", 0);
MY_CHECKGEOM("model", 1);
@@ -2825,6 +2817,7 @@ void GUIFormSpecMenu::parseModel(parserData *data, const std::string &element)
}
e->setFrameLoop(frame_loop_begin, frame_loop_end);
+ e->setAnimationSpeed(stof(speed));
auto style = getStyleForElement("model", spec.fname);
e->setStyles(style);
diff --git a/src/gui/guiKeyChangeMenu.cpp b/src/gui/guiKeyChangeMenu.cpp
index 4dcb47779..84678b629 100644
--- a/src/gui/guiKeyChangeMenu.cpp
+++ b/src/gui/guiKeyChangeMenu.cpp
@@ -46,7 +46,7 @@ enum
GUI_ID_KEY_BACKWARD_BUTTON,
GUI_ID_KEY_LEFT_BUTTON,
GUI_ID_KEY_RIGHT_BUTTON,
- GUI_ID_KEY_USE_BUTTON,
+ GUI_ID_KEY_AUX1_BUTTON,
GUI_ID_KEY_FLY_BUTTON,
GUI_ID_KEY_FAST_BUTTON,
GUI_ID_KEY_JUMP_BUTTON,
@@ -177,7 +177,7 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
{
core::rect<s32> rect(0, 0, option_w, 30 * s);
rect += topleft + v2s32(option_x, option_y);
- const wchar_t *text = wgettext("\"Special\" = climb down");
+ const wchar_t *text = wgettext("\"Aux1\" = climb down");
Environment->addCheckBox(g_settings->getBool("aux1_descends"), rect, this,
GUI_ID_CB_AUX1_DESCENDS, text);
delete[] text;
@@ -416,7 +416,7 @@ void GUIKeyChangeMenu::init_keys()
this->add_key(GUI_ID_KEY_BACKWARD_BUTTON, wgettext("Backward"), "keymap_backward");
this->add_key(GUI_ID_KEY_LEFT_BUTTON, wgettext("Left"), "keymap_left");
this->add_key(GUI_ID_KEY_RIGHT_BUTTON, wgettext("Right"), "keymap_right");
- this->add_key(GUI_ID_KEY_USE_BUTTON, wgettext("Special"), "keymap_special1");
+ this->add_key(GUI_ID_KEY_AUX1_BUTTON, wgettext("Aux1"), "keymap_aux1");
this->add_key(GUI_ID_KEY_JUMP_BUTTON, wgettext("Jump"), "keymap_jump");
this->add_key(GUI_ID_KEY_SNEAK_BUTTON, wgettext("Sneak"), "keymap_sneak");
this->add_key(GUI_ID_KEY_DROP_BUTTON, wgettext("Drop"), "keymap_drop");
diff --git a/src/gui/guiScene.cpp b/src/gui/guiScene.cpp
index 5f4c50b91..f0cfbec5e 100644
--- a/src/gui/guiScene.cpp
+++ b/src/gui/guiScene.cpp
@@ -34,9 +34,6 @@ GUIScene::GUIScene(gui::IGUIEnvironment *env, scene::ISceneManager *smgr,
m_cam = m_smgr->addCameraSceneNode(0, v3f(0.f, 0.f, -100.f), v3f(0.f));
m_cam->setFOV(30.f * core::DEGTORAD);
- scene::ILightSceneNode *light = m_smgr->addLightSceneNode(m_cam);
- light->setRadius(1000.f);
-
m_smgr->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
}
@@ -60,6 +57,7 @@ scene::IAnimatedMeshSceneNode *GUIScene::setMesh(scene::IAnimatedMesh *mesh)
m_mesh = m_smgr->addAnimatedMeshSceneNode(mesh);
m_mesh->setPosition(-m_mesh->getBoundingBox().getCenter());
m_mesh->animateJoints();
+
return m_mesh;
}
@@ -73,10 +71,13 @@ void GUIScene::setTexture(u32 idx, video::ITexture *texture)
material.setFlag(video::EMF_FOG_ENABLE, true);
material.setFlag(video::EMF_BILINEAR_FILTER, false);
material.setFlag(video::EMF_BACK_FACE_CULLING, false);
+ material.setFlag(video::EMF_ZWRITE_ENABLE, true);
}
void GUIScene::draw()
{
+ m_driver->clearBuffers(video::ECBF_DEPTH);
+
// Control rotation speed based on time
u64 new_time = porting::getTimeMs();
u64 dtime_ms = 0;
@@ -161,6 +162,14 @@ void GUIScene::setFrameLoop(s32 begin, s32 end)
m_mesh->setFrameLoop(begin, end);
}
+/**
+ * Sets the animation speed (FPS) for the mesh
+ */
+void GUIScene::setAnimationSpeed(f32 speed)
+{
+ m_mesh->setAnimationSpeed(speed);
+}
+
/* Camera control functions */
inline void GUIScene::calcOptimalDistance()
diff --git a/src/gui/guiScene.h b/src/gui/guiScene.h
index 08eb7f350..0f5f3a891 100644
--- a/src/gui/guiScene.h
+++ b/src/gui/guiScene.h
@@ -37,6 +37,7 @@ public:
void setTexture(u32 idx, video::ITexture *texture);
void setBackgroundColor(const video::SColor &color) noexcept { m_bgcolor = color; };
void setFrameLoop(s32 begin, s32 end);
+ void setAnimationSpeed(f32 speed);
void enableMouseControl(bool enable) noexcept { m_mouse_ctrl = enable; };
void setRotation(v2f rot) noexcept { m_custom_rot = rot; };
void enableContinuousRotation(bool enable) noexcept { m_inf_rot = enable; };
diff --git a/src/gui/intlGUIEditBox.cpp b/src/gui/intlGUIEditBox.cpp
deleted file mode 100644
index 0f09ea746..000000000
--- a/src/gui/intlGUIEditBox.cpp
+++ /dev/null
@@ -1,626 +0,0 @@
-// 11.11.2011 11:11 ValkaTR
-//
-// This is a copy of intlGUIEditBox from the irrlicht, but with a
-// fix in the OnEvent function, which doesn't allowed input of
-// other keyboard layouts than latin-1
-//
-// Characters like: ä ö ü õ ы й ю я ъ № € ° ...
-//
-// This fix is only needed for linux, because of a bug
-// in the CIrrDeviceLinux.cpp:1014-1015 of the irrlicht
-//
-// Also locale in the programm should not be changed to
-// a "C", "POSIX" or whatever, it should be set to "",
-// or XLookupString will return nothing for the international
-// characters.
-//
-// From the "man setlocale":
-//
-// On startup of the main program, the portable "C" locale
-// is selected as default. A program may be made
-// portable to all locales by calling:
-//
-// setlocale(LC_ALL, "");
-//
-// after program initialization....
-//
-
-// Copyright (C) 2002-2013 Nikolaus Gebhardt
-// This file is part of the "Irrlicht Engine".
-// For conditions of distribution and use, see copyright notice in irrlicht.h
-
-#include <util/numeric.h>
-#include "intlGUIEditBox.h"
-
-#include "IGUISkin.h"
-#include "IGUIEnvironment.h"
-#include "IGUIFont.h"
-#include "IVideoDriver.h"
-//#include "irrlicht/os.cpp"
-#include "porting.h"
-//#include "Keycodes.h"
-#include "log.h"
-
-/*
- todo:
- optional scrollbars
- ctrl+left/right to select word
- double click/ctrl click: word select + drag to select whole words, triple click to select line
- optional? dragging selected text
- numerical
-*/
-
-namespace irr
-{
-namespace gui
-{
-
-//! constructor
-intlGUIEditBox::intlGUIEditBox(const wchar_t* text, bool border,
- IGUIEnvironment* environment, IGUIElement* parent, s32 id,
- const core::rect<s32>& rectangle, bool writable, bool has_vscrollbar)
- : GUIEditBox(environment, parent, id, rectangle, border, writable)
-{
- #ifdef _DEBUG
- setDebugName("intlintlGUIEditBox");
- #endif
-
- Text = text;
-
- if (Environment)
- m_operator = Environment->getOSOperator();
-
- if (m_operator)
- m_operator->grab();
-
- // this element can be tabbed to
- setTabStop(true);
- setTabOrder(-1);
-
- IGUISkin *skin = 0;
- if (Environment)
- skin = Environment->getSkin();
- if (m_border && skin)
- {
- m_frame_rect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X)+1;
- m_frame_rect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y)+1;
- m_frame_rect.LowerRightCorner.X -= skin->getSize(EGDS_TEXT_DISTANCE_X)+1;
- m_frame_rect.LowerRightCorner.Y -= skin->getSize(EGDS_TEXT_DISTANCE_Y)+1;
- }
-
- if (skin && has_vscrollbar) {
- m_scrollbar_width = skin->getSize(gui::EGDS_SCROLLBAR_SIZE);
-
- if (m_scrollbar_width > 0) {
- createVScrollBar();
- }
- }
-
- breakText();
-
- calculateScrollPos();
- setWritable(writable);
-}
-
-//! Sets whether to draw the background
-void intlGUIEditBox::setDrawBackground(bool draw)
-{
-}
-
-void intlGUIEditBox::updateAbsolutePosition()
-{
- core::rect<s32> oldAbsoluteRect(AbsoluteRect);
- IGUIElement::updateAbsolutePosition();
- if ( oldAbsoluteRect != AbsoluteRect )
- {
- breakText();
- }
-}
-
-
-//! draws the element and its children
-void intlGUIEditBox::draw()
-{
- if (!IsVisible)
- return;
-
- const bool focus = Environment->hasFocus(this);
-
- IGUISkin* skin = Environment->getSkin();
- if (!skin)
- return;
-
- m_frame_rect = AbsoluteRect;
-
- // draw the border
-
- if (m_border)
- {
- if (m_writable) {
- skin->draw3DSunkenPane(this, skin->getColor(EGDC_WINDOW),
- false, true, m_frame_rect, &AbsoluteClippingRect);
- }
-
- m_frame_rect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X)+1;
- m_frame_rect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y)+1;
- m_frame_rect.LowerRightCorner.X -= skin->getSize(EGDS_TEXT_DISTANCE_X)+1;
- m_frame_rect.LowerRightCorner.Y -= skin->getSize(EGDS_TEXT_DISTANCE_Y)+1;
- }
-
- updateVScrollBar();
- core::rect<s32> localClipRect = m_frame_rect;
- localClipRect.clipAgainst(AbsoluteClippingRect);
-
- // draw the text
-
- IGUIFont* font = m_override_font;
- if (!m_override_font)
- font = skin->getFont();
-
- s32 cursorLine = 0;
- s32 charcursorpos = 0;
-
- if (font)
- {
- if (m_last_break_font != font)
- {
- breakText();
- }
-
- // calculate cursor pos
-
- core::stringw *txtLine = &Text;
- s32 startPos = 0;
-
- core::stringw s, s2;
-
- // get mark position
- const bool ml = (!m_passwordbox && (m_word_wrap || m_multiline));
- const s32 realmbgn = m_mark_begin < m_mark_end ? m_mark_begin : m_mark_end;
- const s32 realmend = m_mark_begin < m_mark_end ? m_mark_end : m_mark_begin;
- const s32 hlineStart = ml ? getLineFromPos(realmbgn) : 0;
- const s32 hlineCount = ml ? getLineFromPos(realmend) - hlineStart + 1 : 1;
- const s32 lineCount = ml ? m_broken_text.size() : 1;
-
- // Save the override color information.
- // Then, alter it if the edit box is disabled.
- const bool prevOver = m_override_color_enabled;
- const video::SColor prevColor = m_override_color;
-
- if (!Text.empty()) {
- if (!IsEnabled && !m_override_color_enabled)
- {
- m_override_color_enabled = true;
- m_override_color = skin->getColor(EGDC_GRAY_TEXT);
- }
-
- for (s32 i=0; i < lineCount; ++i)
- {
- setTextRect(i);
-
- // clipping test - don't draw anything outside the visible area
- core::rect<s32> c = localClipRect;
- c.clipAgainst(m_current_text_rect);
- if (!c.isValid())
- continue;
-
- // get current line
- if (m_passwordbox)
- {
- if (m_broken_text.size() != 1)
- {
- m_broken_text.clear();
- m_broken_text.emplace_back();
- }
- if (m_broken_text[0].size() != Text.size())
- {
- m_broken_text[0] = Text;
- for (u32 q = 0; q < Text.size(); ++q)
- {
- m_broken_text[0] [q] = m_passwordchar;
- }
- }
- txtLine = &m_broken_text[0];
- startPos = 0;
- }
- else
- {
- txtLine = ml ? &m_broken_text[i] : &Text;
- startPos = ml ? m_broken_text_positions[i] : 0;
- }
-
-
- // draw normal text
- font->draw(txtLine->c_str(), m_current_text_rect,
- m_override_color_enabled ? m_override_color : skin->getColor(EGDC_BUTTON_TEXT),
- false, true, &localClipRect);
-
- // draw mark and marked text
- if (focus && m_mark_begin != m_mark_end && i >= hlineStart && i < hlineStart + hlineCount)
- {
-
- s32 mbegin = 0, mend = 0;
- s32 lineStartPos = 0, lineEndPos = txtLine->size();
-
- if (i == hlineStart)
- {
- // highlight start is on this line
- s = txtLine->subString(0, realmbgn - startPos);
- mbegin = font->getDimension(s.c_str()).Width;
-
- // deal with kerning
- mbegin += font->getKerningWidth(
- &((*txtLine)[realmbgn - startPos]),
- realmbgn - startPos > 0 ? &((*txtLine)[realmbgn - startPos - 1]) : 0);
-
- lineStartPos = realmbgn - startPos;
- }
- if (i == hlineStart + hlineCount - 1)
- {
- // highlight end is on this line
- s2 = txtLine->subString(0, realmend - startPos);
- mend = font->getDimension(s2.c_str()).Width;
- lineEndPos = (s32)s2.size();
- }
- else
- mend = font->getDimension(txtLine->c_str()).Width;
-
- m_current_text_rect.UpperLeftCorner.X += mbegin;
- m_current_text_rect.LowerRightCorner.X = m_current_text_rect.UpperLeftCorner.X + mend - mbegin;
-
- // draw mark
- skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), m_current_text_rect, &localClipRect);
-
- // draw marked text
- s = txtLine->subString(lineStartPos, lineEndPos - lineStartPos);
-
- if (!s.empty())
- font->draw(s.c_str(), m_current_text_rect,
- m_override_color_enabled ? m_override_color : skin->getColor(EGDC_HIGH_LIGHT_TEXT),
- false, true, &localClipRect);
-
- }
- }
-
- // Return the override color information to its previous settings.
- m_override_color_enabled = prevOver;
- m_override_color = prevColor;
- }
-
- // draw cursor
-
- if (m_word_wrap || m_multiline)
- {
- cursorLine = getLineFromPos(m_cursor_pos);
- txtLine = &m_broken_text[cursorLine];
- startPos = m_broken_text_positions[cursorLine];
- }
- s = txtLine->subString(0,m_cursor_pos-startPos);
- charcursorpos = font->getDimension(s.c_str()).Width +
- font->getKerningWidth(L"_", m_cursor_pos-startPos > 0 ? &((*txtLine)[m_cursor_pos-startPos-1]) : 0);
-
- if (m_writable) {
- if (focus && (porting::getTimeMs() - m_blink_start_time) % 700 < 350) {
- setTextRect(cursorLine);
- m_current_text_rect.UpperLeftCorner.X += charcursorpos;
-
- font->draw(L"_", m_current_text_rect,
- m_override_color_enabled ? m_override_color : skin->getColor(EGDC_BUTTON_TEXT),
- false, true, &localClipRect);
- }
- }
- }
-
- // draw children
- IGUIElement::draw();
-}
-
-
-s32 intlGUIEditBox::getCursorPos(s32 x, s32 y)
-{
- IGUIFont* font = getActiveFont();
-
- const u32 lineCount = (m_word_wrap || m_multiline) ? m_broken_text.size() : 1;
-
- core::stringw *txtLine = NULL;
- s32 startPos = 0;
- u32 curr_line_idx = 0;
- x += 3;
-
- for (; curr_line_idx < lineCount; ++curr_line_idx) {
- setTextRect(curr_line_idx);
- if (curr_line_idx == 0 && y < m_current_text_rect.UpperLeftCorner.Y)
- y = m_current_text_rect.UpperLeftCorner.Y;
- if (curr_line_idx == lineCount - 1 && y > m_current_text_rect.LowerRightCorner.Y)
- y = m_current_text_rect.LowerRightCorner.Y;
-
- // is it inside this region?
- if (y >= m_current_text_rect.UpperLeftCorner.Y && y <= m_current_text_rect.LowerRightCorner.Y) {
- // we've found the clicked line
- txtLine = (m_word_wrap || m_multiline) ? &m_broken_text[curr_line_idx] : &Text;
- startPos = (m_word_wrap || m_multiline) ? m_broken_text_positions[curr_line_idx] : 0;
- break;
- }
- }
-
- if (x < m_current_text_rect.UpperLeftCorner.X)
- x = m_current_text_rect.UpperLeftCorner.X;
- else if (x > m_current_text_rect.LowerRightCorner.X)
- x = m_current_text_rect.LowerRightCorner.X;
-
- s32 idx = font->getCharacterFromPos(txtLine->c_str(), x - m_current_text_rect.UpperLeftCorner.X);
- // Special handling for last line, if we are on limits, add 1 extra shift because idx
- // will be the last char, not null char of the wstring
- if (curr_line_idx == lineCount - 1 && x == m_current_text_rect.LowerRightCorner.X)
- idx++;
-
- return rangelim(idx + startPos, 0, S32_MAX);
-}
-
-
-//! Breaks the single text line.
-void intlGUIEditBox::breakText()
-{
- IGUISkin* skin = Environment->getSkin();
-
- if ((!m_word_wrap && !m_multiline) || !skin)
- return;
-
- m_broken_text.clear(); // need to reallocate :/
- m_broken_text_positions.clear();
-
- IGUIFont* font = m_override_font;
- if (!m_override_font)
- font = skin->getFont();
-
- if (!font)
- return;
-
- m_last_break_font = font;
-
- core::stringw line;
- core::stringw word;
- core::stringw whitespace;
- s32 lastLineStart = 0;
- s32 size = Text.size();
- s32 length = 0;
- s32 elWidth = RelativeRect.getWidth() - m_scrollbar_width - 10;
- wchar_t c;
-
- for (s32 i=0; i<size; ++i)
- {
- c = Text[i];
- bool lineBreak = false;
-
- if (c == L'\r') // Mac or Windows breaks
- {
- lineBreak = true;
- c = ' ';
- if (Text[i+1] == L'\n') // Windows breaks
- {
- Text.erase(i+1);
- --size;
- }
- }
- else if (c == L'\n') // Unix breaks
- {
- lineBreak = true;
- c = ' ';
- }
-
- // don't break if we're not a multi-line edit box
- if (!m_multiline)
- lineBreak = false;
-
- if (c == L' ' || c == 0 || i == (size-1))
- {
- if (!word.empty()) {
- // here comes the next whitespace, look if
- // we can break the last word to the next line.
- s32 whitelgth = font->getDimension(whitespace.c_str()).Width;
- s32 worldlgth = font->getDimension(word.c_str()).Width;
-
- if (m_word_wrap && length + worldlgth + whitelgth > elWidth)
- {
- // break to next line
- length = worldlgth;
- m_broken_text.push_back(line);
- m_broken_text_positions.push_back(lastLineStart);
- lastLineStart = i - (s32)word.size();
- line = word;
- }
- else
- {
- // add word to line
- line += whitespace;
- line += word;
- length += whitelgth + worldlgth;
- }
-
- word = L"";
- whitespace = L"";
- }
-
- whitespace += c;
-
- // compute line break
- if (lineBreak)
- {
- line += whitespace;
- line += word;
- m_broken_text.push_back(line);
- m_broken_text_positions.push_back(lastLineStart);
- lastLineStart = i+1;
- line = L"";
- word = L"";
- whitespace = L"";
- length = 0;
- }
- }
- else
- {
- // yippee this is a word..
- word += c;
- }
- }
-
- line += whitespace;
- line += word;
- m_broken_text.push_back(line);
- m_broken_text_positions.push_back(lastLineStart);
-}
-
-
-void intlGUIEditBox::setTextRect(s32 line)
-{
- core::dimension2du d;
-
- IGUISkin* skin = Environment->getSkin();
- if (!skin)
- return;
-
- IGUIFont* font = m_override_font ? m_override_font : skin->getFont();
-
- if (!font)
- return;
-
- // get text dimension
- const u32 lineCount = (m_word_wrap || m_multiline) ? m_broken_text.size() : 1;
- if (m_word_wrap || m_multiline)
- {
- d = font->getDimension(m_broken_text[line].c_str());
- }
- else
- {
- d = font->getDimension(Text.c_str());
- d.Height = AbsoluteRect.getHeight();
- }
- d.Height += font->getKerningHeight();
-
- // justification
- switch (m_halign)
- {
- case EGUIA_CENTER:
- // align to h centre
- m_current_text_rect.UpperLeftCorner.X = (m_frame_rect.getWidth()/2) - (d.Width/2);
- m_current_text_rect.LowerRightCorner.X = (m_frame_rect.getWidth()/2) + (d.Width/2);
- break;
- case EGUIA_LOWERRIGHT:
- // align to right edge
- m_current_text_rect.UpperLeftCorner.X = m_frame_rect.getWidth() - d.Width;
- m_current_text_rect.LowerRightCorner.X = m_frame_rect.getWidth();
- break;
- default:
- // align to left edge
- m_current_text_rect.UpperLeftCorner.X = 0;
- m_current_text_rect.LowerRightCorner.X = d.Width;
-
- }
-
- switch (m_valign)
- {
- case EGUIA_CENTER:
- // align to v centre
- m_current_text_rect.UpperLeftCorner.Y =
- (m_frame_rect.getHeight()/2) - (lineCount*d.Height)/2 + d.Height*line;
- break;
- case EGUIA_LOWERRIGHT:
- // align to bottom edge
- m_current_text_rect.UpperLeftCorner.Y =
- m_frame_rect.getHeight() - lineCount*d.Height + d.Height*line;
- break;
- default:
- // align to top edge
- m_current_text_rect.UpperLeftCorner.Y = d.Height*line;
- break;
- }
-
- m_current_text_rect.UpperLeftCorner.X -= m_hscroll_pos;
- m_current_text_rect.LowerRightCorner.X -= m_hscroll_pos;
- m_current_text_rect.UpperLeftCorner.Y -= m_vscroll_pos;
- m_current_text_rect.LowerRightCorner.Y = m_current_text_rect.UpperLeftCorner.Y + d.Height;
-
- m_current_text_rect += m_frame_rect.UpperLeftCorner;
-
-}
-
-void intlGUIEditBox::calculateScrollPos()
-{
- if (!m_autoscroll)
- return;
-
- // calculate horizontal scroll position
- s32 cursLine = getLineFromPos(m_cursor_pos);
- setTextRect(cursLine);
-
- // don't do horizontal scrolling when wordwrap is enabled.
- if (!m_word_wrap)
- {
- // get cursor position
- IGUISkin* skin = Environment->getSkin();
- if (!skin)
- return;
- IGUIFont* font = m_override_font ? m_override_font : skin->getFont();
- if (!font)
- return;
-
- core::stringw *txtLine = m_multiline ? &m_broken_text[cursLine] : &Text;
- s32 cPos = m_multiline ? m_cursor_pos - m_broken_text_positions[cursLine] : m_cursor_pos;
-
- s32 cStart = m_current_text_rect.UpperLeftCorner.X + m_hscroll_pos +
- font->getDimension(txtLine->subString(0, cPos).c_str()).Width;
-
- s32 cEnd = cStart + font->getDimension(L"_ ").Width;
-
- if (m_frame_rect.LowerRightCorner.X < cEnd)
- m_hscroll_pos = cEnd - m_frame_rect.LowerRightCorner.X;
- else if (m_frame_rect.UpperLeftCorner.X > cStart)
- m_hscroll_pos = cStart - m_frame_rect.UpperLeftCorner.X;
- else
- m_hscroll_pos = 0;
-
- // todo: adjust scrollbar
- }
-
- if (!m_word_wrap && !m_multiline)
- return;
-
- // vertical scroll position
- if (m_frame_rect.LowerRightCorner.Y < m_current_text_rect.LowerRightCorner.Y)
- m_vscroll_pos += m_current_text_rect.LowerRightCorner.Y - m_frame_rect.LowerRightCorner.Y; // scrolling downwards
- else if (m_frame_rect.UpperLeftCorner.Y > m_current_text_rect.UpperLeftCorner.Y)
- m_vscroll_pos += m_current_text_rect.UpperLeftCorner.Y - m_frame_rect.UpperLeftCorner.Y; // scrolling upwards
-
- // todo: adjust scrollbar
- if (m_vscrollbar)
- m_vscrollbar->setPos(m_vscroll_pos);
-}
-
-
-//! Create a vertical scrollbar
-void intlGUIEditBox::createVScrollBar()
-{
- s32 fontHeight = 1;
-
- if (m_override_font) {
- fontHeight = m_override_font->getDimension(L"").Height;
- } else {
- if (IGUISkin* skin = Environment->getSkin()) {
- if (IGUIFont* font = skin->getFont()) {
- fontHeight = font->getDimension(L"").Height;
- }
- }
- }
-
- irr::core::rect<s32> scrollbarrect = m_frame_rect;
- scrollbarrect.UpperLeftCorner.X += m_frame_rect.getWidth() - m_scrollbar_width;
- m_vscrollbar = new GUIScrollBar(Environment, getParent(), -1,
- scrollbarrect, false, true);
-
- m_vscrollbar->setVisible(false);
- m_vscrollbar->setSmallStep(3 * fontHeight);
- m_vscrollbar->setLargeStep(10 * fontHeight);
-}
-
-} // end namespace gui
-} // end namespace irr
diff --git a/src/gui/intlGUIEditBox.h b/src/gui/intlGUIEditBox.h
deleted file mode 100644
index 007fe1c93..000000000
--- a/src/gui/intlGUIEditBox.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (C) 2002-2013 Nikolaus Gebhardt
-// This file is part of the "Irrlicht Engine".
-// For conditions of distribution and use, see copyright notice in irrlicht.h
-
-#pragma once
-
-#include "IrrCompileConfig.h"
-//#ifdef _IRR_COMPILE_WITH_GUI_
-
-#include "guiEditBox.h"
-#include "irrArray.h"
-#include "IOSOperator.h"
-
-namespace irr
-{
-namespace gui
-{
- class intlGUIEditBox : public GUIEditBox
- {
- public:
-
- //! constructor
- intlGUIEditBox(const wchar_t* text, bool border, IGUIEnvironment* environment,
- IGUIElement* parent, s32 id, const core::rect<s32>& rectangle,
- bool writable = true, bool has_vscrollbar = false);
-
- //! destructor
- virtual ~intlGUIEditBox() {}
-
- //! Sets whether to draw the background
- virtual void setDrawBackground(bool draw);
-
- virtual bool isDrawBackgroundEnabled() const { return true; }
-
- //! draws the element and its children
- virtual void draw();
-
- //! Updates the absolute position, splits text if required
- virtual void updateAbsolutePosition();
-
- virtual void setCursorChar(const wchar_t cursorChar) {}
-
- virtual wchar_t getCursorChar() const { return L'|'; }
-
- virtual void setCursorBlinkTime(u32 timeMs) {}
-
- virtual u32 getCursorBlinkTime() const { return 500; }
-
- protected:
- //! Breaks the single text line.
- virtual void breakText();
- //! sets the area of the given line
- virtual void setTextRect(s32 line);
-
- //! calculates the current scroll position
- void calculateScrollPos();
-
- s32 getCursorPos(s32 x, s32 y);
-
- //! Create a vertical scrollbar
- void createVScrollBar();
- };
-
-
-} // end namespace gui
-} // end namespace irr
-
-//#endif // _IRR_COMPILE_WITH_GUI_
diff --git a/src/gui/touchscreengui.cpp b/src/gui/touchscreengui.cpp
index e1a971462..78b18c2d9 100644
--- a/src/gui/touchscreengui.cpp
+++ b/src/gui/touchscreengui.cpp
@@ -40,7 +40,7 @@ const char **button_imagenames = (const char *[]) {
"jump_btn.png",
"down.png",
"zoom.png",
- "aux_btn.png"
+ "aux1_btn.png"
};
const char **joystick_imagenames = (const char *[]) {
@@ -80,8 +80,8 @@ static irr::EKEY_CODE id2keycode(touch_gui_button_id id)
case zoom_id:
key = "zoom";
break;
- case special1_id:
- key = "special1";
+ case aux1_id:
+ key = "aux1";
break;
case fly_id:
key = "freemove";
@@ -425,7 +425,7 @@ TouchScreenGUI::TouchScreenGUI(IrrlichtDevice *device, IEventReceiver *receiver)
m_touchscreen_threshold = g_settings->getU16("touchscreen_threshold");
m_fixed_joystick = g_settings->getBool("fixed_virtual_joystick");
- m_joystick_triggers_special1 = g_settings->getBool("virtual_joystick_triggers_aux");
+ m_joystick_triggers_aux1 = g_settings->getBool("virtual_joystick_triggers_aux1");
m_screensize = m_device->getVideoDriver()->getScreenSize();
button_size = MYMIN(m_screensize.Y / 4.5f,
porting::getDisplayDensity() *
@@ -521,9 +521,9 @@ void TouchScreenGUI::init(ISimpleTextureSource *tsrc)
m_screensize.Y - (3 * button_size)),
L"z", false);
- // init special1/aux button
- if (!m_joystick_triggers_special1)
- initButton(special1_id,
+ // init aux1 button
+ if (!m_joystick_triggers_aux1)
+ initButton(aux1_id,
rect<s32>(m_screensize.X - (1.25 * button_size),
m_screensize.Y - (2.5 * button_size),
m_screensize.X - (0.25 * button_size),
@@ -923,7 +923,7 @@ void TouchScreenGUI::translateEvent(const SEvent &event)
}
if (distance > button_size) {
- m_joystick_status[j_special1] = true;
+ m_joystick_status[j_aux1] = true;
// move joystick "button"
s32 ndx = button_size * dx / distance - button_size / 2.0f;
s32 ndy = button_size * dy / distance - button_size / 2.0f;
@@ -1039,7 +1039,7 @@ bool TouchScreenGUI::doubleTapDetection()
void TouchScreenGUI::applyJoystickStatus()
{
for (unsigned int i = 0; i < 5; i++) {
- if (i == 4 && !m_joystick_triggers_special1)
+ if (i == 4 && !m_joystick_triggers_aux1)
continue;
SEvent translated{};
diff --git a/src/gui/touchscreengui.h b/src/gui/touchscreengui.h
index 0349624fa..ad5abae87 100644
--- a/src/gui/touchscreengui.h
+++ b/src/gui/touchscreengui.h
@@ -39,7 +39,7 @@ typedef enum
jump_id = 0,
crunch_id,
zoom_id,
- special1_id,
+ aux1_id,
after_last_element_id,
settings_starter_id,
rare_controls_starter_id,
@@ -69,7 +69,7 @@ typedef enum
j_backward,
j_left,
j_right,
- j_special1
+ j_aux1
} touch_gui_joystick_move_id;
typedef enum
@@ -217,7 +217,7 @@ private:
// forward, backward, left, right
touch_gui_button_id m_joystick_names[5] = {
- forward_id, backward_id, left_id, right_id, special1_id};
+ forward_id, backward_id, left_id, right_id, aux1_id};
bool m_joystick_status[5] = {false, false, false, false, false};
/*
@@ -237,7 +237,7 @@ private:
int m_joystick_id = -1;
bool m_joystick_has_really_moved = false;
bool m_fixed_joystick = false;
- bool m_joystick_triggers_special1 = false;
+ bool m_joystick_triggers_aux1 = false;
button_info *m_joystick_btn_off = nullptr;
button_info *m_joystick_btn_bg = nullptr;
button_info *m_joystick_btn_center = nullptr;