Most of the things are now working.. some are not
updated windowSystem
local window=nil;
function createWindow(title,x,y,w,h,closeable,text)
window=
{
titlew=title;
x=x;
y=y;
W=w;
H=h;
ca=closeable;
text=text;
}
return window
end
function drawWindow(windowp)
term.setCursorPos(window.x,window.y)
term.setBackgroundColor(colors.lightGray)
for i=0, windowp.W do
term.setCursorPos(windowp.x+i,windowp.y)
print(" ")
term.setCursorPos(windowp.x+i,windowp.y+windowp.H)
print(" ")
end
for j=0, windowp.H do
term.setCursorPos(windowp.x,windowp.y+j)
print(" ")
term.setCursorPos(windowp.x+windowp.W,windowp.y+j)
print(" ")
end
term.setCursorPos(windowp.x+windowp.W/2-string.len(windowp.titlew)/2,windowp.y)
term.setTextColor(colors.gray)
print(windowp.titlew)
if(windowp.ca) then
term.setBackgroundColor(colors.red)
term.setCursorPos(windowp.x+windowp.W+1,windowp.y)
print("X")
term.setBackgroundColor(colors.white)
end
term.setCursorPos(windowp.x+2,windowp.y+2)
for i in string.gmatch(windowp.text,"[^\n]+") do
print(i)
x,y=term.getCursorPos()
if i== " " then
term.setCursorPos(windowp.x+1,y)
end
end
end
the kernel part that manages routnes(this might be what is wrong)
programCache={}
routineCache={}
local evt={}
--table.insert(programCache,function() shell.run("OSCore/desktop")end)
local routine=nil;
os.queueEvent("abc", 6, "meow")
function startCoroutines()
for i=1, #programCache,1 do
routine=coroutine.create(programCache[i])
table.insert(routineCache,routine)
ok, err=coroutine.resume(routine,unpack(evt))
end
end
function updateCoroutines()
for i=1, #routineCache,1 do
if coroutine.status(routineCache[i])=="suspended" then
ok, err=coroutine.resume(routineCache[i],unpack(evt))
end
end
end
function addCoroutine(functionD)
table.insert(programCache,functionD)
startCoroutines()
updateCoroutines()
end
function removeCoroutine(functionD)
for k,v in ipairs(programCache) do
if v==functionD then
table.remove(programCache,k)
end
end
end
if loggedStatus then
addCoroutine(function() shell.run("OSCore/desktop")end)
end
while true do
evt={os.pullEvent()}
updateCoroutines()
end
desktop coroutine
os.loadAPI("Apis/DesignUtil")
os.loadAPI("Apis/AccountSytem")
os.loadAPI("Apis/windowSystem")
DesignUtil.setDesign("whiteLightGray")
local background,topBar =DesignUtil.getDesign()
local showOS1Menu = false;
term.setTextColor(colors.gray)
local OS1MenuB={
text="O1|";
x=1;
y=1;
W=3;
H=1;
}
local OS1MenuSelections=
{
s1Text="About this device";
s1X=1;
s1Y=2;
s1W=17;
s1H=1;
s2Text="Software update ";
s2X=1;
s2Y=3;
s2W=17;
s2H=1;
s3Text="Restart device ";
s3X=1;
s3Y=4;
s3W=17;
s3H=1;
s4Text="Shut down ";
s4X=1;
s4Y=5;
s4W=17;
s4H=1;
}
function registerClickEvent(x,y)
if x >=OS1MenuB.x and x <=OS1MenuB.x+OS1MenuB.W-1 and y >=OS1MenuB.y and y <=OS1MenuB.y+OS1MenuB.H-1 then
if showOS1Menu then
showOS1Menu=false
else
showOS1Menu=true
end
end
if x >=OS1MenuSelections.s1X and x <=OS1MenuSelections.s1X+OS1MenuSelections.s1W-1 and y >=OS1MenuSelections.s1Y and y <=OS1MenuSelections.s1Y+OS1MenuSelections.s1H-1 then
addCoroutine(function() shell.run("OSCore/aboutW.app")end)
print("added routine")
end
end
function printOS1Menu()
if showOS1Menu then
term.setBackgroundColor(colors.lightGray)
term.setCursorPos(OS1MenuSelections.s1X,OS1MenuSelections.s1Y)
print(OS1MenuSelections.s1Text)
term.setCursorPos(OS1MenuSelections.s2X,OS1MenuSelections.s2Y)
print(OS1MenuSelections.s2Text)
term.setCursorPos(OS1MenuSelections.s3X,OS1MenuSelections.s3Y)
print(OS1MenuSelections.s3Text)
term.setCursorPos(OS1MenuSelections.s3X,OS1MenuSelections.s3Y)
print(OS1MenuSelections.s3Text)
term.setCursorPos(OS1MenuSelections.s4X,OS1MenuSelections.s4Y)
print(OS1MenuSelections.s4Text)
end
end
while true do
local e = {os.pullEvent()}
paintutils.drawImage(background,1,1)
paintutils.drawImage(topBar,1,1)
term.setCursorPos(OS1MenuB.x,OS1MenuB.y)
term.setBackgroundColor(colors.lightGray)
print(OS1MenuB.text)
if e[1]=="mouse_click" then
registerClickEvent(e[3],e[4])
printOS1Menu()
end
end
and aboutW.app coroutine
os.loadAPI("Apis/windowSystem")
local afData = {}
local x,y=0;
function exit()
end
local SysU=
{
text="Software update";
x=22;
y=7;
W=15;
H=1;
}
function loadAbout()
local abF=fs.open("data/osInfo","r")
local line = abF.readLine()
repeat
table.insert(afData,line) -- Puts the value of the current line into the table we have.
line = abF.readLine() -- read the next line
until line == nil -- readLine() returns nil when the end of the file is reached.
abF.close() -- Close up the file ready for use again.
end
loadAbout()
function registerClick(xPos,yPos)
shell.run("OSCore/loginUtil")
if xPos==window.x+window.W+1 and yPos==window.y then
exit()
end
if xPos >= SysU.x and xPos <= SysU.x + SysU.W - 1 and yPos >= SysU.y and yPos <= SysU.y + SysU.H then
shell.run("OSCore/updateManager.app")
end
end
local window=windowSystem.createWindow("About this Device",21,3,18,13,true,"Version:"..afData[1].." \n \n \n System: "..afData[2])
while true do
local e = {os.pullEvent()}
windowSystem.drawWindow(window)
term.setBackgroundColor(colors.white)
if e[1]=="mouse_click" then
registerClick(e[3],e[4])
end
end
heres what Id still need to make working
- The menu in desktop wont close if I click outside of it
- When I add the aboutW.app coroutine, the said routine starts to flicker onscreen, displays errors: No such program and AboutW:37 attemp to index ? (a nil value) (but I pass in the x and y, dont I?)
- After a short while: TOO LONG WITHOUT YIELDING can be briefly seen, comsole spills out java.lang.ThreadDeath
How can a I make those problems dissapear aswell?? Should I load the apis inside the handler aswell, not separately in each coroutine???