From c989105bab6640f345234ed9ea4802d02d14c0f3 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 28 Aug 2020 13:45:16 +0200 Subject: [PATCH] Add setting to remove the 'Today' button --- API.md | 2 ++ gui.lua | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/API.md b/API.md index cd83dfe..ce2e387 100644 --- a/API.md +++ b/API.md @@ -127,6 +127,8 @@ get a tooltip. * `"full"`: Can change year and month (default) * `"months"`: Can change month only * `"none"`: Can't change anything + * `today_button`: Whether to show the 'Today' button (default: `true`) + Note: If `changable=="none"`, the 'Today' button is never shown * `wanted_months`: Which cardinal calendar month to show (default: current one) * `wanted_years`: Which cardinal calendar year to show (default: current one) * `caption_format`: Optional format information to change the calendar caption. diff --git a/gui.lua b/gui.lua index 17a41c2..26a8095 100644 --- a/gui.lua +++ b/gui.lua @@ -14,6 +14,7 @@ SHOW_WEEKDAYS = true SHOW_TODAY = true SHOWHOLIDAYS = true CHANGABLE = "full" +TODAY_BUTTON = true local DEFAULT_SETTINGS = { ordinal = ORDINAL, @@ -21,6 +22,7 @@ local DEFAULT_SETTINGS = { show_today = SHOW_TODAY, show_holidays = SHOW_HOLIDAYS, changable = CHANGABLE, + today_button = TODAY_BUTTON, } local SHOW_AREA_TOOLTIPS = minetest.features.formspec_version_element @@ -154,7 +156,9 @@ function calendar.show_calendar(player_name, settings, wanted_months, wanted_yea .. "tooltip[prev_year;"..F(S("Previous year")).."]" end end - formspec = formspec .. "button[2.5,"..y..";2,1;today;"..F(S("Today")).."]" + if settings.today_button then + formspec = formspec .. "button[2.5,"..y..";2,1;today;"..F(S("Today")).."]" + end if chg_months and wanted_months < calendar.MONTHS - 1 then formspec = formspec .. "button[4.5,"..y..";1,1;next_month;>]"