Redo gaming formspec to no longer use large backgrounds

This commit is contained in:
MoNTE48 2020-03-03 16:11:59 +01:00
parent 519c2589ed
commit 490b99312f
16 changed files with 50 additions and 15 deletions

View File

@ -2,27 +2,34 @@
-- Formspecs -- Formspecs
-- --
function default.get_furnace_active_formspec(fuel_percent) function default.get_furnace_active_formspec(fuel_percent, item_percent)
return default.gui .. return default.gui ..
"background[-0.2,-0.26;9.41,9.49;formspec_furnace.png]" ..
"item_image[0,-0.1;1,1;default:furnace_active]" .. "item_image[0,-0.1;1,1;default:furnace_active]" ..
"label[0.9,0.1;" .. Sl("Furnace") .. "]" .. "label[0.9,0.1;" .. Sl("Furnace") .. "]" ..
"item_image[3,0.5;1,1;default:cell]" ..
"list[context;src;3,0.5;1,1;]" .. "list[context;src;3,0.5;1,1;]" ..
"item_image[3,2.5;1,1;default:cell]" ..
"list[context;fuel;3,2.5;1,1;]" .. "list[context;fuel;3,2.5;1,1;]" ..
"image[3,1.5;1,1;default_furnace_fire_bg.png^[lowpart:" .. "image[3,1.5;1,1;default_furnace_fire_bg.png^[lowpart:" ..
fuel_percent .. ":default_furnace_fire_fg.png]" .. fuel_percent .. ":default_furnace_fire_fg.png]" ..
"image[4,1.5;1,1;default_arrow_bg.png^[lowpart:" ..
item_percent ..":default_arrow_fg.png^[transformR270]" ..
"item_image[4.925,1.425;1.2,1.2;default:cell]" ..
"list[context;dst;5,1.5;1,1;]" .. "list[context;dst;5,1.5;1,1;]" ..
"list[context;split;8,3.14;1,1;]" "list[context;split;8,3.14;1,1;]"
end end
function default.get_furnace_inactive_formspec() function default.get_furnace_inactive_formspec()
return default.gui .. return default.gui ..
"background[-0.2,-0.26;9.41,9.49;formspec_furnace.png]" ..
"item_image[0,-0.1;1,1;default:furnace]" .. "item_image[0,-0.1;1,1;default:furnace]" ..
"label[0.9,0.1;" .. Sl("Furnace") .. "]" .. "label[0.9,0.1;" .. Sl("Furnace") .. "]" ..
"item_image[3,0.5;1,1;default:cell]" ..
"list[context;src;3,0.5;1,1;]" .. "list[context;src;3,0.5;1,1;]" ..
"item_image[3,2.5;1,1;default:cell]" ..
"list[context;fuel;3,2.5;1,1;]" .. "list[context;fuel;3,2.5;1,1;]" ..
"image[3,1.5;1,1;default_furnace_fire_bg.png]" .. "image[3,1.5;1,1;default_furnace_fire_bg.png]" ..
"image[4,1.5;1,1;default_arrow_bg.png^[transformR270]" ..
"item_image[4.925,1.425;1.2,1.2;default:cell]" ..
"list[context;dst;5,1.5;1,1;]" .. "list[context;dst;5,1.5;1,1;]" ..
"list[context;split;8,3.14;1,1;]" "list[context;split;8,3.14;1,1;]"
end end
@ -61,7 +68,11 @@ local function allow_metadata_inventory_put(pos, listname, _, stack, player)
return 0 return 0
end end
elseif listname == "src" then elseif listname == "src" then
return stack:get_count() if minetest.get_craft_result({method="cooking", width=1, items={stack}}).time ~= 0 then
return stack:get_count()
else
return 0
end
elseif listname == "dst" then elseif listname == "dst" then
return 0 return 0
elseif listname == "split" then elseif listname == "split" then

View File

