poweroff_confirm_page.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.Draw()
  23. self.Screen.SwapAndShow()
  24. }
  25. if ev.Data["Key"] == UI.CurKeys["B"] {
  26. cmdpath := ""
  27. if UI.CheckBattery() < 20 {
  28. cmdpath = "feh --bg-center sysgo/gameshell/wallpaper/gameover.png;"
  29. } else {
  30. cmdpath = "feh --bg-center sysgo/gameshell/wallpaper/seeyou.png;"
  31. }
  32. cmdpath = cmdpath + "sleep 3;"
  33. cmdpath = cmdpath + "sudo halt -p"
  34. event.Post(UI.RUNSYS, cmdpath)
  35. }
  36. if ev.Data["Key"] == UI.CurKeys["X"] {
  37. cmdpath := "feh --bg-center sysgo/gameshell/wallpaper/seeyou.png;"
  38. cmdpath += "sleep 3;"
  39. cmdpath += "sudo reboot"
  40. event.Post(UI.RUNSYS, cmdpath)
  41. }
  42. }