Advertisement
DOGGYWOOF

Untitled

Aug 24th, 2024 (edited)
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.12 KB | None | 0 0
  1. -- Constants
  2. local WIDTH = 51
  3. local HEIGHT = 10
  4. local SCROLL_STEP = 1
  5. local SCROLL_UP_KEY = keys.up
  6. local SCROLL_DOWN_KEY = keys.down
  7.  
  8. -- Function to draw a filled rectangle
  9. function drawRect(x, y, width, height, color)
  10. term.setBackgroundColor(color)
  11. term.setCursorPos(x, y)
  12. term.clearLine()
  13. for i = 1, height do
  14. term.setCursorPos(x, y + i - 1)
  15. term.write(string.rep(" ", width))
  16. end
  17. end
  18.  
  19. -- Function to draw text
  20. function drawText(x, y, text, color)
  21. term.setTextColor(color)
  22. term.setCursorPos(x, y)
  23. term.write(text)
  24. end
  25.  
  26. -- Function to create a button
  27. function drawButton(x, y, width, text, bgColor, textColor)
  28. drawRect(x, y, width, 3, bgColor)
  29. drawText(x + 1, y + 1, text, textColor)
  30. end
  31.  
  32. -- Function to draw the navigation bar
  33. function drawNavBar()
  34. drawRect(1, 6, WIDTH, 3, colors.gray)
  35. drawButton(2, 7, 10, "Home", colors.lightGray, colors.black)
  36. drawButton(13, 7, 15, "Features", colors.lightGray, colors.black)
  37. drawButton(30, 7, 12, "About", colors.lightGray, colors.black)
  38. drawButton(44, 7, 8, "Help", colors.lightGray, colors.black)
  39. end
  40.  
  41. -- Function to render content with scrolling
  42. function drawScrollableContent(content, scrollOffset, pageHeight)
  43. -- Calculate the start and end of the visible content
  44. local startLine = scrollOffset + 1
  45. local endLine = math.min(scrollOffset + pageHeight, #content)
  46.  
  47. -- Draw visible content
  48. for i = startLine, endLine do
  49. drawText(2, i - scrollOffset + 10, content[i], colors.white)
  50. end
  51. end
  52.  
  53. -- Function to draw the main screen
  54. function drawMainScreen(scrollOffset)
  55. term.clear()
  56. term.setBackgroundColor(colors.black)
  57. term.setTextColor(colors.white)
  58.  
  59. -- Draw header
  60. drawRect(1, 1, WIDTH, 5, colors.blue)
  61. drawText(2, 2, "Doggy OS", colors.white)
  62.  
  63. -- Draw navigation bar
  64. drawNavBar()
  65.  
  66. -- Draw content area
  67. drawRect(1, 10, WIDTH, HEIGHT, colors.black)
  68. local content = {
  69. "Welcome to Doggy OS!",
  70. "A user-friendly and secure operating system.",
  71. "Designed with both novice and advanced users in mind.",
  72. "Explore our features and learn more about security and privacy.",
  73. "Navigate using function keys: F1, F4, F5, F6.",
  74. "Press F1 for Home, F4 for Features, F5 for About, and F6 for Help."
  75. }
  76. drawScrollableContent(content, scrollOffset, HEIGHT)
  77. end
  78.  
  79. -- Function to draw the features page
  80. function drawFeaturesPage(scrollOffset)
  81. term.clear()
  82. term.setBackgroundColor(colors.black)
  83. term.setTextColor(colors.white)
  84.  
  85. -- Draw header
  86. drawRect(1, 1, WIDTH, 5, colors.blue)
  87. drawText(2, 2, "Doggy OS - Features", colors.white)
  88.  
  89. -- Draw navigation bar
  90. drawNavBar()
  91.  
  92. -- Draw content area
  93. drawRect(1, 10, WIDTH, HEIGHT, colors.black)
  94. local content = {
  95. "Features of Doggy OS:",
  96. "- User-friendly Interface",
  97. "- Customizable Settings",
  98. "- Fun and Interactive",
  99. "- Advanced Security Features",
  100. "- Privacy Controls",
  101. "- Regular Updates",
  102. "Discover more and customize to fit your needs.",
  103. "Explore these features to enhance your experience."
  104. }
  105. drawScrollableContent(content, scrollOffset, HEIGHT)
  106. end
  107.  
  108. -- Function to draw the about page
  109. function drawAboutPage(scrollOffset)
  110. term.clear()
  111. term.setBackgroundColor(colors.black)
  112. term.setTextColor(colors.white)
  113.  
  114. -- Draw header
  115. drawRect(1, 1, WIDTH, 5, colors.blue)
  116. drawText(2, 2, "Doggy OS - About", colors.white)
  117.  
  118. -- Draw navigation bar
  119. drawNavBar()
  120.  
  121. -- Draw content area
  122. drawRect(1, 10, WIDTH, HEIGHT, colors.black)
  123. local content = {
  124. "Security & Privacy:",
  125. "Doggy OS prioritizes your security and privacy.",
  126. "Key features include:",
  127. "- Encrypted User Data",
  128. "- Regular Security Updates",
  129. "- Privacy-focused Design",
  130. "Choose between Advanced or Simple modes.",
  131. "Tailored to meet both casual and power users' needs."
  132. }
  133. drawScrollableContent(content, scrollOffset, HEIGHT)
  134. end
  135.  
  136. -- Function to draw the help page
  137. function drawHelpPage(scrollOffset)
  138. term.clear()
  139. term.setBackgroundColor(colors.black)
  140. term.setTextColor(colors.white)
  141.  
  142. -- Draw header
  143. drawRect(1, 1, WIDTH, 5, colors.blue)
  144. drawText(2, 2, "Doggy OS - Help", colors.white)
  145.  
  146. -- Draw navigation bar
  147. drawNavBar()
  148.  
  149. -- Draw content area
  150. drawRect(1, 10, WIDTH, HEIGHT, colors.black)
  151. local content = {
  152. "Help & Instructions:",
  153. "Use the function keys to navigate:",
  154. "- F1: Home",
  155. "- F4: Features",
  156. "- F5: About",
  157. "- F6: Help",
  158. "Follow on-screen instructions for more details.",
  159. "For additional support, refer to the official documentation.",
  160. "Contact support if you need further assistance."
  161. }
  162. drawScrollableContent(content, scrollOffset, HEIGHT)
  163. end
  164.  
  165. -- Function to handle user input
  166. function handleInput()
  167. local scrollOffset = 0
  168. local maxScroll = 10 -- Maximum number of lines that can be scrolled
  169.  
  170. while true do
  171. local event, key = os.pullEvent("key")
  172. if key == keys.f1 then
  173. drawMainScreen(scrollOffset)
  174. elseif key == keys.f4 then
  175. drawFeaturesPage(scrollOffset)
  176. elseif key == keys.f5 then
  177. drawAboutPage(scrollOffset)
  178. elseif key == keys.f6 then
  179. drawHelpPage(scrollOffset)
  180. elseif key == SCROLL_UP_KEY then
  181. if scrollOffset > 0 then
  182. scrollOffset = scrollOffset - SCROLL_STEP
  183. drawFeaturesPage(scrollOffset) -- or drawAboutPage(scrollOffset), etc.
  184. end
  185. elseif key == SCROLL_DOWN_KEY then
  186. if scrollOffset < maxScroll then
  187. scrollOffset = scrollOffset + SCROLL_STEP
  188. drawFeaturesPage(scrollOffset) -- or drawAboutPage(scrollOffset), etc.
  189. end
  190. elseif key == keys.q then
  191. break
  192. end
  193. end
  194. end
  195.  
  196. -- Main Program
  197. drawMainScreen(0)
  198. handleInput()
  199.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement