Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Constants
- local WIDTH = 51
- local HEIGHT = 10
- local SCROLL_STEP = 1
- local SCROLL_UP_KEY = keys.up
- local SCROLL_DOWN_KEY = keys.down
- -- Function to draw a filled rectangle
- function drawRect(x, y, width, height, color)
- term.setBackgroundColor(color)
- term.setCursorPos(x, y)
- term.clearLine()
- for i = 1, height do
- term.setCursorPos(x, y + i - 1)
- term.write(string.rep(" ", width))
- end
- end
- -- Function to draw text
- function drawText(x, y, text, color)
- term.setTextColor(color)
- term.setCursorPos(x, y)
- term.write(text)
- end
- -- Function to create a button
- function drawButton(x, y, width, text, bgColor, textColor)
- drawRect(x, y, width, 3, bgColor)
- drawText(x + 1, y + 1, text, textColor)
- end
- -- Function to draw the navigation bar
- function drawNavBar()
- drawRect(1, 6, WIDTH, 3, colors.gray)
- drawButton(2, 7, 10, "Home", colors.lightGray, colors.black)
- drawButton(13, 7, 15, "Features", colors.lightGray, colors.black)
- drawButton(30, 7, 12, "About", colors.lightGray, colors.black)
- drawButton(44, 7, 8, "Help", colors.lightGray, colors.black)
- end
- -- Function to render content with scrolling
- function drawScrollableContent(content, scrollOffset, pageHeight)
- -- Calculate the start and end of the visible content
- local startLine = scrollOffset + 1
- local endLine = math.min(scrollOffset + pageHeight, #content)
- -- Draw visible content
- for i = startLine, endLine do
- drawText(2, i - scrollOffset + 10, content[i], colors.white)
- end
- end
- -- Function to draw the main screen
- function drawMainScreen(scrollOffset)
- term.clear()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- -- Draw header
- drawRect(1, 1, WIDTH, 5, colors.blue)
- drawText(2, 2, "Doggy OS", colors.white)
- -- Draw navigation bar
- drawNavBar()
- -- Draw content area
- drawRect(1, 10, WIDTH, HEIGHT, colors.black)
- local content = {
- "Welcome to Doggy OS!",
- "A user-friendly and secure operating system.",
- "Designed with both novice and advanced users in mind.",
- "Explore our features and learn more about security and privacy.",
- "Navigate using function keys: F1, F4, F5, F6.",
- "Press F1 for Home, F4 for Features, F5 for About, and F6 for Help."
- }
- drawScrollableContent(content, scrollOffset, HEIGHT)
- end
- -- Function to draw the features page
- function drawFeaturesPage(scrollOffset)
- term.clear()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- -- Draw header
- drawRect(1, 1, WIDTH, 5, colors.blue)
- drawText(2, 2, "Doggy OS - Features", colors.white)
- -- Draw navigation bar
- drawNavBar()
- -- Draw content area
- drawRect(1, 10, WIDTH, HEIGHT, colors.black)
- local content = {
- "Features of Doggy OS:",
- "- User-friendly Interface",
- "- Customizable Settings",
- "- Fun and Interactive",
- "- Advanced Security Features",
- "- Privacy Controls",
- "- Regular Updates",
- "Discover more and customize to fit your needs.",
- "Explore these features to enhance your experience."
- }
- drawScrollableContent(content, scrollOffset, HEIGHT)
- end
- -- Function to draw the about page
- function drawAboutPage(scrollOffset)
- term.clear()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- -- Draw header
- drawRect(1, 1, WIDTH, 5, colors.blue)
- drawText(2, 2, "Doggy OS - About", colors.white)
- -- Draw navigation bar
- drawNavBar()
- -- Draw content area
- drawRect(1, 10, WIDTH, HEIGHT, colors.black)
- local content = {
- "Security & Privacy:",
- "Doggy OS prioritizes your security and privacy.",
- "Key features include:",
- "- Encrypted User Data",
- "- Regular Security Updates",
- "- Privacy-focused Design",
- "Choose between Advanced or Simple modes.",
- "Tailored to meet both casual and power users' needs."
- }
- drawScrollableContent(content, scrollOffset, HEIGHT)
- end
- -- Function to draw the help page
- function drawHelpPage(scrollOffset)
- term.clear()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- -- Draw header
- drawRect(1, 1, WIDTH, 5, colors.blue)
- drawText(2, 2, "Doggy OS - Help", colors.white)
- -- Draw navigation bar
- drawNavBar()
- -- Draw content area
- drawRect(1, 10, WIDTH, HEIGHT, colors.black)
- local content = {
- "Help & Instructions:",
- "Use the function keys to navigate:",
- "- F1: Home",
- "- F4: Features",
- "- F5: About",
- "- F6: Help",
- "Follow on-screen instructions for more details.",
- "For additional support, refer to the official documentation.",
- "Contact support if you need further assistance."
- }
- drawScrollableContent(content, scrollOffset, HEIGHT)
- end
- -- Function to handle user input
- function handleInput()
- local scrollOffset = 0
- local maxScroll = 10 -- Maximum number of lines that can be scrolled
- while true do
- local event, key = os.pullEvent("key")
- if key == keys.f1 then
- drawMainScreen(scrollOffset)
- elseif key == keys.f4 then
- drawFeaturesPage(scrollOffset)
- elseif key == keys.f5 then
- drawAboutPage(scrollOffset)
- elseif key == keys.f6 then
- drawHelpPage(scrollOffset)
- elseif key == SCROLL_UP_KEY then
- if scrollOffset > 0 then
- scrollOffset = scrollOffset - SCROLL_STEP
- drawFeaturesPage(scrollOffset) -- or drawAboutPage(scrollOffset), etc.
- end
- elseif key == SCROLL_DOWN_KEY then
- if scrollOffset < maxScroll then
- scrollOffset = scrollOffset + SCROLL_STEP
- drawFeaturesPage(scrollOffset) -- or drawAboutPage(scrollOffset), etc.
- end
- elseif key == keys.q then
- break
- end
- end
- end
- -- Main Program
- drawMainScreen(0)
- handleInput()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement