Cleanups
This commit is contained in:
parent
4a7a2b23a2
commit
2b1a3e7434
@ -1,6 +1,7 @@
|
||||
local S = minetest.get_translator("block_league")
|
||||
|
||||
local function get_formspec() end
|
||||
local function get_weapon_details() end
|
||||
|
||||
|
||||
|
||||
@ -17,7 +18,9 @@ function get_formspec(p_name)
|
||||
local p_skill = block_league.get_player_skill(p_name)
|
||||
local skill_def = skills.get_skill_def(p_skill)
|
||||
local info_section = {}
|
||||
local elem = minetest.get_player_by_name(p_name):get_meta():get_string("bl_profile_elem_active")
|
||||
local p_meta = minetest.get_player_by_name(p_name):get_meta()
|
||||
local elem = p_meta:get_string("bl_profile_elem_active")
|
||||
local elem_technical = "block_league:" .. elem
|
||||
|
||||
-- calcolo contenuto da metter sulla destra
|
||||
if elem == "" then
|
||||
@ -28,82 +31,21 @@ function get_formspec(p_name)
|
||||
|
||||
else
|
||||
local item, elem_name, body, button
|
||||
local weap = minetest.registered_items["block_league:" .. elem]
|
||||
local skill = skills.get_skill_def("block_league:" .. elem)
|
||||
local weap = minetest.registered_items[elem_technical]
|
||||
local skill = skills.get_skill_def(elem_technical)
|
||||
|
||||
-- se è un'arma..
|
||||
if weap then
|
||||
item = weap.mesh and "model[0,1.5;5.08,2.2;weap_model;" .. weap.mesh .. ";" .. table.concat(weap.tiles, ",") .. ";0,140;false;true]"
|
||||
or "image[2,1.7;1.5,1.5;" .. weap.wield_image .. "]"
|
||||
elem_name = weap.description
|
||||
|
||||
local action_y = 0
|
||||
local action1, action1_hold, action1_air, action2, action2_hold, action2_air
|
||||
|
||||
-- azioni varie
|
||||
if weap.action1 then
|
||||
action1 = "image[0," .. action_y .. ";0.4,0.55;bl_gui_profile_action_lmb.png]" ..
|
||||
"hypertext[0.6," .. action_y - 0.12 .. ";3.8,0.8;elem_desc;<global size=15 valign=middle><i>" .. weap.action1.description .. "</i>]"
|
||||
action_y = action_y + 0.8
|
||||
end
|
||||
|
||||
if weap.action1_hold then
|
||||
action1_hold = "image[0," .. action_y .. ";0.4,0.55;bl_gui_profile_action_lmb_hold.png]" ..
|
||||
"hypertext[0.6," .. action_y - 0.12 .. ";3.8,0.8;elem_desc;<global size=15 valign=middle><i>" .. weap.action1_hold.description .. "</i>]"
|
||||
action_y = action_y + 0.8
|
||||
end
|
||||
|
||||
if weap.action1_air then
|
||||
action1_air = "image[0," .. action_y .. ";0.4,0.55;bl_gui_profile_action_lmb_air.png]" ..
|
||||
"hypertext[0.6," .. action_y - 0.12 .. ";3.8,0.8;elem_desc;<global size=15 valign=middle><i>" .. weap.action1_air.description .. "</i>]"
|
||||
action_y = action_y + 0.8
|
||||
end
|
||||
|
||||
if weap.action2 then
|
||||
action2 = "image[0," .. action_y .. ";0.4,0.55;bl_gui_profile_action_rmb.png]" ..
|
||||
"hypertext[0.6," .. action_y - 0.12 .. ";3.8,0.8;elem_desc;<global size=15 valign=middle><i>" .. weap.action2.description .. "</i>]"
|
||||
action_y = action_y + 0.8
|
||||
end
|
||||
|
||||
if weap.action2_hold then
|
||||
action2_hold = "image[0," .. action_y .. ";0.4,0.55;bl_gui_profile_action_rmb_hold.png]" ..
|
||||
"hypertext[0.6," .. action_y - 0.12 .. ";3.8,0.8;elem_desc;<global size=15 valign=middle><i>" .. weap.action2_hold.description .. "</i>]"
|
||||
action_y = action_y + 0.8
|
||||
end
|
||||
|
||||
if weap.action2_air then
|
||||
action1_air = "image[0," .. action_y .. ";0.4,0.55;bl_gui_profile_action_rmb_air.png]" ..
|
||||
"hypertext[0.6," .. action_y - 0.12 .. ";3.8,0.8;elem_desc;<global size=15 valign=middle><i>" .. weap.action2_air.description .. "</i>]"
|
||||
action_y = action_y + 0.8
|
||||
end
|
||||
|
||||
local ammo = ""
|
||||
if weap.weapon_type ~= "melee" then
|
||||
ammo = table.concat({
|
||||
"image[0,1.6;0.4,0.4;bl_gui_profile_weapon_magazine.png]",
|
||||
"image[3,1.6;0.4,0.4;bl_gui_profile_weapon_reload.png]",
|
||||
"hypertext[0.6,1.53;1,0.6;elem_desc;<global size=16 valign=middle><i>" .. weap.magazine .. " / --</i>]",
|
||||
"hypertext[3.6,1.53;1,0.6;elem_desc;<global size=16 valign=middle><i>" .. weap.reload_time .. "</i>]"
|
||||
})
|
||||
end
|
||||
|
||||
local attributes = table.concat({
|
||||
"container[0.4,5.1]",
|
||||
action1 or "",
|
||||
action1_hold or "",
|
||||
action1_air or "",
|
||||
action2 or "",
|
||||
action2_hold or "",
|
||||
action2_air or "",
|
||||
ammo,
|
||||
"container_end[]",
|
||||
}, "")
|
||||
|
||||
body = table.concat({
|
||||
"hypertext[0.3,4.12;4.48,0.9;elem_desc;<global size=15 halign=center valign=middle><style color=#abc0c0><i>" .. weap.profile_description .. "</i>]",
|
||||
attributes
|
||||
}, "")
|
||||
--TODO: inserire il pulsante "rimuovi" per quando si potrà cambiare equipaggiamento
|
||||
body = get_weapon_details(weap)
|
||||
button = "" -- TODO v
|
||||
--[[if block_league.has_weapon_equipped(p_name, elem_technical) then
|
||||
button = "image_button[1.45,7.9;2.2,0.8;bl_gui_profile_button_unequip.png;unequip;" .. S("UNEQUIP") .. "]"
|
||||
else
|
||||
button = "image_button[1.45,7.9;2.2,0.8;bl_gui_profile_button_equip.png;equip;" .. S("EQUIP") .. "]"
|
||||
end]]
|
||||
|
||||
-- se è un'abilità..
|
||||
elseif skill then
|
||||
@ -111,8 +53,8 @@ function get_formspec(p_name)
|
||||
elem_name = skill.name
|
||||
body = "hypertext[0.3,4.2;4.48,4.3;elem_desc;<global size=15 halign=center><style color=#abc0c0><i>" .. skill.profile_description .. "</i>]"
|
||||
|
||||
if "block_league:" .. elem ~= p_skill then
|
||||
button = "image_button[1.45,7.9;2.2,0.8;bl_gui_profile_button_confirm.png;equip;" .. S("EQUIP") .. "]"
|
||||
if elem_technical ~= p_skill then
|
||||
button = "image_button[1.45,7.9;2.2,0.8;bl_gui_profile_button_equip.png;equip;" .. S("EQUIP") .. "]"
|
||||
end
|
||||
end
|
||||
|
||||
@ -198,6 +140,75 @@ end
|
||||
|
||||
|
||||
|
||||
function get_weapon_details(weap)
|
||||
local action_y = 0
|
||||
local action1, action1_hold, action1_air, action2, action2_hold, action2_air
|
||||
|
||||
-- azioni varie
|
||||
if weap.action1 then
|
||||
action1 = "image[0," .. action_y .. ";0.4,0.55;bl_gui_profile_action_lmb.png]" ..
|
||||
"hypertext[0.6," .. action_y - 0.12 .. ";3.8,0.8;elem_desc;<global size=15 valign=middle><i>" .. weap.action1.description .. "</i>]"
|
||||
action_y = action_y + 0.8
|
||||
end
|
||||
|
||||
if weap.action1_hold then
|
||||
action1_hold = "image[0," .. action_y .. ";0.4,0.55;bl_gui_profile_action_lmb_hold.png]" ..
|
||||
"hypertext[0.6," .. action_y - 0.12 .. ";3.8,0.8;elem_desc;<global size=15 valign=middle><i>" .. weap.action1_hold.description .. "</i>]"
|
||||
action_y = action_y + 0.8
|
||||
end
|
||||
|
||||
if weap.action1_air then
|
||||
action1_air = "image[0," .. action_y .. ";0.4,0.55;bl_gui_profile_action_lmb_air.png]" ..
|
||||
"hypertext[0.6," .. action_y - 0.12 .. ";3.8,0.8;elem_desc;<global size=15 valign=middle><i>" .. weap.action1_air.description .. "</i>]"
|
||||
action_y = action_y + 0.8
|
||||
end
|
||||
|
||||
if weap.action2 then
|
||||
action2 = "image[0," .. action_y .. ";0.4,0.55;bl_gui_profile_action_rmb.png]" ..
|
||||
"hypertext[0.6," .. action_y - 0.12 .. ";3.8,0.8;elem_desc;<global size=15 valign=middle><i>" .. weap.action2.description .. "</i>]"
|
||||
action_y = action_y + 0.8
|
||||
end
|
||||
|
||||
if weap.action2_hold then
|
||||
action2_hold = "image[0," .. action_y .. ";0.4,0.55;bl_gui_profile_action_rmb_hold.png]" ..
|
||||
"hypertext[0.6," .. action_y - 0.12 .. ";3.8,0.8;elem_desc;<global size=15 valign=middle><i>" .. weap.action2_hold.description .. "</i>]"
|
||||
action_y = action_y + 0.8
|
||||
end
|
||||
|
||||
if weap.action2_air then
|
||||
action1_air = "image[0," .. action_y .. ";0.4,0.55;bl_gui_profile_action_rmb_air.png]" ..
|
||||
"hypertext[0.6," .. action_y - 0.12 .. ";3.8,0.8;elem_desc;<global size=15 valign=middle><i>" .. weap.action2_air.description .. "</i>]"
|
||||
action_y = action_y + 0.8
|
||||
end
|
||||
|
||||
local ammo = ""
|
||||
if weap.weapon_type ~= "melee" then
|
||||
ammo = table.concat({
|
||||
"image[0,1.6;0.4,0.4;bl_gui_profile_weapon_magazine.png]",
|
||||
"image[3,1.6;0.4,0.4;bl_gui_profile_weapon_reload.png]",
|
||||
"hypertext[0.6,1.53;1,0.6;elem_desc;<global size=16 valign=middle><i>" .. weap.magazine .. " / --</i>]",
|
||||
"hypertext[3.6,1.53;1,0.6;elem_desc;<global size=16 valign=middle><i>" .. weap.reload_time .. "</i>]"
|
||||
})
|
||||
end
|
||||
|
||||
local attributes = table.concat({
|
||||
"hypertext[0.3,4.12;4.48,0.9;elem_desc;<global size=15 halign=center valign=middle><style color=#abc0c0><i>" .. weap.profile_description .. "</i>]",
|
||||
"container[0.4,5.1]",
|
||||
action1 or "",
|
||||
action1_hold or "",
|
||||
action1_air or "",
|
||||
action2 or "",
|
||||
action2_hold or "",
|
||||
action2_air or "",
|
||||
ammo,
|
||||
"container_end[]",
|
||||
}, "")
|
||||
|
||||
return attributes
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
@ -224,10 +235,18 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
elseif fields.sslot then
|
||||
player:get_meta():set_string("bl_profile_elem_active", fields.sslot)
|
||||
elseif fields.equip then
|
||||
local skill = "block_league:" .. player:get_meta():get_string("bl_profile_elem_active")
|
||||
local elem_technical = "block_league:" .. player:get_meta():get_string("bl_profile_elem_active")
|
||||
local weap = minetest.registered_items[elem_technical]
|
||||
|
||||
block_league.set_player_skill(p_name, skill)
|
||||
audio_lib.play_sound("bl_gui_equip_confirm", {to_player = p_name})
|
||||
if weap then
|
||||
minetest.chat_send_player(p_name, "TODO")
|
||||
else
|
||||
block_league.set_player_skill(p_name, elem_technical)
|
||||
audio_lib.play_sound("bl_gui_equip_confirm", {to_player = p_name})
|
||||
end
|
||||
|
||||
elseif fields.unequip then
|
||||
minetest.chat_send_player(p_name, "TODO")
|
||||
end
|
||||
|
||||
minetest.show_formspec(p_name, "block_league:profile", get_formspec(p_name))
|
||||
|
@ -31,3 +31,15 @@ function block_league.set_player_skill(p_name, s_name)
|
||||
equip[p_name].skill = s_name
|
||||
block_league.update_storage(p_name, "skill", s_name)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function block_league.has_weapon_equipped(p_name, w_name)
|
||||
if not equip[p_name] then return end
|
||||
|
||||
for _, ww_name in pairs(equip[p_name].weapons) do
|
||||
if w_name == ww_name then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 131 B |
BIN
block_league/textures/bl_gui_profile_button_unequip.png
Normal file
BIN
block_league/textures/bl_gui_profile_button_unequip.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 131 B |
Loading…
x
Reference in New Issue
Block a user