Use texture status indicators (#16)

This commit is contained in:
SmallJoker 2022-07-10 20:25:00 +02:00 committed by GitHub
parent 6ac1b61951
commit a05aa9a59b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 46 additions and 17 deletions

@ -5,6 +5,10 @@ hopper = {}
local MP = minetest.get_modpath(minetest.get_current_modname()) local MP = minetest.get_modpath(minetest.get_current_modname())
local S = minetest.get_translator("hopper") local S = minetest.get_translator("hopper")
hopper.translator_escaped = function(...)
return minetest.formspec_escape(S(...))
end
if minetest.get_modpath("default") then if minetest.get_modpath("default") then
hopper.formspec_bg = default.gui_bg .. default.gui_bg_img .. default.gui_slots hopper.formspec_bg = default.gui_bg .. default.gui_bg_img .. default.gui_slots
else else

@ -1,3 +1,6 @@
Code license
============
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2016 TenPlus1 and FaceDeer Copyright (c) 2016 TenPlus1 and FaceDeer
@ -19,3 +22,13 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
Texture licenses
================
SmallJoker/Krock (CC0)
* hopper_mode_*.png (created with LibreOffice Draw)

@ -1,11 +1,14 @@
local S = minetest.get_translator("hopper") local S = minetest.get_translator("hopper")
local FS = hopper.translator_escaped
local function get_chute_formspec(pos) local function get_chute_formspec(pos)
local spos = hopper.get_string_pos(pos) local spos = hopper.get_string_pos(pos)
local formspec = local formspec =
"size[8,7]" "size[8,7]"
.. hopper.formspec_bg .. hopper.formspec_bg
.. "list[nodemeta:" .. spos .. ";main;3,0.3;2,2;]" .. "label[3,-0.1;" .. FS("Hopper Chute") .."]"
.. hopper.get_eject_button_texts(pos, 7, 0.8) .. "list[nodemeta:" .. spos .. ";main;3,0.4;2,2;]"
.. hopper.get_eject_button_texts(pos, 6, 0.8)
.. "list[current_player;main;0,2.85;8,1;]" .. "list[current_player;main;0,2.85;8,1;]"
.. "list[current_player;main;0,4.08;8,3;8]" .. "list[current_player;main;0,4.08;8,3;8]"
.. "listring[nodemeta:" .. spos .. ";main]" .. "listring[nodemeta:" .. spos .. ";main]"

@ -1,4 +1,6 @@
local S = minetest.get_translator("hopper") local S = minetest.get_translator("hopper")
local FS = hopper.translator_escaped
local ALPHA_CLIP = minetest.features.use_texture_alpha_string_modes and "clip" or true
-- formspec -- formspec
local function get_hopper_formspec(pos) local function get_hopper_formspec(pos)
@ -6,8 +8,9 @@ local function get_hopper_formspec(pos)
local formspec = local formspec =
"size[8,9]" "size[8,9]"
.. hopper.formspec_bg .. hopper.formspec_bg
.. "list[nodemeta:" .. spos .. ";main;2,0.3;4,4;]" .. "label[3.5,-0.1;" .. FS("Hopper") .."]"
.. hopper.get_eject_button_texts(pos, 7, 2) .. "list[nodemeta:" .. spos .. ";main;2,0.4;4,4;]"
.. hopper.get_eject_button_texts(pos, 6.5, 2)
.. "list[current_player;main;0,4.85;8,1;]" .. "list[current_player;main;0,4.85;8,1;]"
.. "list[current_player;main;0,6.08;8,3;8]" .. "list[current_player;main;0,6.08;8,3;8]"
.. "listring[nodemeta:" .. spos .. ";main]" .. "listring[nodemeta:" .. spos .. ";main]"
@ -68,6 +71,7 @@ minetest.register_node("hopper:hopper", {
"hopper_top_" .. hopper.config.texture_resolution .. ".png", "hopper_top_" .. hopper.config.texture_resolution .. ".png",
"hopper_front_" .. hopper.config.texture_resolution .. ".png" "hopper_front_" .. hopper.config.texture_resolution .. ".png"
}, },
use_texture_alpha = ALPHA_CLIP,
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
@ -160,6 +164,7 @@ minetest.register_node("hopper:hopper_side", {
"hopper_back_" .. hopper.config.texture_resolution .. ".png", "hopper_back_" .. hopper.config.texture_resolution .. ".png",
"hopper_back_" .. hopper.config.texture_resolution .. ".png" "hopper_back_" .. hopper.config.texture_resolution .. ".png"
}, },
use_texture_alpha = ALPHA_CLIP,
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {

@ -1,4 +1,5 @@
local S = minetest.get_translator("hopper") local S = minetest.get_translator("hopper")
local FS = hopper.translator_escaped
local facedir_to_bottomdir = { local facedir_to_bottomdir = {
[0]={x=0, y=-1, z=0}, [0]={x=0, y=-1, z=0},
@ -18,15 +19,15 @@ local function get_sorter_formspec(pos)
local filter_all = minetest.get_meta(pos):get_string("filter_all") == "true" local filter_all = minetest.get_meta(pos):get_string("filter_all") == "true"
local y_displace = 0 local y_displace = 0
local filter_button_text, filter_button_tooltip, filter_body local filter_texture, filter_button_tooltip, filter_body
if filter_all then if filter_all then
filter_body = "" filter_body = ""
filter_button_text = S("Selective\nFilter") filter_texture = "hopper_mode_off.png"
filter_button_tooltip = S("This sorter is currently set to try sending all items\nin the direction of the arrow. Click this button\nto enable an item-type-specific filter.") filter_button_tooltip = FS("This sorter is currently set to try sending all items\nin the direction of the arrow. Click this button\nto enable an item-type-specific filter.")
else else
filter_body = "label[3.7,0;"..S("Filter").."]list[nodemeta:" .. spos .. ";filter;0,0.5;8,1;]" filter_body = "label[3.7,0;"..FS("Filter").."]list[nodemeta:" .. spos .. ";filter;0,0.5;8,1;]"
filter_button_text = S("Filter\nAll") filter_texture = "hopper_mode_on.png"
filter_button_tooltip = S("This sorter is currently set to only send items listed\nin the filter list in the direction of the arrow.\nClick this button to set it to try sending all\nitems that way first.") filter_button_tooltip = FS("This sorter is currently set to only send items listed\nin the filter list in the direction of the arrow.\nClick this button to set it to try sending all\nitems that way first.")
y_displace = 1.6 y_displace = 1.6
end end
@ -35,7 +36,8 @@ local function get_sorter_formspec(pos)
.. hopper.formspec_bg .. hopper.formspec_bg
.. filter_body .. filter_body
.. "list[nodemeta:" .. spos .. ";main;3,".. tostring(0.3 + y_displace) .. ";2,2;]" .. "list[nodemeta:" .. spos .. ";main;3,".. tostring(0.3 + y_displace) .. ";2,2;]"
.. "button_exit[7,".. tostring(0.8 + y_displace) .. ";1,1;filter_all;".. filter_button_text .. "]tooltip[filter_all;" .. filter_button_tooltip.. "]" .. ("image_button_exit[0,%g;1,1;%s;filter_all;]"):format(y_displace, filter_texture)
.. "tooltip[filter_all;" .. filter_button_tooltip.. "]"
.. hopper.get_eject_button_texts(pos, 6, 0.8 + y_displace) .. hopper.get_eject_button_texts(pos, 6, 0.8 + y_displace)
.. "list[current_player;main;0,".. tostring(2.85 + y_displace) .. ";8,1;]" .. "list[current_player;main;0,".. tostring(2.85 + y_displace) .. ";8,1;]"
.. "list[current_player;main;0,".. tostring(4.08 + y_displace) .. ";8,3;8]" .. "list[current_player;main;0,".. tostring(4.08 + y_displace) .. ";8,3;8]"

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
textures/hopper_mode_on.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

@ -1,4 +1,5 @@
local S = minetest.get_translator("hopper") local S = minetest.get_translator("hopper")
local FS = hopper.translator_escaped
-- Target inventory retrieval -- Target inventory retrieval
-- looks first for a registration matching the specific node name, then for a registration -- looks first for a registration matching the specific node name, then for a registration
@ -26,15 +27,16 @@ end
hopper.get_eject_button_texts = function(pos, loc_X, loc_Y) hopper.get_eject_button_texts = function(pos, loc_X, loc_Y)
if not hopper.config.eject_button_enabled then return "" end if not hopper.config.eject_button_enabled then return "" end
local eject_button_text, eject_button_tooltip local texture, eject_button_tooltip
if minetest.get_meta(pos):get_string("eject") == "true" then if minetest.get_meta(pos):get_string("eject") == "true" then
eject_button_text = S("Don't\nEject") texture = "hopper_mode_eject.png"
eject_button_tooltip = S("This hopper is currently set to eject items from its output\neven if there isn't a compatible block positioned to receive it.\nClick this button to disable this feature.") eject_button_tooltip = FS("This hopper is currently set to eject items from its output\neven if there isn't a compatible block positioned to receive it.\nClick this button to disable this feature.")
else else
eject_button_text = S("Eject\nItems") texture = "hopper_mode_hold.png"
eject_button_tooltip = S("This hopper is currently set to hold on to item if there\nisn't a compatible block positioned to receive it.\nClick this button to have it eject items instead.") eject_button_tooltip = FS("This hopper is currently set to hold on to item if there\nisn't a compatible block positioned to receive it.\nClick this button to have it eject items instead.")
end end
return "button_exit["..loc_X..","..loc_Y..";1,1;eject;"..eject_button_text.."]tooltip[eject;"..eject_button_tooltip.."]" return ("image_button_exit[%g,%g;1,1;%s;eject;]"):format(loc_X, loc_Y, texture) ..
"tooltip[eject;"..eject_button_tooltip.."]"
end end
hopper.get_string_pos = function(pos) hopper.get_string_pos = function(pos)