mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-12 07:58:51 +01:00
Reunicon icons from ~/apps/Menu/
This commit is contained in:
parent
aa878e79da
commit
ba7451271a
2
main.go
2
main.go
@ -257,6 +257,8 @@ func run() int {
|
|||||||
main_screen.FootBar = foot_bar
|
main_screen.FootBar = foot_bar
|
||||||
|
|
||||||
ReadTheDirIntoPages(main_screen,"Menu",0,nil)
|
ReadTheDirIntoPages(main_screen,"Menu",0,nil)
|
||||||
|
ReadTheDirIntoPages(main_screen,"/home/cpi/apps/Menu",1,main_screen.Pages[len(main_screen.Pages)-1])
|
||||||
|
ReunionPagesIcons(main_screen)
|
||||||
|
|
||||||
main_screen.FartherPages()
|
main_screen.FartherPages()
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
//os/exec"
|
//os/exec"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/yookoala/realpath"
|
"github.com/yookoala/realpath"
|
||||||
|
|
||||||
@ -26,6 +27,42 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func ReunionPagesIcons(self *UI.MainScreen) {
|
||||||
|
type Tup struct {
|
||||||
|
FileName string
|
||||||
|
OrigIdx int
|
||||||
|
}
|
||||||
|
|
||||||
|
var tmp []Tup
|
||||||
|
|
||||||
|
for i,p := range self.Pages {
|
||||||
|
p_icons := p.GetIcons()
|
||||||
|
for i,x := range p_icons {
|
||||||
|
var t Tup
|
||||||
|
if x.GetFileName() != ""{
|
||||||
|
if strings.Contains(x.GetFileName(),"_") == false {
|
||||||
|
t = Tup{"98_"+x.GetFileName(),i}
|
||||||
|
}else {
|
||||||
|
t = Tup{x.GetFileName(),i}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
t = Tup{"",i}
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp = append(tmp,t)
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Slice(tmp, func(i, j int) bool { return tmp[i].FileName < tmp[j].FileName })
|
||||||
|
//fmt.Println(tmp)
|
||||||
|
var new_icons []UI.IconItemInterface
|
||||||
|
for _,x := range tmp {
|
||||||
|
new_icons = append(new_icons, p_icons[x.OrigIdx])
|
||||||
|
}
|
||||||
|
self.Pages[i].(*UI.Page).Icons = new_icons
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func ReadTheDirIntoPages(self *UI.MainScreen, _dir string, pglevel int, cur_page UI.PageInterface) {
|
func ReadTheDirIntoPages(self *UI.MainScreen, _dir string, pglevel int, cur_page UI.PageInterface) {
|
||||||
|
|
||||||
@ -49,11 +86,12 @@ func ReadTheDirIntoPages(self *UI.MainScreen, _dir string, pglevel int, cur_page
|
|||||||
}else{ // on cur_page now
|
}else{ // on cur_page now
|
||||||
i2:= self.ExtraName(f.Name())
|
i2:= self.ExtraName(f.Name())
|
||||||
iconitem := UI.NewIconItem()
|
iconitem := UI.NewIconItem()
|
||||||
|
iconitem.FileName = f.Name()
|
||||||
iconitem.AddLabel(i2,self.IconFont)
|
iconitem.AddLabel(i2,self.IconFont)
|
||||||
if UI.FileExists( UI.SkinMap(_dir+"/"+i2+".png")) {
|
if UI.FileExists( UI.SkinMap(_dir+"/"+i2+".png")) {
|
||||||
iconitem.ImageName = UI.SkinMap(_dir+"/"+i2+".png")
|
iconitem.ImageName = UI.SkinMap(_dir+"/"+i2+".png")
|
||||||
}else {
|
}else {
|
||||||
fmt.Println( UI.SkinMap(_dir+"/"+i2+".png") )
|
//fmt.Println( UI.SkinMap(_dir+"/"+i2+".png") )
|
||||||
untitled := UI.NewUntitledIcon()
|
untitled := UI.NewUntitledIcon()
|
||||||
untitled.Init()
|
untitled.Init()
|
||||||
if len(i2) > 1 {
|
if len(i2) > 1 {
|
||||||
@ -134,6 +172,15 @@ func ReadTheDirIntoPages(self *UI.MainScreen, _dir string, pglevel int, cur_page
|
|||||||
fmt.Println("ReadTheDirIntoPages EmulatorConfig ",err)
|
fmt.Println("ReadTheDirIntoPages EmulatorConfig ",err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}else if self.IsExecPackage(_dir+"/"+f.Name()) {
|
||||||
|
iconitem.MyType = UI.ICON_TYPES["EXE"]
|
||||||
|
rel_path,err := realpath.Realpath( filepath.Join(_dir,f.Name(),i2+".sh"))
|
||||||
|
if err != nil {
|
||||||
|
rel_path,_ = filepath.Abs(filepath.Join(_dir,f.Name(),i2+".sh"))
|
||||||
|
}
|
||||||
|
iconitem.CmdPath = rel_path
|
||||||
|
UI.MakeExecutable( iconitem.CmdPath )
|
||||||
|
cur_page.AppendIcon(iconitem)
|
||||||
}else {
|
}else {
|
||||||
iconitem.MyType = UI.ICON_TYPES["DIR"]
|
iconitem.MyType = UI.ICON_TYPES["DIR"]
|
||||||
linkpage := UI.NewPage()
|
linkpage := UI.NewPage()
|
||||||
@ -154,6 +201,8 @@ func ReadTheDirIntoPages(self *UI.MainScreen, _dir string, pglevel int, cur_page
|
|||||||
}
|
}
|
||||||
|
|
||||||
iconitem.CmdPath = rel_path
|
iconitem.CmdPath = rel_path
|
||||||
|
iconitem.FileName = f.Name()
|
||||||
|
|
||||||
UI.MakeExecutable( iconitem.CmdPath )
|
UI.MakeExecutable( iconitem.CmdPath )
|
||||||
iconitem.MyType = UI.ICON_TYPES["EXE"]
|
iconitem.MyType = UI.ICON_TYPES["EXE"]
|
||||||
if UI.FileExists( UI.SkinMap( _dir+"/"+ UI.ReplaceSuffix(i2,"png"))) {
|
if UI.FileExists( UI.SkinMap( _dir+"/"+ UI.ReplaceSuffix(i2,"png"))) {
|
||||||
|
|||||||
@ -54,7 +54,7 @@ type IconItemInterface interface {
|
|||||||
|
|
||||||
GetCmdInvoke() PluginInterface
|
GetCmdInvoke() PluginInterface
|
||||||
|
|
||||||
|
GetFileName() string
|
||||||
Draw()
|
Draw()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +72,7 @@ type IconItem struct {
|
|||||||
Label LabelInterface
|
Label LabelInterface
|
||||||
Align int
|
Align int
|
||||||
AnimationTime int
|
AnimationTime int
|
||||||
|
FileName string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -240,6 +241,9 @@ func (self *IconItem) GetCmdInvoke() PluginInterface {
|
|||||||
return self.CmdInvoke
|
return self.CmdInvoke
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *IconItem) GetFileName() string {
|
||||||
|
return self.FileName
|
||||||
|
}
|
||||||
func (self *IconItem) Draw() {
|
func (self *IconItem) Draw() {
|
||||||
if self.Parent == nil {
|
if self.Parent == nil {
|
||||||
fmt.Println("Error: IconItem Draw Parent nil")
|
fmt.Println("Error: IconItem Draw Parent nil")
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"log"
|
"log"
|
||||||
//"encoding/json"
|
//"encoding/json"
|
||||||
//"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/veandco/go-sdl2/sdl"
|
"github.com/veandco/go-sdl2/sdl"
|
||||||
"github.com/veandco/go-sdl2/ttf"
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
@ -264,6 +264,27 @@ func (self *MainScreen) ExtraName(name string) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//ExecPackage is all-in-one folder ,Name.sh,Name.png,etc
|
||||||
|
func (self *MainScreen) IsExecPackage(dirname string ) bool {
|
||||||
|
files,err := ioutil.ReadDir(dirname)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
bname := filepath.Base(dirname)
|
||||||
|
bname = self.ExtraName(bname)
|
||||||
|
|
||||||
|
for _,v := range files {
|
||||||
|
if v.Name() == bname+".sh" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (self *MainScreen) IsPluginPackage(dirname string ) bool {
|
func (self *MainScreen) IsPluginPackage(dirname string ) bool {
|
||||||
ret := false
|
ret := false
|
||||||
files,err := ioutil.ReadDir(dirname)
|
files,err := ioutil.ReadDir(dirname)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user