@ -14,12 +14,19 @@ default = {
} }
} }
minetest.register_craftitem("default:cell", {
inventory_image = "formspec_cell.png",
groups = {craftguide_cell = 1}
})
default.gui_bg = "bgcolor[#08080880;true]" default.gui_bg = "bgcolor[#08080880;true]"
default.listcolors = "listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]" default.listcolors = "listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]"
default.gui = "size[9,8.75]" .. default.gui = "size[9,8.75]" ..
default.gui_bg .. default.gui_bg ..
default.listcolors .. default.listcolors ..
"background[-0.2,-0.26;9.41,9.49;formspec_inventory.png]" .. "background[0,0;0,0;formspec_background_color.png;true]" ..
"background[0,0;0,0;formspec_backround.png;true]" ..
"background[0,0;0,0;formspec_inventory.png;true]" ..
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;false;close_pressed.png]" .. "image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;false;close_pressed.png]" ..
"list[current_player;main;0.01,4.51;9,3;9]" .. "list[current_player;main;0.01,4.51;9,3;9]" ..
"list[current_player;main;0.01,7.75;9,1;]" "list[current_player;main;0.01,7.75;9,1;]"

View File

@ -1247,7 +1247,6 @@ minetest.register_node("default:lava_flowing", {
local bookshelf_formspec = local bookshelf_formspec =
default.gui .. default.gui ..
"background[-0.2,-0.26;9.41,9.49;formspec_shelf.png]" ..
"item_image[0,-0.1;1,1;default:bookshelf]" .. "item_image[0,-0.1;1,1;default:bookshelf]" ..
"label[0.9,0.1;" .. Sl("Bookshelf") .. "]" .. "label[0.9,0.1;" .. Sl("Bookshelf") .. "]" ..
"list[context;books;0,1;9,2;]" .. "list[context;books;0,1;9,2;]" ..
@ -1269,6 +1268,8 @@ local function update_bookshelf(pos)
bx = 0 bx = 0
by = by + 1 by = by + 1
end end
formspec = formspec ..
"image[" .. bx .. "," .. by .. ";1,1;formspec_cell.png]"
local stack = invlist[i] local stack = invlist[i]
if stack:is_empty() then if stack:is_empty() then
formspec = formspec .. formspec = formspec ..

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 B

View File

Before

Width:  |  Height:  |  Size: 69 B

After

Width:  |  Height:  |  Size: 69 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 841 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 715 B

View File

@ -98,9 +98,10 @@ Potions = Зелья
#craftguide #craftguide
Crafting Guide = Руководство Крафта Crafting Guide = Руководство Крафта
Usage = Примен. Usage: = Примен.:
Recipe = Рецепты Recipe: = Рецепт:
of = из of = из
Page: = Страница:
Clear = Очистить Clear = Очистить
Search = Искать Search = Искать
Previous page = Предыдущая страница Previous page = Предыдущая страница
@ -110,6 +111,7 @@ Burning time: = Время горения:
Cooking time: = Время приготовления: Cooking time: = Время приготовления:
No usages.\nClick again to show recipes. = Нет применений.\nНажмите снова для рецептов. No usages.\nClick again to show recipes. = Нет применений.\nНажмите снова для рецептов.
No recipes.\nClick again to show usages. = Невозможно скрафтить.\nНажмите снова для применений. No recipes.\nClick again to show usages. = Невозможно скрафтить.\nНажмите снова для применений.
Select an item from the list\nto view recipes and usages. = Выбери предмет из списка,\nдля просмотра рецептов и применений.
#default #default

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1008 B

View File

@ -198,20 +198,33 @@ function mobs_trader(self, clicker, entity, race)
y = i - 3.2 y = i - 3.2
end end
local name_prices = self.trades[i][2]:match("%S*")
local amount_prices = self.trades[i][2]:match("%d")
local itemdef_prices = minetest.registered_items[name_prices]
local tooltip_prices =
(itemdef_prices and itemdef_prices.description or "") .. " " ..
(amount_prices and amount_prices ~= "1" and amount_prices or "")
local name_goods = self.trades[i][1]:match("%S*")
local amount_goods = self.trades[i][1]:match("%d")
local itemdef_goods = minetest.registered_items[name_goods]
local tooltip_goods =
(itemdef_goods and itemdef_goods.description or "") .. " " ..
(amount_goods and amount_goods ~= "1" and amount_goods or "")
formspec_trade_list = formspec_trade_list .. formspec_trade_list = formspec_trade_list ..
"item_image[" .. x .. "," .. y .. ";1,1;" .. self.trades[i][2] .. "]" .. "item_image[" .. x .. "," .. y .. ";1,1;" .. self.trades[i][2] .. "]" ..
"image_button[" .. x .. "," .. y .. ";1,1;blank.png;prices#" .. i .. "#" .. self.id .. ";;;false;default_item_pressed.png]" .. "image_button[" .. x .. "," .. y .. ";1,1;formspec_cell.png;prices#" .. i .. "#" .. self.id .. ";;;false;formspec_cell.png^default_item_pressed.png]" ..
-- "tooltip[prices#".. i .. "#" .. self.id .. ";"..tooltip.."]" .. "tooltip[prices#" .. i .. "#" .. self.id .. ";" .. tooltip_prices .. "]" ..
"image[".. x + 1 ..",".. y ..";1,1;default_arrow_bg.png^[transformR270]" ..
"item_image[" .. x + 2 .. "," .. y .. ";1,1;" .. self.trades[i][1] .. "]" .. "item_image[" .. x + 2 .. "," .. y .. ";1,1;" .. self.trades[i][1] .. "]" ..
"image_button[" .. x + 2 .. "," .. y .. ";1,1;blank.png;goods#" .. i .. "#" .. self.id .. ";;;false;default_item_pressed.png]" "image_button[" .. x + 2 .. "," .. y .. ";1,1;formspec_cell.png;goods#" .. i .. "#" .. self.id .. ";;;false;formspec_cell.png^default_item_pressed.png]" ..
-- "tooltip[prices#".. i .. "#" .. self.id .. ";"..tooltip.."]" "tooltip[goods#" .. i .. "#" .. self.id .. ";" .. tooltip_goods .. "]"
end end
end end
minetest.show_formspec(player, "mobs_npc:trade", minetest.show_formspec(player, "mobs_npc:trade",
default.gui .. default.gui ..
"background[7.95,3.1;1,1;default_background.png]" ..
"background[-0.2,-0.26;9.41,9.49;formspec_trader.png]" ..
"item_image[0,-0.1;1,1;default:emerald]" .. "item_image[0,-0.1;1,1;default:emerald]" ..
"label[0.9,0.1;" .. S("Trader @1's stock", self.game_name) .. "]" .. "label[0.9,0.1;" .. S("Trader @1's stock", self.game_name) .. "]" ..
formspec_trade_list) formspec_trade_list)

View File

@ -1,6 +1,5 @@
local vessels_shelf_formspec = local vessels_shelf_formspec =
default.gui .. default.gui ..
"background[-0.2,-0.26;9.41,9.49;formspec_shelf.png]" ..
"item_image[0,-0.1;1,1;vessels:shelf]" .. "item_image[0,-0.1;1,1;vessels:shelf]" ..
"label[0.9,0.1;" .. Sl("Potion Shelf") .. "]" .. "label[0.9,0.1;" .. Sl("Potion Shelf") .. "]" ..
"list[context;vessels;0,1;9,2;]" .. "list[context;vessels;0,1;9,2;]" ..
@ -22,6 +21,8 @@ local function update_vessels_shelf(pos)
vx = 0 vx = 0
vy = vy + 1 vy = vy + 1
end end
formspec = formspec ..
"image[" .. vx .. "," .. vy .. ";1,1;formspec_cell.png]"
local stack = invlist[i] local stack = invlist[i]
if stack:is_empty() then if stack:is_empty() then
formspec = formspec .. formspec = formspec ..