Compare commits

..

2 Commits

Author SHA1 Message Date
Sanjay Bhadra 29d3d91245 File cleanup 2020-07-03 12:32:22 -04:00
Sanjay Bhadra b706eb031a Command hooks registry 2020-07-03 12:28:50 -04:00
5 changed files with 56 additions and 61 deletions

View File

@ -5,11 +5,8 @@ return {
dev = nil, -- Holds workshop instance and is set in main.lua
user = nil, -- Holds user instance and is set in main.lua
developerMode = false, -- Holds the developer_mode boolean and is set in main.lua
sideBarPageDefault = nil, -- Holds the default sidebar page (view) as a string and is set in topbarInterface.lua
sideBarPageActive = nil, -- Holds the current active sidebar page (view) as a string and is set in topbarInterface.lua
commandGroups = {}, -- Holds the core command groups used internally by workshop
commandGroups = {}, -- Holds the command groups that have been registered (~\library\toolchain\commands.lua)
defaultColours = { -- Default colors used for theming UI components (~\library\ui\components)
--primary = colour.rgb(112, 112, 112),
primary = colour.rgb(52, 58, 64),
secondary = colour.rgb(239, 239, 239),
background = colour.rgb(33, 33, 33),

View File

@ -3,17 +3,19 @@
local globals = require("tevgit:workshop/library/globals.lua") -- globals; variables or instances that can be shared between files
--[[
TEST DOCUMENT
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
-- How to register a plugin
local commands = require("...")
local extension = commands.createGroup("Hello")
extension.command("ping", function() print("pong") end)
-- >hello: ping
---> pong!
]]
return {
createGroup = function(id)
@ -21,36 +23,32 @@ return {
self = data
self.id = id
self.commands = {}
table.insert(globals.commandGroups, id)
globals.commandGroups[id] = {}
self.command = function(id, callback)
table.insert(commands, {id=callback})
end
self.invokeCommand = function(id)
for i,v in pairs(self.commands) do
for k,l in pairs(self.commands[i]) do
if l == id then return print("FOUND: "..id) end
end
end
table.insert(globals.commandGroups[data.id], {[tostring(id)]=callback})
end
return data
end,
parse = function(text)
-- Sytax
---> group: name
local commandIndex = string.find(text, ":")
if commandIndex == -1 then print("Failed to find command group: "..text) return end
local commandGroup = string.sub(text, 0, (commandIndex-1))
print("commandGroup: "..commandGroup)
-- Sytax
---> group: name
local commandIndex = string.find(text, ":")
if commandIndex == -1 or commandIndex == nil then print("Failed to find command group: "..text) return end
local commandGroup = string.gsub(string.sub(text, 0, (commandIndex-1)), "%s+", "")
local commandName = string.gsub(string.sub(text, (commandIndex+1), string.len(text)), "%s+", "")
--[[for i,v in pairs(globals.commandGroups) do
for k,l in pairs(self.commands[i]) do
if l ==
end
end]]--
for row, group in pairs(globals.commandGroups) do
for column, placement in pairs(group) do
for selection, trigger in pairs(placement) do
if(commandGroup == ">"..row) and (commandName == selection) then
placement[selection]()
print("COMMAND INVOKED")
end
end
end
end
end
}

View File

@ -53,7 +53,6 @@ return {
name = pageName,
size = guiCoord(1, 0, 0, 600),
position = guiCoord(-1, 0, 0, 200),
--backgroundColour = globals.defaultColours.red,
backgroundAlpha = 0,
zIndex = 200
})

View File

@ -5,6 +5,10 @@ local globals = require("tevgit:workshop/library/globals.lua") -- globals; varia
local toolTip = require("tevgit:workshop/library/ui/components/toolTip.lua") -- UI component
local commands = require("tevgit:workshop/library/toolchain/commands.lua") -- Commandbar toolchain component
-- Core Command Groups
local show_commandGroup = commands.createGroup("Show")
return {
construct = function(idValue, nameValue)
--[[
@ -30,8 +34,8 @@ return {
self.name = nameValue -- Name of scene being edited / developed on
self.keys = {} -- Where item keys are stored
self.pages = {}
self.defaultPage = nil
self.currentPage = nil
local defaultPage = nil
local currentPage = nil
self.animate = function(page, pos)
teverse.tween:begin(page, 0.5, { position = pos }, "inOutQuad")
@ -199,13 +203,25 @@ return {
end
self.bindDefaultMenu = function(page)
self.defaultPage = page
self.currentPage = page
defaultPage = page
currentPage = page
data.animate(page, guiCoord(0, 0, 0, 200))
end
self.bindMenu = function(name, page)
table.insert(data.pages, #data.pages+1, { [name] = page })
show_commandGroup.command(name, function()
if currentPage.id == page.id then
data.animate(currentPage, guiCoord(-1, 0, 0, 200))
data.animate(defaultPage, guiCoord(0, 0, 0, 200))
currentPage = defaultPage
return
end
data.animate(currentPage, guiCoord(-1, 0, 0, 200))
data.animate(page, guiCoord(0, 0, 0, 200))
currentPage = page
end)
_count = _count + 1
end

View File

@ -4,6 +4,7 @@
local globals = require("tevgit:workshop/library/globals.lua") -- globals; variables or instances that can be shared between files
local topbarInterface = require("tevgit:workshop/library/ui/controllers/topbarInterface.lua") -- UI Controller
local sidebarInterface = require("tevgit:workshop/library/ui/controllers/sidebarInterface.lua") -- UI Controller
local commands = require("tevgit:workshop/library/toolchain/commands.lua") -- Commands Registry
local topBar = topbarInterface.construct("horizontalNavbar", "Test Place 1") -- Create initial topbar instance
local sideBar = sidebarInterface.construct("verticalNavbar") -- Create initial sidebar instance
@ -26,8 +27,6 @@ defaultPage.registerIcon("uploadFileIcon", "file-upload", nil)
defaultPage.registerIcon("downloadFileIcon", "file-download", nil)
defaultPage.registerIcon("importFileIcon", "file-import", nil)
defaultPage.registerIcon("exportFileIcon", "file-export", nil)
--globals.sideBarPageDefault = defaultPage -- Set default sidebar page to default
--globals.sideBarPageActive = defaultPage -- Set default sidebar page as active
local designPage = sideBar.registerPage("Design") -- Register design page to sidebar instance
@ -36,7 +35,6 @@ designPage.registerIcon("guiFrameIcon", "square-full", nil)
designPage.registerIcon("guiTextBoxIcon", "i-cursor", nil)
designPage.registerIcon("guiImageIcon", "image", nil)
--[[
local modelPage = sideBar.registerPage("Model") -- Register model page to sidebar instance
modelPage.registerIcon("modelIcon", "shapes", nil)
@ -51,23 +49,10 @@ testPage.registerIcon("consoleIcon", "terminal", nil)
testPage.registerIcon("playIcon", "play", nil)
testPage.registerIcon("serverIcon", "server", nil)
testPage.registerIcon("fullScreenIcon", "expand-alt", nil)
]]--
-- Bind pages to labels in menu
-- Bind pages to sidebar menu
topBar.bindDefaultMenu(defaultPage.getContainer())
topBar.bindMenu("Design", designPage.getContainer())
--topBar.bindMenu("Model", modelPage.getContainer())
--topBar.bindMenu("Insert", insertPage.getContainer())
--topBar.bindMenu("Test", testPage.getContainer())
--[[
-- Register topbar button (name labels) to topbar instance
topBar.register("Design", "Design your guis", designPage)
topBar.register("Model", "Model your scene", modelPage)
topBar.register("Insert", "Insert an instance to your scene", insertPage)
topBar.register("Test", "Test your scene", testPage)
]]--
topBar.bindMenu("Model", modelPage.getContainer())
topBar.bindMenu("Insert", insertPage.getContainer())
topBar.bindMenu("Test", testPage.getContainer())