Adding gui components and vfs
This commit is contained in:
parent
e4c6315ac5
commit
1abb948347
@ -94,7 +94,7 @@ end
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
local visited = {}
|
||||
function tdump(o, level)
|
||||
local function tdump(o, level)
|
||||
local level = level or 1
|
||||
if(level == 0) then visited = {} end
|
||||
if type(o) == 'table' then
|
||||
@ -347,17 +347,8 @@ return {
|
||||
|
||||
deepcopy = deepcopy,
|
||||
|
||||
isjudge = isjudge,
|
||||
getpeoplecount = getpeoplecount,
|
||||
getpeopletext = getpeopletext,
|
||||
getscenariotext = getscenariotext,
|
||||
gettimetext = gettimetext,
|
||||
getjudgetext = getjudgetext,
|
||||
|
||||
tickround = tickround,
|
||||
|
||||
loaddata = loaddata,
|
||||
saveconfig = saveconfig,
|
||||
loadconfig = loadconfig,
|
||||
}
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
@ -46,6 +46,26 @@ local font_list = {
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
local visited = {}
|
||||
local function tdump(o, level)
|
||||
local level = level or 1
|
||||
if(level == 0) then visited = {} end
|
||||
if type(o) == 'table' then
|
||||
local s = ' {\n'
|
||||
for k,v in pairs(o) do
|
||||
if type(k) ~= 'number' then k = '"'..tostring(k)..'"' end
|
||||
if(visited[v] == nil) then
|
||||
visited[v] = true
|
||||
s = s .. string.rep(" ", level)..'['..k..'] = ' .. tdump(v, level+1)
|
||||
end
|
||||
end
|
||||
return s .. string.rep(" ", level-1)..'}\n'
|
||||
else
|
||||
return tostring(o).."\n"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
-- Static vars
|
||||
--
|
||||
@ -215,7 +235,7 @@ local function assets_panel(ctx)
|
||||
|
||||
nk.nk_style_set_font(ctx, myfonts[3].handle)
|
||||
|
||||
curr_tab = wdgts.widget_notebook(ctx, tabs, curr_tab, 120)
|
||||
curr_tab = wdgts.widget_notebook(ctx, "assets", tabs, curr_tab, 500, 120)
|
||||
|
||||
nk.nk_layout_row_begin(ctx, nk.NK_STATIC, 22, 3)
|
||||
nk.nk_layout_row_push(ctx, 50)
|
||||
@ -304,3 +324,25 @@ app_desc[0].ios_keyboard_resizes_canvas = false
|
||||
sapp.sapp_run( app_desc )
|
||||
|
||||
-- --------------------------------------------------------------------------------------
|
||||
|
||||
local default_libs = {
|
||||
["os"] = true,
|
||||
["_G"] = true,
|
||||
["jit"] = true,
|
||||
["table"] = true,
|
||||
["jit.opt"] = true,
|
||||
["ffi"] = true,
|
||||
["string"] = true,
|
||||
["io"] = true,
|
||||
["coroutine"] = true,
|
||||
["package"] = true,
|
||||
["math"] = true,
|
||||
["debug"] = true,
|
||||
["bit"] = true,
|
||||
}
|
||||
for k,v in pairs(package.loaded) do
|
||||
|
||||
if(type(v) ~= "userdata" and default_libs[tostring(k)] == nil) then
|
||||
print( "["..tostring(k).."] = "..tostring(v))
|
||||
end
|
||||
end
|
||||
35
tools/build/rbuilder/utils/vfs.lua
Normal file
35
tools/build/rbuilder/utils/vfs.lua
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
-- This is a stub of how to make a virtual file system append a loader to the package loader system
|
||||
-- Not sure why other loaders are throw away. I think an insert would be nicer (ie, higher prioerity or similar)
|
||||
|
||||
loadfile = function(name, mode, ...)
|
||||
local file = load_file(name) -- native function returning data blob
|
||||
if file then
|
||||
-- :as_chunk() method will do "lua_loadbuffer" and set environment if asked
|
||||
return file:as_chunk(name, ...)
|
||||
end
|
||||
return nil, "cannot open '"..name.."': No such file or directory"
|
||||
end
|
||||
|
||||
dofile = function(name, ...)
|
||||
local chunk, err = loadfile(name)
|
||||
if not chunk then error(err, 2) end
|
||||
return chunk(...)
|
||||
end
|
||||
|
||||
local function vfs_loader(modname, file)
|
||||
local chunk, err = file:as_chunk(modname)
|
||||
if not chunk then error(err,2) end
|
||||
return chunk()
|
||||
end
|
||||
|
||||
local function vfs_searcher(fname)
|
||||
local file = load_file(gsub(fname,"%.","/")..".lua")
|
||||
if file then
|
||||
return vfs_loader, file
|
||||
end
|
||||
end
|
||||
|
||||
-- not just insert our searcher, but drop all the rest to disable
|
||||
-- loading of external files
|
||||
package.searchers = { package.loaders[1], vfs_searcher }
|
||||
@ -7,7 +7,9 @@ local ffi = require("ffi")
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local widgets = {}
|
||||
local widgets = {
|
||||
id_name = 1,
|
||||
}
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -170,7 +172,7 @@ end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
widgets.widget_notebook = function(ctx, tabs, current_tab, tab_fixed_width)
|
||||
widgets.widget_notebook = function(ctx, tab_name, tabs, current_tab, height, tab_fixed_width)
|
||||
|
||||
local step = (2*3.141592654) / 32
|
||||
local chart_type = {CHART_LINE=1, CHART_HISTO=2, CHART_MIXED=3}
|
||||
@ -199,12 +201,12 @@ widgets.widget_notebook = function(ctx, tabs, current_tab, tab_fixed_width)
|
||||
nk.nk_style_pop_float(ctx)
|
||||
|
||||
-- /* Body */
|
||||
nk.nk_layout_row_dynamic(ctx, 140, 1)
|
||||
if (nk.nk_group_begin(ctx, "Notebook", nk.NK_WINDOW_BORDER) == true) then
|
||||
nk.nk_layout_row_dynamic(ctx, height, 1)
|
||||
if (nk.nk_group_begin(ctx, tab_name, nk.NK_WINDOW_BORDER) == true) then
|
||||
|
||||
nk.nk_style_pop_vec2(ctx)
|
||||
if(current_tab == chart_type.CHART_LINE) then
|
||||
nk.nk_layout_row_dynamic(ctx, 100, 1)
|
||||
nk.nk_layout_row_dynamic(ctx, height-20, 1)
|
||||
if (nk.nk_chart_begin_colored(ctx, nk.NK_CHART_LINES, nk.nk_rgb(255,0,0), nk.nk_rgb(150,0,0), 32, 0.0, 1.0)) then
|
||||
nk.nk_chart_add_slot_colored(ctx, nk.NK_CHART_LINES, nk.nk_rgb(0,0,255), nk.nk_rgb(0,0,150),32, -1.0, 1.0)
|
||||
local id = 0
|
||||
@ -217,7 +219,7 @@ widgets.widget_notebook = function(ctx, tabs, current_tab, tab_fixed_width)
|
||||
nk.nk_chart_end(ctx)
|
||||
elseif(current_tab == chart_type.CHART_HISTO) then
|
||||
|
||||
nk.nk_layout_row_dynamic(ctx, 100, 1)
|
||||
nk.nk_layout_row_dynamic(ctx, height-20, 1)
|
||||
if (nk.nk_chart_begin_colored(ctx, nk.NK_CHART_COLUMN, nk.nk_rgb(255,0,0), nk.nk_rgb(150,0,0), 32, 0.0, 1.0)) then
|
||||
local id = 0
|
||||
for i = 0, 32-1 do
|
||||
@ -227,7 +229,7 @@ widgets.widget_notebook = function(ctx, tabs, current_tab, tab_fixed_width)
|
||||
end
|
||||
nk.nk_chart_end(ctx)
|
||||
elseif(current_tab == chart_type.CHART_MIXED) then
|
||||
nk.nk_layout_row_dynamic(ctx, 100, 1)
|
||||
nk.nk_layout_row_dynamic(ctx, height-20, 1)
|
||||
if (nk.nk_chart_begin_colored(ctx, nk.NK_CHART_LINES, nk.nk_rgb(255,0,0), nk.nk_rgb(150,0,0), 32, 0.0, 1.0)) then
|
||||
nk.nk_chart_add_slot_colored(ctx, nk.NK_CHART_LINES, nk.nk_rgb(0,0,255), nk.nk_rgb(0,0,150),32, -1.0, 1.0)
|
||||
nk.nk_chart_add_slot_colored(ctx, nk.NK_CHART_COLUMN, nk.nk_rgb(0,255,0), nk.nk_rgb(0,150,0), 32, 0.0, 1.0)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user