Commit Graph

91 Commits

Author SHA1 Message Date
SmallJoker
1b074828a6 Document and replace sounds
A few sounds were replaced because I could not find them on freesound.org
2023-01-10 21:27:56 +01:00
luk3yx
b590764026
Centre page number label and move refill/trash labels (#221)
* Centre page number label

* Move refill and trash labels
2023-01-04 14:35:46 +01:00
SmallJoker
8e9ea34ae8 Elaborate the use of NS() 2022-09-15 10:56:01 +02:00
Thomas--S
574de91971
Craft guide: Add support for colored items (#213) 2022-09-15 10:48:29 +02:00
Oversword
d6688872c8
Fix two occasional runtime errors (#191) 2021-12-25 17:31:18 +01:00
OgelGames
28a5d4db49
Show wear and description in crafting guide (#189) 2021-11-21 19:42:54 +01:00
Vanessa Dannenberg
608cdfb887 fix refill slot list[] offset also 2021-03-10 12:32:55 -05:00
Vanessa Dannenberg
2c16805ef9 Get rid of the image button left of the crafting guide
It had the same function as clicking the craft result on the
right (just inverted), making it redundant. Click either one more
than once and UI would alternately show usages or recipes.
2021-03-09 15:04:11 -05:00
Vanessa Dannenberg
dc61d2980a Move craft guide a little to the right to make some room. 2021-03-09 15:04:11 -05:00
Vanessa Dannenberg
8ee0eb9fce swap the craft type icon with its word
(makes it look like it used to)
2021-03-09 15:04:11 -05:00
Vanessa Dannenberg
b8a568d7eb remove unused var, excess whitespace 2021-03-09 15:04:11 -05: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
8e94d86420 don't display the refill slot image if no creative priv/mode
(leftover from when it was part of the craft grid image)

Also fixed a typo in the corresponding list[] element that
made it not work.
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
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
97960c552b increase size and tweak position of "give/to grid" buttons
and make them vary in pos with lite vs full mode
2021-03-09 15:04:11 -05:00
Vanessa Dannenberg
7a0a44037a remove a couple of unused variables 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
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
Maksim
f25426911d
Fix teleport sounds when teleport fails (#155) 2020-07-10 21:58:45 +02:00
CarlosBarrazaE
eb96c89b5d
Update the Spanish language (#144)
Complete missing translations; error corrections.

Co-authored-by: David Leal <halfpacho@gmail.com>
2020-05-01 18:15:08 +02:00
Andrey Kozlovskiy
ca6d9a10df Implement new crafting algorithm (#132)
* Implement new crafting algorithm

* Take craft width into account when creating craft index
* Fix moving logic, correctly check for empty stacks
* Return early when there's not enough items for craft
* Bound match_count with smallest stack_max value, take from inventory only if needed
* Continue if item can't be moved to the current position.
* Fix metadata loss and. Improve placement for some corner cases.
* Drop items from oversized stacks on the ground
* Place items exactly as displayed in the guide
* One source list one destination. Try to take from destination list first
2019-10-26 17:22:33 +02: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
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
e9b4b52dc1 Biggest stacks first, smallest as late as possible
Split stacks ~evenly
Fast skip occupied slots
2019-03-30 22:53:36 +01:00
SmallJoker
bcb96d6caf Improve craftguide_craft() speed: Move stacks 2019-03-30 22:53:36 +01:00
SmallJoker
850ee9cbc0 Improve callback execution, add giveme guards 2019-02-17 15:14:38 +01:00
codexp
3988f4c572 Merge origin/master to refactor-translation branch (resolving conflicts) 2018-06-23 15:37:13 +02:00
SmallJoker
edd00f222c Replace deprecated function names, unify creative check 2018-06-23 15:02:23 +02:00
codexp
934757edd6 FIX: do not translate direction 2018-04-08 22:21:44 +02:00
codexp
c1ab7277ab refactor code to use with intllib tool 2018-04-02 13:33:36 +02:00
ForbiddenJ
7ab8825460 Make trash configurable but preserve default functionality 2017-03-01 16:28:40 -06:00
Vanessa Ezekowitz
2e00206f58 Merge pull request #81 from Wuzzy2/master
Disable useless main buttons
2016-11-27 13:36:02 -05:00
Vanessa Ezekowitz
e57a5f80b4 Merge pull request #80 from Wuzzy2/give
Also enable “Give me” for creative mode and priv
2016-11-27 13:31:12 -05:00
Wuzzy
8770b7df93 Disable useless main buttons 2016-11-06 02:28:45 +01:00
Wuzzy
a661f54e72 Also enable “Give me” for creative mode and priv 2016-11-06 01:48:05 +01:00
Wuzzy
8e98b00021 Also show “real” item name in craft result 2016-10-29 14:20:11 +02:00
Wuzzy
15f5b8e804 Craftguide: Use better tooltips for group buttons 2016-08-14 23:36:12 +02:00
Wuzzy
0678056716 Fix horizontally flipped crafting recipes in guide 2016-08-14 13:17:41 +02:00
Wuzzy
3bc3fae648 Hide “To crafting grid:” for crafts with size > 3 2016-08-14 13:16:30 +02:00
Wuzzy
2ef76af687 Apply size optimizations for large craftings
Also prevent huge crafting recipes from being displayed for stability reasons.
2016-08-14 13:16:30 +02:00
Wuzzy
c1fcc06059 Fix horizontal craft guide offset for large crafts 2016-08-14 13:16:30 +02:00
Wuzzy
f8082a0e35 Fix crafting guide grid button sizes for size>4 2016-08-14 13:16:30 +02:00
Wuzzy
5c57915159 Attempt to make large crafting recipes displayable 2016-08-14 13:16:30 +02:00
Wuzzy
a1e7b650ab Guide: Allow to move back and forth in alternates 2016-08-14 10:56:24 +02:00
Vanessa Ezekowitz
23a27b38ae Revert "Show real item name in craft guide"
Players don't really like this, neither do I.
See the comments attached to the original commit.
Sorry, Wuzzy. :-(

This reverts commit fe00059eeade4bf0714df9369ba57e2bc60ad3bf.
2016-08-13 18:19:29 -04:00