New Editor now has the build settings in it.
This commit is contained in:
parent
4d3eedab64
commit
4eaa8ed9b0
@ -1,2 +1,5 @@
|
|||||||
[Info] settings.load projectpath nil, using default settings.
|
[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...
|
||||||
|
|||||||
14
data/gui/elements/assets_config.lua
Normal file
14
data/gui/elements/assets_config.lua
Normal 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
|
||||||
0
data/gui/elements/paths_config.lua
Normal file
0
data/gui/elements/paths_config.lua
Normal file
48
data/gui/elements/project_config.lua
Normal file
48
data/gui/elements/project_config.lua
Normal 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
|
||||||
0
data/gui/elements/world_config.lua
Normal file
0
data/gui/elements/world_config.lua
Normal file
@ -1,6 +1,8 @@
|
|||||||
-- All gui ui elements will follow a std format (under development)
|
-- 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.
|
--- Primary goal: A formal gui protocol like svg or html that allows for clear gui creation and control.
|
||||||
local nk = sg
|
local nk = sg
|
||||||
|
|
||||||
|
local notes = require("data.gui.widgets.notebook")
|
||||||
local panels = {}
|
local panels = {}
|
||||||
|
|
||||||
panels.windows = {}
|
panels.windows = {}
|
||||||
@ -16,14 +18,7 @@ panels.windows.panel_simple = {
|
|||||||
window_flags = bit.bor(0, nk.NK_WINDOW_NO_SCROLLBAR),
|
window_flags = bit.bor(0, nk.NK_WINDOW_NO_SCROLLBAR),
|
||||||
|
|
||||||
layout = {
|
layout = {
|
||||||
{
|
notes.side_panel,
|
||||||
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" },
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
22
data/gui/widgets/notebook.lua
Normal file
22
data/gui/widgets/notebook.lua
Normal 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
|
||||||
@ -9,6 +9,8 @@ local smgr = require("engine.utils.statemanager")
|
|||||||
local nk = sg
|
local nk = sg
|
||||||
local hmm = require("hmm")
|
local hmm = require("hmm")
|
||||||
|
|
||||||
|
local ffi = require("ffi")
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- These are child states that allow easier management of a simple controller
|
-- 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 panels = require("data.gui.panels.panels")
|
||||||
local panelactions = require("data.gui.actions.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()
|
local SmainGui = smgr:NewState()
|
||||||
@ -53,6 +65,13 @@ function SmainGui:Init(wwidth, wheight)
|
|||||||
-- SenvHandler:Init(wwidth, wheight)
|
-- SenvHandler:Init(wwidth, wheight)
|
||||||
print("Display: "..wwidth.." x "..wheight)
|
print("Display: "..wwidth.." x "..wheight)
|
||||||
panels.windows.panel_master.parent = { size = { wwidth, 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
|
end
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------
|
||||||
@ -199,7 +218,15 @@ end
|
|||||||
|
|
||||||
local function render_element( ctx, element )
|
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}})
|
element.winrect = element.winrect or ffi.new("struct nk_rect[1]", {{0, 0, 400, 600}})
|
||||||
get_geometry(element, element.winrect)
|
get_geometry(element, element.winrect)
|
||||||
@ -224,6 +251,50 @@ local function render_element( ctx, element )
|
|||||||
end
|
end
|
||||||
nk.nk_end(ctx)
|
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
|
elseif(element.type == "row") then
|
||||||
local row_height = 30
|
local row_height = 30
|
||||||
local children = 1
|
local children = 1
|
||||||
@ -247,7 +318,7 @@ local function render_element( ctx, element )
|
|||||||
nk.nk_label(ctx, element.text or "", alignment)
|
nk.nk_label(ctx, element.text or "", alignment)
|
||||||
|
|
||||||
elseif(element.type == "button") then
|
elseif(element.type == "button") then
|
||||||
local styled_button = ffi.new("struct nk_style_button[1]", { ctx[0].style.button})
|
local styled_button = ffi.new("struct nk_style_button[1]", { ctx[0].style.button })
|
||||||
-- Override rounded corners (can do other things here too - can also make your own button style)
|
-- Override rounded corners (can do other things here too - can also make your own button style)
|
||||||
styled_button[0].rounding = 0.0
|
styled_button[0].rounding = 0.0
|
||||||
if( nk.nk_button_label_styled(ctx, styled_button, element.text or "Missing Text")) then
|
if( nk.nk_button_label_styled(ctx, styled_button, element.text or "Missing Text")) then
|
||||||
@ -273,6 +344,7 @@ function SmainGui:Update(mxi, myi, buttons)
|
|||||||
-- SmenuMain:Update(mxi, myi, buttons)
|
-- SmenuMain:Update(mxi, myi, buttons)
|
||||||
-- SenvHandler:Update(mxi, myi, buttons)
|
-- SenvHandler:Update(mxi, myi, buttons)
|
||||||
render_element(mainState.ctx, panels.windows.panel_master)
|
render_element(mainState.ctx, panels.windows.panel_master)
|
||||||
|
|
||||||
--nkgui:render()
|
--nkgui:render()
|
||||||
|
|
||||||
self.prevmxi = mxi
|
self.prevmxi = mxi
|
||||||
|
|||||||
@ -169,7 +169,7 @@ end
|
|||||||
|
|
||||||
-- --------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
panel.main_ui = function(ctx)
|
panel.setup_fonts = function(ctx)
|
||||||
|
|
||||||
if(myfonts == nil) then
|
if(myfonts == nil) then
|
||||||
myfonts = fonts.setup_font(ctx, font_list)
|
myfonts = fonts.setup_font(ctx, font_list)
|
||||||
@ -179,6 +179,11 @@ panel.main_ui = function(ctx)
|
|||||||
assets.font = myfonts
|
assets.font = myfonts
|
||||||
build.font = myfonts
|
build.font = myfonts
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
panel.main_ui = function(ctx)
|
||||||
|
|
||||||
wdgts.widget_panel_fixed(ctx, "WinMain", 0, 0, sapp.sapp_width(), sapp.sapp_height(), 0, function(data)
|
wdgts.widget_panel_fixed(ctx, "WinMain", 0, 0, sapp.sapp_width(), sapp.sapp_height(), 0, function(data)
|
||||||
|
|
||||||
|
|||||||
@ -82,7 +82,7 @@ local tabs = {
|
|||||||
|
|
||||||
assets.panel = function(ctx)
|
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 r = nk.nk_window_get_content_region(ctx)
|
||||||
local flags = nk.NK_WINDOW_BORDER
|
local flags = nk.NK_WINDOW_BORDER
|
||||||
|
|||||||
@ -310,6 +310,16 @@ function parseurl(s)
|
|||||||
return ans
|
return ans
|
||||||
end
|
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 {
|
return {
|
||||||
|
|
||||||
@ -338,5 +348,7 @@ return {
|
|||||||
|
|
||||||
urldecode = urldecode,
|
urldecode = urldecode,
|
||||||
parseurl = parseurl,
|
parseurl = parseurl,
|
||||||
|
|
||||||
|
get_field_ptr = get_field_ptr,
|
||||||
}
|
}
|
||||||
-- ---------------------------------------------------------------------------
|
-- ---------------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user