5 Commits

Author SHA1 Message Date
Robert Jelic
14c0630c1e Added xml :loadLayoutFromString 2025-09-25 15:53:49 +02:00
Robert Jelic
64cb0d15e8 Update download.md
Updated install link
2025-04-06 01:15:52 +02:00
Robert Jelic
322ddb6158 Delete CNAME 2025-03-14 16:50:47 +01:00
Robert Jelic
c71557feb7 Small fix for programs 2025-02-15 18:12:08 +01:00
Robert Jelic
98b4191504 small fixxes for xml
Small fixxes for xml usage
2025-02-12 08:49:37 +01:00
6 changed files with 46 additions and 15 deletions

View File

@@ -78,7 +78,7 @@ local getObject = function(objectName)
return getObjects()[objectName]
end
local createObject = function(basalt, objectName, id)
local createObject = function(objectName, id)
return getObject(objectName)(id, basalt)
end
@@ -515,6 +515,9 @@ basalt = {
stop = stop,
stopUpdate = stop,
getTerm = function()
return baseTerm
end,
isKeyDown = function(key)
if(activeKey[key]==nil)then return false end

View File

@@ -419,7 +419,7 @@ return function(name, basalt)
for objectName, _ in pairs(basalt.getObjects()) do
container["add" .. objectName] = function(self, id)
return self:addChild(basalt:createObject(objectName, id))
return self:addChild(basalt.createObject(objectName, id))
end
end

View File

@@ -100,7 +100,7 @@ end
return {
basalt = function(basalt)
local createObjectsFromXMLNode = function(node, env)
local function createObjectsFromXMLNode(node, env)
local layout = env[node.tag]
if (layout ~= nil) then
local props = {}
@@ -109,12 +109,20 @@ return {
end
return basalt.createObjectsFromLayout(layout, props)
end
local objectName = node.tag:gsub("^%l", string.upper)
local object = basalt:createObject(objectName, node.attributes["id"])
local object = basalt.createObject(objectName, node.attributes["id"])
for attribute, expression in pairs(node.attributes) do
if (attribute:sub(1, 2) == "on") then
registerFunctionEvent(object, object[attribute], expression .. "()", env)
object[attribute](object, function(...)
local basaltCallback = basalt.getVariable(expression:gsub("\"", ""):gsub("\'", ""))
if(basaltCallback ~= nil) then
basaltCallback()
elseif(env[expression] ~= nil) then
env[expression]()
else
registerFunctionEvent(object, object[attribute], expression .. "()", env)
end
end)
else
local update = function()
local value = load("return " .. expression, nil, "t", env)()
@@ -124,7 +132,7 @@ return {
end
end
for _, child in ipairs(node.children) do
local childObjects = basalt.createObjectsFromXMLNode(child, env)
local childObjects = createObjectsFromXMLNode(child, env)
for _, childObject in ipairs(childObjects) do
object:addChild(childObject)
end
@@ -159,6 +167,9 @@ return {
end
setmetatable(env.props, {
__index = function(_, k)
if(updateFns[k] == nil) then
error("Property " .. k .. " not found")
end
return updateFns[k]()
end
})
@@ -196,6 +207,24 @@ return {
self:addChild(object)
end
return self
end,
loadLayoutFromString = function(self, xmlContent, props)
local wrappedProps = {}
if (props == nil) then
props = {}
end
for prop, value in pairs(props) do
wrappedProps[prop] = function()
return value
end
end
local layout = Layout.fromXML(xmlContent)
local objects = basalt.createObjectsFromLayout(layout, wrappedProps)
for _, object in ipairs(objects) do
self:addChild(object)
end
return self
end
}
return object

View File

@@ -88,7 +88,7 @@ plugin[v] = function(base, name, basalt)
if(base.init(self))then
local parent = self:getParent() or self
self:setBackground(parent:getTheme(v.."BG"))
self:setForeground(parent:getTheme(v.."Text"))
self:setForeground(parent:getTheme(v.."Text"))
end
end
}

View File

@@ -1 +0,0 @@
basalt.madefor.cc

View File

@@ -6,11 +6,11 @@ The Release version provides a specific, stable version of Basalt. Use this vers
To download the Release version, use the following command:
`wget run https://basalt.madefor.cc/install.lua release [remote_filename] [local_filename]`
`wget run https://raw.githubusercontent.com/Pyroxenium/Basalt/refs/heads/master/docs/install.lua release [remote_filename] [local_filename]`
In most cases, you'll likely want to use:
`wget run https://basalt.madefor.cc/install.lua release latest.lua`
`wget run https://raw.githubusercontent.com/Pyroxenium/Basalt/refs/heads/master/docs/install.lua release latest.lua`
- `remote_filename`: The file name of the Basalt release you want to download (e.g., basalt-1.6.6.lua, latest.lua).
- `local_filename` (optional): The file name for the Basalt installation on your local system (e.g., basalt.lua).
@@ -23,7 +23,7 @@ The Minified/Packed version is a compressed version of the Basalt code directly
To download the Minified/Packed version, use the following command:
`wget run https://basalt.madefor.cc/install.lua packed [filename] [branch]`
`wget run https://raw.githubusercontent.com/Pyroxenium/Basalt/refs/heads/master/docs/install.lua packed [filename] [branch]`
- `filename` (optional): The file name for the Basalt installation (default: `basalt.lua`).
- `branch` (optional): Choose between `master` and `dev` branches (default: `master`).
@@ -34,7 +34,7 @@ The Source version, as the name suggests, contains the unmodified source code of
To download the Source version, use the following command:
`wget run https://basalt.madefor.cc/install.lua source [foldername] [branch]`
`wget run https://raw.githubusercontent.com/Pyroxenium/Basalt/refs/heads/master/docs/install.lua source [foldername] [branch]`
- `foldername` (optional): The folder name for the Basalt installation (default: `basalt`).
- `branch` (optional): Choose between `master` and `dev` branches (default: `master`).
@@ -45,9 +45,9 @@ The Web version is designed for minimal project size and fetches the required co
To download the Web version, use the following command:
`wget run https://basalt.madefor.cc/install.lua web [version] [filename]`
`wget run https://raw.githubusercontent.com/Pyroxenium/Basalt/refs/heads/master/docs/install.lua web [version] [filename]`
- `version` (optional): Specify the desired version of Basalt (default: latest version). [Click here](https://github.com/Pyroxenium/Basalt/tree/master/docs/versions) to see the available versions.
- `filename` (optional): The file name for the Basalt installation (default: `basaltWeb.lua`).
**Note**: If using the Web version, remember to change `local basalt = require("basalt")` to `local basalt = require("basaltWeb")` in your code.
**Note**: If using the Web version, remember to change `local basalt = require("basalt")` to `local basalt = require("basaltWeb")` in your code.