Added search tools to dirtools and build panel.
This commit is contained in:
parent
9013bde402
commit
686914e5c2
@ -1 +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}}}
|
||||
{"project":{"build_path":{"slen":256,"index":2,"len_ffi":null,"ffi":null,"value":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\builds\\cube_sapp","ptype":"path","key":"build_path"},"project_name":{"slen":64,"index":1,"len_ffi":null,"ffi":null,"value":"default","ptype":"string","key":"project_name"},"project_start":{"len_ffi":null,"slen":128,"index":3,"ffi":null,"pfilter":"*.lua","value":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\examples\\samples\\cube_sapp.lua","ptype":"file","key":"project_start"}},"sokol":{"sokol_path":{"slen":256,"index":1,"len_ffi":null,"ffi":null,"value":"F:\\dev\\luajit\\Thunc","ptype":"path","key":"sokol_path"},"sokol_bin":{"slen":256,"index":2,"len_ffi":null,"ffi":null,"value":"F:\\dev\\luajit\\Thunc\\bin","ptype":"path","key":"sokol_bin"},"sokol_ffi":{"slen":256,"index":3,"len_ffi":null,"ffi":null,"value":"F:\\dev\\luajit\\Thunc\\ffi","ptype":"path","key":"sokol_ffi"},"sokol_lua":{"slen":256,"index":4,"len_ffi":null,"ffi":null,"value":"F:\\dev\\luajit\\Thunc\\lua","ptype":"path","key":"sokol_lua"},"sokol_examples":{"slen":256,"index":5,"len_ffi":null,"ffi":null,"value":"F:\\dev\\luajit\\Thunc\\examples","ptype":"path","key":"sokol_examples"}},"platform":{"srlua_path":{"slen":256,"index":2,"len_ffi":null,"value":"../srlua/","ffi":null,"ptype":"path"},"arch":{"plist":["x86","x64","arm","arm64","arm64be","ppc","mips","mipsel","mips64","mips64el","mips64r6","mips64r6el"],"index":3,"value":2,"ffi":null,"ptype":"combo"},"os":{"plist":["Windows","Linux","OSX","BSD","POSIX","Other"],"index":4,"value":1,"ffi":null,"ptype":"combo"},"target":{"plist":["Win64","MacOS","Linux","IOS64"],"index":1,"value":1,"ffi":null,"ptype":"combo"}},"audio":{"music_volume":{"ffi":null,"vmin":0,"index":3,"vstep":0.02,"vinc":0.1,"value":1,"vmax":1,"ptype":"float"},"master_volume":{"ffi":null,"vmin":0,"index":1,"vstep":0.02,"vinc":0.1,"value":1,"vmax":1,"ptype":"float"},"effects_volume":{"ffi":null,"vmin":0,"index":2,"vstep":0.02,"vinc":0.1,"value":1,"vmax":1,"ptype":"float"}},"assets":{"lua":[],"images":[],"data":[]},"rbuilder":{"appname":{"slen":7,"index":1,"value":"rbuild"},"title":{"slen":32,"value":"rbuild (00.01.snow)"},"version":{"slen":32,"index":2,"value":"00.01.snow"}},"graphics":{"display_width":{"ffi":null,"vmin":640,"index":2,"vstep":32,"vinc":0.1,"value":1024,"vmax":8192,"ptype":"int"},"display_height":{"ffi":null,"vmin":480,"index":3,"vstep":32,"vinc":0.1,"value":768,"vmax":8192,"ptype":"int"},"display_fps":{"ffi":null,"vmin":25,"index":4,"vstep":5,"vinc":0.1,"value":60,"vmax":200,"ptype":"int"},"antialias":{"slen":16,"index":5,"value":"fxaa"},"display_res":{"plist":["1920x1080","1680x1050","1600x900","1440x900","1376x768"],"index":1,"value":1,"ffi":null,"ptype":"combo"}},"remote":{"remote_data":{"slen":256,"index":2,"value":"https://myremotedata.com/data"},"remote_build":{"slen":256,"index":1,"value":"https://mybuildserver.com/sokol_build"}}}
|
||||
@ -1 +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}}}
|
||||
{"assets":{"images":[],"data":[],"lua":[]},"project":{"build_path":{"key":"build_path","slen":256,"ptype":"path","ffi":null,"index":2,"len_ffi":null,"value":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\builds\\cube_sapp"},"project_start":{"key":"project_start","index":3,"ffi":null,"ptype":"file","slen":128,"pfilter":"*.lua","len_ffi":null,"value":"F:\\dev\\luajit\\Thunc\\sokol-luajit\\examples\\samples\\offscreen_sapp.lua"},"project_name":{"key":"project_name","slen":64,"ptype":"string","ffi":null,"index":1,"len_ffi":null,"value":"default"}},"sokol":{"sokol_examples":{"key":"sokol_examples","slen":256,"ptype":"path","ffi":null,"index":5,"len_ffi":null,"value":"examples/"},"sokol_path":{"key":"sokol_path","slen":256,"ptype":"path","ffi":null,"index":1,"len_ffi":null,"value":"../../../../"},"sokol_bin":{"key":"sokol_bin","slen":256,"ptype":"path","ffi":null,"index":2,"len_ffi":null,"value":"bin/"},"sokol_ffi":{"key":"sokol_ffi","slen":256,"ptype":"path","ffi":null,"index":3,"len_ffi":null,"value":"ffi/"},"sokol_lua":{"key":"sokol_lua","slen":256,"ptype":"path","ffi":null,"index":4,"len_ffi":null,"value":"lua/"}},"remote":{"remote_build":{"index":1,"slen":256,"value":"https://mybuildserver.com/sokol_build"},"remote_data":{"index":2,"slen":256,"value":"https://myremotedata.com/data"}},"platform":{"os":{"ptype":"combo","ffi":null,"index":4,"plist":["Windows","Linux","OSX","BSD","POSIX","Other"],"value":1},"arch":{"ptype":"combo","ffi":null,"index":3,"plist":["x86","x64","arm","arm64","arm64be","ppc","mips","mipsel","mips64","mips64el","mips64r6","mips64r6el"],"value":2},"srlua_path":{"index":2,"ptype":"path","ffi":null,"slen":256,"len_ffi":null,"value":"../srlua/"},"target":{"ptype":"combo","ffi":null,"index":1,"plist":["Win64","MacOS","Linux","IOS64"],"value":1}},"rbuilder":{"appname":{"index":1,"slen":7,"value":"rbuild"},"title":{"slen":32,"value":"rbuild (00.01.snow)"},"version":{"index":2,"slen":32,"value":"00.01.snow"}},"audio":{"effects_volume":{"vmin":0,"vmax":1,"vstep":0.02,"ptype":"float","ffi":null,"index":2,"vinc":0.1,"value":1},"music_volume":{"vmin":0,"vmax":1,"vstep":0.02,"ptype":"float","ffi":null,"index":3,"vinc":0.1,"value":1},"master_volume":{"vmin":0,"vmax":1,"vstep":0.02,"ptype":"float","ffi":null,"index":1,"vinc":0.1,"value":1}},"graphics":{"display_res":{"ptype":"combo","ffi":null,"index":1,"plist":["1920x1080","1680x1050","1600x900","1440x900","1376x768"],"value":1},"display_width":{"vmin":640,"vmax":8192,"vstep":32,"ptype":"int","ffi":null,"index":2,"vinc":0.1,"value":1024},"display_height":{"vmin":480,"vmax":8192,"vstep":32,"ptype":"int","ffi":null,"index":3,"vinc":0.1,"value":768},"display_fps":{"vmin":25,"vmax":200,"vstep":5,"ptype":"int","ffi":null,"index":4,"vinc":0.1,"value":60},"antialias":{"index":5,"slen":16,"value":"fxaa"}}}
|
||||
@ -91,7 +91,6 @@ local function loadconfig(projectpath)
|
||||
else
|
||||
res = json.decode(res)
|
||||
end
|
||||
print(res)
|
||||
else
|
||||
print("[Error] settings.load - unable to load config: "..projectpath)
|
||||
end
|
||||
|
||||
@ -167,6 +167,36 @@ panel.init = function()
|
||||
recent_files = fsel.create_file_list("Choose Recent", dim3, {})
|
||||
end
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
-- Attempts to find sokol in nearby folders (up max 4 directories from builder)
|
||||
-- Sets all the sokol properties if it does find it
|
||||
local function search_sokol(ctx)
|
||||
|
||||
local r = nk.nk_window_get_content_region(ctx)
|
||||
|
||||
nk.nk_layout_space_begin(ctx, nk.NK_STATIC, 27, 1)
|
||||
nk.nk_layout_space_push(ctx, nk.nk_rect(r.w-40, -195, 27, 27))
|
||||
|
||||
|
||||
nk.nk_style_set_font(ctx, myfonts[1].handle)
|
||||
if(nk.nk_button_label(ctx, "") == true) then
|
||||
-- do search stuff
|
||||
local found = dirtools.find_folder(".", 5, "sokol-luajit")
|
||||
if(found) then
|
||||
logging.info(string.format("Found Sokol-luajit: %s",found))
|
||||
logging.info("Auto filling sokol paths...")
|
||||
panel.config["sokol"].sokol_path.value = found
|
||||
panel.config["sokol"].sokol_bin.value = dirtools.combine_path(found, "bin")
|
||||
panel.config["sokol"].sokol_ffi.value = dirtools.combine_path(found, "ffi")
|
||||
panel.config["sokol"].sokol_lua.value = dirtools.combine_path(found, "lua")
|
||||
panel.config["sokol"].sokol_examples.value = dirtools.combine_path(found, "examples")
|
||||
setup_config()
|
||||
end
|
||||
end
|
||||
nk.nk_style_set_font(ctx, myfonts[3].handle)
|
||||
nk.nk_layout_space_end(ctx)
|
||||
end
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
local function display_section(ctx, sectionname)
|
||||
@ -227,7 +257,6 @@ local function display_section(ctx, sectionname)
|
||||
end
|
||||
nk.nk_layout_row_end(ctx)
|
||||
end
|
||||
|
||||
nk.nk_group_end(ctx)
|
||||
end
|
||||
end
|
||||
@ -241,6 +270,7 @@ local project_tabs = {
|
||||
func = function(ctx)
|
||||
display_section(ctx, "project")
|
||||
display_section(ctx, "sokol")
|
||||
search_sokol(ctx)
|
||||
end,
|
||||
},
|
||||
{
|
||||
@ -338,9 +368,9 @@ panel.show_recents = function(ctx)
|
||||
fsel.show(recent_files, function(udata, res)
|
||||
if(res == true) then
|
||||
panel.current_path = udata.file_selected
|
||||
settings.load(udata.file_selected)
|
||||
panel.config = settings.load(udata.file_selected)
|
||||
setup_config()
|
||||
settings.add_recents(udata.file_selected)
|
||||
print("Opened: "..udata.file_selected)
|
||||
end
|
||||
end)
|
||||
end
|
||||
@ -501,7 +531,8 @@ panel.loadconfig = function()
|
||||
local name=ffi.string(udata.file_selected)
|
||||
panel.current_path = name
|
||||
logging.info(" panel.loadconfig: Loaded path - "..name)
|
||||
settings.load(name)
|
||||
panel.config = settings.load(name)
|
||||
setup_config()
|
||||
settings.add_recents(name)
|
||||
end
|
||||
end)
|
||||
|
||||
@ -30,6 +30,23 @@ if(ffi.os ~= "Windows") then sep = "/" end
|
||||
|
||||
---------------------------------------------------------------------------------------
|
||||
|
||||
dirtools.compare_paths = function(p1, p2)
|
||||
-- Remove minus, they seem to cause the most problems
|
||||
p1 = string.gsub(p1, "%-", "_")
|
||||
p2 = string.gsub(p2, "%-", "_")
|
||||
return string.match(p1, p2)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------
|
||||
|
||||
dirtools.combine_path = function( base, addition )
|
||||
|
||||
return base..sep..addition
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
dirtools.get_drives = function()
|
||||
local cmd = "wmic logicaldisk get name"
|
||||
-- Note: Add more -t <filetype> to support different file system mounts
|
||||
@ -109,16 +126,18 @@ dirtools.get_app_path = function( expected_root_folder )
|
||||
if(cmdh) then base_dir = cmdh:read("*a"); cmdh:close() end
|
||||
end
|
||||
|
||||
local folder_name = expected_root_folder
|
||||
local last_folder, remain = string.match(base_dir, "(.-"..folder_name..")(.-)")
|
||||
last_folder = last_folder or ""
|
||||
remain = remain or ""
|
||||
if(expected_root_folder) then
|
||||
local folder_name = expected_root_folder
|
||||
local last_folder, remain = string.match(base_dir, "(.-"..folder_name..")(.-)")
|
||||
last_folder = last_folder or ""
|
||||
remain = remain or ""
|
||||
|
||||
remain = remain:gsub("%s+", "")
|
||||
if(ffi.os == "Windows") then
|
||||
base_dir = last_folder.."\\"
|
||||
else
|
||||
base_dir = last_folder.."/"
|
||||
remain = remain:gsub("%s+", "")
|
||||
if(ffi.os == "Windows") then
|
||||
base_dir = last_folder.."\\"
|
||||
else
|
||||
base_dir = last_folder.."/"
|
||||
end
|
||||
end
|
||||
-- print("Base Directory: "..base_dir)
|
||||
return base_dir
|
||||
@ -198,7 +217,6 @@ dirtools.get_dirlist = function(path, cache_update)
|
||||
res = fh:read("*a")
|
||||
fh:close()
|
||||
if(#res == 0) then
|
||||
print(path)
|
||||
list_cache[path] = files
|
||||
return files
|
||||
end
|
||||
@ -218,6 +236,17 @@ dirtools.get_dirlist = function(path, cache_update)
|
||||
return files
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------
|
||||
dirtools.path_match = function(list, path)
|
||||
|
||||
for i,v in ipairs(list) do
|
||||
if(dirtools.compare_paths(v.name, path)) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------
|
||||
dirtools.get_parent = function( path )
|
||||
if(path == nil or path == "") then path = "." end
|
||||
@ -225,6 +254,30 @@ dirtools.get_parent = function( path )
|
||||
return parentpath
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------
|
||||
|
||||
dirtools.find_folder = function( start_path, parent_up, folder_name )
|
||||
|
||||
-- If starting in current application folder, convert it to a full path
|
||||
if(start_path == ".") then
|
||||
start_path = dirtools.get_app_path()
|
||||
end
|
||||
local list = dirtools.get_folderslist(start_path)
|
||||
if(dirtools.path_match(list, "sokol-luajit") == true) then
|
||||
return start_path
|
||||
end
|
||||
|
||||
local current = start_path
|
||||
for i=1, parent_up do
|
||||
current = dirtools.get_parent(current)
|
||||
list = dirtools.get_folderslist(current)
|
||||
if(dirtools.path_match(list, "sokol-luajit") == true) then
|
||||
return current
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------
|
||||
dirtools.change_folder = function( path, child )
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user