Working on base create project. with defaults for sokol-luajit. Similar to the build config panel.

This commit is contained in:
dlannan 2024-12-27 12:59:58 +10:30
parent ea654dcc6e
commit 840995a63b
10 changed files with 132 additions and 21 deletions

View File

@ -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\tags.lua:613>
editor\twig/aspect\compiler.lua:259: in function <editor\twig/aspect\compiler.lua:202>
editor\twig/aspect\compiler.lua:261: in function <editor\twig/aspect\compiler.lua:202>
[C]: in function 'pcall'
editor\twig/aspect\compiler.lua:126: in function 'run'
editor\twig/aspect\template.lua:232: in function 'compile'

View File

View File

@ -57,7 +57,7 @@
<form role="form">
<div class="form-group input-group">
<span class="input-group-addon">New Project Name</span>
<input type="text" class="form-control" placeholder="MegaProject">
<input id="project-create-name" type="text" class="form-control" placeholder="MegaProject">
</div>
</form>
@ -75,6 +75,8 @@
</div>
<!-- /.col-lg-6 -->
{% include "modals/project_selection_confirm.html" %}
</div>
</div>
</div>

View File

@ -0,0 +1,19 @@
<div id="modalProjectSelectConfirm" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Create Project</h4>
</div>
<div class="modal-body">
<p>A new project is being created in:</p>
<h3 id="project_path"></h3>
<p>It will be named:</p>
<h3 id="project_name"></h3>
</div>
<div class="modal-footer">
<button id="project-select-cancel" type="button" class="btn btn-danger">Cancel</button>
<button id="project-select-ok" type="button" class="btn btn-primary">Ok</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->

View File

@ -0,0 +1,16 @@
<script>
$(document).ready(function () {
$("#project-select-cancel").on("click", function(evt){
$("#modalProjectSelectConfirm").modal("hide");
});
$("#project-select-ok").on("click", function(evt){
console.log(evt);
});
});
</script>

View File

@ -2,9 +2,22 @@
<script>
function showConfirm() {
$("#project-select-create").on("click", function(evt) {
var projectName = $("#project-create-name").val();
console.log(projectName);
$("#project_name").text( projectName );
$("#project_path").text( $("#project-select-path").attr("placeholder") );
$("#modalProjectSelectConfirm").modal("show");
});
}
function updateFolders(data) {
$("#sys-folders-select").load( "/partials/sys/folders-select.html", null, function() {
$("#sys-folders-select").load( "/partials/sys/folders-select.html", null, function() {
checkFolderSelect();
showConfirm();
});
}
@ -30,6 +43,10 @@ function checkFolderSelect()
$(document).ready(function () {
if($("#project-create-name").val().length == 0) {
$("#project-create-name").val("MegaProject");
}
$(".drive-select").on("click", function(evt){
console.log($(this).attr("data"));
var jdata = { drive: $(this).attr("data")};
@ -39,7 +56,10 @@ $(document).ready(function () {
$("#sys-folders-select").load( "/partials/sys/folders-select.html", null, function() {
checkFolderSelect();
showConfirm();
});
});
</script>
</script>
{% include("modals/project_selection_confirm_js.html") %}

View File

@ -1,5 +1,4 @@
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover sys-folders-list">
<thead>
@ -8,8 +7,10 @@
<form role="form">
<div class="form-group btn-group input-group">
<span class="input-group-addon">Folder Path</span>
<input type="text" class="form-control" placeholder="{{ projectmgr.sys.current_folder }}">
<div class="input-group-btn"><button type="button" class="btn btn-primary">Create</button></div>
<input id="project-select-path" type="text" class="form-control" placeholder="{{ projectmgr.sys.current_folder }}">
{% if projectmgr.sys.has_create==1 %}
<div id="project-select-create" class="input-group-btn"><button type="button" class="btn btn-primary">Create Project</button></div>
{% endif %}
</div>
</form>
</th>

View File

@ -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
---------------------------------------------------------------------------------------

View File

@ -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
------------------------------------------------------------------------------------------------------------

View File

@ -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