Tweak legacy daybox offset

master
Wuzzy 2020-08-28 15:41:20 +02:00
parent 980f3b9798
commit 7d7998910c
1 changed files with 29 additions and 16 deletions

45
gui.lua
View File

@ -1,21 +1,22 @@
local S = calendar._get_translator("calendar")
local F = minetest.formspec_escape
local player_current_calendars = {}
-- Colors
local COLOR_HOLIDAY = "#00FF00"
local COLOR_DAYBOX_HOLIDAY = "#00940FFF"
local COLOR_DAYBOX = "#1A1A1AFF"
local COLOR_DAYBOX_TODAY = "#FFF508FF"
local COLOR_TOOLTIP_TODAY = COLOR_DAYBOX_TODAY
local player_current_calendars = {}
ORDINAL = true
SHOW_WEEKDAYS = true
SHOW_TODAY = true
SHOW_HOLIDAYS = true
CHANGABLE = "full"
TODAY_BUTTON = true
-- Default settings
local ORDINAL = true
local SHOW_WEEKDAYS = true
local SHOW_TODAY = true
local SHOW_HOLIDAYS = true
local CHANGABLE = "full"
local TODAY_BUTTON = true
local DEFAULT_SETTINGS = {
ordinal = ORDINAL,
show_weekdays = SHOW_WEEKDAYS,
@ -25,6 +26,18 @@ local DEFAULT_SETTINGS = {
today_button = TODAY_BUTTON,
}
-- Offset between dayboxes
local DAYBOX_OFFSET
if minetest.features.formspec_version_element then
DAYBOX_OFFSET = 0.1
else
DAYBOX_OFFSET = 0
end
-- Check if area tooltips are supported.
-- minetest.features, doesn't tell us that directly, but
-- the formspec version element was added after area tooltips,
-- so if those are present, area tooltips have to be supported as well.
local SHOW_AREA_TOOLTIPS = minetest.features.formspec_version_element
function calendar.show_calendar(player_name, settings, wanted_months, wanted_years, caption_format)
@ -89,7 +102,7 @@ function calendar.show_calendar(player_name, settings, wanted_months, wanted_yea
x, y = 0.75, 1.2
for w=1, #calendar.weekday_names_short do
formspec = formspec .. "label["..x..","..y..";"..F(S(calendar.weekday_names_short[w])).."]"
x = x + 1.1
x = x + 1 + DAYBOX_OFFSET
end
else
weekday = 0
@ -101,9 +114,9 @@ function calendar.show_calendar(player_name, settings, wanted_months, wanted_yea
weekday = weekday + 1
if weekday > calendar.WEEK_DAYS then
weekday = 1
y = y + 1.1
y = y + 1 + DAYBOX_OFFSET
end
x = (weekday*1.1)- 0.5
x = (weekday * (1 + DAYBOX_OFFSET)) - 0.5
local pday = iday
if settings.ordinal then
pday = iday + 1
@ -128,7 +141,7 @@ function calendar.show_calendar(player_name, settings, wanted_months, wanted_yea
if SHOW_AREA_TOOLTIPS then
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.."]"
formspec = formspec .. "box["..(x-0.075)..","..(y-0.075)..";0.95,1.05;"..COLOR_DAYBOX_TODAY.."]"
end
table.insert(tooltip_lines, minetest.colorize(COLOR_TOOLTIP_TODAY, S("Today")))
end
@ -154,11 +167,11 @@ function calendar.show_calendar(player_name, settings, wanted_months, wanted_yea
end
tdays = tdays + 1
end
y = y + 1.1
y = y + 1 + DAYBOX_OFFSET
if settings.show_weekdays and calendar.get_weekday(tdays_start) <= calendar.get_weekday(tdays - 1) then
y = y + 1.1
y = y + 1 + DAYBOX_OFFSET
end
y = y + 0.1
y = y + DAYBOX_OFFSET
local chg_months = settings.changable == "full" or settings.changable == "months"
local chg_years = settings.changable == "full"
-- Add controls