Commit Graph

49 Commits

Author SHA1 Message Date
Niklp
235fa841dd
Replace deprecated meta:set_string(*, nil) call 2024-06-29 16:52:32 +02:00
SmallJoker
d6d4bea819 Bags: Prevent error caused by moving the opened bag 2023-06-18 18:48:15 +02:00
luk3yx
37969b2a1b Make bags support lite mode 2023-01-12 22:16:06 +01:00
SmallJoker
177debd13c Bags: Disallow moving bags into themselves
Previously, the bag and its list would disappear immediately.
2022-09-15 12:53:41 +02:00
Vanessa Dannenberg
76c9bb9517 Use 9-slicing to build inventory-type backgrounds
This way the slots are all nice and crisp regardless of GUI scale or
image size, and we only need the single slot and its bright version.

This also makes the standard crafting grid into a style table entry that
can be referenced to insert the crafting grid at its proper
style-specific position in any formspec.

And it also makes the craft grid arrow, its X position, and the crafting
grid's result slot X position into style table entries.

Includes a few public helper functions to do most of the work:

`ui.single_slot(xpos, ypos, bright)`

    Does just what it sounds like: it returns a single slot image.
    `xpos` and `ypos` are normal coordinates in slots, as you'd use in
    `image[]` element.  `bright` is a flag that switches to the brighter
    version of the slot image.

`ui.make_trash_slot(xpos, ypos)`

    Creates a single slot, with a one-item `list[]` and a trash can icon
    overlay.

`ui.make_inv_img_grid(xpos, ypos, width, height, bright)`

    Generates a `width` by `height` grid of slot images, using the
    single_slot function above, starting at (`xpos`,`ypos`) for the
    top-left.  Position is as in any `image[]` element, and dimensions
    are in integer numbers of slots (so 8,4 would be a standard inventory).
    `bright` is as above.

