Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local api = { LoadOrder = 99 }
- function api.Build()
- local App = { Apps = data:load(".apps"), Data = data("/nekOS/Apps") }
- App.__index = App
- function App:__call()
- local app = { Running = false }
- app.__index = app
- function app:__call(id, ...)
- local inst = setmetatable({ Id = id, Path = "/nekOS/Apps/"..id, EventHandler = events(), Data = data("/nekOS/AppData/"..id) }, self)
- inst:connect("terminate", inst.stop)
- inst:constructor(...)
- return inst
- end
- function app:start() self.Running = true while self.Running do self:draw() self.EventHandler() end end
- function app:constructor() end
- function app:draw() end
- function app:stop() self.Running = false self:emit("stop") end
- function app:emit(e,...) return self.EventHandler:emit(e,...) end
- function app:connect(e,c,t) return self.EventHandler:connect(e,function(...) c(t or self,...) end) end
- function app:disconnect(c) return self.EventHandler:disconnect(c) end
- function app:disconnectAll(e) return self.EventHandler:disconnectAll(e) end
- function app:load(p) return self.Data:load(p) end
- function app:save(p,d) return self.Data:save(p,d) end
- function app:require(p) return App.Data:require(self.Id.."/"..p) end
- function app:list(p,r) return path.list(self.Path.."/"..p,r) end
- function app:setInterval(c,t,...) local r={...} local i=os.startTimer(t) local e=self:connect("timer", function(a,f) if f ~= i then return end c(a,table.unpack(r)) i=os.startTimer(t) end) return {Token=i,Conn=e} end
- function app:clearInterval(i) os.cancelTimer(i.Token) self:disconnect(i.Conn) end
- return setmetatable(app, app)
- end
- function App:load(p) return self.Data:load(p) end
- function App:save(p,d) return self.Data:save(p,d) end
- function App:require(p) return self.Data:require(p) end
- function App:getApps() local a = {} for i,f in ipairs(path.list("/nekOS/Apps",false)) do local n=string.match(fs.getName(f),"([^\.]+)") local m=self:load(f) a[n]=m end return a end
- function App:manifest(id)
- return self:load(id..".manifest")
- end
- function App:update(id)
- end
- function App:execute(id, ...)
- self.Apps()
- if not self.Apps[id] then return false,"Application not found." end
- local m=self:load(id..".manifest")
- if not m.Local then
- s,e=self:update(id)
- if not s then return false,e end
- m()
- end
- local app=self:require(id.."/"..m.Entry)(id,...)
- app:start()
- end
- function App:install(id)
- self.Apps()
- end
- App.Apps()
- local apps = App:getApps()
- for k,v in pairs(apps) do if not App.Apps[k] then App.Apps[k] = {1,2,-1,false} end App.Apps[k][4]=v.Hidden or false end
- App.Apps:save()
- return setmetatable(App, App)
- end
- return api
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement