mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-12 07:58:51 +01:00
add 50_Pico8
This commit is contained in:
parent
94b7bf121a
commit
9f70638d99
@ -653,7 +653,7 @@ func (self *WareHouse) Click() {
|
|||||||
}
|
}
|
||||||
if cur_li.Value["type"] == "pico8" && cur_li.ReadOnly == false {
|
if cur_li.Value["type"] == "pico8" && cur_li.ReadOnly == false {
|
||||||
if UI.FileExists("/home/cpi/games/PICO-8/pico-8/pico8") {
|
if UI.FileExists("/home/cpi/games/PICO-8/pico-8/pico8") {
|
||||||
game_sh := "/home/cpi/launcher/Menu/GameShell/50_PICO-8/PICO-8.sh"
|
game_sh := "/home/cpi/launchergo/Menu/GameShell/50_PICO-8/PICO-8.sh"
|
||||||
self.Screen.RunEXE(game_sh) //pico8 manages its games self
|
self.Screen.RunEXE(game_sh) //pico8 manages its games self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
111
Menu/GameShell/50_Pico8/game_page.go
Normal file
111
Menu/GameShell/50_Pico8/game_page.go
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
package Pico8
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/cuu/gogame/event"
|
||||||
|
"github.com/cuu/gogame/rect"
|
||||||
|
"github.com/cuu/gogame/surface"
|
||||||
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
|
|
||||||
|
"github.com/cuu/gogame/color"
|
||||||
|
|
||||||
|
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GamePage struct {
|
||||||
|
UI.Page
|
||||||
|
ListFontObj *ttf.Font
|
||||||
|
URLColor *color.Color
|
||||||
|
TextColor *color.Color
|
||||||
|
Labels map[string]UI.LabelInterface
|
||||||
|
Icons map[string]UI.IconItemInterface
|
||||||
|
|
||||||
|
|
||||||
|
MsgBox *UI.MessageBox
|
||||||
|
NotFound bool
|
||||||
|
|
||||||
|
Pkg *UI.CommercialSoftwarePackage
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGamePage() *GamePage {
|
||||||
|
p := &GamePage{}
|
||||||
|
p.PageIconMargin = 20
|
||||||
|
p.SelectedIconTopOffset = 20
|
||||||
|
p.EasingDur = 10
|
||||||
|
|
||||||
|
p.Align = UI.ALIGN["SLeft"]
|
||||||
|
|
||||||
|
p.FootMsg = [5]string{"Nav.", "", "", "Back", ""}
|
||||||
|
|
||||||
|
|
||||||
|
p.URLColor = UI.MySkinManager.GiveColor("URL")
|
||||||
|
p.TextColor = UI.MySkinManager.GiveColor("Text")
|
||||||
|
p.ListFontObj = UI.MyLangManager.TrFont("varela18")
|
||||||
|
|
||||||
|
//p.Labels = make(map[string]UI.LabelInterface)
|
||||||
|
|
||||||
|
//p.Icons = make(map[string]UI.IconItemInterface)
|
||||||
|
p.NotFound = true
|
||||||
|
|
||||||
|
p.Pkg = UI.NewCommercialSoftwarePackage("/home/cpi/games/PICO-8/pico-8/pico8_dyn","/home/cpi/launchergo/Menu/GameShell/50_Pico8/")
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *GamePage) OnLoadCb() {
|
||||||
|
self.PosY = 0
|
||||||
|
if self.Pkg.IsInstalled() {
|
||||||
|
self.Pkg.RunSetup()
|
||||||
|
fmt.Println("Run pico8")
|
||||||
|
self.MsgBox.SetText("Running Pico8")
|
||||||
|
self.Screen.RunEXE(self.Pkg.GetRunScript())
|
||||||
|
|
||||||
|
}else{
|
||||||
|
self.MsgBox.SetText("Please purchase the PICO-8 and copy it to the \"~/games/PICO-8\"")
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("GamePage OnLoadCb")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (self *GamePage) Init() {
|
||||||
|
if self.Screen == nil {
|
||||||
|
panic("No Screen")
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil {
|
||||||
|
self.HWND = self.Screen.CanvasHWND
|
||||||
|
self.CanvasHWND = surface.Surface(self.Screen.Width, self.Screen.Height)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.PosX = self.Index * self.Screen.Width
|
||||||
|
self.Width = self.Screen.Width
|
||||||
|
self.Height = self.Screen.Height
|
||||||
|
|
||||||
|
self.MsgBox = UI.NewMessageBox()
|
||||||
|
self.MsgBox.Parent = self.CanvasHWND
|
||||||
|
self.MsgBox.Init("Please purchase the PICO-8 and copy it to the \"~/games/PICO-8\"",self.ListFontObj,nil,self.Width,self.Height)
|
||||||
|
|
||||||
|
self.Pkg.Init()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *GamePage) KeyDown(ev *event.Event) {
|
||||||
|
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
||||||
|
self.ReturnToUpLevelPage()
|
||||||
|
self.Screen.Refresh()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *GamePage) Draw() {
|
||||||
|
self.ClearCanvas()
|
||||||
|
|
||||||
|
self.MsgBox.Draw()
|
||||||
|
|
||||||
|
if self.HWND != nil {
|
||||||
|
surface.Fill(self.HWND, UI.MySkinManager.GiveColor("white"))
|
||||||
|
rect_ := rect.Rect(self.PosX, self.PosY, self.Width, self.Height)
|
||||||
|
surface.Blit(self.HWND, self.CanvasHWND, &rect_, nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
4
Menu/GameShell/50_Pico8/plugin.json
Normal file
4
Menu/GameShell/50_Pico8/plugin.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"SO_FILE":"",
|
||||||
|
"NAME":"Pico8"
|
||||||
|
}
|
||||||
38
Menu/GameShell/50_Pico8/plugin_init.go
Normal file
38
Menu/GameShell/50_Pico8/plugin_init.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package Pico8
|
||||||
|
|
||||||
|
import (
|
||||||
|
/*
|
||||||
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
|
|
||||||
|
"github.com/cuu/gogame/surface"
|
||||||
|
"github.com/cuu/gogame/event"
|
||||||
|
"github.com/cuu/gogame/rect"
|
||||||
|
"github.com/cuu/gogame/color"
|
||||||
|
*/
|
||||||
|
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||||
|
//"github.com/clockworkpi/LauncherGoDev/sysgo/DBUS"
|
||||||
|
)
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
type GamePlugin struct {
|
||||||
|
UI.Plugin
|
||||||
|
MainPage *GamePage
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *GamePlugin) Init(main_screen *UI.MainScreen) {
|
||||||
|
self.MainPage = NewGamePage()
|
||||||
|
self.MainPage.SetScreen(main_screen)
|
||||||
|
self.MainPage.SetName("Pico8")
|
||||||
|
self.MainPage.Init()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *GamePlugin) Run(main_screen *UI.MainScreen) {
|
||||||
|
if main_screen != nil {
|
||||||
|
main_screen.PushCurPage()
|
||||||
|
main_screen.SetCurPage(self.MainPage)
|
||||||
|
main_screen.Draw()
|
||||||
|
main_screen.SwapAndShow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var APIOBJ GamePlugin
|
||||||
@ -21,6 +21,7 @@ import (
|
|||||||
|
|
||||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings"
|
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings"
|
||||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/21_Warehouse"
|
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/21_Warehouse"
|
||||||
|
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/50_Pico8"
|
||||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/97_MusicPlayer"
|
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/97_MusicPlayer"
|
||||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/98_TinyCloud"
|
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/98_TinyCloud"
|
||||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/99_PowerOFF"
|
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/99_PowerOFF"
|
||||||
@ -32,6 +33,7 @@ var (
|
|||||||
UIPluginList = []*UI.UIPlugin{
|
UIPluginList = []*UI.UIPlugin{
|
||||||
&UI.UIPlugin{1, "", "Menu/GameShell/10_Settings", "Settings", &Settings.APIOBJ},
|
&UI.UIPlugin{1, "", "Menu/GameShell/10_Settings", "Settings", &Settings.APIOBJ},
|
||||||
&UI.UIPlugin{1, "", "Menu/GameShell/21_Warehouse", "Warehouse", &Warehouse.APIOBJ},
|
&UI.UIPlugin{1, "", "Menu/GameShell/21_Warehouse", "Warehouse", &Warehouse.APIOBJ},
|
||||||
|
&UI.UIPlugin{1, "", "Menf/GameShell/50_Pico8", "Pico8", &Pico8.APIOBJ},
|
||||||
&UI.UIPlugin{1, "", "Menu/GameShell/97_MusicPlayer", "Music Player", &MusicPlayer.APIOBJ},
|
&UI.UIPlugin{1, "", "Menu/GameShell/97_MusicPlayer", "Music Player", &MusicPlayer.APIOBJ},
|
||||||
&UI.UIPlugin{1, "", "Menu/GameShell/98_TinyCloud", "TinyCloud", &TinyCloud.APIOBJ},
|
&UI.UIPlugin{1, "", "Menu/GameShell/98_TinyCloud", "TinyCloud", &TinyCloud.APIOBJ},
|
||||||
&UI.UIPlugin{1, "", "Menu/GameShell/99_PowerOFF", "PowerOFF", &PowerOFF.APIOBJ},
|
&UI.UIPlugin{1, "", "Menu/GameShell/99_PowerOFF", "PowerOFF", &PowerOFF.APIOBJ},
|
||||||
|
|||||||
@ -126,9 +126,9 @@ func Init() {
|
|||||||
Fonts[keyname] = FontRW(fonts_data["noto"].Data, i)
|
Fonts[keyname] = FontRW(fonts_data["noto"].Data, i)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
Fonts["notosanscjk12"] = FontRW(fonts_data["notocjk"].Data, 12)
|
Fonts["notosanscjk12"] = font.Font(fonts_path["notocjk"], 12)
|
||||||
Fonts["notosanscjk14"] = FontRW(fonts_data["notocjk"].Data, 14)
|
Fonts["notosanscjk14"] = font.Font(fonts_path["notocjk"], 14)
|
||||||
Fonts["notosanscjk15"] = FontRW(fonts_data["notocjk"].Data, 15)
|
Fonts["notosanscjk15"] = font.Font(fonts_path["notocjk"], 15)
|
||||||
//
|
//
|
||||||
keys_def_init()
|
keys_def_init()
|
||||||
|
|
||||||
|
|||||||
44
sysgo/UI/comercial_package.go
Normal file
44
sysgo/UI/comercial_package.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package UI
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CommercialSoftwarePackage struct {
|
||||||
|
BinLocation string
|
||||||
|
MenuLocation string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCommercialSoftwarePackage(b,m string) *CommercialSoftwarePackage{
|
||||||
|
return &CommercialSoftwarePackage{b,m}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *CommercialSoftwarePackage) Init() {
|
||||||
|
|
||||||
|
script := filepath.Join(self.MenuLocation,"Setup.sh")
|
||||||
|
MakeExecutable(script)
|
||||||
|
script = filepath.Join(self.MenuLocation,"Run.sh")
|
||||||
|
MakeExecutable(script)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *CommercialSoftwarePackage) IsInstalled() bool {
|
||||||
|
return FileExists(self.BinLocation)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *CommercialSoftwarePackage) IsConfiged() bool {
|
||||||
|
return FileExists(filepath.Join(self.MenuLocation,".done"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *CommercialSoftwarePackage) GetRunScript() string {
|
||||||
|
return filepath.Join(self.MenuLocation,"Run.sh")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *CommercialSoftwarePackage) RunSetup() {
|
||||||
|
if self.IsConfiged() == false {
|
||||||
|
script := filepath.Join(self.MenuLocation,"Setup.sh")
|
||||||
|
MakeExecutable(script)
|
||||||
|
System(script) /// Scripts with very short runtime
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -55,7 +55,9 @@ type PluginConfig struct {
|
|||||||
|
|
||||||
type MessageBox struct {
|
type MessageBox struct {
|
||||||
Label
|
Label
|
||||||
Parent *MainScreen
|
Parent *sdl.Surface
|
||||||
|
ParentWidth int
|
||||||
|
ParentHeight int
|
||||||
HWND *sdl.Surface
|
HWND *sdl.Surface
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +68,7 @@ func NewMessageBox() *MessageBox {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *MessageBox) Init(text string, font_obj *ttf.Font, col *color.Color) {
|
func (self *MessageBox) Init(text string, font_obj *ttf.Font, col *color.Color,w int, h int) {
|
||||||
if col != nil {
|
if col != nil {
|
||||||
self.Color = col
|
self.Color = col
|
||||||
}
|
}
|
||||||
@ -77,8 +79,16 @@ func (self *MessageBox) Init(text string, font_obj *ttf.Font, col *color.Color)
|
|||||||
self.Width = 0
|
self.Width = 0
|
||||||
self.Height = 0
|
self.Height = 0
|
||||||
|
|
||||||
self.CanvasHWND = surface.Surface(self.Parent.Width, self.Parent.Height)
|
if w == 0 || h == 0 {
|
||||||
self.HWND = self.Parent.CanvasHWND
|
self.CanvasHWND = surface.Surface(Width,Height)
|
||||||
|
self.ParentWidth = Width
|
||||||
|
self.ParentHeight = Height
|
||||||
|
}else{
|
||||||
|
self.CanvasHWND = surface.Surface(w,h)
|
||||||
|
self.ParentWidth = w
|
||||||
|
self.ParentHeight = h
|
||||||
|
}
|
||||||
|
self.HWND = self.Parent
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +104,7 @@ func (self *MessageBox) Draw() {
|
|||||||
words := strings.Split(self.Text, " ")
|
words := strings.Split(self.Text, " ")
|
||||||
space, _ := font.Size(self.FontObj, " ")
|
space, _ := font.Size(self.FontObj, " ")
|
||||||
|
|
||||||
max_width := self.Parent.Width - 40
|
max_width := self.ParentWidth - 40
|
||||||
x := 0
|
x := 0
|
||||||
y := 0
|
y := 0
|
||||||
|
|
||||||
@ -130,7 +140,7 @@ func (self *MessageBox) Draw() {
|
|||||||
self.Width = x
|
self.Width = x
|
||||||
}
|
}
|
||||||
|
|
||||||
if lines >= self.Parent.Height-40 {
|
if lines >= self.ParentHeight-40 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,8 +148,8 @@ func (self *MessageBox) Draw() {
|
|||||||
self.Height = lines
|
self.Height = lines
|
||||||
|
|
||||||
padding := 5
|
padding := 5
|
||||||
x = (self.Parent.Width - self.Width) / 2
|
x = (self.ParentWidth - self.Width) / 2
|
||||||
y = (self.Parent.Height - self.Height) / 2
|
y = (self.ParentHeight - self.Height) / 2
|
||||||
|
|
||||||
rect_ := rect.Rect(x-padding, y-padding, self.Width+padding*2, self.Height+padding*2)
|
rect_ := rect.Rect(x-padding, y-padding, self.Width+padding*2, self.Height+padding*2)
|
||||||
|
|
||||||
@ -147,7 +157,7 @@ func (self *MessageBox) Draw() {
|
|||||||
|
|
||||||
draw.Rect(self.HWND, &color.Color{255, 255, 255, 255}, &rect_, 0)
|
draw.Rect(self.HWND, &color.Color{255, 255, 255, 255}, &rect_, 0)
|
||||||
|
|
||||||
rect__ := draw.MidRect(self.Parent.Width/2, self.Parent.Height/2, self.Width, self.Height, Width, Height)
|
rect__ := draw.MidRect(self.ParentWidth/2, self.ParentHeight/2, self.Width, self.Height, Width, Height)
|
||||||
|
|
||||||
dest_rect := rect.Rect(0, 0, self.Width, self.Height)
|
dest_rect := rect.Rect(0, 0, self.Width, self.Height)
|
||||||
|
|
||||||
@ -211,8 +221,8 @@ func (self *MainScreen) Init() {
|
|||||||
self.CanvasHWND = surface.Surface(self.Width, self.Height)
|
self.CanvasHWND = surface.Surface(self.Width, self.Height)
|
||||||
|
|
||||||
self.MsgBox = NewMessageBox()
|
self.MsgBox = NewMessageBox()
|
||||||
self.MsgBox.Parent = self
|
self.MsgBox.Parent = self.CanvasHWND
|
||||||
self.MsgBox.Init(" ", self.MsgBoxFont, &color.Color{83, 83, 83, 255})
|
self.MsgBox.Init(" ", self.MsgBoxFont, &color.Color{83, 83, 83, 255},self.Width,self.Height)
|
||||||
|
|
||||||
self.SkinManager = NewSkinManager()
|
self.SkinManager = NewSkinManager()
|
||||||
self.SkinManager.Init()
|
self.SkinManager.Init()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user