Commit Graph

62 Commits

Author SHA1 Message Date
Vanessa Dannenberg
51de368949 using a table.copy() to pass the style tables around requires
setting-up items_per_page, standard_inv, and standard_inv_bg
for both tables at init time.
2021-03-08 05:10:16 -05:00
Vanessa Dannenberg
e61ae0e149 always modify and return a table.copy() of the style table 2021-03-08 05:10:00 -05:00
Vanessa Dannenberg
62881d9938 Multiple related changes to string handling
1) Convert most formspec elements to use string.format(), when the
result would be more readable, or less messy, or at least makes the line
shorter, assuming it looked like it really needed it to begin with.

2) Convert all long `foo..","..bar..";"..baz..bleh..` types of excessive
string concatenation into tables that then get concated only once, when
their containing functions return the final formspec string.

3) In some places in the code, such tables were already being used, and
were named "formspec", while others were named "fs".  I settled on just
one name, "formspec", as it's more readable, if longer.

4) There was a mix of styles of adding items to those tables:

* Some places used line after line of `t[#t + 1] = foo/bar/baz`.
* Others places used the form `t[1] = foo, t[2] = bar, ...`.
* Still others used the form `t[n] = foo, t[n+1] = bar...`,
  with `n` being increased or reset every so often.

Most of them should now be of the third form, with a few of the second.
2021-03-08 05:10:00 -05:00
Vanessa Dannenberg
55692900f9 use local "ui" to reference "unified_inventory", where practical
(makes code shorter, easier to read and write)
2021-03-08 05:10:00 -05:00
Vanessa Dannenberg
4d52ebe774 put style-specific settings in their own tables
and switch between them directly, instead of copy-and-modify.
2021-03-08 05:10:00 -05:00
Vanessa Dannenberg
73ce55646c "Please continue to use string.format here to avoid messy code"
Derp :-)
2021-03-08 05:10:00 -05:00
Vanessa Dannenberg
4b39bc86cb fix indent 2021-03-08 05:10:00 -05:00
Vanessa Dannenberg
0df814d9d4 remove a used-only-once variable 2021-03-08 05:10:00 -05:00
Vanessa Dannenberg
8056bdf966 use string.format() to create the standard_inv variables
do it just once, after the lite mode settings are applied
(if applicable)
2021-03-08 05:10:00 -05:00
Vanessa Dannenberg
7e27f584eb get rid of uninv global
make all uses of it back into `unified_inventory.`
2021-03-08 05:09:54 -05:00
Vanessa Dannenberg
5140853a3a increase spacing around the text above the items page
("Filter:" and its search key, and the page or "No matches)
Adjust main and page flipping buttons' positions to compensate
2021-03-07 04:26:11 -05:00
Vanessa Dannenberg
a0c06516f4 increase size and tweak position of "give/to grid" buttons
and make them vary in pos with lite vs full mode
2021-03-07 04:13:36 -05:00
Vanessa Dannenberg
5ec4b986bb shift the craft grid and guide down a bit
to make more room for the result string
(and shift the result string down a hair to follow)
2021-03-07 03:57:39 -05:00
Vanessa Dannenberg
eb6697aa0d remove a couple of unused variables 2021-03-06 16:37:35 -05:00
Vanessa Dannenberg
e8e1d4d705 Convert over to formspec version 4
I recreated the original layout as best as practical, but by necessity
there are a few minor positioning changes, since the underlying
hard-wired inventory slots are square now and image positioning is now
scaled by exactly 1.250 in both dimensions (as opposed to roughly 1.25
by 1.16).

Backstage, I also needed to fix the aspect ratios of the various
inventory slot elements.  That meant redesigning the single-slot image
from scratch.  It was already blurry/grainy and a little ugly, and
trying to alter it would have only made it worse.

The slot image is now exactly 56x56 pixels square, set on a 64x64
canvas, so there's a 4 pixel empty space around the edges. The full
256px .xcf workfile is included in the UI folder.

I've re-tiled all slot/inv images from the new single slot.

I also re-rendered the trash can icon from it since it was blurry and
oddly-sized. I couldn't find the original upstream image, so since
they're free, I used one of my Linux system's icons which happens to
resemble it.

I also removed a couple more improper uses of `background[]` where
`image[]` is more appropriate.

There are tons of minor tweaks throughout the code to re-align
everything, and I had to rewrite a few sections to avoid code
duplication and to allow for a little more flexibility (mainly to make
"lite" mode look right).
2021-03-06 13:22:20 -05:00
Vanessa Dannenberg
ebd1d1f245 Improve consistency of inventory (and alike) imagery
In a number of places, background[] is misused to place the
inventory backdrop images.  Where appropriate, image[] is used
instead, so that "ui_form_bg.png" actually serves as the one
and only true background image.

In so doing, I was able to remake the bag inventory images,
making them only big as is actually needed to hold 1, 2, or 3
rows of inventory slots.

This, in turn, allows a standardized main inventory image to
occupy the lower part of the window, which allows for
consistent inventory image positioning and sizing from one
page to another.

I also removed ui_misc_form.png.  Nothing in UI uses it, and
any external mods that used it can just use the standard
inventory and its background.

Lastly, I reduced the background image to 512x384 px.  It was
unnecessarily large before, considering it has no real detail.

The larger inventory images are all 512px wide, and multiples
of 64px in height.  Before, they were oddly sized.
2021-03-01 18:57:50 +01:00
Louis Royer
341a438267
Search items by English and translated description (#156)
This works only with Minetest version >= 5.3.0, nothing is changed for
older versions.
2020-07-15 20:21:06 +02:00
David Leal
606ba6a1a3
Add GitHub workflow (#149) 2020-03-25 18:46:35 +01:00
Wuzzy
8e74a80e91 Translation: Fix parameter symbols 2019-10-17 21:05:08 +02:00
Wuzzy
5327261718 Move to MT 5.0.0 translation system 2019-10-17 21:05:08 +02:00
Scott Horvath
86d2a11643 Allow all players to view items regardless of 'creative' priv
This allows any player to see usages of items found
even if item does not have explicit
recipies themselves.
(ex: default:papyrus, found/grown in wild, can be made into paper)
2019-05-28 21:30:55 +02:00
Emiel van Rooijen
16babc54f3 Add no_prepend[] by default 2019-03-31 12:19:08 +02:00
SmallJoker
54abad72f0 Add item tooltips with mod name
Inspired by #118, @Quent42340
2018-12-12 20:20:11 +01:00
codexp
c1ab7277ab refactor code to use with intllib tool 2018-04-02 13:33:36 +02:00
shivajiva101
2ab5a7c90a fix excessive privilege check 2018-01-03 11:15:53 +01:00
Diego Martínez
2ea417fad0 Search when ENTER is pressed on the search field. 2016-11-29 17:35:40 -03:00
Wuzzy
8770b7df93 Disable useless main buttons 2016-11-06 02:28:45 +01:00
Wuzzy
2a516ac22b Add seperate button for resetting search 2016-08-14 23:35:12 +02:00
Vanessa Ezekowitz
54d97635ec Merge pull request #64 from Wuzzy2/flipclick
Toggle recipe/usage mode in craft guide when clicking on current item in item list
2016-08-07 12:57:29 -04:00
Wuzzy
7bba35a911 Flip craft mode when clicking current item in list 2016-08-07 02:14:46 +02:00
Wuzzy
c816666945 Ensure formspec escaping for translated strings 2016-08-06 17:23:46 +02:00
Vanessa Ezekowitz
9fe84789ba Allow per-user "full" mode when "lite" mode is set as global
default (give the user "ui_full" priv to turn it on).

Also, a few whitespace fixes.
2015-10-05 04:24:01 -04:00
HybridDog
babe4380ac disallow repairing tools using the 'to craft grid', allow it to put items of specific groups and (maybe) make it keep the meta of items, remove unused elseif, change a bit translation and use table.concat at one place because I read somewhere that it's faster than .. 2015-08-16 16:40:49 +02:00
Vanessa Ezekowitz
2d6a0ed606 split ui_crafting_form
into craft grid/trash image and a single slot image.  The latter is now
used for a refill slot if user has creative priv or server is in
creative mode.
2015-08-05 08:37:25 -04:00
Vanessa Ezekowitz
f2914b3d4f only show items in crafting guide if they can be crafted or player has creative 2015-07-30 09:13:16 -04:00
Vanessa Ezekowitz
8338b406d3 fix crash in waypoints? 2015-06-28 05:17:43 -04:00
Vanessa Ezekowitz
16e40a2e22 re-arrange a few elements in the crafting guide to eliminate text overlap
Also make sure to chech if lite mode before assuming 4x2 "tab" button layout.
2015-06-28 04:54:48 -04:00
Vanessa Ezekowitz
0a70d8edef Add "lite" mode
Set unified_inventory_lite = true in minetest.conf to enable.

This mode reduces the feature-set of the mod as follows:

* no bags
* no waypoints,
* no home/go-home buttons,
* no set-day/-night buttons,
* smaller creative/craft guide inventory pages (4x6 instead of 8x10)
* fewer paging buttons
* smaller search field
* move "Result: foo" to below the crafting guide grid.
* Move main "tab" buttons to the right, below the search and paging buttons.
* Made "tab" buttons able to use to 2 rows if necessary (max 8 buttons)
2015-06-28 04:15:55 -04:00
Tim
76a9efff71 reduce table lookups during initialization 2015-02-05 10:03:07 +01:00
Tim
1a1bfc3839 supress intllib check warning, this fixes #19 2015-02-05 10:00:10 +01:00
RealBadAngel
0d777362f3 Update tooltips usage due to core changes. 2014-06-24 12:39:12 +02:00
RealBadAngel
f800f39083 More tooltips and translations. 2014-06-22 00:34:35 +02:00
RealBadAngel
002bcbb6d8 Add intllib support.
Some polish and german translations.
Start adding tooltips.
2014-06-21 12:44:31 +02:00
Zefram
87f502a259 Show item usages in craft guide
When the craft guide is showing a craft, the output slot is now a button,
which causes the craft guide to show ways in which that output can be
used.  This mirrors the way input slots are buttons that show recipes
for the selected ingredient.  Usages of an item can be iterated through
in the same way as recipes for the item.  This incidentally offers some
ability to retrace one's steps through a crafting chain, without storing
actual history.
2014-06-13 11:30:09 -03:00
Zefram
a8c8ef0890 Correctly display multi-group ingredients
Extend the representative-item logic to handle ingredients specified
as the intersection of multiple groups.  Also add mangling of item
button content, because comma for a multi-group ingredient is getting
formspec-escaped and then not de-escaped.
2014-06-13 09:28:37 -03:00
Zefram
7f4f0fd225 Use plain substring search in craft guide
The user input was being erroneously treated as a lua regexp.
2014-06-13 04:50:07 -03:00
RealBadAngel
3003b19322 Add sorting inventories function. 2014-05-22 21:24:24 +02:00
Zefram
79320c109c Respect not_in_creative_inventory in group search 2014-05-02 12:21:10 +02:00
Zefram
b0e10d44f4 Tweak display of searching status
When the current search produces no results, give a specific message
rather than "Page 1 of 0".  Don't display the "Filter:" label if no
filtering is currently applied.
2014-04-29 20:08:04 +01:00
Zefram
01297996a6 Preserve player's search string
Keep the current inventory search string when performing inventory
form actions other than searching.  This means the player's input is
not lost if the player breaks off from entering it to switch pages,
or if the player absent-mindedly ends text input with <return>.
2014-04-29 19:36:52 +01:00