I have no idea how to do that yet, also don't use that version, gonna remove it in a second.
This one doesn't have the hang error that it did:
--Alter the date which the updating region process finishes at.
local gui = require 'gui'
local widgets = require 'gui.widgets'
local vw = df.global.gview.view.child
local yr
local mn
local dy
updater=defclass(updater,gui.Screen)
updater.focus_path = 'updatefinish'
function updater:init()
self:addviews{
widgets.Label{
view_id="mainLabel",
frame = {xalign=0,yalign=0},
text={
{id="cmd", text=" Left/Right: Day, Up/Down: Week, Fast: Month/3 Months, Enter/Esc: To "},
{id="yr", text=self:callback("getYear")},{text="/"}, {id="mn", text=self:callback("getMonth")},{text="/"}, {id="dy", text=self:callback("getDay")},{text=" "}}
}
}
end
function updater:getYear()
if df.viewscreen_update_regionst:is_instance(vw) then
yr = vw.year
else
yr = df.global.cur_year
end
return yr
end
function updater:getMonth()
if df.viewscreen_update_regionst:is_instance(vw) then
if vw.year_tick>=33600 then
mn = math.floor(vw.year_tick/33600)+1
else
mn = 1
end
else
mn = math.floor(df.global.cur_year_tick/33600)+1
end
return mn
end
function updater:getDay()
if df.viewscreen_update_regionst:is_instance(vw) then
local mf = (mn-1)*28
local yf = math.floor(vw.year_tick/1200)
if vw.year_tick>=1200 then
dy = (yf-mf)+1
else
dy = 1
end
else
mf = (math.floor(df.global.cur_year_tick/33600))*28
yf = math.floor(df.global.cur_year_tick/1200)
dy = (yf-mf)+1
end
return dy
end
function updater:onInput(keys)
if df.viewscreen_update_regionst:is_instance(vw) then
if keys.LEAVESCREEN or keys.SELECT then
self:dismiss()
end
if keys.CURSOR_RIGHT then
if vw.year_tick>=402000 then
vw.year = vw.year+1
vw.year_tick = 0
else
vw.year_tick = vw.year_tick+1200
end
elseif keys.CURSOR_RIGHT_FAST then
if vw.year_tick>=369600 then
vw.year = vw.year+1
vw.year_tick = 0
else
vw.year_tick = vw.year_tick+33600
end
elseif keys.CURSOR_LEFT then
if vw.year_tick<=1200 then
vw.year = vw.year-1
vw.year_tick = 402000
else
vw.year_tick = vw.year_tick-1200
end
elseif keys.CURSOR_LEFT_FAST then
if vw.year_tick<=33600 then
vw.year = vw.year-1
vw.year_tick = 369600
else
vw.year_tick = vw.year_tick-33600
end
elseif keys.CURSOR_UP then
if vw.year_tick<=8400 then
vw.year = vw.year-1
vw.year_tick = vw.year_tick+394800
else
vw.year_tick = vw.year_tick-8400
end
elseif keys.CURSOR_UP_FAST then
if vw.year_tick<=100800 then
vw.year = vw.year-1
vw.year_tick = vw.year_tick+302400
else
vw.year_tick = vw.year_tick-100800
end
elseif keys.CURSOR_DOWN then
if vw.year_tick>=394800 then
vw.year = vw.year+1
vw.year_tick = vw.year_tick-394800
else
vw.year_tick = vw.year_tick+8400
end
elseif keys.CURSOR_DOWN_FAST then
if vw.year_tick>=302400 then
vw.year = vw.year+1
vw.year_tick = vw.year_tick-302400
else
vw.year_tick = vw.year_tick+100800
end
end
elseif not df.viewscreen_update_regionst:is_instance(vw) then
if keys then
self:dismiss()
qerror("This has to be used on the updating region screen!")
end
end
self.super.onInput(self,keys)
end
function updater:onRenderBody(dc)
self._native.parent:render()
end
updater():show()
I'll try to figure out how to have it display the current date but this is the first time I've ever actually thrown up text on screen for a script, everything else I've ever done has just used the in-game display/interface where appropriate but I needed an indicator that the selection was active and when it was dismissed so I had to figure out some basic widgetry.
The version I posted originally was borked because I derped on the "check if this is the right screen and exit if not" so it just screams at you "LA LA LA YOU ARE ON THE WRONG SCREEN HA HA FUCK YOU" until you devel/pop-screen it.
Now it just exits and shows the error message if used on the wrong screen because I couldn't make it not show on the right screen yet, better a graceful clear than nothing I guess?