Fixed recents.
This commit is contained in:
parent
e221bc4b03
commit
9013bde402
@ -1 +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"]
|
["F:\\dev\\luajit\\Thunc\\sokol-luajit\\builds\\cube_sapp\\cube_sapp.slp","F:\\dev\\luajit\\Thunc\\sokol-luajit\\builds\\cube_sapp\\cube_sapp2.slp"]
|
||||||
@ -105,13 +105,17 @@ settings.add_recents = function( filename )
|
|||||||
if(settings.recents) then
|
if(settings.recents) then
|
||||||
|
|
||||||
-- Check it isnt already in the list, add to first and remove the other.
|
-- Check it isnt already in the list, add to first and remove the other.
|
||||||
local removal = {}
|
local cleaned_recents = {}
|
||||||
|
|
||||||
for i, v in ipairs(settings.recents) do
|
for i, v in ipairs(settings.recents) do
|
||||||
if string.match(v, filename) then table.insert(removal, i) end
|
local testf = string.gsub(filename, "%-", "_")
|
||||||
end
|
local testv = string.gsub(v, "%-", "_")
|
||||||
for i, v in ipairs(removal) do
|
if string.match(testf, testv) then
|
||||||
table.remove(settings.recents, v)
|
else
|
||||||
|
table.insert(cleaned_recents, v)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
settings.recents = cleaned_recents
|
||||||
table.insert(settings.recents, 1, filename)
|
table.insert(settings.recents, 1, filename)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -38,13 +38,16 @@ file_selector.create_file_list = function( name, rect, recent_files )
|
|||||||
|
|
||||||
if (nk.nk_group_begin(ctx, name, flags) == true) then
|
if (nk.nk_group_begin(ctx, name, flags) == true) then
|
||||||
|
|
||||||
nk.nk_layout_row_dynamic(ctx, dim.h-90, 1)
|
nk.nk_layout_row_dynamic(ctx, dim.h-115, 1)
|
||||||
|
|
||||||
local bhit = wdgts.widget_list_buttons(ctx, "recent_file", nil, udata.recent_files, dim.w -40 )
|
local bhit = wdgts.widget_list_buttons(ctx, "recent_file", nil, udata.recent_files, dim.w -40 )
|
||||||
if(bhit) then
|
if(bhit) then
|
||||||
udata.file_selected = bhit[2]
|
udata.file_selected = bhit[2]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
nk.nk_layout_row_dynamic(ctx, 25, 1)
|
||||||
|
nk.nk_label(ctx, string.format("Selected: %s",udata.file_selected), 1)
|
||||||
|
|
||||||
nk.nk_layout_row_dynamic(ctx, 25, 2)
|
nk.nk_layout_row_dynamic(ctx, 25, 2)
|
||||||
if (nk.nk_button_label(ctx, "Cancel") == true) then
|
if (nk.nk_button_label(ctx, "Cancel") == true) then
|
||||||
udata.popup_active = 0
|
udata.popup_active = 0
|
||||||
@ -199,7 +202,7 @@ end
|
|||||||
|
|
||||||
-- --------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
file_selector.show = function(select_obj)
|
file_selector.show = function(select_obj, callback)
|
||||||
|
|
||||||
select_obj.popup_active = 1
|
select_obj.popup_active = 1
|
||||||
if(callback) then select_obj.callback = callback end
|
if(callback) then select_obj.callback = callback end
|
||||||
|
|||||||
@ -161,7 +161,10 @@ panel.init = function()
|
|||||||
setup_config()
|
setup_config()
|
||||||
|
|
||||||
settings.load_recents()
|
settings.load_recents()
|
||||||
recent_files = fsel.create_file_list("Choose Recent", dim2, {})
|
popup_wide = sapp.sapp_width()* 0.8
|
||||||
|
local dim3 = nk.nk_rect( sapp.sapp_width()/2-8 - popup_wide/2,
|
||||||
|
sapp.sapp_height()/2-40 - popup_high/2, popup_wide, popup_high)
|
||||||
|
recent_files = fsel.create_file_list("Choose Recent", dim3, {})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------
|
||||||
@ -333,6 +336,12 @@ panel.show_recents = function(ctx)
|
|||||||
end
|
end
|
||||||
recent_files.recent_files = panel.recent_list
|
recent_files.recent_files = panel.recent_list
|
||||||
fsel.show(recent_files, function(udata, res)
|
fsel.show(recent_files, function(udata, res)
|
||||||
|
if(res == true) then
|
||||||
|
panel.current_path = udata.file_selected
|
||||||
|
settings.load(udata.file_selected)
|
||||||
|
settings.add_recents(udata.file_selected)
|
||||||
|
print("Opened: "..udata.file_selected)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -475,7 +484,10 @@ panel.input = function(event)
|
|||||||
sapp.sapp_height()/2-40 - popup_high/2, popup_wide, popup_high)
|
sapp.sapp_height()/2-40 - popup_high/2, popup_wide, popup_high)
|
||||||
file_select.popup_dim = dim2
|
file_select.popup_dim = dim2
|
||||||
|
|
||||||
recent_files.popup_dim = dim2
|
popup_wide = sapp.sapp_width()* 0.8
|
||||||
|
local dim3 = nk.nk_rect( sapp.sapp_width()/2-8 - popup_wide/2,
|
||||||
|
sapp.sapp_height()/2-40 - popup_high/2, popup_wide, popup_high)
|
||||||
|
recent_files.popup_dim = dim3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user