Tweak legacy daybox offset
parent
980f3b9798
commit
7d7998910c
45
gui.lua
45
gui.lua
|
@ -1,21 +1,22 @@
|
||||||
local S = calendar._get_translator("calendar")
|
local S = calendar._get_translator("calendar")
|
||||||
local F = minetest.formspec_escape
|
local F = minetest.formspec_escape
|
||||||
|
|
||||||
|
local player_current_calendars = {}
|
||||||
|
|
||||||
|
-- Colors
|
||||||
local COLOR_HOLIDAY = "#00FF00"
|
local COLOR_HOLIDAY = "#00FF00"
|
||||||
local COLOR_DAYBOX_HOLIDAY = "#00940FFF"
|
local COLOR_DAYBOX_HOLIDAY = "#00940FFF"
|
||||||
local COLOR_DAYBOX = "#1A1A1AFF"
|
local COLOR_DAYBOX = "#1A1A1AFF"
|
||||||
local COLOR_DAYBOX_TODAY = "#FFF508FF"
|
local COLOR_DAYBOX_TODAY = "#FFF508FF"
|
||||||
local COLOR_TOOLTIP_TODAY = COLOR_DAYBOX_TODAY
|
local COLOR_TOOLTIP_TODAY = COLOR_DAYBOX_TODAY
|
||||||
|
|
||||||
local player_current_calendars = {}
|
-- Default settings
|
||||||
|
local ORDINAL = true
|
||||||
ORDINAL = true
|
local SHOW_WEEKDAYS = true
|
||||||
SHOW_WEEKDAYS = true
|
local SHOW_TODAY = true
|
||||||
SHOW_TODAY = true
|
local SHOW_HOLIDAYS = true
|
||||||
SHOW_HOLIDAYS = true
|
local CHANGABLE = "full"
|
||||||
CHANGABLE = "full"
|
local TODAY_BUTTON = true
|
||||||
TODAY_BUTTON = true
|
|
||||||
|
|
||||||
local DEFAULT_SETTINGS = {
|
local DEFAULT_SETTINGS = {
|
||||||
ordinal = ORDINAL,
|
ordinal = ORDINAL,
|
||||||
show_weekdays = SHOW_WEEKDAYS,
|
show_weekdays = SHOW_WEEKDAYS,
|
||||||
|
@ -25,6 +26,18 @@ local DEFAULT_SETTINGS = {
|
||||||
today_button = TODAY_BUTTON,
|
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
|
local SHOW_AREA_TOOLTIPS = minetest.features.formspec_version_element
|
||||||
|
|
||||||
function calendar.show_calendar(player_name, settings, wanted_months, wanted_years, caption_format)
|
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
|
x, y = 0.75, 1.2
|
||||||
for w=1, #calendar.weekday_names_short do
|
for w=1, #calendar.weekday_names_short do
|
||||||
formspec = formspec .. "label["..x..","..y..";"..F(S(calendar.weekday_names_short[w])).."]"
|
formspec = formspec .. "label["..x..","..y..";"..F(S(calendar.weekday_names_short[w])).."]"
|
||||||
x = x + 1.1
|
x = x + 1 + DAYBOX_OFFSET
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
weekday = 0
|
weekday = 0
|
||||||
|
@ -101,9 +114,9 @@ function calendar.show_calendar(player_name, settings, wanted_months, wanted_yea
|
||||||
weekday = weekday + 1
|
weekday = weekday + 1
|
||||||
if weekday > calendar.WEEK_DAYS then
|
if weekday > calendar.WEEK_DAYS then
|
||||||
weekday = 1
|
weekday = 1
|
||||||
y = y + 1.1
|
y = y + 1 + DAYBOX_OFFSET
|
||||||
end
|
end
|
||||||
x = (weekday*1.1)- 0.5
|
x = (weekday * (1 + DAYBOX_OFFSET)) - 0.5
|
||||||
local pday = iday
|
local pday = iday
|
||||||
if settings.ordinal then
|
if settings.ordinal then
|
||||||
pday = iday + 1
|
pday = iday + 1
|
||||||
|
@ -128,7 +141,7 @@ function calendar.show_calendar(player_name, settings, wanted_months, wanted_yea
|
||||||
if SHOW_AREA_TOOLTIPS then
|
if SHOW_AREA_TOOLTIPS then
|
||||||
formspec = formspec .. "box["..(x-0.05)..","..(y-0.05)..";1.1,1.1;"..COLOR_DAYBOX_TODAY.."]"
|
formspec = formspec .. "box["..(x-0.05)..","..(y-0.05)..";1.1,1.1;"..COLOR_DAYBOX_TODAY.."]"
|
||||||
else
|
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
|
end
|
||||||
table.insert(tooltip_lines, minetest.colorize(COLOR_TOOLTIP_TODAY, S("Today")))
|
table.insert(tooltip_lines, minetest.colorize(COLOR_TOOLTIP_TODAY, S("Today")))
|
||||||
end
|
end
|
||||||
|
@ -154,11 +167,11 @@ function calendar.show_calendar(player_name, settings, wanted_months, wanted_yea
|
||||||
end
|
end
|
||||||
tdays = tdays + 1
|
tdays = tdays + 1
|
||||||
end
|
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
|
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
|
end
|
||||||
y = y + 0.1
|
y = y + DAYBOX_OFFSET
|
||||||
local chg_months = settings.changable == "full" or settings.changable == "months"
|
local chg_months = settings.changable == "full" or settings.changable == "months"
|
||||||
local chg_years = settings.changable == "full"
|
local chg_years = settings.changable == "full"
|
||||||
-- Add controls
|
-- Add controls
|
||||||
|
|
Loading…
Reference in New Issue