rom_so_confirm_page.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package Emulator
  2. import (
  3. "fmt"
  4. //"strconv"
  5. "strings"
  6. "path/filepath"
  7. "github.com/cuu/gogame/event"
  8. "github.com/clockworkpi/LauncherGoDev/sysgo"
  9. "github.com/clockworkpi/LauncherGoDev/sysgo/UI"
  10. )
  11. type RomSoConfirmPage struct {
  12. UI.ConfirmPage
  13. Parent EmulatorPageInterface
  14. DownloadPage *UI.DownloadProcessPage
  15. }
  16. func NewRomSoConfirmPage() *RomSoConfirmPage {
  17. p := &RomSoConfirmPage{}
  18. p.PageIconMargin = 20
  19. p.SelectedIconTopOffset = 20
  20. p.EasingDur = 10
  21. p.Align = UI.ALIGN["SLeft"]
  22. p.ListFont = UI.Fonts["veramono18"]
  23. p.FootMsg = [5]string{"Nav","","","Cancel","Yes"}
  24. p.ConfirmText ="Do you want to setup this game engine automatically?"
  25. return p
  26. }
  27. func (self *RomSoConfirmPage) Init() {
  28. self.PosX = self.Index * self.Screen.Width
  29. self.Width = self.Screen.Width
  30. self.Height = self.Screen.Height
  31. self.CanvasHWND = self.Screen.CanvasHWND
  32. li := UI.NewMultiLabel()
  33. li.SetCanvasHWND(self.CanvasHWND)
  34. li.Width = 160
  35. li.Init(self.ConfirmText,self.ListFont,nil)
  36. li.PosX = (self.Width - li.Width)/2
  37. li.PosY = (self.Height - li.Height)/2
  38. self.BGPosX = li.PosX-20
  39. self.BGPosY = li.PosY-20
  40. self.BGWidth = li.Width+40
  41. self.BGHeight = li.Height+40
  42. self.MyList = append(self.MyList ,li )
  43. }
  44. func (self *RomSoConfirmPage) SnapMsg(msg string) {
  45. self.MyList[0].SetText(msg)
  46. self.Screen.Draw()
  47. self.Screen.SwapAndShow()
  48. self.MyList[0].SetText(self.ConfirmText)
  49. }
  50. func (self *RomSoConfirmPage) OnReturnBackCb() {
  51. self.ReturnToUpLevelPage()
  52. self.Screen.Draw()
  53. self.Screen.SwapAndShow()
  54. }
  55. func (self *RomSoConfirmPage) KeyDown(ev *event.Event) {
  56. if ev.Data["Key"] == UI.CurKeys["Menu"] || ev.Data["Key"] == UI.CurKeys["A"] {
  57. self.ReturnToUpLevelPage()
  58. self.Screen.Draw()
  59. self.Screen.SwapAndShow()
  60. }
  61. if ev.Data["Key"] == UI.CurKeys["B"] {
  62. bat := UI.CheckBattery()
  63. if bat < 5 && bat >= 0 {
  64. self.SnapMsg("Battery must over 5%")
  65. }else { // -1 or something else,
  66. if self.DownloadPage == nil {
  67. self.DownloadPage = UI.NewDownloadProcessPage()
  68. self.DownloadPage.Screen = self.Screen
  69. self.DownloadPage.Name = "Downloading"
  70. self.DownloadPage.Init()
  71. }
  72. self.Screen.PushPage(self.DownloadPage)
  73. self.Screen.Draw()
  74. self.Screen.SwapAndShow()
  75. ec := self.Parent.GetEmulatorConfig()
  76. if sysgo.CurKeySet == "PC" {
  77. so_url := ec.SO_URL
  78. so_url = strings.Replace(so_url,"armhf","x86_64",-1)
  79. fmt.Println(so_url)
  80. self.DownloadPage.StartDownload(so_url,filepath.Dir(ec.ROM_SO))
  81. }else{
  82. so_url := ec.SO_URL
  83. self.DownloadPage.StartDownload(so_url,filepath.Dir(ec.ROM_SO))
  84. }
  85. }
  86. }
  87. }
  88. func (self *RomSoConfirmPage) Draw() {
  89. self.ClearCanvas()
  90. self.DrawBG()
  91. for _,v := range self.MyList{
  92. v.Draw()
  93. }
  94. }