From 4c76239818f5159314f30883f98b977d30aaa26c Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Fri, 22 Jan 2021 15:09:26 +0000 Subject: Remove dead code (#10845) --- src/gui/guiFormSpecMenu.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/gui/guiFormSpecMenu.cpp') diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index 973fc60a8..4415bdd3a 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -3505,8 +3505,6 @@ bool GUIFormSpecMenu::getAndroidUIInput() GUIInventoryList::ItemSpec GUIFormSpecMenu::getItemAtPos(v2s32 p) const { - core::rect imgrect(0, 0, imgsize.X, imgsize.Y); - for (const GUIInventoryList *e : m_inventorylists) { s32 item_index = e->getItemIndexAtPos(p); if (item_index != -1) @@ -3837,7 +3835,7 @@ ItemStack GUIFormSpecMenu::verifySelectedItem() return ItemStack(); } -void GUIFormSpecMenu::acceptInput(FormspecQuitMode quitmode=quit_mode_no) +void GUIFormSpecMenu::acceptInput(FormspecQuitMode quitmode) { if(m_text_dst) { -- cgit v1.2.3 From 009e39e73b9aa003c369fe6bc88f366fdc91610e Mon Sep 17 00:00:00 2001 From: Vincent Robinson Date: Sat, 23 Jan 2021 12:46:19 -0800 Subject: FormSpec: Add list spacing, slot size, and noclip (#10083) * Add list spacing, slot size, and noclip * Simplify StyleSpec * Add test cases Co-authored-by: rubenwardy --- doc/lua_api.txt | 8 ++++- games/devtest/mods/testformspec/formspec.lua | 15 ++++++++- src/gui/StyleSpec.h | 47 +++++++++++++++++++--------- src/gui/guiFormSpecMenu.cpp | 30 +++++++++++++++--- 4 files changed, 78 insertions(+), 22 deletions(-) (limited to 'src/gui/guiFormSpecMenu.cpp') diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 317bbe577..f751eb512 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -2226,7 +2226,8 @@ Elements * Show an inventory list if it has been sent to the client. Nothing will be shown if the inventory list is of size 0. * **Note**: With the new coordinate system, the spacing between inventory - slots is one-fourth the size of an inventory slot. + slots is one-fourth the size of an inventory slot by default. Also see + [Styling Formspecs] for changing the size of slots and spacing. ### `list[;;,;,;]` @@ -2809,6 +2810,7 @@ Some types may inherit styles from parent types. * image_button * item_image_button * label +* list * model * pwdfield, inherits from field * scrollbar @@ -2896,6 +2898,10 @@ Some types may inherit styles from parent types. * font - Sets font type. See button `font` property for more information. * font_size - Sets font size. See button `font_size` property for more information. * noclip - boolean, set to true to allow the element to exceed formspec bounds. +* list + * noclip - boolean, set to true to allow the element to exceed formspec bounds. + * size - 2d vector, sets the size of inventory slots in coordinates. + * spacing - 2d vector, sets the space between inventory slots in coordinates. * image_button (additional properties) * fgimg - standard image. Defaults to none. * fgimg_hovered - image when hovered. Defaults to fgimg when not provided. diff --git a/games/devtest/mods/testformspec/formspec.lua b/games/devtest/mods/testformspec/formspec.lua index 5495896ce..0eef859a9 100644 --- a/games/devtest/mods/testformspec/formspec.lua +++ b/games/devtest/mods/testformspec/formspec.lua @@ -33,6 +33,15 @@ local tabheaders_fs = [[ tabheader[8,6;10,1.5;tabs_size2;Height=1.5;1;false;false] ]] +local inv_style_fs = [[ + style_type[list;noclip=true] + list[current_player;main;-1.125,-1.125;2,2] + style_type[list;spacing=.25,.125;size=.75,.875] + list[current_player;main;3,.5;3,3] + style_type[list;spacing=0;size=1] + list[current_player;main;.5,4;8,4] +]] + local hypertext_basic = [[ Normal test This is a normal text. @@ -310,6 +319,10 @@ local pages = { "size[12,13]real_coordinates[true]" .. "container[0.5,1.5]" .. tabheaders_fs .. "container_end[]", + -- Inv + "size[12,13]real_coordinates[true]" .. + "container[0.5,1.5]" .. inv_style_fs .. "container_end[]", + -- Animation [[ formspec_version[3] @@ -341,7 +354,7 @@ Number] local function show_test_formspec(pname, page_id) page_id = page_id or 2 - local fs = pages[page_id] .. "tabheader[0,0;8,0.65;maintabs;Real Coord,Styles,Noclip,Hypertext,Tabs,Anim,ScrollC;" .. page_id .. ";false;false]" + local fs = pages[page_id] .. "tabheader[0,0;8,0.65;maintabs;Real Coord,Styles,Noclip,Hypertext,Tabs,Invs,Anim,ScrollC;" .. page_id .. ";false;false]" minetest.show_formspec(pname, "testformspec:formspec", fs) end diff --git a/src/gui/StyleSpec.h b/src/gui/StyleSpec.h index f2844ce28..fc92a861b 100644 --- a/src/gui/StyleSpec.h +++ b/src/gui/StyleSpec.h @@ -55,6 +55,8 @@ public: BORDERCOLORS, BORDERWIDTHS, SOUND, + SPACING, + SIZE, NUM_PROPERTIES, NONE }; @@ -119,6 +121,10 @@ public: return BORDERWIDTHS; } else if (name == "sound") { return SOUND; + } else if (name == "spacing") { + return SPACING; + } else if (name == "size") { + return SIZE; } else { return NONE; } @@ -259,27 +265,40 @@ public: return rect; } - irr::core::vector2d getVector2i(Property prop, irr::core::vector2d def) const + v2f32 getVector2f(Property prop, v2f32 def) const { const auto &val = properties[prop]; if (val.empty()) return def; - irr::core::vector2d vec; - if (!parseVector2i(val, &vec)) + v2f32 vec; + if (!parseVector2f(val, &vec)) return def; return vec; } - irr::core::vector2d getVector2i(Property prop) const + v2s32 getVector2i(Property prop, v2s32 def) const + { + const auto &val = properties[prop]; + if (val.empty()) + return def; + + v2f32 vec; + if (!parseVector2f(val, &vec)) + return def; + + return v2s32(vec.X, vec.Y); + } + + v2s32 getVector2i(Property prop) const { const auto &val = properties[prop]; FATAL_ERROR_IF(val.empty(), "Unexpected missing property"); - irr::core::vector2d vec; - parseVector2i(val, &vec); - return vec; + v2f32 vec; + parseVector2f(val, &vec); + return v2s32(vec.X, vec.Y); } gui::IGUIFont *getFont() const @@ -432,22 +451,20 @@ private: return true; } - bool parseVector2i(const std::string &value, irr::core::vector2d *parsed_vec) const + bool parseVector2f(const std::string &value, v2f32 *parsed_vec) const { - irr::core::vector2d vec; + v2f32 vec; std::vector v_vector = split(value, ','); if (v_vector.size() == 1) { - s32 x = stoi(v_vector[0]); + f32 x = stof(v_vector[0]); vec.X = x; vec.Y = x; } else if (v_vector.size() == 2) { - s32 x = stoi(v_vector[0]); - s32 y = stoi(v_vector[1]); - vec.X = x; - vec.Y = y; + vec.X = stof(v_vector[0]); + vec.Y = stof(v_vector[1]); } else { - warningstream << "Invalid vector2d string format: \"" << value + warningstream << "Invalid 2d vector string format: \"" << value << "\"" << std::endl; return false; } diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index 4415bdd3a..7b37de6f8 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -497,20 +497,40 @@ void GUIFormSpecMenu::parseList(parserData *data, const std::string &element) 3 ); - v2f32 slot_spacing = data->real_coordinates ? - v2f32(imgsize.X * 1.25f, imgsize.Y * 1.25f) : spacing; + auto style = getDefaultStyleForElement("list", spec.fname); - v2s32 pos = data->real_coordinates ? getRealCoordinateBasePos(v_pos) - : getElementBasePos(&v_pos); + v2f32 slot_scale = style.getVector2f(StyleSpec::SIZE, v2f32(0, 0)); + v2s32 slot_size( + slot_scale.X <= 0 ? imgsize.X : slot_scale.X * imgsize.X, + slot_scale.Y <= 0 ? imgsize.Y : slot_scale.Y * imgsize.Y + ); + + v2f32 slot_spacing = style.getVector2f(StyleSpec::SPACING, v2f32(-1, -1)); + if (data->real_coordinates) { + slot_spacing.X = slot_spacing.X < 0 ? imgsize.X * 1.25f : + slot_spacing.X * imgsize.X + imgsize.X; + slot_spacing.Y = slot_spacing.Y < 0 ? imgsize.Y * 1.25f : + slot_spacing.Y * imgsize.Y + imgsize.Y; + } else { + slot_spacing.X = slot_spacing.X < 0 ? spacing.X : + slot_spacing.X * spacing.X; + slot_spacing.Y = slot_spacing.Y < 0 ? spacing.Y : + slot_spacing.Y * spacing.Y; + } + + v2s32 pos = data->real_coordinates ? getRealCoordinateBasePos(v_pos) : + getElementBasePos(&v_pos); core::rect rect = core::rect(pos.X, pos.Y, pos.X + (geom.X - 1) * slot_spacing.X + imgsize.X, pos.Y + (geom.Y - 1) * slot_spacing.Y + imgsize.Y); GUIInventoryList *e = new GUIInventoryList(Environment, data->current_parent, - spec.fid, rect, m_invmgr, loc, listname, geom, start_i, imgsize, + spec.fid, rect, m_invmgr, loc, listname, geom, start_i, slot_size, slot_spacing, this, data->inventorylist_options, m_font); + e->setNotClipped(style.getBool(StyleSpec::NOCLIP, false)); + m_inventorylists.push_back(e); m_fields.push_back(spec); return; -- cgit v1.2.3 From ad9adcb88444b4a7063d5c2f5debd85729e8ce42 Mon Sep 17 00:00:00 2001 From: Vincent Robinson Date: Sat, 23 Jan 2021 14:49:13 -0800 Subject: Fix formspec list spacing (#10861) --- src/gui/guiFormSpecMenu.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/gui/guiFormSpecMenu.cpp') diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index 7b37de6f8..e4678bcd1 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -507,10 +507,13 @@ void GUIFormSpecMenu::parseList(parserData *data, const std::string &element) v2f32 slot_spacing = style.getVector2f(StyleSpec::SPACING, v2f32(-1, -1)); if (data->real_coordinates) { - slot_spacing.X = slot_spacing.X < 0 ? imgsize.X * 1.25f : - slot_spacing.X * imgsize.X + imgsize.X; - slot_spacing.Y = slot_spacing.Y < 0 ? imgsize.Y * 1.25f : - slot_spacing.Y * imgsize.Y + imgsize.Y; + slot_spacing.X = slot_spacing.X < 0 ? imgsize.X * 0.25f : + imgsize.X * slot_spacing.X; + slot_spacing.Y = slot_spacing.Y < 0 ? imgsize.Y * 0.25f : + imgsize.Y * slot_spacing.Y; + + slot_spacing.X += slot_size.X; + slot_spacing.Y += slot_size.Y; } else { slot_spacing.X = slot_spacing.X < 0 ? spacing.X : slot_spacing.X * spacing.X; -- cgit v1.2.3 From f227e40180b2035f33059749b14287478bab374a Mon Sep 17 00:00:00 2001 From: Vincent Robinson Date: Tue, 2 Feb 2021 11:55:13 -0800 Subject: Fix list spacing and size (again) (#10869) --- games/devtest/mods/testformspec/formspec.lua | 30 +++++++++++++++++----- src/gui/guiFormSpecMenu.cpp | 38 +++++++++++++--------------- src/gui/guiInventoryList.cpp | 2 -- 3 files changed, 42 insertions(+), 28 deletions(-) (limited to 'src/gui/guiFormSpecMenu.cpp') diff --git a/games/devtest/mods/testformspec/formspec.lua b/games/devtest/mods/testformspec/formspec.lua index 62578b740..bb178e1b3 100644 --- a/games/devtest/mods/testformspec/formspec.lua +++ b/games/devtest/mods/testformspec/formspec.lua @@ -35,11 +35,30 @@ local tabheaders_fs = [[ local inv_style_fs = [[ style_type[list;noclip=true] - list[current_player;main;-1.125,-1.125;2,2] + list[current_player;main;-0.75,0.75;2,2] + + real_coordinates[false] + list[current_player;main;1.5,0;3,2] + real_coordinates[true] + + real_coordinates[false] + style_type[list;size=1.1;spacing=0.1] + list[current_player;main;5,0;3,2] + real_coordinates[true] + + style_type[list;size=.001;spacing=0] + list[current_player;main;7,3.5;8,4] + + box[3,3.5;1,1;#000000] + box[5,3.5;1,1;#000000] + box[4,4.5;1,1;#000000] + box[3,5.5;1,1;#000000] + box[5,5.5;1,1;#000000] style_type[list;spacing=.25,.125;size=.75,.875] - list[current_player;main;3,.5;3,3] - style_type[list;spacing=0;size=1] - list[current_player;main;.5,4;8,4] + list[current_player;main;3,3.5;3,3] + + style_type[list;spacing=0;size=1.1] + list[current_player;main;.5,7;8,4] ]] local hypertext_basic = [[ @@ -322,8 +341,7 @@ local pages = { "container[0.5,1.5]" .. tabheaders_fs .. "container_end[]", -- Inv - "size[12,13]real_coordinates[true]" .. - "container[0.5,1.5]" .. inv_style_fs .. "container_end[]", + "size[12,13]real_coordinates[true]" .. inv_style_fs, -- Animation [[ diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index e4678bcd1..88ea77812 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include +#include #include #include #include @@ -500,37 +501,34 @@ void GUIFormSpecMenu::parseList(parserData *data, const std::string &element) auto style = getDefaultStyleForElement("list", spec.fname); v2f32 slot_scale = style.getVector2f(StyleSpec::SIZE, v2f32(0, 0)); - v2s32 slot_size( - slot_scale.X <= 0 ? imgsize.X : slot_scale.X * imgsize.X, - slot_scale.Y <= 0 ? imgsize.Y : slot_scale.Y * imgsize.Y + v2f32 slot_size( + slot_scale.X <= 0 ? imgsize.X : std::max(slot_scale.X * imgsize.X, 1), + slot_scale.Y <= 0 ? imgsize.Y : std::max(slot_scale.Y * imgsize.Y, 1) ); v2f32 slot_spacing = style.getVector2f(StyleSpec::SPACING, v2f32(-1, -1)); - if (data->real_coordinates) { - slot_spacing.X = slot_spacing.X < 0 ? imgsize.X * 0.25f : - imgsize.X * slot_spacing.X; - slot_spacing.Y = slot_spacing.Y < 0 ? imgsize.Y * 0.25f : - imgsize.Y * slot_spacing.Y; + v2f32 default_spacing = data->real_coordinates ? + v2f32(imgsize.X * 0.25f, imgsize.Y * 0.25f) : + v2f32(spacing.X - imgsize.X, spacing.Y - imgsize.Y); - slot_spacing.X += slot_size.X; - slot_spacing.Y += slot_size.Y; - } else { - slot_spacing.X = slot_spacing.X < 0 ? spacing.X : - slot_spacing.X * spacing.X; - slot_spacing.Y = slot_spacing.Y < 0 ? spacing.Y : - slot_spacing.Y * spacing.Y; - } + slot_spacing.X = slot_spacing.X < 0 ? default_spacing.X : + imgsize.X * slot_spacing.X; + slot_spacing.Y = slot_spacing.Y < 0 ? default_spacing.Y : + imgsize.Y * slot_spacing.Y; + + slot_spacing += slot_size; v2s32 pos = data->real_coordinates ? getRealCoordinateBasePos(v_pos) : getElementBasePos(&v_pos); core::rect rect = core::rect(pos.X, pos.Y, - pos.X + (geom.X - 1) * slot_spacing.X + imgsize.X, - pos.Y + (geom.Y - 1) * slot_spacing.Y + imgsize.Y); + pos.X + (geom.X - 1) * slot_spacing.X + slot_size.X, + pos.Y + (geom.Y - 1) * slot_spacing.Y + slot_size.Y); GUIInventoryList *e = new GUIInventoryList(Environment, data->current_parent, - spec.fid, rect, m_invmgr, loc, listname, geom, start_i, slot_size, - slot_spacing, this, data->inventorylist_options, m_font); + spec.fid, rect, m_invmgr, loc, listname, geom, start_i, + v2s32(slot_size.X, slot_size.Y), slot_spacing, this, + data->inventorylist_options, m_font); e->setNotClipped(style.getBool(StyleSpec::NOCLIP, false)); diff --git a/src/gui/guiInventoryList.cpp b/src/gui/guiInventoryList.cpp index dfdb60448..183d72165 100644 --- a/src/gui/guiInventoryList.cpp +++ b/src/gui/guiInventoryList.cpp @@ -104,8 +104,6 @@ void GUIInventoryList::draw() && m_invmgr->getInventory(selected_item->inventoryloc) == inv && selected_item->listname == m_listname && selected_item->i == item_i; - core::rect clipped_rect(rect); - clipped_rect.clipAgainst(AbsoluteClippingRect); bool hovering = m_hovered_i == item_i; ItemRotationKind rotation_kind = selected ? IT_ROT_SELECTED : (hovering ? IT_ROT_HOVERED : IT_ROT_NONE); -- cgit v1.2.3 From 6591597430c8a06c579e2631fcdbb022ae12160d Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Mon, 8 Feb 2021 00:04:38 +0000 Subject: Fix animation_image support in scroll containers --- games/devtest/mods/testformspec/formspec.lua | 1 + src/gui/guiFormSpecMenu.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gui/guiFormSpecMenu.cpp') diff --git a/games/devtest/mods/testformspec/formspec.lua b/games/devtest/mods/testformspec/formspec.lua index bb178e1b3..2a2bdad60 100644 --- a/games/devtest/mods/testformspec/formspec.lua +++ b/games/devtest/mods/testformspec/formspec.lua @@ -227,6 +227,7 @@ local scroll_fs = "box[1,1;8,6;#00aa]".. "scroll_container[1,1;8,6;scrbar;vertical]".. "button[0,1;1,1;lorem;Lorem]".. + "animated_image[0,1;4.5,1;clip_animated_image;testformspec_animation.png;4;100]" .. "button[0,10;1,1;ipsum;Ipsum]".. "pwdfield[2,2;1,1;lorem2;Lorem]".. "list[current_player;main;4,4;1,5;]".. diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index 88ea77812..5aa6dc9ae 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -928,7 +928,7 @@ void GUIFormSpecMenu::parseAnimatedImage(parserData *data, const std::string &el core::rect rect = core::rect(pos, pos + geom); - GUIAnimatedImage *e = new GUIAnimatedImage(Environment, this, spec.fid, + GUIAnimatedImage *e = new GUIAnimatedImage(Environment, data->current_parent, spec.fid, rect, texture_name, frame_count, frame_duration, m_tsrc); if (parts.size() >= 7) -- cgit v1.2.3 From 285ba74723695c4b51192dac0e1e17c5d8f880db Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Tue, 16 Mar 2021 23:28:16 +0100 Subject: GUIScene: Clear depth buffer + replace deprecated clearZBuffer calls --- doc/lua_api.txt | 3 ++- src/client/camera.cpp | 2 +- src/client/hud.cpp | 2 +- src/client/render/anaglyph.cpp | 2 +- src/gui/guiFormSpecMenu.cpp | 4 +++- src/gui/guiScene.cpp | 15 ++++++++++++--- src/gui/guiScene.h | 1 + 7 files changed, 21 insertions(+), 8 deletions(-) (limited to 'src/gui/guiFormSpecMenu.cpp') diff --git a/doc/lua_api.txt b/doc/lua_api.txt index c09578a15..abbe88f80 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -2299,7 +2299,7 @@ Elements * `frame duration`: Milliseconds between each frame. `0` means the frames don't advance. * `frame start` (Optional): The index of the frame to start on. Default `1`. -### `model[,;,;;;;;;;]` +### `model[,;,;;;;;;;;]` * Show a mesh model. * `name`: Element name that can be used for styling @@ -2313,6 +2313,7 @@ Elements * `frame loop range` (Optional): Range of the animation frames. * Defaults to the full range of all available frames. * Syntax: `,` +* `animation speed` (Optional): Sets the animation speed. Default 0 FPS. ### `item_image[,;,;]` diff --git a/src/client/camera.cpp b/src/client/camera.cpp index 350b685e1..5158d0dd1 100644 --- a/src/client/camera.cpp +++ b/src/client/camera.cpp @@ -664,7 +664,7 @@ void Camera::wield(const ItemStack &item) void Camera::drawWieldedTool(irr::core::matrix4* translation) { // Clear Z buffer so that the wielded tool stays in front of world geometry - m_wieldmgr->getVideoDriver()->clearZBuffer(); + m_wieldmgr->getVideoDriver()->clearBuffers(video::ECBF_DEPTH); // Draw the wielded node (in a separate scene manager) scene::ICameraSceneNode* cam = m_wieldmgr->getActiveCamera(); diff --git a/src/client/hud.cpp b/src/client/hud.cpp index 46736b325..74c1828e3 100644 --- a/src/client/hud.cpp +++ b/src/client/hud.cpp @@ -950,7 +950,7 @@ void drawItemStack( if (imesh && imesh->mesh) { scene::IMesh *mesh = imesh->mesh; - driver->clearZBuffer(); + driver->clearBuffers(video::ECBF_DEPTH); s32 delta = 0; if (rotation_kind < IT_ROT_NONE) { MeshTimeInfo &ti = rotation_time_infos[rotation_kind]; diff --git a/src/client/render/anaglyph.cpp b/src/client/render/anaglyph.cpp index 9ba4464a2..153e77400 100644 --- a/src/client/render/anaglyph.cpp +++ b/src/client/render/anaglyph.cpp @@ -40,7 +40,7 @@ void RenderingCoreAnaglyph::setupMaterial(int color_mask) void RenderingCoreAnaglyph::useEye(bool right) { RenderingCoreStereo::useEye(right); - driver->clearZBuffer(); + driver->clearBuffers(video::ECBF_DEPTH); setupMaterial(right ? video::ECP_GREEN | video::ECP_BLUE : video::ECP_RED); } diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index 5aa6dc9ae..5d763a4be 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -2746,7 +2746,7 @@ void GUIFormSpecMenu::parseModel(parserData *data, const std::string &element) { std::vector 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; @@ -2766,6 +2766,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 frame_loop = split(parts[8], ','); + std::string speed = unescape_string(parts[9]); MY_CHECKPOS("model", 0); MY_CHECKGEOM("model", 1); @@ -2825,6 +2826,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/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; }; -- cgit v1.2.3 From 96d4df995c1baf364217699cd43e5ab71918c9d8 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Fri, 19 Mar 2021 18:44:32 +0100 Subject: Drop old text input workarounds (#11089) * Drop unused intlGUIEditBox * Drop unnecessary Linux text input workarounds --- src/gui/CMakeLists.txt | 1 - src/gui/guiChatConsole.cpp | 8 +- src/gui/guiConfirmRegistration.cpp | 9 +- src/gui/guiEditBox.cpp | 23 +- src/gui/guiFormSpecMenu.cpp | 23 +- src/gui/intlGUIEditBox.cpp | 626 ------------------------------------- src/gui/intlGUIEditBox.h | 68 ---- 7 files changed, 13 insertions(+), 745 deletions(-) delete mode 100644 src/gui/intlGUIEditBox.cpp delete mode 100644 src/gui/intlGUIEditBox.h (limited to 'src/gui/guiFormSpecMenu.cpp') 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/guiChatConsole.cpp b/src/gui/guiChatConsole.cpp index ef471106d..a4e91fe78 100644 --- a/src/gui/guiChatConsole.cpp +++ b/src/gui/guiChatConsole.cpp @@ -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; } } 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 #include #include -#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 5d763a4be..4661e505d 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); 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 -#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& 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 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 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 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; igetDimension(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 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& 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_ -- cgit v1.2.3 From c9eba8440d3dc293a8aa6ffafc045737732da1e1 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Sun, 21 Mar 2021 23:23:30 +0100 Subject: Fix segfault for model[] without animation speed --- src/gui/guiFormSpecMenu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui/guiFormSpecMenu.cpp') diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index 4661e505d..fd35f2d84 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -2745,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 v_pos = split(parts[0], ','); std::vector v_geom = split(parts[1], ','); -- cgit v1.2.3 From 5a02c376ea5f2e7f1dd0a2bd4f08bf953ed4bfc8 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Thu, 29 Apr 2021 09:40:56 +0200 Subject: refacto: RenderingEngine::get_scene_manager() is now not callable from singleton This permits to make evidence that we have some bad object passing on various code parts. I fixed majority of them to reduce the scope of passed objects Unfortunately, for some edge cases i should have to expose ISceneManager from client, this should be fixed in the future when our POO will be cleaner client side (we have a mix of rendering and processing in majority of the client objects, it works but it's not clean) --- src/client/client.cpp | 5 +++++ src/client/client.h | 1 + src/client/clientenvironment.cpp | 2 +- src/client/content_mapblock.cpp | 16 +++++++--------- src/client/content_mapblock.h | 3 ++- src/client/mapblock_mesh.cpp | 4 ++-- src/client/particles.cpp | 4 ++-- src/client/renderingengine.h | 5 ++--- src/client/wieldmesh.cpp | 5 +++-- src/gui/guiFormSpecMenu.cpp | 2 +- src/nodedef.cpp | 4 ++-- 11 files changed, 28 insertions(+), 23 deletions(-) (limited to 'src/gui/guiFormSpecMenu.cpp') diff --git a/src/client/client.cpp b/src/client/client.cpp index d1c5cd948..2f4f2aac5 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1475,6 +1475,11 @@ bool Client::updateWieldedItem() return true; } +irr::scene::ISceneManager* Client::getSceneManager() +{ + return m_rendering_engine->get_scene_manager(); +} + Inventory* Client::getInventory(const InventoryLocation &loc) { switch(loc.type){ diff --git a/src/client/client.h b/src/client/client.h index bcb7d6b09..be5970160 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -355,6 +355,7 @@ public: void setCamera(Camera* camera) { m_camera = camera; } Camera* getCamera () { return m_camera; } + irr::scene::ISceneManager *getSceneManager(); bool shouldShowMinimap() const; diff --git a/src/client/clientenvironment.cpp b/src/client/clientenvironment.cpp index 9c40484bf..7e3867537 100644 --- a/src/client/clientenvironment.cpp +++ b/src/client/clientenvironment.cpp @@ -352,7 +352,7 @@ u16 ClientEnvironment::addActiveObject(ClientActiveObject *object) if (!m_ao_manager.registerObject(object)) return 0; - object->addToScene(m_texturesource, RenderingEngine::get_scene_manager()); + object->addToScene(m_texturesource, m_client->getSceneManager()); // Update lighting immediately object->updateLight(getDayNightRatio()); diff --git a/src/client/content_mapblock.cpp b/src/client/content_mapblock.cpp index ce7235bca..e530f3d7f 100644 --- a/src/client/content_mapblock.cpp +++ b/src/client/content_mapblock.cpp @@ -60,18 +60,16 @@ static constexpr u16 quad_indices[] = {0, 1, 2, 2, 3, 0}; const std::string MapblockMeshGenerator::raillike_groupname = "connect_to_raillike"; -MapblockMeshGenerator::MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output) +MapblockMeshGenerator::MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output, + irr::scene::IMeshManipulator *mm): + data(input), + collector(output), + nodedef(data->m_client->ndef()), + meshmanip(mm), + blockpos_nodes(data->m_blockpos * MAP_BLOCKSIZE) { - data = input; - collector = output; - - nodedef = data->m_client->ndef(); - meshmanip = RenderingEngine::get_scene_manager()->getMeshManipulator(); - enable_mesh_cache = g_settings->getBool("enable_mesh_cache") && !data->m_smooth_lighting; // Mesh cache is not supported with smooth lighting - - blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE; } void MapblockMeshGenerator::useTile(int index, u8 set_flags, u8 reset_flags, bool special) diff --git a/src/client/content_mapblock.h b/src/client/content_mapblock.h index a6c450d1f..cbee49021 100644 --- a/src/client/content_mapblock.h +++ b/src/client/content_mapblock.h @@ -172,7 +172,8 @@ public: void drawNode(); public: - MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output); + MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output, + irr::scene::IMeshManipulator *mm); void generate(); void renderSingle(content_t node, u8 param2 = 0x00); }; diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp index 167e1e3ec..72e68fe97 100644 --- a/src/client/mapblock_mesh.cpp +++ b/src/client/mapblock_mesh.cpp @@ -1072,8 +1072,8 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset): */ { - MapblockMeshGenerator generator(data, &collector); - generator.generate(); + MapblockMeshGenerator(data, &collector, + data->m_client->getSceneManager()->getMeshManipulator()).generate(); } /* diff --git a/src/client/particles.cpp b/src/client/particles.cpp index 7acd996dc..288826a5f 100644 --- a/src/client/particles.cpp +++ b/src/client/particles.cpp @@ -64,8 +64,8 @@ Particle::Particle( v2f texsize, video::SColor color ): - scene::ISceneNode(RenderingEngine::get_scene_manager()->getRootSceneNode(), - RenderingEngine::get_scene_manager()) + scene::ISceneNode(((Client *)gamedef)->getSceneManager()->getRootSceneNode(), + ((Client *)gamedef)->getSceneManager()) { // Misc m_gamedef = gamedef; diff --git a/src/client/renderingengine.h b/src/client/renderingengine.h index 5462aa667..4d06baa23 100644 --- a/src/client/renderingengine.h +++ b/src/client/renderingengine.h @@ -79,10 +79,9 @@ public: return s_singleton->m_device->getVideoDriver(); } - static scene::ISceneManager *get_scene_manager() + scene::ISceneManager *get_scene_manager() { - sanity_check(s_singleton && s_singleton->m_device); - return s_singleton->m_device->getSceneManager(); + return m_device->getSceneManager(); } static irr::IrrlichtDevice *get_raw_device() diff --git a/src/client/wieldmesh.cpp b/src/client/wieldmesh.cpp index d9d5e57cd..08fd49fc0 100644 --- a/src/client/wieldmesh.cpp +++ b/src/client/wieldmesh.cpp @@ -307,7 +307,8 @@ static scene::SMesh *createSpecialNodeMesh(Client *client, MapNode n, MeshMakeData mesh_make_data(client, false); MeshCollector collector; mesh_make_data.setSmoothLighting(false); - MapblockMeshGenerator gen(&mesh_make_data, &collector); + MapblockMeshGenerator gen(&mesh_make_data, &collector, + client->getSceneManager()->getMeshManipulator()); if (n.getParam2()) { // keep it @@ -538,7 +539,7 @@ void getItemMesh(Client *client, const ItemStack &item, ItemMesh *result) content_t id = ndef->getId(def.name); FATAL_ERROR_IF(!g_extrusion_mesh_cache, "Extrusion mesh cache is not yet initialized"); - + scene::SMesh *mesh = nullptr; // Shading is on by default diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index fd35f2d84..fdcf27a0a 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -2794,7 +2794,7 @@ void GUIFormSpecMenu::parseModel(parserData *data, const std::string &element) core::rect rect(pos, pos + geom); - GUIScene *e = new GUIScene(Environment, RenderingEngine::get_scene_manager(), + GUIScene *e = new GUIScene(Environment, m_client->getSceneManager(), data->current_parent, rect, spec.fid); auto meshnode = e->setMesh(mesh); diff --git a/src/nodedef.cpp b/src/nodedef.cpp index dd862e606..65a76bcec 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -1446,8 +1446,8 @@ void NodeDefManager::updateTextures(IGameDef *gamedef, Client *client = (Client *)gamedef; ITextureSource *tsrc = client->tsrc(); IShaderSource *shdsrc = client->getShaderSource(); - scene::IMeshManipulator *meshmanip = - RenderingEngine::get_scene_manager()->getMeshManipulator(); + auto smgr = client->getSceneManager(); + scene::IMeshManipulator *meshmanip = smgr->getMeshManipulator(); TextureSettings tsettings; tsettings.readSettings(); -- cgit v1.2.3 From 48d5abd5bee7a3f956cb2b92745bed6313cf5d8a Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Thu, 29 Apr 2021 20:38:35 +0200 Subject: refacto: remove get_gui_env & draw_load_screen from RenderingEngine singleton --- src/client/client.cpp | 6 +++--- src/client/client.h | 1 + src/client/game.cpp | 24 ++++++++++++------------ src/client/renderingengine.cpp | 2 +- src/client/renderingengine.h | 17 ++++------------- src/gui/guiEngine.cpp | 1 + src/gui/guiFormSpecMenu.cpp | 12 ++++++------ src/gui/guiFormSpecMenu.h | 6 ++++-- src/nodedef.cpp | 6 ++---- src/nodedef.h | 4 +--- src/script/lua_api/l_mainmenu.cpp | 5 +++-- 11 files changed, 38 insertions(+), 46 deletions(-) (limited to 'src/gui/guiFormSpecMenu.cpp') diff --git a/src/client/client.cpp b/src/client/client.cpp index 1a3a81378..c7aae1644 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1731,7 +1731,7 @@ typedef struct TextureUpdateArgs { ITextureSource *tsrc; } TextureUpdateArgs; -void texture_update_progress(void *args, u32 progress, u32 max_progress) +void Client::showUpdateProgressTexture(void *args, u32 progress, u32 max_progress) { TextureUpdateArgs* targs = (TextureUpdateArgs*) args; u16 cur_percent = ceil(progress / (double) max_progress * 100.); @@ -1750,7 +1750,7 @@ void texture_update_progress(void *args, u32 progress, u32 max_progress) targs->last_time_ms = time_ms; std::basic_stringstream strm; strm << targs->text_base << " " << targs->last_percent << "%..."; - RenderingEngine::draw_load_screen(strm.str(), targs->guienv, targs->tsrc, 0, + m_rendering_engine->draw_load_screen(strm.str(), targs->guienv, targs->tsrc, 0, 72 + (u16) ((18. / 100.) * (double) targs->last_percent), true); } } @@ -1804,7 +1804,7 @@ void Client::afterContentReceived() tu_args.last_percent = 0; tu_args.text_base = wgettext("Initializing nodes"); tu_args.tsrc = m_tsrc; - m_nodedef->updateTextures(this, texture_update_progress, &tu_args); + m_nodedef->updateTextures(this, &tu_args); delete[] tu_args.text_base; // Start mesh update thread after setting up content definitions diff --git a/src/client/client.h b/src/client/client.h index be5970160..b819d4301 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -347,6 +347,7 @@ public: float mediaReceiveProgress(); void afterContentReceived(); + void showUpdateProgressTexture(void *args, u32 progress, u32 max_progress); float getRTT(); float getCurRate(); diff --git a/src/client/game.cpp b/src/client/game.cpp index 81508f5f4..2f0f50505 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -2047,8 +2047,8 @@ void Game::openInventory() || !client->getScript()->on_inventory_open(fs_src->m_client->getInventory(inventoryloc))) { TextDest *txt_dst = new TextDestPlayerInventory(client); auto *&formspec = m_game_ui->updateFormspec(""); - GUIFormSpecMenu::create(formspec, client, &input->joystick, fs_src, - txt_dst, client->getFormspecPrepend(), sound); + GUIFormSpecMenu::create(formspec, client, m_rendering_engine->get_gui_env(), + &input->joystick, fs_src, txt_dst, client->getFormspecPrepend(), sound); formspec->setFormSpec(fs_src->getForm(), inventoryloc); } @@ -2626,8 +2626,8 @@ void Game::handleClientEvent_ShowFormSpec(ClientEvent *event, CameraOrientation new TextDestPlayerInventory(client, *(event->show_formspec.formname)); auto *&formspec = m_game_ui->updateFormspec(*(event->show_formspec.formname)); - GUIFormSpecMenu::create(formspec, client, &input->joystick, - fs_src, txt_dst, client->getFormspecPrepend(), sound); + GUIFormSpecMenu::create(formspec, client, m_rendering_engine->get_gui_env(), + &input->joystick, fs_src, txt_dst, client->getFormspecPrepend(), sound); } delete event->show_formspec.formspec; @@ -2639,8 +2639,8 @@ void Game::handleClientEvent_ShowLocalFormSpec(ClientEvent *event, CameraOrienta FormspecFormSource *fs_src = new FormspecFormSource(*event->show_formspec.formspec); LocalFormspecHandler *txt_dst = new LocalFormspecHandler(*event->show_formspec.formname, client); - GUIFormSpecMenu::create(m_game_ui->getFormspecGUI(), client, &input->joystick, - fs_src, txt_dst, client->getFormspecPrepend(), sound); + GUIFormSpecMenu::create(m_game_ui->getFormspecGUI(), client, m_rendering_engine->get_gui_env(), + &input->joystick, fs_src, txt_dst, client->getFormspecPrepend(), sound); delete event->show_formspec.formspec; delete event->show_formspec.formname; @@ -3332,8 +3332,8 @@ bool Game::nodePlacement(const ItemDefinition &selected_def, TextDest *txt_dst = new TextDestNodeMetadata(nodepos, client); auto *&formspec = m_game_ui->updateFormspec(""); - GUIFormSpecMenu::create(formspec, client, &input->joystick, fs_src, - txt_dst, client->getFormspecPrepend(), sound); + GUIFormSpecMenu::create(formspec, client, m_rendering_engine->get_gui_env(), + &input->joystick, fs_src, txt_dst, client->getFormspecPrepend(), sound); formspec->setFormSpec(meta->getString("formspec"), inventoryloc); return false; @@ -4082,8 +4082,8 @@ void Game::showDeathFormspec() LocalFormspecHandler *txt_dst = new LocalFormspecHandler("MT_DEATH_SCREEN", client); auto *&formspec = m_game_ui->getFormspecGUI(); - GUIFormSpecMenu::create(formspec, client, &input->joystick, - fs_src, txt_dst, client->getFormspecPrepend(), sound); + GUIFormSpecMenu::create(formspec, client, m_rendering_engine->get_gui_env(), + &input->joystick, fs_src, txt_dst, client->getFormspecPrepend(), sound); formspec->setFocus("btn_respawn"); } @@ -4216,8 +4216,8 @@ void Game::showPauseMenu() LocalFormspecHandler *txt_dst = new LocalFormspecHandler("MT_PAUSE_MENU"); auto *&formspec = m_game_ui->getFormspecGUI(); - GUIFormSpecMenu::create(formspec, client, &input->joystick, - fs_src, txt_dst, client->getFormspecPrepend(), sound); + GUIFormSpecMenu::create(formspec, client, m_rendering_engine->get_gui_env(), + &input->joystick, fs_src, txt_dst, client->getFormspecPrepend(), sound); formspec->setFocus("btn_continue"); formspec->doPause = true; diff --git a/src/client/renderingengine.cpp b/src/client/renderingengine.cpp index ec8f47576..e74446aeb 100644 --- a/src/client/renderingengine.cpp +++ b/src/client/renderingengine.cpp @@ -493,7 +493,7 @@ bool RenderingEngine::setXorgWindowIconFromPath(const std::string &icon_file) Text will be removed when the screen is drawn the next time. Additionally, a progressbar can be drawn when percent is set between 0 and 100. */ -void RenderingEngine::_draw_load_screen(const std::wstring &text, +void RenderingEngine::draw_load_screen(const std::wstring &text, gui::IGUIEnvironment *guienv, ITextureSource *tsrc, float dtime, int percent, bool clouds) { diff --git a/src/client/renderingengine.h b/src/client/renderingengine.h index 4d06baa23..1fd85f5ef 100644 --- a/src/client/renderingengine.h +++ b/src/client/renderingengine.h @@ -95,19 +95,14 @@ public: return m_device->getTimer()->getTime(); } - static gui::IGUIEnvironment *get_gui_env() + gui::IGUIEnvironment *get_gui_env() { - sanity_check(s_singleton && s_singleton->m_device); - return s_singleton->m_device->getGUIEnvironment(); + return m_device->getGUIEnvironment(); } - inline static void draw_load_screen(const std::wstring &text, + void draw_load_screen(const std::wstring &text, gui::IGUIEnvironment *guienv, ITextureSource *tsrc, - float dtime = 0, int percent = 0, bool clouds = true) - { - s_singleton->_draw_load_screen( - text, guienv, tsrc, dtime, percent, clouds); - } + float dtime = 0, int percent = 0, bool clouds = true); void draw_menu_scene(gui::IGUIEnvironment *guienv, float dtime, bool clouds); void draw_scene(video::SColor skycolor, bool show_hud, @@ -125,10 +120,6 @@ public: static std::vector getSupportedVideoDrivers(); private: - void _draw_load_screen(const std::wstring &text, gui::IGUIEnvironment *guienv, - ITextureSource *tsrc, float dtime = 0, int percent = 0, - bool clouds = true); - v2u32 _getWindowSize() const; std::unique_ptr core; diff --git a/src/gui/guiEngine.cpp b/src/gui/guiEngine.cpp index 0c7b96492..694baf482 100644 --- a/src/gui/guiEngine.cpp +++ b/src/gui/guiEngine.cpp @@ -170,6 +170,7 @@ GUIEngine::GUIEngine(JoystickController *joystick, -1, m_menumanager, NULL /* &client */, + m_rendering_engine->get_gui_env(), m_texture_source, m_sound_manager, m_formspecgui, diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index fdcf27a0a..c6435804f 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -96,10 +96,10 @@ inline u32 clamp_u8(s32 value) GUIFormSpecMenu::GUIFormSpecMenu(JoystickController *joystick, gui::IGUIElement *parent, s32 id, IMenuManager *menumgr, - Client *client, ISimpleTextureSource *tsrc, ISoundManager *sound_manager, - IFormSource *fsrc, TextDest *tdst, + Client *client, gui::IGUIEnvironment *guienv, ISimpleTextureSource *tsrc, + ISoundManager *sound_manager, IFormSource *fsrc, TextDest *tdst, const std::string &formspecPrepend, bool remap_dbl_click): - GUIModalMenu(RenderingEngine::get_gui_env(), parent, id, menumgr, remap_dbl_click), + GUIModalMenu(guienv, parent, id, menumgr, remap_dbl_click), m_invmgr(client), m_tsrc(tsrc), m_sound_manager(sound_manager), @@ -145,12 +145,12 @@ GUIFormSpecMenu::~GUIFormSpecMenu() } void GUIFormSpecMenu::create(GUIFormSpecMenu *&cur_formspec, Client *client, - JoystickController *joystick, IFormSource *fs_src, TextDest *txt_dest, - const std::string &formspecPrepend, ISoundManager *sound_manager) + gui::IGUIEnvironment *guienv, JoystickController *joystick, IFormSource *fs_src, + TextDest *txt_dest, const std::string &formspecPrepend, ISoundManager *sound_manager) { if (cur_formspec == nullptr) { cur_formspec = new GUIFormSpecMenu(joystick, guiroot, -1, &g_menumgr, - client, client->getTextureSource(), sound_manager, fs_src, + client, guienv, client->getTextureSource(), sound_manager, fs_src, txt_dest, formspecPrepend); cur_formspec->doPause = false; diff --git a/src/gui/guiFormSpecMenu.h b/src/gui/guiFormSpecMenu.h index d658aba7b..926de66d5 100644 --- a/src/gui/guiFormSpecMenu.h +++ b/src/gui/guiFormSpecMenu.h @@ -152,6 +152,7 @@ public: gui::IGUIElement* parent, s32 id, IMenuManager *menumgr, Client *client, + gui::IGUIEnvironment *guienv, ISimpleTextureSource *tsrc, ISoundManager *sound_manager, IFormSource* fs_src, @@ -162,8 +163,9 @@ public: ~GUIFormSpecMenu(); static void create(GUIFormSpecMenu *&cur_formspec, Client *client, - JoystickController *joystick, IFormSource *fs_src, TextDest *txt_dest, - const std::string &formspecPrepend, ISoundManager *sound_manager); + gui::IGUIEnvironment *guienv, JoystickController *joystick, IFormSource *fs_src, + TextDest *txt_dest, const std::string &formspecPrepend, + ISoundManager *sound_manager); void setFormSpec(const std::string &formspec_string, const InventoryLocation ¤t_inventory_location) diff --git a/src/nodedef.cpp b/src/nodedef.cpp index 65a76bcec..db4043aa1 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -1435,9 +1435,7 @@ void NodeDefManager::applyTextureOverrides(const std::vector &o } } -void NodeDefManager::updateTextures(IGameDef *gamedef, - void (*progress_callback)(void *progress_args, u32 progress, u32 max_progress), - void *progress_callback_args) +void NodeDefManager::updateTextures(IGameDef *gamedef, void *progress_callback_args) { #ifndef SERVER infostream << "NodeDefManager::updateTextures(): Updating " @@ -1456,7 +1454,7 @@ void NodeDefManager::updateTextures(IGameDef *gamedef, for (u32 i = 0; i < size; i++) { ContentFeatures *f = &(m_content_features[i]); f->updateTextures(tsrc, shdsrc, meshmanip, client, tsettings); - progress_callback(progress_callback_args, i, size); + client->showUpdateProgressTexture(progress_callback_args, i, size); } #endif } diff --git a/src/nodedef.h b/src/nodedef.h index 0de4dbc21..8a6d88071 100644 --- a/src/nodedef.h +++ b/src/nodedef.h @@ -660,9 +660,7 @@ public: * total ContentFeatures. * @param progress_cbk_args passed to the callback function */ - void updateTextures(IGameDef *gamedef, - void (*progress_cbk)(void *progress_args, u32 progress, u32 max_progress), - void *progress_cbk_args); + void updateTextures(IGameDef *gamedef, void *progress_cbk_args); /*! * Writes the content of this manager to the given output stream. diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index a5bb5f261..b13398539 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -397,7 +397,8 @@ int ModApiMainMenu::l_show_keys_menu(lua_State *L) GUIEngine* engine = getGuiEngine(L); sanity_check(engine != NULL); - GUIKeyChangeMenu *kmenu = new GUIKeyChangeMenu(RenderingEngine::get_gui_env(), + GUIKeyChangeMenu *kmenu = new GUIKeyChangeMenu( + engine->m_rendering_engine->get_gui_env(), engine->m_parent, -1, engine->m_menumanager, @@ -694,7 +695,7 @@ int ModApiMainMenu::l_show_path_select_dialog(lua_State *L) bool is_file_select = readParam(L, 3); GUIFileSelectMenu* fileOpenMenu = - new GUIFileSelectMenu(RenderingEngine::get_gui_env(), + new GUIFileSelectMenu(engine->m_rendering_engine->get_gui_env(), engine->m_parent, -1, engine->m_menumanager, -- cgit v1.2.3