mirror of
https://github.com/t-affeldt/climate_api.git
synced 2025-07-05 18:00:36 +02:00
Improve HUD shading, skybox merging, add new artwork
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user