diff --git a/init.lua b/init.lua index 3899fba..5134374 100644 --- a/init.lua +++ b/init.lua @@ -5,6 +5,10 @@ hopper = {} local MP = minetest.get_modpath(minetest.get_current_modname()) local S = minetest.get_translator("hopper") +hopper.translator_escaped = function(...) + return minetest.formspec_escape(S(...)) +end + if minetest.get_modpath("default") then hopper.formspec_bg = default.gui_bg .. default.gui_bg_img .. default.gui_slots else diff --git a/license.txt b/license.txt index 682768d..94ccf26 100644 --- a/license.txt +++ b/license.txt @@ -1,3 +1,6 @@ +Code license +============ + The MIT License (MIT) 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, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +Texture licenses +================ + + +SmallJoker/Krock (CC0) + + * hopper_mode_*.png (created with LibreOffice Draw) diff --git a/nodes/chute.lua b/nodes/chute.lua index c380733..21e1125 100644 --- a/nodes/chute.lua +++ b/nodes/chute.lua @@ -1,11 +1,14 @@ local S = minetest.get_translator("hopper") +local FS = hopper.translator_escaped + local function get_chute_formspec(pos) local spos = hopper.get_string_pos(pos) local formspec = "size[8,7]" .. hopper.formspec_bg - .. "list[nodemeta:" .. spos .. ";main;3,0.3;2,2;]" - .. hopper.get_eject_button_texts(pos, 7, 0.8) + .. "label[3,-0.1;" .. FS("Hopper Chute") .."]" + .. "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,4.08;8,3;8]" .. "listring[nodemeta:" .. spos .. ";main]" diff --git a/nodes/hoppers.lua b/nodes/hoppers.lua index 5e4ff91..d08d63e 100644 --- a/nodes/hoppers.lua +++ b/nodes/hoppers.lua @@ -1,4 +1,6 @@ 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 local function get_hopper_formspec(pos) @@ -6,8 +8,9 @@ local function get_hopper_formspec(pos) local formspec = "size[8,9]" .. hopper.formspec_bg - .. "list[nodemeta:" .. spos .. ";main;2,0.3;4,4;]" - .. hopper.get_eject_button_texts(pos, 7, 2) + .. "label[3.5,-0.1;" .. FS("Hopper") .."]" + .. "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,6.08;8,3;8]" .. "listring[nodemeta:" .. spos .. ";main]" @@ -68,6 +71,7 @@ minetest.register_node("hopper:hopper", { "hopper_top_" .. hopper.config.texture_resolution .. ".png", "hopper_front_" .. hopper.config.texture_resolution .. ".png" }, + use_texture_alpha = ALPHA_CLIP, node_box = { type = "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" }, + use_texture_alpha = ALPHA_CLIP, node_box = { type = "fixed", fixed = { diff --git a/nodes/sorter.lua b/nodes/sorter.lua index ac86332..5f0858c 100644 --- a/nodes/sorter.lua +++ b/nodes/sorter.lua @@ -1,4 +1,5 @@ local S = minetest.get_translator("hopper") +local FS = hopper.translator_escaped local facedir_to_bottomdir = { [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 y_displace = 0 - local filter_button_text, filter_button_tooltip, filter_body + local filter_texture, filter_button_tooltip, filter_body if filter_all then filter_body = "" - filter_button_text = S("Selective\nFilter") - 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_texture = "hopper_mode_off.png" + 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 - filter_body = "label[3.7,0;"..S("Filter").."]list[nodemeta:" .. spos .. ";filter;0,0.5;8,1;]" - filter_button_text = S("Filter\nAll") - 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_body = "label[3.7,0;"..FS("Filter").."]list[nodemeta:" .. spos .. ";filter;0,0.5;8,1;]" + filter_texture = "hopper_mode_on.png" + 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 end @@ -35,7 +36,8 @@ local function get_sorter_formspec(pos) .. hopper.formspec_bg .. filter_body .. "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) .. "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]" diff --git a/textures/hopper_mode_eject.png b/textures/hopper_mode_eject.png new file mode 100644 index 0000000..3ad0870 Binary files /dev/null and b/textures/hopper_mode_eject.png differ diff --git a/textures/hopper_mode_hold.png b/textures/hopper_mode_hold.png new file mode 100644 index 0000000..f9ab0c4 Binary files /dev/null and b/textures/hopper_mode_hold.png differ diff --git a/textures/hopper_mode_off.png b/textures/hopper_mode_off.png new file mode 100644 index 0000000..825731a Binary files /dev/null and b/textures/hopper_mode_off.png differ diff --git a/textures/hopper_mode_on.png b/textures/hopper_mode_on.png new file mode 100644 index 0000000..67fad41 Binary files /dev/null and b/textures/hopper_mode_on.png differ diff --git a/utility.lua b/utility.lua index 2075017..0e8c646 100644 --- a/utility.lua +++ b/utility.lua @@ -1,4 +1,5 @@ local S = minetest.get_translator("hopper") +local FS = hopper.translator_escaped -- Target inventory retrieval -- 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) 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 - eject_button_text = S("Don't\nEject") - 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.") + texture = "hopper_mode_eject.png" + 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 - eject_button_text = S("Eject\nItems") - 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.") + texture = "hopper_mode_hold.png" + 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 - 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 hopper.get_string_pos = function(pos)