Fix changable="months" mode
This commit is contained in:
parent
ef753f94a2
commit
c6e2848b56
2
API.md
2
API.md
@ -177,7 +177,7 @@ get a tooltip.
|
|||||||
* `show_holiday`: If `true`, mark holidays (default: `true`)
|
* `show_holiday`: If `true`, mark holidays (default: `true`)
|
||||||
* `changable`: Which controls are available:
|
* `changable`: Which controls are available:
|
||||||
* `"full"`: Can change year and month (default)
|
* `"full"`: Can change year and month (default)
|
||||||
* `"months"`: Can change month only
|
* `"months"`: Can change month within selected year only
|
||||||
* `"none"`: Can't change anything
|
* `"none"`: Can't change anything
|
||||||
* `today_button`: Whether to show the 'Today' button (default: `true`)
|
* `today_button`: Whether to show the 'Today' button (default: `true`)
|
||||||
Note: If `changable=="none"`, the 'Today' button is never shown
|
Note: If `changable=="none"`, the 'Today' button is never shown
|
||||||
|
9
gui.lua
9
gui.lua
@ -183,8 +183,9 @@ function calendar.show_calendar(player_name, settings, wanted_months, wanted_yea
|
|||||||
local chg_years = settings.changable == "full"
|
local chg_years = settings.changable == "full"
|
||||||
-- Add controls
|
-- Add controls
|
||||||
if chg_months then
|
if chg_months then
|
||||||
|
|
||||||
if wanted_months > 0 or wanted_years > 0 then
|
if wanted_months > 0 or wanted_years > 0 then
|
||||||
if chg_months or wanted_months > 0 then
|
if (chg_years or wanted_months > 0) or (not chg_years and wanted_months > 0) then
|
||||||
formspec = formspec .. "button[1.5,"..y..";1,1;prev_month;<]"
|
formspec = formspec .. "button[1.5,"..y..";1,1;prev_month;<]"
|
||||||
.. "tooltip[prev_month;"..F(S("Previous month")).."]"
|
.. "tooltip[prev_month;"..F(S("Previous month")).."]"
|
||||||
end
|
end
|
||||||
@ -197,7 +198,7 @@ function calendar.show_calendar(player_name, settings, wanted_months, wanted_yea
|
|||||||
formspec = formspec .. "button[2.5,"..y..";2,1;today;"..F(S("Today")).."]"
|
formspec = formspec .. "button[2.5,"..y..";2,1;today;"..F(S("Today")).."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
if chg_months or wanted_months < calendar.MONTHS - 1 then
|
if (chg_years or wanted_months < calendar.MONTHS - 1) or (not chg_years and wanted_months < calendar.MONTHS - 1) then
|
||||||
formspec = formspec .. "button[4.5,"..y..";1,1;next_month;>]"
|
formspec = formspec .. "button[4.5,"..y..";1,1;next_month;>]"
|
||||||
.. "tooltip[next_month;"..F(S("Next month")).."]"
|
.. "tooltip[next_month;"..F(S("Next month")).."]"
|
||||||
end
|
end
|
||||||
@ -256,7 +257,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
if fields.next_month then
|
if fields.next_month then
|
||||||
cur_months = cur_months + 1
|
cur_months = cur_months + 1
|
||||||
if cur_months > calendar.MONTHS - 1 then
|
if cur_months > calendar.MONTHS - 1 then
|
||||||
if settings.changable == "months" or settings.changable == "full" then
|
if settings.changable == "full" then
|
||||||
cur_months = 0
|
cur_months = 0
|
||||||
cur_years = cur_years + 1
|
cur_years = cur_years + 1
|
||||||
else
|
else
|
||||||
@ -267,7 +268,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
elseif fields.prev_month then
|
elseif fields.prev_month then
|
||||||
cur_months = cur_months - 1
|
cur_months = cur_months - 1
|
||||||
if cur_months < 0 and cur_years > 0 then
|
if cur_months < 0 and cur_years > 0 then
|
||||||
if settings.changable == "months" or settings.changable == "full" then
|
if settings.changable == "full" then
|
||||||
cur_months = calendar.MONTHS - 1
|
cur_months = calendar.MONTHS - 1
|
||||||
cur_years = cur_years - 1
|
cur_years = cur_years - 1
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user