Improve HUD shading, skybox merging, add new artwork

This commit is contained in:
Till Affeldt
2020-04-24 19:55:24 +02:00
parent e24b0340e5
commit 1057342ac6
8 changed files with 33 additions and 9 deletions

View File

@ -4,9 +4,25 @@ local EFFECT_NAME = "climate_api:hud_overlay"
local handles = {}
local function apply_hud(pname, weather, hud)
if handles[pname] == nil then handles[pname] = {} end
if handles[pname][weather] ~= nil then return end
local player = minetest.get_player_by_name(pname)
if handles[pname] == nil then handles[pname] = {} end
if handles[pname][weather] ~= nil then
player:hud_remove(handles[pname][weather])
end
local file
if hud.color_correction then
local pos = vector.add(player:get_pos(), {x = 0, y = 1, z = 0})
local light = math.floor(math.max(minetest.env:get_node_light(pos) / 15, 0.2) * 256)
local shadow = 256 - light
local dark_file = hud.file .. "^[multiply:#000000ff^[opacity:" .. shadow
local light_file = hud.file .. "^[opacity:" .. light
file = "(" .. light_file .. ")^(" .. dark_file .. ")"
else
file = hud.file
end
local handle = player:hud_add({
name = weather,
hud_elem_type = "image",
@ -14,7 +30,7 @@ local function apply_hud(pname, weather, hud)
alignment = {x = 1, y = 1},
scale = { x = -100, y = -100},
z_index = hud.z_index,
text = hud.file,
text = file,
offset = {x = 0, y = 0}
})
handles[pname][weather] = handle
@ -39,7 +55,12 @@ end
local function handle_effect(player_data, prev_data)
for playername, data in pairs(player_data) do
for weather, value in pairs(data) do
if prev_data[playername][weather] == nil then
if prev_data[playername][weather] == nil
or value.color_correction == true
or prev_data[playername][weather].color_correction == true
or value.file ~= prev_data[playername][weather].file
or value.z_index ~= prev_data[playername][weather].z_index
then
apply_hud(playername, weather, value)
end
end