mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2026-03-19 02:12:46 +01:00
add TimeZone selection in settings
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
package Emulator
|
||||
|
||||
import (
|
||||
"sync"
|
||||
//"github.com/cuu/LauncherGoDev/sysgo/UI"
|
||||
|
||||
)
|
||||
|
||||
type element struct {
|
||||
data interface{}
|
||||
next *element
|
||||
}
|
||||
|
||||
type EmuStack struct {
|
||||
lock *sync.Mutex
|
||||
head *element
|
||||
Size int
|
||||
EmulatorConfig *ActionConfig
|
||||
}
|
||||
|
||||
func (stk *EmuStack) Push(data interface{}) {
|
||||
stk.lock.Lock()
|
||||
|
||||
element := new(element)
|
||||
element.data = data
|
||||
temp := stk.head
|
||||
element.next = temp
|
||||
stk.head = element
|
||||
stk.Size++
|
||||
|
||||
stk.lock.Unlock()
|
||||
}
|
||||
|
||||
func (stk *EmuStack) Pop() interface{} {
|
||||
if stk.head == nil {
|
||||
return nil
|
||||
}
|
||||
stk.lock.Lock()
|
||||
r := stk.head.data
|
||||
stk.head = stk.head.next
|
||||
stk.Size--
|
||||
|
||||
stk.lock.Unlock()
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (stk *EmuStack) Length() int {
|
||||
return stk.Size
|
||||
}
|
||||
|
||||
func (stk *EmuStack) Last() string {
|
||||
idx := stk.Length() -1
|
||||
if idx < 0 {
|
||||
return stk.EmulatorConfig.ROM
|
||||
}else {
|
||||
return stk.head.data.(string)
|
||||
}
|
||||
}
|
||||
|
||||
func NewEmuStack() *EmuStack {
|
||||
stk := new(EmuStack)
|
||||
stk.lock = &sync.Mutex{}
|
||||
return stk
|
||||
}
|
||||
@@ -21,7 +21,7 @@ type FavListPage struct {
|
||||
UI.Page
|
||||
Icons map[string]UI.IconItemInterface
|
||||
ListFont *ttf.Font
|
||||
MyStack *EmuStack
|
||||
MyStack *UI.FolderStack
|
||||
EmulatorConfig *ActionConfig
|
||||
|
||||
RomSoConfirmDownloadPage *RomSoConfirmPage
|
||||
@@ -48,7 +48,7 @@ func NewFavListPage() *FavListPage {
|
||||
p.Icons=make(map[string]UI.IconItemInterface)
|
||||
p.ListFont = UI.Fonts["notosanscjk15"]
|
||||
|
||||
p.MyStack = NewEmuStack()
|
||||
p.MyStack = UI.NewFolderStack()
|
||||
|
||||
p.BGwidth = 75
|
||||
p.BGheight = 73
|
||||
@@ -194,10 +194,10 @@ func (self *FavListPage) Init() {
|
||||
self.Ps = ps
|
||||
self.PsIndex = 0
|
||||
|
||||
self.MyStack.SetRootPath(self.EmulatorConfig.ROM)
|
||||
|
||||
self.SyncList( self.EmulatorConfig.ROM )
|
||||
|
||||
self.MyStack.EmulatorConfig = self.EmulatorConfig
|
||||
|
||||
|
||||
icon_for_list := UI.NewMultiIconItem()
|
||||
icon_for_list.ImgSurf = UI.MyIconPool.GetImgSurf("sys")
|
||||
icon_for_list.MyType = UI.ICON_TYPES["STAT"]
|
||||
@@ -492,7 +492,7 @@ func (self *FavListPage) Draw() {
|
||||
self.Icons["bg"].Draw()
|
||||
}else{
|
||||
_,h := self.Ps.Size()
|
||||
if len(self.MyList) * HierListItemDefaultHeight > self.Height {
|
||||
if len(self.MyList) * UI.HierListItemDefaultHeight > self.Height {
|
||||
|
||||
self.Ps.NewSize(self.Width - 10, h)
|
||||
self.Ps.Draw()
|
||||
@@ -511,7 +511,8 @@ func (self *FavListPage) Draw() {
|
||||
v.Draw()
|
||||
}
|
||||
|
||||
self.Scroller.UpdateSize( len(self.MyList)*HierListItemDefaultHeight, self.PsIndex*HierListItemDefaultHeight)
|
||||
self.Scroller.UpdateSize( len(self.MyList)*UI.HierListItemDefaultHeight,
|
||||
self.PsIndex*UI.HierListItemDefaultHeight)
|
||||
self.Scroller.Draw()
|
||||
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"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/surface"
|
||||
//"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
|
||||
"github.com/cuu/gogame/draw"
|
||||
@@ -24,153 +24,8 @@ type EmulatorPageInterface interface {
|
||||
}
|
||||
|
||||
|
||||
type ListItemIcon struct {
|
||||
UI.IconItem
|
||||
|
||||
|
||||
}
|
||||
|
||||
func NewListItemIcon() *ListItemIcon {
|
||||
p := &ListItemIcon{}
|
||||
p.MyType = UI.ICON_TYPES["EXE"]
|
||||
|
||||
p.Align = UI.ALIGN["VCenter"]
|
||||
|
||||
p.Width = 18
|
||||
p.Height = 18
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *ListItemIcon) Draw() {
|
||||
_,h := self.Parent.Size()
|
||||
|
||||
rect_ := rect.Rect(self.PosX,self.PosY+(h-self.Height)/2,self.Width,self.Height)
|
||||
|
||||
surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf,&rect_,nil)
|
||||
}
|
||||
|
||||
/// [..] [.]
|
||||
type HierListItem struct {
|
||||
UI.ListItem
|
||||
MyType int
|
||||
Path string
|
||||
Active bool
|
||||
Playing bool
|
||||
}
|
||||
|
||||
var HierListItemDefaultHeight = 32
|
||||
|
||||
func NewHierListItem() *HierListItem {
|
||||
p := &HierListItem{}
|
||||
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 = HierListItemDefaultHeight
|
||||
p.Width = 0
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *HierListItem) IsFile() bool {
|
||||
if self.MyType == UI.ICON_TYPES["FILE"] {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
func (self *HierListItem) IsDir() bool {
|
||||
if self.MyType == UI.ICON_TYPES["DIR"] {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
func (self *HierListItem) Init(text string) {
|
||||
l := UI.NewLabel()
|
||||
l.PosX = 20
|
||||
if self.Parent == nil {
|
||||
fmt.Println("Parent nil")
|
||||
return
|
||||
}
|
||||
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 *HierListItem) 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()
|
||||
|
||||
|
||||
/*
|
||||
w,h := self.Parent.Icons["sys"].Size()
|
||||
|
||||
if self.IsDir() == true && self.Path != "[..]" {
|
||||
self.Parent.Icons["sys"].IconIndex = 0
|
||||
self.Parent.Icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
|
||||
self.Parent.Icons["sys"].Draw()
|
||||
}
|
||||
|
||||
if self.IsFile() == true {
|
||||
self.Parent.Icons["sys"].IconIndex = 1
|
||||
self.Parent.Icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
|
||||
self.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)
|
||||
|
||||
}
|
||||
|
||||
type EmulatorListItem struct {
|
||||
HierListItem
|
||||
UI.HierListItem
|
||||
Parent EmulatorPageInterface
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ type RomListPage struct {
|
||||
UI.Page
|
||||
Icons map[string]UI.IconItemInterface
|
||||
ListFont *ttf.Font
|
||||
MyStack *EmuStack
|
||||
MyStack *UI.FolderStack
|
||||
EmulatorConfig *ActionConfig
|
||||
|
||||
RomSoConfirmDownloadPage *RomSoConfirmPage
|
||||
@@ -49,7 +49,7 @@ func NewRomListPage() *RomListPage {
|
||||
p.Icons=make(map[string]UI.IconItemInterface)
|
||||
p.ListFont = UI.Fonts["notosanscjk15"]
|
||||
|
||||
p.MyStack = NewEmuStack()
|
||||
p.MyStack = UI.NewFolderStack()
|
||||
|
||||
p.BGwidth = 56
|
||||
p.BGheight = 70
|
||||
@@ -211,6 +211,8 @@ func (self *RomListPage) Init() {
|
||||
self.Ps = ps
|
||||
self.PsIndex = 0
|
||||
|
||||
self.MyStack.SetRootPath(self.EmulatorConfig.ROM)
|
||||
|
||||
self.SyncList( self.EmulatorConfig.ROM )
|
||||
|
||||
err := os.MkdirAll( self.EmulatorConfig.ROM+"/.Trash", 0700)
|
||||
@@ -222,9 +224,7 @@ func (self *RomListPage) Init() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
self.MyStack.EmulatorConfig = self.EmulatorConfig
|
||||
|
||||
|
||||
icon_for_list := UI.NewMultiIconItem()
|
||||
icon_for_list.ImgSurf = UI.MyIconPool.GetImgSurf("sys")
|
||||
icon_for_list.MyType = UI.ICON_TYPES["STAT"]
|
||||
@@ -543,7 +543,7 @@ func (self *RomListPage) Draw() {
|
||||
self.Icons["bg"].Draw()
|
||||
}else{
|
||||
_,h := self.Ps.Size()
|
||||
if len(self.MyList) * HierListItemDefaultHeight > self.Height {
|
||||
if len(self.MyList) * UI.HierListItemDefaultHeight > self.Height {
|
||||
|
||||
self.Ps.NewSize(self.Width - 10,h)
|
||||
self.Ps.Draw()
|
||||
@@ -555,7 +555,8 @@ func (self *RomListPage) Draw() {
|
||||
v.Draw()
|
||||
}
|
||||
|
||||
self.Scroller.UpdateSize( len(self.MyList)*HierListItemDefaultHeight, self.PsIndex*HierListItemDefaultHeight)
|
||||
self.Scroller.UpdateSize( len(self.MyList)*UI.HierListItemDefaultHeight,
|
||||
self.PsIndex*UI.HierListItemDefaultHeight)
|
||||
self.Scroller.Draw()
|
||||
|
||||
}else {
|
||||
|
||||
Reference in New Issue
Block a user