Add 0.4.17 support for GUI mode

master
Wuzzy 2020-08-28 14:26:33 +02:00
parent 31354005f5
commit b07f75ca73
1 changed files with 27 additions and 9 deletions

36
gui.lua
View File

@ -113,27 +113,45 @@ function calendar.show_calendar(player_name, settings, wanted_months, wanted_yea
local holidays = calendar.get_holidays(tdays)
local tooltip_lines = {}
-- Highlight holiday
local is_holiday = false
if settings.show_holidays and #holidays > 0 then
if SHOW_AREA_TOOLTIPS then
for h=1, #holidays do
table.insert(tooltip_lines, minetest.colorize(COLOR_HOLIDAY, holidays[h].name))
end
is_holiday = true
for h=1, #holidays do
table.insert(tooltip_lines, minetest.colorize(COLOR_HOLIDAY, holidays[h].name))
end
day_str = minetest.colorize(COLOR_HOLIDAY, day_str)
box_color = COLOR_DAYBOX_HOLIDAY
if not SHOW_AREA_TOOLTIPS then
formspec = formspec .. "box["..(x-0.05)..","..(y-0.05)..";0.925,1;"..box_color.."]"
end
end
day_str = F(day_str)
-- Highlight today
if settings.show_today and tdays == total_days then
formspec = formspec .. "box["..(x-0.05)..","..(y-0.05)..";1.1,1.1;"..COLOR_DAYBOX_TODAY.."]"
if SHOW_AREA_TOOLTIPS then
table.insert(tooltip_lines, minetest.colorize(COLOR_TOOLTIP_TODAY, S("Today")))
formspec = formspec .. "box["..(x-0.05)..","..(y-0.05)..";1.1,1.1;"..COLOR_DAYBOX_TODAY.."]"
else
formspec = formspec .. "box["..(x-0.1)..","..(y-0.1)..";1,1.1;"..COLOR_DAYBOX_TODAY.."]"
end
table.insert(tooltip_lines, minetest.colorize(COLOR_TOOLTIP_TODAY, S("Today")))
end
if SHOW_AREA_TOOLTIPS then
formspec = formspec .. "box["..x..","..y..";1,1;"..box_color.."]"
.. "label["..(x+0.15)..","..(y+0.3)..";"..day_str.."]"
else
local day_num = pday
if is_holiday then
day_num = minetest.colorize(COLOR_HOLIDAY, pday)
end
formspec = formspec .. "button["..x..","..y..";1,1;day"..iday..";"..F(day_num).."]"
end
formspec = formspec .. "box["..x..","..y..";1,1;"..box_color.."]" ..
"label["..(x+0.15)..","..(y+0.3)..";"..day_str.."]"
if #tooltip_lines > 0 then
formspec = formspec .. "tooltip["..x..","..y..";1,1;"..F(table.concat(tooltip_lines, "\n")).."]"
local tooltips = F(table.concat(tooltip_lines, "\n"))
if SHOW_AREA_TOOLTIPS then
formspec = formspec .. "tooltip["..x..","..y..";1,1;"..F(tooltips).."]"
else
formspec = formspec .. "tooltip[day"..iday..";"..F(tooltips).."]"
end
end
tdays = tdays + 1
end