about.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. package main
  2. import (
  3. "strings"
  4. "os/exec"
  5. "github.com/veandco/go-sdl2/ttf"
  6. "github.com/cuu/gogame/surface"
  7. "github.com/cuu/gogame/event"
  8. "github.com/cuu/gogame/rect"
  9. "github.com/cuu/gogame/color"
  10. "github.com/cuu/LauncherGo/sysgo/UI"
  11. )
  12. type InfoPageListItem struct{
  13. UI.Widget
  14. Labels map[string]UI.LabelInterface
  15. Icons map[string]UI.IconItemInterface
  16. Fonts map[string]*ttf.Font
  17. Parent UI.PageInterface
  18. Flag string
  19. }
  20. func NewInfoPageListItem() *InfoPageListItem {
  21. i := &InfoPageListItem{}
  22. i.Labels = make(map[string]UI.LabelInterface)
  23. i.Icons = make( map[string]UI.IconItemInterface)
  24. i.Fonts = make(map[string]*ttf.Font)
  25. i.Height = 20
  26. i.Width = 0
  27. return i
  28. }
  29. func (self *InfoPageListItem) Init(text string) {
  30. l := UI.NewLabel()
  31. l.PosX = 10
  32. l.SetCanvasHWND(self.Parent.GetCanvasHWND())
  33. l.Init(text,self.Fonts["normal"],nil)
  34. self.Labels["Text"] = l
  35. }
  36. func (self *InfoPageListItem) SetSmallText( text string) {
  37. l := UI.NewMultiLabel()
  38. l.SetCanvasHWND(self.Parent.GetCanvasHWND())
  39. l.Init(text,self.Fonts["small"],nil)
  40. self.Labels["Small"] = l
  41. _,h_ := self.Labels["Small"].Size()
  42. if h_>= self.Height {
  43. self.Height = h_ + 10
  44. }
  45. }
  46. func (self *InfoPageListItem) Draw() {
  47. x_,_ := self.Labels["Text"].Coord()
  48. self.Labels["Text"].NewCoord(x_,self.PosY)
  49. self.Labels["Text"].Draw()
  50. if _, ok := self.Labels["Small"]; ok {
  51. w_,_ := self.Labels["Text"].Size()
  52. self.Labels["Small"].NewCoord(w_+16,self.PosY)
  53. self.Labels["Small"].Draw()
  54. }
  55. }
  56. type AboutPage struct {
  57. UI.Page
  58. AList map[string]map[string]string
  59. ListFontObj *ttf.Font
  60. Scrolled int
  61. BGwidth int
  62. BGheight int
  63. DrawOnce bool
  64. Scroller *UI.ListScroller
  65. MyList []*InfoPageListItem
  66. }
  67. func NewAboutPage() *AboutPage {
  68. p := &HelloWorldPage{}
  69. p.FootMsg = [5]string{"Nav.","","","Back",""}
  70. p.AList = make(map[string]map[string]string)
  71. p.BGwidth = 320
  72. p.BGheight = 300
  73. p.DrawOnce = false
  74. p.MyList = make([]*InfoPageListItem,0)
  75. p.ListFontObj = UI.Fonts["varela13"]
  76. p.Index = 0
  77. return p
  78. }
  79. func (self *AboutPage) Uname() {
  80. out := make(map[string]string)
  81. out["key"] = "uname"
  82. out["label"] = "Kernel:"
  83. out_bytes, err := exec.Command("uname","-srmo").Output()
  84. if err != nil {
  85. fmt.Println(err)
  86. out["value"] = ""
  87. }
  88. out_str := strings.Trim(string(out_bytes), "\t\n")
  89. out["value"]= out_str
  90. self.AList["uname"] = out
  91. }
  92. func (self *AboutPage) CpuMhz() {
  93. }
  94. func (self *AboutPage) CpuInfo() {
  95. }
  96. func (self *AboutPage) MemInfo() {
  97. }
  98. func (self *AboutPage) GenList() {
  99. }