1
0
Fork 0

Add credits screen

This commit is contained in:
Lizzy Fleckenstein 2021-04-06 11:55:21 +02:00
parent 175cb44fb1
commit d07e415b37
3 changed files with 113 additions and 28 deletions

View File

@ -2,22 +2,22 @@ mcl_credits = {
players = {}, players = {},
} }
mcl_credits.description = "A faithful Open Source imitation of Minecraft" mcl_credits.description = "A faithful Open Source clone of Minecraft"
-- Sub-lists are sorted by number of commits -- Sub-lists are sorted by number of commits, but the list should not be rearranged (-> new contributors are just added at the end of the list)
mcl_credits.people = { mcl_credits.people = {
{"Creator of MineClone", { {"Creator of MineClone", 0x0A9400, {
"davedevils", "davedevils",
}}, }},
{"Creator of MineClone2", { {"Creator of MineClone2", 0xFBF837, {
"Wuzzy", "Wuzzy",
}}, }},
{"Maintainers", { {"Maintainers", 0xFF51D5, {
"Fleckenstein", "Fleckenstein",
"kay27", "kay27",
"oilboi", "oilboi",
}}, }},
{"Developers", { {"Developers", 0xF84355, {
"bzoss", "bzoss",
"AFCMS", "AFCMS",
"epCode", "epCode",
@ -28,7 +28,7 @@ mcl_credits.people = {
"Nicu", "Nicu",
"aligator", "aligator",
}}, }},
{"Contributors", { {"Contributors", 0x52FF00, {
"Code-Sploit", "Code-Sploit",
"Laurent Rocher", "Laurent Rocher",
"HimbeerserverDE", "HimbeerserverDE",
@ -55,11 +55,11 @@ mcl_credits.people = {
"nickolas360", "nickolas360",
"yutyo", "yutyo",
}}, }},
{"3D Models", { {"3D Models", 0x0019FF, {
"22i", "22i",
"tobyplowy", "tobyplowy",
}}, }},
{"Textures", { {"Textures", 0xFF9705, {
"XSSheep", "XSSheep",
"kingoscargames", "kingoscargames",
"leorockway", "leorockway",
@ -67,39 +67,125 @@ mcl_credits.people = {
}}, }},
} }
local function add_hud_element(def, huds, y)
def.alignment = {x = 0, y = 0}
def.position = {x = 0.5, y = 0}
def.offset = {x = 0, y = y}
def.z_index = 1001
local id = huds.player:hud_add(def)
table.insert(huds.ids, id)
huds.moving[id] = y
return id
end
function mcl_credits.show(player) function mcl_credits.show(player)
local name = player:get_player_name() local name = player:get_player_name()
if mcl_credits.players[name] then if mcl_credits.players[name] then
return return
end end
local hud_list = { local huds = {
player:hud_add({ new = true, -- workaround for MT < 5.5 (sending hud_add and hud_remove in the same tick)
hud_elem_type = "image", player = player,
text = "menu_bg.png", moving = {},
position = {x = 0, y = 0}, ids = {
alignment = {x = 1, y = 1}, player:hud_add({
scale = {x = -100, y = -100}, hud_elem_type = "image",
z_index = 1000, text = "menu_bg.png",
}) position = {x = 0, y = 0},
alignment = {x = 1, y = 1},
scale = {x = -100, y = -100},
z_index = 1000,
}),
player:hud_add({
hud_elem_type = "text",
text = "Sneak to skip",
position = {x = 1, y = 1},
alignment = {x = -1, y = -1},
offset = {x = -5, y = -5},
z_index = 1001,
number = 0xFFFFFF,
})
},
} }
mcl_credits.players[name] = hud_list add_hud_element({
hud_elem_type = "image",
text = "mineclone2_logo.png",
scale = {x = 1, y = 1},
}, huds, 300, 0)
add_hud_element({
hud_elem_type = "text",
text = mcl_credits.description,
number = 0x757575,
scale = {x = 5, y = 5},
}, huds, 350, 0)
local y = 450
for _, group in ipairs(mcl_credits.people) do
add_hud_element({
hud_elem_type = "text",
text = group[1],
number = group[2],
scale = {x = 3, y = 3},
}, huds, y, 0)
y = y + 25
for _, name in ipairs(group[3]) do
y = y + 25
add_hud_element({
hud_elem_type = "text",
text = name,
number = 0xFFFFFF,
scale = {x = 1, y = 1},
}, huds, y, 0)
end
y = y + 200
end
huds.icon = add_hud_element({
hud_elem_type = "image",
text = "mineclone2_icon.png",
scale = {x = 1, y = 1},
}, huds, y)
mcl_credits.players[name] = huds
end end
function mcl_credits.hide(player) function mcl_credits.hide(player)
local name = player:get_player_name() local name = player:get_player_name()
local list = mcl_credits.players[name] local huds = mcl_credits.players[name]
if list then if huds then
for _, id in pairs(list) do for _, id in pairs(huds.ids) do
player:hud_remove(id) player:hud_remove(id)
end end
end end
mcl_credits.players[name] = nil mcl_credits.players[name] = nil
end end
controls.register_on_press(function(player, key) minetest.register_on_leaveplayer(function(player)
if key == "sneak" then mcl_credits.players[player:get_player_name()] = nil
mcl_credits.hide(player) end)
elseif key == "aux1" then
mcl_credits.show(player) minetest.register_globalstep(function(dtime)
for _, huds in pairs(mcl_credits.players) do
local player = huds.player
if not huds.new and player:get_player_control().sneak then
mcl_credits.hide(player)
else
local moving = {}
local any
for id, y in pairs(huds.moving) do
y = y - 1
if y > -100 then
if id == huds.icon then
y = math.max(400, y)
else
any = true
end
player:hud_change(id, "offset", {x = 0, y = y})
moving[id] = y
end
end
if not any then
mcl_credits.hide(player)
end
huds.moving = moving
end
huds.new = false
end end
end) end)

View File

@ -1,4 +1,3 @@
name = mcl_credits name = mcl_credits
author = Fleckenstein author = Fleckenstein
description = Show a HUD containing the credits description = Show a HUD containing the credits
depends = controls

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB