Added builder progress panel
This commit is contained in:
parent
103a8b0a70
commit
93c68cf140
2
tools/build/rbuilder/config/rbuilder.log
Normal file
2
tools/build/rbuilder/config/rbuilder.log
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Info] settings.load projectpath nil, using default settings.
|
||||||
|
[Info] settings.save_recents.
|
||||||
@ -27,6 +27,23 @@ ffi.cdef[[
|
|||||||
void Sleep(uint32_t ms);
|
void Sleep(uint32_t ms);
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
-- --------------------------------------------------------------------------------------
|
||||||
|
local ticker = nil
|
||||||
|
|
||||||
|
function default_handler(ctx, build)
|
||||||
|
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
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
local function init(void)
|
local function init(void)
|
||||||
@ -46,6 +63,7 @@ local function init(void)
|
|||||||
sapp.sapp_show_mouse(false)
|
sapp.sapp_show_mouse(false)
|
||||||
|
|
||||||
panel.init()
|
panel.init()
|
||||||
|
panel.build.handler = default_handler
|
||||||
sapp.sapp_set_window_title(panel.config.rbuilder.title.value)
|
sapp.sapp_set_window_title(panel.config.rbuilder.title.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,35 @@ local logging = require("utils.logging")
|
|||||||
local panel = {
|
local panel = {
|
||||||
config = nil,
|
config = nil,
|
||||||
current_path = ".",
|
current_path = ".",
|
||||||
|
|
||||||
|
build = {
|
||||||
|
mode = nil,
|
||||||
|
active = 0,
|
||||||
|
progress = ffi.new("size_t[1]", { 0 } ),
|
||||||
|
status = "",
|
||||||
|
handler = nil,
|
||||||
|
ui_func = function(ctx, dim, build)
|
||||||
|
|
||||||
|
nk.nk_layout_row_dynamic(ctx, dim.h-20, 1)
|
||||||
|
|
||||||
|
local flags = bit.bor(nk.NK_WINDOW_BORDER, nk.NK_WINDOW_TITLE)
|
||||||
|
flags = bit.bor(flags, nk.NK_WINDOW_NO_SCROLLBAR)
|
||||||
|
if (nk.nk_group_begin(ctx, "Building...", flags) == true) then
|
||||||
|
|
||||||
|
nk.nk_layout_row_dynamic(ctx, dim.h-dim.h/2 - 50, 1)
|
||||||
|
nk.nk_layout_row_dynamic(ctx, 25, 1)
|
||||||
|
nk.nk_label(ctx, "Please wait. Build mode: "..build.mode, nk.NK_TEXT_CENTERED)
|
||||||
|
nk.nk_layout_row_dynamic(ctx, 25, 1)
|
||||||
|
nk.nk_progress(ctx, build.progress, 1000, nk.NK_FIXED)
|
||||||
|
nk.nk_group_end(ctx)
|
||||||
|
end
|
||||||
|
|
||||||
|
if(build.handler) then build.handler(ctx, build) end
|
||||||
|
|
||||||
|
if(build.active == 0) then nk.nk_popup_close(ctx) end
|
||||||
|
return build.active
|
||||||
|
end,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------
|
||||||
@ -281,6 +310,11 @@ local project_tabs = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "Logs",
|
name = "Logs",
|
||||||
|
func = function(ctx)
|
||||||
|
local bounds = nk.nk_window_get_content_region(ctx)
|
||||||
|
nk.nk_layout_row_dynamic(ctx, bounds.h, 1)
|
||||||
|
wdgts.widget_list(ctx, "Logs", nk.NK_WINDOW_BORDER, logging.loglines)
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
-- --------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------
|
||||||
@ -294,13 +328,13 @@ local function project_panel(ctx)
|
|||||||
-- display_section(ctx, "audio")
|
-- display_section(ctx, "audio")
|
||||||
|
|
||||||
nk.nk_layout_row_dynamic(ctx, 25, 2)
|
nk.nk_layout_row_dynamic(ctx, 25, 2)
|
||||||
local add_folder = false
|
|
||||||
if (nk.nk_button_label(ctx, "Build Release") == true) then
|
if (nk.nk_button_label(ctx, "Build Release") == true) then
|
||||||
add_folder = true
|
panel.build.mode = "release"
|
||||||
|
panel.build.active = 1
|
||||||
end
|
end
|
||||||
local add_file = false
|
|
||||||
if (nk.nk_button_label(ctx, "Clean All") == true) then
|
if (nk.nk_button_label(ctx, "Clean All") == true) then
|
||||||
add_file = true
|
panel.build.mode = "clean"
|
||||||
|
panel.build.active = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Awesome little radial popup.
|
-- Awesome little radial popup.
|
||||||
@ -379,9 +413,10 @@ 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)
|
||||||
|
|
||||||
folder_select.popup_active = wdgts.widget_popup_panel(ctx, "popup", folder_select.popup_dim, folder_select.ui_func, folder_select, folder_select.popup_active)
|
panel.build.active = wdgts.widget_popup_panel(ctx, "popup_build", folder_select.popup_dim, panel.build.ui_func, panel.build, panel.build.active)
|
||||||
file_select.popup_active = wdgts.widget_popup_panel(ctx, "popup", file_select.popup_dim, file_select.ui_func, file_select, file_select.popup_active)
|
folder_select.popup_active = wdgts.widget_popup_panel(ctx, "popup_folder", folder_select.popup_dim, folder_select.ui_func, folder_select, folder_select.popup_active)
|
||||||
recent_files.popup_active = wdgts.widget_popup_panel(ctx, "popup", recent_files.popup_dim, recent_files.ui_func, recent_files, recent_files.popup_active)
|
file_select.popup_active = wdgts.widget_popup_panel(ctx, "popup_fileselect", file_select.popup_dim, file_select.ui_func, file_select, file_select.popup_active)
|
||||||
|
recent_files.popup_active = wdgts.widget_popup_panel(ctx, "popup_recentfiles", recent_files.popup_dim, recent_files.ui_func, recent_files, recent_files.popup_active)
|
||||||
|
|
||||||
-- /* menubar */
|
-- /* menubar */
|
||||||
local menu_states = { MENU_DEFAULT = 0, MENU_WINDOWS = 1}
|
local menu_states = { MENU_DEFAULT = 0, MENU_WINDOWS = 1}
|
||||||
@ -464,24 +499,20 @@ panel.main_ui = function(ctx)
|
|||||||
local height = sapp.sapp_height()
|
local height = sapp.sapp_height()
|
||||||
nk.nk_layout_row_dynamic(ctx, height-20, 2)
|
nk.nk_layout_row_dynamic(ctx, height-20, 2)
|
||||||
|
|
||||||
-- wdgts.widget_panel_fixed(ctx, "Project", 10, 10, width, height, flags, function(data)
|
|
||||||
if (nk.nk_group_begin(ctx, "Settings", flags) == true) then
|
if (nk.nk_group_begin(ctx, "Settings", flags) == true) then
|
||||||
|
|
||||||
local padding = ctx[0].style.window.padding
|
local padding = ctx[0].style.window.padding
|
||||||
ctx[0].style.window.padding = nk.nk_vec2(10,10)
|
ctx[0].style.window.padding = nk.nk_vec2(10,10)
|
||||||
|
|
||||||
project_panel(data.ctx)
|
project_panel(data.ctx)
|
||||||
-- end, {ctx=ctx})
|
|
||||||
nk.nk_group_end(ctx)
|
nk.nk_group_end(ctx)
|
||||||
end
|
end
|
||||||
|
|
||||||
nk.nk_style_set_font(ctx, myfonts[4].handle)
|
nk.nk_style_set_font(ctx, myfonts[4].handle)
|
||||||
|
|
||||||
-- wdgts.widget_panel_fixed(ctx, "Assets", 10+width+10, 10, width, height, flags, function(data)
|
|
||||||
if (nk.nk_group_begin(ctx, "Assets", flags) == true) then
|
if (nk.nk_group_begin(ctx, "Assets", flags) == true) then
|
||||||
|
|
||||||
assets_panel(data.ctx)
|
assets_panel(data.ctx)
|
||||||
-- end, {ctx=ctx})
|
|
||||||
nk.nk_group_end(ctx)
|
nk.nk_group_end(ctx)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -566,6 +597,7 @@ end
|
|||||||
panel.cleanup = function()
|
panel.cleanup = function()
|
||||||
|
|
||||||
settings.save_recents()
|
settings.save_recents()
|
||||||
|
logging.cleanup()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -1,22 +1,49 @@
|
|||||||
|
|
||||||
local logging = {}
|
local tinsert = table.insert
|
||||||
|
|
||||||
|
local logging = {
|
||||||
|
logfilename = "config/rbuilder.log",
|
||||||
|
logfh = nil, -- log file handle
|
||||||
|
loglines = {}, -- As each line is written, its captured for display if needed.
|
||||||
|
}
|
||||||
|
|
||||||
|
-- --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
logging.write = function( str )
|
||||||
|
|
||||||
|
logging.fh = logging.fh or io.open(logging.logfilename, "w")
|
||||||
|
assert(logging.fh, "[Fatal Error] Cannot open logfile")
|
||||||
|
|
||||||
|
tinsert(logging.loglines, str)
|
||||||
|
|
||||||
|
logging.fh:write(str)
|
||||||
|
io.write(str) -- writes to std out as well
|
||||||
|
end
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
logging.info = function( infostr )
|
logging.info = function( infostr )
|
||||||
io.write(string.format("[Info] %s\n", infostr))
|
logging.write(string.format("[Info] %s\n", infostr))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
logging.warn = function( warnstr )
|
logging.warn = function( warnstr )
|
||||||
io.write(string.format("[Warning] %s\n", warnstr))
|
logging.write(string.format("[Warning] %s\n", warnstr))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
logging.error = function( errstr )
|
logging.error = function( errstr )
|
||||||
io.write(string.format("[Error] %s\n", errstr))
|
logging.write(string.format("[Error] %s\n", errstr))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
logging.cleanup = function( )
|
||||||
|
if(logging.logfh) then
|
||||||
|
logging.logfh:close()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -241,6 +241,19 @@ end
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
widgets.widget_list = function(ctx, title, flags, items)
|
||||||
|
|
||||||
|
if (nk.nk_group_begin(ctx, title, flags) == true) then
|
||||||
|
nk.nk_layout_row_dynamic(ctx, 22, 1);
|
||||||
|
for i, item in ipairs(items) do
|
||||||
|
nk.nk_label(ctx, item, nk.NK_TEXT_LEFT)
|
||||||
|
end
|
||||||
|
nk.nk_group_end(ctx)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
widgets.widget_list_selectable = function(ctx, title, flags, items, width)
|
widgets.widget_list_selectable = function(ctx, title, flags, items, width)
|
||||||
|
|
||||||
if (nk.nk_group_begin(ctx, title, flags) == true) then
|
if (nk.nk_group_begin(ctx, title, flags) == true) then
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user