Skip to content

Commit 5dd2c77

Browse files
committed
- Update bundler to support core and full versions
- Update ScrollFrame's properties
1 parent 2b0f14d commit 5dd2c77

4 files changed

Lines changed: 84 additions & 51 deletions

File tree

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ jobs:
7676
run: |
7777
git config --global user.name 'github-actions[bot]'
7878
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
79-
git add config.lua BasaltLS.lua release/basalt.lua CHANGELOG.md
80-
git commit -m "Update config, BasaltLS definitions, bundle and changelog" || exit 0
79+
git add config.lua BasaltLS.lua release/basalt-full.lua release/basalt-core.lua CHANGELOG.md
80+
git commit -m "Update config, BasaltLS definitions, full and core bundles, and changelog" || exit 0
8181
git push

install.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local basalt
2-
local releasePath = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/release/basalt.lua"
2+
local fullPath = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/release/basalt-full.lua"
3+
local corePath = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/release/basalt-core.lua"
34
local devPath = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/src/"
45
local configPath = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/config.lua"
56
local luaLSPath = "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/BasaltLS.lua"
@@ -31,7 +32,7 @@ end
3132

3233
if(args[1] == "-r")or(args[1] == "--release")then
3334
print("Installing release version...")
34-
local request = http.get(releasePath)
35+
local request = http.get(fullPath)
3536
if not request then
3637
error("Failed to download Basalt")
3738
end
@@ -83,7 +84,7 @@ if(args[1] == "-d")or(args[1] == "--dev")then
8384
end
8485

8586

86-
local basaltRequest = http.get(releasePath)
87+
local basaltRequest = http.get(fullPath)
8788
if not basaltRequest then
8889
error("Failed to download Basalt")
8990
end
@@ -131,7 +132,10 @@ local function getScreenPosition(index)
131132
end
132133

133134
local function createScreen(index)
134-
local screen = main:addFrame(coloring)
135+
local screen = main:addScrollFrame(coloring)
136+
:setScrollBarBackgroundColor(colors.black)
137+
--:setScrollBarBackgroundColor2(colors.gray)
138+
:setScrollBarColor(colors.lightGray)
135139
:onScroll(function(self, direction)
136140
local height = getChildrenHeight(self)
137141
local scrollOffset = self:getOffsetY()
@@ -422,7 +426,7 @@ end
422426
local function installRelease(installPath, log, progressBar)
423427
logMessage(log, "Installing Release version...")
424428

425-
local request = http.get(releasePath)
429+
local request = http.get(fullPath)
426430
if not request then
427431
logMessage(log, "Failed to download release version, aborting installation.")
428432
return

src/elements/ScrollFrame.lua

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,18 @@ ScrollFrame.defineProperty(ScrollFrame, "showScrollBar", {default = true, type =
9191
---@property scrollBarSymbol string "_" The symbol used for the scrollbar handle
9292
ScrollFrame.defineProperty(ScrollFrame, "scrollBarSymbol", {default = " ", type = "string", canTriggerRender = true})
9393

94-
---@property scrollBarBackground string "\127" The symbol used for the scrollbar background
95-
ScrollFrame.defineProperty(ScrollFrame, "scrollBarBackground", {default = "\127", type = "string", canTriggerRender = true})
94+
---@property scrollBarBackgroundSymbol string "\127" The symbol used for the scrollbar background
95+
ScrollFrame.defineProperty(ScrollFrame, "scrollBarBackgroundSymbol", {default = "\127", type = "string", canTriggerRender = true})
9696

9797
---@property scrollBarColor color lightGray Color of the scrollbar handle
9898
ScrollFrame.defineProperty(ScrollFrame, "scrollBarColor", {default = colors.lightGray, type = "color", canTriggerRender = true})
9999

100100
---@property scrollBarBackgroundColor color gray Background color of the scrollbar
101101
ScrollFrame.defineProperty(ScrollFrame, "scrollBarBackgroundColor", {default = colors.gray, type = "color", canTriggerRender = true})
102102

103+
---@property scrollBarBackgroundColor2 secondary color black Background color of the scrollbar
104+
ScrollFrame.defineProperty(ScrollFrame, "scrollBarBackgroundColor2", {default = colors.black, type = "color", canTriggerRender = true})
105+
103106
---@property contentWidth number 0 The total width of the content (calculated from children)
104107
ScrollFrame.defineProperty(ScrollFrame, "contentWidth", {
105108
default = 0,
@@ -378,20 +381,19 @@ function ScrollFrame:render()
378381
local scrollHeight = viewportHeight
379382
local handleSize = math.max(1, math.floor((viewportHeight / contentHeight) * scrollHeight))
380383
local maxOffset = contentHeight - viewportHeight
381-
local scrollBarSymbol = self.get("scrollBarSymbol")
382-
local scrollBarBg = self.get("scrollBarBackground")
384+
local scrollBarBg = self.get("scrollBarBackgroundSymbol")
383385
local scrollBarColor = self.get("scrollBarColor")
384386
local scrollBarBgColor = self.get("scrollBarBackgroundColor")
385-
local foreground = self.get("foreground")
387+
local scrollBarBg2Color = self.get("scrollBarBackgroundColor2")
386388

387389
local currentPercent = maxOffset > 0 and (offsetY / maxOffset * 100) or 0
388390
local handlePos = math.floor((currentPercent / 100) * (scrollHeight - handleSize)) + 1
389391

390392
for i = 1, scrollHeight do
391393
if i >= handlePos and i < handlePos + handleSize then
392-
self:blit(width, i, scrollBarSymbol, tHex[scrollBarColor], tHex[scrollBarBgColor])
394+
self:blit(width, i, " ", tHex[scrollBarColor], tHex[scrollBarColor])
393395
else
394-
self:blit(width, i, scrollBarBg, tHex[foreground], tHex[scrollBarBgColor])
396+
self:blit(width, i, scrollBarBg, tHex[scrollBarBgColor], tHex[scrollBarBg2Color])
395397
end
396398
end
397399
end
@@ -400,20 +402,19 @@ function ScrollFrame:render()
400402
local scrollWidth = viewportWidth
401403
local handleSize = math.max(1, math.floor((viewportWidth / contentWidth) * scrollWidth))
402404
local maxOffset = contentWidth - viewportWidth
403-
local scrollBarSymbol = self.get("scrollBarSymbol")
404-
local scrollBarBg = self.get("scrollBarBackground")
405+
local scrollBarBg = self.get("scrollBarBackgroundSymbol")
405406
local scrollBarColor = self.get("scrollBarColor")
406407
local scrollBarBgColor = self.get("scrollBarBackgroundColor")
407-
local foreground = self.get("foreground")
408+
local scrollBarBg2Color = self.get("scrollBarBackgroundColor2")
408409

409410
local currentPercent = maxOffset > 0 and (offsetX / maxOffset * 100) or 0
410411
local handlePos = math.floor((currentPercent / 100) * (scrollWidth - handleSize)) + 1
411412

412413
for i = 1, scrollWidth do
413414
if i >= handlePos and i < handlePos + handleSize then
414-
self:blit(i, height, scrollBarSymbol, tHex[scrollBarColor], tHex[scrollBarBgColor])
415+
self:blit(i, height, " ", tHex[scrollBarColor], tHex[scrollBarColor])
415416
else
416-
self:blit(i, height, scrollBarBg, tHex[foreground], tHex[scrollBarBgColor])
417+
self:blit(i, height, scrollBarBg, tHex[scrollBarBgColor], tHex[scrollBarBg2Color])
417418
end
418419
end
419420
end

tools/bundler.lua

Lines changed: 60 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
local minify = loadfile("tools/minify.lua")()
22

3+
local function loadConfig()
4+
local config = dofile("config.lua")
5+
return config
6+
end
7+
8+
local function isDefaultFile(path, config)
9+
for _, category in pairs(config.categories) do
10+
for fileName, fileInfo in pairs(category.files) do
11+
if fileInfo.path == path and fileInfo.default == true then
12+
return true
13+
end
14+
end
15+
end
16+
return false
17+
end
18+
319
local function scanDir(dir)
420
local files = {}
521
for file in io.popen('find "'..dir..'" -type f -name "*.lua"'):lines() do
@@ -13,9 +29,11 @@ local function scanDir(dir)
1329
return files
1430
end
1531

16-
local function bundle()
32+
local function bundle(coreOnly)
33+
local outputFile = coreOnly and "release/basalt-core.lua" or "release/basalt-full.lua"
34+
local config = coreOnly and loadConfig() or nil
1735
local files = scanDir("src")
18-
36+
1937
local output = {
2038
'local minified = true\n',
2139
'local minified_elementDirectory = {}\n',
@@ -27,51 +45,61 @@ local function bundle()
2745
}
2846

2947
for _, file in ipairs(files) do
48+
if not coreOnly or isDefaultFile(file.path, config) then
49+
local elementName = file.path:match("^elements/(.+)%.lua$")
50+
if elementName then
51+
table.insert(output, string.format(
52+
'minified_elementDirectory["%s"] = {}\n',
53+
elementName
54+
))
55+
end
3056

31-
local elementName = file.path:match("^elements/(.+)%.lua$")
32-
if elementName then
33-
table.insert(output, string.format(
34-
'minified_elementDirectory["%s"] = {}\n',
35-
elementName
36-
))
37-
end
38-
39-
local pluginName = file.path:match("^plugins/(.+)%.lua$")
40-
if pluginName then
41-
table.insert(output, string.format(
42-
'minified_pluginDirectory["%s"] = {}\n',
43-
pluginName
44-
))
57+
local pluginName = file.path:match("^plugins/(.+)%.lua$")
58+
if pluginName then
59+
table.insert(output, string.format(
60+
'minified_pluginDirectory["%s"] = {}\n',
61+
pluginName
62+
))
63+
end
4564
end
4665
end
4766

67+
local includedFiles = {}
4868
for _, file in ipairs(files) do
49-
local f = io.open(file.fullPath, "r")
50-
local content = f:read("*all")
51-
f:close()
69+
if not coreOnly or isDefaultFile(file.path, config) then
70+
table.insert(includedFiles, file)
5271

53-
local success, minified = minify(content)
54-
if not success then
55-
print("Failed to minify " .. file.path)
56-
os.exit(1)
57-
end
72+
local f = io.open(file.fullPath, "r")
73+
local content = f:read("*all")
74+
f:close()
75+
76+
local success, minified = minify(content)
77+
if not success then
78+
print("Failed to minify " .. file.path)
79+
os.exit(1)
80+
end
5881

59-
table.insert(output, string.format(
60-
'project["%s"] = function(...) %s end\n',
61-
file.path, minified
62-
))
82+
table.insert(output, string.format(
83+
'project["%s"] = function(...) %s end\n',
84+
file.path, minified
85+
))
86+
end
6387
end
6488

6589
table.insert(output, 'return project["main.lua"]()')
6690

67-
local out = io.open("release/basalt.lua", "w")
91+
local out = io.open(outputFile, "w")
6892
out:write(table.concat(output))
6993
out:close()
7094

71-
print("Successfully bundled files:")
72-
for _, file in ipairs(files) do
95+
print("Successfully bundled " .. outputFile .. ":")
96+
for _, file in ipairs(includedFiles) do
7397
print("- " .. file.path)
7498
end
99+
print("Total files: " .. #includedFiles)
75100
end
76101

77-
bundle()
102+
print("=== Building Full Version ===")
103+
bundle(false)
104+
print("\n=== Building Core Version ===")
105+
bundle(true)

0 commit comments

Comments
 (0)