mirror of
https://github.com/kepler155c/opus
synced 2025-10-11 22:07:43 +00:00
format and installer branches
This commit is contained in:
129
startup
129
startup
@@ -4,67 +4,67 @@ local settings = _G.settings
|
||||
local term = _G.term
|
||||
|
||||
local bootOptions = {
|
||||
{ prompt = os.version() },
|
||||
{ prompt = 'Opus' , args = { '/sys/boot/opus.boot' } },
|
||||
{ prompt = 'Opus Shell' , args = { '/sys/boot/opus.boot', 'sys/apps/shell' } },
|
||||
{ prompt = os.version() },
|
||||
{ prompt = 'Opus' , args = { '/sys/boot/opus.boot' } },
|
||||
{ prompt = 'Opus Shell' , args = { '/sys/boot/opus.boot', 'sys/apps/shell' } },
|
||||
}
|
||||
local bootOption = 2
|
||||
if settings then
|
||||
settings.load('.settings')
|
||||
bootOption = tonumber(settings.get('opus.boot_option') or 2) or 2
|
||||
settings.load('.settings')
|
||||
bootOption = tonumber(settings.get('opus.boot_option') or 2) or 2
|
||||
end
|
||||
|
||||
local function startupMenu()
|
||||
while true do
|
||||
term.clear()
|
||||
term.setCursorPos(1, 1)
|
||||
print('Select startup mode')
|
||||
print()
|
||||
for k,option in pairs(bootOptions) do
|
||||
print(k .. ' : ' .. option.prompt)
|
||||
end
|
||||
print('')
|
||||
term.write('> ')
|
||||
local ch = tonumber(_G.read())
|
||||
if ch and bootOptions[ch] then
|
||||
return ch
|
||||
end
|
||||
end
|
||||
while true do
|
||||
term.clear()
|
||||
term.setCursorPos(1, 1)
|
||||
print('Select startup mode')
|
||||
print()
|
||||
for k,option in pairs(bootOptions) do
|
||||
print(k .. ' : ' .. option.prompt)
|
||||
end
|
||||
print('')
|
||||
term.write('> ')
|
||||
local ch = tonumber(_G.read())
|
||||
if ch and bootOptions[ch] then
|
||||
return ch
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function splash()
|
||||
local w, h = term.current().getSize()
|
||||
local w, h = term.current().getSize()
|
||||
|
||||
term.setTextColor(colors.white)
|
||||
if not term.isColor() then
|
||||
local str = 'Opus OS'
|
||||
term.setCursorPos((w - #str) / 2, h / 2)
|
||||
term.write(str)
|
||||
else
|
||||
term.setBackgroundColor(colors.black)
|
||||
term.clear()
|
||||
local opus = {
|
||||
'fffff00',
|
||||
'ffff07000',
|
||||
'ff00770b00 4444',
|
||||
'ff077777444444444',
|
||||
'f07777744444444444',
|
||||
'f0000777444444444',
|
||||
'070000111744444',
|
||||
'777770000',
|
||||
'7777000000',
|
||||
'70700000000',
|
||||
'077000000000',
|
||||
}
|
||||
for k,line in ipairs(opus) do
|
||||
term.setCursorPos((w - 18) / 2, k + (h - #opus) / 2)
|
||||
term.blit(string.rep(' ', #line), string.rep('a', #line), line)
|
||||
end
|
||||
end
|
||||
term.setTextColor(colors.white)
|
||||
if not term.isColor() then
|
||||
local str = 'Opus OS'
|
||||
term.setCursorPos((w - #str) / 2, h / 2)
|
||||
term.write(str)
|
||||
else
|
||||
term.setBackgroundColor(colors.black)
|
||||
term.clear()
|
||||
local opus = {
|
||||
'fffff00',
|
||||
'ffff07000',
|
||||
'ff00770b00 4444',
|
||||
'ff077777444444444',
|
||||
'f07777744444444444',
|
||||
'f0000777444444444',
|
||||
'070000111744444',
|
||||
'777770000',
|
||||
'7777000000',
|
||||
'70700000000',
|
||||
'077000000000',
|
||||
}
|
||||
for k,line in ipairs(opus) do
|
||||
term.setCursorPos((w - 18) / 2, k + (h - #opus) / 2)
|
||||
term.blit(string.rep(' ', #line), string.rep('a', #line), line)
|
||||
end
|
||||
end
|
||||
|
||||
local str = 'Press any key for menu'
|
||||
term.setCursorPos((w - #str) / 2, h)
|
||||
term.write(str)
|
||||
local str = 'Press any key for menu'
|
||||
term.setCursorPos((w - #str) / 2, h)
|
||||
term.write(str)
|
||||
end
|
||||
|
||||
term.clear()
|
||||
@@ -72,24 +72,25 @@ splash()
|
||||
|
||||
local timerId = os.startTimer(1.5)
|
||||
while true do
|
||||
local e, id = os.pullEvent()
|
||||
if e == 'timer' and id == timerId then
|
||||
break
|
||||
end
|
||||
if e == 'char' then
|
||||
bootOption = startupMenu()
|
||||
if settings then
|
||||
settings.set('opus.boot_option', bootOption)
|
||||
settings.save('.settings')
|
||||
end
|
||||
break
|
||||
end
|
||||
local e, id = os.pullEvent()
|
||||
if e == 'timer' and id == timerId then
|
||||
break
|
||||
end
|
||||
if e == 'char' then
|
||||
bootOption = startupMenu()
|
||||
if settings then
|
||||
settings.set('opus.boot_option', bootOption)
|
||||
settings.save('.settings')
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
term.clear()
|
||||
term.setCursorPos(1, 1)
|
||||
if bootOptions[bootOption].args then
|
||||
os.run(_G.getfenv(1), table.unpack(bootOptions[bootOption].args))
|
||||
os.run(_G.getfenv(1), table.unpack(bootOptions[bootOption].args))
|
||||
else
|
||||
print(bootOptions[bootOption].prompt)
|
||||
print(bootOptions[bootOption].prompt)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user