diff --git a/.gitignore b/.gitignore index 5838145..c70b20f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .containerizer /Launcher/build -/Software/build \ No newline at end of file +/Software/build +/Repos/build \ No newline at end of file diff --git a/Repos/build.lua b/Repos/build.lua new file mode 100644 index 0000000..4b64437 --- /dev/null +++ b/Repos/build.lua @@ -0,0 +1,25 @@ +--Default build.lua Script + +local appid = "org.ruffles.repos" + +local project_name = "Repos" + + +local package_data = build.optimize(build.package("src")) + +build.writePackage(package_data,"build/"..appid) + +local meta = { + perms = { + repo = true, + network = false, + app = false, + http = false, + }, + author = "Ruffles", + name = project_name, + appid = appid, +} + +build.writeMeta(meta,"build/"..project_name..".meta") +build.merge("build/"..appid,"build/"..project_name..".meta","build/"..project_name..".app") diff --git a/Repos/src/startup.lua b/Repos/src/startup.lua new file mode 100644 index 0000000..b48892a --- /dev/null +++ b/Repos/src/startup.lua @@ -0,0 +1,66 @@ +local w,h = term.getSize() +local scroll = 0 +local selected = 1 +local do_render = true +local map_to_id = {} +local function render() + while true do + if do_render then + term.setBackgroundColor(colors.black) + term.setTextColor(colors.white) + term.clear() + local repos = repo.getRepos() + local ypos = 1 + map_to_id = {} + for k,v in pairs(repos) do + map_to_id[ypos] = k + term.setCursorPos(1,ypos+scroll) + if ypos == selected then + term.setBackgroundColor(colors.white) + term.setTextColor(colors.black) + else + term.setBackgroundColor(colors.black) + term.setTextColor(colors.white) + end + term.clearLine() + term.write(tostring(k).." "..tostring(v)) + ypos = ypos + 1 + end + end + sleep(1/20) + end +end + +local function input() + while true do + local event = {os.pullEvent()} + if event[1] == "mouse_scroll" then + scroll = math.max(math.min(0,scroll-event[2]),-math.max(0,#map_to_id-1)) + elseif event[1] == "key_up" then + if event[2] == keys["a"] then + do_render = false + term.setBackgroundColor(colors.lightGray) + term.setCursorPos(1,(h/2)+1) + term.clearLine() + term.setCursorPos(1,(h/2)-1) + term.clearLine() + term.setBackgroundColor(colors.gray) + term.setCursorPos(1,h/2) + term.clearLine() + local id = tonumber(read()) + if id and id >= 0 then + repo.addRepo(id) + end + term.setBackgroundColor(colors.black) + do_render = true + elseif event[2] == keys["d"] then + if map_to_id[selected] then + repo.rmRepo(map_to_id[selected]) + end + end + elseif event[1] == "mouse_click" then + selected = event[4]-scroll + end + end +end +parallel.waitForAny(input,render) \ No newline at end of file