1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-21 14:45:24 +00:00
OpenDiablo2/d2game/d2gamescreen/gui_testing.go
Gürkan Kaymak 473a0b3b19
Remaining lint fixes for the d2gamescreen package (#550)
* lint fixes for the game.go

* lint fixes for the gui_testing.go

* lint fixes for the blizzard_intro.go, map_engine_testing.go and select_hero_class.go

* added package comment for the d2gamescreen package

* fixes after merge
2020-07-06 20:13:55 -04:00

100 lines
3.3 KiB
Go

package d2gamescreen
import (
"fmt"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2gui"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2screen"
)
// GuiTestMain is a playground screen for the gui components
type GuiTestMain struct {
renderer d2interface.Renderer
}
// CreateGuiTestMain creates a GuiTestMain screen
func CreateGuiTestMain(renderer d2interface.Renderer) *GuiTestMain {
return &GuiTestMain{
renderer: renderer,
}
}
// OnLoad loads the resources and creates the gui components
func (g *GuiTestMain) OnLoad(loading d2screen.LoadingState) {
layout := d2gui.CreateLayout(g.renderer, d2gui.PositionTypeHorizontal)
loading.Progress(0.3)
//
layoutLeft := layout.AddLayout(d2gui.PositionTypeVertical)
layoutLeft.SetHorizontalAlign(d2gui.HorizontalAlignCenter)
if _, err := layoutLeft.AddLabel("FontStyle16Units", d2gui.FontStyle16Units); err != nil {
fmt.Printf("could not add label: %s to the GuiTestMain screen\n", "FontStyle16Units")
}
layoutLeft.AddSpacerStatic(0, 100)
if _, err := layoutLeft.AddLabel("FontStyle30Units", d2gui.FontStyle30Units); err != nil {
fmt.Printf("could not add label: %s to the GuiTestMain screen\n", "FontStyle30Units")
}
if _, err := layoutLeft.AddLabel("FontStyle42Units", d2gui.FontStyle42Units); err != nil {
fmt.Printf("could not add label: %s to the GuiTestMain screen\n", "FontStyle42Units")
}
if _, err := layoutLeft.AddLabel("FontStyleFormal10Static", d2gui.FontStyleFormal10Static); err != nil {
fmt.Printf("could not add label: %s to the GuiTestMain screen\n", "FontStyleFormal10Static")
}
if _, err := layoutLeft.AddLabel("FontStyleFormal11Units", d2gui.FontStyleFormal11Units); err != nil {
fmt.Printf("could not add label: %s to the GuiTestMain screen\n", "FontStyleFormal11Units")
}
if _, err := layoutLeft.AddLabel("FontStyleFormal12Static", d2gui.FontStyleFormal12Static); err != nil {
fmt.Printf("could not add label: %s to the GuiTestMain screen\n", "FontStyleFormal12Static")
}
loading.Progress(0.6)
layout.AddSpacerDynamic()
layoutRight := layout.AddLayout(d2gui.PositionTypeVertical)
layoutRight.SetHorizontalAlign(d2gui.HorizontalAlignRight)
if _, err := layoutRight.AddButton("Medium", d2gui.ButtonStyleMedium); err != nil {
fmt.Printf("could not add button: %s to the GuiTestMain screen\n", "Medium")
}
if _, err := layoutRight.AddButton("Narrow", d2gui.ButtonStyleNarrow); err != nil {
fmt.Printf("could not add button: %s to the GuiTestMain screen\n", "Narrow")
}
if _, err := layoutRight.AddButton("OkCancel", d2gui.ButtonStyleOkCancel); err != nil {
fmt.Printf("could not add button: %s to the GuiTestMain screen\n", "OkCancel")
}
if _, err := layoutRight.AddButton("Short", d2gui.ButtonStyleShort); err != nil {
fmt.Printf("could not add button: %s to the GuiTestMain screen\n", "Short")
}
if _, err := layoutRight.AddButton("Wide", d2gui.ButtonStyleWide); err != nil {
fmt.Printf("could not add button: %s to the GuiTestMain screen\n", "Wide")
}
loading.Progress(0.9)
layout.SetVerticalAlign(d2gui.VerticalAlignMiddle)
d2gui.SetLayout(layout)
}
// Render does nothing for the GuiTestMain screen
func (g *GuiTestMain) Render(_ d2interface.Surface) error {
return nil
}
// Advance does nothing for the GuiTestMain screen
func (g *GuiTestMain) Advance(_ float64) error {
return nil
}