From 840995a63b3288cd5534ebdaec4605fa84494b35 Mon Sep 17 00:00:00 2001 From: dlannan Date: Fri, 27 Dec 2024 12:59:58 +1030 Subject: [PATCH] Working on base create project. with defaults for sokol-luajit. Similar to the build config panel. --- editor/aspect-error.log | 11 ++-- editor/config/recents.lua | 0 editor/www/modals/project_selection.html | 4 +- .../www/modals/project_selection_confirm.html | 19 +++++++ .../modals/project_selection_confirm_js.html | 16 ++++++ editor/www/modals/project_selection_js.html | 24 ++++++++- editor/www/partials/sys/folders-select.html | 7 +-- engine/world/config-manager.lua | 51 +++++++++++++++++++ engine/world/project-manager.lua | 12 +++-- tools/vfs/dirtools.lua | 9 +++- 10 files changed, 132 insertions(+), 21 deletions(-) create mode 100644 editor/config/recents.lua create mode 100644 editor/www/modals/project_selection_confirm.html create mode 100644 editor/www/modals/project_selection_confirm_js.html create mode 100644 engine/world/config-manager.lua diff --git a/editor/aspect-error.log b/editor/aspect-error.log index 13ebf24..8a76843 100644 --- a/editor/aspect-error.log +++ b/editor/aspect-error.log @@ -1,13 +1,8 @@ -compile error: unknown filter len in partials/sys/folders-select.html:21 -Context: if folder.folder|len > <-- there +syntax error: unexpected token '.', expecting end of tag in partials/dashboard_js.html:16 +Context: set projectmgr. <-- there Lua stack traceback: editor\twig/aspect\error.lua:49: in function 'compiler_error' - editor\twig/aspect\compiler.lua:656: in function 'parse_filters' - editor\twig/aspect\compiler.lua:739: in function 'parse_value' - editor\twig/aspect\ast.lua:85: in function 'parse' - editor\twig/aspect\compiler.lua:749: in function 'parse_expression' - editor\twig/aspect\tags.lua:616: in function - editor\twig/aspect\compiler.lua:259: in function + editor\twig/aspect\compiler.lua:261: in function [C]: in function 'pcall' editor\twig/aspect\compiler.lua:126: in function 'run' editor\twig/aspect\template.lua:232: in function 'compile' diff --git a/editor/config/recents.lua b/editor/config/recents.lua new file mode 100644 index 0000000..e69de29 diff --git a/editor/www/modals/project_selection.html b/editor/www/modals/project_selection.html index 589ccf8..29689db 100644 --- a/editor/www/modals/project_selection.html +++ b/editor/www/modals/project_selection.html @@ -57,7 +57,7 @@
New Project Name - +
@@ -75,6 +75,8 @@ + {% include "modals/project_selection_confirm.html" %} + diff --git a/editor/www/modals/project_selection_confirm.html b/editor/www/modals/project_selection_confirm.html new file mode 100644 index 0000000..0ceccab --- /dev/null +++ b/editor/www/modals/project_selection_confirm.html @@ -0,0 +1,19 @@ + \ No newline at end of file diff --git a/editor/www/modals/project_selection_confirm_js.html b/editor/www/modals/project_selection_confirm_js.html new file mode 100644 index 0000000..5071a96 --- /dev/null +++ b/editor/www/modals/project_selection_confirm_js.html @@ -0,0 +1,16 @@ + + + \ No newline at end of file diff --git a/editor/www/modals/project_selection_js.html b/editor/www/modals/project_selection_js.html index f7f0778..4989ed5 100644 --- a/editor/www/modals/project_selection_js.html +++ b/editor/www/modals/project_selection_js.html @@ -2,9 +2,22 @@ \ No newline at end of file + + +{% include("modals/project_selection_confirm_js.html") %} \ No newline at end of file diff --git a/editor/www/partials/sys/folders-select.html b/editor/www/partials/sys/folders-select.html index 2a006ed..4f1b7bb 100644 --- a/editor/www/partials/sys/folders-select.html +++ b/editor/www/partials/sys/folders-select.html @@ -1,5 +1,4 @@ -
@@ -8,8 +7,10 @@
Folder Path - -
+ + {% if projectmgr.sys.has_create==1 %} +
+ {% endif %}
diff --git a/engine/world/config-manager.lua b/engine/world/config-manager.lua new file mode 100644 index 0000000..fb1f253 --- /dev/null +++ b/engine/world/config-manager.lua @@ -0,0 +1,51 @@ + +-- Config manager handles editor config only. + +local utils = require("utils") +local json = require("json") +local dirtools = require("tools.vfs.dirtools") + +--------------------------------------------------------------------------------------- + +configmanager = { + recents_path = "editor/config/recents.json", + recents = {}, +} + +--------------------------------------------------------------------------------------- + +configmanager.load = function() + + -- This returns true for folder, false for file and nil for invalid + local recents_file = dirtools.is_folder(configmanager.recents_path) + if(recents_file == nil) then + + elseif(recents_file == false) then + local data = utils.loaddata( configmanager.recents_path ) + configmanager.recents = json.decode(data) + end +end + +--------------------------------------------------------------------------------------- + +configmanager.save = function() + + local fh = io.open(configmanager.recents_path, "w") + if(fh) then + fh:write( json.encode(configmanager.recents) ) + fh:close() + end + -- silent fail. +end + +--------------------------------------------------------------------------------------- + +configmanager.add_recent = function(name, path) + table.insert(configmanager.recents, { name=name, path=path } ) +end + +--------------------------------------------------------------------------------------- + +return configmanager + +--------------------------------------------------------------------------------------- diff --git a/engine/world/project-manager.lua b/engine/world/project-manager.lua index 24bdf58..9924823 100644 --- a/engine/world/project-manager.lua +++ b/engine/world/project-manager.lua @@ -7,23 +7,25 @@ local utils = require('lua.utils') local ffi = require("ffi") local dirtools = require("tools.vfs.dirtools") +local cfgmgr = require('engine.world.config-manager') ------------------------------------------------------------------------------------------------------------ local projectmanager = { recents = {}, sys = { - drives = dirtools.get_drives(), - folders = dirtools.get_folderslist("."), - current_folder = dirtools.get_app_path(), + has_create = 1, + drives = dirtools.get_drives(), + folders = dirtools.get_folderslist("."), + current_folder = dirtools.get_app_path(), }, } ------------------------------------------------------------------------------------------------------------ projectmanager.init = function(self) - - + cfgmgr.load() + self.recents = cfgmgr.recents end ------------------------------------------------------------------------------------------------------------ diff --git a/tools/vfs/dirtools.lua b/tools/vfs/dirtools.lua index f9a1550..1d1c1fa 100644 --- a/tools/vfs/dirtools.lua +++ b/tools/vfs/dirtools.lua @@ -169,19 +169,24 @@ end if(ffi.os == "Windows") then dirtools.is_folder = function(path) + if(path == nil) then return nil end + local fh = io.popen([[attrib "]]..path..[["]], "r") if(fh) then local res = fh:read("*a") local fileattr = string.sub(res, 1, 20) fileattr = string.gsub(fileattr, " ", "") fh:close() + if(string.match(res, "^File not found")) then return nil end return (#fileattr == 0) end - return false + return nil end else dirtools.is_folder = function(path) + if(path == nil) then return nil end + local fh = io.popen("file "..path, "r") if(fh) then local res = fh:read("*a") @@ -189,7 +194,7 @@ else fh:close() return (folder ~= nil) end - return false + return nil end end