All three return a string that can be directly inserted into a formspec.
2021-03-09 15:04:11 -05:00
Vanessa Dannenberg
60d7a6d213 Draw the trash slot by overlaying the bare trash can icon
over the single slot image instead of baking it in.
2021-03-09 15:04:11 -05:00
Vanessa Dannenberg
5ea0208ffe 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-09 15:04:11 -05:00
Vanessa Dannenberg
694553e68b use local "ui" to reference "unified_inventory", where practical
(makes code shorter, easier to read and write)
2021-03-09 15:04:11 -05:00
Vanessa Dannenberg
2d200eb9ae Ditto for bags. 2021-03-09 15:04:11 -05:00
Vanessa Dannenberg
603b5d1d4e get rid of uninv global
make all uses of it back into `unified_inventory.`
2021-03-09 15:04:11 -05:00
Vanessa Dannenberg
167dddaa84 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-09 15:04:11 -05:00
SmallJoker
d1a4396fbe
Fix bags backwards compatibility breakage since 4403b69 (#167) 2021-03-09 11:12:50 +01:00
Vanessa Dannenberg
fbbf786caf Tweak spacing between bags page top row and bag's inv 2021-03-01 18:57:50 +01:00
Vanessa Dannenberg
ae124b02c2 Tweak trash can icon 2021-03-01 18:57:50 +01: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
David Leal
606ba6a1a3
Add GitHub workflow (#149) 2020-03-25 18:46:35 +01:00
SmallJoker
c0bd9977be Modernize. Bags: use strings 2020-03-21 18:57:53 +01:00
Wuzzy
5327261718 Move to MT 5.0.0 translation system 2019-10-17 21:05:08 +02:00
Panquesito7
4403b696be Replace deprecated functions with newer ones (#131)
These commits makes more compatibility with MT/MTG 5.0.0+ versions.
However, these commits breaks compatibility with the 0.4-series.
2019-06-16 10:26:40 +02:00
SmallJoker
b871ccfc41 Use table.concat to build formspecs, style cleanups 2019-03-31 11:29:10 +02:00
SmallJoker
77c3de08ce Fix crash caused by bag swapping 2018-08-10 16:15:00 +02:00
codexp
3988f4c572 Merge origin/master to refactor-translation branch (resolving conflicts) 2018-06-23 15:37:13 +02:00
SmallJoker
c43074f5c2
Move bag storage to player attributes
Compatible with 0.4.16 or later
Fixes an item duplication bug for the four player inventory slots on each join
Clean up old player lists after saving
2018-06-21 21:23:21 +02:00
codexp
c1ab7277ab refactor code to use with intllib tool 2018-04-02 13:33:36 +02:00
Diego Martínez
8073df0134 bags: Add buttons to quickly switch bags in sub-form. 2017-03-24 19:48:59 -03:00
ForbiddenJ
7ab8825460 Make trash configurable but preserve default functionality 2017-03-01 16:28:40 -06:00
Vanessa Ezekowitz
029d5c4c6a avoid "leaking" detached inventories to other players (see also, 2ff48b22a9 ) 2016-11-27 04:10:10 -05:00
Diego Martínez
75a0e6a318 Bags: Code cleanup and per-bag trash slot.
* Turn page creation into a loop.
* Add per-bag trash slot.
* Changed i18n to allow replacements.
2016-11-17 19:19:51 -03:00
Vanessa Ezekowitz
8332707198 Merge pull request #61 from Wuzzy2/bagdep
Add optional farming dependency for bag craft
2016-08-07 12:57:06 -04:00
Wuzzy
1c11de10d5 Add optional farming dependency for bag craft 2016-08-06 17:44:37 +02:00
Wuzzy
c816666945 Ensure formspec escaping for translated strings 2016-08-06 17:23:46 +02:00
Wuzzy
115e0bfaf4 Collect missing strings for translation 2016-08-05 19:34:40 +02:00
BadToad2000
3cdfdd14a5 When attempting to replace a bag with a smaller bag, ensure the items beyond the last index of the smaller bag are not lost.
If there is sufficient space in the smaller bag, move the items to the front.
Otherwise disallow the replacement.
2016-02-28 23:34:13 -06:00
DonBatman
9bc6301f60 Added listring/shift click to bags 2015-10-09 18:55:46 -07: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
Brett O'Donnell
570d2cb162 peoposed update for bag recipies
when bags was first created, wool and farming were not in minetest_game, and so that people didnt have a load of dependancies I made the recipe from wood and sticks.

now that wool and cotton are available it makes a lot more sense to craft the bags from these items.

they are harder to obtain, but bags are valuable items in game, so i think the extra effort to obtain the items is justified.
2015-08-06 16:03:11 +09:30
Ardonel
d5d97e7dca Update bags.lua
changed bag recipes from default:stick to group:stick
2015-03-11 17:55:30 -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
002bcbb6d8 Add intllib support.
Some polish and german translations.
Start adding tooltips.
2014-06-21 12:44:31 +02:00
Zefram
20cf474886 Fix formspec injection issues 2014-04-29 17:53:43 +01:00
Zefram
76a2337c59 Show bag number when displaying bag contents 2014-04-29 17:19:57 +01:00
ShadowNinja
d5f60ed136 Check formname in on_receive_fields 2013-12-04 10:43:49 -05:00
Vanessa Ezekowitz
ee93afd439 Fix incorrect background colors over inventory slots
caused by BlockMen's/kahrl's inventory #hexcolor patch
( 25edae00ea )
2013-11-05 10:46:49 -05:00
ShadowNinja
04600f64d8 API tweaks 2013-10-02 23:25:07 -04:00
ShadowNinja
f974fd8c2c Update 2013-09-28 18:15:37 -04:00
RealBadAngel
e3d391d63f Update mod 2013-09-21 21:40:20 +02:00
RealBadAngel
43e308a815 New version:
another structure, its a modpack now
searches are not case sensitive
2012-12-11 00:48:23 +01:00
RealBadAngel
216078a0f8 1st release 2012-12-02 10:08:32 +01:00