mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-29 04:06:39 +09:00
Fixed Init Fail Bugs
This commit is contained in:
@@ -24,7 +24,7 @@ function center.add(obj)
|
||||
if not is_type(obj,'table') then return end
|
||||
if not is_type(obj.name,'string') then return end
|
||||
verbose('Created Center Gui: '..obj.name)
|
||||
setmetatable(obj,{__index=center._prototype,__call=function(self,...) center.open(player,self.name) end})
|
||||
setmetatable(obj,{__index=center._prototype,__call=function(self,player) return center.open(player,self.name) end})
|
||||
obj.tabs = {}
|
||||
obj._tabs = {}
|
||||
Gui.data('center',obj.name,obj)
|
||||
@@ -38,7 +38,7 @@ end
|
||||
-- @treturn table the gui element flow
|
||||
function center.get_flow(player)
|
||||
local player = Game.get_player(player)
|
||||
if not player then error('Invalid player') end
|
||||
if not player then error('Invalid player',2) end
|
||||
return player.gui.center.exp_center or player.gui.center.add{name='exp_center',type='flow'}
|
||||
end
|
||||
|
||||
@@ -49,7 +49,7 @@ end
|
||||
-- @treturn boelon based on if it successed or not
|
||||
function center.open(player,center)
|
||||
local player = Game.get_player(player)
|
||||
if not player then error('Invalid player') return false end
|
||||
if not player then error('Invalid player',2) return false end
|
||||
Gui.center.clear(player)
|
||||
if not Gui.data.center[center] then return false end
|
||||
Gui.data.center[center].open{
|
||||
@@ -67,7 +67,7 @@ end
|
||||
-- @treturn boelon based on if it successed or not
|
||||
function center.open_tab(player,center,tab)
|
||||
local player = Game.get_player(player)
|
||||
if not player then error('Invalid player') end
|
||||
if not player then error('Invalid player',2) end
|
||||
if not Gui.center.open(player,center) then return false end
|
||||
local name = center..'_'..tab
|
||||
if not Gui.data.inputs_button[name] then return false end
|
||||
@@ -212,4 +212,4 @@ end}
|
||||
|
||||
center.on_role_change = center.clear
|
||||
-- calling will attempt to add a new gui
|
||||
return setmetatable(center,{__call=function(self,...) self.add(...) end})
|
||||
return setmetatable(center,{__call=function(self,...) return self.add(...) end})
|
||||
@@ -111,7 +111,7 @@ function inputs.add(obj)
|
||||
obj.draw_data = table.deepcopy(obj)
|
||||
obj.data = {}
|
||||
obj.events = {}
|
||||
setmetatable(obj,{__index=inputs._prototype,__call=function(self,...) self:draw(...) end})
|
||||
setmetatable(obj,{__index=inputs._prototype,__call=function(self,...) return self:draw(...) end})
|
||||
Gui.data('inputs_'..type,obj.name,obj)
|
||||
return obj
|
||||
end
|
||||
@@ -380,6 +380,6 @@ function inputs.add_drop_down(name,items,index,callback)
|
||||
end
|
||||
|
||||
-- calling will attempt to add a new input
|
||||
return setmetatable(inputs,{__call=function(self,...) self.add(...) end})
|
||||
return setmetatable(inputs,{__call=function(self,...) return self.add(...) end})
|
||||
|
||||
-- to see examples look at GuiParts/test.lua
|
||||
|
||||
@@ -30,7 +30,7 @@ function left.add(obj)
|
||||
if not is_type(obj,'table') then return end
|
||||
if not is_type(obj.name,'string') then return end
|
||||
verbose('Created Left Gui: '..obj.name)
|
||||
setmetatable(obj,{__index=left._prototype,__call=function(self,player) if player then self:toggle(player) else left.update(self.name) end end})
|
||||
setmetatable(obj,{__index=left._prototype,__call=function(self,player) if player then return self:toggle(player) else return left.update(self.name) end end})
|
||||
Gui.data('left',obj.name,obj)
|
||||
Gui.toolbar(obj.name,obj.caption,obj.tooltip,function(event) obj:toggle(event) end)
|
||||
return obj
|
||||
@@ -205,4 +205,4 @@ function left:on_init()
|
||||
end
|
||||
|
||||
-- calling will attempt to add a new gui
|
||||
return setmetatable(left,{__call=function(self,...) self.add(...) end})
|
||||
return setmetatable(left,{__call=function(self,...) return self.add(...) end})
|
||||
@@ -35,7 +35,7 @@ function popup.add(obj)
|
||||
if not is_type(obj,'table') then return end
|
||||
if not is_type(obj.name,'string') then return end
|
||||
verbose('Created Popup Gui: '..obj.name)
|
||||
setmetatable(obj,{__index=popup._prototype,__call=function(self,data,player) local players = player and {player} or nil popup.open(self.name,data,players) end})
|
||||
setmetatable(obj,{__index=popup._prototype,__call=function(self,data,player) local players = player and {player} or nil return popup.open(self.name,data,players) end})
|
||||
local name = obj.name; obj.name = nil
|
||||
Gui.data('popup',name,obj)
|
||||
obj.name = name
|
||||
@@ -115,4 +115,4 @@ end
|
||||
popup.on_player_joined_game = popup.flow
|
||||
|
||||
-- calling will attempt to add a new popup style
|
||||
return setmetatable(popup,{__call=function(self,...) self.add(...) end})
|
||||
return setmetatable(popup,{__call=function(self,...) return self.add(...) end})
|
||||
@@ -54,4 +54,4 @@ end
|
||||
toolbar.on_role_change = toolbar.draw
|
||||
toolbar.on_player_joined_game = toolbar.draw
|
||||
-- calling with only a player will draw the toolbar for that player, more params will attempt to add a button
|
||||
return setmetatable(toolbar,{__call=function(self,player,extra,...) if extra then self.add(player,extra,...) else self.draw(player) end end})
|
||||
return setmetatable(toolbar,{__call=function(self,player,extra,...) if extra then return self.add(player,extra,...) else self.draw(player) end end})
|
||||
@@ -7,8 +7,8 @@
|
||||
--- This file will be loaded when ExpGamingCore.Gui is present
|
||||
-- @function _comment
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Gui = require('ExpGamingCore.Gui')
|
||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||
local Gui = require('ExpGamingCore.Gui@^4.0.0')
|
||||
local Sync = Sync -- this is to force sync to remain in the ENV
|
||||
|
||||
local Sync_gui_functions = {}
|
||||
@@ -99,7 +99,4 @@ script.on_event(defines.events.on_gui_click,function(event)
|
||||
end
|
||||
end)
|
||||
|
||||
script.on_event(defines.events.on_player_joined_game,function(event)
|
||||
local player = Game.get_player(event)
|
||||
Sync.info_gui(player)
|
||||
end)
|
||||
script.on_event(defines.events.on_player_joined_game,Sync.info_gui)
|
||||
Reference in New Issue
Block a user