mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-12 16:08:52 +01:00
UI Emulator
This commit is contained in:
parent
babe981c68
commit
8746a98d3b
@ -1,7 +1,9 @@
|
||||
ROM=/home/cpi/games/MAME
|
||||
ROM_SO=/home/cpi/apps/emulators/mame2003_plus_libretro.so
|
||||
EXT=zip
|
||||
LAUNCHER=retroarch -L
|
||||
TITLE=MAME Roms
|
||||
SO_URL=http://buildbot.libretro.com/nightly/linux/armhf/latest/mame2003_plus_libretro.so.zip
|
||||
RETRO_CONFIG=/home/cpi/apps/launcher/Menu/GameShell/20_Retro\ Games/MAME/retroarch.cfg
|
||||
{
|
||||
"ROM":"/home/cpi/games/MAME",
|
||||
"ROM_SO":"/home/cpi/apps/emulators/mame2003_plus_libretro.so",
|
||||
"EXT":["zip"],
|
||||
"LAUNCHER":"retroarch -L",
|
||||
"TITLE":"MAME Roms",
|
||||
"EXCLUDE":["neogeo.zip"],
|
||||
"SO_URL":"http://buildbot.libretro.com/nightly/linux/armhf/latest/mame2003_plus_libretro.so.zip"
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
ROM=/home/cpi/games/MGBA
|
||||
ROM_SO=/home/cpi/apps/emulators/mgba_libretro.so
|
||||
EXT=gba,gbx
|
||||
LAUNCHER=retroarch -L
|
||||
TITLE=MGBA Roms
|
||||
SO_URL=http://buildbot.libretro.com/nightly/linux/armhf/latest/mgba_libretro.so.zip
|
||||
{
|
||||
"ROM":"/home/cpi/games/MGBA",
|
||||
"ROM_SO":"/home/cpi/apps/emulators/mgba_libretro.so",
|
||||
"EXT":["gba","gbx"],
|
||||
"LAUNCHER":"retroarch -L",
|
||||
"TITLE":"MGBA Roms",
|
||||
"SO_URL":"http://buildbot.libretro.com/nightly/linux/armhf/latest/mgba_libretro.so.zip"
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
ROM=/home/cpi/games/NESTOPIA
|
||||
ROM_SO=/home/cpi/apps/emulators/nestopia_libretro.so
|
||||
EXT=zip
|
||||
LAUNCHER=retroarch -L
|
||||
TITLE=NESTOPIA Roms
|
||||
SO_URL=http://buildbot.libretro.com/nightly/linux/armhf/latest/nestopia_libretro.so.zip
|
||||
{
|
||||
"ROM":"/home/cpi/games/NESTOPIA",
|
||||
"ROM_SO":"/home/cpi/apps/emulators/nestopia_libretro.so",
|
||||
"EXT":["zip"],
|
||||
"LAUNCHER":"retroarch -L",
|
||||
"TITLE":"NESTOPIA Roms",
|
||||
"SO_URL":"http://buildbot.libretro.com/nightly/linux/armhf/latest/nestopia_libretro.so.zip"
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/cuu/LauncherGoDev/sysgo/UI"
|
||||
"github.com/cuu/LauncherGoDev/sysgo/UI/Emulator"
|
||||
"github.com/cuu/LauncherGoDev/Menu/GameShell/10_Settings"
|
||||
)
|
||||
|
||||
@ -101,6 +102,32 @@ func ReadTheDirIntoPages(self *UI.MainScreen, _dir string, pglevel int, cur_page
|
||||
}
|
||||
}
|
||||
//Init it
|
||||
}else if self.IsEmulatorPackage(_dir+"/"+f.Name()) {
|
||||
a_c := Emulator.ActionConfig{}
|
||||
dat, err := ioutil.ReadFile(_dir+"/"+f.Name()+"/" +UI.Emulator_flag)
|
||||
UI.ShowErr(err)
|
||||
|
||||
err = json.Unmarshal(dat, &a_c)
|
||||
if err == nil {
|
||||
if UI.FileExists(filepath.Join(_dir,f.Name(),"retroarch-local.cfg")) {
|
||||
a_c.RETRO_CONFIG = UI.CmdClean( filepath.Join(_dir,f.Name(),"retroarch-local.cfg") )
|
||||
fmt.Println("a local retroarch cfg: ",a_c.RETRO_CONFIG)
|
||||
}
|
||||
|
||||
em := Emulator.NewMyEmulator()
|
||||
em.EmulatorConfig = &a_c
|
||||
em.Init(self)
|
||||
|
||||
iconitem.CmdInvoke = em
|
||||
if iconitem.CmdInvoke != nil {
|
||||
iconitem.MyType = UI.ICON_TYPES["Emulator"]
|
||||
iconitem.CmdPath = f.Name()
|
||||
cur_page.AppendIcon(iconitem)
|
||||
}
|
||||
}else {
|
||||
fmt.Println("ReadTheDirIntoPages EmulatorConfig ",err)
|
||||
}
|
||||
|
||||
}else {
|
||||
iconitem.MyType = UI.ICON_TYPES["DIR"]
|
||||
linkpage := UI.NewPage()
|
||||
|
||||
@ -2,7 +2,7 @@ package Emulator
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"github.com/cuu/LauncherGoDev/sysgo/UI"
|
||||
//"github.com/cuu/LauncherGoDev/sysgo/UI"
|
||||
|
||||
)
|
||||
|
||||
|
||||
@ -29,6 +29,8 @@ type MyEmulator struct { // as leader of RomListPage and FavListPage, it's a Plu
|
||||
Name string
|
||||
RomPage *RomListPage
|
||||
FavPage *FavListPage
|
||||
DeleteConfirmPage *UI.DeleteConfirmPage
|
||||
EmulatorConfig *ActionConfig
|
||||
}
|
||||
|
||||
func NewMyEmulator() *MyEmulator{
|
||||
@ -42,11 +44,36 @@ func (self *MyEmulator) GetName() string {
|
||||
}
|
||||
|
||||
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()
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
func (self *MyEmulator) API(main_screen *UI.MainScreen) {
|
||||
|
||||
func (self *MyEmulator) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.RomPage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,11 +1,18 @@
|
||||
package Emulator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"path/filepath"
|
||||
"errors"
|
||||
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/event"
|
||||
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/time"
|
||||
"github.com/cuu/LauncherGoDev/sysgo/UI"
|
||||
|
||||
)
|
||||
@ -21,8 +28,9 @@ type FavListPage struct {
|
||||
|
||||
MyList []*EmulatorListItem
|
||||
BGwidth int
|
||||
BGheight 70
|
||||
|
||||
BGheight int //70
|
||||
Scroller *UI.ListScroller
|
||||
Scrolled int
|
||||
Leader *MyEmulator
|
||||
|
||||
}
|
||||
@ -33,7 +41,7 @@ func NewFavListPage() *FavListPage {
|
||||
p.SelectedIconTopOffset = 20
|
||||
p.EasingDur = 10
|
||||
|
||||
p.Align = ALIGN["SLeft"]
|
||||
p.Align = UI.ALIGN["SLeft"]
|
||||
|
||||
p.FootMsg = [5]string{ "Nav","Scan","Remove","","Run" }
|
||||
|
||||
@ -47,11 +55,17 @@ func NewFavListPage() *FavListPage {
|
||||
|
||||
return p
|
||||
}
|
||||
func (self *FavListPage) GetMapIcons() map[string]UI.IconItemInterface {
|
||||
return self.Icons
|
||||
}
|
||||
|
||||
func (self *FavListPage) GetEmulatorConfig() *ActionConfig {
|
||||
return self.EmulatorConfig
|
||||
}
|
||||
|
||||
func (self *FavListPage) GeneratePathList(path string) []map[string]string {
|
||||
func (self *FavListPage) GeneratePathList(path string) ([]map[string]string,error) {
|
||||
if UI.IsDirectory(path) == false {
|
||||
return nil
|
||||
return nil,errors.New("Path is not a folder")
|
||||
}
|
||||
dirmap := make(map[string]string)
|
||||
var ret []map[string]string
|
||||
@ -59,10 +73,10 @@ func (self *FavListPage) GeneratePathList(path string) []map[string]string {
|
||||
file_paths,err := filepath.Glob(path+"/*")//sorted
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return false
|
||||
return ret,err
|
||||
}
|
||||
|
||||
for i,v := range file_paths {
|
||||
for _,v := range file_paths {
|
||||
if UI.IsDirectory(v) && self.EmulatorConfig.FILETYPE == "dir" { // like DOSBOX
|
||||
gameshell_bat := self.EmulatorConfig.EXT[0]
|
||||
if UI.GetGid(v) != FavGID { //only favs
|
||||
@ -75,7 +89,7 @@ func (self *FavListPage) GeneratePathList(path string) []map[string]string {
|
||||
}
|
||||
}
|
||||
|
||||
if UI.IsFile(v) && self.EmulatorConfig.FILETYPE == "file" {
|
||||
if UI.IsAFile(v) && self.EmulatorConfig.FILETYPE == "file" {
|
||||
if UI.GetGid(v) != FavGID { //only favs
|
||||
continue
|
||||
}
|
||||
@ -97,16 +111,16 @@ func (self *FavListPage) GeneratePathList(path string) []map[string]string {
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
return ret,nil
|
||||
|
||||
}
|
||||
|
||||
func (self *FavListPage) SyncList( path string ) {
|
||||
|
||||
alist := self.GeneratePathList(path)
|
||||
alist,err := self.GeneratePathList(path)
|
||||
|
||||
if alist == nil {
|
||||
fmt.Println("listfiles return false")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
@ -139,7 +153,7 @@ func (self *FavListPage) SyncList( path string ) {
|
||||
li.Fonts["normal"] = self.ListFont
|
||||
li.MyType = UI.ICON_TYPES["FILE"]
|
||||
|
||||
init_val = "NoName"
|
||||
init_val := "NoName"
|
||||
|
||||
if val, ok := v["directory"]; ok {
|
||||
li.MyType = UI.ICON_TYPES["DIR"]
|
||||
@ -165,7 +179,7 @@ func (self *FavListPage) Init() {
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
sefl.CanvasHWND = self.Screen.CanvasHWND
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
|
||||
ps := UI.NewInfoPageSelector()
|
||||
ps.Width = UI.Width - 12
|
||||
@ -193,16 +207,16 @@ func (self *FavListPage) Init() {
|
||||
bgpng.MyType = UI.ICON_TYPES["STAT"]
|
||||
bgpng.Parent = self
|
||||
bgpng.AddLabel("my favourites games",UI.Fonts["varela22"])
|
||||
bgpng.SetLableColor(&color.Color{204,204,204,255} )
|
||||
bgpng.SetLabelColor(&color.Color{204,204,204,255} )
|
||||
bgpng.Adjust(0,0,self.BGwidth,self.BGheight,0)
|
||||
|
||||
self.Icons["bg"] = bgpng
|
||||
|
||||
self._Scroller = UI.NewListScroller()
|
||||
self._Scroller.Parent = self
|
||||
self._Scroller.PosX = self.Width - 10
|
||||
self._Scroller.PosY = 2
|
||||
self._Scroller.Init()
|
||||
self.Scroller = UI.NewListScroller()
|
||||
self.Scroller.Parent = self
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
|
||||
rom_so_confirm_page := NewRomSoConfirmPage()
|
||||
rom_so_confirm_page.Screen = self.Screen
|
||||
@ -272,7 +286,7 @@ func (self *FavListPage) SyncScroll() {
|
||||
self.MyList[i].PosY += self.Scrolled*self.MyList[i].Height
|
||||
}
|
||||
}
|
||||
} if self.Scrolled < 0 {
|
||||
}else if self.Scrolled < 0 {
|
||||
if cur_li.PosY + cur_li.Height > self.Height {
|
||||
for i,_ := range self.MyList {
|
||||
self.MyList[i].PosY += self.Scrolled*self.MyList[i].Height
|
||||
@ -299,7 +313,7 @@ func (self *FavListPage) Click() {
|
||||
cur_li := self.MyList[self.PsIndex]
|
||||
|
||||
if cur_li.MyType == UI.ICON_TYPES["DIR"] {
|
||||
if cur_li.Path = "[..]"{
|
||||
if cur_li.Path == "[..]" {
|
||||
self.MyStack.Pop()
|
||||
self.SyncList(self.MyStack.Last())
|
||||
self.PsIndex = 0
|
||||
@ -332,7 +346,7 @@ func (self *FavListPage) Click() {
|
||||
|
||||
custom_config := ""
|
||||
|
||||
if self.EmulatorConfig.RETRO_CONFIG != "" && len(self.EmulatorConfig.RETRO_CONFIG) 5 {
|
||||
if self.EmulatorConfig.RETRO_CONFIG != "" && len(self.EmulatorConfig.RETRO_CONFIG) > 5 {
|
||||
custom_config = " -c " + self.EmulatorConfig.RETRO_CONFIG
|
||||
}
|
||||
|
||||
@ -341,11 +355,11 @@ func (self *FavListPage) Click() {
|
||||
cmdpath := strings.Join( partsofpath," ")
|
||||
|
||||
if self.EmulatorConfig.ROM_SO =="" { //empty means No needs for rom so
|
||||
event.POST(UI.RUNEVT,cmdpath)
|
||||
event.Post(UI.RUNEVT,cmdpath)
|
||||
}else{
|
||||
|
||||
if UI.FileExists(self.EmulatorConfig.ROM_SO) == true {
|
||||
event.POST(UI.RUNEVT,cmdpath)
|
||||
event.Post(UI.RUNEVT,cmdpath)
|
||||
} else {
|
||||
self.Screen.PushCurPage()
|
||||
self.Screen.SetCurPage( self.RomSoConfirmDownloadPage)
|
||||
@ -456,13 +470,14 @@ func (self *FavListPage) Draw() {
|
||||
self.Icons["bg"].NewCoord(self.Width/2,self.Height/2)
|
||||
self.Icons["bg"].Draw()
|
||||
}else{
|
||||
|
||||
_,h := self.Ps.Size()
|
||||
if len(self.MyList) * HierListItemDefaultHeight > self.Height {
|
||||
self.Ps.Width = self.Width - 10
|
||||
|
||||
self.Ps.NewSize(self.Width - 10, h)
|
||||
self.Ps.Draw()
|
||||
|
||||
|
||||
for i,v := range self.MyList {
|
||||
for _,v := range self.MyList {
|
||||
if v.PosY > self.Height + self.Height/2 {
|
||||
break
|
||||
}
|
||||
@ -480,7 +495,7 @@ func (self *FavListPage) Draw() {
|
||||
|
||||
|
||||
}else {
|
||||
self.Ps.Width = self.Width
|
||||
self.Ps.NewSize(self.Width,h)
|
||||
self.Ps.Draw()
|
||||
for _,v := range self.MyList {
|
||||
v.Draw()
|
||||
|
||||
@ -1,22 +1,33 @@
|
||||
package Emulator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
//"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/draw"
|
||||
"github.com/cuu/LauncherGoDev/sysgo/UI"
|
||||
|
||||
)
|
||||
|
||||
type EmulatorPageInterface {
|
||||
type EmulatorPageInterface interface {
|
||||
UI.PageInterface
|
||||
GetIcons() map[string]UI.IconItemInterface
|
||||
GetMapIcons() map[string]UI.IconItemInterface
|
||||
GetEmulatorConfig() *ActionConfig
|
||||
}
|
||||
|
||||
|
||||
type ListItemIcon struct {
|
||||
UI.IconItem
|
||||
|
||||
|
||||
}
|
||||
|
||||
func NewListItemIcon() *ListItemIcon {
|
||||
@ -36,7 +47,7 @@ func (self *ListItemIcon) Draw() {
|
||||
|
||||
rect_ := rect.Rect(self.PosX,self.PosY+(h-self.Height)/2,self.Width,self.Height)
|
||||
|
||||
surface.Blit(self.CanvasHWND, self.ImgSurf,&rect_,nil)
|
||||
surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf,&rect_,nil)
|
||||
}
|
||||
|
||||
/// [..] [.]
|
||||
@ -52,8 +63,8 @@ var HierListItemDefaultHeight = 32
|
||||
|
||||
func NewHierListItem() *HierListItem {
|
||||
p := &HierListItem{}
|
||||
p.Labels = make(map[string]LabelInterface)
|
||||
p.Icons = make( map[string]IconItemInterface)
|
||||
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"]
|
||||
@ -107,9 +118,9 @@ func (self *HierListItem) Init(text string) {
|
||||
}
|
||||
|
||||
if self.IsDir() == true {
|
||||
l.Init(label_text, self.Fonts["normal"])
|
||||
l.Init(label_text, self.Fonts["normal"],nil)
|
||||
}else {
|
||||
l.Init(label_text,self.Fonts["normal"])
|
||||
l.Init(label_text,self.Fonts["normal"],nil)
|
||||
}
|
||||
|
||||
self.Labels["Text"] = l
|
||||
@ -161,8 +172,8 @@ type EmulatorListItem struct {
|
||||
|
||||
func NewEmulatorListItem() *EmulatorListItem {
|
||||
p := &EmulatorListItem{}
|
||||
p.Labels = make(map[string]LabelInterface)
|
||||
p.Icons = make( map[string]IconItemInterface)
|
||||
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"]
|
||||
@ -187,17 +198,17 @@ func (self *EmulatorListItem) Draw() {
|
||||
|
||||
self.Labels["Text"].Draw()
|
||||
|
||||
parent_icons := self.Parent.GetIcons()
|
||||
w,h := parent_cons["sys"].Size()
|
||||
parent_icons := self.Parent.GetMapIcons()
|
||||
_,h = parent_icons["sys"].Size()
|
||||
|
||||
if self.IsDir() == true && self.Path != "[..]" {
|
||||
parent_icons["sys"].IconIndex = 0
|
||||
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"].IconIndex = 1
|
||||
parent_icons["sys"].SetIconIndex(1)
|
||||
parent_icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
|
||||
parent_icons["sys"].Draw()
|
||||
}
|
||||
|
||||
@ -1,11 +1,18 @@
|
||||
package Emulator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"regexp"
|
||||
"path/filepath"
|
||||
"os/exec"
|
||||
"errors"
|
||||
|
||||
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"github.com/cuu/gogame/time"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/LauncherGoDev/sysgo/UI"
|
||||
|
||||
)
|
||||
@ -21,7 +28,9 @@ type RomListPage struct {
|
||||
|
||||
MyList []*EmulatorListItem
|
||||
BGwidth int
|
||||
BGheight 70
|
||||
BGheight int //70
|
||||
Scroller *UI.ListScroller
|
||||
Scrolled int
|
||||
|
||||
Leader *MyEmulator
|
||||
|
||||
@ -33,7 +42,7 @@ func NewRomListPage() *RomListPage {
|
||||
p.SelectedIconTopOffset = 20
|
||||
p.EasingDur = 10
|
||||
|
||||
p.Align = ALIGN["SLeft"]
|
||||
p.Align = UI.ALIGN["SLeft"]
|
||||
|
||||
p.FootMsg = [5]string{ "Nav","Scan","Del","AddFav","Run" }
|
||||
|
||||
@ -48,10 +57,18 @@ func NewRomListPage() *RomListPage {
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *RomListPage) GetMapIcons() map[string]UI.IconItemInterface {
|
||||
return self.Icons
|
||||
}
|
||||
|
||||
func (self *RomListPage) GeneratePathList(path string) []map[string]string {
|
||||
func (self *RomListPage) GetEmulatorConfig() *ActionConfig {
|
||||
return self.EmulatorConfig
|
||||
}
|
||||
|
||||
|
||||
func (self *RomListPage) GeneratePathList(path string) ([]map[string]string,error) {
|
||||
if UI.IsDirectory(path) == false {
|
||||
return nil
|
||||
return nil,errors.New("Path is not a folder")
|
||||
}
|
||||
dirmap := make(map[string]string)
|
||||
var ret []map[string]string
|
||||
@ -59,10 +76,10 @@ func (self *RomListPage) GeneratePathList(path string) []map[string]string {
|
||||
file_paths,err := filepath.Glob(path+"/*")//sorted
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return false
|
||||
return ret,err
|
||||
}
|
||||
|
||||
for i,v := range file_paths {
|
||||
for _,v := range file_paths {
|
||||
if UI.IsDirectory(v) && self.EmulatorConfig.FILETYPE == "dir" { // like DOSBOX
|
||||
gameshell_bat := self.EmulatorConfig.EXT[0]
|
||||
if UI.GetGid(v) == FavGID { // skip fav roms
|
||||
@ -75,7 +92,7 @@ func (self *RomListPage) GeneratePathList(path string) []map[string]string {
|
||||
}
|
||||
}
|
||||
|
||||
if UI.IsFile(v) && self.EmulatorConfig.FILETYPE == "file" {
|
||||
if UI.IsAFile(v) && self.EmulatorConfig.FILETYPE == "file" {
|
||||
if UI.GetGid(v) == FavGID {
|
||||
continue
|
||||
}
|
||||
@ -109,16 +126,16 @@ func (self *RomListPage) GeneratePathList(path string) []map[string]string {
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
return ret,nil
|
||||
|
||||
}
|
||||
|
||||
func (self *RomListPage) SyncList( path string ) {
|
||||
|
||||
alist := self.GeneratePathList(path)
|
||||
alist,err := self.GeneratePathList(path)
|
||||
|
||||
if alist == nil {
|
||||
fmt.Println("listfiles return false")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
@ -151,7 +168,7 @@ func (self *RomListPage) SyncList( path string ) {
|
||||
li.Fonts["normal"] = self.ListFont
|
||||
li.MyType = UI.ICON_TYPES["FILE"]
|
||||
|
||||
init_val = "NoName"
|
||||
init_val := "NoName"
|
||||
|
||||
if val, ok := v["directory"]; ok {
|
||||
li.MyType = UI.ICON_TYPES["DIR"]
|
||||
@ -177,7 +194,7 @@ func (self *RomListPage) Init() {
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
sefl.CanvasHWND = self.Screen.CanvasHWND
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
|
||||
ps := UI.NewInfoPageSelector()
|
||||
ps.Width = UI.Width - 12
|
||||
@ -215,16 +232,16 @@ func (self *RomListPage) Init() {
|
||||
bgpng.MyType = UI.ICON_TYPES["STAT"]
|
||||
bgpng.Parent = self
|
||||
bgpng.AddLabel("Please upload data over Wi-Fi",UI.Fonts["varela22"])
|
||||
bgpng.SetLableColor(&color.Color{204,204,204,255} )
|
||||
bgpng.SetLabelColor(&color.Color{204,204,204,255} )
|
||||
bgpng.Adjust(0,0,self.BGwidth,self.BGheight,0)
|
||||
|
||||
self.Icons["bg"] = bgpng
|
||||
|
||||
self._Scroller = UI.NewListScroller()
|
||||
self._Scroller.Parent = self
|
||||
self._Scroller.PosX = self.Width - 10
|
||||
self._Scroller.PosY = 2
|
||||
self._Scroller.Init()
|
||||
self.Scroller = UI.NewListScroller()
|
||||
self.Scroller.Parent = self
|
||||
self.Scroller.PosX = self.Width - 10
|
||||
self.Scroller.PosY = 2
|
||||
self.Scroller.Init()
|
||||
|
||||
rom_so_confirm_page := NewRomSoConfirmPage()
|
||||
rom_so_confirm_page.Screen = self.Screen
|
||||
@ -294,7 +311,7 @@ func (self *RomListPage) SyncScroll() {
|
||||
self.MyList[i].PosY += self.Scrolled*self.MyList[i].Height
|
||||
}
|
||||
}
|
||||
} if self.Scrolled < 0 {
|
||||
}else if self.Scrolled < 0 {
|
||||
if cur_li.PosY + cur_li.Height > self.Height{
|
||||
for i,_ := range self.MyList{
|
||||
self.MyList[i].PosY += self.Scrolled*self.MyList[i].Height
|
||||
@ -307,7 +324,6 @@ func (self *RomListPage) SyncScroll() {
|
||||
|
||||
|
||||
func (self *RomListPage) Click() {
|
||||
|
||||
if len(self.MyList) == 0 {
|
||||
return
|
||||
}
|
||||
@ -321,7 +337,7 @@ func (self *RomListPage) Click() {
|
||||
cur_li := self.MyList[self.PsIndex]
|
||||
|
||||
if cur_li.MyType == UI.ICON_TYPES["DIR"] {
|
||||
if cur_li.Path = "[..]"{
|
||||
if cur_li.Path == "[..]"{
|
||||
self.MyStack.Pop()
|
||||
self.SyncList(self.MyStack.Last())
|
||||
self.PsIndex = 0
|
||||
@ -354,7 +370,7 @@ func (self *RomListPage) Click() {
|
||||
|
||||
custom_config := ""
|
||||
|
||||
if self.EmulatorConfig.RETRO_CONFIG != "" && len(self.EmulatorConfig.RETRO_CONFIG) 5 {
|
||||
if self.EmulatorConfig.RETRO_CONFIG != "" && len(self.EmulatorConfig.RETRO_CONFIG) > 5 {
|
||||
custom_config = " -c " + self.EmulatorConfig.RETRO_CONFIG
|
||||
}
|
||||
|
||||
@ -363,11 +379,11 @@ func (self *RomListPage) Click() {
|
||||
cmdpath := strings.Join( partsofpath," ")
|
||||
|
||||
if self.EmulatorConfig.ROM_SO =="" { //empty means No needs for rom so
|
||||
event.POST(UI.RUNEVT,cmdpath)
|
||||
event.Post(UI.RUNEVT,cmdpath)
|
||||
}else{
|
||||
|
||||
if UI.FileExists(self.EmulatorConfig.ROM_SO) == true {
|
||||
event.POST(UI.RUNEVT,cmdpath)
|
||||
event.Post(UI.RUNEVT,cmdpath)
|
||||
} else {
|
||||
self.Screen.PushCurPage()
|
||||
self.Screen.SetCurPage( self.RomSoConfirmDownloadPage)
|
||||
@ -429,6 +445,7 @@ func (self *RomListPage) KeyDown(ev *event.Event) {
|
||||
self.Screen.SetCurPage(self.Leader.FavPage)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == UI.CurKeys["Up"]{
|
||||
self.ScrollUp()
|
||||
@ -503,13 +520,13 @@ func (self *RomListPage) Draw() {
|
||||
self.Icons["bg"].NewCoord(self.Width/2,self.Height/2)
|
||||
self.Icons["bg"].Draw()
|
||||
}else{
|
||||
|
||||
_,h := self.Ps.Size()
|
||||
if len(self.MyList) * HierListItemDefaultHeight > self.Height {
|
||||
self.Ps.Width = self.Width - 10
|
||||
self.Ps.NewSize(self.Width - 10,h)
|
||||
self.Ps.Draw()
|
||||
|
||||
|
||||
for i,v := range self.MyList {
|
||||
for _,v := range self.MyList {
|
||||
if v.PosY > self.Height + self.Height/2 {
|
||||
break
|
||||
}
|
||||
@ -527,7 +544,7 @@ func (self *RomListPage) Draw() {
|
||||
|
||||
|
||||
}else {
|
||||
self.Ps.Width = self.Width
|
||||
self.Ps.NewSize(self.Width,h)
|
||||
self.Ps.Draw()
|
||||
for _,v := range self.MyList {
|
||||
v.Draw()
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
package Emulator
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"fmt"
|
||||
//"strconv"
|
||||
"strings"
|
||||
|
||||
"path/filepath"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/LauncherGoDev/sysgo"
|
||||
"github.com/cuu/LauncherGoDev/sysgo/UI"
|
||||
|
||||
@ -14,7 +15,7 @@ import (
|
||||
|
||||
type RomSoConfirmPage struct {
|
||||
UI.ConfirmPage
|
||||
|
||||
Parent EmulatorPageInterface
|
||||
DownloadPage *UI.DownloadProcessPage
|
||||
|
||||
}
|
||||
@ -24,7 +25,7 @@ func NewRomSoConfirmPage() *RomSoConfirmPage {
|
||||
p.PageIconMargin = 20
|
||||
p.SelectedIconTopOffset = 20
|
||||
p.EasingDur = 10
|
||||
p.Align = ALIGN["SLeft"]
|
||||
p.Align = UI.ALIGN["SLeft"]
|
||||
|
||||
p.ListFont = UI.Fonts["veramono18"]
|
||||
p.FootMsg = [5]string{"Nav","","","Cancel","Yes"}
|
||||
@ -44,7 +45,7 @@ func (self *RomSoConfirmPage) Init() {
|
||||
li := UI.NewMultiLabel()
|
||||
li.SetCanvasHWND(self.CanvasHWND)
|
||||
li.Width = 160
|
||||
li.Init(self.ConfirmText,self.ListFont)
|
||||
li.Init(self.ConfirmText,self.ListFont,nil)
|
||||
|
||||
li.PosX = (self.Width - li.Width)/2
|
||||
li.PosY = (self.Height - li.Height)/2
|
||||
@ -94,16 +95,17 @@ func (self *RomSoConfirmPage) KeyDown(ev *event.Event) {
|
||||
self.Screen.PushPage(self.DownloadPage)
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
|
||||
ec := self.Parent.GetEmulatorConfig()
|
||||
if sysgo.CurKeySet == "PC" {
|
||||
so_url := self.Parent.EmulatorConfig.SO_URL
|
||||
|
||||
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(self.Parent.EmulatorConfig.ROM_SO))
|
||||
self.DownloadPage.StartDownload(so_url,filepath.Dir(ec.ROM_SO))
|
||||
|
||||
}else{
|
||||
so_url := self.Parent.EmulatorConfig.SO_URL
|
||||
self.DownloadPage.StartDownload(so_url,filepath.Dir(self.Parent.EmulatorConfig.ROM_SO))
|
||||
so_url := ec.SO_URL
|
||||
self.DownloadPage.StartDownload(so_url,filepath.Dir(ec.ROM_SO))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
77
sysgo/UI/delete_confirm_page.go
Normal file
77
sysgo/UI/delete_confirm_page.go
Normal file
@ -0,0 +1,77 @@
|
||||
package UI
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/time"
|
||||
)
|
||||
|
||||
type DeleteConfirmPage struct {
|
||||
ConfirmPage
|
||||
|
||||
}
|
||||
|
||||
|
||||
func NewDeleteConfirmPage() *DeleteConfirmPage {
|
||||
p := &DeleteConfirmPage{}
|
||||
p.ListFont = Fonts["veramono20"]
|
||||
p.FootMsg = [5]string{"Nav","","","Cancel","Yes"}
|
||||
p.ConfirmText ="Confirm Delete ?"
|
||||
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
|
||||
func (self *DeleteConfirmPage) SetTrashDir(d string) {
|
||||
self.TrashDir = d
|
||||
if IsDirectory(self.TrashDir)== false {
|
||||
panic("DeleteConfirmPage SetTrashDir errors")
|
||||
}
|
||||
}
|
||||
|
||||
func (self *DeleteConfirmPage) SetFileName(fn string) {
|
||||
self.FileName = fn
|
||||
}
|
||||
|
||||
func (self *DeleteConfirmPage) KeyDown(ev *event.Event) {
|
||||
|
||||
if ev.Data["Key"] == CurKeys["A"] || ev.Data["Key"] == CurKeys["Menu"] {
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
if ev.Data["Key"] == CurKeys["B"] {
|
||||
err := os.Remove(filepath.Join(self.TrashDir, filepath.Base(self.FileName)))
|
||||
if err != nil {
|
||||
fmt.Println("DeleteConfirmPage os.Remove errors :",err)
|
||||
}
|
||||
|
||||
err = os.Rename(filepath.Base(self.FileName), filepath.Join(self.TrashDir, filepath.Base(self.FileName)))
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(),"exists" ) {
|
||||
self.Screen.MsgBox.SetText("Already Existed")
|
||||
} else {
|
||||
self.Screen.MsgBox.SetText("Error")
|
||||
}
|
||||
self.Screen.MsgBox.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
} else {
|
||||
self.SnapMsg("Deleting")
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
self.Reset()
|
||||
time.BlockDelay(300)
|
||||
self.ReturnToUpLevelPage()
|
||||
self.Screen.Draw()
|
||||
self.Screen.SwapAndShow()
|
||||
}
|
||||
|
||||
fmt.Println(self.FileName)
|
||||
}
|
||||
}
|
||||
@ -807,7 +807,7 @@ func (self *Page) IconClick() {
|
||||
return
|
||||
}
|
||||
|
||||
if cur_icon.GetMyType() == ICON_TYPES["FUNC"] {
|
||||
if cur_icon.GetMyType() == ICON_TYPES["FUNC"] || cur_icon.GetMyType() == ICON_TYPES["Emulator"] {
|
||||
invoker := cur_icon.GetCmdInvoke()
|
||||
if invoker != nil {
|
||||
invoker.Run(self.Screen)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user