mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2026-03-19 10:22:41 +01:00
go fmt ./...
This commit is contained in:
@@ -1,87 +1,77 @@
|
||||
package Emulator
|
||||
|
||||
import (
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
)
|
||||
|
||||
type ActionConfig struct {
|
||||
ROM string `ini:"ROM"`
|
||||
ROM_SO string `ini:"ROM_SO"`
|
||||
EXT []string `ini:"EXT,omitempty"`
|
||||
EXCLUDE []string `ini:"EXCLUDE,omitempty"`
|
||||
FILETYPE string `ini:"FILETYPE"` // defalut is file
|
||||
LAUNCHER string `ini:"LAUNCHER"`
|
||||
TITLE string `ini:"TITLE"` // defaut is Game
|
||||
SO_URL string `ini:"SO_URL"`
|
||||
RETRO_CONFIG string `ini:"RETRO_CONFIG"`
|
||||
ROM string `ini:"ROM"`
|
||||
ROM_SO string `ini:"ROM_SO"`
|
||||
EXT []string `ini:"EXT,omitempty"`
|
||||
EXCLUDE []string `ini:"EXCLUDE,omitempty"`
|
||||
FILETYPE string `ini:"FILETYPE"` // defalut is file
|
||||
LAUNCHER string `ini:"LAUNCHER"`
|
||||
TITLE string `ini:"TITLE"` // defaut is Game
|
||||
SO_URL string `ini:"SO_URL"`
|
||||
RETRO_CONFIG string `ini:"RETRO_CONFIG"`
|
||||
}
|
||||
|
||||
|
||||
var (
|
||||
FavGID = 31415
|
||||
FavGname = "cpifav"
|
||||
|
||||
FavGID = 31415
|
||||
FavGname = "cpifav"
|
||||
)
|
||||
|
||||
|
||||
type MyEmulator struct { // as leader of RomListPage and FavListPage, it's a PluginInterface
|
||||
Name string
|
||||
RomPage *RomListPage
|
||||
FavPage *FavListPage
|
||||
DeleteConfirmPage *UI.DeleteConfirmPage
|
||||
EmulatorConfig *ActionConfig
|
||||
|
||||
SpeedMax int
|
||||
SpeedTimeInter int
|
||||
|
||||
Name string
|
||||
RomPage *RomListPage
|
||||
FavPage *FavListPage
|
||||
DeleteConfirmPage *UI.DeleteConfirmPage
|
||||
EmulatorConfig *ActionConfig
|
||||
|
||||
SpeedMax int
|
||||
SpeedTimeInter int
|
||||
}
|
||||
|
||||
func NewMyEmulator() *MyEmulator{
|
||||
p := &MyEmulator{}
|
||||
|
||||
p.SpeedMax = 5
|
||||
p.SpeedTimeInter = 300
|
||||
|
||||
return p
|
||||
func NewMyEmulator() *MyEmulator {
|
||||
p := &MyEmulator{}
|
||||
|
||||
p.SpeedMax = 5
|
||||
p.SpeedTimeInter = 300
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *MyEmulator) GetName() string {
|
||||
return "MyEmulator"
|
||||
return "MyEmulator"
|
||||
}
|
||||
|
||||
func (self *MyEmulator) Init(main_screen *UI.MainScreen) {
|
||||
self.DeleteConfirmPage = UI.NewDeleteConfirmPage()
|
||||
self.DeleteConfirmPage.Screen = main_screen
|
||||
self.DeleteConfirmPage.Name = "Delete Confirm"
|
||||
self.DeleteConfirmPage.Init()
|
||||
func (self *MyEmulator) Init(main_screen *UI.MainScreen) {
|
||||
self.DeleteConfirmPage = UI.NewDeleteConfirmPage()
|
||||
self.DeleteConfirmPage.Screen = main_screen
|
||||
self.DeleteConfirmPage.Name = "Delete Confirm"
|
||||
self.DeleteConfirmPage.Init()
|
||||
|
||||
self.RomPage = NewRomListPage()
|
||||
self.RomPage.Screen = main_screen
|
||||
self.RomPage.Name = self.EmulatorConfig.TITLE
|
||||
self.RomPage.EmulatorConfig = self.EmulatorConfig
|
||||
self.RomPage.Leader = self
|
||||
self.RomPage.Init()
|
||||
|
||||
self.FavPage = NewFavListPage()
|
||||
self.FavPage.Screen = main_screen
|
||||
self.FavPage.Name = "FavouriteGames"
|
||||
self.FavPage.EmulatorConfig = self.EmulatorConfig
|
||||
self.FavPage.Leader = self
|
||||
self.FavPage.Init()
|
||||
|
||||
self.RomPage = NewRomListPage()
|
||||
self.RomPage.Screen = main_screen
|
||||
self.RomPage.Name = self.EmulatorConfig.TITLE
|
||||
self.RomPage.EmulatorConfig = self.EmulatorConfig
|
||||
self.RomPage.Leader = self
|
||||
self.RomPage.Init()
|
||||
|
||||
self.FavPage = NewFavListPage()
|
||||
self.FavPage.Screen = main_screen
|
||||
self.FavPage.Name = "FavouriteGames"
|
||||
self.FavPage.EmulatorConfig = self.EmulatorConfig
|
||||
self.FavPage.Leader = self
|
||||
self.FavPage.Init()
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
func (self *MyEmulator) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.RomPage)
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.RomPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,118 +1,112 @@
|
||||
package Emulator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
//"github.com/veandco/go-sdl2/sdl"
|
||||
"fmt"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
//"github.com/veandco/go-sdl2/sdl"
|
||||
//"github.com/cuu/gogame/surface"
|
||||
//"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
//"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
|
||||
)
|
||||
|
||||
type EmulatorPageInterface interface {
|
||||
UI.PageInterface
|
||||
GetMapIcons() map[string]UI.IconItemInterface
|
||||
GetEmulatorConfig() *ActionConfig
|
||||
type EmulatorPageInterface interface {
|
||||
UI.PageInterface
|
||||
GetMapIcons() map[string]UI.IconItemInterface
|
||||
GetEmulatorConfig() *ActionConfig
|
||||
}
|
||||
|
||||
|
||||
type EmulatorListItem struct {
|
||||
UI.HierListItem
|
||||
Parent EmulatorPageInterface
|
||||
UI.HierListItem
|
||||
Parent EmulatorPageInterface
|
||||
}
|
||||
|
||||
func NewEmulatorListItem() *EmulatorListItem {
|
||||
p := &EmulatorListItem{}
|
||||
p.Labels = make(map[string]UI.LabelInterface)
|
||||
p.Icons = make( map[string]UI.IconItemInterface)
|
||||
p.Fonts = make(map[string]*ttf.Font)
|
||||
|
||||
p.MyType = UI.ICON_TYPES["EXE"]
|
||||
p := &EmulatorListItem{}
|
||||
p.Labels = make(map[string]UI.LabelInterface)
|
||||
p.Icons = make(map[string]UI.IconItemInterface)
|
||||
p.Fonts = make(map[string]*ttf.Font)
|
||||
|
||||
p.MyType = UI.ICON_TYPES["EXE"]
|
||||
p.Height = 32
|
||||
p.Width = 0
|
||||
|
||||
|
||||
return p
|
||||
p.Width = 0
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *EmulatorListItem) Init(text string) {
|
||||
l := UI.NewLabel()
|
||||
l.PosX = 20
|
||||
l := UI.NewLabel()
|
||||
l.PosX = 20
|
||||
|
||||
l.SetCanvasHWND(self.Parent.GetCanvasHWND())
|
||||
|
||||
if self.IsDir() == true || self.IsFile() == true {
|
||||
self.Path = text
|
||||
}
|
||||
|
||||
label_text := filepath.Base(text)
|
||||
ext:= filepath.Ext(text)
|
||||
if ext != "" {
|
||||
alias_file := strings.Replace(text,ext,"",-1) + ".alias"
|
||||
|
||||
if UI.FileExists(alias_file) == true {
|
||||
b, err := ioutil.ReadFile(alias_file)
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}else {
|
||||
label_text = string(b)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if self.IsDir() == true {
|
||||
l.Init(label_text, self.Fonts["normal"],nil)
|
||||
}else {
|
||||
l.Init(label_text,self.Fonts["normal"],nil)
|
||||
}
|
||||
|
||||
self.Labels["Text"] = l
|
||||
l.SetCanvasHWND(self.Parent.GetCanvasHWND())
|
||||
|
||||
if self.IsDir() == true || self.IsFile() == true {
|
||||
self.Path = text
|
||||
}
|
||||
|
||||
label_text := filepath.Base(text)
|
||||
ext := filepath.Ext(text)
|
||||
if ext != "" {
|
||||
alias_file := strings.Replace(text, ext, "", -1) + ".alias"
|
||||
|
||||
if UI.FileExists(alias_file) == true {
|
||||
b, err := ioutil.ReadFile(alias_file)
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
} else {
|
||||
label_text = string(b)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if self.IsDir() == true {
|
||||
l.Init(label_text, self.Fonts["normal"], nil)
|
||||
} else {
|
||||
l.Init(label_text, self.Fonts["normal"], nil)
|
||||
}
|
||||
|
||||
self.Labels["Text"] = l
|
||||
}
|
||||
|
||||
func (self *EmulatorListItem) Draw() {
|
||||
x,y := self.Labels["Text"].Coord()
|
||||
_,h := self.Labels["Text"].Size()
|
||||
|
||||
|
||||
if self.Path != "[..]" {
|
||||
self.Labels["Text"].NewCoord(23,y)
|
||||
|
||||
}else {
|
||||
self.Labels["Text"].NewCoord(3,y)
|
||||
}
|
||||
|
||||
x,y = self.Labels["Text"].Coord()
|
||||
self.Labels["Text"].NewCoord(x, self.PosY + (self.Height-h)/2)
|
||||
|
||||
self.Labels["Text"].Draw()
|
||||
|
||||
parent_icons := self.Parent.GetMapIcons()
|
||||
_,h = parent_icons["sys"].Size()
|
||||
|
||||
if self.IsDir() == true && self.Path != "[..]" {
|
||||
parent_icons["sys"].SetIconIndex (0)
|
||||
parent_icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
|
||||
parent_icons["sys"].Draw()
|
||||
}
|
||||
|
||||
if self.IsFile() == true {
|
||||
parent_icons["sys"].SetIconIndex(1)
|
||||
parent_icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
|
||||
parent_icons["sys"].Draw()
|
||||
}
|
||||
|
||||
draw.Line(self.Parent.GetCanvasHWND(),&color.Color{169,169,169,255},
|
||||
self.PosX,self.PosY+self.Height-1,self.PosX+self.Width,self.PosY+self.Height-1,1)
|
||||
x, y := self.Labels["Text"].Coord()
|
||||
_, h := self.Labels["Text"].Size()
|
||||
|
||||
if self.Path != "[..]" {
|
||||
self.Labels["Text"].NewCoord(23, y)
|
||||
|
||||
} else {
|
||||
self.Labels["Text"].NewCoord(3, y)
|
||||
}
|
||||
|
||||
x, y = self.Labels["Text"].Coord()
|
||||
self.Labels["Text"].NewCoord(x, self.PosY+(self.Height-h)/2)
|
||||
|
||||
self.Labels["Text"].Draw()
|
||||
|
||||
parent_icons := self.Parent.GetMapIcons()
|
||||
_, h = parent_icons["sys"].Size()
|
||||
|
||||
if self.IsDir() == true && self.Path != "[..]" {
|
||||
parent_icons["sys"].SetIconIndex(0)
|
||||
parent_icons["sys"].NewCoord(self.PosX+12, self.PosY+(self.Height-h)/2+h/2)
|
||||
parent_icons["sys"].Draw()
|
||||
}
|
||||
|
||||
if self.IsFile() == true {
|
||||
parent_icons["sys"].SetIconIndex(1)
|
||||
parent_icons["sys"].NewCoord(self.PosX+12, self.PosY+(self.Height-h)/2+h/2)
|
||||
parent_icons["sys"].Draw()
|
||||
}
|
||||
|
||||
draw.Line(self.Parent.GetCanvasHWND(), &color.Color{169, 169, 169, 255},
|
||||
self.PosX, self.PosY+self.Height-1, self.PosX+self.Width, self.PosY+self.Height-1, 1)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,122 +1,119 @@
|
||||
package Emulator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
//"strconv"
|
||||
"strings"
|
||||
|
||||
"path/filepath"
|
||||
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"fmt"
|
||||
//"strconv"
|
||||
"strings"
|
||||
|
||||
"path/filepath"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
"github.com/cuu/gogame/event"
|
||||
)
|
||||
|
||||
type RomSoConfirmPage struct {
|
||||
UI.ConfirmPage
|
||||
Parent EmulatorPageInterface
|
||||
DownloadPage *UI.DownloadProcessPage
|
||||
|
||||
UI.ConfirmPage
|
||||
Parent EmulatorPageInterface
|
||||
DownloadPage *UI.DownloadProcessPage
|
||||
}
|
||||
|
||||
func NewRomSoConfirmPage() *RomSoConfirmPage {
|
||||
p := &RomSoConfirmPage{}
|
||||
p.PageIconMargin = 20
|
||||
p := &RomSoConfirmPage{}
|
||||
p.PageIconMargin = 20
|
||||
p.SelectedIconTopOffset = 20
|
||||
p.EasingDur = 10
|
||||
p.Align = UI.ALIGN["SLeft"]
|
||||
|
||||
p.ListFont = UI.Fonts["veramono18"]
|
||||
p.FootMsg = [5]string{"Nav","","","Cancel","Yes"}
|
||||
p.ConfirmText ="Do you want to setup this game engine automatically?"
|
||||
|
||||
return p
|
||||
|
||||
|
||||
p.ListFont = UI.Fonts["veramono18"]
|
||||
p.FootMsg = [5]string{"Nav", "", "", "Cancel", "Yes"}
|
||||
p.ConfirmText = "Do you want to setup this game engine automatically?"
|
||||
|
||||
return p
|
||||
|
||||
}
|
||||
|
||||
func (self *RomSoConfirmPage) Init() {
|
||||
self.PosX = self.Index * self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
self.PosX = self.Index * self.Screen.Width
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
|
||||
li := UI.NewMultiLabel()
|
||||
li.SetCanvasHWND(self.CanvasHWND)
|
||||
li.Width = 160
|
||||
li.Init(self.ConfirmText,self.ListFont,nil)
|
||||
|
||||
li.PosX = (self.Width - li.Width)/2
|
||||
li.PosY = (self.Height - li.Height)/2
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
|
||||
li := UI.NewMultiLabel()
|
||||
li.SetCanvasHWND(self.CanvasHWND)
|
||||
li.Width = 160
|
||||
li.Init(self.ConfirmText, self.ListFont, nil)
|
||||
|
||||
li.PosX = (self.Width - li.Width) / 2
|
||||
li.PosY = (self.Height - li.Height) / 2
|
||||
|
||||
self.BGPosX = li.PosX - 20
|
||||
self.BGPosY = li.PosY - 20
|
||||
self.BGWidth = li.Width + 40
|
||||
self.BGHeight = li.Height + 40
|
||||
|
||||
self.MyList = append(self.MyList, li)
|
||||
|
||||
self.BGPosX = li.PosX-20
|
||||
self.BGPosY = li.PosY-20
|
||||
self.BGWidth = li.Width+40
|
||||
self.BGHeight = li.Height+40
|
||||
|
||||
self.MyList = append(self.MyList ,li )
|
||||
|
||||
}
|
||||
|
||||
func (self *RomSoConfirmPage) SnapMsg(msg string) {
|
||||
self.MyList[0].SetText(msg)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
self.MyList[0].SetText(self.ConfirmText)
|
||||
self.MyList[0].SetText(msg)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
self.MyList[0].SetText(self.ConfirmText)
|
||||
}
|
||||
|
||||
func (self *RomSoConfirmPage) OnReturnBackCb() {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
func (self *RomSoConfirmPage) KeyDown(ev *event.Event) {
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Menu"] || ev.Data["Key"] == UI.CurKeys["A"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
bat := UI.CheckBattery()
|
||||
if bat < 5 && bat >= 0 {
|
||||
self.SnapMsg("Battery must over 5%")
|
||||
}else { // -1 or something else,
|
||||
if self.DownloadPage == nil {
|
||||
self.DownloadPage = UI.NewDownloadProcessPage()
|
||||
self.DownloadPage.Screen = self.Screen
|
||||
self.DownloadPage.Name = "Downloading"
|
||||
self.DownloadPage.Init()
|
||||
}
|
||||
|
||||
self.Screen.PushPage(self.DownloadPage)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
ec := self.Parent.GetEmulatorConfig()
|
||||
if sysgo.CurKeySet == "PC" {
|
||||
|
||||
so_url := ec.SO_URL
|
||||
so_url = strings.Replace(so_url,"armhf","x86_64",-1)
|
||||
fmt.Println(so_url)
|
||||
self.DownloadPage.StartDownload(so_url,filepath.Dir(ec.ROM_SO))
|
||||
|
||||
}else{
|
||||
so_url := ec.SO_URL
|
||||
go self.DownloadPage.StartDownload(so_url,filepath.Dir(ec.ROM_SO))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Menu"] || ev.Data["Key"] == UI.CurKeys["A"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["B"] {
|
||||
bat := UI.CheckBattery()
|
||||
if bat < 5 && bat >= 0 {
|
||||
self.SnapMsg("Battery must over 5%")
|
||||
} else { // -1 or something else,
|
||||
if self.DownloadPage == nil {
|
||||
self.DownloadPage = UI.NewDownloadProcessPage()
|
||||
self.DownloadPage.Screen = self.Screen
|
||||
self.DownloadPage.Name = "Downloading"
|
||||
self.DownloadPage.Init()
|
||||
}
|
||||
|
||||
self.Screen.PushPage(self.DownloadPage)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
ec := self.Parent.GetEmulatorConfig()
|
||||
if sysgo.CurKeySet == "PC" {
|
||||
|
||||
so_url := ec.SO_URL
|
||||
so_url = strings.Replace(so_url, "armhf", "x86_64", -1)
|
||||
fmt.Println(so_url)
|
||||
self.DownloadPage.StartDownload(so_url, filepath.Dir(ec.ROM_SO))
|
||||
|
||||
} else {
|
||||
so_url := ec.SO_URL
|
||||
go self.DownloadPage.StartDownload(so_url, filepath.Dir(ec.ROM_SO))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (self *RomSoConfirmPage) Draw() {
|
||||
self.ClearCanvas()
|
||||
self.DrawBG()
|
||||
for _,v := range self.MyList{
|
||||
v.Draw()
|
||||
}
|
||||
|
||||
self.ClearCanvas()
|
||||
self.DrawBG()
|
||||
for _, v := range self.MyList {
|
||||
v.Draw()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user