More file handling improvements.
This commit is contained in:
parent
743c7ff809
commit
e221bc4b03
1
builds/cube_sapp/cube_sapp.slp
Normal file
1
builds/cube_sapp/cube_sapp.slp
Normal file
@ -0,0 +1 @@
|
||||
{"rbuilder":{"title":{"slen":32,"value":"rbuild (00.01.snow)"},"version":{"value":"00.01.snow","index":2,"slen":32},"appname":{"value":"rbuild","index":1,"slen":7}},"project":{"build_path":{"value":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\builds\\cube_sapp","key":"build_path","index":2,"ptype":"path","slen":256},"project_name":{"value":"default","key":"project_name","index":1,"ptype":"string","slen":64},"project_start":{"value":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\examples\\samples\\cube_sapp.lua","pfilter":"*.lua","key":"project_start","index":3,"ptype":"file","slen":128}},"assets":{"images":[],"data":[],"lua":[]},"graphics":{"antialias":{"value":"fxaa","index":5,"slen":16},"display_res":{"index":1,"plist":["1920x1080","1680x1050","1600x900","1440x900","1376x768"],"ptype":"combo","value":1},"display_width":{"value":1024,"vmin":640,"vmax":8192,"vstep":32,"ptype":"int","index":2,"vinc":0.1},"display_height":{"value":768,"vmin":480,"vmax":8192,"vstep":32,"ptype":"int","index":3,"vinc":0.1},"display_fps":{"value":60,"vmin":25,"vmax":200,"vstep":5,"ptype":"int","index":4,"vinc":0.1}},"platform":{"arch":{"index":3,"plist":["x86","x64","arm","arm64","arm64be","ppc","mips","mipsel","mips64","mips64el","mips64r6","mips64r6el"],"ptype":"combo","value":2},"target":{"index":1,"plist":["Win64","MacOS","Linux","IOS64"],"ptype":"combo","value":1},"srlua_path":{"index":2,"value":"../srlua/","ptype":"path","slen":256},"os":{"index":4,"plist":["Windows","Linux","OSX","BSD","POSIX","Other"],"ptype":"combo","value":1}},"audio":{"effects_volume":{"value":1,"vmin":0,"vmax":1,"vstep":0.02,"ptype":"float","index":2,"vinc":0.1},"music_volume":{"value":1,"vmin":0,"vmax":1,"vstep":0.02,"ptype":"float","index":3,"vinc":0.1},"master_volume":{"value":1,"vmin":0,"vmax":1,"vstep":0.02,"ptype":"float","index":1,"vinc":0.1}},"sokol":{"sokol_bin":{"value":"bin/","key":"sokol_bin","index":2,"ptype":"path","slen":256},"sokol_ffi":{"value":"ffi/","key":"sokol_ffi","index":3,"ptype":"path","slen":256},"sokol_lua":{"value":"lua/","key":"sokol_lua","index":4,"ptype":"path","slen":256},"sokol_examples":{"value":"examples/","key":"sokol_examples","index":5,"ptype":"path","slen":256},"sokol_path":{"value":"../../../../","key":"sokol_path","index":1,"ptype":"path","slen":256}},"remote":{"remote_build":{"value":"https://mybuildserver.com/sokol_build","index":1,"slen":256},"remote_data":{"value":"https://myremotedata.com/data","index":2,"slen":256}}}
|
||||
1
builds/cube_sapp/cube_sapp2.slp
Normal file
1
builds/cube_sapp/cube_sapp2.slp
Normal file
@ -0,0 +1 @@
|
||||
{"rbuilder":{"title":{"slen":32,"value":"rbuild (00.01.snow)"},"version":{"value":"00.01.snow","index":2,"slen":32},"appname":{"value":"rbuild","index":1,"slen":7}},"project":{"build_path":{"value":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\builds\\cube_sapp","key":"build_path","index":2,"ptype":"path","slen":256},"project_name":{"value":"default","key":"project_name","index":1,"ptype":"string","slen":64},"project_start":{"value":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\examples\\samples\\cube_sapp.lua","pfilter":"*.lua","key":"project_start","index":3,"ptype":"file","slen":128}},"assets":{"images":[],"data":[],"lua":[]},"graphics":{"antialias":{"value":"fxaa","index":5,"slen":16},"display_res":{"index":1,"plist":["1920x1080","1680x1050","1600x900","1440x900","1376x768"],"ptype":"combo","value":1},"display_width":{"value":1024,"vmin":640,"vmax":8192,"vstep":32,"ptype":"int","index":2,"vinc":0.1},"display_height":{"value":768,"vmin":480,"vmax":8192,"vstep":32,"ptype":"int","index":3,"vinc":0.1},"display_fps":{"value":60,"vmin":25,"vmax":200,"vstep":5,"ptype":"int","index":4,"vinc":0.1}},"platform":{"arch":{"index":3,"plist":["x86","x64","arm","arm64","arm64be","ppc","mips","mipsel","mips64","mips64el","mips64r6","mips64r6el"],"ptype":"combo","value":2},"target":{"index":1,"plist":["Win64","MacOS","Linux","IOS64"],"ptype":"combo","value":1},"srlua_path":{"index":2,"value":"../srlua/","ptype":"path","slen":256},"os":{"index":4,"plist":["Windows","Linux","OSX","BSD","POSIX","Other"],"ptype":"combo","value":1}},"audio":{"effects_volume":{"value":1,"vmin":0,"vmax":1,"vstep":0.02,"ptype":"float","index":2,"vinc":0.1},"music_volume":{"value":1,"vmin":0,"vmax":1,"vstep":0.02,"ptype":"float","index":3,"vinc":0.1},"master_volume":{"value":1,"vmin":0,"vmax":1,"vstep":0.02,"ptype":"float","index":1,"vinc":0.1}},"sokol":{"sokol_bin":{"value":"bin/","key":"sokol_bin","index":2,"ptype":"path","slen":256},"sokol_ffi":{"value":"ffi/","key":"sokol_ffi","index":3,"ptype":"path","slen":256},"sokol_lua":{"value":"lua/","key":"sokol_lua","index":4,"ptype":"path","slen":256},"sokol_examples":{"value":"examples/","key":"sokol_examples","index":5,"ptype":"path","slen":256},"sokol_path":{"value":"../../../../","key":"sokol_path","index":1,"ptype":"path","slen":256}},"remote":{"remote_build":{"value":"https://mybuildserver.com/sokol_build","index":1,"slen":256},"remote_data":{"value":"https://myremotedata.com/data","index":2,"slen":256}}}
|
||||
@ -100,6 +100,11 @@ local sel_date = sel_time
|
||||
|
||||
local popup_active = ffi.new("int[1]")
|
||||
|
||||
local menu_states = { MENU_NONE = 0,MENU_FILE = 1, MENU_EDIT = 2,MENU_VIEW = 3,MENU_CHART = 4}
|
||||
local menu_state = menu_states.MENU_NONE
|
||||
local state = ffi.new("enum nk_collapse_states[1]")
|
||||
state[0] = nk.NK_MINIMIZED
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
local function draw_demo_ui(ctx)
|
||||
@ -121,7 +126,6 @@ local function draw_demo_ui(ctx)
|
||||
if (show_menu[0] == true) then
|
||||
|
||||
-- /* menubar */
|
||||
local menu_states = { MENU_DEFAULT = 0, MENU_WINDOWS = 1}
|
||||
nk.nk_menubar_begin(ctx)
|
||||
|
||||
-- /* menu #1 */
|
||||
@ -148,10 +152,6 @@ local function draw_demo_ui(ctx)
|
||||
nk.nk_layout_row_push(ctx, 60)
|
||||
if (nk.nk_menu_begin_label(ctx, "ADVANCED", nk.NK_TEXT_LEFT, nk.nk_vec2(200, 600))) then
|
||||
|
||||
menu_states = { MENU_NONE = 0,MENU_FILE = 1, MENU_EDIT = 2,MENU_VIEW = 3,MENU_CHART = 4}
|
||||
menu_state = menu_states.MENU_NONE
|
||||
state = ffi.new("enum nk_collapse_states[1]")
|
||||
|
||||
state[0] = nk.NK_MINIMIZED
|
||||
if(menu_state == menu_states.MENU_FILE) then state[0] = nk.NK_MAXIMIZED end
|
||||
if (nk.nk_tree_state_push(ctx, nk.NK_TREE_TAB, "FILE", state)) then
|
||||
@ -167,10 +167,8 @@ local function draw_demo_ui(ctx)
|
||||
menu_state = menu_states.MENU_NONE
|
||||
end
|
||||
end
|
||||
|
||||
state[0] = nk.NK_MINIMIZED
|
||||
if(menu_state == menu_states.MENU_EDIT) then state[0] = nk.NK_MAXIMIZED end
|
||||
|
||||
if (nk.nk_tree_state_push(ctx, nk.NK_TREE_TAB, "EDIT", state)) then
|
||||
menu_state = menu_states.MENU_EDIT
|
||||
nk.nk_menu_item_label(ctx, "Copy", nk.NK_TEXT_LEFT)
|
||||
@ -183,7 +181,6 @@ local function draw_demo_ui(ctx)
|
||||
menu_state = menu_states.MENU_NONE
|
||||
end
|
||||
end
|
||||
|
||||
state[0] = nk.NK_MINIMIZED
|
||||
if(menu_state == menu_states.MENU_VIEW) then state[0] = nk.NK_MAXIMIZED end
|
||||
if (nk.nk_tree_state_push(ctx, nk.NK_TREE_TAB, "VIEW", state)) then
|
||||
@ -197,7 +194,6 @@ local function draw_demo_ui(ctx)
|
||||
menu_state = menu_states.MENU_NONE
|
||||
end
|
||||
end
|
||||
|
||||
state[0] = nk.NK_MINIMIZED
|
||||
if(menu_state == menu_states.MENU_CHART) then state[0] = nk.NK_MAXIMIZED end
|
||||
if (nk.nk_tree_state_push(ctx, nk.NK_TREE_TAB, "CHART", state)) then
|
||||
|
||||
@ -1,2 +1 @@
|
||||
{
|
||||
}
|
||||
["F:\\dev\\luajit\\Thunc\\sokol-luajit\\builds\\cube_sapp\\cube_sapp2.slp","F:\\dev\\luajit\\Thunc\\sokol-luajit\\builds\\cube_sapp\\cube_sapp.slp"]
|
||||
@ -2,13 +2,17 @@
|
||||
|
||||
local ffi = require("ffi")
|
||||
local json = require("lua.json")
|
||||
local logging = require("utils.logging")
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------------
|
||||
-- The main module table
|
||||
local settings = {}
|
||||
local settings = {
|
||||
|
||||
recents = {},
|
||||
}
|
||||
|
||||
-- Default settings if none are loaded or found
|
||||
local platforms = { "Win64", "MacOS", "Linux", "IOS64" }
|
||||
@ -96,27 +100,69 @@ end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------------
|
||||
|
||||
settings.load = function( projectpath )
|
||||
settings.add_recents = function( filename )
|
||||
|
||||
if(settings.recents) then
|
||||
|
||||
-- Check it isnt already in the list, add to first and remove the other.
|
||||
local removal = {}
|
||||
for i, v in ipairs(settings.recents) do
|
||||
if string.match(v, filename) then table.insert(removal, i) end
|
||||
end
|
||||
for i, v in ipairs(removal) do
|
||||
table.remove(settings.recents, v)
|
||||
end
|
||||
table.insert(settings.recents, 1, filename)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------------
|
||||
|
||||
settings.load_recents = function( )
|
||||
|
||||
-- Grab the recents file list too.
|
||||
settings.recent = nil
|
||||
local fh = io.open("config/recent_projects.json", "r")
|
||||
if(fh) then
|
||||
settings.recent = json.decode( fh:read("*a") )
|
||||
settings.recents = json.decode( fh:read("*a") )
|
||||
fh:close()
|
||||
else
|
||||
logging.error(" settings.load_recents: Cannot load recents.")
|
||||
end
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------------
|
||||
|
||||
settings.save_recents = function( )
|
||||
|
||||
-- Grab the recents file list too.
|
||||
if(settings.recents) then
|
||||
local fh = io.open("config/recent_projects.json", "w")
|
||||
if(fh) then
|
||||
fh:write(json.encode( settings.recents ))
|
||||
fh:close()
|
||||
logging.error(" settings.save_recents.")
|
||||
else
|
||||
logging.error(" settings.save_recents: Cannot load recents.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------------
|
||||
|
||||
settings.load = function( projectpath )
|
||||
|
||||
if( projectpath == nil ) then
|
||||
print("[Error] settings.load invalid projectpath nil, using default settings.")
|
||||
settings.config = default_settings
|
||||
else
|
||||
|
||||
-- Load the project settings into the local config
|
||||
settings.config = loadconfig(projectpath)
|
||||
end
|
||||
|
||||
local title = settings.config.rbuilder.appname.value.." ("..settings.config.rbuilder.version.value..")"
|
||||
settings.config.rbuilder.title = { value = title, slen = 32 }
|
||||
|
||||
return settings.config
|
||||
end
|
||||
|
||||
@ -126,7 +172,6 @@ settings.save = function( projectpath )
|
||||
|
||||
-- Grab the recents file list too.
|
||||
settings.recent = nil
|
||||
print(projectpath)
|
||||
local fh = io.open(projectpath, "w")
|
||||
if(fh) then
|
||||
fh:write( json.encode(settings.config) )
|
||||
|
||||
@ -82,7 +82,7 @@ local function frame(void)
|
||||
|
||||
local ctx = nk.snk_new_frame()
|
||||
current_ctx = ctx
|
||||
local config_reset = panel.main_ui(ctx)
|
||||
panel.main_ui(ctx)
|
||||
|
||||
-- // the sokol_gfx draw pass
|
||||
local pass = ffi.new("sg_pass[1]")
|
||||
@ -95,9 +95,6 @@ local function frame(void)
|
||||
sg.sg_end_pass()
|
||||
sg.sg_commit()
|
||||
|
||||
if(config_reset) then
|
||||
panel.init()
|
||||
end
|
||||
ffi.C.Sleep(3)
|
||||
end
|
||||
|
||||
@ -143,3 +140,7 @@ for k,v in pairs(package.loaded) do
|
||||
end
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
panel.cleanup()
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
@ -21,6 +21,51 @@ local file_selector = {}
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
file_selector.create_file_list = function( name, rect, recent_files )
|
||||
|
||||
local file_select = {
|
||||
popup_active = 0,
|
||||
popup_dim = rect,
|
||||
file_selected = "",
|
||||
recent_files = recent_files,
|
||||
hit = {0, "", 0},
|
||||
|
||||
ui_func = function(ctx, dim, udata)
|
||||
|
||||
nk.nk_layout_row_dynamic(ctx, dim.h-20, 1)
|
||||
local flags = bit.bor(nk.NK_WINDOW_BORDER, nk.NK_WINDOW_TITLE)
|
||||
flags = bit.bor(flags, nk.NK_WINDOW_NO_SCROLLBAR)
|
||||
|
||||
if (nk.nk_group_begin(ctx, name, flags) == true) then
|
||||
|
||||
nk.nk_layout_row_dynamic(ctx, dim.h-90, 1)
|
||||
|
||||
local bhit = wdgts.widget_list_buttons(ctx, "recent_file", nil, udata.recent_files, dim.w -40 )
|
||||
if(bhit) then
|
||||
udata.file_selected = bhit[2]
|
||||
end
|
||||
|
||||
nk.nk_layout_row_dynamic(ctx, 25, 2)
|
||||
if (nk.nk_button_label(ctx, "Cancel") == true) then
|
||||
udata.popup_active = 0
|
||||
if(udata.callback) then udata.callback(udata, false) end
|
||||
end
|
||||
if (nk.nk_button_label(ctx, "OK") == true) then
|
||||
udata.popup_active = 0
|
||||
if(udata.callback) then udata.callback(udata, true) end
|
||||
end
|
||||
nk.nk_group_end(ctx)
|
||||
end
|
||||
|
||||
if(udata.popup_active == 0) then nk.nk_popup_close(ctx) end
|
||||
return udata.popup_active
|
||||
end,
|
||||
}
|
||||
return file_select
|
||||
end
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
file_selector.create_file_selector = function( name, rect, start_folder, folders_only )
|
||||
|
||||
local file_select = {
|
||||
@ -114,6 +159,12 @@ file_selector.create_file_selector = function( name, rect, start_folder, folders
|
||||
end
|
||||
if (nk.nk_button_label(ctx, "OK") == true) then
|
||||
udata.popup_active = 0
|
||||
if(folders_only) then
|
||||
udata.prop.value = udata.folder_path
|
||||
else
|
||||
udata.prop.value = udata.file_selected
|
||||
end
|
||||
|
||||
if(udata.callback) then
|
||||
udata.callback(udata, true)
|
||||
end
|
||||
@ -146,6 +197,15 @@ file_selector.open = function(select_obj, initial_path, prop, callback)
|
||||
if(callback) then select_obj.callback = callback end
|
||||
end
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
file_selector.show = function(select_obj)
|
||||
|
||||
select_obj.popup_active = 1
|
||||
if(callback) then select_obj.callback = callback end
|
||||
end
|
||||
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
return file_selector
|
||||
|
||||
@ -18,9 +18,11 @@ local fsel = require("ui.file_selector")
|
||||
local icons = ffi.new("struct nk_image [?]", 10)
|
||||
|
||||
local themes = require("lua.themes")
|
||||
local logging = require("utils.logging")
|
||||
|
||||
local panel = {
|
||||
config = nil
|
||||
config = nil,
|
||||
current_path = ".",
|
||||
}
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
@ -43,6 +45,7 @@ local font_list = {
|
||||
|
||||
local folder_select = nil
|
||||
local file_select = nil
|
||||
local recent_files = nil
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
local curr_tab = 1
|
||||
@ -156,6 +159,9 @@ panel.init = function()
|
||||
|
||||
panel.config = settings.load()
|
||||
setup_config()
|
||||
|
||||
settings.load_recents()
|
||||
recent_files = fsel.create_file_list("Choose Recent", dim2, {})
|
||||
end
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
@ -316,6 +322,22 @@ end
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
panel.show_recents = function(ctx)
|
||||
|
||||
panel.recent_list = {}
|
||||
for i,v in ipairs(settings.recents) do
|
||||
local newfile = { name = ffi.string(v) }
|
||||
newfile.select = ffi.new("int[1]")
|
||||
newfile.select[0] = 0
|
||||
table.insert(panel.recent_list, newfile)
|
||||
end
|
||||
recent_files.recent_files = panel.recent_list
|
||||
fsel.show(recent_files, function(udata, res)
|
||||
end)
|
||||
end
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
panel.main_ui = function(ctx)
|
||||
|
||||
if(myfonts == nil) then
|
||||
@ -324,12 +346,11 @@ panel.main_ui = function(ctx)
|
||||
themes.tech(ctx)
|
||||
end
|
||||
|
||||
local config_reset = nil
|
||||
|
||||
wdgts.widget_panel_fixed(ctx, "WinMain", 0, 0, sapp.sapp_width(), sapp.sapp_height(), 0, function(data)
|
||||
|
||||
folder_select.popup_active = wdgts.widget_popup_panel(ctx, "popup", folder_select.popup_dim, folder_select.ui_func, folder_select, folder_select.popup_active)
|
||||
file_select.popup_active = wdgts.widget_popup_panel(ctx, "popup", file_select.popup_dim, file_select.ui_func, file_select, file_select.popup_active)
|
||||
recent_files.popup_active = wdgts.widget_popup_panel(ctx, "popup", recent_files.popup_dim, recent_files.ui_func, recent_files, recent_files.popup_active)
|
||||
|
||||
-- /* menubar */
|
||||
local menu_states = { MENU_DEFAULT = 0, MENU_WINDOWS = 1}
|
||||
@ -338,27 +359,43 @@ panel.main_ui = function(ctx)
|
||||
-- /* menu #1 */
|
||||
nk.nk_layout_row_begin(ctx, nk.NK_STATIC, 25, 2)
|
||||
nk.nk_layout_row_push(ctx, 140)
|
||||
if (nk.nk_menu_begin_label(ctx, "File", nk.NK_TEXT_LEFT, nk.nk_vec2(120, 200))) then
|
||||
if (nk.nk_menu_begin_label(ctx, "File", nk.NK_TEXT_LEFT, nk.nk_vec2(150, 240))) then
|
||||
|
||||
nk.nk_layout_row_dynamic(ctx, 35, 1)
|
||||
if (nk.nk_menu_item_label(ctx, "New", nk.NK_TEXT_LEFT)) then
|
||||
config_reset = true
|
||||
if (nk.nk_menu_item_label(ctx, "New", nk.NK_TEXT_LEFT)== true) then
|
||||
end
|
||||
|
||||
nk.nk_layout_row_dynamic(ctx, 3, 1)
|
||||
nk.nk_menu_item_label(ctx, "------------", nk.NK_TEXT_LEFT)
|
||||
|
||||
nk.nk_layout_row_dynamic(ctx, 35, 1)
|
||||
if (nk.nk_menu_item_label(ctx, "Open", nk.NK_TEXT_LEFT)) then
|
||||
if (nk.nk_menu_item_label(ctx, "Open", nk.NK_TEXT_LEFT)== true) then
|
||||
panel.loadconfig()
|
||||
end
|
||||
|
||||
nk.nk_layout_row_dynamic(ctx, 35, 1)
|
||||
if (nk.nk_menu_item_label(ctx, "Save", nk.NK_TEXT_LEFT)) then
|
||||
panel.saveconfig(true)
|
||||
if(nk.nk_menu_item_label(ctx, "Open Recent", nk.NK_TEXT_LEFT) == true) then
|
||||
panel.show_recents()
|
||||
end
|
||||
|
||||
nk.nk_layout_row_dynamic(ctx, 3, 1)
|
||||
nk.nk_menu_item_label(ctx, "------------", nk.NK_TEXT_LEFT)
|
||||
|
||||
nk.nk_layout_row_dynamic(ctx, 35, 1)
|
||||
if (nk.nk_menu_item_label(ctx, "Save", nk.NK_TEXT_LEFT)== true) then
|
||||
panel.saveconfig()
|
||||
end
|
||||
nk.nk_layout_row_dynamic(ctx, 35, 1)
|
||||
if (nk.nk_menu_item_label(ctx, "SaveAs", nk.NK_TEXT_LEFT)) then
|
||||
if (nk.nk_menu_item_label(ctx, "SaveAs", nk.NK_TEXT_LEFT)== true) then
|
||||
panel.saveconfig(true)
|
||||
end
|
||||
|
||||
nk.nk_layout_row_dynamic(ctx, 3, 1)
|
||||
nk.nk_menu_item_label(ctx, "------------", nk.NK_TEXT_LEFT)
|
||||
|
||||
nk.nk_layout_row_dynamic(ctx, 35, 1)
|
||||
if (nk.nk_menu_item_label(ctx, "Quit", nk.NK_TEXT_LEFT)) then
|
||||
os.exit()
|
||||
sapp.sapp_request_quit()
|
||||
end
|
||||
nk.nk_menu_end(ctx)
|
||||
end
|
||||
@ -419,7 +456,6 @@ panel.main_ui = function(ctx)
|
||||
end, {ctx=ctx})
|
||||
|
||||
-- return not nk.nk_window_is_closed(ctx, "Overview")
|
||||
return config_reset
|
||||
end
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
@ -438,6 +474,8 @@ panel.input = function(event)
|
||||
local dim2 = nk.nk_rect( sapp.sapp_width()/2-8 - popup_wide/2,
|
||||
sapp.sapp_height()/2-40 - popup_high/2, popup_wide, popup_high)
|
||||
file_select.popup_dim = dim2
|
||||
|
||||
recent_files.popup_dim = dim2
|
||||
end
|
||||
end
|
||||
|
||||
@ -449,7 +487,10 @@ panel.loadconfig = function()
|
||||
function(udata, res)
|
||||
if(res == true) then
|
||||
local name=ffi.string(udata.file_selected)
|
||||
panel.current_path = name
|
||||
logging.info(" panel.loadconfig: Loaded path - "..name)
|
||||
settings.load(name)
|
||||
settings.add_recents(name)
|
||||
end
|
||||
end)
|
||||
end
|
||||
@ -458,13 +499,29 @@ end
|
||||
|
||||
panel.saveconfig = function(saveas)
|
||||
|
||||
fsel.open(file_select, ".", nil,
|
||||
local init_path = panel.current_path or "."
|
||||
print("Init Path: "..panel.current_path)
|
||||
|
||||
if(saveas) then
|
||||
fsel.open(file_select, init_path, nil,
|
||||
function(udata, res)
|
||||
if(res == true) then
|
||||
local name=ffi.string(udata.file_selected)
|
||||
logging.info(" panel.saveconfig: Saved path - "..name)
|
||||
settings.save(name)
|
||||
end
|
||||
end)
|
||||
else
|
||||
settings.save(panel.current_path)
|
||||
logging.info(" panel.saveconfig: Saved path - "..panel.current_path)
|
||||
end
|
||||
end
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
panel.cleanup = function()
|
||||
|
||||
settings.save_recents()
|
||||
end
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
26
tools/build/rbuilder/utils/logging.lua
Normal file
26
tools/build/rbuilder/utils/logging.lua
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
local logging = {}
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
logging.info = function( infostr )
|
||||
io.write(string.format("[Info] %s\n", infostr))
|
||||
end
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
logging.warn = function( warnstr )
|
||||
io.write(string.format("[Warning] %s\n", warnstr))
|
||||
end
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
logging.error = function( errstr )
|
||||
io.write(string.format("[Error] %s\n", errstr))
|
||||
end
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
return logging
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
Loading…
Reference in New Issue
Block a user