Gui debug added

This commit is contained in:
Cooldude2606
2017-09-22 16:37:36 +01:00
parent 9eabc1b925
commit bb2009b7f7
6 changed files with 18 additions and 1 deletions

View File

@@ -43,6 +43,7 @@ ExpGui.add_input.button('close_center','Close','Close this GUI',function(player,
function draw_frame.center(player,element) function draw_frame.center(player,element)
local frame_data = nil local frame_data = nil
for _,frame in pairs(frames.center) do if element.name == frame.name then frame_data = frame break end end for _,frame in pairs(frames.center) do if element.name == frame.name then frame_data = frame break end end
debug_write({'GUI','CENTER'},player.name..' '..frame_data.name)
if player.gui.is_valid_sprite_path(frame_data.display) then frame_data.display = frame_data.name end if player.gui.is_valid_sprite_path(frame_data.display) then frame_data.display = frame_data.name end
if player.gui.center[frame_data.name] then player.gui.center.clear() return else player.gui.center.clear() end if player.gui.center[frame_data.name] then player.gui.center.clear() return else player.gui.center.clear() end
local frame = player.gui.center.add{name=frame_data.name,type='frame',caption=frame_data.display,direction='vertical',style=mod_gui.frame_style} local frame = player.gui.center.add{name=frame_data.name,type='frame',caption=frame_data.display,direction='vertical',style=mod_gui.frame_style}
@@ -50,7 +51,7 @@ function draw_frame.center(player,element)
local tab_bar_scroll = frame.add{type = "scroll-pane", name= "tab_bar_scroll", vertical_scroll_policy="never", horizontal_scroll_policy="always"} local tab_bar_scroll = frame.add{type = "scroll-pane", name= "tab_bar_scroll", vertical_scroll_policy="never", horizontal_scroll_policy="always"}
local tab_bar = tab_bar_scroll.add{type='flow',direction='horizontal',name='tab_bar'} local tab_bar = tab_bar_scroll.add{type='flow',direction='horizontal',name='tab_bar'}
local tab = frame.add{type = "scroll-pane", name= "tab", vertical_scroll_policy="auto", horizontal_scroll_policy="never"} local tab = frame.add{type = "scroll-pane", name= "tab", vertical_scroll_policy="auto", horizontal_scroll_policy="never"}
for n,t in pairs(frame_data.tabs) do if rank_allowed(get_rank(player),t.name..'_tab') then ExpGui.add_input.draw_button(tab_bar,t.name) end end for n,t in pairs(frame_data.tabs) do if rank_allowed(get_rank(player),t.name..'_tab') then debug_write({'GUI','CENTER','ADD'},t.name) ExpGui.add_input.draw_button(tab_bar,t.name) end end
draw_frame.tab(player,tab_bar[frame_data.tabs[1].name]) draw_frame.tab(player,tab_bar[frame_data.tabs[1].name])
ExpGui.add_input.draw_button(tab_bar,'close_center') ExpGui.add_input.draw_button(tab_bar,'close_center')
tab.style.minimal_height = 300 tab.style.minimal_height = 300
@@ -65,6 +66,7 @@ function draw_frame.center(player,element)
end end
--Draw the tab into the center GUI for the player; do not call manually, must use other functions to call --Draw the tab into the center GUI for the player; do not call manually, must use other functions to call
function draw_frame.tab(player,element) function draw_frame.tab(player,element)
debug_write({'GUI','CENTER','OPEN-TAB'},element.name)
for _,btn in pairs(element.parent.children) do if btn.name == 'close_center' or btn.name == element.name then for _,btn in pairs(element.parent.children) do if btn.name == 'close_center' or btn.name == element.name then
btn.style.font_color = {r = 255, g = 255, b = 255,a=255} btn.style.font_color = {r = 255, g = 255, b = 255,a=255}
else else

View File

@@ -34,6 +34,7 @@ end
function add_input.draw_button(frame,name,display,tooltip) function add_input.draw_button(frame,name,display,tooltip)
if not frame or not frame.valid then error('No frame to draw to') end if not frame or not frame.valid then error('No frame to draw to') end
if not name then error('No button to draw') end if not name then error('No button to draw') end
debug_write({'GUI','INPUT'},name)
for _,button in pairs(inputs.buttons) do for _,button in pairs(inputs.buttons) do
if button.name == name then if button.name == name then
local display = display or button.display or button.name local display = display or button.display or button.name
@@ -51,6 +52,7 @@ end
function add_input.draw_text(frame,name,display) function add_input.draw_text(frame,name,display)
if not frame or not frame.valid then error('No frame to draw to') end if not frame or not frame.valid then error('No frame to draw to') end
if not name then error('No text filed to draw') end if not name then error('No text filed to draw') end
debug_write({'GUI','INPUT'},name)
for _,text in pairs(inputs.text) do for _,text in pairs(inputs.text) do
if text.name == name then if text.name == name then
local display = display or text.display or text.name local display = display or text.display or text.name

View File

@@ -33,9 +33,11 @@ function add_frame.left(name,default_display,default_tooltip,vis,event)
end end
--draw the left GUI for the player; called via script, only call manually when update is true and element is the name of the GUI --draw the left GUI for the player; called via script, only call manually when update is true and element is the name of the GUI
function draw_frame.left(player,element,update) function draw_frame.left(player,element,update)
debug_write({'GUI','LEFT'},player.name)
local frame = nil local frame = nil
local frame_data = nil local frame_data = nil
local left = mod_gui.get_frame_flow(player) local left = mod_gui.get_frame_flow(player)
debug_write({'GUI','LEFT','UPDATE'},update)
if not update then if not update then
for _,frame in pairs(frames.left) do if element.name == frame.name then frame_data = frame break end end for _,frame in pairs(frames.left) do if element.name == frame.name then frame_data = frame break end end
if left[frame_data.name] then ExpGui.toggle_visible(left[frame_data.name]) return end if left[frame_data.name] then ExpGui.toggle_visible(left[frame_data.name]) return end

View File

@@ -39,6 +39,7 @@ for _,filter in pairs(player_table_functions.filters) do
end end
--used to draw filters from the list above --used to draw filters from the list above
function player_table_functions.draw_filters(player,frame,filters) function player_table_functions.draw_filters(player,frame,filters)
debug_write({'GUI','PLAYER-TABLE','DRAW-FILTERS'},player.name)
local input_bar = frame.add{type='flow',name='input_bar',direction='horizontal'} local input_bar = frame.add{type='flow',name='input_bar',direction='horizontal'}
for _,name in pairs(filters) do for _,name in pairs(filters) do
local filter_data = nil local filter_data = nil
@@ -76,6 +77,7 @@ end
--used to draw the player table with filter that you want --used to draw the player table with filter that you want
--filter = {{'is_admin',true},{'offline',true},{'player_name'}} ; if the length is 2 then it will not attempt to get a user input --filter = {{'is_admin',true},{'offline',true},{'player_name'}} ; if the length is 2 then it will not attempt to get a user input
function player_table_functions.draw(player,frame,filters,input_location) function player_table_functions.draw(player,frame,filters,input_location)
debug_write({'GUI','PLAYER-TABLE','START'},player.name)
global.current_filters[player.index] = {filters,frame} global.current_filters[player.index] = {filters,frame}
--setup the table --setup the table
if frame.player_table then frame.player_table.destroy() end if frame.player_table then frame.player_table.destroy() end
@@ -93,6 +95,7 @@ function player_table_functions.draw(player,frame,filters,input_location)
local add=true local add=true
for _,filter in pairs(filters) do for _,filter in pairs(filters) do
if #filter == 2 and add then if #filter == 2 and add then
debug_write({'GUI','PLAYER-TABLE','CHEAK'},p.name..' '..fliter.name)
local result = player_table_functions.player_match(p,filter.name,filter.is_text) local result = player_table_functions.player_match(p,filter.name,filter.is_text)
if not result and filter.is_text == true then result = filter.is_text end if not result and filter.is_text == true then result = filter.is_text end
add = result or false add = result or false
@@ -100,11 +103,13 @@ function player_table_functions.draw(player,frame,filters,input_location)
end end
for _,filter in pairs(player_table_functions.get_filters(input_location)) do for _,filter in pairs(player_table_functions.get_filters(input_location)) do
if add then if add then
debug_write({'GUI','PLAYER-TABLE','CHEAK'},p.name..' '..fliter.name)
add = player_table_functions.player_match(p,filter.name,filter.is_text) or false add = player_table_functions.player_match(p,filter.name,filter.is_text) or false
end end
end end
--add the player --add the player
if add then--and player.name ~= p.name then if add then--and player.name ~= p.name then
debug_write({'GUI','PLAYER-TABLE','ADD'},p.name)
player_table.add{name=p.name.."_id", type="label", caption=i} player_table.add{name=p.name.."_id", type="label", caption=i}
player_table.add{name=p.name..'_name', type="label", caption=p.name} player_table.add{name=p.name..'_name', type="label", caption=p.name}
if p.connected == true if p.connected == true

View File

@@ -50,6 +50,7 @@ function add_frame.popup(style,default_display,default_tooltip,on_click,event)
end end
--draw the popup on_click GUI for the player; do not call manually must use other functions to call --draw the popup on_click GUI for the player; do not call manually must use other functions to call
function draw_frame.popup_button(player,element) function draw_frame.popup_button(player,element)
debug_write({'GUI','POPUP-BUTTON'},player.name)
local frame_data = nil local frame_data = nil
for _,frame in pairs(frames.popup) do if element.name == frame.style then frame_data = frame break end end for _,frame in pairs(frames.popup) do if element.name == frame.style then frame_data = frame break end end
local popups = mod_gui.get_frame_flow(player).popups local popups = mod_gui.get_frame_flow(player).popups
@@ -62,8 +63,11 @@ function draw_frame.popup(style,args)
local args = args or {} local args = args or {}
local frame_data = nil local frame_data = nil
for _,frame in pairs(frames.popup) do if style == frame.style then frame_data = frame break end end for _,frame in pairs(frames.popup) do if style == frame.style then frame_data = frame break end end
debug_write({'GUI','POPUP','STYLE'},style)
debug_write({'GUI','POPUP','ARGS'},args)
game.write_file('popups.log','\n'..game.tick..' Popup Style: '..style..' Was made with args of: '..table.tostring(args), true, 0) game.write_file('popups.log','\n'..game.tick..' Popup Style: '..style..' Was made with args of: '..table.tostring(args), true, 0)
for _,player in pairs(game.connected_players) do for _,player in pairs(game.connected_players) do
debug_write({'GUI','POPUP','PLAYERS'},player.name)
local popups = mod_gui.get_frame_flow(player).popups local popups = mod_gui.get_frame_flow(player).popups
local frame = get_next_popup(popups) local frame = get_next_popup(popups)
frame_data.event(player,frame,args) frame_data.event(player,frame,args)

View File

@@ -27,12 +27,14 @@ function toolbar.add_button(name,default_display,default_tooltip,event)
end end
--draw the toolbar to the player only showing buttons within their restriction --draw the toolbar to the player only showing buttons within their restriction
function toolbar.draw(player) function toolbar.draw(player)
debug_write({'GUI','TOOLBAR'},player.name)
if not player then error('Need a player to draw to') end if not player then error('Need a player to draw to') end
local toolbar_frame = mod_gui.get_button_flow(player) local toolbar_frame = mod_gui.get_button_flow(player)
toolbar_frame.clear() toolbar_frame.clear()
for _,button in pairs(toolbar.buttons) do for _,button in pairs(toolbar.buttons) do
local rank = get_rank(player) local rank = get_rank(player)
if rank_allowed(get_rank(player),button.name) then if rank_allowed(get_rank(player),button.name) then
debug_write({'GUI','TOOLBAR','ADD'},button.name)
ExpGui.add_input.draw_button(toolbar_frame,button.name) ExpGui.add_input.draw_button(toolbar_frame,button.name)
end end
end end