New Editor now has the build settings in it.

This commit is contained in:
dlannan 2025-10-18 16:05:03 +10:30
parent 4d3eedab64
commit 4eaa8ed9b0
11 changed files with 184 additions and 13 deletions

View File

@ -1,2 +1,5 @@
[Info] settings.load projectpath nil, using default settings.
[Info] settings.save_recents.
[Info] Found Sokol-luajit: F:\dev\luajit\repos\sokol-luajit
[Info] Auto filling sokol paths...
[Info] Found Sokol-luajit: F:\dev\luajit\repos\sokol-luajit
[Info] Auto filling sokol paths...

View File

@ -0,0 +1,14 @@
local assets = require("engine.gui.ui.panels_assets")
local element_assets = {
type = "custom",
init = nil,
update = assets.panel,
finish = nil,
}
return element_assets

View File

View File

@ -0,0 +1,48 @@
local panel = require("engine.gui.ui.panels")
local builder = require("engine.utils.build")
local build = require("engine.gui.ui.panels_build")
local element_project = {}
function default_handler(ctx, build)
builder.configure(panel.config)
builder.run(panel.config)
-- ticker = (ticker or 0) + 0.016
-- if(ticker > 0.01) then
-- build.progress[0] = build.progress[0] + 1
-- ticker = ticker - 0.01
-- end
-- if(panel.build.progress[0] >= 999) then
-- ticker = nil
build.progress[0] = 0.0
build.active = 0
build.mode = nil
-- end
end
function project_init(ctx, element)
print("project init handler")
panel.init()
panel.setup_fonts(ctx)
panel.build.handler = default_handler
-- Remove init on the element (no longer needed)
element.init = nil
end
function project_update(ctx, element)
build.panel(ctx)
end
element_project.type = "custom"
element_project.init = project_init
element_project.update = project_update
element_project.finish = panel.cleanup
return element_project

View File

View File

@ -1,6 +1,8 @@
-- All gui ui elements will follow a std format (under development)
--- Primary goal: A formal gui protocol like svg or html that allows for clear gui creation and control.
local nk = sg
local notes = require("data.gui.widgets.notebook")
local panels = {}
panels.windows = {}
@ -16,14 +18,7 @@ panels.windows.panel_simple = {
window_flags = bit.bor(0, nk.NK_WINDOW_NO_SCROLLBAR),
layout = {
{
type = "row", height = 24, layout = {
{ type = "button", text = "Project", action = "project_config", width = "auto" },
{ type = "button", text = "Paths", action = "paths_config", width = "auto" },
{ type = "button", text = "World", action = "world_view", width = "auto" },
{ type = "button", text = "Assets", action = "assets_view", width = "auto" },
}
},
notes.side_panel,
}
}

View File

@ -0,0 +1,22 @@
local nk = sg
local widgets = {}
widgets.notebook = {}
widgets.notebook.side_panel = {
type = "notebook",
height = 24,
tab_titles = { "Project", "Paths", "World", "Assets" },
tab_panels = { "project_config", "paths_config", "world_config", "assets_config" },
layout = {
{
},
}
}
return widgets.notebook

View File

