mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +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)
|
||||
@@ -15,7 +15,7 @@ local poll_time_out = 90 -- In seconds
|
||||
local module_verbose = false
|
||||
local ThisModule = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Server@^4.0.0'] then Role = require('ExpGamingCore.Server@^4.0.0') end
|
||||
if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end
|
||||
end
|
||||
}
|
||||
|
||||
@@ -65,6 +65,29 @@ local function _poll_data(question,answers)
|
||||
return poll.uuid
|
||||
end
|
||||
|
||||
local function draw_poll(frame)
|
||||
frame.clear()
|
||||
local index = tonumber(frame.parent.current_index.caption)
|
||||
local poll = global.old[index]
|
||||
if not poll then
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'polls.no-poll'}
|
||||
}
|
||||
return
|
||||
end
|
||||
frame.add{
|
||||
type='label',
|
||||
caption='Question: '..poll.question
|
||||
}
|
||||
for answer,votes in pairs(poll.votes) do
|
||||
frame.add{
|
||||
type='label',
|
||||
caption=answer..') '..votes
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
local function _opptions(player,root_frame)
|
||||
local opptions = {'Please Select An Opption'}
|
||||
local uuid = root_frame.name
|
||||
@@ -227,7 +250,7 @@ ThisModule.Gui = Gui.popup{
|
||||
local btn = next:draw(title)
|
||||
btn.style.width = 20
|
||||
btn.style.height = 20
|
||||
if Role and Role.get_highest(frame.player_index):allowed('create-poll') or player.admin then
|
||||
if Role and Role.allowed(frame.player_index,'create-poll') or player.admin then
|
||||
local btn = create_poll:draw(title)
|
||||
btn.style.width = 20
|
||||
btn.style.height = 20
|
||||
|
||||
@@ -21,10 +21,10 @@ local function _roles(player)
|
||||
local _role = Role.get_highest(player)
|
||||
for index,role_name in pairs(Role.order) do
|
||||
if index >= _role.index then
|
||||
table.insert(ranks,role_name)
|
||||
table.insert(roles,role_name)
|
||||
end
|
||||
end
|
||||
return ranks
|
||||
return roles
|
||||
end
|
||||
|
||||
local role_drop_down = Gui.inputs.add_drop_down('rank-drop-down-annoncements',_roles,1,function(player,selected,items,element)
|
||||
@@ -91,8 +91,8 @@ ThisModule.Gui = Gui.popup{
|
||||
type='label',
|
||||
caption={'announcements.select-rank'}
|
||||
}
|
||||
rank_drop_down:draw(flow)
|
||||
local btn = send_popup:draw(flow)
|
||||
role_drop_down(flow)
|
||||
local btn = send_popup(flow)
|
||||
btn.style.visible = false
|
||||
btn.style.height = 25
|
||||
btn.style.width = 25
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
-- @alais ThisModule
|
||||
|
||||
-- Module Require
|
||||
local Color = require('FactorioStdLib@Color@^0.8.0')
|
||||
local Color = require('FactorioStdLib.Color@^0.8.0')
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
@@ -35,8 +35,8 @@ Event.register(defines.events.on_player_created, function(event)
|
||||
while player.color.r == defines.color.black.r and player.color.g == defines.color.black.g and player.color.b == defines.color.black.b
|
||||
or player.color.r == defines.color.white.r and player.color.g == defines.color.white.g and player.color.b == defines.color.white.b do
|
||||
player.color = defines.color[colours[math.random(#colours)]]
|
||||
if default_colours[player.name] then
|
||||
local c = default_colours[player.name]
|
||||
if global[player.name] then
|
||||
local c = global[player.name]
|
||||
player.color = Color.from_rgb(c.r,c.g,c.b)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user