From d8a1d43afec2277b4a6698d56a7a51da7ace6d8b Mon Sep 17 00:00:00 2001 From: bajdcc Date: Thu, 1 Feb 2018 16:44:04 +0800 Subject: [PATCH] ADD: Disable restart button while booting --- .../script/lib/ui/comctl/button.lua | 21 +++++++++++++++++++ CCGameFramework/script/scene/simu/x86.lua | 11 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/CCGameFramework/script/lib/ui/comctl/button.lua b/CCGameFramework/script/lib/ui/comctl/button.lua index f2fe9d3..7bdd86e 100644 --- a/CCGameFramework/script/lib/ui/comctl/button.lua +++ b/CCGameFramework/script/lib/ui/comctl/button.lua @@ -87,6 +87,27 @@ end function M:reset(text) self.text = text self.layers.fg.text = text + if self.enable ~= 1 then + self.layers.bg.color = self.bgcolor + self.layers.fg.color = self.fgcolor_disable + end + self.layers.bg:update() + self.layers.fg:update() +end + +function M:disabled() + self.enable = 2 + self.layers.bg.color = self.bgcolor + self.layers.fg.color = self.fgcolor_disable + self.layers.bg:update() + self.layers.fg:update() +end + +function M:enabled() + self.enable = 1 + self.layers.bg.color = self.bgcolor + self.layers.fg.color = self.fgcolor + self.layers.bg:update() self.layers.fg:update() end diff --git a/CCGameFramework/script/scene/simu/x86.lua b/CCGameFramework/script/scene/simu/x86.lua index b806653..1943d74 100644 --- a/CCGameFramework/script/scene/simu/x86.lua +++ b/CCGameFramework/script/scene/simu/x86.lua @@ -122,6 +122,10 @@ function M:init_event() this.layers.rtstatus.text = string.format("IPS: %d", span) end this.layers.rtstatus:update_and_paint() + elseif id == 12 then + this.layers.restart_btn:enabled() + UIExt.paint() + UIExt.kill_timer(12) end end self.handler[self.win_event.keydown] = function(this, code, flags) @@ -171,8 +175,14 @@ function M:init_menu(info) font_size = 16, click = function() UIExt.refresh(CurrentScene.layers.x86, 5) + CurrentScene.layers.restart_btn:disabled() + UIExt.set_timer(12, 6000) + UIExt.paint() end }):attach(slider) + self.layers.restart_btn = slider.children[#slider.children] + self.layers.restart_btn:disabled() + UIExt.set_timer(12, 6000) Button:new({ text = 'ÔÝÍ£/¼ÌÐø', font_family = '¿¬Ìå', @@ -190,6 +200,7 @@ function M:init_menu(info) end }):attach(slider) self.layers.rtstatus = slider.children[#slider.children] + UIExt.paint() end return M \ No newline at end of file