Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Colors
- tColors = {
- ["main"] = { bg = colors.white, fg = colors.black },
- ["taskbar"] = { bg = colors.blue, fg = colors.white },
- ["button"] = { fg = colors.white, bar = colors.gray, drag = colors.yellow, close = colors.red, edit = colors.green },
- ["error"] = { bg = colors.red, fg = colors.white },
- ["icon"] = { bg = colors.blue, fg = colors.lightGray },
- ["start"] = { bg = colors.lightBlue, fg = colors.white }
- }
- -- Buttons/Boxes
- tButtons = {
- ["icon1"] = { x = 4, y = 3, w = 4, h = 3, fg = "Tst1", bDrag = true, bBar = true, bClose = true, bEdit = true, bHidden = false, bg = colors.blue, link = "/test1" },
- ["icon2"] = { x = 9, y = 3, w = 4, h = 3, fg = "Tst2", bDrag = true, bBar = true, bClose = true, bEdit = true, bHidden = false, bg = colors.blue, link = "/test2" },
- ["icon3"] = { x = 14, y = 3, w = 4, h = 3, fg = "Tst3", bDrag = true, bBar = true, bClose = true, bEdit = true, bHidden = false, bg = tColors["icon"].bg, link = "/test3" },
- ["iconedit"] = { x = 20, y = 3, w = 29, h = 14, fg = "Icon Editor", bDrag = true, bBar = true, bClose = true, bEdit = false, bg = colors.blue },
- ["iconedit_links"] = { x = 22, y = 5, w = 25, h = 3, fg = "Modify Links", bDrag = false, bBar = false, bClose = false, bEdit = false, bg = colors.lightGray, },
- ["iconedit_labels"] = { x = 22, y = 9, w = 25, h = 3, fg = "Modify Labels", bDrag = false, bBar = false, bClose = false, bEdit = false, bg = colors.lightGray, },
- ["iconedit_hidden"] = { x = 22, y = 13, w = 25, h = 3, fg = "Hide Icons", bDrag = false, bBar = false, bClose = false, bEdit = false, bg = colors.lightGray, },
- ["iconedit_h1"] = { x = 22, y = 5, w = 25, h = 3, fg = "Icon 1", bDrag = false, bBar = false, bClose = false, bEdit = false, bg = colors.lightGray },
- ["iconedit_h2"] = { x = 22, y = 9, w = 25, h = 3, fg = "Icon 2", bDrag = false, bBar = false, bClose = false, bEdit = false, bg = colors.lightGray },
- ["iconedit_h3"] = { x = 22, y = 13, w = 25, h = 3, fg = "Icon 3", bDrag = false, bBar = false, bClose = false, bEdit = false, bg = colors.lightGray },
- ["iconedit_l1"] = { x = 22, y = 5, w = 25, h = 3, fg = "Link 1", bDrag = false, bBar = false, bClose = false, bEdit = false, bg = colors.lightGray },
- ["iconedit_l2"] = { x = 22, y = 9, w = 25, h = 3, fg = "Link 2", bDrag = false, bBar = false, bClose = false, bEdit = false, bg = colors.lightGray },
- ["iconedit_l3"] = { x = 22, y = 13, w = 25, h = 3, fg = "Link 3", bDrag = false, bBar = false, bClose = false, bEdit = false, bg = colors.lightGray },
- ["iconedit_ll1"] = { x = 22, y = 5, w = 25, h = 3, fg = "Label 1", bDrag = false, bBar = false, bClose = false, bEdit = false, bg = colors.lightGray },
- ["iconedit_ll2"] = { x = 22, y = 9, w = 25, h = 3, fg = "Label 2", bDrag = false, bBar = false, bClose = false, bEdit = false, bg = colors.lightGray },
- ["iconedit_ll3"] = { x = 22, y = 13, w = 25, h = 3, fg = "Label 3", bDrag = false, bBar = false, bClose = false, bEdit = false, bg = colors.lightGray },
- ["notification"] = { x = 20, y = 3, w = 29, h = 13, fg = "Notifications", bDrag = true, bBar = true, bClose = true, bEdit = false, bg = colors.blue, bAttention = false },
- ["notification_msg"] = { x = 2, y = 12, w = 29, h = 5, fg = "Message", bDrag = true, bBar = true, bClose = true, bEdit = false, bg = colors.blue }
- }
- tNotifications = {
- [1] = { x = 22, y = 5, h = 1, w = 25, fg = colors.gray, bg = colors.lightBlue, text = "", sAction = "" },
- [2] = { x = 22, y = 6, h = 1, w = 25, fg = colors.lightBlue, bg = colors.gray, text = "", sAction = "" },
- [3] = { x = 22, y = 7, h = 1, w = 25, fg = colors.gray, bg = colors.lightBlue, text = "", sAction = "" },
- [4] = { x = 22, y = 8, h = 1, w = 25, fg = colors.lightBlue, bg = colors.gray, text = "", sAction = "" },
- [5] = { x = 22, y = 9, h = 1, w = 25, fg = colors.gray, bg = colors.lightBlue, text = "", sAction = "" },
- [6] = { x = 22, y = 10, h = 1, w = 25, fg = colors.lightBlue, bg = colors.gray, text = "", sAction = "" },
- [7] = { x = 22, y = 11, h = 1, w = 25, fg = colors.gray, bg = colors.lightBlue, text = "", sAction = "" },
- [8] = { x = 22, y = 12, h = 1, w = 25, fg = colors.lightBlue, bg = colors.gray, text = "", sAction = "" },
- [9] = { x = 22, y = 13, h = 1, w = 25, fg = colors.gray, bg = colors.lightBlue, text = "", sAction = "" },
- [10] = { x = 22, y = 14, h = 1, w = 25, fg = colors.lightBlue, bg = colors.gray, text = "", sAction = "" },
- }
- rednet.open("top")
- -- Icons
- tIcons = {}
- -- Paths
- path_users = "/guie2/.users/"
- -- Event catcher is running
- bRunning = true
- -- Icon editor; running or not?
- bIconEditor = false
- sIconEditorMenu = 0
- -- Start menu; showing or not?
- bStartMenu = false
- -- Notifications menu
- bNotification = false
- bNotification_msg = false
- sMessageText = ""
- sMessageFrom = -1
- term_width, term_height = term.getSize()
- bDragging = false
- sDragTime = 0
- bStartingToDrag = false
- -- Computer Time Timer
- sTime = os.startTimer(1)
- -- Background update checking
- sUpdate = os.startTimer(10)
- -- Draw a box! function
- function drawBox(tButton,extra,bIcon,bBackButton,bNotificationButton,bMsg,sFrom,sText)
- term.setBackgroundColor(tButton.bg)
- if not bNotificationButton then
- term.setTextColor(tColors["button"].fg)
- else
- term.setTextColor(tButton.fg)
- end
- term.setCursorPos(tButton.x,tButton.y)
- for i=1,tButton.h do
- for i=1,tButton.w do
- write(" ")
- end
- term.setCursorPos(tButton.x,tButton.y+i)
- end
- if bNotificationButton then
- term.setCursorPos(tButton.x,tButton.y)
- if #tButton.text > 22 then
- print(string.sub(tButton.text,1,22))
- else
- print(tButton.text)
- end
- term.setCursorPos(tButton.x + tButton.w - 1, tButton.y)
- term.setTextColor(tColors["button"].close)
- print(string.char(7))
- term.setCursorPos(tButton.x + tButton.w - 2, tButton.y)
- term.setTextColor(tColors["button"].edit)
- print(string.char(7))
- end
- if tButton.bBar then
- term.setCursorPos(tButton.x,tButton.y)
- term.setBackgroundColor(tColors["button"].bar)
- for i=1,tButton.w do
- write(" ")
- end
- if tButton.bDrag then
- term.setCursorPos(tButton.x,tButton.y)
- term.setTextColor(tColors["button"].drag)
- print(string.char(7))
- end
- if tButton.bClose then
- term.setCursorPos(tButton.x+tButton.w-1,tButton.y)
- term.setTextColor(tColors["button"].close)
- print(string.char(7))
- end
- if tButton.bEdit then
- term.setCursorPos(tButton.x+tButton.w-2,tButton.y)
- term.setTextColor(tColors["button"].edit)
- print(string.char(7))
- end
- if bBackButton then
- term.setCursorPos(tButton.x+tButton.w-2,tButton.y)
- term.setTextColor(tColors["button"].edit)
- print(string.char(17))
- end
- if bIcon then
- term.setCursorPos(tButton.x,tButton.y+tButton.h-1)
- term.setTextColor(tColors["icon"].fg)
- term.setBackgroundColor(tColors["icon"].bg)
- print(tButton.fg)
- else
- term.setCursorPos(tButton.x+1,tButton.y)
- term.setTextColor(tColors["button"].fg)
- print(tButton.fg)
- end
- else
- if not bNotificationButton then
- if tButton.h == 3 or tButton.h == 5 or tButton.h == 7 or tButton.h == 9 then
- term.setCursorPos(tButton.x+(tButton.w/2)-(#tButton.fg/2),tButton.y+(tButton.h/2))
- print(tButton.fg)
- else
- term.setCursorPos(tButton.x+(tButton.w/2)-(#tButton.fg/2),tButton.y+(tButton.h/2)-1)
- print(tButton.fg)
- end
- end
- end
- term.setCursorPos(tButton.x+(tButton.w/2)-(#extra/2),tButton.y+(tButton.h/2)+1)
- term.setTextColor(colors.gray)
- print(extra)
- if bMsg then
- term.setCursorPos(tButtons["notification_msg"].x+1,tButtons["notification_msg"].y+2)
- term.setBackgroundColor(tButtons["notification_msg"].bg)
- term.setTextColor(tColors["button"].fg)
- write("From: ")
- term.setTextColor(colors.lightGray)
- write(sFrom)
- term.setTextColor(tColors["button"].fg)
- term.setCursorPos(tButtons["notification_msg"].x+1,tButtons["notification_msg"].y+3)
- write("Message: ")
- term.setTextColor(colors.lightGray)
- if #sText >= 18 then
- write(string.sub(sText,1,18))
- if #sText >= 36 then
- if (string.sub(sText,19,19)) == " " then
- term.setCursorPos(tButtons["notification_msg"].x+10,tButtons["notification_msg"].y+4)
- print(string.sub(sText,20,36))
- else
- term.setCursorPos(tButtons["notification_msg"].x+10,tButtons["notification_msg"].y+4)
- print(string.sub(sText,19,36))
- end
- if (string.sub(sText,37,37)) == " " then
- term.setCursorPos(tButtons["notification_msg"].x+10,tButtons["notification_msg"].y+5)
- print(string.sub(sText,38,#sText))
- else
- term.setCursorPos(tButtons["notification_msg"].x+10,tButtons["notification_msg"].y+5)
- print(string.sub(sText,37,#sText))
- end
- else
- if (string.sub(sText,19,19)) == " " then
- term.setCursorPos(tButtons["notification_msg"].x+10,tButtons["notification_msg"].y+4)
- print(string.sub(sText,20,#sText))
- else
- term.setCursorPos(tButtons["notification_msg"].x+10,tButtons["notification_msg"].y+4)
- print(string.sub(sText,19,#sText))
- end
- end
- else
- write(sText)
- end
- end
- end
- function addNotification(name,extra,func)
- local bChosen = -1
- for i=1,#tNotifications do
- if tNotifications[i].text == "" then
- bChosen = i
- break
- end
- end
- if bChosen == -1 then
- bChosen = 10
- tNotifications[1].text = tNotifications[2].text
- tNotifications[1].sAction = tNotifications[2].sAction
- tNotifications[2].text = tNotifications[3].text
- tNotifications[2].sAction = tNotifications[3].sAction
- tNotifications[3].text = tNotifications[4].text
- tNotifications[3].sAction = tNotifications[4].sAction
- tNotifications[4].text = tNotifications[5].text
- tNotifications[4].sAction = tNotifications[5].sAction
- tNotifications[5].text = tNotifications[6].text
- tNotifications[5].sAction = tNotifications[6].sAction
- tNotifications[6].text = tNotifications[7].text
- tNotifications[6].sAction = tNotifications[7].sAction
- tNotifications[7].text = tNotifications[8].text
- tNotifications[7].sAction = tNotifications[8].sAction
- tNotifications[8].text = tNotifications[9].text
- tNotifications[8].sAction = tNotifications[9].sAction
- tNotifications[9].text = tNotifications[10].text
- tNotifications[9].sAction = tNotifications[10].sAction
- end
- tNotifications[bChosen].text = name
- tNotifications[bChosen].sAction = func
- end
- -- Draw everything! function
- function drawBackground()
- term.setBackgroundColor(tColors["main"].bg)
- term.clear()
- term.setCursorPos(1,1)
- term.setBackgroundColor(tColors["taskbar"].bg)
- term.clearLine()
- term.setCursorPos(1,1)
- term.setTextColor(tColors["taskbar"].fg)
- print("GUI Example V2")
- term.setCursorPos(1,term_height)
- term.clearLine()
- term.setBackgroundColor(tColors["start"].bg)
- term.setTextColor(tColors["start"].fg)
- write(" Start ")
- if not tButtons["icon1"].bHidden then
- drawBox(tButtons["icon1"],"",true,false,false,false,"","")
- end
- if not tButtons["icon2"].bHidden then
- drawBox(tButtons["icon2"],"",true,false,false,false,"","")
- end
- if not tButtons["icon3"].bHidden then
- drawBox(tButtons["icon3"],"",true,false,false,false,"","")
- end
- if bIconEditor then
- drawIconEditor()
- end
- if bStartMenu then
- drawStartMenu()
- end
- if bNotification then
- drawNotificationMenu()
- end
- if bNotification_msg then
- drawBox(tButtons["notification_msg"],"",false,false,false,true,sMessageFrom,sMessageText)
- end
- end
- function drawTime()
- term.setCursorPos((term_width - #textutils.formatTime(os.time(),false)) + 1,term_height)
- term.setBackgroundColor(tColors["taskbar"].bg)
- term.setTextColor(tColors["taskbar"].fg)
- write(textutils.formatTime(os.time(),false))
- end
- function updateNotificationMenu()
- local nTaken = 0
- local nOpen = 0
- for i=1,#tNotifications do
- if i >= 2 then
- if tNotifications[i-1].text == "" then
- tNotifications[i-1].text = tNotifications[i].text
- tNotifications[i-1].sAction = tNotifications[i].sAction
- if tNotifications[i+1] then
- tNotifications[i].text = tNotifications[i+1].text
- tNotifications[i].sAction = tNotifications[i+1].sAction
- if tNotifications[i+2] then
- tNotifications[i+1].text = tNotifications[i+2].text
- tNotifications[i+1].sAction = tNotifications[i+2].sAction
- if tNotifications[i+3] then
- tNotifications[i+2].text = tNotifications[i+3].text
- tNotifications[i+2].sAction = tNotifications[i+3].sAction
- if tNotifications[i+4] then
- tNotifications[i+3].text = tNotifications[i+4].text
- tNotifications[i+3].sAction = tNotifications[i+4].sAction
- if tNotifications[i+5] then
- tNotifications[i+4].text = tNotifications[i+5].text
- tNotifications[i+4].sAction = tNotifications[i+5].sAction
- if tNotifications[i+6] then
- tNotifications[i+5].text = tNotifications[i+6].text
- tNotifications[i+5].sAction = tNotifications[i+6].sAction
- if tNotifications[i+7] then
- tNotifications[i+6].text = tNotifications[i+7].text
- tNotifications[i+6].sAction = tNotifications[i+7].sAction
- if tNotifications[i+8] then
- tNotifications[i+7].text = tNotifications[i+8].text
- tNotifications[i+7].sAction = tNotifications[i+8].sAction
- if tNotifications[i+9] then
- tNotifications[i+8].text = tNotifications[i+9].text
- tNotifications[i+8].sAction = tNotifications[i+9].sAction
- else
- tNotifications[i+8].text = ""
- tNotifications[i+8].sAction = ""
- end
- else
- tNotifications[i+7].text = ""
- tNotifications[i+7].sAction = ""
- end
- else
- tNotifications[i+6].text = ""
- tNotifications[i+6].sAction = ""
- end
- else
- tNotifications[i+5].text = ""
- tNotifications[i+5].sAction = ""
- end
- else
- tNotifications[i+4].text = ""
- tNotifications[i+4].sAction = ""
- end
- else
- tNotifications[i+3].text = ""
- tNotifications[i+3].sAction = ""
- end
- else
- tNotifications[i+2].text = ""
- tNotifications[i+2].sAction = ""
- end
- else
- tNotifications[i+1].text = ""
- tNotifications[i+1].sAction = ""
- end
- else
- tNotifications[i].text = ""
- tNotifications[i].sAction = ""
- end
- end
- end
- end
- end
- function drawNotificationMenu()
- drawBox(tButtons["notification"],"",false,false,false)
- for i=1,#tNotifications do
- drawBox(tNotifications[i],"",false,false,true)
- end
- end
- function drawIconEditor()
- drawBox(tButtons["iconedit"],"",false,true,false)
- if sIconEditorMenu == 2 then
- drawBox(tButtons["iconedit_l1"],tButtons["icon1"].link,false,false,false)
- drawBox(tButtons["iconedit_l2"],tButtons["icon2"].link,false,false,false)
- drawBox(tButtons["iconedit_l3"],tButtons["icon3"].link,false,false,false)
- elseif sIconEditorMenu == 1 then
- drawBox(tButtons["iconedit"],"",false,false,false)
- drawBox(tButtons["iconedit_links"],"",false,false,false)
- drawBox(tButtons["iconedit_labels"],"",false,false,false)
- drawBox(tButtons["iconedit_hidden"],"",false,false,false)
- elseif sIconEditorMenu == 3 then
- drawBox(tButtons["iconedit_ll1"],tButtons["icon1"].fg,false,false,false)
- drawBox(tButtons["iconedit_ll2"],tButtons["icon2"].fg,false,false,false)
- drawBox(tButtons["iconedit_ll3"],tButtons["icon3"].fg,false,false,false)
- elseif sIconEditorMenu == 4 then
- local icon1_h = "Not Hidden"
- local icon2_h = "Not Hidden"
- local icon3_h = "Not Hidden"
- if tButtons["icon1"].bHidden then
- icon1_h = "Hidden"
- end
- if tButtons["icon2"].bHidden then
- icon2_h = "Hidden"
- end
- if tButtons["icon3"].bHidden then
- icon3_h = "Hidden"
- end
- drawBox(tButtons["iconedit_h1"],icon1_h,false,false,false)
- drawBox(tButtons["iconedit_h2"],icon2_h,false,false,false)
- drawBox(tButtons["iconedit_h3"],icon3_h,false,false,false)
- end
- end
- function drawStartMenu()
- term.setTextColor(tColors["start"].fg)
- term.setBackgroundColor(tColors["start"].bg)
- term.setCursorPos(1,term_height-7)
- print(" ")
- term.setCursorPos(1,term_height-6)
- print(" CraftOS ")
- term.setCursorPos(1,term_height-5)
- print(" Notifications ")
- term.setCursorPos(1,term_height-4)
- print(" Control Panel ")
- term.setCursorPos(1,term_height-3)
- print(" Icon Editor ")
- term.setCursorPos(1,term_height-2)
- print(" Log out ")
- term.setCursorPos(1,term_height-1)
- print(" ")
- term.setCursorPos(2,term_height-6)
- term.setTextColor(tColors["taskbar"].bg)
- print(string.char(7))
- term.setCursorPos(2,term_height-5)
- if tButtons["notification"].bAttention then
- term.setTextColor(colors.red)
- print(string.char(7))
- else
- term.setTextColor(tColors["taskbar"].bg)
- print(string.char(7))
- end
- term.setCursorPos(2,term_height-4)
- term.setTextColor(tColors["taskbar"].bg)
- print(string.char(7))
- term.setCursorPos(2,term_height-3)
- term.setTextColor(tColors["taskbar"].bg)
- print(string.char(7))
- term.setCursorPos(2,term_height-2)
- term.setTextColor(tColors["taskbar"].bg)
- print(string.char(7))
- end
- drawBackground()
- while bRunning do
- local event, button, X, Y = os.pullEvent()
- if event == "mouse_click" then
- currentX1, currentY1 = X, Y
- currentX2, currentY2 = currentX1, currentY1
- currentX3, currentY3 = currentX1, currentY1
- currentXIE, currentYIE = currentX1, currentY1
- currentXN, currentYN = currentX1, currentY1
- currentXNM, currentYNM = currentX1, currentY1
- if button == 1 then
- if bIconEditor then
- if X == tButtons["iconedit"].x and Y == tButtons["iconedit"].y then
- bStartingToDrag = true
- end
- -- Click 'RED' on Icon Editor
- if X == (tButtons["iconedit"].x + tButtons["iconedit"].w - 1) and Y == tButtons["iconedit"].y then
- bIconEditor = false
- sIconEditorMenu = 0
- drawBackground()
- drawTime()
- end
- if sIconEditorMenu > 1 then
- if X == (tButtons["iconedit"].x + tButtons["iconedit"].w - 2) and Y == tButtons["iconedit"].y then
- sIconEditorMenu = 1
- drawBackground()
- drawTime()
- end
- end
- if sIconEditorMenu == 2 then
- -- Click textbox on Link 1
- if X >= tButtons["iconedit_l1"].x and X <= (tButtons["iconedit_l1"].x + tButtons["iconedit_l1"].w - 1) and Y >= tButtons["iconedit_l1"].y and Y <= (tButtons["iconedit_l1"].y + tButtons["iconedit_l1"].h - 1) then
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(tButtons["iconedit_l1"].x+1,tButtons["iconedit_l1"].y+tButtons["iconedit_l1"].h-1)
- print(" ")
- term.setCursorPos(tButtons["iconedit_l1"].x+1,tButtons["iconedit_l1"].y+tButtons["iconedit_l1"].h-1)
- local linkInput = read()
- if fs.exists(linkInput) then
- tButtons["icon1"].link = linkInput
- end
- drawBackground()
- drawTime()
- -- Click textbox on Link 2
- elseif X >= tButtons["iconedit_l2"].x and X <= (tButtons["iconedit_l2"].x + tButtons["iconedit_l2"].w - 1) and Y >= tButtons["iconedit_l2"].y and Y <= (tButtons["iconedit_l2"].y + tButtons["iconedit_l2"].h - 1) then
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(tButtons["iconedit_l2"].x+1,tButtons["iconedit_l2"].y+tButtons["iconedit_l2"].h-1)
- print(" ")
- term.setCursorPos(tButtons["iconedit_l2"].x+1,tButtons["iconedit_l2"].y+tButtons["iconedit_l2"].h-1)
- local linkInput = read()
- if fs.exists(linkInput) then
- tButtons["icon2"].link = linkInput
- end
- drawBackground()
- drawTime()
- -- Click textbox on Link 3
- elseif X >= tButtons["iconedit_l3"].x and X <= (tButtons["iconedit_l3"].x + tButtons["iconedit_l3"].w - 1) and Y >= tButtons["iconedit_l3"].y and Y <= (tButtons["iconedit_l3"].y + tButtons["iconedit_l3"].h - 1) then
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(tButtons["iconedit_l3"].x+1,tButtons["iconedit_l3"].y+tButtons["iconedit_l3"].h-1)
- print(" ")
- term.setCursorPos(tButtons["iconedit_l3"].x+1,tButtons["iconedit_l3"].y+tButtons["iconedit_l3"].h-1)
- local linkInput = read()
- if fs.exists(linkInput) then
- tButtons["icon3"].link = linkInput
- end
- drawBackground()
- drawTime()
- end
- elseif sIconEditorMenu == 1 then
- -- Click the 'Links' button
- if X >= tButtons["iconedit_links"].x and X <= (tButtons["iconedit_links"].x + tButtons["iconedit_links"].w - 1) and Y >= tButtons["iconedit_links"].y and Y <= (tButtons["iconedit_links"].y + tButtons["iconedit_links"].h - 1) then
- sIconEditorMenu = 2
- drawBackground()
- drawTime()
- -- Click the 'Labels' button
- elseif X >= tButtons["iconedit_labels"].x and X <= (tButtons["iconedit_labels"].x + tButtons["iconedit_labels"].w - 1) and Y >= tButtons["iconedit_labels"].y and Y <= (tButtons["iconedit_labels"].y + tButtons["iconedit_labels"].h - 1) then
- sIconEditorMenu = 3
- drawBackground()
- drawTime()
- -- Click the 'Hidden' button
- elseif X >= tButtons["iconedit_hidden"].x and X <= (tButtons["iconedit_hidden"].x + tButtons["iconedit_hidden"].w - 1) and Y >= tButtons["iconedit_hidden"].y and Y <= (tButtons["iconedit_hidden"].y + tButtons["iconedit_hidden"].h - 1) then
- sIconEditorMenu = 4
- drawBackground()
- drawTime()
- end
- elseif sIconEditorMenu == 3 then
- -- Click textbox on Link 1
- if X >= tButtons["iconedit_ll1"].x and X <= (tButtons["iconedit_ll1"].x + tButtons["iconedit_ll1"].w - 1) and Y >= tButtons["iconedit_ll1"].y and Y <= (tButtons["iconedit_ll1"].y + tButtons["iconedit_ll1"].h - 1) then
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(tButtons["iconedit_ll1"].x+1,tButtons["iconedit_ll1"].y+tButtons["iconedit_ll1"].h-1)
- print(" ")
- term.setCursorPos(tButtons["iconedit_ll1"].x+1,tButtons["iconedit_ll1"].y+tButtons["iconedit_ll1"].h-1)
- local fgInput = read()
- tButtons["icon1"].fg = string.sub(fgInput,1,4)
- drawBackground()
- drawTime()
- -- Click textbox on Link 2
- elseif X >= tButtons["iconedit_ll2"].x and X <= (tButtons["iconedit_ll2"].x + tButtons["iconedit_ll2"].w - 1) and Y >= tButtons["iconedit_ll2"].y and Y <= (tButtons["iconedit_ll2"].y + tButtons["iconedit_ll2"].h - 1) then
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(tButtons["iconedit_ll2"].x+1,tButtons["iconedit_ll2"].y+tButtons["iconedit_ll2"].h-1)
- print(" ")
- term.setCursorPos(tButtons["iconedit_ll2"].x+1,tButtons["iconedit_ll2"].y+tButtons["iconedit_ll2"].h-1)
- local fgInput = read()
- tButtons["icon2"].fg = string.sub(fgInput,1,4)
- drawBackground()
- drawTime()
- -- Click textbox on Link 3
- elseif X >= tButtons["iconedit_ll3"].x and X <= (tButtons["iconedit_ll3"].x + tButtons["iconedit_ll3"].w - 1) and Y >= tButtons["iconedit_ll3"].y and Y <= (tButtons["iconedit_ll3"].y + tButtons["iconedit_ll3"].h - 1) then
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(tButtons["iconedit_ll3"].x+1,tButtons["iconedit_ll3"].y+tButtons["iconedit_ll3"].h-1)
- print(" ")
- term.setCursorPos(tButtons["iconedit_ll3"].x+1,tButtons["iconedit_ll3"].y+tButtons["iconedit_ll3"].h-1)
- local fgInput = read()
- tButtons["icon3"].fg = string.sub(fgInput,1,4)
- drawBackground()
- drawTime()
- end
- elseif sIconEditorMenu == 4 then
- -- Click Icon 1 Box
- if X >= tButtons["iconedit_h1"].x and X <= (tButtons["iconedit_h1"].x + tButtons["iconedit_h1"].w - 1) and Y >= tButtons["iconedit_h1"].y and Y <= (tButtons["iconedit_h1"].y + tButtons["iconedit_h1"].h - 1) then
- tButtons["icon1"].bHidden = not tButtons["icon1"].bHidden
- drawBackground()
- drawTime()
- elseif X >= tButtons["iconedit_h2"].x and X <= (tButtons["iconedit_h2"].x + tButtons["iconedit_h2"].w - 1) and Y >= tButtons["iconedit_h2"].y and Y <= (tButtons["iconedit_h2"].y + tButtons["iconedit_h2"].h - 1) then
- tButtons["icon2"].bHidden = not tButtons["icon2"].bHidden
- drawBackground()
- drawTime()
- elseif X >= tButtons["iconedit_h3"].x and X <= (tButtons["iconedit_h3"].x + tButtons["iconedit_h3"].w - 1) and Y >= tButtons["iconedit_h3"].y and Y <= (tButtons["iconedit_h3"].y + tButtons["iconedit_h3"].h - 1) then
- tButtons["icon3"].bHidden = not tButtons["icon3"].bHidden
- drawBackground()
- drawTime()
- end
- end
- end
- if bStartMenu then
- if X >= 1 and X <= 18 and Y == (term_height - 2) then
- bRunning = false
- shell.run("guie")
- elseif X >= 1 and X <= 18 and Y == (term_height - 3) then
- if not bIconEditor then
- bNotification = false
- bIconEditor = true
- sIconEditorMenu = 1
- bStartMenu = false
- end
- drawBackground()
- drawTime()
- elseif X >= 1 and X <= 18 and Y == (term_height - 4) then
- bStartMenu = false
- drawBackground()
- drawTime()
- elseif X >= 1 and X <= 18 and Y == (term_height - 5) then
- if not bNotification then
- bStartMenu = false
- bIconEditor = false
- bNotification = true
- end
- drawBackground()
- drawTime()
- elseif X >= 1 and X <= 18 and Y == (term_height - 6) then
- bRunning = false
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- term.clear()
- term.setCursorPos(1,1)
- print(os.version())
- term.setTextColor(colors.white)
- else
- bStartMenu = false
- drawBackground()
- drawTime()
- end
- end
- if bNotification_msg then
- if X == (tButtons["notification_msg"].x + tButtons["notification_msg"].w - 1) and Y == tButtons["notification_msg"].y then
- bNotification_msg = false
- drawBackground()
- drawTime()
- end
- end
- if bNotification then
- -- Click 'RED' on Notifications
- if X == (tButtons["notification"].x + tButtons["notification"].w - 1) and Y == tButtons["notification"].y then
- bNotification = false
- drawBackground()
- drawTime()
- elseif X == (tNotifications[1].x + tNotifications[1].w - 1) and Y == tNotifications[1].y then
- tNotifications[1].text = ""
- tNotifications[1].sAction = ""
- updateNotificationMenu()
- drawNotificationMenu()
- drawTime()
- elseif X == (tNotifications[2].x + tNotifications[2].w - 1) and Y == tNotifications[2].y then
- tNotifications[2].text = ""
- tNotifications[2].sAction = ""
- updateNotificationMenu()
- drawNotificationMenu()
- drawTime()
- elseif X == (tNotifications[3].x + tNotifications[3].w - 1) and Y == tNotifications[3].y then
- tNotifications[3].text = ""
- tNotifications[3].sAction = ""
- updateNotificationMenu()
- drawNotificationMenu()
- drawTime()
- elseif X == (tNotifications[4].x + tNotifications[4].w - 1) and Y == tNotifications[4].y then
- tNotifications[4].text = ""
- tNotifications[4].sAction = ""
- updateNotificationMenu()
- drawNotificationMenu()
- drawTime()
- elseif X == (tNotifications[5].x + tNotifications[5].w - 1) and Y == tNotifications[5].y then
- tNotifications[5].text = ""
- tNotifications[5].sAction = ""
- updateNotificationMenu()
- drawNotificationMenu()
- drawTime()
- elseif X == (tNotifications[6].x + tNotifications[6].w - 1) and Y == tNotifications[6].y then
- tNotifications[6].text = ""
- tNotifications[6].sAction = ""
- updateNotificationMenu()
- drawNotificationMenu()
- drawTime()
- elseif X == (tNotifications[7].x + tNotifications[7].w - 1) and Y == tNotifications[7].y then
- tNotifications[7].text = ""
- tNotifications[7].sAction = ""
- updateNotificationMenu()
- drawNotificationMenu()
- drawTime()
- elseif X == (tNotifications[8].x + tNotifications[8].w - 1) and Y == tNotifications[8].y then
- tNotifications[8].text = ""
- tNotifications[8].sAction = ""
- updateNotificationMenu()
- drawNotificationMenu()
- drawTime()
- elseif X == (tNotifications[9].x + tNotifications[9].w - 1) and Y == tNotifications[9].y then
- tNotifications[9].text = ""
- tNotifications[9].sAction = ""
- updateNotificationMenu()
- drawNotificationMenu()
- drawTime()
- elseif X == (tNotifications[10].x + tNotifications[10].w - 1) and Y == tNotifications[10].y then
- tNotifications[10].text = ""
- tNotifications[10].sAction = ""
- updateNotificationMenu()
- drawNotificationMenu()
- drawTime()
- elseif X == (tNotifications[1].x + tNotifications[1].w - 2) and Y == tNotifications[1].y then
- tNotifications[1].sAction()
- drawBackground()
- drawTime()
- elseif X == (tNotifications[2].x + tNotifications[2].w - 2) and Y == tNotifications[2].y then
- tNotifications[2].sAction()
- drawBackground()
- drawTime()
- elseif X == (tNotifications[3].x + tNotifications[3].w - 2) and Y == tNotifications[3].y then
- tNotifications[3].sAction()
- drawBackground()
- drawTime()
- elseif X == (tNotifications[4].x + tNotifications[4].w - 2) and Y == tNotifications[4].y then
- tNotifications[4].sAction()
- drawBackground()
- drawTime()
- elseif X == (tNotifications[5].x + tNotifications[5].w - 2) and Y == tNotifications[5].y then
- tNotifications[5].sAction()
- drawBackground()
- drawTime()
- elseif X == (tNotifications[6].x + tNotifications[6].w - 2) and Y == tNotifications[6].y then
- tNotifications[6].sAction()
- drawBackground()
- drawTime()
- elseif X == (tNotifications[7].x + tNotifications[7].w - 2) and Y == tNotifications[7].y then
- tNotifications[7].sAction()
- drawBackground()
- drawTime()
- elseif X == (tNotifications[8].x + tNotifications[8].w - 2) and Y == tNotifications[8].y then
- tNotifications[8].sAction()
- drawBackground()
- drawTime()
- elseif X == (tNotifications[9].x + tNotifications[9].w - 2) and Y == tNotifications[9].y then
- tNotifications[9].sAction()
- drawBackground()
- drawTime()
- elseif X == (tNotifications[10].x + tNotifications[10].w - 2) and Y == tNotifications[10].y then
- tNotifications[10].sAction()
- drawBackground()
- drawTime()
- end
- end
- if X >= 1 and X <= 7 and Y == term_height then
- bStartMenu = true
- drawBackground()
- drawTime()
- end
- if not tButtons["icon1"].bHidden and X >= tButtons["icon1"].x and X <= (tButtons["icon1"].x + tButtons["icon1"].w - 1) and Y >= (tButtons["icon1"].y + 1) and Y <= (tButtons["icon1"].y + tButtons["icon1"].h - 1) then
- if not bStartingToDrag then
- shell.run(tButtons["icon1"].link)
- drawBackground()
- drawTime()
- end
- elseif not tButtons["icon2"].bHidden and X >= tButtons["icon2"].x and X <= (tButtons["icon2"].x + tButtons["icon2"].w - 1) and Y >= (tButtons["icon2"].y + 1) and Y <= (tButtons["icon2"].y + tButtons["icon2"].h - 1) then
- if not bStartingToDrag then
- shell.run(tButtons["icon2"].link)
- drawBackground()
- drawTime()
- end
- elseif not tButtons["icon3"].bHidden and X >= tButtons["icon3"].x and X <= (tButtons["icon3"].x + tButtons["icon3"].w - 1) and Y >= (tButtons["icon3"].y + 1) and Y <= (tButtons["icon3"].y + tButtons["icon3"].h - 1) then
- if not bStartingToDrag then
- shell.run(tButtons["icon3"].link)
- drawBackground()
- drawTime()
- end
- elseif not tButtons["icon1"].bHidden and X == (tButtons["icon1"].x + tButtons["icon1"].w - 2) and Y == tButtons["icon1"].y then
- if not bIconEditor then
- bNotification = false
- sIconEditorMenu = 1
- bIconEditor = true
- end
- drawBackground()
- drawTime()
- elseif not tButtons["icon2"].bHidden and X == (tButtons["icon2"].x + tButtons["icon2"].w - 2) and Y == tButtons["icon2"].y then
- if not bIconEditor then
- bNotification = false
- sIconEditorMenu = 1
- bIconEditor = true
- end
- drawBackground()
- drawTime()
- elseif not tButtons["icon3"].bHidden and X == (tButtons["icon3"].x + tButtons["icon3"].w - 2) and Y == tButtons["icon3"].y then
- if not bIconEditor then
- bNotification = false
- sIconEditorMenu = 1
- bIconEditor = true
- end
- drawBackground()
- drawTime()
- elseif not tButtons["icon1"].bHidden and X == (tButtons["icon1"].x + tButtons["icon1"].w - 1) and Y == tButtons["icon1"].y then
- tButtons["icon1"].bHidden = true
- drawBackground()
- drawTime()
- elseif not tButtons["icon2"].bHidden and X == (tButtons["icon2"].x + tButtons["icon2"].w - 1) and Y == tButtons["icon2"].y then
- tButtons["icon2"].bHidden = true
- drawBackground()
- drawTime()
- elseif not tButtons["icon3"].bHidden and X == (tButtons["icon3"].x + tButtons["icon3"].w - 1) and Y == tButtons["icon3"].y then
- tButtons["icon3"].bHidden = true
- drawBackground()
- drawTime()
- end
- end
- elseif event == "timer" then
- if button == sDragTime then
- bDragging = false
- bStartingToDrag = false
- elseif button == sTime then
- sTime = os.startTimer(1)
- drawTime()
- elseif button == sUpdate then
- sUpdate = os.startTimer(10)
- drawBackground()
- end
- elseif event == "mouse_drag" then
- if button == 1 then
- if tButtons["icon1"].bDrag and currentX1 == tButtons["icon1"].x and currentY1 == tButtons["icon1"].y then
- bDragging = true
- if bDragging == true then
- sDragTime = os.startTimer(1)
- if X >= 1 and X <= (term_width - tButtons["icon2"].w + 1) and Y >= 2 and Y <= (term_height - tButtons["icon2"].h) then
- tButtons["icon1"].x = X
- tButtons["icon1"].y = Y
- currentX1 = tButtons["icon1"].x
- currentY1 = tButtons["icon1"].y
- drawBackground()
- drawTime()
- end
- end
- elseif tButtons["icon2"].bDrag and currentX2 == tButtons["icon2"].x and currentY2 == tButtons["icon2"].y then
- bDragging = true
- if bDragging == true then
- sDragTime = os.startTimer(1)
- if X >= 1 and X <= (term_width - tButtons["icon2"].w + 1) and Y >= 2 and Y <= (term_height - tButtons["icon2"].h) then
- tButtons["icon2"].x = X
- tButtons["icon2"].y = Y
- currentX2 = tButtons["icon2"].x
- currentY2 = tButtons["icon2"].y
- drawBackground()
- drawTime()
- end
- end
- elseif tButtons["icon3"].bDrag and currentX3 == tButtons["icon3"].x and currentY3 == tButtons["icon3"].y then
- bDragging = true
- if bDragging == true then
- sDragTime = os.startTimer(1)
- if X >= 1 and X <= (term_width - tButtons["icon2"].w + 1) and Y >= 2 and Y <= (term_height - tButtons["icon2"].h) then
- tButtons["icon3"].x = X
- tButtons["icon3"].y = Y
- currentX3 = tButtons["icon3"].x
- currentY3 = tButtons["icon3"].y
- drawBackground()
- drawTime()
- end
- end
- elseif bIconEditor and tButtons["iconedit"].bDrag and currentXIE == tButtons["iconedit"].x and currentYIE == tButtons["iconedit"].y then
- bDragging = true
- if bDragging == true then
- sDragTime = os.startTimer(1)
- if X >= 1 and X <= (term_width - (tButtons["iconedit"].w - 1)) and Y >= 2 and Y <= (term_height - tButtons["iconedit"].h) then
- local tempX, tempY = X, Y
- tButtons["iconedit"].x = tempX
- tButtons["iconedit"].y = tempY
- tButtons["iconedit_labels"].x = tempX + 2
- tButtons["iconedit_labels"].y = tempY + 6
- tButtons["iconedit_links"].x = tempX + 2
- tButtons["iconedit_links"].y = tempY + 2
- tButtons["iconedit_l1"].x = tempX + 2
- tButtons["iconedit_l1"].y = tempY + 2
- tButtons["iconedit_l2"].x = tempX + 2
- tButtons["iconedit_l2"].y = tempY + 6
- tButtons["iconedit_l3"].x = tempX + 2
- tButtons["iconedit_l3"].y = tempY + 10
- tButtons["iconedit_h1"].x = tempX + 2
- tButtons["iconedit_h1"].y = tempY + 2
- tButtons["iconedit_h2"].x = tempX + 2
- tButtons["iconedit_h2"].y = tempY + 6
- tButtons["iconedit_h3"].x = tempX + 2
- tButtons["iconedit_h3"].y = tempY + 10
- tButtons["iconedit_ll1"].x = tempX + 2
- tButtons["iconedit_ll1"].y = tempY + 2
- tButtons["iconedit_ll2"].x = tempX + 2
- tButtons["iconedit_ll2"].y = tempY + 6
- tButtons["iconedit_ll3"].x = tempX + 2
- tButtons["iconedit_ll3"].y = tempY + 10
- tButtons["iconedit_hidden"].x = tempX + 2
- tButtons["iconedit_hidden"].y = tempY + 10
- currentXIE = tButtons["iconedit"].x
- currentYIE = tButtons["iconedit"].y
- drawBackground()
- drawTime()
- end
- end
- elseif bNotification and tButtons["notification"].bDrag and currentXN == tButtons["notification"].x and currentYN == tButtons["notification"].y then
- bDragging = true
- if bDragging == true then
- sDragTime = os.startTimer(1)
- if X >= 1 and X <= (term_width - (tButtons["notification"].w - 1)) and Y >= 2 and Y <= (term_height - tButtons["notification"].h) then
- local tempX, tempY = X, Y
- tButtons["notification"].x = tempX
- tButtons["notification"].y = tempY
- tNotifications[1].x = tempX + 2
- tNotifications[1].y = tempY + 2
- tNotifications[2].x = tempX + 2
- tNotifications[2].y = tempY + 3
- tNotifications[3].x = tempX + 2
- tNotifications[3].y = tempY + 4
- tNotifications[4].x = tempX + 2
- tNotifications[4].y = tempY + 5
- tNotifications[5].x = tempX + 2
- tNotifications[5].y = tempY + 6
- tNotifications[6].x = tempX + 2
- tNotifications[6].y = tempY + 7
- tNotifications[7].x = tempX + 2
- tNotifications[7].y = tempY + 8
- tNotifications[8].x = tempX + 2
- tNotifications[8].y = tempY + 9
- tNotifications[9].x = tempX + 2
- tNotifications[9].y = tempY + 10
- tNotifications[10].x = tempX + 2
- tNotifications[10].y = tempY + 11
- currentXN = tButtons["notification"].x
- currentYN = tButtons["notification"].y
- drawBackground()
- drawTime()
- end
- end
- elseif bNotification_msg and tButtons["notification_msg"].bDrag and currentXNM == tButtons["notification_msg"].x and currentYNM == tButtons["notification_msg"].y then
- bDragging = true
- if bDragging == true then
- sDragTime = os.startTimer(1)
- if X >= 1 and X <= (term_width - (tButtons["notification_msg"].w - 1)) and Y >= 2 and Y <= (term_height - tButtons["notification_msg"].h) then
- local tempX, tempY = X, Y
- tButtons["notification_msg"].x = tempX
- tButtons["notification_msg"].y = tempY
- currentXNM = tButtons["notification_msg"].x
- currentYNM = tButtons["notification_msg"].y
- drawBackground()
- drawTime()
- end
- end
- end
- end
- elseif event == "rednet_message" then
- local msg = X
- local id = button
- addNotification("Message from ID: "..id,
- msg,
- function()
- bNotification_msg = true
- sMessageFrom = id
- sMessageText = msg
- if #msg >= 18 then
- tButtons["notification_msg"].h = 6
- if #msg >= 36 then
- tButtons["notification_msg"].h = 7
- end
- end
- end)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement