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"
"strconv"
"github.com/veandco/go-sdl2/sdl"
"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/UI"
)
@ -25,6 +32,35 @@ func NewSliderIcon() *SliderIcon {
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 {
UI.MultiIconItem
Parent *BSlider
@ -42,6 +78,35 @@ func NewSliderMultiIcon() *SliderMultiIcon {
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 {
UI.Slider
@ -67,6 +132,10 @@ func NewBSlider() *BSlider {
return p
}
func (self *BSlider) GetCanvasHWND() *sdl.Surface {
return self.CanvasHWND
}
func (self *BSlider) Init() {
self.Width = self.Parent.Width

View File

@ -4,6 +4,11 @@ import(
"fmt"
"github.com/veandco/go-sdl2/sdl"
"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"
)
@ -14,6 +19,7 @@ type SliderIcon struct {
Parent *SoundSlider
}
func NewSliderIcon() *SliderIcon {
p := &SliderIcon{}
p.MyType = UI.ICON_TYPES["EXE"]
@ -22,6 +28,36 @@ func NewSliderIcon() *SliderIcon {
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 {
UI.MultiIconItem
Parent *SoundSlider
@ -39,6 +75,35 @@ func NewSliderMultiIcon() *SliderMultiIcon {
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 {
UI.Slider
@ -131,6 +196,7 @@ func (self *SoundSlider) StepBack() {
func (self *SoundSlider) Draw() {
self.BGpng.NewCoord(self.Width/2,self.Height/2)
fmt.Printf("%x\n",self.BGpng.Parent)
self.BGpng.Draw()
self.Scale.NewCoord(self.Width/2,self.Height/2)

View File

@ -98,6 +98,8 @@ func NewUpdatePage() *UpdatePage {
p.Align = UI.ALIGN["SLeft"]
p.ListFontObj = UI.Fonts["varela15"]
p.AList = make( map[string]map[string]string )
return p
}
@ -124,7 +126,10 @@ func (self *UpdatePage) GenList() {
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)
i+=1

View File

@ -1,7 +1,7 @@
package UI
import (
// "fmt"
"fmt"
"github.com/veandco/go-sdl2/sdl"
"github.com/veandco/go-sdl2/ttf"
@ -241,7 +241,10 @@ func (self *IconItem) GetCmdInvoke() PluginInterface {
}
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.Label != nil {

View File

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