diff --git a/.gitignore b/.gitignore index b58ac73..b9db5bb 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,6 @@ screenshots/* .pcsx/* *.log +app-local.ini +*.db +app diff --git a/Menu/GameShell/21_Warehouse/image_download_process_page.go b/Menu/GameShell/21_Warehouse/image_download_process_page.go index 933d06f..760059b 100644 --- a/Menu/GameShell/21_Warehouse/image_download_process_page.go +++ b/Menu/GameShell/21_Warehouse/image_download_process_page.go @@ -72,9 +72,16 @@ func (self *ImageDownloadProcessPage) Init() { self.LoadingLabel = LoadingLabel self.Downloader = grab.NewClient() - self.Downloading = make(chan bool) + self.Downloading = make(chan bool,1) } +func (self *ImageDownloadProcessPage) SetDownloading(v bool) { + for len(self.Downloading) > 0 { + <- self.Downloading + } + + self.Downloading <- v +} func (self *ImageDownloadProcessPage) OnLoadCb() { @@ -104,10 +111,8 @@ func (self *ImageDownloadProcessPage) OnLoadCb() { self.req,_ = grab.NewRequest("/tmp",self.URL) self.resp = self.Downloader.Do(self.req) - for len(self.Downloading) > 0 { - <-self.Downloading - } - self.Downloading <- true + + self.SetDownloading(true) go self.UpdateProcessInterval(400) @@ -116,10 +121,10 @@ func (self *ImageDownloadProcessPage) OnLoadCb() { } func (self *ImageDownloadProcessPage) UpdateProcessInterval(ms int) { - + ms_total := 0 t := gotime.NewTicker(gotime.Duration(ms) * gotime.Millisecond) defer t.Stop() - +L: for { select { case <-t.C: @@ -127,14 +132,17 @@ func (self *ImageDownloadProcessPage) UpdateProcessInterval(ms int) { self.resp.BytesComplete(), self.resp.Size, 100*self.resp.Progress()) - + ms_total += ms + if(ms_total > 10000) { + fmt.Println("Get preview image timeout") + break L + } case <-self.resp.Done: // download is complete - break + break L case v:= <-self.Downloading: if v == false { - t.Stop() - break + break L } } } @@ -184,7 +192,7 @@ func (self *ImageDownloadProcessPage) KeyDown(ev *event.Event) { if UI.IsKeyMenuOrB(ev.Data["Key"]) { - self.Downloading <- false + self.SetDownloading(false) self.ReturnToUpLevelPage() self.Screen.Draw() diff --git a/Menu/GameShell/21_Warehouse/load_house_page.go b/Menu/GameShell/21_Warehouse/load_house_page.go index 45a98cd..2c133b2 100644 --- a/Menu/GameShell/21_Warehouse/load_house_page.go +++ b/Menu/GameShell/21_Warehouse/load_house_page.go @@ -8,6 +8,7 @@ import ( "strings" "encoding/json" "path" + "path/filepath" "github.com/veandco/go-sdl2/ttf" @@ -15,6 +16,7 @@ import ( //"github.com/cuu/gogame/draw" "github.com/cuu/gogame/color" "github.com/cuu/gogame/event" + "github.com/cuu/gogame/time" "github.com/clockworkpi/LauncherGoDev/sysgo/UI" "github.com/cuu/grab" ) @@ -60,10 +62,18 @@ func (self *LoadHousePage) Init() { self.LoadingLabel.SetColor(self.TextColor) self.Downloader = grab.NewClient() - self.Downloading = make(chan bool) + self.Downloading = make(chan bool,1) } +func (self *LoadHousePage) SetDownloading(v bool) { + for len(self.Downloading) > 0 { + <- self.Downloading + } + + self.Downloading <- v +} + func (self *LoadHousePage) OnLoadCb() { if len(self.URL) < 10 { @@ -77,7 +87,7 @@ func (self *LoadHousePage) OnLoadCb() { //filename := strings.TrimSpace(parts[len(parts)-1]) local_dir := strings.Split(self.URL,"raw.githubusercontent.com") home_path, _ := os.UserHomeDir() - + fmt.Println("LoadHouse OnLoadCb") if len(local_dir) > 1 { menu_file := local_dir[1] local_menu_file := fmt.Sprintf("%s/aria2downloads%s", @@ -93,21 +103,16 @@ func (self *LoadHousePage) OnLoadCb() { defer jsonFile.Close() byteValue, _ := ioutil.ReadAll(jsonFile) json.Unmarshal(byteValue, &result) - - for _, repo := range result.List { - self.Parent.MyStack.Push(repo) - } + self.Parent.MyStack.Push(result.List) self.Leave() } else { + self.req,_ = grab.NewRequest("/tmp",self.URL) self.resp = self.Downloader.Do(self.req) - - for len(self.Downloading) > 0 { - <-self.Downloading - } - - self.Downloading <- true + + self.SetDownloading(true) + fmt.Println("Start Download index json to /tmp,grab") go self.UpdateProcessInterval(400) } @@ -115,9 +120,10 @@ func (self *LoadHousePage) OnLoadCb() { } func (self *LoadHousePage) UpdateProcessInterval(ms int) { + ms_total := 0 t := gotime.NewTicker(gotime.Duration(ms) * gotime.Millisecond) defer t.Stop() - +L: for { select { case <-t.C: @@ -125,20 +131,25 @@ func (self *LoadHousePage) UpdateProcessInterval(ms int) { self.resp.BytesComplete(), self.resp.Size, 100*self.resp.Progress()) - + ms_total += ms + if(ms_total > 5000) { + fmt.Println("LoadHouse Timeout") + break L + } case <-self.resp.Done: // download is complete - break - case v:= <-self.Downloading: + fmt.Println("Grab Download House done") + break L + case v:= <- self.Downloading: if v == false { - t.Stop() - break + break L } } } - //dst_filename := self.resp.Filename - + dst_filename := self.resp.Filename + fmt.Println("dst_filename ",dst_filename) + if err := self.resp.Err(); err == nil {//download successfully home_path, _ := os.UserHomeDir() parts := strings.Split(self.URL,"/") @@ -154,14 +165,21 @@ func (self *LoadHousePage) UpdateProcessInterval(ms int) { home_path,menu_file) } dl_file := path.Join("/tmp",filename) - if UI.IsDirectory( path.Base(local_menu_file) ) == false { - merr := os.MkdirAll( path.Base(local_menu_file), os.ModePerm) + fmt.Println("dl_file: ",dl_file) + fmt.Println(local_menu_file) + + + if UI.IsDirectory( filepath.Dir(local_menu_file) ) == false { + merr := os.MkdirAll( filepath.Dir(local_menu_file), os.ModePerm) if merr != nil { panic(merr) } } UI.CopyFile(dl_file,local_menu_file) + + os.Remove(dl_file) + var result WareHouseIndex jsonFile, err := os.Open(local_menu_file) if err != nil { @@ -171,24 +189,22 @@ func (self *LoadHousePage) UpdateProcessInterval(ms int) { defer jsonFile.Close() byteValue, _ := ioutil.ReadAll(jsonFile) json.Unmarshal(byteValue, &result) - - for _, repo := range result.List { - self.Parent.MyStack.Push(repo) - } - + self.Parent.MyStack.Push(result.List) self.Leave() } else { + fmt.Println(err) self.Screen.MsgBox.SetText("Fetch house failed") self.Screen.MsgBox.Draw() self.Screen.SwapAndShow() + time.BlockDelay(500) } } func (self *LoadHousePage) Leave() { - self.Downloading <- false + self.SetDownloading(false) self.ReturnToUpLevelPage() self.Screen.Draw() diff --git a/Menu/GameShell/21_Warehouse/plugin.json b/Menu/GameShell/21_Warehouse/plugin.json new file mode 100644 index 0000000..7219b50 --- /dev/null +++ b/Menu/GameShell/21_Warehouse/plugin.json @@ -0,0 +1,5 @@ +{ +"SO_FILE":"", +"NAME":"Warehouse" +} + diff --git a/Menu/GameShell/21_Warehouse/plugin_init.go b/Menu/GameShell/21_Warehouse/plugin_init.go index cae9905..fed3f8e 100644 --- a/Menu/GameShell/21_Warehouse/plugin_init.go +++ b/Menu/GameShell/21_Warehouse/plugin_init.go @@ -19,10 +19,12 @@ type WareHousePlugin struct { MainPage *WareHouse } +var aria2dl_folder = "%s/aria2downloads%s" + func (self *WareHousePlugin) Init(main_screen *UI.MainScreen) { self.MainPage = NewWareHouse() self.MainPage.SetScreen(main_screen) - self.MainPage.SetName("Tiny cloud") + self.MainPage.SetName("Warehouse") self.MainPage.Init() } diff --git a/Menu/GameShell/21_Warehouse/ware_house_list_item.go b/Menu/GameShell/21_Warehouse/ware_house_list_item.go index 0975302..16f89c4 100644 --- a/Menu/GameShell/21_Warehouse/ware_house_list_item.go +++ b/Menu/GameShell/21_Warehouse/ware_house_list_item.go @@ -13,7 +13,7 @@ type WareHouseListItem struct { Type string Value map[string]string - Parent *WareHouse + } @@ -86,7 +86,7 @@ func (self *WareHouseListItem) Draw() { if self.Type == "source" || self.Type == "dir" { _,h := self.Icons["ware"].Size() - self.Icons["ware"].NewCoord(4,(self.Height - h)/2) + self.Icons["ware"].NewCoord(4,self.PosY + (self.Height - h)/2) self.Icons["ware"].DrawTopLeft() } @@ -96,13 +96,13 @@ func (self *WareHouseListItem) Draw() { _icon = "appdling" } _,h := self.Icons[_icon].Size() - self.Icons[_icon].NewCoord(4,(self.Height - h )/2) + self.Icons[_icon].NewCoord(4,self.PosY + (self.Height - h )/2) self.Icons[_icon].DrawTopLeft() } if self.Type == "add_house" { _,h := self.Icons["add"].Size() - self.Icons["add"].NewCoord(4,(self.Height - h)/2) + self.Icons["add"].NewCoord(4,self.PosY+(self.Height - h)/2) self.Icons["add"].DrawTopLeft() } diff --git a/Menu/GameShell/21_Warehouse/ware_house_page.go b/Menu/GameShell/21_Warehouse/ware_house_page.go index ab68ac4..0d7ea62 100644 --- a/Menu/GameShell/21_Warehouse/ware_house_page.go +++ b/Menu/GameShell/21_Warehouse/ware_house_page.go @@ -11,6 +11,7 @@ import ( "io/ioutil" "path/filepath" "encoding/json" + "reflect" "database/sql" _ "github.com/mattn/go-sqlite3" @@ -228,6 +229,12 @@ func (self *WareHouse) SyncTasks() []map[string]string { return ret } +func IsSlice(v interface{}) bool { + if reflect.TypeOf(v).Kind() == reflect.Slice || reflect.TypeOf(v).Kind() == reflect.Array { + return true + } + return false +} func (self *WareHouse) SyncList() { @@ -240,10 +247,17 @@ func (self *WareHouse) SyncList() { var repos []map[string]string + + fmt.Printf("SyncList: %+v\n", self.MyStack) + stk := self.MyStack.Last() stk_len := self.MyStack.Length() - repos = append(repos, stk.(map[string]string)) + if IsSlice(stk) { + repos = append(repos, stk.([]map[string]string)...) + }else { + repos = append(repos, stk.(map[string]string)) + } add_new_house := make(map[string]string) add_new_house["title"] = "Add new warehouse..." @@ -266,7 +280,8 @@ func (self *WareHouse) SyncList() { } for _, u := range repos { - li := &WareHouseListItem{} + fmt.Printf("%+v\n",u) + li := NewWareHouseListItem() li.Parent = self li.PosX = start_x li.PosY = start_y + last_height @@ -285,7 +300,8 @@ func (self *WareHouse) SyncList() { if err != nil { log.Fatal( err ) } - local_menu_file := fmt.Sprintf("%s/aria2download%s",home_path,menu_file) + local_menu_file := fmt.Sprintf(aria2dl_folder,home_path,menu_file) + fmt.Println("for loop ",local_menu_file) if UI.FileExists(local_menu_file) { li.ReadOnly = false }else { @@ -350,12 +366,16 @@ func (self *WareHouse) Init() { self.RemovePage.StartOrAEvent = self.RemoveGame self.RemovePage.Name = "Are you sure?" + self.RemovePage.Init() + self.Keyboard = UI.NewKeyboard() self.Keyboard.Name = "Enter warehouse addr" self.Keyboard.FootMsg = [5]string{"Nav.","Add","ABC","Backspace","Enter"} self.Keyboard.Screen = self.Screen self.Keyboard.Init() - + self.Keyboard.SetPassword("github.com/cuu/warehouse") + self.Keyboard.Caller = self + self.PreviewPage = NewImageDownloadProcessPage() self.PreviewPage.Screen = self.Screen self.PreviewPage.Name ="Preview" @@ -399,7 +419,7 @@ func (self *WareHouse) ResetHouse() { remote_file_url := cur_li.Value["file"] parts := strings.Split(remote_file_url,"raw.githubusercontent.com") menu_file := parts[1] - local_menu_file := fmt.Sprintf("%s/aria2download%s",home_path,menu_file) + local_menu_file := fmt.Sprintf(aria2dl_folder,home_path,menu_file) local_menu_file_path := filepath.Dir(local_menu_file) fmt.Println(local_menu_file) @@ -467,11 +487,14 @@ func (self *WareHouse) UrlIsDownloading(url string) (string,bool) { if uris,err := self.rpcc.GetURIs(v.Gid);err == nil { for _,x := range uris { if x.URI == url { + fmt.Println(x.URI," ",url) return v.Gid,true } } } } + }else { + log.Fatal(err) } return "",false } @@ -480,6 +503,7 @@ func (self *WareHouse) RemoveGame() { if self.PsIndex > len(self.MyList) -1 { return } + fmt.Println("RemoveGame") cur_li := self.MyList[self.PsIndex].(*WareHouseListItem) fmt.Println("Remove cur_li._Value",cur_li.Value) @@ -505,7 +529,7 @@ func (self *WareHouse) RemoveGame() { remote_file_url := cur_li.Value["file"] parts := strings.Split(remote_file_url,"raw.githubusercontent.com") menu_file := parts[1] - local_menu_file := fmt.Sprintf("%s/aria2download%s",home_path,menu_file) + local_menu_file := fmt.Sprintf(aria2dl_folder,home_path,menu_file) local_menu_file_path := filepath.Dir(local_menu_file) gid,ret := self.UrlIsDownloading(remote_file_url) @@ -532,14 +556,14 @@ func (self *WareHouse) Click() { } cur_li := self.MyList[self.PsIndex].(*WareHouseListItem) home_path, _ := os.UserHomeDir() - fmt.Println("cur_li._Value",cur_li.Value) + fmt.Println("Click cur_li._Value",cur_li.Value) if cur_li.Value["type"] == "source" || cur_li.Value["type"] == "dir" { remote_file_url := cur_li.Value["file"] parts := strings.Split(remote_file_url,"raw.githubusercontent.com")//assume master branch menu_file := parts[1] - local_menu_file := fmt.Sprintf("%s/aria2download%s",home_path,menu_file) - fmt.Println(local_menu_file) + local_menu_file := fmt.Sprintf(aria2dl_folder,home_path,menu_file) + fmt.Println("warehouse click: ",local_menu_file) if UI.FileExists(local_menu_file) == false { self.LoadHouse() }else { @@ -559,11 +583,8 @@ func (self *WareHouse) Click() { byteValue, _ := ioutil.ReadAll(jsonFile) json.Unmarshal(byteValue, &result) + self.MyStack.Push(result.List) - for _, repo := range result.List { - self.MyStack.Push(repo) - } - self.SyncList() self.Screen.Draw() self.Screen.SwapAndShow() @@ -581,17 +602,28 @@ func (self *WareHouse) Click() { remote_file_url := cur_li.Value["file"] parts := strings.Split(remote_file_url,"raw.githubusercontent.com")//assume master branch menu_file := parts[1] - local_menu_file := fmt.Sprintf("%s/aria2download%s",home_path,menu_file) - + local_menu_file := fmt.Sprintf(aria2dl_folder,home_path,menu_file) + fmt.Println("Click on game ", local_menu_file) + if UI.FileExists(local_menu_file) == false { gid,ret := self.UrlIsDownloading(remote_file_url) if ret == false { - gid,err := self.rpcc.AddURI([]string{remote_file_url},"out:"+menu_file) + + outfile := struct { + Out string `json:"out"` + + }{Out:menu_file} + + gid,err := self.rpcc.AddURI([]string{remote_file_url},outfile) + if err != nil { log.Fatal(err) }else { + fmt.Println("Warehouse Click game is downloading, ",gid) + fmt.Println(remote_file_url) self.Aria2DownloadingGid = gid } + } else { fmt.Println(self.rpcc.TellStatus(gid,"status","totalLength","completedLength")) self.Screen.MsgBox.SetText("Getting the game now") @@ -601,7 +633,7 @@ func (self *WareHouse) Click() { self.Screen.TitleBar.Redraw() } }else { - fmt.Println("file downloaded") //maybe check it if is installed fst,then execute it + fmt.Println("file downloaded ", cur_li.Value) //maybe check it if is installed fst,then execute it if cur_li.Value["type"] == "launcher" && cur_li.ReadOnly == false { local_menu_file_path := filepath.Dir(local_menu_file) game_sh := filepath.Join(local_menu_file_path,cur_li.Value["title"],cur_li.Value["title"]+".sh") @@ -656,6 +688,7 @@ func (self *WareHouse) raw_github_com(url string) (bool,string) { func (self *WareHouse) OnKbdReturnBackCb() { + inputed:= strings.Join(self.Keyboard.Textarea.MyWords,"") inputed = strings.Replace(inputed,"http://","",-1) inputed = strings.Replace(inputed,"https://","",-1) @@ -746,7 +779,7 @@ func (self *WareHouse) OnReturnBackCb() { self.FootMsg[2] = "Remove" self.FootMsg[1] = "Preview" } - + self.SyncList() self.RestoreScrolled() @@ -904,6 +937,12 @@ func (self *WareHouse) KeyDown(ev *event.Event) { func (self *WareHouse) Draw() { self.ClearCanvas() + if self.PsIndex > len(self.MyList) -1 { + self.PsIndex = len(self.MyList) -1 + } + if self.PsIndex < 0 { + self.PsIndex = 0 + } if len(self.MyList) == 0 { return } else { @@ -913,7 +952,7 @@ func (self *WareHouse) Draw() { self.Ps.Draw() for _,v := range self.MyList { _,y := v.Coord() - if y > self.Height + self.Height/2 { + if y > (self.Height + self.Height/2) { break } if y < 0 { diff --git a/appinstaller/app_notifier.go b/appinstaller/app_notifier.go new file mode 100644 index 0000000..1e452bd --- /dev/null +++ b/appinstaller/app_notifier.go @@ -0,0 +1,163 @@ +package main + +import ( + "fmt" + "log" + "os" + "os/exec" + "strings" + "path/filepath" + "context" + "time" + + "github.com/zyxar/argo/rpc" + + //"database/sql" + //_"github.com/mattn/go-sqlite3" +) + +// The RPC server might send notifications to the client. +// Notifications is unidirectional, therefore the client which receives the notification must not respond to it. +// The method signature of a notification is much like a normal method request but lacks the id key + +func fileExists(filename string) bool { + info, err := os.Stat(filename) + if os.IsNotExist(err) { + return false + } + return !info.IsDir() +} + +func System(cmd string) string { + ret := "" + out, err := exec.Command("bash", "-c", cmd).Output() + if err != nil { + if _, ok := err.(*exec.ExitError); ok { + //exit code !=0 ,but it can be ignored + } else { + fmt.Println(err) + } + } else { + ret = string(out) + } + + return ret +} + +type AppNotifier struct{} + +func (AppNotifier) OnDownloadStart(events []rpc.Event) { log.Printf("%s started.", events) } +func (AppNotifier) OnDownloadPause(events []rpc.Event) { log.Printf("%s paused.", events) } +func (AppNotifier) OnDownloadStop(events []rpc.Event) { log.Printf("%s stopped.", events) } + +func (AppNotifier) OnDownloadComplete(events []rpc.Event) { + log.Printf("AppNotifier %s completed.", events) + + rpcc_, err := rpc.New(context.Background(), rpcURI, rpcSecret, time.Second,nil) + if err != nil { + fmt.Fprintln(os.Stderr, err) + return + } + defer rpcc_.Close() + + for _,v := range events { + gid := v.Gid + msg, err := rpcc_.TellStatus(gid) + if err == nil { + log.Printf("%+v\n",msg) + if msg.Status == "complete" { + go InstallGame(msg) + }else if msg.Status == "error" { + log.Println(msg.ErrorMessage) + for _,v := range msg.Files { + if fileExists(v.Path) { + e := os.Remove(v.Path) + if e != nil { + log.Fatal(e) + } + } + if fileExists( v.Path + ".aria2" ) { + e := os.Remove(v.Path + ".aria2") + if e != nil { + log.Fatal(e) + } + } + } + } + }else { + log.Println("TellStatus err: ",err) + } + } +} + +func (AppNotifier) OnDownloadError(events []rpc.Event) { + log.Printf("%s error.", events) +} + +func (AppNotifier) OnBtDownloadComplete(events []rpc.Event) { + + log.Printf("bt %s completed.", events) + +} + + + +func InstallGame(msg rpc.StatusInfo) { + + if len(msg.Files) <= 0 { + return + } + + ret := msg.Files[0].URIs + home_path,_ := os.UserHomeDir() + + remote_file_url := ret[0].URI + + parts := strings.Split(remote_file_url,"raw.githubusercontent.com") + if len(parts) < 1 { + return + } + + menu_file := parts[1] + local_menu_file := fmt.Sprintf("%s/aria2downloads%s",home_path,menu_file) + local_menu_file_path := filepath.Dir(local_menu_file) + + if fileExists(local_menu_file) { + gametype := "launcher" + + if strings.HasSuffix(local_menu_file,".tar.gz") { + gametype = "launcher" + } + + if strings.HasSuffix(local_menu_file,".p8.png") { + gametype = "pico8" + } + + if strings.HasSuffix(local_menu_file,".tic") { + gametype = "tic80" + } + + if gametype == "launcher" { + _cmd := fmt.Sprintf( "tar zxvf '%s' -C %s",local_menu_file, local_menu_file_path) + fmt.Println(_cmd) + System(_cmd) + } + + if gametype == "pico8" { + _cmd := fmt.Sprintf("cp -rf '%s' ~/.lexaloffle/pico-8/carts/", local_menu_file) + fmt.Println(_cmd) + System(_cmd) + } + + if gametype == "tic80" { + _cmd := fmt.Sprintf("cp -rf '%s' ~/games/TIC-80/",local_menu_file) + fmt.Println(_cmd) + System(_cmd) + } + + }else { + fmt.Println(local_menu_file, " not found") + } + +} + diff --git a/appinstaller/appinstaller.go b/appinstaller/appinstaller.go new file mode 100644 index 0000000..2e19091 --- /dev/null +++ b/appinstaller/appinstaller.go @@ -0,0 +1,100 @@ +package main + +import ( + "context" + "errors" + "flag" + "fmt" + "os" + //"os/exec" + "time" + "log" + + "github.com/zyxar/argo/rpc" + + "database/sql" + _"github.com/mattn/go-sqlite3" +) + +var ( + rpcc rpc.Client + rpcSecret string + rpcURI string + launchLocal bool + errParameter = errors.New("invalid parameter") + errNotSupportedCmd = errors.New("not supported command") + errInvalidCmd = errors.New("invalid command") +) + +func init() { + flag.StringVar(&rpcSecret, "secret", "", "set --rpc-secret for aria2c") + flag.StringVar(&rpcURI, "uri", "ws://localhost:6800/jsonrpc", "set rpc address") + flag.BoolVar(&launchLocal, "launch", false, "launch local aria2c daemon") +} + +func InitSql() { + db, err := sql.Open("sqlite3", "foo.db") + if err != nil { + log.Fatal(err) + } + defer db.Close() + sqlStmt := ` + CREATE TABLE IF NOT EXISTS tasks ( + id integer PRIMARY KEY, + gid text NOT NULL, + title text NOT NULL, + file text NOT NULL, + type text NOT NULL, + status text, + totalLength text, + completedLength text, + fav text + ); + ` + + _, err = db.Exec(sqlStmt) + if err != nil { + log.Printf("%q: %s\n", err, sqlStmt) + return + } + + sqlStmt = ` + CREATE TABLE IF NOT EXISTS warehouse ( + id integer PRIMARY KEY, + title text NOT NULL, + file text NOT NULL, + type text NOT NULL + ); + ` + _,err = db.Exec(sqlStmt) + if err != nil { + log.Printf("%q: %s\n",err,sqlStmt) + return + } +} + +func main() { + flag.Parse() + + + if flag.NArg() == 0 { + fmt.Fprintf(os.Stderr, "usage: app start\n") + flag.PrintDefaults() + fmt.Fprintln(os.Stderr) + } + + InitSql() + + var err error + rpcc, err = rpc.New(context.Background(), rpcURI, rpcSecret, time.Second, AppNotifier{}) + if err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(2) + } + defer rpcc.Close() + + for { + + } +} + diff --git a/local-build.sh b/local-build.sh new file mode 100755 index 0000000..5bca7c9 --- /dev/null +++ b/local-build.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -x +go build -o app appinstaller/appinstaller.go appinstaller/app_notifier.go + +if [ $? -eq 0 ]; then + cp app ~/github/clockworkpi/launchergo +fi + + +go build -o launchergo main.go mainscreen.go +#go build -ldflags="-s -w" -o main main.go mainscreen.go + +if [ $? -eq 0 ]; then + cp launchergo ~/github/clockworkpi/launchergo +fi + + + + diff --git a/sysgo/UI/confirm_page.go b/sysgo/UI/confirm_page.go index 11fccd0..31ec9b5 100644 --- a/sysgo/UI/confirm_page.go +++ b/sysgo/UI/confirm_page.go @@ -67,7 +67,7 @@ type ConfirmPage struct { func NewConfirmPage() *ConfirmPage { p := &ConfirmPage{} - p.ListFont = Fonts["veramono20"] + p.ListFont = MyLangManager.TrFont("veramono20") p.FootMsg = [5]string{"Nav", "", "", "Cancel", "Yes"} p.ConfirmText = "Confirm?" diff --git a/sysgo/UI/yes_cancel_confirm_page.go b/sysgo/UI/yes_cancel_confirm_page.go index a08c08d..fb1edeb 100644 --- a/sysgo/UI/yes_cancel_confirm_page.go +++ b/sysgo/UI/yes_cancel_confirm_page.go @@ -1,7 +1,7 @@ package UI import ( - //"fmt" + "fmt" //"os" //"path/filepath" //"strings" @@ -24,7 +24,8 @@ func NewYesCancelConfirmPage() *YesCancelConfirmPage { p := &YesCancelConfirmPage{} p.FootMsg = [5]string{"Nav","","","Cancel","Yes"} p.ConfirmText = MyLangManager.Tr("Awaiting Input") - + p.ListFont = MyLangManager.TrFont("veramono20") + p.StartOrAEvent = nil p.KeyXEvent = nil p.KeyYEvent = nil @@ -42,8 +43,11 @@ func (self *YesCancelConfirmPage) KeyDown(ev *event.Event) { if IsKeyStartOrA(ev.Data["Key"]) { if self.StartOrAEvent != nil { + fmt.Println("StartOrA yes or no") self.StartOrAEvent() self.ReturnToUpLevelPage() + }else { + fmt.Println("StartOrA nil") } }