@ -9,6 +9,8 @@ local smgr = require("engine.utils.statemanager")
local nk = sg
local hmm = require("hmm")
local ffi = require("ffi")
------------------------------------------------------------------------------------------------------------
-- These are child states that allow easier management of a simple controller
@ -36,6 +38,16 @@ local copas = require("copas")
local panels = require("data.gui.panels.panels")
local panelactions = require("data.gui.actions.panels")
-- This needs to be a database of loaded element templates
local elements_lookup = {
project_config = require("data.gui.elements.project_config"),
assets_config = require("data.gui.elements.assets_config"),
}
local button_colors = nil
------------------------------------------------------------------------------------------------------------
local SmainGui = smgr:NewState()
@ -53,6 +65,13 @@ function SmainGui:Init(wwidth, wheight)
-- SenvHandler:Init(wwidth, wheight)
print("Display: "..wwidth.." x "..wheight)
panels.windows.panel_master.parent = { size = { wwidth, wheight } }
button_colors = {
normal = nk.nk_style_item_color(mainState.ctx[0].style.button.normal.data.color),
hover = nk.nk_style_item_color(mainState.ctx[0].style.button.hover.data.color),
active = nk.nk_style_item_color(mainState.ctx[0].style.button.active.data.color),
}
end
------------------------------------------------------------------------------------------------------------
@ -199,7 +218,15 @@ end
local function render_element( ctx, element )
if(element.type == "group") then
-- Custom is for custom provided gui rendering (ie doesnt work well with provided templates)
if(element.type == "custom") then
if(element.init) then element.init(ctx, element) end
if(element.update) then element.update(ctx, element) end
-- if(element.finish) then element.finish(ctx, element) end
elseif(element.type == "group") then
element.winrect = element.winrect or ffi.new("struct nk_rect[1]", {{0, 0, 400, 600}})
get_geometry(element, element.winrect)
@ -224,6 +251,50 @@ local function render_element( ctx, element )
end
nk.nk_end(ctx)
elseif(element.type == "notebook") then
element.winrect = element.winrect or ffi.new("struct nk_rect[1]", {{0, 0, 400, 600}})
element.current_tab = element.current_tab or 1
local tabs = #element.tab_titles or 0
local row_height = element.height or 30
local widget_width = (element.parent.size[1] / tabs) / element.parent.size[1]
-- Remove button rounding
local rounding_ptr = utils.get_field_ptr( ctx[0].style.button, "struct nk_style_button", "rounding", "float *")
nk.nk_style_push_float(ctx, rounding_ptr, 0)
nk.nk_layout_row_begin(ctx, nk.NK_DYNAMIC, row_height, tabs)
for i = 1, tabs do
-- /* make sure button perfectly fits text */
nk.nk_layout_row_push(ctx, widget_width)
if (element.current_tab == i) then
-- /* active tab gets highlighted */
ctx[0].style.button.normal = button_colors.active
ctx[0].style.button.hover = button_colors.active
if (nk.nk_button_label(ctx, element.tab_titles[i]) ) then element.current_tab = i end
else
if(nk.nk_button_label(ctx, element.tab_titles[i])) then element.current_tab = i end
end
ctx[0].style.button.normal = button_colors.normal
ctx[0].style.button.hover = button_colors.hover
end
nk.nk_layout_row_end(ctx)
nk.nk_style_pop_float(ctx)
get_geometry(element, element.winrect)
if(element.tab_panels) then
for i,v in ipairs(element.tab_panels) do
if(i == element.current_tab) then
child_element = elements_lookup[v]
if(child_element) then
child_element.parent = element
render_element(ctx, child_element)
end
end
end
end
elseif(element.type == "row") then
local row_height = 30
local children = 1
@ -273,6 +344,7 @@ function SmainGui:Update(mxi, myi, buttons)
-- SmenuMain:Update(mxi, myi, buttons)
-- SenvHandler:Update(mxi, myi, buttons)
render_element(mainState.ctx, panels.windows.panel_master)
--nkgui:render()
self.prevmxi = mxi

View File

@ -169,7 +169,7 @@ end
-- --------------------------------------------------------------------------------------
panel.main_ui = function(ctx)
panel.setup_fonts = function(ctx)
if(myfonts == nil) then
myfonts = fonts.setup_font(ctx, font_list)
@ -179,6 +179,11 @@ panel.main_ui = function(ctx)
assets.font = myfonts
build.font = myfonts
end
end
-- --------------------------------------------------------------------------------------
panel.main_ui = function(ctx)
wdgts.widget_panel_fixed(ctx, "WinMain", 0, 0, sapp.sapp_width(), sapp.sapp_height(), 0, function(data)

View File

@ -82,7 +82,7 @@ local tabs = {
assets.panel = function(ctx)
nk.nk_style_set_font(ctx, assets.font[3].handle)
-- nk.nk_style_set_font(ctx, assets.font[3].handle)
local r = nk.nk_window_get_content_region(ctx)
local flags = nk.NK_WINDOW_BORDER

View File

@ -310,6 +310,16 @@ function parseurl(s)
return ans
end
-- ---------------------------------------------------------------------------
local function get_field_ptr( object, structname, field, ptrtype)
local base_ptr = ffi.cast("uint8_t *", object)
local off = ffi.offsetof(structname, field)
return ffi.cast(ptrtype, base_ptr + off)
end
-- ---------------------------------------------------------------------------
return {
@ -338,5 +348,7 @@ return {
urldecode = urldecode,
parseurl = parseurl,
get_field_ptr = get_field_ptr,
}
-- ---------------------------------------------------------------------------