mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2026-03-19 02:12:46 +01:00
combine all code into a single binary
This commit is contained in:
@@ -14,3 +14,8 @@ var (
|
||||
DT = 50
|
||||
|
||||
)
|
||||
|
||||
var (
|
||||
Emulator_flag = "action.json"
|
||||
Plugin_flag = "plugin.json"
|
||||
)
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package UI
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
//"fmt"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
"log"
|
||||
"encoding/json"
|
||||
|
||||
//"encoding/json"
|
||||
//"path/filepath"
|
||||
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
@@ -19,13 +20,10 @@ import (
|
||||
"github.com/cuu/gogame/time"
|
||||
|
||||
"github.com/cuu/gogame/event"
|
||||
|
||||
|
||||
"github.com/cuu/LauncherGoDev/sysgo/DBUS"
|
||||
)
|
||||
|
||||
var (
|
||||
emulator_flag = "action.json"
|
||||
plugin_flag = "plugin.json"
|
||||
|
||||
)
|
||||
|
||||
type PluginConfig struct {
|
||||
@@ -159,6 +157,8 @@ type MainScreen struct {
|
||||
DBusManager *DBUS.DBus
|
||||
CounterScreen *CounterScreen
|
||||
Closed bool
|
||||
|
||||
UIPluginList []*UIPlugin
|
||||
}
|
||||
|
||||
|
||||
@@ -191,6 +191,7 @@ func (self *MainScreen) Init() {
|
||||
self.CounterScreen.HWND = self.HWND
|
||||
self.CounterScreen.Init()
|
||||
|
||||
//self.GenList() // load predefined plugin list,ready to be injected ,or ,as a .so for dynamic loading
|
||||
|
||||
}
|
||||
|
||||
@@ -275,7 +276,7 @@ func (self *MainScreen) IsPluginPackage(dirname string ) bool {
|
||||
if f.IsDir() {
|
||||
//pass
|
||||
}else {
|
||||
if strings.HasSuffix(f.Name(),plugin_flag) == true {
|
||||
if strings.HasSuffix(f.Name(),Plugin_flag) == true {
|
||||
ret = true
|
||||
break
|
||||
}
|
||||
@@ -297,7 +298,7 @@ func (self *MainScreen) IsEmulatorPackage(dirname string ) bool {
|
||||
if f.IsDir() {
|
||||
//pass
|
||||
}else {
|
||||
if strings.HasSuffix(f.Name(),emulator_flag) == true {
|
||||
if strings.HasSuffix(f.Name(),Emulator_flag) == true {
|
||||
ret = true
|
||||
break
|
||||
}
|
||||
@@ -307,112 +308,6 @@ func (self *MainScreen) IsEmulatorPackage(dirname string ) bool {
|
||||
return ret
|
||||
}
|
||||
|
||||
func (self *MainScreen) ReadTheDirIntoPages(_dir string, pglevel int, cur_page PageInterface) {
|
||||
|
||||
if FileExists(_dir) == false && IsDirectory(_dir) == false {
|
||||
return
|
||||
}
|
||||
|
||||
files,err := ioutil.ReadDir(_dir)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
|
||||
for _,f := range files { // already sorted
|
||||
if IsDirectory( _dir +"/"+f.Name()) {
|
||||
if pglevel == 0 {
|
||||
page := NewPage()
|
||||
page.Name = self.ExtraName(f.Name())
|
||||
self.Pages = append(self.Pages, page)
|
||||
self.ReadTheDirIntoPages(_dir+"/"+f.Name(),pglevel+1, self.Pages[ len(self.Pages) - 1] )
|
||||
}else{ // on cur_page now
|
||||
i2:= self.ExtraName(f.Name())
|
||||
iconitem := NewIconItem()
|
||||
iconitem.AddLabel(i2,self.IconFont)
|
||||
if FileExists( SkinMap(_dir+"/"+i2+".png")) {
|
||||
iconitem.ImageName = SkinMap(_dir+"/"+i2+".png")
|
||||
}else {
|
||||
fmt.Println( SkinMap(_dir+"/"+i2+".png") )
|
||||
untitled := NewUntitledIcon()
|
||||
untitled.Init()
|
||||
if len(i2) > 1 {
|
||||
untitled.SetWords(string(i2[0]),string(i2[1]))
|
||||
}else if len(i2) == 1 {
|
||||
untitled.SetWords(string(i2[0]),string(i2[0]))
|
||||
}else {
|
||||
untitled.SetWords("G","s")
|
||||
}
|
||||
iconitem.ImgSurf = untitled.Surface()
|
||||
iconitem.ImageName = ""
|
||||
}
|
||||
|
||||
if self.IsPluginPackage(_dir+"/"+f.Name()) {
|
||||
p_c := PluginConfig{}
|
||||
|
||||
dat, err := ioutil.ReadFile(_dir+"/"+f.Name()+"/" +plugin_flag)
|
||||
ShowErr(err)
|
||||
|
||||
err = json.Unmarshal(dat, &p_c)
|
||||
if err == nil {
|
||||
if p_c.NAME == "" {
|
||||
p_c.NAME = f.Name()
|
||||
}
|
||||
|
||||
pi,err := LoadPlugin(_dir+"/"+f.Name()+"/"+p_c.SO_FILE)
|
||||
Assert(err)
|
||||
iconitem.CmdInvoke = InitPlugin(pi,self)
|
||||
if iconitem.CmdInvoke != nil {
|
||||
|
||||
iconitem.MyType = ICON_TYPES["FUNC"]
|
||||
iconitem.CmdPath = f.Name()
|
||||
cur_page.AppendIcon(iconitem)
|
||||
}
|
||||
}
|
||||
//Init it
|
||||
}else {
|
||||
iconitem.MyType = ICON_TYPES["DIR"]
|
||||
linkpage := NewPage()
|
||||
linkpage.Name = i2
|
||||
iconitem.LinkPage = linkpage
|
||||
cur_page.AppendIcon(iconitem)
|
||||
self.ReadTheDirIntoPages(_dir+"/"+f.Name(),pglevel+1, iconitem.LinkPage)
|
||||
}
|
||||
|
||||
}
|
||||
} else if IsAFile(_dir+"/"+f.Name()) && (pglevel > 0) {
|
||||
if strings.HasSuffix(strings.ToLower(f.Name()),IconExt) {
|
||||
i2 := self.ExtraName(f.Name())
|
||||
iconitem := NewIconItem()
|
||||
iconitem.CmdPath = _dir+"/"+f.Name()
|
||||
MakeExecutable( iconitem.CmdPath )
|
||||
iconitem.MyType = ICON_TYPES["EXE"]
|
||||
if FileExists( SkinMap( _dir+"/"+ ReplaceSuffix(i2,"png"))) {
|
||||
iconitem.ImageName = SkinMap( _dir+"/"+ ReplaceSuffix(i2,"png"))
|
||||
}else {
|
||||
|
||||
untitled:= NewUntitledIcon()
|
||||
untitled.Init()
|
||||
if len(i2) > 1 {
|
||||
untitled.SetWords(string(i2[0]),string(i2[1]))
|
||||
}else if len(i2) == 1 {
|
||||
untitled.SetWords(string(i2[0]),string(i2[0]))
|
||||
}else {
|
||||
untitled.SetWords("G","s")
|
||||
}
|
||||
iconitem.ImgSurf = untitled.Surface()
|
||||
iconitem.ImageName = ""
|
||||
}
|
||||
|
||||
iconitem.AddLabel(strings.Split(i2,".")[0], self.IconFont)
|
||||
iconitem.LinkPage = nil
|
||||
cur_page.AppendIcon(iconitem)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func (self *MainScreen) RunEXE( cmdpath string) {
|
||||
self.DrawRun()
|
||||
self.SwapAndShow()
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"log"
|
||||
goplugin "plugin"
|
||||
)
|
||||
|
||||
var PluginPool = NewPluginPool()
|
||||
|
||||
type PluginInterface interface {
|
||||
@@ -90,3 +91,10 @@ func RunPlugin(p *goplugin.Plugin, main_screen *MainScreen) {
|
||||
pi.Run(main_screen)
|
||||
}
|
||||
|
||||
type UIPlugin struct{ //Loadable and injectable
|
||||
Type int
|
||||
SoFile string
|
||||
FolderName string
|
||||
LabelText string
|
||||
EmbInterface PluginInterface
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user