mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-13 00:18:52 +01:00
PluginConfig
This commit is contained in:
parent
3c0884c2d7
commit
a1f49ad1d9
5
Menu/GameShell/HelloWorld/plugin.config
Normal file
5
Menu/GameShell/HelloWorld/plugin.config
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"SO_FILE":"HelloWorld.so",
|
||||||
|
"NAME":"HelloWorld"
|
||||||
|
}
|
||||||
|
|
||||||
@ -5,6 +5,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
"log"
|
"log"
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/veandco/go-sdl2/sdl"
|
"github.com/veandco/go-sdl2/sdl"
|
||||||
"github.com/veandco/go-sdl2/ttf"
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
@ -27,6 +28,24 @@ var (
|
|||||||
plugin_flag = "plugin.config"
|
plugin_flag = "plugin.config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ActionConifg struct {
|
||||||
|
ROM string `json:"ROM"`
|
||||||
|
ROM_SO string `json:"ROM_SO"`
|
||||||
|
EXT []string `json:"EXT"`
|
||||||
|
EXCLUDE []string `json:"EXCLUDE"`
|
||||||
|
FILETYPE string `json:"FILETYPE"` // defalut is file
|
||||||
|
LAUNCHER string `json:"LAUNCHER"`
|
||||||
|
TITLE string `json:"TITLE"` // defaut is Game
|
||||||
|
SO_URL string `json:"SO_URL"`
|
||||||
|
RETRO_CONFIG string `json:"RETRO_CONFIG"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PluginConfig struct {
|
||||||
|
NAME string `json:"NAME"` // plugin name,default could be the same as Plugin Folder's name
|
||||||
|
SO_FILE string `json:"SO_FILE"`
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
type MessageBox struct {
|
type MessageBox struct {
|
||||||
Label
|
Label
|
||||||
Parent *MainScreen
|
Parent *MainScreen
|
||||||
@ -336,9 +355,27 @@ func (self *MainScreen) ReadTheDirIntoPages(_dir string, pglevel int, cur_page P
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.IsPluginPackage(_dir+"/"+f.Name()) {
|
if self.IsPluginPackage(_dir+"/"+f.Name()) {
|
||||||
iconitem.MyType = ICON_TYPES["FUNC"]
|
p_c := PluginConfig{}
|
||||||
iconitem.CmdPath = f.Name()
|
|
||||||
cur_page.AppendIcon(iconitem)
|
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
|
//Init it
|
||||||
}else {
|
}else {
|
||||||
iconitem.MyType = ICON_TYPES["DIR"]
|
iconitem.MyType = ICON_TYPES["DIR"]
|
||||||
|
|||||||
@ -51,22 +51,26 @@ func LoadPlugin( pname string) (*goplugin.Plugin,error) {
|
|||||||
return goplugin.Open(pname)
|
return goplugin.Open(pname)
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitPlugin(p *goplugin.Plugin, main_screen *MainScreen) {
|
func InitPlugin(p *goplugin.Plugin, main_screen *MainScreen) PluginInterface {
|
||||||
symAPI,err := p.Lookup("APIOBJ")
|
symAPI,err := p.Lookup("APIOBJ")
|
||||||
|
|
||||||
if err!= nil {
|
if err!= nil {
|
||||||
log.Fatal( "init plugin failed")
|
log.Fatal( "init plugin failed")
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var pi PluginInterface
|
var pi PluginInterface
|
||||||
pi,ok := symAPI.(PluginInterface)
|
pi,ok := symAPI.(PluginInterface)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Fatal("unexpected type from module symbol")
|
log.Fatal("unexpected type from module symbol")
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//PluginPoolRegister(pi)
|
||||||
|
|
||||||
pi.Init(main_screen)
|
pi.Init(main_screen)
|
||||||
|
|
||||||
|
return pi
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunPlugin(p *goplugin.Plugin, main_screen *MainScreen) {
|
func RunPlugin(p *goplugin.Plugin, main_screen *MainScreen) {
|
||||||
|
|||||||
@ -5,12 +5,31 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/cuu/gogame/display"
|
"github.com/cuu/gogame/display"
|
||||||
|
|
||||||
"github.com/cuu/LauncherGo/sysgo"
|
"github.com/cuu/LauncherGo/sysgo"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func ShowErr(e error) {
|
||||||
|
if e != nil {
|
||||||
|
fmt.Println(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Assert(e error) {
|
||||||
|
if e != nil {
|
||||||
|
log.Fatal("Assert: " , e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func CheckAndPanic(e error) {
|
||||||
|
if e != nil {
|
||||||
|
panic(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func Abs(n int) int {
|
func Abs(n int) int {
|
||||||
y := n >> 63
|
y := n >> 63
|
||||||
return (n ^ y) - y
|
return (n ^ y) - y
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user