mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2026-09-07 22:14:40 +02:00
go fmt ./...
This commit is contained in:
@@ -2,48 +2,47 @@ package UI
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/color"
|
||||
"github.com/cuu/gogame/draw"
|
||||
"github.com/cuu/gogame/image"
|
||||
"github.com/cuu/gogame/rect"
|
||||
"github.com/cuu/gogame/surface"
|
||||
"github.com/cuu/gogame/transform"
|
||||
"github.com/cuu/gogame/utils"
|
||||
"github.com/cuu/gogame/rect"
|
||||
|
||||
)
|
||||
|
||||
type IconItemInterface interface {
|
||||
Init(x,y,w,h,at int)
|
||||
Adjust(x,y,w,h,at int)
|
||||
Init(x, y, w, h, at int)
|
||||
Adjust(x, y, w, h, at int)
|
||||
GetCmdPath() string
|
||||
SetCmdPath( path string)
|
||||
|
||||
SetMyType( thetype int )
|
||||
SetCmdPath(path string)
|
||||
|
||||
SetMyType(thetype int)
|
||||
GetMyType() int
|
||||
|
||||
GetIconIndex() int
|
||||
SetIconIndex(idx int)
|
||||
|
||||
|
||||
GetIndex() int
|
||||
SetIndex(i int)
|
||||
|
||||
SetParent( p interface{} )
|
||||
|
||||
|
||||
SetParent(p interface{})
|
||||
|
||||
SetLabelColor(col *color.Color)
|
||||
SetLabelText(text string)
|
||||
GetLabelText() string
|
||||
|
||||
Coord() (int,int)
|
||||
NewCoord(x,y int)
|
||||
Size() (int,int)
|
||||
NewSize(w,h int)
|
||||
|
||||
Coord() (int, int)
|
||||
NewCoord(x, y int)
|
||||
Size() (int, int)
|
||||
NewSize(w, h int)
|
||||
|
||||
TotalWidth() int
|
||||
|
||||
|
||||
AddLabel(text string, fontobj *ttf.Font)
|
||||
GetLinkPage() PageInterface
|
||||
AdjustLinkPage()
|
||||
@@ -51,46 +50,43 @@ type IconItemInterface interface {
|
||||
SetImgSurf(newsurf *sdl.Surface)
|
||||
CreateImgSurf()
|
||||
ChangeImgSurfColor(col *color.Color)
|
||||
|
||||
|
||||
Clear()
|
||||
|
||||
GetCmdInvoke() PluginInterface
|
||||
|
||||
GetFileName() string
|
||||
Draw()
|
||||
DrawTopLeft()
|
||||
|
||||
DrawTopLeft()
|
||||
}
|
||||
|
||||
type IconItem struct {
|
||||
Widget
|
||||
ImageName string
|
||||
ImgSurf *sdl.Surface
|
||||
Parent PageInterface
|
||||
Index int
|
||||
IconIndex int
|
||||
MyType int
|
||||
CmdPath string
|
||||
CmdInvoke PluginInterface
|
||||
LinkPage PageInterface
|
||||
Label LabelInterface
|
||||
Align int
|
||||
ImageName string
|
||||
ImgSurf *sdl.Surface
|
||||
Parent PageInterface
|
||||
Index int
|
||||
IconIndex int
|
||||
MyType int
|
||||
CmdPath string
|
||||
CmdInvoke PluginInterface
|
||||
LinkPage PageInterface
|
||||
Label LabelInterface
|
||||
Align int
|
||||
AnimationTime int
|
||||
FileName string
|
||||
FileName string
|
||||
}
|
||||
|
||||
|
||||
func NewIconItem() *IconItem {
|
||||
i := &IconItem{}
|
||||
i.MyType = ICON_TYPES["EXE"]
|
||||
|
||||
i.Align = ALIGN["VCenter"]
|
||||
|
||||
|
||||
return i
|
||||
}
|
||||
|
||||
|
||||
func (self *IconItem) Init(x,y,w,h,at int) {
|
||||
func (self *IconItem) Init(x, y, w, h, at int) {
|
||||
self.PosX = x
|
||||
self.PosY = y
|
||||
self.Width = w
|
||||
@@ -98,7 +94,7 @@ func (self *IconItem) Init(x,y,w,h,at int) {
|
||||
self.AnimationTime = at
|
||||
}
|
||||
|
||||
func (self *IconItem) Adjust(x,y,w,h,at int) {
|
||||
func (self *IconItem) Adjust(x, y, w, h, at int) {
|
||||
self.PosX = x
|
||||
self.PosY = y
|
||||
self.Width = w
|
||||
@@ -111,19 +107,18 @@ func (self *IconItem) Adjust(x,y,w,h,at int) {
|
||||
|
||||
self.CreateImgSurf()
|
||||
self.AdjustLinkPage()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *IconItem) GetCmdPath() string {
|
||||
return self.CmdPath
|
||||
}
|
||||
|
||||
func (self *IconItem) SetCmdPath( path string) {
|
||||
func (self *IconItem) SetCmdPath(path string) {
|
||||
self.CmdPath = path
|
||||
}
|
||||
|
||||
func (self *IconItem) SetMyType( thetype int ) {
|
||||
func (self *IconItem) SetMyType(thetype int) {
|
||||
self.MyType = thetype
|
||||
}
|
||||
|
||||
@@ -135,7 +130,7 @@ func (self *IconItem) GetIconIndex() int {
|
||||
return self.IconIndex
|
||||
}
|
||||
|
||||
func (self *IconItem) SetIconIndex( idx int) {
|
||||
func (self *IconItem) SetIconIndex(idx int) {
|
||||
self.IconIndex = idx
|
||||
}
|
||||
|
||||
@@ -147,7 +142,7 @@ func (self *IconItem) SetIndex(i int) {
|
||||
self.Index = i
|
||||
}
|
||||
|
||||
func (self *IconItem) SetParent(p interface{} ) {
|
||||
func (self *IconItem) SetParent(p interface{}) {
|
||||
self.Parent = p.(PageInterface)
|
||||
}
|
||||
|
||||
@@ -163,11 +158,11 @@ func (self *IconItem) SetLabelText(text string) {
|
||||
self.Label.SetText(text)
|
||||
}
|
||||
|
||||
func (self *IconItem) Coord() (int,int) {
|
||||
return self.PosX,self.PosY
|
||||
func (self *IconItem) Coord() (int, int) {
|
||||
return self.PosX, self.PosY
|
||||
}
|
||||
|
||||
func (self *IconItem) NewCoord(x,y int) {
|
||||
func (self *IconItem) NewCoord(x, y int) {
|
||||
self.PosX = x
|
||||
self.PosY = y
|
||||
}
|
||||
@@ -176,18 +171,18 @@ func (self *IconItem) TotalWidth() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *IconItem) Size() (int,int) {
|
||||
return self.Width,self.Height
|
||||
func (self *IconItem) Size() (int, int) {
|
||||
return self.Width, self.Height
|
||||
}
|
||||
|
||||
func (self *IconItem) AddLabel(text string, fontobj *ttf.Font) {
|
||||
if self.Label == nil {
|
||||
l:= NewLabel()
|
||||
l := NewLabel()
|
||||
self.Label = l
|
||||
}
|
||||
|
||||
self.Label.Init(text,fontobj,nil)
|
||||
|
||||
|
||||
self.Label.Init(text, fontobj, nil)
|
||||
|
||||
}
|
||||
|
||||
func (self *IconItem) GetLinkPage() PageInterface {
|
||||
@@ -200,21 +195,20 @@ func (self *IconItem) AdjustLinkPage() {
|
||||
self.LinkPage.SetAlign(ALIGN["SLeft"])
|
||||
self.LinkPage.UpdateIconNumbers()
|
||||
self.LinkPage.SetScreen(self.Parent.GetScreen())
|
||||
self.LinkPage.SetCanvasHWND( (self.Parent.GetScreen()).CanvasHWND )
|
||||
self.LinkPage.SetFootMsg([5]string{ "Nav.","","","Back","Enter" } )
|
||||
self.LinkPage.SetCanvasHWND((self.Parent.GetScreen()).CanvasHWND)
|
||||
self.LinkPage.SetFootMsg([5]string{"Nav.", "", "", "Back", "Enter"})
|
||||
if self.LinkPage.GetAlign() == ALIGN["HLeft"] {
|
||||
self.LinkPage.AdjustHLeftAlign()
|
||||
}else if self.LinkPage.GetAlign() == ALIGN["SLeft"] {
|
||||
} else if self.LinkPage.GetAlign() == ALIGN["SLeft"] {
|
||||
self.LinkPage.AdjustSAutoLeftAlign()
|
||||
if self.LinkPage.GetIconNumbers() > 1 {
|
||||
self.LinkPage.SetPsIndex(1)
|
||||
self.LinkPage.SetIconIndex ( 1 )
|
||||
self.LinkPage.SetIconIndex(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func (self *IconItem) GetImgSurf() *sdl.Surface {
|
||||
return self.ImgSurf
|
||||
}
|
||||
@@ -223,22 +217,21 @@ func (self *IconItem) SetImgSurf(newsurf *sdl.Surface) {
|
||||
self.ImgSurf = newsurf
|
||||
}
|
||||
|
||||
|
||||
func (self *IconItem) CreateImgSurf() {
|
||||
if self.ImgSurf == nil && self.ImageName != "" {
|
||||
self.ImgSurf = image.Load(self.ImageName)
|
||||
if int(self.ImgSurf.W) > IconWidth || int(self.ImgSurf.H) > IconHeight {
|
||||
self.ImgSurf = transform.Scale(self.ImgSurf,IconWidth,IconHeight)
|
||||
if int(self.ImgSurf.W) > IconWidth || int(self.ImgSurf.H) > IconHeight {
|
||||
self.ImgSurf = transform.Scale(self.ImgSurf, IconWidth, IconHeight)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (self *IconItem) ChangeImgSurfColor(col *color.Color) {
|
||||
utils.ColorSurface(self.ImgSurf,col)
|
||||
utils.ColorSurface(self.ImgSurf, col)
|
||||
}
|
||||
|
||||
func (self *IconItem) Clear() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
func (self *IconItem) GetCmdInvoke() PluginInterface {
|
||||
@@ -246,65 +239,64 @@ func (self *IconItem) GetCmdInvoke() PluginInterface {
|
||||
}
|
||||
|
||||
func (self *IconItem) GetFileName() string {
|
||||
return self.FileName
|
||||
return self.FileName
|
||||
}
|
||||
|
||||
func (self *IconItem) DrawTopLeft() {
|
||||
if self.Parent == nil {
|
||||
fmt.Println("Error: IconItem Draw Parent nil")
|
||||
return
|
||||
}
|
||||
parent_x,parent_y := self.Parent.Coord()
|
||||
|
||||
if self.Parent == nil {
|
||||
fmt.Println("Error: IconItem Draw Parent nil")
|
||||
return
|
||||
}
|
||||
parent_x, parent_y := self.Parent.Coord()
|
||||
|
||||
if self.Label != nil {
|
||||
// lab_x,lab_y := self.Label.Coord()
|
||||
lab_w,lab_h:= self.Label.Size()
|
||||
|
||||
// lab_x,lab_y := self.Label.Coord()
|
||||
lab_w, lab_h := self.Label.Size()
|
||||
|
||||
if self.Align == ALIGN["VCenter"] {
|
||||
// fmt.Println("IconItem Draw VCenter:",lab_w,lab_h,self.Label.GetText())
|
||||
|
||||
self.Label.NewCoord( self.PosX - lab_w/2 + parent_x, self.PosY + self.Height/2+6+parent_y)
|
||||
|
||||
}else if self.Align == ALIGN["HLeft"] {
|
||||
self.Label.NewCoord( self.PosX + self.Width/2+3+parent_x, self.PosY - lab_h/2 + parent_y)
|
||||
// fmt.Println("IconItem Draw VCenter:",lab_w,lab_h,self.Label.GetText())
|
||||
|
||||
self.Label.NewCoord(self.PosX-lab_w/2+parent_x, self.PosY+self.Height/2+6+parent_y)
|
||||
|
||||
} else if self.Align == ALIGN["HLeft"] {
|
||||
self.Label.NewCoord(self.PosX+self.Width/2+3+parent_x, self.PosY-lab_h/2+parent_y)
|
||||
}
|
||||
|
||||
self.Label.Draw()
|
||||
}
|
||||
|
||||
if self.ImgSurf != nil {
|
||||
rect_ := rect.Rect( self.PosX+parent_x,self.PosY+parent_y, self.Width,self.Height ) // DIFF
|
||||
surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf,&rect_,nil)
|
||||
rect_ := rect.Rect(self.PosX+parent_x, self.PosY+parent_y, self.Width, self.Height) // DIFF
|
||||
surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf, &rect_, nil)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *IconItem) Draw() {
|
||||
if self.Parent == nil {
|
||||
fmt.Println("Error: IconItem Draw Parent nil")
|
||||
return
|
||||
}
|
||||
parent_x,parent_y := self.Parent.Coord()
|
||||
|
||||
if self.Parent == nil {
|
||||
fmt.Println("Error: IconItem Draw Parent nil")
|
||||
return
|
||||
}
|
||||
parent_x, parent_y := self.Parent.Coord()
|
||||
|
||||
if self.Label != nil {
|
||||
// lab_x,lab_y := self.Label.Coord()
|
||||
lab_w,lab_h:= self.Label.Size()
|
||||
|
||||
// lab_x,lab_y := self.Label.Coord()
|
||||
lab_w, lab_h := self.Label.Size()
|
||||
|
||||
if self.Align == ALIGN["VCenter"] {
|
||||
// fmt.Println("IconItem Draw VCenter:",lab_w,lab_h,self.Label.GetText())
|
||||
|
||||
self.Label.NewCoord( self.PosX - lab_w/2 + parent_x, self.PosY + self.Height/2+6+parent_y)
|
||||
|
||||
}else if self.Align == ALIGN["HLeft"] {
|
||||
self.Label.NewCoord( self.PosX + self.Width/2+3+parent_x, self.PosY - lab_h/2 + parent_y)
|
||||
// fmt.Println("IconItem Draw VCenter:",lab_w,lab_h,self.Label.GetText())
|
||||
|
||||
self.Label.NewCoord(self.PosX-lab_w/2+parent_x, self.PosY+self.Height/2+6+parent_y)
|
||||
|
||||
} else if self.Align == ALIGN["HLeft"] {
|
||||
self.Label.NewCoord(self.PosX+self.Width/2+3+parent_x, self.PosY-lab_h/2+parent_y)
|
||||
}
|
||||
|
||||
self.Label.Draw()
|
||||
}
|
||||
|
||||
if self.ImgSurf != nil {
|
||||
surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf,draw.MidRect(self.PosX + parent_x, self.PosY + parent_y,
|
||||
self.Width,self.Height, Width, Height),nil)
|
||||
surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf, draw.MidRect(self.PosX+parent_x, self.PosY+parent_y,
|
||||
self.Width, self.Height, Width, Height), nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user