- Update bundler to support core and full versions
- Update ScrollFrame's properties
This commit is contained in:
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
@@ -76,6 +76,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
git config --global user.name 'github-actions[bot]'
|
git config --global user.name 'github-actions[bot]'
|
||||||
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
||||||
git add config.lua BasaltLS.lua release/basalt.lua CHANGELOG.md
|
git add config.lua BasaltLS.lua release/basalt-full.lua release/basalt-core.lua CHANGELOG.md
|
||||||
git commit -m "Update config, BasaltLS definitions, bundle and changelog" || exit 0
|
git commit -m "Update config, BasaltLS definitions, full and core bundles, and changelog" || exit 0
|
||||||
git push
|
git push
|
||||||
14
install.lua
14
install.lua
@@ -1,5 +1,6 @@
|
|||||||
local basalt
|
local basalt
|
||||||
local releasePath = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/release/basalt.lua"
|
local fullPath = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/release/basalt-full.lua"
|
||||||
|
local corePath = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/release/basalt-core.lua"
|
||||||
local devPath = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/src/"
|
local devPath = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/src/"
|
||||||
local configPath = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/config.lua"
|
local configPath = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/config.lua"
|
||||||
local luaLSPath = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/BasaltLS.lua"
|
local luaLSPath = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/BasaltLS.lua"
|
||||||
@@ -31,7 +32,7 @@ end
|
|||||||
|
|
||||||
if(args[1] == "-r")or(args[1] == "--release")then
|
if(args[1] == "-r")or(args[1] == "--release")then
|
||||||
print("Installing release version...")
|
print("Installing release version...")
|
||||||
local request = http.get(releasePath)
|
local request = http.get(fullPath)
|
||||||
if not request then
|
if not request then
|
||||||
error("Failed to download Basalt")
|
error("Failed to download Basalt")
|
||||||
end
|
end
|
||||||
@@ -83,7 +84,7 @@ if(args[1] == "-d")or(args[1] == "--dev")then
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local basaltRequest = http.get(releasePath)
|
local basaltRequest = http.get(fullPath)
|
||||||
if not basaltRequest then
|
if not basaltRequest then
|
||||||
error("Failed to download Basalt")
|
error("Failed to download Basalt")
|
||||||
end
|
end
|
||||||
@@ -131,7 +132,10 @@ local function getScreenPosition(index)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function createScreen(index)
|
local function createScreen(index)
|
||||||
local screen = main:addFrame(coloring)
|
local screen = main:addScrollFrame(coloring)
|
||||||
|
:setScrollBarBackgroundColor(colors.black)
|
||||||
|
--:setScrollBarBackgroundColor2(colors.gray)
|
||||||
|
:setScrollBarColor(colors.lightGray)
|
||||||
:onScroll(function(self, direction)
|
:onScroll(function(self, direction)
|
||||||
local height = getChildrenHeight(self)
|
local height = getChildrenHeight(self)
|
||||||
local scrollOffset = self:getOffsetY()
|
local scrollOffset = self:getOffsetY()
|
||||||
@@ -422,7 +426,7 @@ end
|
|||||||
local function installRelease(installPath, log, progressBar)
|
local function installRelease(installPath, log, progressBar)
|
||||||
logMessage(log, "Installing Release version...")
|
logMessage(log, "Installing Release version...")
|
||||||
|
|
||||||
local request = http.get(releasePath)
|
local request = http.get(fullPath)
|
||||||
if not request then
|
if not request then
|
||||||
logMessage(log, "Failed to download release version, aborting installation.")
|
logMessage(log, "Failed to download release version, aborting installation.")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -91,8 +91,8 @@ ScrollFrame.defineProperty(ScrollFrame, "showScrollBar", {default = true, type =
|
|||||||
---@property scrollBarSymbol string "_" The symbol used for the scrollbar handle
|
---@property scrollBarSymbol string "_" The symbol used for the scrollbar handle
|
||||||
ScrollFrame.defineProperty(ScrollFrame, "scrollBarSymbol", {default = " ", type = "string", canTriggerRender = true})
|
ScrollFrame.defineProperty(ScrollFrame, "scrollBarSymbol", {default = " ", type = "string", canTriggerRender = true})
|
||||||
|
|
||||||
---@property scrollBarBackground string "\127" The symbol used for the scrollbar background
|
---@property scrollBarBackgroundSymbol string "\127" The symbol used for the scrollbar background
|
||||||
ScrollFrame.defineProperty(ScrollFrame, "scrollBarBackground", {default = "\127", type = "string", canTriggerRender = true})
|
ScrollFrame.defineProperty(ScrollFrame, "scrollBarBackgroundSymbol", {default = "\127", type = "string", canTriggerRender = true})
|
||||||
|
|
||||||
---@property scrollBarColor color lightGray Color of the scrollbar handle
|
---@property scrollBarColor color lightGray Color of the scrollbar handle
|
||||||
ScrollFrame.defineProperty(ScrollFrame, "scrollBarColor", {default = colors.lightGray, type = "color", canTriggerRender = true})
|
ScrollFrame.defineProperty(ScrollFrame, "scrollBarColor", {default = colors.lightGray, type = "color", canTriggerRender = true})
|
||||||
@@ -100,6 +100,9 @@ ScrollFrame.defineProperty(ScrollFrame, "scrollBarColor", {default = colors.ligh
|
|||||||
---@property scrollBarBackgroundColor color gray Background color of the scrollbar
|
---@property scrollBarBackgroundColor color gray Background color of the scrollbar
|
||||||
ScrollFrame.defineProperty(ScrollFrame, "scrollBarBackgroundColor", {default = colors.gray, type = "color", canTriggerRender = true})
|
ScrollFrame.defineProperty(ScrollFrame, "scrollBarBackgroundColor", {default = colors.gray, type = "color", canTriggerRender = true})
|
||||||
|
|
||||||
|
---@property scrollBarBackgroundColor2 secondary color black Background color of the scrollbar
|
||||||
|
ScrollFrame.defineProperty(ScrollFrame, "scrollBarBackgroundColor2", {default = colors.black, type = "color", canTriggerRender = true})
|
||||||
|
|
||||||
---@property contentWidth number 0 The total width of the content (calculated from children)
|
---@property contentWidth number 0 The total width of the content (calculated from children)
|
||||||
ScrollFrame.defineProperty(ScrollFrame, "contentWidth", {
|
ScrollFrame.defineProperty(ScrollFrame, "contentWidth", {
|
||||||
default = 0,
|
default = 0,
|
||||||
@@ -378,20 +381,19 @@ function ScrollFrame:render()
|
|||||||
local scrollHeight = viewportHeight
|
local scrollHeight = viewportHeight
|
||||||
local handleSize = math.max(1, math.floor((viewportHeight / contentHeight) * scrollHeight))
|
local handleSize = math.max(1, math.floor((viewportHeight / contentHeight) * scrollHeight))
|
||||||
local maxOffset = contentHeight - viewportHeight
|
local maxOffset = contentHeight - viewportHeight
|
||||||
local scrollBarSymbol = self.get("scrollBarSymbol")
|
local scrollBarBg = self.get("scrollBarBackgroundSymbol")
|
||||||
local scrollBarBg = self.get("scrollBarBackground")
|
|
||||||
local scrollBarColor = self.get("scrollBarColor")
|
local scrollBarColor = self.get("scrollBarColor")
|
||||||
local scrollBarBgColor = self.get("scrollBarBackgroundColor")
|
local scrollBarBgColor = self.get("scrollBarBackgroundColor")
|
||||||
local foreground = self.get("foreground")
|
local scrollBarBg2Color = self.get("scrollBarBackgroundColor2")
|
||||||
|
|
||||||
local currentPercent = maxOffset > 0 and (offsetY / maxOffset * 100) or 0
|
local currentPercent = maxOffset > 0 and (offsetY / maxOffset * 100) or 0
|
||||||
local handlePos = math.floor((currentPercent / 100) * (scrollHeight - handleSize)) + 1
|
local handlePos = math.floor((currentPercent / 100) * (scrollHeight - handleSize)) + 1
|
||||||
|
|
||||||
for i = 1, scrollHeight do
|
for i = 1, scrollHeight do
|
||||||
if i >= handlePos and i < handlePos + handleSize then
|
if i >= handlePos and i < handlePos + handleSize then
|
||||||
self:blit(width, i, scrollBarSymbol, tHex[scrollBarColor], tHex[scrollBarBgColor])
|
self:blit(width, i, " ", tHex[scrollBarColor], tHex[scrollBarColor])
|
||||||
else
|
else
|
||||||
self:blit(width, i, scrollBarBg, tHex[foreground], tHex[scrollBarBgColor])
|
self:blit(width, i, scrollBarBg, tHex[scrollBarBgColor], tHex[scrollBarBg2Color])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -400,20 +402,19 @@ function ScrollFrame:render()
|
|||||||
local scrollWidth = viewportWidth
|
local scrollWidth = viewportWidth
|
||||||
local handleSize = math.max(1, math.floor((viewportWidth / contentWidth) * scrollWidth))
|
local handleSize = math.max(1, math.floor((viewportWidth / contentWidth) * scrollWidth))
|
||||||
local maxOffset = contentWidth - viewportWidth
|
local maxOffset = contentWidth - viewportWidth
|
||||||
local scrollBarSymbol = self.get("scrollBarSymbol")
|
local scrollBarBg = self.get("scrollBarBackgroundSymbol")
|
||||||
local scrollBarBg = self.get("scrollBarBackground")
|
|
||||||
local scrollBarColor = self.get("scrollBarColor")
|
local scrollBarColor = self.get("scrollBarColor")
|
||||||
local scrollBarBgColor = self.get("scrollBarBackgroundColor")
|
local scrollBarBgColor = self.get("scrollBarBackgroundColor")
|
||||||
local foreground = self.get("foreground")
|
local scrollBarBg2Color = self.get("scrollBarBackgroundColor2")
|
||||||
|
|
||||||
local currentPercent = maxOffset > 0 and (offsetX / maxOffset * 100) or 0
|
local currentPercent = maxOffset > 0 and (offsetX / maxOffset * 100) or 0
|
||||||
local handlePos = math.floor((currentPercent / 100) * (scrollWidth - handleSize)) + 1
|
local handlePos = math.floor((currentPercent / 100) * (scrollWidth - handleSize)) + 1
|
||||||
|
|
||||||
for i = 1, scrollWidth do
|
for i = 1, scrollWidth do
|
||||||
if i >= handlePos and i < handlePos + handleSize then
|
if i >= handlePos and i < handlePos + handleSize then
|
||||||
self:blit(i, height, scrollBarSymbol, tHex[scrollBarColor], tHex[scrollBarBgColor])
|
self:blit(i, height, " ", tHex[scrollBarColor], tHex[scrollBarColor])
|
||||||
else
|
else
|
||||||
self:blit(i, height, scrollBarBg, tHex[foreground], tHex[scrollBarBgColor])
|
self:blit(i, height, scrollBarBg, tHex[scrollBarBgColor], tHex[scrollBarBg2Color])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
local minify = loadfile("tools/minify.lua")()
|
local minify = loadfile("tools/minify.lua")()
|
||||||
|
|
||||||
|
local function loadConfig()
|
||||||
|
local config = dofile("config.lua")
|
||||||
|
return config
|
||||||
|
end
|
||||||
|
|
||||||
|
local function isDefaultFile(path, config)
|
||||||
|
for _, category in pairs(config.categories) do
|
||||||
|
for fileName, fileInfo in pairs(category.files) do
|
||||||
|
if fileInfo.path == path and fileInfo.default == true then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
local function scanDir(dir)
|
local function scanDir(dir)
|
||||||
local files = {}
|
local files = {}
|
||||||
for file in io.popen('find "'..dir..'" -type f -name "*.lua"'):lines() do
|
for file in io.popen('find "'..dir..'" -type f -name "*.lua"'):lines() do
|
||||||
@@ -13,7 +29,9 @@ local function scanDir(dir)
|
|||||||
return files
|
return files
|
||||||
end
|
end
|
||||||
|
|
||||||
local function bundle()
|
local function bundle(coreOnly)
|
||||||
|
local outputFile = coreOnly and "release/basalt-core.lua" or "release/basalt-full.lua"
|
||||||
|
local config = coreOnly and loadConfig() or nil
|
||||||
local files = scanDir("src")
|
local files = scanDir("src")
|
||||||
|
|
||||||
local output = {
|
local output = {
|
||||||
@@ -27,51 +45,61 @@ local function bundle()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
|
if not coreOnly or isDefaultFile(file.path, config) then
|
||||||
|
local elementName = file.path:match("^elements/(.+)%.lua$")
|
||||||
|
if elementName then
|
||||||
|
table.insert(output, string.format(
|
||||||
|
'minified_elementDirectory["%s"] = {}\n',
|
||||||
|
elementName
|
||||||
|
))
|
||||||
|
end
|
||||||
|
|
||||||
local elementName = file.path:match("^elements/(.+)%.lua$")
|
local pluginName = file.path:match("^plugins/(.+)%.lua$")
|
||||||
if elementName then
|
if pluginName then
|
||||||
table.insert(output, string.format(
|
table.insert(output, string.format(
|
||||||
'minified_elementDirectory["%s"] = {}\n',
|
'minified_pluginDirectory["%s"] = {}\n',
|
||||||
elementName
|
pluginName
|
||||||
))
|
))
|
||||||
end
|
end
|
||||||
|
|
||||||
local pluginName = file.path:match("^plugins/(.+)%.lua$")
|
|
||||||
if pluginName then
|
|
||||||
table.insert(output, string.format(
|
|
||||||
'minified_pluginDirectory["%s"] = {}\n',
|
|
||||||
pluginName
|
|
||||||
))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local includedFiles = {}
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
local f = io.open(file.fullPath, "r")
|
if not coreOnly or isDefaultFile(file.path, config) then
|
||||||
local content = f:read("*all")
|
table.insert(includedFiles, file)
|
||||||
f:close()
|
|
||||||
|
|
||||||
local success, minified = minify(content)
|
local f = io.open(file.fullPath, "r")
|
||||||
if not success then
|
local content = f:read("*all")
|
||||||
print("Failed to minify " .. file.path)
|
f:close()
|
||||||
os.exit(1)
|
|
||||||
|
local success, minified = minify(content)
|
||||||
|
if not success then
|
||||||
|
print("Failed to minify " .. file.path)
|
||||||
|
os.exit(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(output, string.format(
|
||||||
|
'project["%s"] = function(...) %s end\n',
|
||||||
|
file.path, minified
|
||||||
|
))
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(output, string.format(
|
|
||||||
'project["%s"] = function(...) %s end\n',
|
|
||||||
file.path, minified
|
|
||||||
))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(output, 'return project["main.lua"]()')
|
table.insert(output, 'return project["main.lua"]()')
|
||||||
|
|
||||||
local out = io.open("release/basalt.lua", "w")
|
local out = io.open(outputFile, "w")
|
||||||
out:write(table.concat(output))
|
out:write(table.concat(output))
|
||||||
out:close()
|
out:close()
|
||||||
|
|
||||||
print("Successfully bundled files:")
|
print("Successfully bundled " .. outputFile .. ":")
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(includedFiles) do
|
||||||
print("- " .. file.path)
|
print("- " .. file.path)
|
||||||
end
|
end
|
||||||
|
print("Total files: " .. #includedFiles)
|
||||||
end
|
end
|
||||||
|
|
||||||
bundle()
|
print("=== Building Full Version ===")
|
||||||
|
bundle(false)
|
||||||
|
print("\n=== Building Core Version ===")
|
||||||
|
bundle(true)
|
||||||
|
|||||||
Reference in New Issue
Block a user