38 Commits

Author SHA1 Message Date
Robert Jelic
075903f9a9 Small 1.6 fixes
- added basalt.forceRenderUpdate
- fixed dropdowns behaving wrong on monitors
2023-04-29 23:14:19 +02:00
Robert Jelic
d6931412c8 Updated textfield
- fixed paste-events by removing an outdated if-statement
2023-04-17 17:42:11 +02:00
Robert Jelic
73b43358ff Small palette fix 2023-03-11 20:10:06 +01:00
Robert Jelic
df7be99fdd Merge branch 'master' of https://github.com/Pyroxenium/Basalt 2023-02-20 16:28:24 +01:00
Robert Jelic
6f0ddd6bf6 Small fix
Small XML borderColor fix
2023-02-20 16:28:22 +01:00
Robert Jelic
a821abed1f Update Textfield.lua
- Removed buggy selection
- Fixed a small bug
2023-02-17 20:40:49 +01:00
Robert Jelic
50dce1c1e7 added :setSelectionColor()
added :setSelectionColor(backgroundCol, foregroundCol)
2023-01-23 21:52:20 +01:00
Robert Jelic
94fccf9211 Update process.lua 2023-01-08 10:04:00 +01:00
Robert Jelic
a4d0492d17 Update Program.lua 2023-01-08 10:03:39 +01:00
Robert Jelic
5ebb5fe436 Update Program.lua
Fixed args for programs
2023-01-08 10:02:50 +01:00
Robert Jelic
bb921c57cd v1.6.5 2023-01-07 02:31:11 +01:00
Robert Jelic
2b85ab9746 Small fix
Forgot to check if program is active or not
2023-01-01 22:46:34 +01:00
Robert Jelic
29ebd7d4d7 Update Program.lua 2023-01-01 22:24:03 +01:00
Robert Jelic
8ab7bc4bde Auto Resizing fix
Forgot to move code for term_resize events to customEventHandler..
2023-01-01 22:21:52 +01:00
Robert Jelic
1b8f62ce41 schedule filter
Added event filters for schedules, now they should work properly.
2022-12-31 01:42:12 +01:00
Robert Jelic
61e38d89e8 Update images.lua 2022-12-30 02:30:48 +01:00
Robert Jelic
a0db5ecb61 Fixed nfp
Forgot i didn't add nfp support >.<
2022-12-30 02:14:58 +01:00
Robert Jelic
3ef7aa91bf Frame Resize
Forgot to add basalt_resize event for base frames
2022-12-26 15:51:25 +01:00
Robert Jelic
09e8589938 Update install.lua 2022-12-26 12:12:31 +01:00
Robert Jelic
e9aba2498b Small XML Fix
-fixed dyn value for width, height, x and y.
- added bgSymbol and bgSymbolColor for xml
- added texture for xml
2022-12-25 19:12:34 +01:00
Robert Jelic
20ceb6b56f Small event fix for programs 2022-12-25 16:56:13 +01:00
Robert Jelic
6d2956f3bf Updated image docs 2022-12-24 11:48:35 +01:00
Robert Jelic
91e42e096c Update utils.lua 2022-12-24 00:28:07 +01:00
Robert Jelic
5f00dfe401 Update Button.lua 2022-12-19 20:32:35 +01:00
Robert Jelic
2c4c059a70 Fixed a fix
Forgot i have to split by words and not just split when width has reached.
2022-12-18 00:43:09 +01:00
Robert Jelic
923b570d48 CreateText & splitString improvements
Improved the createText and splitString functions.
2022-12-18 00:31:52 +01:00
Robert Jelic
5499057e7e Merge pull request #43 from Erb3/path-6
✏️ Fix small typo ("sotred" -> "stored")
2022-12-16 18:31:21 +01:00
Erlend
d6091b312c ✏️ Fix small typo ("sotred" -> "stored") 2022-12-16 15:28:11 +01:00
Robert Jelic
f19c0ebb49 Update Frame.lua 2022-12-14 20:34:17 +01:00
Robert Jelic
01b83822b1 Merge branch 'master' of https://github.com/Pyroxenium/Basalt 2022-12-14 20:33:05 +01:00
Robert Jelic
c81f24cca2 Made a small mistake.. 2022-12-14 20:31:01 +01:00
Robert Jelic
ed894cb390 Monitor mouse event fix
Fixed mouse event's on monitor frames not working
2022-12-14 20:25:49 +01:00
Robert Jelic
355db9a82c Merge pull request #42 from Erb3/patch-3
📝 Fix a small typo in How-To.md
2022-12-14 20:10:28 +01:00
Erlend
8112378c70 📝 Fix a small typo in How-To.md
Fixed typo where it said `mainFrame` instead of `main`.
Reported by Broso56#0465 in the Discord.
2022-12-14 15:10:36 +01:00
Robert Jelic
a181496052 Update Frame.lua
This is just a small workaround for an actual bug - i need to figure out where it comes from.
2022-12-09 12:38:20 +01:00
Robert Jelic
636ed0001f Update init.lua
Accidentally changed package.path to nil in certain cases. Oopsie #fixed
2022-12-09 07:18:00 +01:00
Robert Jelic
0e3da7eda5 Update install.lua 2022-11-27 00:47:16 +01:00
Robert Jelic
3cf5adaef1 Add files via upload 2022-11-23 17:52:04 +01:00
27 changed files with 9341 additions and 2667 deletions

