mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-12 16:08:52 +01:00
add Switch to python launcher
This commit is contained in:
parent
aca420aab7
commit
bc8193c793
32
Menu/GameShell/10_Settings/LauncherPy/plugin_init.go
Normal file
32
Menu/GameShell/10_Settings/LauncherPy/plugin_init.go
Normal file
@ -0,0 +1,32 @@
|
||||
package LauncherPy
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"github.com/cuu/gogame/time"
|
||||
"github.com/cuu/LauncherGoDev/sysgo/UI"
|
||||
|
||||
)
|
||||
/******************************************************************************/
|
||||
type LauncherPyPlugin struct {
|
||||
UI.Plugin
|
||||
}
|
||||
|
||||
func (self *LauncherPyPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
|
||||
}
|
||||
|
||||
func (self *LauncherPyPlugin) Run( main_screen *UI.MainScreen ) {
|
||||
if main_screen != nil {
|
||||
main_screen.MsgBox.SetText("Rebooting to Launcher")
|
||||
main_screen.MsgBox.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
time.BlockDelay(300)
|
||||
cmd := exec.Command("sed","-i","s/launchergo/launcher/g","~/.bashrc")
|
||||
cmd.Run()
|
||||
|
||||
cmd = exec.Command("sudo","reboot")
|
||||
cmd.Run()
|
||||
}
|
||||
}
|
||||
|
||||
var APIOBJ LauncherPyPlugin
|
||||
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"path/filepath"
|
||||
// "github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
@ -11,6 +12,9 @@ import (
|
||||
|
||||
"github.com/cuu/LauncherGoDev/sysgo/UI"
|
||||
|
||||
"github.com/cuu/LauncherGoDev/Menu/GameShell/10_Settings/LauncherPy"
|
||||
|
||||
|
||||
)
|
||||
|
||||
type SettingsPageSelector struct {
|
||||
@ -49,6 +53,14 @@ func (self *SettingsPageSelector) Draw() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
type SettingPlugin struct{
|
||||
Type int
|
||||
SoFile string
|
||||
FolderName string
|
||||
LabelText string
|
||||
EmbInterface UI.PluginInterface
|
||||
}
|
||||
//##############################################//
|
||||
|
||||
type SettingsPage struct {
|
||||
@ -76,6 +88,16 @@ func NewSettingsPage() *SettingsPage {
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *SettingsPage) GenList() []*SettingPlugin {
|
||||
alist := []*SettingPlugin{
|
||||
&SettingPlugin{0,"wifi.so", "Wifi", "Wi-Fi",nil},
|
||||
&SettingPlugin{0,"about.so", "About", "About",nil},
|
||||
&SettingPlugin{1,"", "LauncherPy","Switch to Launcher",&LauncherPy.APIOBJ},
|
||||
}
|
||||
|
||||
return alist
|
||||
}
|
||||
|
||||
func (self *SettingsPage) Init() {
|
||||
if self.Screen != nil {
|
||||
|
||||
@ -91,16 +113,11 @@ func (self *SettingsPage) Init() {
|
||||
self.PsIndex = 0
|
||||
|
||||
|
||||
alist := [][]string{ // "so file", "folder name", "label text"
|
||||
{"wifi.so","Wifi","Wi-Fi"},
|
||||
{"about.so","About","About"},
|
||||
|
||||
}
|
||||
|
||||
|
||||
start_x := 0
|
||||
start_y := 0
|
||||
|
||||
alist := self.GenList()
|
||||
|
||||
for i,v := range alist{
|
||||
li := UI.NewListItem()
|
||||
li.Parent = self
|
||||
@ -110,18 +127,24 @@ func (self *SettingsPage) Init() {
|
||||
|
||||
li.Fonts["normal"] = self.ListFontObj
|
||||
|
||||
if v[2] != "" {
|
||||
li.Init(v[2])
|
||||
if v.LabelText != "" {
|
||||
li.Init(v.LabelText)
|
||||
}else{
|
||||
li.Init(v[1])
|
||||
li.Init(v.FolderName)
|
||||
}
|
||||
|
||||
if UI.FileExists( self.MyPath+"/"+v[1]+"/"+v[0]) {
|
||||
pi,err := UI.LoadPlugin(self.MyPath+"/"+v[1]+"/"+v[0] )
|
||||
if v.SoFile!= "" && UI.FileExists( filepath.Join(self.MyPath,v.FolderName,v.SoFile )) {
|
||||
pi,err := UI.LoadPlugin(filepath.Join(self.MyPath,v.FolderName,v.SoFile ))
|
||||
UI.Assert(err)
|
||||
li.LinkObj = UI.InitPlugin(pi,self.Screen)
|
||||
self.MyList = append(self.MyList,li)
|
||||
|
||||
}else {
|
||||
if v.EmbInterface != nil {
|
||||
v.EmbInterface.Init(self.Screen)
|
||||
li.LinkObj = v.EmbInterface
|
||||
self.MyList = append(self.MyList,li)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,15 +1,23 @@
|
||||
package UI
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"path/filepath"
|
||||
"os/exec"
|
||||
|
||||
gotime "time"
|
||||
"net/url"
|
||||
|
||||
"github.com/cuu/grab"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/draw"
|
||||
|
||||
)
|
||||
|
||||
type DownloadProcessPage struct {
|
||||
UI.Page
|
||||
Page
|
||||
|
||||
URL string
|
||||
DST_DIR string
|
||||
@ -64,7 +72,7 @@ func (self *DownloadProcessPage) Init() {
|
||||
bgpng.Adjust(0,0,self.PngSize["bg"][0],self.PngSize["bg"][1],0)
|
||||
self.Icons["bg"] = bgpng
|
||||
|
||||
needwifi_bg = NewIconItem()
|
||||
needwifi_bg := NewIconItem()
|
||||
needwifi_bg.ImgSurf = MyIconPool.GetImgSurf("needwifi_bg")
|
||||
needwifi_bg.MyType = ICON_TYPES["STAT"]
|
||||
needwifi_bg.Parent = self
|
||||
@ -74,11 +82,11 @@ func (self *DownloadProcessPage) Init() {
|
||||
|
||||
self.FileNameLabel = NewLabel()
|
||||
self.FileNameLabel.SetCanvasHWND(self.CanvasHWND)
|
||||
self.FileNameLabel.Init("", Fonts["varela12"])
|
||||
self.FileNameLabel.Init("", Fonts["varela12"],nil)
|
||||
|
||||
self.SizeLabel = NewLabel()
|
||||
self.SizeLabel.SetCanvasHWND(self.CanvasHWND)
|
||||
self.SizeLabel.Init("0/0Kb",Fonts["varela12"])
|
||||
self.SizeLabel.Init("0/0Kb",Fonts["varela12"],nil)
|
||||
self.SizeLabel.SetColor( self.URLColor )
|
||||
|
||||
self.Downloader = grab.NewClient()
|
||||
@ -178,7 +186,7 @@ func (self *DownloadProcessPage) StartDownload(_url,dst_dir string) {
|
||||
}
|
||||
|
||||
_, err := url.ParseRequestURI(_url)
|
||||
if err == nil && UI.IsDirectory(dst_dir) {
|
||||
if err == nil && IsDirectory(dst_dir) {
|
||||
self.URL = _url
|
||||
self.DST_DIR = dst_dir
|
||||
}else{
|
||||
@ -190,7 +198,7 @@ func (self *DownloadProcessPage) StartDownload(_url,dst_dir string) {
|
||||
return
|
||||
}
|
||||
|
||||
self.req, _ := grab.NewRequest(self.DST_DIR, _url)
|
||||
self.req, _ = grab.NewRequest(self.DST_DIR, _url)
|
||||
|
||||
fmt.Printf("Downloading %v...\n", self.req.URL())
|
||||
|
||||
@ -224,13 +232,13 @@ func (self *DownloadProcessPage) Draw() {
|
||||
percent = 10
|
||||
}
|
||||
|
||||
rect_ := draw.MidRect(self.Width/2,self.Height/2+33,170,17, UI.Width,UI.Height)
|
||||
rect_ := draw.MidRect(self.Width/2,self.Height/2+33,170,17, Width,Height)
|
||||
|
||||
draw.AARoundRect(self.CanvasHWND,rect_,
|
||||
&color.Color{228,228,228,255},5,0,&color.Color{228,228,228,255})
|
||||
|
||||
|
||||
rect2_ := draw.MidRect( self.Width/2,self.Height/2+33,int(170.0*((float64)percent/100.0)),17, UI.Width,UI.Height )
|
||||
rect2_ := draw.MidRect( self.Width/2,self.Height/2+33,int(170.0*(float64(percent)/100.0)),17, Width,Height )
|
||||
|
||||
rect2_.X = rect_.X
|
||||
rect2_.Y = rect_.Y
|
||||
@ -240,11 +248,11 @@ func (self *DownloadProcessPage) Draw() {
|
||||
|
||||
w,h := self.FileNameLabel.Size()
|
||||
|
||||
rect3_ := draw.MidRect(self.Width/2,self.Height/2+53,w, h,UI.Width,UI.Height)
|
||||
rect3_ := draw.MidRect(self.Width/2,self.Height/2+53,w, h,Width,Height)
|
||||
|
||||
w, h = self.SizeLabel.Size()
|
||||
|
||||
rect4 := draw.MidRect(self.Width/2,self.Height/2+70,w, h,UI.Width,UI.Height)
|
||||
rect4_ := draw.MidRect(self.Width/2,self.Height/2+70,w, h,Width,Height)
|
||||
|
||||
self.FileNameLabel.NewCoord(int(rect3_.X),int(rect3_.Y))
|
||||
self.FileNameLabel.Draw()
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
"bytes"
|
||||
"io"
|
||||
"strconv"
|
||||
"syscall"
|
||||
|
||||
"github.com/cuu/gogame/display"
|
||||
|
||||
@ -206,7 +207,7 @@ func GetUid(path string) int {
|
||||
func CheckBattery() int {
|
||||
batinfos,err := ReadLines(sysgo.Battery)
|
||||
if err == nil {
|
||||
for i,v := range batinfos {
|
||||
for _,v := range batinfos {
|
||||
if strings.HasPrefix(v,"POWER_SUPPLY_CAPACITY") {
|
||||
parts := strings.Split(v,"=")
|
||||
if len(parts) > 1 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user