- Update bundler to support core and full versions

- Update ScrollFrame's properties
This commit is contained in:
Robert Jelic
2025-11-04 09:42:44 +01:00
parent 2b0f14dc56
commit 5dd2c77dbc
4 changed files with 84 additions and 51 deletions

View File

@@ -76,6 +76,6 @@ jobs:
run: |
git config --global user.name 'github-actions[bot]'
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 commit -m "Update config, BasaltLS definitions, bundle and changelog" || exit 0
git add config.lua BasaltLS.lua release/basalt-full.lua release/basalt-core.lua CHANGELOG.md
git commit -m "Update config, BasaltLS definitions, full and core bundles, and changelog" || exit 0
git push

View File

@@ -1,5 +1,6 @@
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 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"
@@ -31,7 +32,7 @@ end
if(args[1] == "-r")or(args[1] == "--release")then
print("Installing release version...")
local request = http.get(releasePath)
local request = http.get(fullPath)
if not request then
error("Failed to download Basalt")
end
@@ -83,7 +84,7 @@ if(args[1] == "-d")or(args[1] == "--dev")then
end
local basaltRequest = http.get(releasePath)
local basaltRequest = http.get(fullPath)
if not basaltRequest then
error("Failed to download Basalt")
end
@@ -131,7 +132,10 @@ local function getScreenPosition(index)
end
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)
local height = getChildrenHeight(self)
local scrollOffset = self:getOffsetY()
@@ -422,7 +426,7 @@ end
local function installRelease(installPath, log, progressBar)
logMessage(log, "Installing Release version...")
local request = http.get(releasePath)
local request = http.get(fullPath)
if not request then
logMessage(log, "Failed to download release version, aborting installation.")
return

View File

@@ -91,8 +91,8 @@ ScrollFrame.defineProperty(ScrollFrame, "showScrollBar", {default = true, type =
---@property scrollBarSymbol string "_" The symbol used for the scrollbar handle
ScrollFrame.defineProperty(ScrollFrame, "scrollBarSymbol", {default = " ", type = "string", canTriggerRender = true})
---@property scrollBarBackground string "\127" The symbol used for the scrollbar background
ScrollFrame.defineProperty(ScrollFrame, "scrollBarBackground", {default = "\127", type = "string", canTriggerRender = true})
---@property scrollBarBackgroundSymbol string "\127" The symbol used for the scrollbar background
ScrollFrame.defineProperty(ScrollFrame, "scrollBarBackgroundSymbol", {default = "\127", type = "string", canTriggerRender = true})
---@property scrollBarColor color lightGray Color of the scrollbar handle
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
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)
ScrollFrame.defineProperty(ScrollFrame, "contentWidth", {
default = 0,
@@ -378,20 +381,19 @@ function ScrollFrame:render()
local scrollHeight = viewportHeight
local handleSize = math.max(1, math.floor((viewportHeight / contentHeight) * scrollHeight))
local maxOffset = contentHeight - viewportHeight
local scrollBarSymbol = self.get("scrollBarSymbol")
local scrollBarBg = self.get("scrollBarBackground")
local scrollBarBg = self.get("scrollBarBackgroundSymbol")
local scrollBarColor = self.get("scrollBarColor")
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 handlePos = math.floor((currentPercent / 100) * (scrollHeight - handleSize)) + 1
for i = 1, scrollHeight do
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
self:blit(width, i, scrollBarBg, tHex[foreground], tHex[scrollBarBgColor])
self:blit(width, i, scrollBarBg, tHex[scrollBarBgColor], tHex[scrollBarBg2Color])
end
end
end
@@ -400,20 +402,19 @@ function ScrollFrame:render()
local scrollWidth = viewportWidth
local handleSize = math.max(1, math.floor((viewportWidth / contentWidth) * scrollWidth))
local maxOffset = contentWidth - viewportWidth
local scrollBarSymbol = self.get("scrollBarSymbol")
local scrollBarBg = self.get("scrollBarBackground")
local scrollBarBg = self.get("scrollBarBackgroundSymbol")
local scrollBarColor = self.get("scrollBarColor")
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 handlePos = math.floor((currentPercent / 100) * (scrollWidth - handleSize)) + 1
for i = 1, scrollWidth do
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
self:blit(i, height, scrollBarBg, tHex[foreground], tHex[scrollBarBgColor])
self:blit(i, height, scrollBarBg, tHex[scrollBarBgColor], tHex[scrollBarBg2Color])
end
end
end

View File

@@ -1,5 +1,21 @@
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 files = {}
for file in io.popen('find "'..dir..'" -type f -name "*.lua"'):lines() do
@@ -13,7 +29,9 @@ local function scanDir(dir)
return files
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 output = {
@@ -27,7 +45,7 @@ local function bundle()
}
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(
@@ -44,8 +62,13 @@ local function bundle()
))
end
end
end
local includedFiles = {}
for _, file in ipairs(files) do
if not coreOnly or isDefaultFile(file.path, config) then
table.insert(includedFiles, file)
local f = io.open(file.fullPath, "r")
local content = f:read("*all")
f:close()
@@ -61,17 +84,22 @@ local function bundle()
file.path, minified
))
end
end
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:close()
print("Successfully bundled files:")
for _, file in ipairs(files) do
print("Successfully bundled " .. outputFile .. ":")
for _, file in ipairs(includedFiles) do
print("- " .. file.path)
end
print("Total files: " .. #includedFiles)
end
bundle()
print("=== Building Full Version ===")
bundle(false)
print("\n=== Building Core Version ===")
bundle(true)