View File

@@ -92,6 +92,7 @@ return function(name, parent, pTerm, basalt)
end
end
end
local function getDeepObject(name)
local o = getObject(name)
if(o~=nil)then return o end
@@ -825,9 +826,7 @@ return function(name, parent, pTerm, basalt)
if (events["other_event"][index] ~= nil) then
for _, value in rpairs(events["other_event"][index]) do
if (value.eventHandler ~= nil) then
if (value:eventHandler(event, ...)) then
return true
end
value:eventHandler(event, ...)
end
end
end
@@ -836,6 +835,7 @@ return function(name, parent, pTerm, basalt)
if(autoSize)and not(isMonitor)then
if(self.parent==nil)then
if(event=="term_resize")then
self:sendEvent("basalt_resize", self, event, ...)
self:setSize(termObject.getSize())
autoSize = true
end
@@ -885,20 +885,20 @@ return function(name, parent, pTerm, basalt)
end
end,
mouseHandler = function(self, button, x, y, _, side)
mouseHandler = function(self, button, x, y, touch, side)
if(isGroupedMonitor)then
if(termObject.calculateClick~=nil)then
x, y = termObject.calculateClick(side, x, y)
end
end
if(base.mouseHandler(self, button, x, y))then
if(base.mouseHandler(self, button, x, y, touch))then
if(events["mouse_click"]~=nil)then
self:setCursor(false)
for _, index in ipairs(eventZIndex["mouse_click"]) do
if (events["mouse_click"][index] ~= nil) then
for _, value in rpairs(events["mouse_click"][index]) do
if (value.mouseHandler ~= nil) then
if (value:mouseHandler(button, x, y)) then
if (value:mouseHandler(button, x, y, touch)) then
return true
end

View File

