2020-06-13 20:36:20 -04:00
|
|
|
package d2gamescreen
|
2020-02-24 22:35:21 -05:00
|
|
|
|
|
|
|
import (
|
2020-06-29 00:41:58 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
2020-11-18 16:02:49 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
|
2020-09-18 16:10:52 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
|
2020-02-24 22:35:21 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2gui"
|
2020-06-24 18:46:03 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2screen"
|
2020-02-24 22:35:21 -05:00
|
|
|
)
|
|
|
|
|
2020-07-06 20:13:55 -04:00
|
|
|
// CreateGuiTestMain creates a GuiTestMain screen
|
2020-11-18 16:02:49 -05:00
|
|
|
func CreateGuiTestMain(renderer d2interface.Renderer,
|
|
|
|
guiManager *d2gui.GuiManager,
|
|
|
|
l d2util.LogLevel,
|
|
|
|
assetManager *d2asset.AssetManager) *GuiTestMain {
|
|
|
|
guiTestMain := &GuiTestMain{
|
2020-09-18 16:10:52 -04:00
|
|
|
renderer: renderer,
|
|
|
|
guiManager: guiManager,
|
|
|
|
assetManager: assetManager,
|
2020-07-03 14:00:56 -04:00
|
|
|
}
|
2020-11-18 16:02:49 -05:00
|
|
|
|
2020-11-22 00:36:59 -05:00
|
|
|
guiTestMain.Logger = d2util.NewLogger()
|
|
|
|
guiTestMain.Logger.SetLevel(l)
|
|
|
|
guiTestMain.Logger.SetPrefix(logPrefix)
|
2020-11-18 16:02:49 -05:00
|
|
|
|
|
|
|
return guiTestMain
|
|
|
|
}
|
|
|
|
|
|
|
|
// GuiTestMain is a playground screen for the gui components
|
|
|
|
type GuiTestMain struct {
|
|
|
|
renderer d2interface.Renderer
|
|
|
|
guiManager *d2gui.GuiManager
|
|
|
|
assetManager *d2asset.AssetManager
|
2020-11-22 00:36:59 -05:00
|
|
|
|
|
|
|
*d2util.Logger
|
2020-02-24 22:35:21 -05:00
|
|
|
}
|
|
|
|
|
2020-07-06 20:13:55 -04:00
|
|
|
// OnLoad loads the resources and creates the gui components
|
2020-06-24 18:46:03 -04:00
|
|
|
func (g *GuiTestMain) OnLoad(loading d2screen.LoadingState) {
|
2020-09-18 16:10:52 -04:00
|
|
|
layout := d2gui.CreateLayout(g.renderer, d2gui.PositionTypeHorizontal, g.assetManager)
|
2020-07-02 13:55:43 -04:00
|
|
|
|
2020-07-18 09:54:10 -04:00
|
|
|
loading.Progress(thirtyPercent)
|
2020-02-24 22:35:21 -05:00
|
|
|
//
|
|
|
|
layoutLeft := layout.AddLayout(d2gui.PositionTypeVertical)
|
|
|
|
layoutLeft.SetHorizontalAlign(d2gui.HorizontalAlignCenter)
|
2020-07-06 20:13:55 -04:00
|
|
|
|
|
|
|
if _, err := layoutLeft.AddLabel("FontStyle16Units", d2gui.FontStyle16Units); err != nil {
|
2020-11-22 00:36:59 -05:00
|
|
|
g.Errorf("could not add label: %s to the GuiTestMain screen\n", "FontStyle16Units")
|
2020-07-06 20:13:55 -04:00
|
|
|
}
|
|
|
|
|
2020-02-24 22:35:21 -05:00
|
|
|
layoutLeft.AddSpacerStatic(0, 100)
|
2020-07-06 20:13:55 -04:00
|
|
|
|
|
|
|
if _, err := layoutLeft.AddLabel("FontStyle30Units", d2gui.FontStyle30Units); err != nil {
|
2020-11-22 00:36:59 -05:00
|
|
|
g.Errorf("could not add label: %s to the GuiTestMain screen\n", "FontStyle30Units")
|
2020-07-06 20:13:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := layoutLeft.AddLabel("FontStyle42Units", d2gui.FontStyle42Units); err != nil {
|
2020-11-22 00:36:59 -05:00
|
|
|
g.Errorf("could not add label: %s to the GuiTestMain screen\n", "FontStyle42Units")
|
2020-07-06 20:13:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := layoutLeft.AddLabel("FontStyleFormal10Static", d2gui.FontStyleFormal10Static); err != nil {
|
2020-11-22 00:36:59 -05:00
|
|
|
g.Errorf("could not add label: %s to the GuiTestMain screen\n", "FontStyleFormal10Static")
|
2020-07-06 20:13:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := layoutLeft.AddLabel("FontStyleFormal11Units", d2gui.FontStyleFormal11Units); err != nil {
|
2020-11-22 00:36:59 -05:00
|
|
|
g.Errorf("could not add label: %s to the GuiTestMain screen\n", "FontStyleFormal11Units")
|
2020-07-06 20:13:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := layoutLeft.AddLabel("FontStyleFormal12Static", d2gui.FontStyleFormal12Static); err != nil {
|
2020-11-22 00:36:59 -05:00
|
|
|
g.Errorf("could not add label: %s to the GuiTestMain screen\n", "FontStyleFormal12Static")
|
2020-07-06 20:13:55 -04:00
|
|
|
}
|
|
|
|
|
2020-07-18 09:54:10 -04:00
|
|
|
loading.Progress(sixtyPercent)
|
2020-02-24 22:35:21 -05:00
|
|
|
|
|
|
|
layout.AddSpacerDynamic()
|
|
|
|
|
|
|
|
layoutRight := layout.AddLayout(d2gui.PositionTypeVertical)
|
|
|
|
layoutRight.SetHorizontalAlign(d2gui.HorizontalAlignRight)
|
2020-07-06 20:13:55 -04:00
|
|
|
|
|
|
|
if _, err := layoutRight.AddButton("Medium", d2gui.ButtonStyleMedium); err != nil {
|
2020-11-22 00:36:59 -05:00
|
|
|
g.Errorf("could not add button: %s to the GuiTestMain screen\n", "Medium")
|
2020-07-06 20:13:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := layoutRight.AddButton("Narrow", d2gui.ButtonStyleNarrow); err != nil {
|
2020-11-22 00:36:59 -05:00
|
|
|
g.Errorf("could not add button: %s to the GuiTestMain screen\n", "Narrow")
|
2020-07-06 20:13:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := layoutRight.AddButton("OkCancel", d2gui.ButtonStyleOkCancel); err != nil {
|
2020-11-22 00:36:59 -05:00
|
|
|
g.Errorf("could not add button: %s to the GuiTestMain screen\n", "OkCancel")
|
2020-07-06 20:13:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := layoutRight.AddButton("Short", d2gui.ButtonStyleShort); err != nil {
|
2020-11-22 00:36:59 -05:00
|
|
|
g.Errorf("could not add button: %s to the GuiTestMain screen\n", "Short")
|
2020-07-06 20:13:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := layoutRight.AddButton("Wide", d2gui.ButtonStyleWide); err != nil {
|
2020-11-22 00:36:59 -05:00
|
|
|
g.Errorf("could not add button: %s to the GuiTestMain screen\n", "Wide")
|
2020-07-06 20:13:55 -04:00
|
|
|
}
|
|
|
|
|
2020-07-18 09:54:10 -04:00
|
|
|
loading.Progress(ninetyPercent)
|
2020-02-24 22:35:21 -05:00
|
|
|
|
|
|
|
layout.SetVerticalAlign(d2gui.VerticalAlignMiddle)
|
2020-09-18 16:10:52 -04:00
|
|
|
g.guiManager.SetLayout(layout)
|
2020-02-24 22:35:21 -05:00
|
|
|
}
|
|
|
|
|
2020-07-06 20:13:55 -04:00
|
|
|
// Render does nothing for the GuiTestMain screen
|
2020-10-28 14:17:42 -04:00
|
|
|
func (g *GuiTestMain) Render(_ d2interface.Surface) { /* NOOP */ }
|
2020-02-24 22:35:21 -05:00
|
|
|
|
2020-07-06 20:13:55 -04:00
|
|
|
// Advance does nothing for the GuiTestMain screen
|
2020-07-03 14:00:56 -04:00
|
|
|
func (g *GuiTestMain) Advance(_ float64) error {
|
2020-02-24 22:35:21 -05:00
|
|
|
return nil
|
|
|
|
}
|