Add 'pushed' state to tabs, make it green
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 131 B |
@ -53,7 +53,7 @@ function crafting.register_craft(def)
|
||||
|
||||
if not minetest.registered_items[itemstack:get_name()] then
|
||||
minetest.log("warning",
|
||||
"[rp_crafting] Trying to register craft #"..itemkey.." ('" .. output
|
||||
"[rp_crafting] Trying to register craft #"..itemkey.." ('" .. output
|
||||
.. "') that has an unknown output item, allowing")
|
||||
end
|
||||
|
||||
@ -413,15 +413,17 @@ function crafting.get_formspec(name, select_craft_id)
|
||||
form = form .. "container_end[]"
|
||||
|
||||
-- Crafting guide button
|
||||
local guide_icon, guide_tip
|
||||
local guide_icon, guide_tip, guide_pushed
|
||||
if userdata[name] and userdata[name].mode == MODE_GUIDE then
|
||||
guide_icon = "ui_icon_craftingguide_active.png"
|
||||
guide_tip = S("Show only craftable recipes")
|
||||
guide_pushed = true
|
||||
else
|
||||
guide_icon = "ui_icon_craftingguide.png"
|
||||
guide_tip = S("Show all recipes")
|
||||
guide_pushed = false
|
||||
end
|
||||
form = form .. rp_formspec.tab(rp_formspec.default.size.x, 0.5, "toggle_filter", guide_icon, guide_tip, "right")
|
||||
form = form .. rp_formspec.tab(rp_formspec.default.size.x, 0.5, "toggle_filter", guide_icon, guide_tip, "right", guide_pushed)
|
||||
|
||||
return form
|
||||
end
|
||||
|
Before Width: | Height: | Size: 141 B After Width: | Height: | Size: 146 B |
Before Width: | Height: | Size: 159 B After Width: | Height: | Size: 125 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 106 B |
@ -282,18 +282,25 @@ the formspec is not closed.
|
||||
|
||||
|
||||
|
||||
### `rp_formspec.tab(x, y, name, icon, tooltip, side)`
|
||||
### `rp_formspec.tab(x, y, name, icon, tooltip, side, pushed)`
|
||||
|
||||
A sideways tab that is either at the left or right side.
|
||||
(Note: Internally, this is a button.)
|
||||
A tab can also be in 'pushed' or 'unpushed' state. A pushed tab
|
||||
is green. A tab should be in 'pushed' state when the thing it
|
||||
represents is being in use.
|
||||
|
||||
* `x`, `y`: Position
|
||||
* `name`: Internal identifier
|
||||
* `icon`: Tab icon (texture file name)
|
||||
* `tooltip`: Tooltip (optional)
|
||||
* `side`: On which side to put the tab. `"left"` or `"right"`. Default: `"left"`
|
||||
* `pushed`: Whether this tab is considered 'pushed'.
|
||||
|
||||
It is also recommended to use a different icon for both pushed and
|
||||
unpushed state.
|
||||
|
||||
(Note: Internally, this tab is a button. It has nothing to do with
|
||||
Minetest's builtin 'tabheader')
|
||||
|
||||
### `rp_formspec.fake_itemstack(x, y, itemstack)`
|
||||
|
||||
|
@ -222,23 +222,36 @@ end
|
||||
|
||||
-- Tabs
|
||||
|
||||
function rp_formspec.tab(x, y, name, icon, tooltip, side)
|
||||
function rp_formspec.tab(x, y, name, icon, tooltip, side, pushed)
|
||||
local tooltip = tooltip or ""
|
||||
local img_active
|
||||
if side == "right" then
|
||||
img_active = "[combine:16x16:0,0=(ui_tab_active.png^[transformFX):0,1="..icon
|
||||
local img_active, img_inactive
|
||||
if pushed then
|
||||
if side == "right" then
|
||||
img_active = "[combine:16x16:0,0=(ui_tab_active_pushed.png^[transformFX):0,1="..icon
|
||||
else
|
||||
img_active = "[combine:16x16:0,0=ui_tab_active_pushed.png:0,1="..icon
|
||||
end
|
||||
|
||||
if side == "right" then
|
||||
img_inactive = "(ui_tab_inactive_pushed.png^[transformFX)^"..icon
|
||||
else
|
||||
img_inactive = "ui_tab_inactive_pushed.png^"..icon
|
||||
end
|
||||
else
|
||||
img_active = "[combine:16x16:0,0=ui_tab_active.png:0,1="..icon
|
||||
if side == "right" then
|
||||
img_active = "[combine:16x16:0,0=(ui_tab_active.png^[transformFX):0,1="..icon
|
||||
else
|
||||
img_active = "[combine:16x16:0,0=ui_tab_active.png:0,1="..icon
|
||||
end
|
||||
|
||||
if side == "right" then
|
||||
img_inactive = "(ui_tab_inactive.png^[transformFX)^" .. icon
|
||||
else
|
||||
img_inactive = "ui_tab_inactive.png^" .. icon
|
||||
end
|
||||
end
|
||||
|
||||
local form = ""
|
||||
local img_inactive
|
||||
if side == "right" then
|
||||
img_inactive = "(ui_tab_inactive.png^[transformFX)^" .. icon
|
||||
else
|
||||
img_inactive = "ui_tab_inactive.png^" .. icon
|
||||
end
|
||||
|
||||
form = form .. "image_button["..x..","..y..";1,1;"
|
||||
..minetest.formspec_escape(img_inactive)
|
||||
..";"..name..";;true;false;"
|
||||
@ -442,13 +455,15 @@ local function get_invtabs(highlight)
|
||||
local tabname = registered_invtabs_order[o]
|
||||
local def = rp_formspec.registered_invtabs[tabname]
|
||||
if def then
|
||||
local icon
|
||||
local icon, pushed
|
||||
if highlight == tabname and def.icon_active then
|
||||
icon = def.icon_active
|
||||
pushed = true
|
||||
else
|
||||
icon = def.icon
|
||||
pushed = false
|
||||
end
|
||||
form = form .. rp_formspec.tab(tabx, taby, "_rp_formspec_tab_"..tabname, icon, def.tooltip)
|
||||
form = form .. rp_formspec.tab(tabx, taby, "_rp_formspec_tab_"..tabname, icon, def.tooltip, "left", pushed)
|
||||
taby = taby + tabplus
|
||||
end
|
||||
end
|
||||
|
Before Width: | Height: | Size: 91 B After Width: | Height: | Size: 91 B |
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 111 B |
BIN
mods/rp_formspec/textures/ui_tab_active_pushed.png
Normal file
After Width: | Height: | Size: 146 B |
BIN
mods/rp_formspec/textures/ui_tab_active_pushed.xcf
Normal file
BIN
mods/rp_formspec/textures/ui_tab_inactive_pushed.png
Normal file
After Width: | Height: | Size: 151 B |
BIN
mods/rp_formspec/textures/ui_tab_inactive_pushed.xcf
Normal file
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 116 B |