diff --git a/config/config.lua b/config/config.lua
deleted file mode 100644
index 585712d..0000000
--- a/config/config.lua
+++ /dev/null
@@ -1,8 +0,0 @@
-return {
- payment = {
- paymentType = "name",
- key = "jhfuiojdnhiotujnhoifdjhydtfydfty-345",
- keyFormat = "pkey",
- name = "kristname"
- }
-};
diff --git a/config/products.lua b/config/products.lua
deleted file mode 100644
index 8392fdc..0000000
--- a/config/products.lua
+++ /dev/null
@@ -1,20 +0,0 @@
-local products = {
- {
- displayName = "Dirt",
- type = "item",
- price = 2,
- params = {
- amount = 203,
- id = "minecraft:dirt"
- }
- },
- {
- displayName = "MiloX",
- type = "link",
- price = 20,
- params = {
- link = "https://devbin.dev/8f3wy"
- }
- }
-};
-return products;
diff --git a/config/services.lua b/config/services.lua
deleted file mode 100644
index 39f2713..0000000
--- a/config/services.lua
+++ /dev/null
@@ -1,15 +0,0 @@
-local services = {
- item = {
- chests = {
- {
- first = "minecraft:chest_",
- ids = {
- 193,
- 195,
- "199->205"
- }
- }
- }
- }
-};
-return services;
diff --git a/data/index.xml b/data/index.xml
new file mode 100644
index 0000000..2a7e1ce
--- /dev/null
+++ b/data/index.xml
@@ -0,0 +1,8 @@
+
+
+ - Home
+ - Items
+
+
+ >
+
\ No newline at end of file
diff --git a/data/pages/home.xml b/data/pages/home.xml
new file mode 100644
index 0000000..18f81fb
--- /dev/null
+++ b/data/pages/home.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/data/pages/items.xml b/data/pages/items.xml
new file mode 100644
index 0000000..d8d6875
--- /dev/null
+++ b/data/pages/items.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/data/products.lua b/data/products.lua
new file mode 100644
index 0000000..b0d94b8
--- /dev/null
+++ b/data/products.lua
@@ -0,0 +1,32 @@
+local products = {
+ {
+ displayName = "Dirt",
+ categorys={"Items"},
+ type = "item",
+ price = 2,
+ params = {
+ amount = 203,
+ id = "minecraft:dirt"
+ }
+ },
+ {
+ displayName = "Diamond",
+ categorys={"Items","RARE"},
+ type = "item",
+ price = 14,
+ params = {
+ amount = 24,
+ id = "minecraft:diamond"
+ }
+ },
+ {
+ displayName = "MiloX",
+ categorys={"Files"},
+ type = "link",
+ price = 20,
+ params = {
+ link = "https://devbin.dev/8f3wy"
+ }
+ }
+};
+return products;
diff --git a/data/services.lua b/data/services.lua
new file mode 100644
index 0000000..0b4a26b
--- /dev/null
+++ b/data/services.lua
@@ -0,0 +1,15 @@
+local services = {
+ item = {
+ chests = {
+ {
+ first = "minecraft:chest_",
+ ids = {
+ 193,
+ 195,
+ "199->205"
+ }
+ }
+ }
+ }
+};
+return services;
diff --git a/src/init.lua b/src/init.lua
index 8aea740..18c2119 100644
--- a/src/init.lua
+++ b/src/init.lua
@@ -1,12 +1,13 @@
-- make a copy of package.path
local old_path = package.path
-local sPath = fs.getDir(shell.getRunningProgram())
-local sData = fs.combine(sPath,"data")
+local sSrc = fs.getDir(shell.getRunningProgram())
+local sRoot = fs.combine(sSrc,"..")
+local sData = fs.combine(sRoot,"data")
local basalt = require("basalt")
local ctx
package.path = string.format(
- "/%s/?.lua;/rom/modules/main/?.lua", sPath
+ "/%s/?.lua;/rom/modules/main/?.lua", sSrc
)
local function init(...)
ctx = {gui={},pages={},current=1,scroll=0,redraw=true}
@@ -19,17 +20,8 @@
f.close()
end
- -- load colors
- local f = fs.open(fs.combine(sData,"color.table"), 'r')
- local content = f.readAll()
- f.close()
+ -- load products
- local col = {white=0x1,orange=0x2,magenta=0x4,lightBlue=0x8,yellow=0x10,lime=0x20,pink=0x40,grey=0x80,lightGrey=0x100,cyan=0x200,purple=0x400,blue=0x800,brown=0x1000,green=0x2000,red=0x4000,black=0x8000}
- local inferiorcol=col; inferiorcol.gray=col.grey; inferiorcol.lightGray=col.lightGrey
- local b,colors = pcall( load("return "..content,"","t",{colours=col,colors=inferiorcol}) )
- if type(colors) == "table" and b then
- ctx.color = colors
- end
return ctx
end
@@ -42,7 +34,7 @@
printError(err)
end)
--- MAIN
+-- Create basalt index page
local base = basalt.createFrame()
:setTheme({
FrameBG = colors.black,
@@ -53,19 +45,44 @@
ListBG = colors.gray,
ListText = colors.black,
LabelBG = colors.black,
- LabelText = colors.white
+ LabelText = colors.white,
+ ScrollbarText = colors.black,
+ ScrollbarBG = colors.gray,
+ ScrollbarSymbolColor = colors.lightGray
})
:addLayout(fs.combine(sData,"index.xml"))
-local displayPage =base:getDeepObject("main-content")
+---Saves the current proucts states into the file
+---and loads them into the interface.
+local function updateProducts()
+
+end
+
local sCurPage = ""
+-- MAIN LOOP
parallel.waitForAny(
basalt.autoUpdate,
function()
+ local scrollbar = base:getDeepObject("main-scroll")
+ local menubar = base:getDeepObject("main-menubar")
+ local displayPage = base:getDeepObject("main-content")
+
+ -- Background
+ local bg = ""
+ local updateContent = true
+ local w,h = term.getSize()
+ for y=1,h do
+ bg = bg..('\127'):rep(w-1)..' '
+ end
+ bg = displayPage:addLabel()
+ :setBackground(colors.black)
+ :setForeground(colors.gray)
+ :setText(bg)
+ :setSize(w-1,h-1)
+ :setPosition(1,1)
+
while true do
- local scrollbar = base:getDeepObject("main-scroll")
- local menubar = base:getDeepObject("main-menubar")
-
+ -- Change pages
local tmpPage = menubar:getItem(menubar:getItemIndex()).text
if tmpPage ~= sCurPage then
sCurPage = tmpPage
@@ -76,6 +93,14 @@
displayPage:addLayoutFromString(ctx.pages[sCurPage:lower()..".xml"])
end
+ -- Update products
+ if updateContent then
+
+ updateContent = false
+ end
+
+ -- Scrolling
+ bg:setPosition(1, scrollbar:getIndex()-1)
displayPage:setOffset(0, scrollbar:getIndex()-1)
sleep()
end