poweroff_confirm_page.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package PowerOFF
  2. import (
  3. "github.com/clockworkpi/LauncherGoDev/sysgo/UI"
  4. "github.com/cuu/gogame/event"
  5. )
  6. type PowerOFFConfirmPage struct {
  7. UI.ConfirmPage
  8. }
  9. func NewPowerOFFConfirmPage() *PowerOFFConfirmPage {
  10. p := &PowerOFFConfirmPage{}
  11. p.ListFont = UI.Fonts["veramono20"]
  12. p.ConfirmText = "Awaiting Input"
  13. p.FootMsg = [5]string{"Nav", "Reboot", "", "Cancel", "Shutdown"}
  14. p.ConfirmPage.ConfirmText = p.ConfirmText
  15. p.ConfirmPage.FootMsg = p.FootMsg
  16. p.ConfirmPage.ListFont = p.ListFont
  17. return p
  18. }
  19. func (self *PowerOFFConfirmPage) KeyDown(ev *event.Event) {
  20. if ev.Data["Key"] == UI.CurKeys["Menu"] || ev.Data["Key"] == UI.CurKeys["A"] {
  21. self.ReturnToUpLevelPage()
  22. self.Screen.Refresh()
  23. }
  24. if ev.Data["Key"] == UI.CurKeys["B"] {
  25. cmdpath := ""
  26. if UI.CheckBattery() < 20 {
  27. cmdpath = "feh --bg-center sysgo/gameshell/wallpaper/gameover.png;"
  28. } else {
  29. cmdpath = "feh --bg-center sysgo/gameshell/wallpaper/seeyou.png;"
  30. }
  31. cmdpath = cmdpath + "sleep 3;"
  32. cmdpath = cmdpath + "sudo halt -p"
  33. event.Post(UI.RUNSYS, cmdpath)
  34. }
  35. if ev.Data["Key"] == UI.CurKeys["X"] {
  36. cmdpath := "feh --bg-center sysgo/gameshell/wallpaper/seeyou.png;"
  37. cmdpath += "sleep 3;"
  38. cmdpath += "sudo reboot"
  39. event.Post(UI.RUNSYS, cmdpath)
  40. }
  41. }