@@ -108,11 +108,25 @@ return function(name)
setValuesByXMLData = function(self, data)
local baseFrame = self:getBaseFrame()
if(xmlValue("x", data)~=nil)then self:setPosition(xmlValue("x", data), self:getY()) end
if(xmlValue("y", data)~=nil)then self:setPosition(self:getX(), xmlValue("y", data)) end
if(xmlValue("width", data)~=nil)then self:setSize(xmlValue("width", data), self.height) end
if(xmlValue("height", data)~=nil)then self:setSize(self.width, xmlValue("height", data)) end
local tex, mode, infPlay
if(xmlValue("texture", data)~=nil)then tex = xmlValue("texture", data) end
if(xmlValue("mode", data)~=nil)then mode = xmlValue("mode", data) end
if(xmlValue("texturePlay", data)~=nil)then infPlay = xmlValue("texturePlay", data) end
local x, y
if(xmlValue("x", data)~=nil)then x = xmlValue("x", data) end
if(xmlValue("y", data)~=nil)then y = xmlValue("y", data) end
if(x~=nil)or(y~=nil)then
self:setPosition(x, y)
end
local w, h
if(xmlValue("width", data)~=nil)then w = xmlValue("width", data) end
if(xmlValue("height", data)~=nil)then h = xmlValue("height", data) end
if(w~=nil)or(h~=nil)then
self:setSize(w, h)
end
if(xmlValue("bg", data)~=nil)then self:setBackground(colors[xmlValue("bg", data)]) end
if(xmlValue("bgSymbol", data)~=nil)then self:setBackground(self.bgColor, xmlValue("bgSymbol", data)) end
if(xmlValue("bgSymbolColor", data)~=nil)then self:setBackground(self.bgColor, self.bgSymbol, colors[xmlValue("bgSymbolColor", data)]) end
if(xmlValue("fg", data)~=nil)then self:setForeground(colors[xmlValue("fg", data)]) end
if(xmlValue("value", data)~=nil)then self:setValue(colors[xmlValue("value", data)]) end
if(xmlValue("visible", data)~=nil)then if(xmlValue("visible", data))then self:show() else self:hide() end end
@@ -121,10 +135,10 @@ return function(name)
if(xmlValue("anchor", data)~=nil)then self:setAnchor(xmlValue("anchor", data)) end
if(xmlValue("shadowColor", data)~=nil)then self:setShadow(colors[xmlValue("shadowColor", data)]) end
if(xmlValue("border", data)~=nil)then self:setBorder(colors[xmlValue("border", data)]) end
if(xmlValue("borderLeft", data)~=nil)then borderColors["left"] = xmlValue("borderLeft", data) end
if(xmlValue("borderTop", data)~=nil)then borderColors["top"] = xmlValue("borderTop", data) end
if(xmlValue("borderRight", data)~=nil)then borderColors["right"] = xmlValue("borderRight", data) end
if(xmlValue("borderBottom", data)~=nil)then borderColors["bottom"] = xmlValue("borderBottom", data) end
if(xmlValue("borderLeft", data)~=nil)then borderColors["left"] = colors[xmlValue("borderLeft", data)] end
if(xmlValue("borderTop", data)~=nil)then borderColors["top"] = colors[xmlValue("borderTop", data)] end
if(xmlValue("borderRight", data)~=nil)then borderColors["right"] = colors[xmlValue("borderRight", data)] end
if(xmlValue("borderBottom", data)~=nil)then borderColors["bottom"] = colors[xmlValue("borderBottom", data)] end
if(xmlValue("borderColor", data)~=nil)then self:setBorder(colors[xmlValue("borderColor", data)]) end
if(xmlValue("ignoreOffset", data)~=nil)then if(xmlValue("ignoreOffset", data))then self:ignoreOffset(true) end end
if(xmlValue("onClick", data)~=nil)then self:generateXMLEventFunction(self.onClick, xmlValue("onClick", data)) end
@@ -141,6 +155,9 @@ return function(name)
if(xmlValue("onEvent", data)~=nil)then self:generateXMLEventFunction(self.onEvent, xmlValue("onEvent", data)) end
if(xmlValue("onGetFocus", data)~=nil)then self:generateXMLEventFunction(self.onGetFocus, xmlValue("onGetFocus", data)) end
if(xmlValue("onLoseFocus", data)~=nil)then self:generateXMLEventFunction(self.onLoseFocus, xmlValue("onLoseFocus", data)) end
if(tex~=nil)then
self:setTexture(tex, mode, infPlay)
end
self:updateDraw()
return self
end,
@@ -1051,4 +1068,4 @@ return function(name)
object.__index = object
return object
end
end

View File

@@ -1,7 +1,7 @@
local curDir = fs.getDir(table.pack(...)[2]) or ""
local defaultPath = package.path
if not(packed)then
local defaultPath = package.path
local format = "path;/path/?.lua;/path/?/init.lua;"
local main = format:gsub("path", curDir)
@@ -14,4 +14,4 @@ end
local Basalt = require("main")
package.path = defaultPath
return Basalt
return Basalt

View File

