Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Dogdroid.lua
- local Dogdroid = {}
- -- navbar submodule
- Dogdroid.navbar = {}
- -- Function to draw navigation bar and return button coordinates
- function Dogdroid.navbar.draw()
- local screenWidth, screenHeight = term.getSize()
- local navBarWidth = 20
- local navBarStart = math.floor((screenWidth - navBarWidth) / 2)
- -- Save current cursor position
- local oldX, oldY = term.getCursorPos()
- -- Draw Home button
- term.setCursorPos(navBarStart + 5, screenHeight)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.write(" () ")
- -- Draw Recents button
- term.setCursorPos(navBarStart + 10, screenHeight)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.write(" lll ")
- -- Draw Back button
- term.setCursorPos(navBarStart + 15, screenHeight)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.write(" < ")
- -- Restore cursor position
- term.setCursorPos(oldX, oldY)
- -- Return button coordinates
- return {
- home = { x = navBarStart + 5, y = screenHeight },
- recents = { x = navBarStart + 10, y = screenHeight },
- back = { x = navBarStart + 15, y = screenHeight }
- }
- end
- -- Function to handle mouse clicks on navbar
- function Dogdroid.navbar.handleButtonClick(navButtons)
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- if event == "mouse_click" and button == 1 then
- -- Check if clicked on any navigation button
- if x >= navButtons.home.x and x <= navButtons.home.x + 3 and y == navButtons.home.y then
- shell.run("/disk/os/gui")
- return
- elseif x >= navButtons.recents.x and x <= navButtons.recents.x + 3 and y == navButtons.recents.y then
- shell.run("/disk/os/recents")
- elseif x >= navButtons.back.x and x <= navButtons.back.x + 3 and y == navButtons.back.y then
- -- Handle back button action if needed
- end
- end
- end
- end
- return Dogdroid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement