From 473004e72f72526428c0258945efd8db5cefe167 Mon Sep 17 00:00:00 2001 From: revolucas Date: Sun, 11 Sep 2016 16:01:47 -0400 Subject: [PATCH] scripts/ui_sleep_dialog.script: sleep_st_tbl changed to self.sleep_st_tbl. SetAutoDelete used for main dialog and message box dialog. --- res/gamedata/scripts/ui_sleep_dialog.script | 25 +++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/res/gamedata/scripts/ui_sleep_dialog.script b/res/gamedata/scripts/ui_sleep_dialog.script index 2b6e4c259a1..8caf72f4d03 100644 --- a/res/gamedata/scripts/ui_sleep_dialog.script +++ b/res/gamedata/scripts/ui_sleep_dialog.script @@ -6,6 +6,8 @@ function sleep_dialog:__init() super() if(device().width/device().height>(1024/768+0.01)) then wide = true end + + self:SetAutoDelete(true) local xml = CScriptXmlInit() xml:ParseFile("ui_sleep_dialog.xml") @@ -18,10 +20,10 @@ function sleep_dialog:__init() super() self.static_cover = xml:InitStatic("static_cover", self.back) self.st_marker = xml:InitStatic("st_marker", self.static_cover) - sleep_st_tbl = {} - for i = 1, 24 do - sleep_st_tbl[i] = xml:InitStatic("sleep_st_"..i, self.back) - end + self.sleep_st_tbl = {} + for i = 1, 24 do + self.sleep_st_tbl[i] = xml:InitStatic("sleep_st_"..i, self.back) + end self.time_track = xml:InitTrackBar("time_track", self.back) self:Register(self.time_track, "time_track") @@ -33,6 +35,7 @@ function sleep_dialog:__init() super() self:Register(self.btn_cancel, "btn_cancel") self.sleep_mb = CUIMessageBoxEx() + self.sleep_mb:self:SetAutoDelete(true) self:Register(self.sleep_mb, "sleep_mb") -------------------------------------------------------------------------------- self:AddCallback("btn_sleep", ui_events.BUTTON_CLICKED, self.OnButtonSleep, self) @@ -43,11 +46,11 @@ end function sleep_dialog:Initialize() local cur_hours = level.get_time_hours() for i = 1, 24 do - local hours = cur_hours + i - if(hours>=24) then - hours = hours - 24 - end - sleep_st_tbl[i]:TextControl():SetText(hours..game.translate_string("st_sleep_hours")) + local hours = cur_hours + i + if(hours>=24) then + hours = hours - 24 + end + self.sleep_st_tbl[i]:TextControl():SetText(hours..game.translate_string("st_sleep_hours")) end local delta = math.floor(591/24*cur_hours) @@ -72,6 +75,10 @@ function sleep_dialog:Initialize() self.sleep_static2:SetWndPos(pos) end +function sleep_dialog:__finalize() + sleep_control = nil +end + function sleep_dialog:TestAndShow() if(db.actor.bleeding>0 or db.actor.radiation>0) then self.sleep_mb:InitMessageBox("message_box_ok")