mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2026-03-19 10:22:41 +01:00
go fmt ./...
This commit is contained in:
@@ -1,37 +1,34 @@
|
||||
package Storage
|
||||
|
||||
|
||||
import (
|
||||
/*
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
/*
|
||||
"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/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/event"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/color"
|
||||
*/
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
|
||||
)
|
||||
|
||||
/******************************************************************************/
|
||||
type StoragePlugin struct {
|
||||
UI.Plugin
|
||||
StoragePage *StoragePage
|
||||
StoragePage *StoragePage
|
||||
}
|
||||
|
||||
|
||||
func (self *StoragePlugin) Init( main_screen *UI.MainScreen ) {
|
||||
func (self *StoragePlugin) Init(main_screen *UI.MainScreen) {
|
||||
self.StoragePage = NewStoragePage()
|
||||
self.StoragePage.SetScreen( main_screen)
|
||||
self.StoragePage.SetScreen(main_screen)
|
||||
self.StoragePage.SetName("Storage")
|
||||
self.StoragePage.Init()
|
||||
self.StoragePage.Init()
|
||||
}
|
||||
|
||||
func (self *StoragePlugin) Run( main_screen *UI.MainScreen ) {
|
||||
func (self *StoragePlugin) Run(main_screen *UI.MainScreen) {
|
||||
if main_screen != nil {
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.StoragePage)
|
||||
main_screen.PushCurPage()
|
||||
main_screen.SetCurPage(self.StoragePage)
|
||||
main_screen.Draw()
|
||||
main_screen.SwapAndShow()
|
||||
}
|
||||
|
||||
@@ -3,12 +3,11 @@ package Storage
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/color"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/draw"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -19,19 +18,19 @@ const (
|
||||
)
|
||||
|
||||
type StoragePage struct {
|
||||
UI.Page
|
||||
|
||||
BGpng UI.IconItemInterface
|
||||
BGwidth int // 96
|
||||
BGheight int // 73
|
||||
BGlabel UI.LabelInterface
|
||||
FreeLabel UI.LabelInterface
|
||||
|
||||
BGmsg string // "%.1GB of %.1fGB Used"
|
||||
|
||||
DskUsg [2]float64
|
||||
HighColor *color.Color //MySkinManager.GiveColor('High')
|
||||
|
||||
UI.Page
|
||||
|
||||
BGpng UI.IconItemInterface
|
||||
BGwidth int // 96
|
||||
BGheight int // 73
|
||||
BGlabel UI.LabelInterface
|
||||
FreeLabel UI.LabelInterface
|
||||
|
||||
BGmsg string // "%.1GB of %.1fGB Used"
|
||||
|
||||
DskUsg [2]float64
|
||||
HighColor *color.Color //MySkinManager.GiveColor('High')
|
||||
|
||||
}
|
||||
|
||||
type DiskStatus struct {
|
||||
@@ -53,97 +52,95 @@ func DiskUsage(path string) (disk DiskStatus) {
|
||||
}
|
||||
|
||||
func NewStoragePage() *StoragePage {
|
||||
p:= &StoragePage{}
|
||||
|
||||
p := &StoragePage{}
|
||||
|
||||
p.PageIconMargin = 20
|
||||
p.SelectedIconTopOffset = 20
|
||||
p.EasingDur = 10
|
||||
|
||||
p.Align = UI.ALIGN["SLeft"]
|
||||
|
||||
p.FootMsg = [5]string{"Nav","","","Back",""}
|
||||
|
||||
p.HighColor = &color.Color{51, 166, 255,255}
|
||||
|
||||
p.BGwidth = 96
|
||||
p.BGheight = 73
|
||||
|
||||
p.BGmsg = "%.1fGB of %.1fGB Used"
|
||||
return p
|
||||
p.FootMsg = [5]string{"Nav", "", "", "Back", ""}
|
||||
|
||||
p.HighColor = &color.Color{51, 166, 255, 255}
|
||||
|
||||
p.BGwidth = 96
|
||||
p.BGheight = 73
|
||||
|
||||
p.BGmsg = "%.1fGB of %.1fGB Used"
|
||||
return p
|
||||
}
|
||||
|
||||
func (self *StoragePage) DiskUsage() (float64,float64) {
|
||||
disk := DiskUsage("/")
|
||||
|
||||
all := float64(disk.All)/float64(GB)
|
||||
|
||||
free := float64(disk.Free)/float64(GB)
|
||||
|
||||
return free,all
|
||||
func (self *StoragePage) DiskUsage() (float64, float64) {
|
||||
disk := DiskUsage("/")
|
||||
|
||||
all := float64(disk.All) / float64(GB)
|
||||
|
||||
free := float64(disk.Free) / float64(GB)
|
||||
|
||||
return free, all
|
||||
|
||||
}
|
||||
|
||||
func (self *StoragePage) Init() {
|
||||
|
||||
self.DskUsg[0],self.DskUsg[1] = self.DiskUsage()
|
||||
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
bgpng := UI.NewIconItem()
|
||||
bgpng.ImgSurf = UI.MyIconPool.GetImgSurf("icon_sd")
|
||||
bgpng.MyType = UI.ICON_TYPES["STAT"]
|
||||
bgpng.Parent = self
|
||||
|
||||
bgpng.AddLabel( fmt.Sprintf(self.BGmsg,self.DskUsg[1]-self.DskUsg[0],self.DskUsg[1]),UI.Fonts["varela15"])
|
||||
bgpng.Adjust(0,0,self.BGwidth,self.BGheight,0)
|
||||
|
||||
self.BGpng = bgpng
|
||||
self.BGlabel = UI.NewLabel()
|
||||
self.BGlabel.SetCanvasHWND(self.CanvasHWND)
|
||||
|
||||
usage_percent := int((self.DskUsg[0]/self.DskUsg[1])*100.0)
|
||||
|
||||
self.BGlabel.Init(fmt.Sprintf("%d%%",usage_percent ),UI.Fonts["varela25"],nil)
|
||||
self.BGlabel.SetColor(self.HighColor)
|
||||
|
||||
self.FreeLabel = UI.NewLabel()
|
||||
self.FreeLabel.SetCanvasHWND(self.CanvasHWND)
|
||||
self.FreeLabel.Init("Free",UI.Fonts["varela13"],nil)
|
||||
self.FreeLabel.SetColor(self.BGlabel.(*UI.Label).Color)
|
||||
|
||||
self.DskUsg[0], self.DskUsg[1] = self.DiskUsage()
|
||||
|
||||
self.CanvasHWND = self.Screen.CanvasHWND
|
||||
self.Width = self.Screen.Width
|
||||
self.Height = self.Screen.Height
|
||||
|
||||
bgpng := UI.NewIconItem()
|
||||
bgpng.ImgSurf = UI.MyIconPool.GetImgSurf("icon_sd")
|
||||
bgpng.MyType = UI.ICON_TYPES["STAT"]
|
||||
bgpng.Parent = self
|
||||
|
||||
bgpng.AddLabel(fmt.Sprintf(self.BGmsg, self.DskUsg[1]-self.DskUsg[0], self.DskUsg[1]), UI.Fonts["varela15"])
|
||||
bgpng.Adjust(0, 0, self.BGwidth, self.BGheight, 0)
|
||||
|
||||
self.BGpng = bgpng
|
||||
self.BGlabel = UI.NewLabel()
|
||||
self.BGlabel.SetCanvasHWND(self.CanvasHWND)
|
||||
|
||||
usage_percent := int((self.DskUsg[0] / self.DskUsg[1]) * 100.0)
|
||||
|
||||
self.BGlabel.Init(fmt.Sprintf("%d%%", usage_percent), UI.Fonts["varela25"], nil)
|
||||
self.BGlabel.SetColor(self.HighColor)
|
||||
|
||||
self.FreeLabel = UI.NewLabel()
|
||||
self.FreeLabel.SetCanvasHWND(self.CanvasHWND)
|
||||
self.FreeLabel.Init("Free", UI.Fonts["varela13"], nil)
|
||||
self.FreeLabel.SetColor(self.BGlabel.(*UI.Label).Color)
|
||||
|
||||
}
|
||||
|
||||
func (self *StoragePage) Draw() {
|
||||
self.ClearCanvas()
|
||||
|
||||
self.BGpng.NewCoord(self.Width/2,self.Height/2-10)
|
||||
self.BGpng.Draw()
|
||||
|
||||
self.BGlabel.NewCoord(self.Width/2-28,self.Height/2-30)
|
||||
self.BGlabel.Draw()
|
||||
self.ClearCanvas()
|
||||
|
||||
x,_ := self.BGlabel.Coord()
|
||||
self.FreeLabel.NewCoord(x+10 ,self.Height/2)
|
||||
self.FreeLabel.Draw()
|
||||
self.BGpng.NewCoord(self.Width/2, self.Height/2-10)
|
||||
self.BGpng.Draw()
|
||||
|
||||
usage_percent := (self.DskUsg[0]/self.DskUsg[1] )
|
||||
if usage_percent < 0.1 {
|
||||
usage_percent = 0.1
|
||||
}
|
||||
|
||||
rect_ := draw.MidRect(self.Width/2,self.Height-30,170,17, UI.Width,UI.Height)
|
||||
self.BGlabel.NewCoord(self.Width/2-28, self.Height/2-30)
|
||||
self.BGlabel.Draw()
|
||||
|
||||
draw.AARoundRect(self.CanvasHWND,rect_,&color.Color{169,169,169,255},5,0,&color.Color{169,169,169,255})
|
||||
|
||||
rect2_ := draw.MidRect(self.Width/2,self.Height-30,int(170.0*(1.0-usage_percent)),17, UI.Width,UI.Height)
|
||||
|
||||
rect2_.X = rect_.X
|
||||
rect2_.Y = rect_.Y
|
||||
|
||||
|
||||
draw.AARoundRect(self.CanvasHWND,rect2_,&color.Color{131,199,219,255},5,0,&color.Color{131,199,219,255})
|
||||
|
||||
x, _ := self.BGlabel.Coord()
|
||||
self.FreeLabel.NewCoord(x+10, self.Height/2)
|
||||
self.FreeLabel.Draw()
|
||||
|
||||
usage_percent := (self.DskUsg[0] / self.DskUsg[1])
|
||||
if usage_percent < 0.1 {
|
||||
usage_percent = 0.1
|
||||
}
|
||||
|
||||
rect_ := draw.MidRect(self.Width/2, self.Height-30, 170, 17, UI.Width, UI.Height)
|
||||
|
||||
draw.AARoundRect(self.CanvasHWND, rect_, &color.Color{169, 169, 169, 255}, 5, 0, &color.Color{169, 169, 169, 255})
|
||||
|
||||
rect2_ := draw.MidRect(self.Width/2, self.Height-30, int(170.0*(1.0-usage_percent)), 17, UI.Width, UI.Height)
|
||||
|
||||
rect2_.X = rect_.X
|
||||
rect2_.Y = rect_.Y
|
||||
|
||||
draw.AARoundRect(self.CanvasHWND, rect2_, &color.Color{131, 199, 219, 255}, 5, 0, &color.Color{131, 199, 219, 255})
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user