sound_page,brightness_page,struct inherited bug,Draw

This commit is contained in:
cuu 2018-12-05 22:31:42 +08:00
parent 9261a1ae27
commit 947cfae038
5 changed files with 151 additions and 3 deletions

View File

@ -5,7 +5,14 @@ import(
"io/ioutil" "io/ioutil"
"strconv" "strconv"
"github.com/veandco/go-sdl2/sdl"
"github.com/cuu/gogame/event" "github.com/cuu/gogame/event"
"github.com/cuu/gogame/draw"
"github.com/cuu/gogame/surface"
"github.com/cuu/gogame/rect"
"github.com/cuu/LauncherGoDev/sysgo" "github.com/cuu/LauncherGoDev/sysgo"
"github.com/cuu/LauncherGoDev/sysgo/UI" "github.com/cuu/LauncherGoDev/sysgo/UI"
) )
@ -25,6 +32,35 @@ func NewSliderIcon() *SliderIcon {
return p return p
} }
func (self *SliderIcon) Draw() {
if self.Parent == nil {
fmt.Println("Error: SliderIcon 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()
if self.Align == UI.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 == UI.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, UI.Width, UI.Height),nil)
}
}
type SliderMultiIcon struct { type SliderMultiIcon struct {
UI.MultiIconItem UI.MultiIconItem
Parent *BSlider Parent *BSlider
@ -42,6 +78,35 @@ func NewSliderMultiIcon() *SliderMultiIcon {
return p return p
} }
func (self *SliderMultiIcon) Draw() {
if self.Parent == nil {
fmt.Println("Error: SliderMultiIcon 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()
if self.Align == UI.ALIGN["VCenter"] {
self.Label.NewCoord( self.PosX - lab_w/2 + parent_x, self.PosY + self.Height/2+6 + parent_y)
}else if self.Align == UI.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 {
portion := rect.Rect(0,self.IconIndex*self.IconHeight,self.IconWidth,self.IconHeight)
surface.Blit(self.Parent.GetCanvasHWND(),
self.ImgSurf,draw.MidRect(self.PosX + parent_x, self.PosY + parent_y,
self.Width,self.Height, UI.Width, UI.Height),&portion)
}
}
type BSlider struct { type BSlider struct {
UI.Slider UI.Slider
@ -67,6 +132,10 @@ func NewBSlider() *BSlider {
return p return p
} }
func (self *BSlider) GetCanvasHWND() *sdl.Surface {
return self.CanvasHWND
}
func (self *BSlider) Init() { func (self *BSlider) Init() {
self.Width = self.Parent.Width self.Width = self.Parent.Width

View File

@ -4,6 +4,11 @@ import(
"fmt" "fmt"
"github.com/veandco/go-sdl2/sdl" "github.com/veandco/go-sdl2/sdl"
"github.com/cuu/gogame/event" "github.com/cuu/gogame/event"
"github.com/cuu/gogame/surface"
"github.com/cuu/gogame/draw"
"github.com/cuu/gogame/rect"
"github.com/cuu/LauncherGoDev/sysgo/UI" "github.com/cuu/LauncherGoDev/sysgo/UI"
) )
@ -14,6 +19,7 @@ type SliderIcon struct {
Parent *SoundSlider Parent *SoundSlider
} }
func NewSliderIcon() *SliderIcon { func NewSliderIcon() *SliderIcon {
p := &SliderIcon{} p := &SliderIcon{}
p.MyType = UI.ICON_TYPES["EXE"] p.MyType = UI.ICON_TYPES["EXE"]
@ -22,6 +28,36 @@ func NewSliderIcon() *SliderIcon {
return p return p
} }
func (self *SliderIcon) Draw() {
if self.Parent == nil {
fmt.Println("Error: SliderIcon 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()
if self.Align == UI.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 == UI.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, UI.Width, UI.Height),nil)
}
}
type SliderMultiIcon struct { type SliderMultiIcon struct {
UI.MultiIconItem UI.MultiIconItem
Parent *SoundSlider Parent *SoundSlider
@ -39,6 +75,35 @@ func NewSliderMultiIcon() *SliderMultiIcon {
return p return p
} }
func (self *SliderMultiIcon) Draw() {
if self.Parent == nil {
fmt.Println("Error: SliderMultiIcon 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()
if self.Align == UI.ALIGN["VCenter"] {
self.Label.NewCoord( self.PosX - lab_w/2 + parent_x, self.PosY + self.Height/2+6 + parent_y)
}else if self.Align == UI.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 {
portion := rect.Rect(0,self.IconIndex*self.IconHeight,self.IconWidth,self.IconHeight)
surface.Blit(self.Parent.GetCanvasHWND(),
self.ImgSurf,draw.MidRect(self.PosX + parent_x, self.PosY + parent_y,
self.Width,self.Height, UI.Width, UI.Height),&portion)
}
}
type SoundSlider struct { type SoundSlider struct {
UI.Slider UI.Slider
@ -131,6 +196,7 @@ func (self *SoundSlider) StepBack() {
func (self *SoundSlider) Draw() { func (self *SoundSlider) Draw() {
self.BGpng.NewCoord(self.Width/2,self.Height/2) self.BGpng.NewCoord(self.Width/2,self.Height/2)
fmt.Printf("%x\n",self.BGpng.Parent)
self.BGpng.Draw() self.BGpng.Draw()
self.Scale.NewCoord(self.Width/2,self.Height/2) self.Scale.NewCoord(self.Width/2,self.Height/2)

View File

@ -98,6 +98,8 @@ func NewUpdatePage() *UpdatePage {
p.Align = UI.ALIGN["SLeft"] p.Align = UI.ALIGN["SLeft"]
p.ListFontObj = UI.Fonts["varela15"] p.ListFontObj = UI.Fonts["varela15"]
p.AList = make( map[string]map[string]string )
return p return p
} }
@ -124,7 +126,10 @@ func (self *UpdatePage) GenList() {
li.Init(self.AList[k]["key"] ) li.Init(self.AList[k]["key"] )
} }
li.Flag = self.AList[k]["value"] li.Flag = self.AList[k]["key"]
li.SetSmallText( self.AList[k]["value"])
self.MyList = append(self.MyList,li) self.MyList = append(self.MyList,li)
i+=1 i+=1

View File

@ -1,7 +1,7 @@
package UI package UI
import ( import (
// "fmt" "fmt"
"github.com/veandco/go-sdl2/sdl" "github.com/veandco/go-sdl2/sdl"
"github.com/veandco/go-sdl2/ttf" "github.com/veandco/go-sdl2/ttf"
@ -241,7 +241,10 @@ func (self *IconItem) GetCmdInvoke() PluginInterface {
} }
func (self *IconItem) Draw() { func (self *IconItem) Draw() {
if self.Parent == nil {
fmt.Println("Error: IconItem Draw Parent nil")
return
}
parent_x,parent_y := self.Parent.Coord() parent_x,parent_y := self.Parent.Coord()
if self.Label != nil { if self.Label != nil {

View File

@ -1,6 +1,7 @@
package UI package UI
import ( import (
"fmt"
"github.com/cuu/gogame/surface" "github.com/cuu/gogame/surface"
"github.com/cuu/gogame/image" "github.com/cuu/gogame/image"
"github.com/cuu/gogame/draw" "github.com/cuu/gogame/draw"
@ -31,6 +32,10 @@ func (self * MultiIconItem) CreateImgSurf() {
} }
func (self *MultiIconItem) Draw() { func (self *MultiIconItem) Draw() {
if self.Parent == nil {
fmt.Println("Error: MultiIconItem Draw Parent nil")
return
}
parent_x,parent_y := self.Parent.Coord() parent_x,parent_y := self.Parent.Coord()
if self.Label != nil { if self.Label != nil {