Fixed gui closing when pressing them

This commit is contained in:
Cooldude2606
2019-05-29 20:51:49 +01:00
parent 9f00de8ae2
commit aa46e33a5a
2 changed files with 13 additions and 13 deletions

View File

@@ -75,8 +75,8 @@ function CenterFrames.toggle_frame(player,name,state)
return true return true
elseif state == false then elseif state == false then
local flow = CenterFrames.get_flow(player) local flow = CenterFrames.get_flow(player)
if flow[define.name] then if flow[define.name..'-frame'] then
flow[define.name].destroy() flow[define.name..'-frame'].destroy()
end end
return false return false
else else
@@ -99,7 +99,7 @@ function CenterFrames.new_frame(permision_name)
mt.__index = CenterFrames._prototype mt.__index = CenterFrames._prototype
mt.__call = self.event_handler mt.__call = self.event_handler
Gui.on_custom_close(self.name,function(event) Gui.on_custom_close(self.name..'-frame',function(event)
local element = event.element local element = event.element
if element and element.valid then element.destroy() end if element and element.valid then element.destroy() end
end) end)
@@ -124,8 +124,8 @@ function CenterFrames._prototype:draw_frame(player)
player = Game.get_player_from_any(player) player = Game.get_player_from_any(player)
local flow = CenterFrames.get_flow(player) local flow = CenterFrames.get_flow(player)
if flow[self.name] then if flow[self.name..'-frame'] then
return flow[self.name] return flow[self.name..'-frame']
end end
if self.auto_focus then if self.auto_focus then
@@ -134,7 +134,7 @@ function CenterFrames._prototype:draw_frame(player)
local frame = flow.add{ local frame = flow.add{
type='frame', type='frame',
name=self.name name=self.name..'-frame'
} }
if self.auto_focus then if self.auto_focus then
@@ -155,8 +155,8 @@ function CenterFrames._prototype:redraw_frame(player)
player = Game.get_player_from_any(player) player = Game.get_player_from_any(player)
local flow = CenterFrames.get_flow(player) local flow = CenterFrames.get_flow(player)
if flow[self.name] then if flow[self.name..'-frame'] then
flow[self.name].destroy() flow[self.name..'-frame'].destroy()
end end
return self:draw_frame(player) return self:draw_frame(player)
@@ -169,8 +169,8 @@ function CenterFrames._prototype:toggle_frame(player)
player = Game.get_player_from_any(player) player = Game.get_player_from_any(player)
local flow = CenterFrames.get_flow(player) local flow = CenterFrames.get_flow(player)
if flow[self.name] then if flow[self.name..'-frame'] then
flow[self.name].destroy() flow[self.name..'-frame'].destroy()
return false return false
else else
self:draw_frame(player) self:draw_frame(player)

View File

@@ -174,8 +174,8 @@ end
-- @treturn LuaGuiElement the frame in the left frame flow for this define -- @treturn LuaGuiElement the frame in the left frame flow for this define
function LeftFrames._prototype:get_frame(player) function LeftFrames._prototype:get_frame(player)
local flow = LeftFrames.get_flow(player) local flow = LeftFrames.get_flow(player)
if flow[self.name] and flow[self.name].valid then if flow[self.name..'-frame'] and flow[self.name..'-frame'].valid then
return flow[self.name] return flow[self.name..'-frame']
end end
end end
@@ -276,7 +276,7 @@ Event.add(defines.events.on_player_created,function(event)
for _,define in pairs(LeftFrames.frames) do for _,define in pairs(LeftFrames.frames) do
local frame = flow.add{ local frame = flow.add{
type='frame', type='frame',
name=define.name, name=define.name..'-frame',
direction=define.direction direction=define.direction
} }