Commit Graph

222 Commits

Author SHA1 Message Date
rubenwardy 429a989648 Add support for 9-sliced backgrounds (#8600)
9-slice textures are commonly used in GUIs to allow scaling them to match any resolution without distortion.

https://en.wikipedia.org/wiki/9-slice_scaling
2019-06-22 16:03:54 +02:00
SmallJoker e2f8f4da83
Formspecs: Close on metadata removal (#8348)
Formspecs will now close as soon the formspec string in the node metadata turns invalid.
2019-06-10 13:01:07 +02:00
SmallJoker 627a96cd99 Do not drag-place stack into 'craftpreview' slot (#8514) 2019-05-25 17:41:35 +02:00
stujones11 b917ea4723 Add IGUIScrollbar implementation with variable bar sizes (#8507) 2019-05-24 16:42:05 +01:00
Jozef Behran eb2bda7d0b Optimize string (mis)handling (#8128)
* Optimize statbar drawing

The texture name of the statbar is a string passed by value.
That slows down the client and creates litter in the heap
as the content of the string is allocated there. Convert the
offending parameter to a const reference to avoid the
performance hit.

* Optimize texture cache

There is an unnecessary temporary created when the texture
path is being generated. This slows down the cache each time
a new texture is encountered and it needs to be loaded into
the cache. Additionally, the heap litter created by this
unnecessary temporary is particularly troublesome here as
the following code then piles another string (the resulting
full path of the texture) on top of it, followed by the
texture itself, which both are quite long term objects as
they are subsequently inserted into the cache where they can
remain for quite a while (especially if the texture turns
out to be a common one like dirt, grass or stone).

Use std::string.append to get rid of the temporary which
solves both issues (speed and heap fragmentation).

* Optimize animations in client

Each time an animated node is updated, an unnecessary copy of
the texture name is created, littering the heap with lots of
fragments. This can be specifically troublesome when looking
at oceans or large lava lakes as both of these nodes are
usually animated (the lava animation is pretty visible).
Convert the parameter of GenericCAO::updateTextures to a
const reference to get rid of the unnecessary copy.

There is a comment stating "std::string copy is mandatory as
mod can be a class member and there is a swap on those class
members ... do NOT pass by reference", reinforcing the
belief that the unnecessary copy is in fact necessary.
However one of the first things the code of the method does
is to assign the parameter to its class member, creating
another copy. By rearranging the code a little bit this
"another copy" can then be used by the subsequent code,
getting rid of the need to pass the parameter by value and
thus saving that copying effort.

* Optimize chat console history handling

The GUIChatConsole::replaceAndAddToHistory was getting the
line to work on by value which turns out to be unnecessary.
Get rid of that unnecessary copy by converting the parameter
to a const reference.

* Optimize gui texture setting

The code used to set the texture for GUI components was
getting the name of the texture by value, creating
unnecessary performance bottleneck for mods/games with
heavily textured GUIs. Get rid of the bottleneck by passing
the texture name as a const reference.

* Optimize sound playing code in GUIEngine

The GUIEngine's code receives the specification of the sound
to be played by value, which turns out to be most likely a
mistake as the underlying sound manager interface receives
the same thing by reference. Convert the offending parameter
to a const reference to get rid of the rather bulky copying
effort and the associated performance hit.

* Silence CLANG TIDY warnings for unit tests

Change "std::string" to "const std::string &" to avoid an
unnecessary local value copy, silencing the CLANG TIDY
process.

* Optimize formspec handling

The "formspec prepend" parameter was passed to the formspec
handling code by value, creating unnecessary copy of
std::string and slowing down the game if mods add things like
textured backgrounds for the player inventory and/or other
forms. Get rid of that performance bottleneck by converting
the parameter to a const reference.

* Optimize hotbar image handling

The code that sets the background images for the hotbar is
getting the name of the image by value, creating an
unnecessary std::string copying effort. Fix that by
converting the relevant parameters to const references.

* Optimize inventory deserialization

The inventory manager deserialization code gets the
serialized version of the inventory by value, slowing the
server and the client down when there are inventory updates.
This can get particularly troublesome with pipeworks which
adds nodes that can mess around with inventories
automatically or with mods that have mobs with inventories
that actively use them.

* Optimize texture scaling cache

There is an io::path parameter passed by value in the
procedure used to add images converted from textures,
leading to slowdown when the image is not yet created and
the conversion is thus needed. The performance hit is
quite significant as io::path is similar to std::string
so convert the parameter to a const reference to get rid of
it.

* Optimize translation file loader

Use "std::string::append" when calculating the final index
for the translation table to avoid unnecessary temporary
strings. This speeds the translation file loader up
significantly as std::string uses heap allocation which
tends to be rather slow. Additionally, the heap is no
longer being littered by these unnecessary string
temporaries, increasing performance of code that gets
executed after the translation file loader finishes.

* Optimize server map saving

When the directory structure for the world data is created
during server map saving, an unnecessary value passing of
the directory name slows things down. Remove that overhead
by converting the offending parameter to a const reference.
2019-05-18 17:19:13 +02:00
SmallJoker f409f44765 Correct the checkbox selection box position (#8246)
Remove m_btn_height dependency, replace with the text and checkbox size.
2019-04-27 00:56:31 +01:00
rubenwardy 4f7674d448 Change pitch fly binding to 'P', add to change keys menu (#8314) 2019-04-03 21:37:30 +01:00
Wuzzy 9f1b98b997 Add newline before itemstring in item tooltip (#8213) 2019-03-17 13:55:02 +01:00
Loïc Blot 02a23892f9 LINT fixes since recent tooling update 2019-03-14 12:30:13 +01:00
Loïc Blot e22a69d61a Drop GUIConfirmRegistration::m_address unused field 2019-03-12 16:53:21 +01:00
Paramat 0b492f82f7
Confirm registration GUI: Remove positional strings to fix Windows bug (#8258)
Positional strings don't work on some Windows builds.
Remove server address string, leave player name string present.
2019-03-10 01:49:03 +00:00
Benjamin Lindley e19565c170 Replace for loop with call to standard library function (#8194)
This loop makes multiple passes over m_stack (type std::list) in order to remove all elements with a specified value. Replacing the loop with a call to std::list::remove does the same job, but in only one pass.
2019-03-05 08:13:15 +01:00
random-geek 2153163cbd Fix coloured fog in main menu (#8181)
Fixes #4727. The issue was due to the video driver fog colour never getting reset after closing the game.
2019-02-15 20:44:21 +01:00
Wuzzy f5bdc04ab5 Don't append itemname to itemname in tooltip (#8176) 2019-02-09 15:46:02 +01:00
random-geek fc566e2e10 Fix cloud color in loading screen and main menu (#8174) 2019-02-04 19:11:02 +00:00
random-geek 2ae794ac45 Update color of main menu clouds (#8172) 2019-02-04 00:12:15 +01:00
rubenwardy 9a071d66a5 Fix core.download_file() creating empty files on HTTP error 2019-02-03 17:31:28 +00:00
Leonid Bobrov 339341ba4e DragonFly BSD is somewhat identical to FreeBSD (#8159) 2019-02-03 09:53:54 +01:00
rubenwardy 0990ddb3bb Android: Fix memory leak when displaying images in the mainmenu (#8011) 2018-12-22 08:46:41 +01:00
stujones11 ba07a8b872 Android: Move touchscreen rare controls inline with settings icon (#8006) 2018-12-20 21:11:57 +00:00
Juozas 94f2d99142 Fix Android build errors (caused by 5f1cd55)
After commit 5f1cd55 touchscreengui.* files were pointing to old file locations
2018-12-03 19:31:20 +01:00
Quentin Bazin 5f1cd555cd Move client-specific files to 'src/client' (#7902)
Update Android.mk
Remove 'src/client' from include_directories
2018-11-28 20:01:49 +01:00
stujones11 9519d57017 Make non-formspec modal menus respect gui scale (#7850) 2018-11-26 22:55:24 +01:00
Ben Deutsch 93bccb3490 Client-side autojump. Remove Android-only stepheight autojump (#7228)
Works by detecting a collision while moving forward and then
simulating a jump. If the simulated jump is more successful,
an artificial jump key press is injected in the client.

Includes setting and key change GUI element for enabling and
disabling this feature.
2018-11-22 21:47:15 +00:00
stujones11 3b11288989 Android: Improve UI scaling on smaller high-density displays (#7834)
* Android: Improve UI scaling on smaller high-density displays
2018-11-18 11:31:19 +01:00
number Zero b78698240c Minor changes for IrrLicht 1.9 support 2018-11-11 18:08:15 +01:00
number Zero d90e3ea88d Drop .NET-specific workaround: _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX 2018-11-11 18:08:15 +01:00
random-geek 3a992ce76d Formspecs: Fix text clipped by scrollbars (#7816) 2018-11-06 22:28:34 +00:00
stujones11 88ba1c70d3 Remove un-needed header inclusion 2018-10-29 15:37:44 +01:00
stujones11 323c860045 Move touchscreen input handling to base GUIModalMenu class 2018-10-29 15:37:44 +01:00
Paramat e369eb1a9b
Android buttons: Inset 'rare controls', inset and resize 'gear icon' (#7792)
Previously these were both inconsistently close to the screen edge.
'gear icon' has been enlarged to match the width of 'zoom' and 'aux'
buttons.
2018-10-19 04:52:47 +01:00
rubenwardy 5a26e46aaa
Formspecs: Fix invalid background warning
Clipped backgrounds are still valid with no size[] tag, as they will apply themselves correctly to any size

Fixes #7197
2018-08-20 13:56:16 +01:00
rubenwardy 28a3c4963e
Formspecs: Fix missing trim() when checking for no_prepend[] 2018-08-15 20:06:09 +01:00
rubenwardy 88efebdf86
Formspecs: Add tooltip element for area 2018-08-05 15:50:02 +01:00
SmallJoker 3b9d49b3c7
guiFormspecMenu: Allow fraction values for container[] (#7497)
Switch spacing and pos_offset to v2f32 for percision, add helper function
2018-08-04 18:55:54 +02:00
Rob Blanckaert 2b83af783b Allow enter to select items from combobox's list (#7351) 2018-07-28 12:58:16 +02:00
nOOb3167 9537cfd3f8 Add a MSVC / Windows compatible snprintf function (#7353)
Use sizeof where applicable for mt_snprintf
2018-07-22 21:56:06 +02:00
Muhammad Rifqi Priyo Susanto 7ebc229b0d Android: Add 'aux' button (#7477)
Add 'aux' button.
Use joystick to trigger 'aux' button when forward and out of main circle, by enabling
'virtual_joystick_triggers_aux' setting.
2018-07-10 23:33:40 +01:00
HybridDog 53dd781927 Fix memory leak in guiConfirmRegistration 2018-07-06 11:13:18 +02:00
Muhammad Rifqi Priyo Susanto ad3d1d20d1 Android: Resize jump and sneak buttons' touch target (#7498) 2018-06-30 22:33:14 +01:00
Loïc Blot a78659ed05 Fix more GCC 8.1 warnings   1   master
Fix 3 warnings reported by GCC 8.1 of the following type

```src/client/gameui.cpp:191:43: warning: « void* memset(void*, int, size_t) » effacement d'un objet du type non trivial « struct GameUI::Flags »; use assignment or value-initialization instead [-Wclass-memaccess]
  memset(&m_flags, 0, sizeof(GameUI::Flags));
```
2018-05-28 15:39:04 +02:00
Muhammad Rifqi Priyo Susanto 2f34797c5c Don't show Android edit dialog when tapping read-only field (#7337)
* Don't show Android edit dialog when tapping read-only field

From Lua API, "If the name is empty the textarea is readonly."
2018-05-15 16:13:30 +02:00
Vincent Glize a292d19fd0 Fix crash guiConfirmRegistration quit menu (#7313) 2018-05-10 13:50:06 +02:00
Thomas--S 9577a4396a Formspecs: Allow setting alpha value for the box[] element 2018-04-23 18:50:50 +01:00
Muhammad Rifqi Priyo Susanto b1e58c9c35 Android: Modify touch screen GUI's buttons (#7240)
* Android: Add zoom, minimap, and toggle chat button
Zoom button is put above jump button.
Minimap and toggle chat button are put in settings bar.
* Jump button is rotated down button
* Move three buttons on the right screen higher
2018-04-18 20:55:42 +02:00
Muhammad Rifqi Priyo Susanto 326eeca306 Android: Replace movement buttons with joystick (#7126)
* Android: Replace movement buttons with joystick

Replace movement control buttons (arrows at bottom left screen) with virtual joystick.
Joystick has 8 directions (same as keyboard). Basically, just map it to keyboard input.
Joystick applies only on left 1/3 of screen.
Joystick's position can be fixed by enabling fixed_virtual_joystick setting.
Three new images:
(1) placeholder joystick,
(2) joystick container (background), and
(3) joystick cursor.
Remove unused images: movement control buttons (*_arrow.png).
New data type: touch_gui_joystick_move_id

Joystick's fixed position is spaced one button size from bottom and from left of screen.
Remove unused variable: m_joystick_downlocation
2018-04-10 22:55:17 +02:00
SmallJoker baca933b6b
Selected ItemStack: Reduce black magic (#6520)
* Selected ItemStack: Reduce black magic
Better button variable value naming
2018-04-03 11:15:58 +02:00
you 12edb200eb Formspecs: Use mouse wheel to pick up and deposit single items 2018-04-02 15:52:07 +01:00
Loïc Blot d88c4e1822
LINT: add clang-tidy step (#6295)
* Implement new travis clang-tidy build step

* This step enable some rules and enforce one rule as error
* This permits to have some C++ quality rules based on clang & clang contributor guidelines

* Fix clang-tidy reported problems on push_back -> emplace_back
2018-04-01 23:57:55 +02:00
Andrew Ward 2323842dd3
Add formspec theming using prepended strings 2018-03-28 16:04:41 +01:00
nOOb3167 b0fef16a27 Guard sound manager initialization with "enable_sound" (#7167) 2018-03-26 17:44:40 +02:00
Loïc Blot 4fd9715876
Cleanup sound manager class (#7158)
* Cleanup sound manager client

* Use some const refs
* Use auto on iterators
* Drop unused parameters
* Move sound_openal.* to client folder
* Move sound.cpp + OnDemandSoundFetcher to client/ folder + reorganize includes properly
2018-03-24 15:45:25 +01:00
nOOb3167 9293d8e271 Global initialization of sound using SoundManagerGlobal (#7063)
* Global initialization of sound using SoundManagerGlobal
2018-03-23 15:31:43 +01:00
Loïc Blot 6c184947c3
Server: delegate mod management & config to ServerModConfiguration (#7131)
* Server: delegate mod management & config to ServerModConfiguration (rename it to ServerModManager)

* Use c++11 range based loops
* Add unittests + experimental/default mod as a test case to permit testing mod loading in future tests
2018-03-16 08:41:33 +01:00
Loic Blot f7938fab9f
Finally fix android build 2018-03-11 17:52:46 +01:00
Loic Blot a1c5a01142
Fix Android build, but there is a remaining linking issue in guiConfirmRegistration
* Also fix variable name overloading in guiConfirmRegistration
2018-03-11 17:45:58 +01:00
stujones11 22a891a925
Android build fixes for c++11 2018-03-11 16:56:27 +01:00
SmallJoker 473d81f2e2 Formspecs: Unify textarea and field parsing functions, fix wrong fallback text
* textarea[], field[]: Unify function, fix wrong fallback text
* Remove apparently superflous mainmenumanager.h incldue
* intlGUIEditBox.cpp: make read-only boxes really read-only
* Use elseif (trivial)
2018-03-09 23:24:57 +00:00
SmallJoker 57418111a8
Registration dialog: Larger text field with scrollbars (#7047)
Center text, text area doubled now
2018-02-23 17:01:05 +01:00
SmallJoker af89a25ff3 Fix 'Change Keys' menu crash caused by 501f936 2018-02-09 09:39:34 +01:00
Loic Blot 99c9e7a986 Game refactor [4/X]: keycache is now owned by InputHandler
* Make InputHandler own the key cache
* Add a helper function InputHandler::cancelPressed to avoid multiple similar calls in game.cpp
* Move RandomInputHandler::step definition into cpp file
2018-01-20 16:38:38 +01:00
Loic Blot 64fe79b53b Game refactor [2/X]: Various moves (profilergraph, nodePlacementPrediction, create_formspec_menu)
* Move profilergraph to dedicated files
* Move nodePlacementPrediction to Game class
* Rename create_formspec_menu to GUIFormSpecMenu::create
2018-01-20 16:38:38 +01:00
red-001 9649e47214 [CSM] Add basic HUD manipulation. (#6067)
* [CSM] Add basic HUD manipulation.

Workaround for on_connect not working right now.
2018-01-20 14:09:58 +01:00
Muhammad Rifqi Priyo Susanto 670f8afd18 Registration confirmation dialog: Fix grammar
Fixes commit 792752997c.
2018-01-13 19:30:34 +00:00
Muhammad Rifqi Priyo Susanto 792752997c Add confirmation on new player registration (#6849)
* Attempt to add registration confirmation

Using SRP auth mechanism, if server sent AUTH_MECHANISM_FIRST_SRP that means the player isn't exist.
Also tell player about the server and chosen username.
Local game has localhost as IP address of the server.
Add RenderingEngine::draw_menu_scene() to draw GUI and clouds background.
aborted -> connection_aborted

* Rewrite information message text

Client::promptConfirmRegister() -> Client::promptConfirmRegistration()
2018-01-13 12:07:16 +01:00
Loic Blot 9146c6a50f Don't recalculate statustext initial color everytime & review fixes 2018-01-05 20:59:30 +01:00
Loic Blot 3a772e7ed6 GameUI refactor (part 2/X): Move Game::guitext to GameUI + enhancements on StaticText
Other enhancements:
* C++ friendlyness for addStaticText() -> move to static StaticText::add()
2018-01-05 20:59:30 +01:00
number Zero 189daf87a0 Fix dancing text 2017-12-25 15:00:50 +01:00
Vitaliy 257626ceed Fix wrong scrolling (#6809) 2017-12-21 20:58:06 +01:00
Luis Cáceres 2b5341c518 Ensure no item stack is being held before crafting (#4779) 2017-12-06 17:32:05 +01:00
shivajiva101 3f8e2e8c38 Fix mousewheel behaviour in textarea (#6641)
Allowing scrolling with the mousewheel when the vertical scrollbar is
hidden, unnecessarily exposes oversized containers and newlines at the
end of the text. For example try scrolling over the textareas in the
pause menu. This PR addresses the issue by requiring the scrollbar to be
visible before allowing the scrolling with the mousewheel.
2017-11-18 14:58:08 +01:00
Vitaliy 20a85d76d9 Move files to subdirectories (#6599)
* Move files around
2017-11-08 23:56:20 +01:00