From d07e415b3752c2e96a2a1fe27b023ca23abebd51 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Tue, 6 Apr 2021 11:55:21 +0200 Subject: [PATCH] Add credits screen --- mods/HUD/mcl_credits/init.lua | 140 ++++++++++++++---- mods/HUD/mcl_credits/mod.conf | 1 - .../mcl_credits/textures/mineclone2_icon.png | Bin 0 -> 3961 bytes 3 files changed, 113 insertions(+), 28 deletions(-) create mode 100644 mods/HUD/mcl_credits/textures/mineclone2_icon.png diff --git a/mods/HUD/mcl_credits/init.lua b/mods/HUD/mcl_credits/init.lua index 05e7aeff4..a53ebbba9 100644 --- a/mods/HUD/mcl_credits/init.lua +++ b/mods/HUD/mcl_credits/init.lua @@ -2,22 +2,22 @@ mcl_credits = { 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 = { - {"Creator of MineClone", { + {"Creator of MineClone", 0x0A9400, { "davedevils", }}, - {"Creator of MineClone2", { + {"Creator of MineClone2", 0xFBF837, { "Wuzzy", }}, - {"Maintainers", { + {"Maintainers", 0xFF51D5, { "Fleckenstein", "kay27", "oilboi", }}, - {"Developers", { + {"Developers", 0xF84355, { "bzoss", "AFCMS", "epCode", @@ -28,7 +28,7 @@ mcl_credits.people = { "Nicu", "aligator", }}, - {"Contributors", { + {"Contributors", 0x52FF00, { "Code-Sploit", "Laurent Rocher", "HimbeerserverDE", @@ -55,11 +55,11 @@ mcl_credits.people = { "nickolas360", "yutyo", }}, - {"3D Models", { + {"3D Models", 0x0019FF, { "22i", "tobyplowy", }}, - {"Textures", { + {"Textures", 0xFF9705, { "XSSheep", "kingoscargames", "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) local name = player:get_player_name() if mcl_credits.players[name] then return end - local hud_list = { - player:hud_add({ - hud_elem_type = "image", - text = "menu_bg.png", - position = {x = 0, y = 0}, - alignment = {x = 1, y = 1}, - scale = {x = -100, y = -100}, - z_index = 1000, - }) + local huds = { + new = true, -- workaround for MT < 5.5 (sending hud_add and hud_remove in the same tick) + player = player, + moving = {}, + ids = { + player:hud_add({ + hud_elem_type = "image", + 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 function mcl_credits.hide(player) local name = player:get_player_name() - local list = mcl_credits.players[name] - if list then - for _, id in pairs(list) do + local huds = mcl_credits.players[name] + if huds then + for _, id in pairs(huds.ids) do player:hud_remove(id) end end mcl_credits.players[name] = nil end -controls.register_on_press(function(player, key) - if key == "sneak" then - mcl_credits.hide(player) - elseif key == "aux1" then - mcl_credits.show(player) +minetest.register_on_leaveplayer(function(player) + mcl_credits.players[player:get_player_name()] = nil +end) + +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) diff --git a/mods/HUD/mcl_credits/mod.conf b/mods/HUD/mcl_credits/mod.conf index b5532cd30..3df6370af 100644 --- a/mods/HUD/mcl_credits/mod.conf +++ b/mods/HUD/mcl_credits/mod.conf @@ -1,4 +1,3 @@ name = mcl_credits author = Fleckenstein description = Show a HUD containing the credits -depends = controls diff --git a/mods/HUD/mcl_credits/textures/mineclone2_icon.png b/mods/HUD/mcl_credits/textures/mineclone2_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..e479dfff5a55bf28d90056e968246e803aad0297 GIT binary patch literal 3961 zcmV-<4~FoGP)e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{01n|vL_t(|+U=doZyWa!$A{!{ zxerRDEQtaX+d=CxG3+!+gTye>0zpvZQXq#Mie7r?v42vJJ@nQ?4+VN@fucnZK@ucI zV+01Aq_F&G^a@|%?sB;#d!T0Zd(7{*KT?uKi90}$ko%za_t}~G&J4K$$St?ra?35Z z+;Yn;x7>2OT2=r6xc#eaeike=9P1*XEDEF?4gqD+JZUN6 z)Zf0HLOI$Ej3F*NB%p}^Sw^yA}x0>fyOzF&4qVEY!>w|_VR00K?(%`pno{v_VL#%(sACBLMoo+$tIgGO(vT!OrqFD{tkVLqHMl{`e@KhOVl8^54EiE;@!X^saQ<@o{)8?z=2G=~QsoyLcFl(gl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