mirror of
https://github.com/minetest-mods/i3.git
synced 2024-12-27 03:10:39 +01:00
Add awards support!
This commit is contained in:
parent
364b3f6d11
commit
bbab3a8899
@ -6,6 +6,7 @@ read_globals = {
|
|||||||
"default",
|
"default",
|
||||||
"armor",
|
"armor",
|
||||||
"skins",
|
"skins",
|
||||||
|
"awards",
|
||||||
"vector",
|
"vector",
|
||||||
"string",
|
"string",
|
||||||
"table",
|
"table",
|
||||||
|
105
init.lua
105
init.lua
@ -11,7 +11,7 @@ local replacements = {fuel = {}}
|
|||||||
local toolrepair
|
local toolrepair
|
||||||
|
|
||||||
local progressive_mode = core.settings:get_bool "i3_progressive_mode"
|
local progressive_mode = core.settings:get_bool "i3_progressive_mode"
|
||||||
local __3darmor, __skinsdb
|
local __3darmor, __skinsdb, __awards
|
||||||
|
|
||||||
local http = core.request_http_api()
|
local http = core.request_http_api()
|
||||||
local singleplayer = core.is_singleplayer()
|
local singleplayer = core.is_singleplayer()
|
||||||
@ -1733,6 +1733,11 @@ local function get_item_list(fs, data, full_height)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function add_subtitle(fs, title, y)
|
||||||
|
fs("style_type[label;font=bold;font_size=+2]", fmt("label", 0, y, title),
|
||||||
|
"style_type[label;font=normal;font_size=+0]", fmt("box", 0, y + 0.3, 5.5, 0.05, "#666"))
|
||||||
|
end
|
||||||
|
|
||||||
local function get_inventory_mode(player, fs, data, full_height)
|
local function get_inventory_mode(player, fs, data, full_height)
|
||||||
fs(fmt("bg9", 0, 0, data.xoffset, full_height, PNG.bg_full, 10))
|
fs(fmt("bg9", 0, 0, data.xoffset, full_height, PNG.bg_full, 10))
|
||||||
|
|
||||||
@ -1760,9 +1765,10 @@ local function get_inventory_mode(player, fs, data, full_height)
|
|||||||
fs(fmt("image", 0.7, 0.2, size, size * props.visual_size.y, props.textures[1]))
|
fs(fmt("image", 0.7, 0.2, size, size * props.visual_size.y, props.textures[1]))
|
||||||
end
|
end
|
||||||
|
|
||||||
local extras = __3darmor or __skinsdb
|
local extras = __3darmor or __skinsdb or __awards
|
||||||
local xoffset = extras and 0 or 4.5
|
local xoffset = extras and 0 or 4.5
|
||||||
local yoffset = extras and 0 or 0.2
|
local yoffset = extras and 0 or 0.2
|
||||||
|
local award_list
|
||||||
|
|
||||||
if extras then
|
if extras then
|
||||||
local max_val = 15
|
local max_val = 15
|
||||||
@ -1775,6 +1781,11 @@ local function get_inventory_mode(player, fs, data, full_height)
|
|||||||
max_val = max_val + 20
|
max_val = max_val + 20
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if __awards then
|
||||||
|
award_list = awards.get_award_states(name)
|
||||||
|
max_val = max_val + (#award_list * 13.2)
|
||||||
|
end
|
||||||
|
|
||||||
fs(sprintf([[
|
fs(sprintf([[
|
||||||
scrollbaroptions[arrows=hide;thumbsize=%u;max=%u]
|
scrollbaroptions[arrows=hide;thumbsize=%u;max=%u]
|
||||||
scrollbar[9.69,0.2;0.3,5.5;vertical;scrbar_inv;%u]
|
scrollbar[9.69,0.2;0.3,5.5;vertical;scrbar_inv;%u]
|
||||||
@ -1807,10 +1818,9 @@ local function get_inventory_mode(player, fs, data, full_height)
|
|||||||
local yextra = 5.6
|
local yextra = 5.6
|
||||||
|
|
||||||
if __3darmor then
|
if __3darmor then
|
||||||
fs("style_type[label;font=bold;font_size=+2]", fmt("label", 0, yextra, ES"Armor"),
|
add_subtitle(fs, ES"Armor", yextra)
|
||||||
"style_type[label;font=normal;font_size=+0]",
|
|
||||||
fmt("box", 0, yextra + 0.3, 5.5, 0.05, "#666"),
|
fs(sprintf("list[detached:%s_armor;armor;0,%f;3,2;]", name, yextra + 0.6))
|
||||||
sprintf("list[detached:%s_armor;armor;0,%f;3,2;]", name, yextra + 0.6))
|
|
||||||
|
|
||||||
fs(fmt("label", 3.75, yextra + 1.55, sprintf("%s: %s", ES"Level", armor.def[name].level)),
|
fs(fmt("label", 3.75, yextra + 1.55, sprintf("%s: %s", ES"Level", armor.def[name].level)),
|
||||||
fmt("label", 3.75, yextra + 1.95, sprintf("%s: %s", ES"Heal", armor.def[name].heal)))
|
fmt("label", 3.75, yextra + 1.95, sprintf("%s: %s", ES"Heal", armor.def[name].heal)))
|
||||||
@ -1824,17 +1834,64 @@ local function get_inventory_mode(player, fs, data, full_height)
|
|||||||
t[#t + 1] = skin.name
|
t[#t + 1] = skin.name
|
||||||
end
|
end
|
||||||
|
|
||||||
yextra = __3darmor and (yextra + 3.5) or 5.65
|
yextra = __3darmor and (yextra + 3.5) or yextra
|
||||||
|
|
||||||
fs("style_type[label;font=bold;font_size=+2]")
|
add_subtitle(fs, ES"Skins", yextra)
|
||||||
fs(fmt("label", 0, yextra, ES"Skins"))
|
|
||||||
fs("style_type[label;font=normal;font_size=+0]")
|
|
||||||
fs(fmt("box", 0, yextra + 0.3, 5.5, 0.05, "#666"))
|
|
||||||
|
|
||||||
fs(sprintf("dropdown[0,%f;3.55,0.6;skins;%s;%u;true]",
|
fs(sprintf("dropdown[0,%f;3.55,0.6;skins;%s;%u;true]",
|
||||||
yextra + 0.6, concat(t, ","), data.skin_id or 1))
|
yextra + 0.6, concat(t, ","), data.skin_id or 1))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if __awards then
|
||||||
|
if (__3darmor and __skinsdb) or __skinsdb then
|
||||||
|
yextra = yextra + 1.8
|
||||||
|
elseif __3darmor then
|
||||||
|
yextra = yextra + 3.5
|
||||||
|
end
|
||||||
|
|
||||||
|
add_subtitle(fs, ES"Awards", yextra)
|
||||||
|
|
||||||
|
for i, award in ipairs(award_list) do
|
||||||
|
local y = yextra - 0.7 + i + (i * 0.3)
|
||||||
|
local def, progress = award.def, award.progress
|
||||||
|
local title, desc = def.title, def.description or ""
|
||||||
|
local icon_size = 1.1
|
||||||
|
|
||||||
|
if not award.unlocked and def.secret then
|
||||||
|
title = ES"Secret award"
|
||||||
|
desc = ES"Unlock this award to find out what it is."
|
||||||
|
end
|
||||||
|
|
||||||
|
local icon = def.icon or "awards_unknown.png"
|
||||||
|
|
||||||
|
if not award.unlocked then
|
||||||
|
icon = sprintf("%s^\\[colorize:#000:180", icon)
|
||||||
|
end
|
||||||
|
|
||||||
|
fs(fmt("image", 0, y + 0.01, icon_size, icon_size, icon))
|
||||||
|
fs(fmt("box", icon_size + 0.1, y, 4.3, icon_size, "#bababa25"))
|
||||||
|
|
||||||
|
if progress then
|
||||||
|
local current, target = progress.current, progress.target
|
||||||
|
local curr_bar = (current * 4.3) / target
|
||||||
|
|
||||||
|
fs(fmt("box", icon_size + 0.1, y + 0.8, 4.3, 0.3, "#101010"),
|
||||||
|
fmt("box", icon_size + 0.1, y + 0.8, curr_bar, 0.3, "#9dc34c"),
|
||||||
|
"style_type[label;font=normal;font_size=-2]",
|
||||||
|
fmt("label", icon_size + 0.5, y + 0.97,
|
||||||
|
sprintf("%u / %u", current, target)))
|
||||||
|
|
||||||
|
y = y - 0.14
|
||||||
|
end
|
||||||
|
|
||||||
|
fs("style_type[label;font=bold;font_size=+1]",
|
||||||
|
fmt("label", icon_size + 0.2, y + 0.4, title),
|
||||||
|
"style_type[label;font=normal;font_size=-1]",
|
||||||
|
fmt("label", icon_size + 0.2, y + 0.75, clr("#bbbbbb", desc)),
|
||||||
|
"style_type[label;font=normal;font_size=+0]")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if extras then
|
if extras then
|
||||||
fs("scroll_container_end[]")
|
fs("scroll_container_end[]")
|
||||||
end
|
end
|
||||||
@ -1934,6 +1991,32 @@ if rawget(_G, "skins") then
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if rawget(_G, "awards") then
|
||||||
|
__awards = true
|
||||||
|
|
||||||
|
core.register_on_craft(function(_, player)
|
||||||
|
set_fs(player)
|
||||||
|
end)
|
||||||
|
|
||||||
|
core.register_on_dignode(function(_, _, player)
|
||||||
|
set_fs(player)
|
||||||
|
end)
|
||||||
|
|
||||||
|
core.register_on_placenode(function(_, _, player)
|
||||||
|
set_fs(player)
|
||||||
|
end)
|
||||||
|
|
||||||
|
core.register_on_chat_message(function(name, message)
|
||||||
|
local player = minetest.get_player_by_name(name)
|
||||||
|
|
||||||
|
if player:is_player() or sub(message, 1, 1) ~= "/" then
|
||||||
|
set_fs(player)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
core.register_on_dieplayer(set_fs)
|
||||||
|
end
|
||||||
|
|
||||||
i3.register_craft_type("digging", {
|
i3.register_craft_type("digging", {
|
||||||
description = ES"Digging",
|
description = ES"Digging",
|
||||||
icon = "i3_steelpick.png",
|
icon = "i3_steelpick.png",
|
||||||
|
Loading…
Reference in New Issue
Block a user