View difference between Paste ID: rBEfV6Gt and 8zek1eez
SHOW: | | - or go back to the newest paste.
1
--this acts as main script CSP
2
version = "1.0.3"
3
settings.load(".settings")
4
local w, h = term.getSize()
5
local BaseAppsInstalled = {true,false,true}
6-
local IntPrograms = {"os/os_Programs/ClientApps/os_AccountPgScript","os/os_Programs/os_LinksProvider","os/os_Programs/os_SettingsMenu","os.reboot","os.shutdown"}
6+
local IntPrograms = {"os/os_Programs/ClientApps/os_AccountPgScript","os/os_Programs/os_LinksProvider","os/os_Programs/os_SettingsMenu"}
7-
local ProgramNames = {"Account","Online Items","Settings","reboot","shutdown"}
7+
local ProgramNames = {"Account","Online Items","Settings"}
8-
local TimeSpot = #ProgramNames + 5
8+
local TimeSpot = h
9
10
local function Clear()
11
term.clear()
12
term.setCursorPos(1,1)
13
end
14
 
15
local function CenterText(y,text)
16
    local x = math.floor((w - string.len(text)) /2)
17
    term.setCursorPos(x,y)
18
    term.clearLine()
19
    term.write(text)
20
end
21-
local function LoadInstalled()
21+
22
local function BetaAppsLoad()
23
ProgramNames = {}
24
IntPrograms = {}
25
settings.load(".settings")
26
ProgramNames = settings.get("ClientApps_Names")
27
IntPrograms = settings.get("ClientApps_Paths")
28
ProgramNames[#ProgramNames + 1] = "reboot"
29
ProgramNames[#ProgramNames + 1] = "shutdown"
30
IntPrograms[#IntPrograms + 1] = "reboot"
31
IntPrograms[#IntPrograms + 1] = "shutdown"
32
TimeSpot = #ProgramNames + 5
33
end
34-
local function NonBetaTestMode()
34+
35-
IntPrograms = {"os/os_Programs/os_AccountPgScript","os/os_Programs/os_LinksProvider","os/os_Programs/os_SettingsMenu", "os.reboot","os.shutdown"}
35+
36-
ProgramNames = {"AccountPage","Online Programs","Settings","Reboot","PowerOff"}
36+
37
term.setBackgroundColor(colors.cyan)
38
Clear()
39
local Background = paintutils.loadImage("os/os_SystemFiles/Images/MenuBackground")
40
paintutils.drawImage(Background,1,1)
41
CenterText(1,"==Desktop==version"..version.."==")
42
CenterText(3,"-=Applications=-")
43
term.setBackgroundColor(colors.cyan)
44
CenterText(TimeSpot,os.date())
45
if settings.get("os_BetaTest") == true then CenterText(TimeSpot -1,"Experimental Mode") end
46
end
47
 
48
49-
    CenterText(TimeSpot - 1,"Experimental Mode")
49+
50
function CUI(m) --declare function
51-
DrawNetworkStatus()
51+
52
local l = #m
53
local BoxPositions = {{2,5},{8,5},{14,5},{2,13},{8,13},{14,13},{2,21},{8,21},{14,21}}
54-
function DrawNetworkStatus()
54+
55-
local Modem = peripheral.find("modem")
55+
56-
local NetworkState = 0
56+
57-
if Modem ~= nil then
57+
	paintutils.drawFilledBox(BoxPositions[i][1],BoxPositions[i][2],BoxPositions[i][1] + 5, BoxPositions[i][2] + 7, colors.gray)
58-
	NetworkState = 1
58+
	term.setCursorPos(BoxPositions[i][1],BoxPositions[i][2])
59
	term.write(m[i])
60-
   	NetworkState = 0
60+
61
62-
if NetworkState == 1 then
62+
a, b, c, d = os.pullEvent("mouse_click") --wait for keypress
63-
	rednet.open(Modem)
63+
for i = 1, #m do
64-
	rednet.broadcast("ping")
64+
	n = i
65-
	local id, message, protocol = rednet.receive()
65+
	if c < 2 and d < 2 then shell.run("os/os_Programs/os_PowerMenu") end
66-
	if message == "pong" then
66+
	if c > BoxPositions[i][1] and c < BoxPositions[i][1] + 5 and d > BoxPositions[i][2] and d < BoxPositions[i][2] + 7 then break end
67-
		NetworkState = 3
67+
68-
    else
68+
69-
        NetworkState = 2
69+
70-
    end
70+
71
72-
paintutils.drawFilledBox(w-3,h-3,w,h,colors.lightGray)
72+
73-
if NetworkState == 3 then paintutils.drawFilledBox(w-2,h-2,w,h, colors.white) end
73+
74-
if NetworkState > 1 then paintutils(w-1, h-1, w, h, colors.lightGray) end
74+
    BetaAppsLoad()
75-
if NetworkState == 0 then
75+
76-
	paintutils.drawPixel(w,h,colors.gray)
76+
77-
elseif NetworkState == 1 then
77+
78-
    paintutils.drawPixel(w,h,colors.white)
78+
79
if IntPrograms[n] == "reboot" then
80
    os.reboot()
81
elseif IntPrograms[n] == "shutdown" then
82
    os.shutdown()
83
else
84
    shell.run(shell.resolve(IntPrograms[n]))
85
end
86-
CenterText(TimeSpot, os.date())
86+