Skip to content

Commit 473004e

Browse files
committed
scripts/ui_sleep_dialog.script: sleep_st_tbl changed to self.sleep_st_tbl. SetAutoDelete used for main dialog and message box dialog.
1 parent 9ea54f9 commit 473004e

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

res/gamedata/scripts/ui_sleep_dialog.script

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ function sleep_dialog:__init() super()
66
if(device().width/device().height>(1024/768+0.01)) then
77
wide = true
88
end
9+
10+
self:SetAutoDelete(true)
911

1012
local xml = CScriptXmlInit()
1113
xml:ParseFile("ui_sleep_dialog.xml")
@@ -18,10 +20,10 @@ function sleep_dialog:__init() super()
1820
self.static_cover = xml:InitStatic("static_cover", self.back)
1921
self.st_marker = xml:InitStatic("st_marker", self.static_cover)
2022

21-
sleep_st_tbl = {}
22-
for i = 1, 24 do
23-
sleep_st_tbl[i] = xml:InitStatic("sleep_st_"..i, self.back)
24-
end
23+
self.sleep_st_tbl = {}
24+
for i = 1, 24 do
25+
self.sleep_st_tbl[i] = xml:InitStatic("sleep_st_"..i, self.back)
26+
end
2527

2628
self.time_track = xml:InitTrackBar("time_track", self.back)
2729
self:Register(self.time_track, "time_track")
@@ -33,6 +35,7 @@ function sleep_dialog:__init() super()
3335
self:Register(self.btn_cancel, "btn_cancel")
3436

3537
self.sleep_mb = CUIMessageBoxEx()
38+
self.sleep_mb:self:SetAutoDelete(true)
3639
self:Register(self.sleep_mb, "sleep_mb")
3740
--------------------------------------------------------------------------------
3841
self:AddCallback("btn_sleep", ui_events.BUTTON_CLICKED, self.OnButtonSleep, self)
@@ -43,11 +46,11 @@ end
4346
function sleep_dialog:Initialize()
4447
local cur_hours = level.get_time_hours()
4548
for i = 1, 24 do
46-
local hours = cur_hours + i
47-
if(hours>=24) then
48-
hours = hours - 24
49-
end
50-
sleep_st_tbl[i]:TextControl():SetText(hours..game.translate_string("st_sleep_hours"))
49+
local hours = cur_hours + i
50+
if(hours>=24) then
51+
hours = hours - 24
52+
end
53+
self.sleep_st_tbl[i]:TextControl():SetText(hours..game.translate_string("st_sleep_hours"))
5154
end
5255

5356
local delta = math.floor(591/24*cur_hours)
@@ -72,6 +75,10 @@ function sleep_dialog:Initialize()
7275
self.sleep_static2:SetWndPos(pos)
7376
end
7477

78+
function sleep_dialog:__finalize()
79+
sleep_control = nil
80+
end
81+
7582
function sleep_dialog:TestAndShow()
7683
if(db.actor.bleeding>0 or db.actor.radiation>0) then
7784
self.sleep_mb:InitMessageBox("message_box_ok")

0 commit comments

Comments
 (0)