Spell Check and Lua Check

This commit is contained in:
Cooldude2606
2019-01-11 22:32:30 +00:00
parent 7110b76444
commit 082d9e5439
65 changed files with 760 additions and 724 deletions

View File

@@ -15,11 +15,11 @@ center._prototype = {}
--- Adds a new obj to the center gui
-- @usage Gui.center.add{name='foo',caption='Foo',tooltip='Testing',draw=function}
-- @usage return_value(player) -- opens the center gui for that player
-- @param obj contains the new object, needs name, fraw is opt and is function(root_frame)
-- @param obj contains the new object, needs name, frame is opt and is function(root_frame)
-- @return the object made, used to add tabs, calling the returned value will open the center for the given player
function center.add(obj)
if not is_type(obj,'table') then return end
if not is_type(obj.name,'string') then return end
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,player,...) return center.open(player,self.name,...) end})
obj.tabs = {}
@@ -30,32 +30,32 @@ function center.add(obj)
end
--- Used to get the center frame of the player, used mainly in script
-- @usage Gui.center.get_flow(player) -- returns gui emelemt
-- @param player a player indifier to get the flow for
-- @usage Gui.center.get_flow(player) -- returns gui element
-- @param player a player identifier to get the flow for
-- @treturn table the gui element flow
function center.get_flow(player)
local player = Game.get_player(player)
player = Game.get_player(player)
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
--- Used to open a center frame for a player, extra params are sent to open event
-- @usage Gui.center.open(player,'server-info') -- return true
-- @param player a player indifier to get the flow for
-- @tparam string center the name of the center frame to open
-- @treturn boelon based on if it successed or not
function center.open(player,center,...)
local player = Game.get_player(player)
-- @param player a player identifier to get the flow for
-- @tparam string center_name the name of the center frame to open
-- @treturn boolean based on if it succeeded or not
function center.open(player,center_name,...)
player = Game.get_player(player)
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
local self = Gui.data.center[center]
if not Gui.data.center[center_name] then return false end
local self = Gui.data.center[center_name]
-- this function is the draw function passed to the open event
self:open(player,function(...) Gui.center._draw(self,...) end,...)
return true
end
-- used as a pice of middle ware for the open event
-- used as a piece of middle ware for the open event
function center._draw(self,frame,...)
game.players[frame.player_index].opened=frame
if is_type(self.draw,'function') then
@@ -66,37 +66,37 @@ end
--- Used to open a center frame for a player
-- @usage Gui.center.open_tab(player,'readme','rules') -- return true
-- @param player a player indifier to get the flow for
-- @param player a player identifier to get the flow for
-- @tparam string center the name of the center frame to open
-- @tparam string tab the name of the tab to open
-- @treturn boelon based on if it successed or not
function center.open_tab(player,center,tab)
local player = Game.get_player(player)
-- @treturn boolean based on if it succeeded or not
function center.open_tab(player,center_name,tab)
player = Game.get_player(player)
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.center.open(player,center_name) then return false end
local name = center_name..'_'..tab
if not Gui.data.inputs_button[name] then return false end
Gui.data.inputs_button[name].events[defines.events.on_gui_click]{
element=Gui.center.get_flow(player)[center].tab_bar.tab_bar_scroll.tab_bar_scroll_flow[name],
element=Gui.center.get_flow(player)[center_name].tab_bar.tab_bar_scroll.tab_bar_scroll_flow[name],
}
return true
end
--- Used to clear the center frame of the player, used mainly in script
-- @usage Gui.center.clear(player)
-- @param player a player indifier to get the flow for
-- @param player a player identifier to get the flow for
function center.clear(player)
local player = Game.get_player(player)
player = Game.get_player(player)
center.get_flow(player).clear()
end
-- opens this gui for this player, draw is the draw function when event is called from center.open
-- this is the default function it can be overriden when the gui is defined, simply call draw on the frame you create
-- this is the default function it can be overridden when the gui is defined, simply call draw on the frame you create
-- extra values passed to draw will also be passed to the draw event
-- extra values from center.draw and passed to the open event
function center._prototype:open(player,draw,...)
local player = Game.get_player(player)
local draw = draw or function(...) center._draw(self,...) end
player = Game.get_player(player)
draw = draw or function(...) center._draw(self,...) end
local center_flow = center.get_flow(player)
if center_flow[self.name] then Gui.center.clear(player) return end
local center_frame = center_flow.add{
@@ -110,8 +110,8 @@ function center._prototype:open(player,draw,...)
draw(center_frame,...)
end
-- this is the default draw function if one is not provided, can be overriden
-- not recomented for direct use see Gui.center.open
-- this is the default draw function if one is not provided, can be overridden
-- not recommended for direct use see Gui.center.open
function center._prototype:draw(frame)
Gui.bar(frame,510)
local tab_bar = frame.add{
@@ -123,8 +123,8 @@ function center._prototype:draw(frame)
tab_bar.style.width = 510
tab_bar.style.height = 65
local tab_bar_scroll = tab_bar.add{
type='scroll-pane',
name='tab_bar_scroll',
type='scroll-pane',
name='tab_bar_scroll',
horizontal_scroll_policy='auto-and-reserve-space',
vertical_scroll_policy='never'
}
@@ -147,7 +147,7 @@ function center._prototype:draw(frame)
tab.style.height = 305
local tab_scroll = tab.add{
type ='scroll-pane',
name='tab_scroll',
name='tab_scroll',
horizontal_scroll_policy='never',
vertical_scroll_policy='auto'
}
@@ -155,8 +155,8 @@ function center._prototype:draw(frame)
tab_scroll.style.vertically_stretchable = true
tab_scroll.style.width = 500
local tab_scroll_flow = tab_scroll.add{
type='flow',
name='tab_scroll_flow',
type='flow',
name='tab_scroll_flow',
direction='vertical'
}
tab_scroll_flow.style.width = 480
@@ -171,7 +171,7 @@ function center._prototype:draw(frame)
frame.parent.add{type='frame',name='temp'}.destroy()--recenter the GUI
end
--- If deafult draw is used then you can add tabs to the gui with this function
--- If default draw is used then you can add tabs to the gui with this function
-- @usage _center:add_tab('foo','Foo','Just a tab',function)
-- @tparam string name this is the name of the tab
-- @tparam string caption this is the words that appear on the tab button
@@ -214,7 +214,7 @@ end)
script.on_event(defines.events.on_player_respawned,center.clear)
function center:on_init()
function center.on_init()
if loaded_modules['ExpGamingCore.Role'] then script.on_event(defines.events.on_role_change,center.clear) end
end
-- calling will attempt to add a new gui