Commit Graph

61 Commits

Author SHA1 Message Date
Hugues Ross 7ce21788f8
Add animated_image[] formspec element (#9258) 2020-02-15 15:33:18 +00:00
DS 1116918dbb
Formspec: Create a new class for inventorylists (#9287) 2020-02-01 13:55:13 +01:00
SmallJoker 1892ff3c0d
StaticText/EnrichedString: Styling support (#9187)
* StaticText/EnrichedString: Styling support

* Fix tooltip fg/bgcolor

* Fix default color for substr(), add unittests
2020-01-22 19:09:11 +01:00
ANAND e8fd1ce623 Replace stray tab with whitespace in guiFormSpecMenu.cpp (#9317) 2020-01-18 16:50:57 +00:00
Hugues Ross 680aaa1bd5 Make clipping of formspec elements more consistent (#9262) 2020-01-16 18:41:07 +00:00
DS 4c8af5492b Formspec: change the appeareance of the cursor on fields and co. (#8665) 2020-01-11 20:17:11 +01:00
DS 7c0e0c34ec Formspec: Fix clicking on tooltip-obstructed elements (#9266) 2020-01-04 15:45:22 +01:00
Hugues Ross b50dc43f67 Don't override the FGIMG style property if the image parameter is null 2019-12-16 19:26:57 +01:00
SmallJoker c3d0aab0bc GUIFormSpecMenu: Fix legacy sorting using std::stable_sort 2019-12-14 21:28:07 +01:00
rubenwardy 8e63d22d64 Fix spaces breaking formspec_version[] tag 2019-12-09 21:05:07 +00:00
Hugues Ross 9284313d17 Refactor to centralize GUIButton styling/rendering code (#9090) 2019-12-09 20:06:51 +00:00
DS 8f73ec6c6c Formspec: make bgcolor element less confusing and allow setting fullscreen color (#8996) 2019-12-08 18:59:30 +01:00
v-rob 4f45bfd08b Add scrollbaroptions FormSpec element (#8530) 2019-12-06 20:51:10 +00:00
SmallJoker b50a166bb0
Formspec: Fix priorities for version < 3 (#9121)
* Formspec: Fix priorities for version < 3

1) Introduce 'priority' to 'FieldSpec'
2) Sort elements based on 'priority'
3) Assign 'name' to the Item Image Button's image to show tooltips again
2019-11-20 19:39:10 +01:00
DS 5506e97ed8 Formspec: draw order and clipping for all elements (#8740) 2019-11-07 20:11:01 +01:00
Pierre-Yves Rollo 72416a6a1f Formspec: add hypertext element 2019-11-03 11:45:33 +01:00
SmallJoker a978278bfb Formspecs: Reset version number on rebuild 2019-10-20 12:44:52 +02:00
Hugues Ross 69a2099c04 Add more visual feedback for button states (#8916)
- Add style properties for overriding the the hovered/pressed state
  - By default, hovered buttons are a lighter version of the base color
  - By default, pressed buttons are a darker version of the base color
- Add hovered bg image support for image buttons (style property)
2019-10-12 18:44:23 +02:00
SmallJoker dee22104b7
Revert "Fix the bgcolor formspec element (#8716)" (#9018)
This reverts commit 1db3d252cf.
Temporary solution until a compatible solution is found to define both - formspec and fullscreen backgrounds.
2019-10-06 14:50:45 +02:00
SmallJoker c2458d3d3a label[]: Fix broken colors since 2c9edef 2019-09-29 14:52:41 +02:00
rubenwardy 07bdd6049b Fix error message caused by adding new parameter to background (#8922)
Adds background9[] element to keep backwards compatibility in formspec prepends.
2019-09-29 13:40:59 +02:00
SmallJoker 26b39f1eae
Fix some reference counters (memleak) (#8981)
Fix some reference counters (memleak)
Map::dispatchEvent: Allocation safety using references
2019-09-24 19:05:28 +02:00
DS 1db3d252cf Fix the bgcolor formspec element (#8716) 2019-09-15 17:14:31 +01:00
rubenwardy 1ea9bfc6f7 Fix formspec version backup in prepends losing data 2019-09-15 16:56:11 +01:00
SmallJoker 9acd36bf99 Formspecs: Introduce formspec_version to mods 2019-09-14 19:43:08 +02:00
SmallJoker 2c9edefde3 label[]: Fix cut-off translated text 2019-09-07 11:15:12 +02:00
Paul Ouellette 008b80fe1c Add ItemStack:get_description() to get tooltip (#8847) 2019-08-24 18:38:02 +02:00
rubenwardy 4f7fa8d417 Add formspec testing to test mod in minimal 2019-08-03 19:36:30 +01:00
rubenwardy 9541165752 Add styles to most elements 2019-08-03 19:36:30 +01:00
rubenwardy ec3795a55c Add style[] tag with button support 2019-08-03 19:36:30 +01:00
rubenwardy d1a1c5cbf0 Add custom colorable GUIButton implementation 2019-08-03 19:36:30 +01:00
rubenwardy 41ad0f4f20 Fix negative offsets not being supported by container[] 2019-08-03 16:20:15 +01:00
v-rob 5e7004e7af Add compatible, consistent coordinate system to FormSpecs. (#8524) 2019-06-27 13:40:49 +01:00
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 627a96cd99 Do not drag-place stack into 'craftpreview' slot (#8514) 2019-05-25 17:41:35 +02: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
Wuzzy 9f1b98b997 Add newline before itemstring in item tooltip (#8213) 2019-03-17 13:55:02 +01:00
Wuzzy f5bdc04ab5 Don't append itemname to itemname in tooltip (#8176) 2019-02-09 15:46:02 +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 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
stujones11 323c860045 Move touchscreen input handling to base GUIModalMenu class 2018-10-29 15:37:44 +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
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
Thomas--S 9577a4396a Formspecs: Allow setting alpha value for the box[] element 2018-04-23 18:50:50 +01: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