@@ -1,7 +1,15 @@
local sub,floor = string.sub,math.floor
local sub,floor,rep = string.sub,math.floor,string.rep
local function loadNFPAsBimg(path)
return {[1]={{}, {}, paintutils.loadImage(path)}}, "bimg"
local bimg = {{}}
local nfp = fs.open(path, "r")
if(nfp~=nil)then
for line in nfp.readLine do
table.insert(bimg[1], {rep(" ",#line), rep(" ",#line), line})
end
nfp.close()
return bimg
end
end
local function loadNFP(path)
@@ -86,4 +94,4 @@ return {
resizeBIMG = resizeBIMG,
loadImageAsBimg = loadImageAsBimg,
}
}

View File

@@ -17,7 +17,6 @@ function process:new(path, window, newEnv, ...)
local env = setmetatable(newEnv, {__index=_ENV})
env.shell = shell
env.basaltProgram=true
env.arg = {[0]=path, table.unpack(args)}
env.require, env.package = newPackage(env, fs.getDir(pPath))
if(fs.exists(pPath))then
local file = fs.open(pPath, "r")
@@ -25,7 +24,7 @@ function process:new(path, window, newEnv, ...)
file.close()
local program = load(content, path, "bt", env)
if(program~=nil)then
return program()
return program(table.unpack(args))
end
end
end)
@@ -82,4 +81,4 @@ function process:start()
coroutine.resume(self.coroutine)
end
return process
return process

View File

@@ -1,14 +1,19 @@
local sub = string.sub
local sub,find,reverse = string.sub,string.find,string.reverse
local splitString = function(str, sep)
if sep == nil then
sep = "%s"
local function splitString(str, delimiter)
local result = {}
if str == "" or delimiter == "" then
return result
end
local start = 1
local delim_start, delim_end = find(str, delimiter, start)
while delim_start do
table.insert(result, sub(str, start, delim_start - 1))
start = delim_end + 1
delim_start, delim_end = find(str, delimiter, start)
end
local t={}
for v in string.gmatch(str, "([^"..sep.."]+)") do
table.insert(t, v)
end
return t
table.insert(result, sub(str, start))
return result
end
local relations = {[0] = {8, 4, 3, 6, 5}, {4, 14, 8, 7}, {6, 10, 8, 7}, {9, 11, 8, 0}, {1, 14, 8, 0}, {13, 12, 8, 0}, {2, 10, 8, 0}, {15, 8, 10, 11, 12, 14},
@@ -81,7 +86,7 @@ end
return {
getTextHorizontalAlign = function(text, width, textAlign, replaceChar)
text = string.sub(text, 1, width)
text = sub(text, 1, width)
local offset = width - string.len(text)
if (textAlign == "right") then
text = string.rep(replaceChar or " ", offset) .. text
@@ -132,22 +137,25 @@ splitString = splitString,
createText = function(str, width)
local uniqueLines = splitString(str, "\n")
local lines = {}
local result = {}
for k,v in pairs(uniqueLines)do
local line = ""
local words = splitString(v, " ")
for a,b in pairs(words)do
if(#line+#b <= width)then
line = line=="" and b or line.." "..b
if(a==#words)then table.insert(lines, line) end
if(#v==0)then table.insert(result, "") end
while #v > width do
local last_space = find(reverse(sub(v, 1, width)), " ")
if not last_space then
last_space = width
else
table.insert(lines, line)
line = b:sub(1,width)
if(a==#words)then table.insert(lines, line) end
last_space = width - last_space + 1
end
local line = sub(v, 1, last_space)
table.insert(result, line)
v = sub(v, last_space + 1)
end
if #v > 0 then
table.insert(result, v)
end
end
return lines
return result
end,
getValueFromXML = function(name, tab)

View File

@@ -68,7 +68,7 @@ return function(...)
local co = coroutine.create(f)
local ok, result = coroutine.resume(co, ...)
if(ok)then
table.insert(schedules, co)
table.insert(schedules, {co, result})
else
basaltError(result)
end
@@ -154,15 +154,26 @@ local bInstance = {
end
}
local function handleSchedules(event, p1, p2, p3, p4)
local function handleSchedules(event, ...)
if(#schedules>0)then
local finished = {}
for n=1,#schedules do
if(schedules[n]~=nil)then
if (coroutine.status(schedules[n]) == "suspended")then
local ok, result = coroutine.resume(schedules[n], event, p1, p2, p3, p4)
if not(ok)then
basaltError(result)
if (coroutine.status(schedules[n][1]) == "suspended")then
if(schedules[n][2]~=nil)then
if(schedules[n][2]==event)then
local ok, result = coroutine.resume(schedules[n][1], event, ...)
schedules[n][2] = result
if not(ok)then
basaltError(result)
end
end
else
local ok, result = coroutine.resume(schedules[n][1], event, ...)
schedules[n][2] = result
if not(ok)then
basaltError(result)
end
end
else
table.insert(finished, n)
@@ -240,21 +251,23 @@ local function basaltUpdateEvent(event, ...)
local mouseEvent = mouseEvents[event]
if(mouseEvent~=nil)then
mouseEvent(mainFrame, ...)
handleSchedules(event, ...)
drawFrames()
return
end
end
if(event == "monitor_touch") then
if(monFrames[p1]~=nil)then
monFrames[p1]:mouseHandler(1, a[2], a[3], true)
activeFrame = monFrames[p1]
if(monFrames[a[1]]~=nil)then
monFrames[a[1]]:mouseHandler(1, a[2], a[3], true)
activeFrame = monFrames[a[1]]
end
if(count(monGroups)>0)then
for k,v in pairs(monGroups)do
v[1]:mouseHandler(1, a[2], a[3], true, a[1])
end
end
handleSchedules(event, ...)
drawFrames()
return
end
@@ -273,6 +286,7 @@ local function basaltUpdateEvent(event, ...)
activeKey[a[1]] = false
end
keyEvent(activeFrame, ...)
handleSchedules(event, ...)
drawFrames()
return
end
@@ -422,6 +436,10 @@ basalt = {
projectDirectory = dir
end,
forceRenderUpdate = function()
drawFrames()
end,
debug = function(...)
local args = { ... }
if(mainFrame==nil)then print(...) return end

View File

@@ -38,7 +38,7 @@ return function(name)
end;
setText = function(self, text)
base:setValue(text)
base:setValue(tostring(text))
self:updateDraw()
return self
end;

View File

@@ -124,7 +124,7 @@ return function(name)
return dropdownW, dropdownH
end,
mouseHandler = function(self, button, x, y)
mouseHandler = function(self, button, x, y, touch)
if (isOpened) then
local obx, oby = self:getAbsolutePosition(self:getAnchorPosition())
if(button==1)then
@@ -135,6 +135,9 @@ return function(name)
self:setValue(list[n + yOffset])
self:updateDraw()
local val = self:getEventSystem():sendEvent("mouse_click", self, "mouse_click", dir, x, y)
if(touch)then
self:mouseUpHandler(button, x, y)
end
if(val==false)then return val end
return true
end

View File

@@ -23,17 +23,17 @@ return function(name)
local p = {}
for k,v in pairs(colors)do
if(type(v)=="number")then
p[k] = {term.nativePaletteColor(v)}
p[v] = {term.nativePaletteColor(v)}
end
end
if(originalImage.palette~=nil)then
for k,v in pairs(originalImage.palette)do
p[k] = tonumber(v)
p[2^k] = v
end
end
if(originalImage[id]~=nil)and(originalImage[id].palette~=nil)then
for k,v in pairs(originalImage[id].palette)do
p[k] = tonumber(v)
p[2^k] = v
end
end
return p

View File

@@ -705,50 +705,55 @@ return function(name, parent)
end
end
end,
customEventHandler = function(self, event, ...)
base.customEventHandler(self, event, ...)
if (curProcess == nil) then
return
end
if(event=="basalt_resize")then
local w, h = pWindow.getSize()
local pW, pH = self:getSize()
if(w~=pW)or(h~=pH)then
pWindow.basalt_resize(pW, pH)
if not (curProcess:isDead()) then
resumeProcess(self, "term_resize")
end
end
pWindow.basalt_reposition(self:getAnchorPosition())
end
end,
eventHandler = function(self, event, p1, p2, p3, p4)
if(base.eventHandler(self, event, p1, p2, p3, p4))then
if (curProcess == nil) then
return
end
if(event=="dynamicValueEvent")then
local w, h = pWindow.getSize()
local pW, pH = self:getSize()
if(w~=pW)or(h~=pH)then
pWindow.basalt_resize(pW, pH)
if not (curProcess:isDead()) then
resumeProcess(self, "term_resize")
end
base.eventHandler(self, event, p1, p2, p3, p4)
if (curProcess == nil) then
return
end
if not (curProcess:isDead()) then
if not (paused) then
if(event ~= "terminate") then
resumeProcess(self, event, p1, p2, p3, p4)
end
pWindow.basalt_reposition(self:getAnchorPosition())
end
if not (curProcess:isDead()) then
if not (paused) then
if(event ~= "terminate") then
resumeProcess(self, event, p1, p2, p3, p4)
end
if (self:isFocused()) then
local obx, oby = self:getAnchorPosition()
local xCur, yCur = pWindow.getCursorPos()
if (self.parent ~= nil) then
local w,h = self:getSize()
if (obx + xCur - 1 >= 1 and obx + xCur - 1 <= obx + w - 1 and yCur + oby - 1 >= 1 and yCur + oby - 1 <= oby + h - 1) then
self.parent:setCursor(pWindow.getCursorBlink(), obx + xCur - 1, yCur + oby - 1, pWindow.getTextColor())
end
if (self:isFocused()) then
local obx, oby = self:getAnchorPosition()
local xCur, yCur = pWindow.getCursorPos()
if (self.parent ~= nil) then
local w,h = self:getSize()
if (obx + xCur - 1 >= 1 and obx + xCur - 1 <= obx + w - 1 and yCur + oby - 1 >= 1 and yCur + oby - 1 <= oby + h - 1) then
self.parent:setCursor(pWindow.getCursorBlink(), obx + xCur - 1, yCur + oby - 1, pWindow.getTextColor())
end
end
if (event == "terminate") then
resumeProcess(self, event)
self.parent:setCursor(false)
return true
end
if (event == "terminate") then
resumeProcess(self, event)
self.parent:setCursor(false)
return true
end
else
table.insert(queuedEvent, { event = event, args = { p1, p2, p3, p4 } })
end
else
table.insert(queuedEvent, { event = event, args = { p1, p2, p3, p4 } })
end
return false
end
end,
@@ -800,4 +805,4 @@ return function(name, parent)
}
return setmetatable(object, base)
end
end

View File

@@ -10,7 +10,7 @@ return function(name)
local objectType = "Textfield"
local hIndex, wIndex, textX, textY = 1, 1, 1, 1
local lines = { " " }
local lines = { "" }
local bgLines = { "" }
local fgLines = { "" }
local keyWords = { }
@@ -216,7 +216,7 @@ return function(name)
end;
clear = function(self)
lines = {" "}
lines = {""}
bgLines = {""}
fgLines = {""}
startSelX,endSelX,startSelY,endSelY = nil,nil,nil,nil
@@ -299,7 +299,7 @@ return function(name)
table.remove(bgLines, index or #bgLines)
table.remove(fgLines, index or #fgLines)
else
lines = {" "}
lines = {""}
bgLines = {""}
fgLines = {""}
end
@@ -666,25 +666,30 @@ return function(name)
end,
eventHandler = function(self, event, paste, p2, p3, p4)
if(base.eventHandler(self, event, paste, p2, p3, p4))then
if(event=="paste")then
if(self:isFocused())then
local w, h = self:getSize()
lines[textY] = lines[textY]:sub(1, textX - 1) .. paste .. lines[textY]:sub(textX, lines[textY]:len())
fgLines[textY] = fgLines[textY]:sub(1, textX - 1) .. tHex[self.fgColor]:rep(paste:len()) .. fgLines[textY]:sub(textX, fgLines[textY]:len())
bgLines[textY] = bgLines[textY]:sub(1, textX - 1) .. tHex[self.bgColor]:rep(paste:len()) .. bgLines[textY]:sub(textX, bgLines[textY]:len())
textX = textX + paste:len()
if (textX >= w + wIndex) then
wIndex = (textX+1)-w
end
local anchx, anchy = self:getAnchorPosition()
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
updateColors(self)
self:updateDraw()
base.eventHandler(self, event, paste, p2, p3, p4)
if(event=="paste")then
if(self:isFocused())then
local w, h = self:getSize()
lines[textY] = lines[textY]:sub(1, textX - 1) .. paste .. lines[textY]:sub(textX, lines[textY]:len())
fgLines[textY] = fgLines[textY]:sub(1, textX - 1) .. tHex[self.fgColor]:rep(paste:len()) .. fgLines[textY]:sub(textX, fgLines[textY]:len())
bgLines[textY] = bgLines[textY]:sub(1, textX - 1) .. tHex[self.bgColor]:rep(paste:len()) .. bgLines[textY]:sub(textX, bgLines[textY]:len())
textX = textX + paste:len()
if (textX >= w + wIndex) then
wIndex = (textX+1)-w
end
local anchx, anchy = self:getAnchorPosition()
self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
updateColors(self)
self:updateDraw()
end
end
end,
setSelectionColor = function(self, bg, fg)
selectionBG = bg or selectionBG
selectionFG = fg or selectionFG
return self
end,
draw = function(self)
if (base.draw(self)) then
@@ -714,6 +719,7 @@ return function(name)
self.parent:setBG(obx, oby + n - 1, bg)
self.parent:setFG(obx, oby + n - 1, fg)
end
--[[
if(startSelX~=nil)and(endSelX~=nil)and(startSelY~=nil)and(endSelY~=nil)then
local sx,ex,sy,ey = getSelectionCoordinates(self)
for n=sy,ey do
@@ -731,7 +737,7 @@ return function(name)
self.parent:setBG(obx + xOffset, oby + n - 1, rep(tHex[selectionBG], line))
self.parent:setFG(obx + xOffset, oby + n - 1, rep(tHex[selectionFG], line))
end
end
end]]
if(self:isFocused())then
local anchx, anchy = self:getAnchorPosition()
--self.parent:setCursor(true, anchx + textX - wIndex, anchy + textY - hIndex, self.fgColor)
@@ -756,4 +762,4 @@ return function(name)
}
return setmetatable(object, base)
end
end

View File

@@ -1,3 +1,5 @@
# How-To
After downloading the project you can finally start creating your own program and use basalt. The first thing you want to use in your program is always:
```lua
@@ -24,7 +26,7 @@ local basalt = require("basalt") --> Load the basalt framework into the variable
--> Now we want to create a base frame, we call the variable "main" - by default everything you create is visible. (you don't need to use :show())
local main = basalt.createFrame()
local button = mainFrame:addButton() --> Here we add our first button
local button = main:addButton() --> Here we add our first button
button:setPosition(4, 4) -- of course we want to change the default position of our button
button:setSize(16, 3) -- and the default size.
button:setText("Click me!") --> This method displays what the text of our button should look like

View File

@@ -243,6 +243,7 @@ function installer.generateWebVersion(file, version)
if(request~=nil)then
if(fs.exists(file))then
fs.delete(file)
end
local f = fs.open(file, "w")
local link = "https://basalt.madefor.cc/versions/"..version
local content = 'local request = http.get("'..link..'", _G._GIT_API_KEY and {Authorization = "token ".._G._GIT_API_KEY})\n'
@@ -257,7 +258,6 @@ end
f.write(content)
f.close()
printStatus("Web version successfully downloaded!")
end
else
error("Version doesn't exist!")
end
@@ -367,9 +367,9 @@ if(#args>0)then
installer.downloadProject(args[2] or "basalt", args[3] or "master", args[4]~=nil and installer.createIgnoreList(args[4]) or nil)
elseif(string.lower(args[1])=="web")then
installer.generateWebVersion(args[3] or "basaltWeb.lua", args[2] or "latest.lua")
elseif(string.lower(args[1])=="file")then
elseif(string.lower(args[1])=="file")or(string.lower(args[1])=="release")then
installer.download("https://basalt.madefor.cc/versions/"..args[2] or "latest.lua", args[3] or "basalt.lua")
end
end
return installer
return installer

View File

@@ -1,17 +1,22 @@
## setTheme
Sets the default theme of that frame children objects always try to get the theme of its parent frame, if it does not exist it goes to its parent parent frame, and so on until it reaches the basalt managers theme - which is sotred in theme.lua (Please checkout [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for how it could look like.
#### Parameters:
Sets the default theme, of that frame children objects always try to get the theme of its parent frame, if it does not exist it goes to its parent parent frame, and so on until it reaches the basalt manager's theme - which is stored in theme.lua (Please checkout [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for how it could look like.
#### Parameters:
1. `table` theme layout look into [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for a example
#### Returns:
1. `frame` The frame being used
#### Usage:
* Creates a new base frame and adds a new theme which only changes the default color of buttons.
- Creates a new base frame and adds a new theme which only changes the default color of buttons.
```lua
local myFrame = basalt.createFrame():setTheme({
ButtonBG = colors.yellow,
ButtonText = colors.red,
})
```
```

View File

@@ -1,12 +1,18 @@
The image object is for adding more advanced backgrounds.
It also provides a :shrink() function, where you can shrink the images to smaller ones. This functionallity is fully provided by the blittle library created by Bomb Bloke. I did not ask for permission to add it into the framework. If the creator wants me to remove the blittle part, just text me on discord!
The image object is still not done. in the future i will provide more image formats.
The image object is for adding more advanced backgrounds to your interface. It supports the loading of .nfp and .bimg images.
[Object](objects/Object.md) methods also apply for images.
| | |
|---|---|
|[loadImage](objects/Image/loadImage.md)|Adds a new object
|[shrink](objects/Image/shrink.md)|Sets the top bar text and colors - deprecated
|[loadImage](objects/Image/loadImage.md)|Loads an image from the specified file path
|[setImage](objects/Image/setImage.md)|Set's a new image
|[usePalette](objects/Image/usePalette.md)|Changes the used palette to the image prefered palette
|[play](objects/Image/play.md)|Plays an animated image
|[selectFrame](objects/Image/selectFrame.md)|Selects a specific frame in an animated image
|[getMetadata](objects/Image/getMetadata.md)|Returns the metadata of the image
|[getImageSize](objects/Image/getImageSize.md)|Returns the width and height of the image
|[resizeImage](objects/Image/resizeImage.md)|Resizes the image to the specified dimensions
# About Bimg
Bimg is a custom image format that can be used in place of .nfp, it is a table which can store multiple frames and metadata. The frames can store text, background and foreground, which makes it possible to create any image you'd like. The image format is made by people from the Minecraft Computercraft Mods - Discord. Here's a Github page which explains how the Bimg format works: [bimg](https://github.com/SkyTheCodeMaster/bimg)

View File

@@ -0,0 +1,6 @@
## getImageSize
Returns the current image size
#### Returns:
1. `number` width
2. `number` height

View File

@@ -0,0 +1,9 @@
## getMetadata
Returns the metadata set in the image
#### Parameter:
1. `string` the metadata key (for example: title, description, author, creator, data, width, height,...)
#### Returns:
1. `any` metadata value

View File

@@ -1,18 +1,23 @@
## loadImage
loads a default .nfp file into the object.
This method is used to load an image file into the image object.
#### Parameters:
1. `string` the absolute file path
1. `path` the absolute file path
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a default image and loads a test.nfp file
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.nfp")
```
```xml
<image path="test.nfp" />
```
```

View File

@@ -0,0 +1,10 @@
## play
Plays a bimg animation. This can only work if the bimg has more than 1 frame.
#### Parameters:
1. `boolean` If the image animation should play
#### Returns:
1. `object` The object in use

View File

@@ -0,0 +1,19 @@
## resizeImage
This method is used to resize a bimg image. It takes two parameters: the new width, and the new height. It is important to note that resizing images can result in a loss of quality, as the original pixel data is being transformed and resampled to fit the new dimensions. This is especially noticeable when increasing the size of an image, as new pixels must be generated to fill in the gaps. As a result, it is generally recommended to use the original image at its full size whenever possible, rather than resizing it.
#### Parameters:
1. `number` the new width
2. `number` the new height
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a new image object, loads the image and changes it's size.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg"):resizeImage(40, 20)
```

View File

@@ -0,0 +1,19 @@
## selectFrame
The selectFrame method allows you to change the current frame of an image object. It takes a single parameter, the index of the frame you want to display.
#### Parameters:
1. `number` the frame index
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a default image and loads a test.nfp file
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg"):selectFrame(2)
```

View File

@@ -0,0 +1,23 @@
## setImage
Sets a new image
#### Parameter:
1. `table` A table in bimg or nfp format.
1. `string` The format in which the image should be loaded (nfp or bimg)
#### Usage:
* Creates a default image and loads a test.nfp file
```lua
local mainFrame = basalt.createFrame()
local bimg = {
[1] = {
{"Hello", "fffff", "33333"}
}
}
local aImage = mainFrame:addImage():setImage(bimg)
```

View File

@@ -0,0 +1,11 @@
## usePalette
Changes the palette colors of the image, if the bimg image has palette metadata.
#### Parameter:
1. `boolean` if the image should change the palette
#### Returns:
1. `object` The object in use

File diff suppressed because one or more lines are too long

3083
docs/versions/basalt.lua Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long