diff --git a/Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/DungeonSlime.csproj b/Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/DungeonSlime.csproj
index 14e50b9a..fa855021 100644
--- a/Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/DungeonSlime.csproj
+++ b/Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/DungeonSlime.csproj
@@ -23,7 +23,7 @@
-
+
diff --git a/Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/Game1.cs b/Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/Game1.cs
index 65120979..f886fc4a 100644
--- a/Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/Game1.cs
+++ b/Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/Game1.cs
@@ -34,7 +34,7 @@ protected override void Initialize()
private void InitializeGum()
{
// Initialize the Gum service
- GumService.Default.Initialize(this, DefaultVisualsVersion.V2);
+ GumService.Default.Initialize(this, DefaultVisualsVersion.V3);
// Tell the Gum service which content manager to use. We will tell it to
// use the global content manager from our Core.
diff --git a/Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/Scenes/GameScene.cs b/Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/Scenes/GameScene.cs
index 193fed68..e5231b3e 100644
--- a/Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/Scenes/GameScene.cs
+++ b/Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/Scenes/GameScene.cs
@@ -144,10 +144,10 @@ private void CreatePausePanel()
{
_pausePanel = new Panel();
_pausePanel.Anchor(Anchor.Center);
- _pausePanel.Visual.WidthUnits = DimensionUnitType.Absolute;
- _pausePanel.Visual.HeightUnits = DimensionUnitType.Absolute;
- _pausePanel.Visual.Height = 70;
- _pausePanel.Visual.Width = 264;
+ _pausePanel.WidthUnits = DimensionUnitType.Absolute;
+ _pausePanel.HeightUnits = DimensionUnitType.Absolute;
+ _pausePanel.Height = 70;
+ _pausePanel.Width = 264;
_pausePanel.IsVisible = false;
_pausePanel.AddToRoot();
@@ -165,17 +165,17 @@ private void CreatePausePanel()
_resumeButton = new Button();
_resumeButton.Text = "RESUME";
_resumeButton.Anchor(Anchor.BottomLeft);
- _resumeButton.Visual.X = 9f;
- _resumeButton.Visual.Y = -9f;
- _resumeButton.Visual.Width = 80;
+ _resumeButton.X = 9f;
+ _resumeButton.Y = -9f;
+ _resumeButton.Width = 80;
_resumeButton.Click += HandleResumeButtonClicked;
_pausePanel.AddChild(_resumeButton);
var quitButton = new Button();
quitButton.Text = "QUIT";
quitButton.Anchor(Anchor.BottomRight);
- quitButton.Visual.X = -9f;
- quitButton.Visual.Y = -9f;
+ quitButton.X = -9f;
+ quitButton.Y = -9f;
quitButton.Width = 80;
quitButton.Click += HandleQuitButtonClicked;
diff --git a/Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/Scenes/TitleScene.cs b/Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/Scenes/TitleScene.cs
index 2d407eca..0d788ad4 100644
--- a/Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/Scenes/TitleScene.cs
+++ b/Tutorials/learn-monogame-2d/src/20-Implementing-UI-With-Gum/DungeonSlime/Scenes/TitleScene.cs
@@ -119,18 +119,18 @@ private void CreateTitlePanel()
var startButton = new Button();
startButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- startButton.Visual.X = 50;
- startButton.Visual.Y = -12;
- startButton.Visual.Width = 70;
+ startButton.X = 50;
+ startButton.Y = -12;
+ startButton.Width = 70;
startButton.Text = "Start";
startButton.Click += HandleStartClicked;
_titleScreenButtonsPanel.AddChild(startButton);
_optionsButton = new Button();
_optionsButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- _optionsButton.Visual.X = -50;
- _optionsButton.Visual.Y = -12;
- _optionsButton.Visual.Width = 70;
+ _optionsButton.X = -50;
+ _optionsButton.Y = -12;
+ _optionsButton.Width = 70;
_optionsButton.Text = "Options";
_optionsButton.Click += HandleOptionsClicked;
_titleScreenButtonsPanel.AddChild(_optionsButton);
@@ -177,7 +177,7 @@ private void CreateOptionsPanel()
var musicSlider = new Slider();
musicSlider.Anchor(Gum.Wireframe.Anchor.Top);
- musicSlider.Visual.Y = 30f;
+ musicSlider.Y = 30f;
musicSlider.Minimum = 0;
musicSlider.Maximum = 1;
musicSlider.Value = Core.Audio.SongVolume;
@@ -189,7 +189,7 @@ private void CreateOptionsPanel()
var sfxSlider = new Slider();
sfxSlider.Anchor(Gum.Wireframe.Anchor.Top);
- sfxSlider.Visual.Y = 93;
+ sfxSlider.Y = 93;
sfxSlider.Minimum = 0;
sfxSlider.Maximum = 1;
sfxSlider.Value = Core.Audio.SoundEffectVolume;
diff --git a/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/DungeonSlime.csproj b/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/DungeonSlime.csproj
index 14e50b9a..fa855021 100644
--- a/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/DungeonSlime.csproj
+++ b/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/DungeonSlime.csproj
@@ -23,7 +23,7 @@
-
+
diff --git a/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/Game1.cs b/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/Game1.cs
index 65120979..f886fc4a 100644
--- a/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/Game1.cs
+++ b/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/Game1.cs
@@ -34,7 +34,7 @@ protected override void Initialize()
private void InitializeGum()
{
// Initialize the Gum service
- GumService.Default.Initialize(this, DefaultVisualsVersion.V2);
+ GumService.Default.Initialize(this, DefaultVisualsVersion.V3);
// Tell the Gum service which content manager to use. We will tell it to
// use the global content manager from our Core.
diff --git a/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/Scenes/GameScene.cs b/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/Scenes/GameScene.cs
index 97ebe8b8..5f843aa6 100644
--- a/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/Scenes/GameScene.cs
+++ b/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/Scenes/GameScene.cs
@@ -150,10 +150,10 @@ private void CreatePausePanel()
{
_pausePanel = new Panel();
_pausePanel.Anchor(Anchor.Center);
- _pausePanel.Visual.WidthUnits = DimensionUnitType.Absolute;
- _pausePanel.Visual.HeightUnits = DimensionUnitType.Absolute;
- _pausePanel.Visual.Height = 70;
- _pausePanel.Visual.Width = 264;
+ _pausePanel.WidthUnits = DimensionUnitType.Absolute;
+ _pausePanel.HeightUnits = DimensionUnitType.Absolute;
+ _pausePanel.Height = 70;
+ _pausePanel.Width = 264;
_pausePanel.IsVisible = false;
_pausePanel.AddToRoot();
@@ -181,16 +181,16 @@ private void CreatePausePanel()
_resumeButton = new AnimatedButton(_atlas);
_resumeButton.Text = "RESUME";
_resumeButton.Anchor(Anchor.BottomLeft);
- _resumeButton.Visual.X = 9f;
- _resumeButton.Visual.Y = -9f;
+ _resumeButton.X = 9f;
+ _resumeButton.Y = -9f;
_resumeButton.Click += HandleResumeButtonClicked;
_pausePanel.AddChild(_resumeButton);
AnimatedButton quitButton = new AnimatedButton(_atlas);
quitButton.Text = "QUIT";
quitButton.Anchor(Anchor.BottomRight);
- quitButton.Visual.X = -9f;
- quitButton.Visual.Y = -9f;
+ quitButton.X = -9f;
+ quitButton.Y = -9f;
quitButton.Click += HandleQuitButtonClicked;
_pausePanel.AddChild(quitButton);
diff --git a/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/Scenes/TitleScene.cs b/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/Scenes/TitleScene.cs
index 742cdf47..b895d425 100644
--- a/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/Scenes/TitleScene.cs
+++ b/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/Scenes/TitleScene.cs
@@ -131,16 +131,16 @@ private void CreateTitlePanel()
AnimatedButton startButton = new AnimatedButton(_atlas);
startButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- startButton.Visual.X = 50;
- startButton.Visual.Y = -12;
+ startButton.X = 50;
+ startButton.Y = -12;
startButton.Text = "Start";
startButton.Click += HandleStartClicked;
_titleScreenButtonsPanel.AddChild(startButton);
_optionsButton = new AnimatedButton(_atlas);
_optionsButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- _optionsButton.Visual.X = -50;
- _optionsButton.Visual.Y = -12;
+ _optionsButton.X = -50;
+ _optionsButton.Y = -12;
_optionsButton.Text = "Options";
_optionsButton.Click += HandleOptionsClicked;
_titleScreenButtonsPanel.AddChild(_optionsButton);
@@ -192,7 +192,7 @@ private void CreateOptionsPanel()
musicSlider.Name = "MusicSlider";
musicSlider.Text = "MUSIC";
musicSlider.Anchor(Gum.Wireframe.Anchor.Top);
- musicSlider.Visual.Y = 30f;
+ musicSlider.Y = 30f;
musicSlider.Minimum = 0;
musicSlider.Maximum = 1;
musicSlider.Value = Core.Audio.SongVolume;
@@ -206,7 +206,7 @@ private void CreateOptionsPanel()
sfxSlider.Name = "SfxSlider";
sfxSlider.Text = "SFX";
sfxSlider.Anchor(Gum.Wireframe.Anchor.Top);
- sfxSlider.Visual.Y = 93;
+ sfxSlider.Y = 93;
sfxSlider.Minimum = 0;
sfxSlider.Maximum = 1;
sfxSlider.Value = Core.Audio.SoundEffectVolume;
diff --git a/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/UI/AnimatedButton.cs b/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/UI/AnimatedButton.cs
index 56ba8cfc..e3058cd0 100644
--- a/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/UI/AnimatedButton.cs
+++ b/Tutorials/learn-monogame-2d/src/21-Customizing-Gum-UI/DungeonSlime/UI/AnimatedButton.cs
@@ -2,7 +2,7 @@
using Gum.DataTypes;
using Gum.DataTypes.Variables;
using Gum.Forms.Controls;
-using Gum.Forms.DefaultVisuals;
+using Gum.Forms.DefaultVisuals.V3;
using Gum.Graphics.Animation;
using Gum.Managers;
using Microsoft.Xna.Framework.Input;
diff --git a/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/DungeonSlime.csproj b/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/DungeonSlime.csproj
index 14e50b9a..fa855021 100644
--- a/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/DungeonSlime.csproj
+++ b/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/DungeonSlime.csproj
@@ -23,7 +23,7 @@
-
+
diff --git a/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/Game1.cs b/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/Game1.cs
index 65120979..f886fc4a 100644
--- a/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/Game1.cs
+++ b/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/Game1.cs
@@ -34,7 +34,7 @@ protected override void Initialize()
private void InitializeGum()
{
// Initialize the Gum service
- GumService.Default.Initialize(this, DefaultVisualsVersion.V2);
+ GumService.Default.Initialize(this, DefaultVisualsVersion.V3);
// Tell the Gum service which content manager to use. We will tell it to
// use the global content manager from our Core.
diff --git a/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/Scenes/GameScene.cs b/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/Scenes/GameScene.cs
index 2ef55d6b..b103a37f 100644
--- a/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/Scenes/GameScene.cs
+++ b/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/Scenes/GameScene.cs
@@ -150,10 +150,10 @@ private void CreatePausePanel()
{
_pausePanel = new Panel();
_pausePanel.Anchor(Anchor.Center);
- _pausePanel.Visual.WidthUnits = DimensionUnitType.Absolute;
- _pausePanel.Visual.HeightUnits = DimensionUnitType.Absolute;
- _pausePanel.Visual.Height = 70;
- _pausePanel.Visual.Width = 264;
+ _pausePanel.WidthUnits = DimensionUnitType.Absolute;
+ _pausePanel.HeightUnits = DimensionUnitType.Absolute;
+ _pausePanel.Height = 70;
+ _pausePanel.Width = 264;
_pausePanel.IsVisible = false;
_pausePanel.AddToRoot();
@@ -181,16 +181,16 @@ private void CreatePausePanel()
_resumeButton = new AnimatedButton(_atlas);
_resumeButton.Text = "RESUME";
_resumeButton.Anchor(Anchor.BottomLeft);
- _resumeButton.Visual.X = 9f;
- _resumeButton.Visual.Y = -9f;
+ _resumeButton.X = 9f;
+ _resumeButton.Y = -9f;
_resumeButton.Click += HandleResumeButtonClicked;
_pausePanel.AddChild(_resumeButton);
AnimatedButton quitButton = new AnimatedButton(_atlas);
quitButton.Text = "QUIT";
quitButton.Anchor(Anchor.BottomRight);
- quitButton.Visual.X = -9f;
- quitButton.Visual.Y = -9f;
+ quitButton.X = -9f;
+ quitButton.Y = -9f;
quitButton.Click += HandleQuitButtonClicked;
_pausePanel.AddChild(quitButton);
diff --git a/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/Scenes/TitleScene.cs b/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/Scenes/TitleScene.cs
index 742cdf47..b895d425 100644
--- a/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/Scenes/TitleScene.cs
+++ b/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/Scenes/TitleScene.cs
@@ -131,16 +131,16 @@ private void CreateTitlePanel()
AnimatedButton startButton = new AnimatedButton(_atlas);
startButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- startButton.Visual.X = 50;
- startButton.Visual.Y = -12;
+ startButton.X = 50;
+ startButton.Y = -12;
startButton.Text = "Start";
startButton.Click += HandleStartClicked;
_titleScreenButtonsPanel.AddChild(startButton);
_optionsButton = new AnimatedButton(_atlas);
_optionsButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- _optionsButton.Visual.X = -50;
- _optionsButton.Visual.Y = -12;
+ _optionsButton.X = -50;
+ _optionsButton.Y = -12;
_optionsButton.Text = "Options";
_optionsButton.Click += HandleOptionsClicked;
_titleScreenButtonsPanel.AddChild(_optionsButton);
@@ -192,7 +192,7 @@ private void CreateOptionsPanel()
musicSlider.Name = "MusicSlider";
musicSlider.Text = "MUSIC";
musicSlider.Anchor(Gum.Wireframe.Anchor.Top);
- musicSlider.Visual.Y = 30f;
+ musicSlider.Y = 30f;
musicSlider.Minimum = 0;
musicSlider.Maximum = 1;
musicSlider.Value = Core.Audio.SongVolume;
@@ -206,7 +206,7 @@ private void CreateOptionsPanel()
sfxSlider.Name = "SfxSlider";
sfxSlider.Text = "SFX";
sfxSlider.Anchor(Gum.Wireframe.Anchor.Top);
- sfxSlider.Visual.Y = 93;
+ sfxSlider.Y = 93;
sfxSlider.Minimum = 0;
sfxSlider.Maximum = 1;
sfxSlider.Value = Core.Audio.SoundEffectVolume;
diff --git a/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/UI/AnimatedButton.cs b/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/UI/AnimatedButton.cs
index 56ba8cfc..e3058cd0 100644
--- a/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/UI/AnimatedButton.cs
+++ b/Tutorials/learn-monogame-2d/src/22-Snake-Game-Mechanics/DungeonSlime/UI/AnimatedButton.cs
@@ -2,7 +2,7 @@
using Gum.DataTypes;
using Gum.DataTypes.Variables;
using Gum.Forms.Controls;
-using Gum.Forms.DefaultVisuals;
+using Gum.Forms.DefaultVisuals.V3;
using Gum.Graphics.Animation;
using Gum.Managers;
using Microsoft.Xna.Framework.Input;
diff --git a/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/DungeonSlime.csproj b/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/DungeonSlime.csproj
index 14e50b9a..fa855021 100644
--- a/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/DungeonSlime.csproj
+++ b/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/DungeonSlime.csproj
@@ -23,7 +23,7 @@
-
+
diff --git a/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/Game1.cs b/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/Game1.cs
index 65120979..f886fc4a 100644
--- a/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/Game1.cs
+++ b/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/Game1.cs
@@ -34,7 +34,7 @@ protected override void Initialize()
private void InitializeGum()
{
// Initialize the Gum service
- GumService.Default.Initialize(this, DefaultVisualsVersion.V2);
+ GumService.Default.Initialize(this, DefaultVisualsVersion.V3);
// Tell the Gum service which content manager to use. We will tell it to
// use the global content manager from our Core.
diff --git a/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/Scenes/TitleScene.cs b/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/Scenes/TitleScene.cs
index 742cdf47..b895d425 100644
--- a/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/Scenes/TitleScene.cs
+++ b/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/Scenes/TitleScene.cs
@@ -131,16 +131,16 @@ private void CreateTitlePanel()
AnimatedButton startButton = new AnimatedButton(_atlas);
startButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- startButton.Visual.X = 50;
- startButton.Visual.Y = -12;
+ startButton.X = 50;
+ startButton.Y = -12;
startButton.Text = "Start";
startButton.Click += HandleStartClicked;
_titleScreenButtonsPanel.AddChild(startButton);
_optionsButton = new AnimatedButton(_atlas);
_optionsButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- _optionsButton.Visual.X = -50;
- _optionsButton.Visual.Y = -12;
+ _optionsButton.X = -50;
+ _optionsButton.Y = -12;
_optionsButton.Text = "Options";
_optionsButton.Click += HandleOptionsClicked;
_titleScreenButtonsPanel.AddChild(_optionsButton);
@@ -192,7 +192,7 @@ private void CreateOptionsPanel()
musicSlider.Name = "MusicSlider";
musicSlider.Text = "MUSIC";
musicSlider.Anchor(Gum.Wireframe.Anchor.Top);
- musicSlider.Visual.Y = 30f;
+ musicSlider.Y = 30f;
musicSlider.Minimum = 0;
musicSlider.Maximum = 1;
musicSlider.Value = Core.Audio.SongVolume;
@@ -206,7 +206,7 @@ private void CreateOptionsPanel()
sfxSlider.Name = "SfxSlider";
sfxSlider.Text = "SFX";
sfxSlider.Anchor(Gum.Wireframe.Anchor.Top);
- sfxSlider.Visual.Y = 93;
+ sfxSlider.Y = 93;
sfxSlider.Minimum = 0;
sfxSlider.Maximum = 1;
sfxSlider.Value = Core.Audio.SoundEffectVolume;
diff --git a/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/UI/AnimatedButton.cs b/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/UI/AnimatedButton.cs
index 56ba8cfc..e3058cd0 100644
--- a/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/UI/AnimatedButton.cs
+++ b/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/UI/AnimatedButton.cs
@@ -2,7 +2,7 @@
using Gum.DataTypes;
using Gum.DataTypes.Variables;
using Gum.Forms.Controls;
-using Gum.Forms.DefaultVisuals;
+using Gum.Forms.DefaultVisuals.V3;
using Gum.Graphics.Animation;
using Gum.Managers;
using Microsoft.Xna.Framework.Input;
diff --git a/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/UI/GameSceneUI.cs b/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/UI/GameSceneUI.cs
index 498655c2..83424927 100644
--- a/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/UI/GameSceneUI.cs
+++ b/Tutorials/learn-monogame-2d/src/23-Completing-The-Game/DungeonSlime/UI/GameSceneUI.cs
@@ -106,10 +106,10 @@ private Panel CreatePausePanel(TextureAtlas atlas)
{
Panel panel = new Panel();
panel.Anchor(Gum.Wireframe.Anchor.Center);
- panel.Visual.WidthUnits = DimensionUnitType.Absolute;
- panel.Visual.HeightUnits = DimensionUnitType.Absolute;
- panel.Visual.Width = 264.0f;
- panel.Visual.Height = 70.0f;
+ panel.WidthUnits = DimensionUnitType.Absolute;
+ panel.HeightUnits = DimensionUnitType.Absolute;
+ panel.Width = 264.0f;
+ panel.Height = 70.0f;
panel.IsVisible = false;
TextureRegion backgroundRegion = atlas.GetRegion("panel-background");
@@ -136,8 +136,8 @@ private Panel CreatePausePanel(TextureAtlas atlas)
_resumeButton = new AnimatedButton(atlas);
_resumeButton.Text = "RESUME";
_resumeButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- _resumeButton.Visual.X = 9.0f;
- _resumeButton.Visual.Y = -9.0f;
+ _resumeButton.X = 9.0f;
+ _resumeButton.Y = -9.0f;
_resumeButton.Click += OnResumeButtonClicked;
_resumeButton.GotFocus += OnElementGotFocus;
@@ -147,8 +147,8 @@ private Panel CreatePausePanel(TextureAtlas atlas)
AnimatedButton quitButton = new AnimatedButton(atlas);
quitButton.Text = "QUIT";
quitButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- quitButton.Visual.X = -9.0f;
- quitButton.Visual.Y = -9.0f;
+ quitButton.X = -9.0f;
+ quitButton.Y = -9.0f;
quitButton.Click += OnQuitButtonClicked;
quitButton.GotFocus += OnElementGotFocus;
@@ -162,10 +162,10 @@ private Panel CreateGameOverPanel(TextureAtlas atlas)
{
Panel panel = new Panel();
panel.Anchor(Gum.Wireframe.Anchor.Center);
- panel.Visual.WidthUnits = DimensionUnitType.Absolute;
- panel.Visual.HeightUnits = DimensionUnitType.Absolute;
- panel.Visual.Width = 264.0f;
- panel.Visual.Height = 70.0f;
+ panel.WidthUnits = DimensionUnitType.Absolute;
+ panel.HeightUnits = DimensionUnitType.Absolute;
+ panel.Width = 264.0f;
+ panel.Height = 70.0f;
panel.IsVisible = false;
TextureRegion backgroundRegion = atlas.GetRegion("panel-background");
@@ -193,8 +193,8 @@ private Panel CreateGameOverPanel(TextureAtlas atlas)
_retryButton = new AnimatedButton(atlas);
_retryButton.Text = "RETRY";
_retryButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- _retryButton.Visual.X = 9.0f;
- _retryButton.Visual.Y = -9.0f;
+ _retryButton.X = 9.0f;
+ _retryButton.Y = -9.0f;
_retryButton.Click += OnRetryButtonClicked;
_retryButton.GotFocus += OnElementGotFocus;
@@ -204,8 +204,8 @@ private Panel CreateGameOverPanel(TextureAtlas atlas)
AnimatedButton quitButton = new AnimatedButton(atlas);
quitButton.Text = "QUIT";
quitButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- quitButton.Visual.X = -9.0f;
- quitButton.Visual.Y = -9.0f;
+ quitButton.X = -9.0f;
+ quitButton.Y = -9.0f;
quitButton.Click += OnQuitButtonClicked;
quitButton.GotFocus += OnElementGotFocus;
diff --git a/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/DungeonSlime.csproj b/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/DungeonSlime.csproj
index 14e50b9a..fa855021 100644
--- a/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/DungeonSlime.csproj
+++ b/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/DungeonSlime.csproj
@@ -23,7 +23,7 @@
-
+
diff --git a/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/Game1.cs b/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/Game1.cs
index 65120979..f886fc4a 100644
--- a/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/Game1.cs
+++ b/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/Game1.cs
@@ -34,7 +34,7 @@ protected override void Initialize()
private void InitializeGum()
{
// Initialize the Gum service
- GumService.Default.Initialize(this, DefaultVisualsVersion.V2);
+ GumService.Default.Initialize(this, DefaultVisualsVersion.V3);
// Tell the Gum service which content manager to use. We will tell it to
// use the global content manager from our Core.
diff --git a/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/Scenes/TitleScene.cs b/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/Scenes/TitleScene.cs
index 742cdf47..b895d425 100644
--- a/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/Scenes/TitleScene.cs
+++ b/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/Scenes/TitleScene.cs
@@ -131,16 +131,16 @@ private void CreateTitlePanel()
AnimatedButton startButton = new AnimatedButton(_atlas);
startButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- startButton.Visual.X = 50;
- startButton.Visual.Y = -12;
+ startButton.X = 50;
+ startButton.Y = -12;
startButton.Text = "Start";
startButton.Click += HandleStartClicked;
_titleScreenButtonsPanel.AddChild(startButton);
_optionsButton = new AnimatedButton(_atlas);
_optionsButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- _optionsButton.Visual.X = -50;
- _optionsButton.Visual.Y = -12;
+ _optionsButton.X = -50;
+ _optionsButton.Y = -12;
_optionsButton.Text = "Options";
_optionsButton.Click += HandleOptionsClicked;
_titleScreenButtonsPanel.AddChild(_optionsButton);
@@ -192,7 +192,7 @@ private void CreateOptionsPanel()
musicSlider.Name = "MusicSlider";
musicSlider.Text = "MUSIC";
musicSlider.Anchor(Gum.Wireframe.Anchor.Top);
- musicSlider.Visual.Y = 30f;
+ musicSlider.Y = 30f;
musicSlider.Minimum = 0;
musicSlider.Maximum = 1;
musicSlider.Value = Core.Audio.SongVolume;
@@ -206,7 +206,7 @@ private void CreateOptionsPanel()
sfxSlider.Name = "SfxSlider";
sfxSlider.Text = "SFX";
sfxSlider.Anchor(Gum.Wireframe.Anchor.Top);
- sfxSlider.Visual.Y = 93;
+ sfxSlider.Y = 93;
sfxSlider.Minimum = 0;
sfxSlider.Maximum = 1;
sfxSlider.Value = Core.Audio.SoundEffectVolume;
diff --git a/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/UI/AnimatedButton.cs b/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/UI/AnimatedButton.cs
index 4cce6ee5..2f33ade4 100644
--- a/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/UI/AnimatedButton.cs
+++ b/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/UI/AnimatedButton.cs
@@ -2,7 +2,7 @@
using Gum.DataTypes;
using Gum.DataTypes.Variables;
using Gum.Forms.Controls;
-using Gum.Forms.DefaultVisuals;
+using Gum.Forms.DefaultVisuals.V3;
using Gum.Graphics.Animation;
using Gum.Managers;
using Microsoft.Xna.Framework.Input;
diff --git a/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/UI/GameSceneUI.cs b/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/UI/GameSceneUI.cs
index 498655c2..83424927 100644
--- a/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/UI/GameSceneUI.cs
+++ b/Tutorials/learn-monogame-2d/src/24-Shaders/DungeonSlime/UI/GameSceneUI.cs
@@ -106,10 +106,10 @@ private Panel CreatePausePanel(TextureAtlas atlas)
{
Panel panel = new Panel();
panel.Anchor(Gum.Wireframe.Anchor.Center);
- panel.Visual.WidthUnits = DimensionUnitType.Absolute;
- panel.Visual.HeightUnits = DimensionUnitType.Absolute;
- panel.Visual.Width = 264.0f;
- panel.Visual.Height = 70.0f;
+ panel.WidthUnits = DimensionUnitType.Absolute;
+ panel.HeightUnits = DimensionUnitType.Absolute;
+ panel.Width = 264.0f;
+ panel.Height = 70.0f;
panel.IsVisible = false;
TextureRegion backgroundRegion = atlas.GetRegion("panel-background");
@@ -136,8 +136,8 @@ private Panel CreatePausePanel(TextureAtlas atlas)
_resumeButton = new AnimatedButton(atlas);
_resumeButton.Text = "RESUME";
_resumeButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- _resumeButton.Visual.X = 9.0f;
- _resumeButton.Visual.Y = -9.0f;
+ _resumeButton.X = 9.0f;
+ _resumeButton.Y = -9.0f;
_resumeButton.Click += OnResumeButtonClicked;
_resumeButton.GotFocus += OnElementGotFocus;
@@ -147,8 +147,8 @@ private Panel CreatePausePanel(TextureAtlas atlas)
AnimatedButton quitButton = new AnimatedButton(atlas);
quitButton.Text = "QUIT";
quitButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- quitButton.Visual.X = -9.0f;
- quitButton.Visual.Y = -9.0f;
+ quitButton.X = -9.0f;
+ quitButton.Y = -9.0f;
quitButton.Click += OnQuitButtonClicked;
quitButton.GotFocus += OnElementGotFocus;
@@ -162,10 +162,10 @@ private Panel CreateGameOverPanel(TextureAtlas atlas)
{
Panel panel = new Panel();
panel.Anchor(Gum.Wireframe.Anchor.Center);
- panel.Visual.WidthUnits = DimensionUnitType.Absolute;
- panel.Visual.HeightUnits = DimensionUnitType.Absolute;
- panel.Visual.Width = 264.0f;
- panel.Visual.Height = 70.0f;
+ panel.WidthUnits = DimensionUnitType.Absolute;
+ panel.HeightUnits = DimensionUnitType.Absolute;
+ panel.Width = 264.0f;
+ panel.Height = 70.0f;
panel.IsVisible = false;
TextureRegion backgroundRegion = atlas.GetRegion("panel-background");
@@ -193,8 +193,8 @@ private Panel CreateGameOverPanel(TextureAtlas atlas)
_retryButton = new AnimatedButton(atlas);
_retryButton.Text = "RETRY";
_retryButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- _retryButton.Visual.X = 9.0f;
- _retryButton.Visual.Y = -9.0f;
+ _retryButton.X = 9.0f;
+ _retryButton.Y = -9.0f;
_retryButton.Click += OnRetryButtonClicked;
_retryButton.GotFocus += OnElementGotFocus;
@@ -204,8 +204,8 @@ private Panel CreateGameOverPanel(TextureAtlas atlas)
AnimatedButton quitButton = new AnimatedButton(atlas);
quitButton.Text = "QUIT";
quitButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- quitButton.Visual.X = -9.0f;
- quitButton.Visual.Y = -9.0f;
+ quitButton.X = -9.0f;
+ quitButton.Y = -9.0f;
quitButton.Click += OnQuitButtonClicked;
quitButton.GotFocus += OnElementGotFocus;
diff --git a/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/DungeonSlime.csproj b/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/DungeonSlime.csproj
index 14e50b9a..fa855021 100644
--- a/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/DungeonSlime.csproj
+++ b/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/DungeonSlime.csproj
@@ -23,7 +23,7 @@
-
+
diff --git a/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/Game1.cs b/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/Game1.cs
index 3d0e602b..f886fc4a 100644
--- a/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/Game1.cs
+++ b/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/Game1.cs
@@ -2,6 +2,7 @@
using Microsoft.Xna.Framework.Media;
using MonoGameLibrary;
using MonoGameGum;
+using Gum.Forms;
using Gum.Forms.Controls;
namespace DungeonSlime;
@@ -33,7 +34,7 @@ protected override void Initialize()
private void InitializeGum()
{
// Initialize the Gum service
- GumService.Default.Initialize(this);
+ GumService.Default.Initialize(this, DefaultVisualsVersion.V3);
// Tell the Gum service which content manager to use. We will tell it to
// use the global content manager from our Core.
diff --git a/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/Scenes/TitleScene.cs b/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/Scenes/TitleScene.cs
index 248c48dd..4bf0b892 100644
--- a/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/Scenes/TitleScene.cs
+++ b/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/Scenes/TitleScene.cs
@@ -131,16 +131,16 @@ private void CreateTitlePanel()
AnimatedButton startButton = new AnimatedButton(_atlas);
startButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- startButton.Visual.X = 50;
- startButton.Visual.Y = -12;
+ startButton.X = 50;
+ startButton.Y = -12;
startButton.Text = "Start";
startButton.Click += HandleStartClicked;
_titleScreenButtonsPanel.AddChild(startButton);
_optionsButton = new AnimatedButton(_atlas);
_optionsButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- _optionsButton.Visual.X = -50;
- _optionsButton.Visual.Y = -12;
+ _optionsButton.X = -50;
+ _optionsButton.Y = -12;
_optionsButton.Text = "Options";
_optionsButton.Click += HandleOptionsClicked;
_titleScreenButtonsPanel.AddChild(_optionsButton);
@@ -192,7 +192,7 @@ private void CreateOptionsPanel()
musicSlider.Name = "MusicSlider";
musicSlider.Text = "MUSIC";
musicSlider.Anchor(Gum.Wireframe.Anchor.Top);
- musicSlider.Visual.Y = 30f;
+ musicSlider.Y = 30f;
musicSlider.Minimum = 0;
musicSlider.Maximum = 1;
musicSlider.Value = Core.Audio.SongVolume;
@@ -206,7 +206,7 @@ private void CreateOptionsPanel()
sfxSlider.Name = "SfxSlider";
sfxSlider.Text = "SFX";
sfxSlider.Anchor(Gum.Wireframe.Anchor.Top);
- sfxSlider.Visual.Y = 93;
+ sfxSlider.Y = 93;
sfxSlider.Minimum = 0;
sfxSlider.Maximum = 1;
sfxSlider.Value = Core.Audio.SoundEffectVolume;
diff --git a/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/UI/AnimatedButton.cs b/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/UI/AnimatedButton.cs
index 769c7196..2f33ade4 100644
--- a/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/UI/AnimatedButton.cs
+++ b/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/UI/AnimatedButton.cs
@@ -1,10 +1,11 @@
using System;
using Gum.DataTypes;
using Gum.DataTypes.Variables;
+using Gum.Forms.Controls;
+using Gum.Forms.DefaultVisuals.V3;
using Gum.Graphics.Animation;
using Gum.Managers;
using Microsoft.Xna.Framework.Input;
-using MonoGameGum.Forms.Controls;
using MonoGameGum.GueDeriving;
using MonoGameLibrary.Graphics;
@@ -22,27 +23,26 @@ internal class AnimatedButton : Button
/// The texture atlas containing button graphics and animations
public AnimatedButton(TextureAtlas atlas)
{
- // Create the top-level container that will hold all visual elements
+ // Each Forms conrol has a general Visual property that
+ // has properties shared by all control types. This Visual
+ // type matches the Forms type. It can be casted to access
+ // controls-specific properties.
+ ButtonVisual buttonVisual = (ButtonVisual)Visual;
// Width is relative to children with extra padding, height is fixed
- ContainerRuntime topLevelContainer = new ContainerRuntime();
- topLevelContainer.Height = 14f;
- topLevelContainer.HeightUnits = DimensionUnitType.Absolute;
- topLevelContainer.Width = 21f;
- topLevelContainer.WidthUnits = DimensionUnitType.RelativeToChildren;
+ buttonVisual.Height = 14f;
+ buttonVisual.HeightUnits = DimensionUnitType.Absolute;
+ buttonVisual.Width = 21f;
+ buttonVisual.WidthUnits = DimensionUnitType.RelativeToChildren;
- // Create the nine-slice background that will display the button graphics
+ // Get a reference to the nine-slice background to display the button graphics
// A nine-slice allows the button to stretch while preserving corner appearance
- NineSliceRuntime nineSliceInstance = new NineSliceRuntime();
- nineSliceInstance.Height = 0f;
- nineSliceInstance.Texture = atlas.Texture;
- nineSliceInstance.TextureAddress = TextureAddress.Custom;
- nineSliceInstance.Dock(Gum.Wireframe.Dock.Fill);
- topLevelContainer.Children.Add(nineSliceInstance);
-
- // Create the text element that will display the button's label
- TextRuntime textInstance = new TextRuntime();
- // Name is required so it hooks in to the base Button.Text property
- textInstance.Name = "TextInstance";
+ NineSliceRuntime background = buttonVisual.Background;
+ background.Texture = atlas.Texture;
+ background.TextureAddress = TextureAddress.Custom;
+ background.Color = Microsoft.Xna.Framework.Color.White;
+ // texture coordinates for the background are set by AnimationChains below
+
+ TextRuntime textInstance = buttonVisual.TextInstance;
textInstance.Text = "START";
textInstance.Blue = 130;
textInstance.Green = 86;
@@ -53,7 +53,6 @@ public AnimatedButton(TextureAtlas atlas)
textInstance.Anchor(Gum.Wireframe.Anchor.Center);
textInstance.Width = 0;
textInstance.WidthUnits = DimensionUnitType.RelativeToChildren;
- topLevelContainer.Children.Add(textInstance);
// Get the texture region for the unfocused button state from the atlas
TextureRegion unfocusedTextureRegion = atlas.GetRegion("unfocused-button");
@@ -94,58 +93,47 @@ public AnimatedButton(TextureAtlas atlas)
}
// Assign both animation chains to the nine-slice background
- nineSliceInstance.AnimationChains = new AnimationChainList
+ background.AnimationChains = new AnimationChainList
{
unfocusedAnimation,
focusedAnimation
};
- // Create a state category for button states
- StateSaveCategory category = new StateSaveCategory();
- category.Name = Button.ButtonCategoryName;
- topLevelContainer.AddCategory(category);
- // Create the enabled (default/unfocused) state
- StateSave enabledState = new StateSave();
- enabledState.Name = FrameworkElement.EnabledStateName;
+ // Reset all state to default so we don't have unexpected variable assignments:
+ buttonVisual.ButtonCategory.ResetAllStates();
+
+ // Get the enabled (default/unfocused) state
+ StateSave enabledState = buttonVisual.States.Enabled;
enabledState.Apply = () =>
{
// When enabled but not focused, use the unfocused animation
- nineSliceInstance.CurrentChainName = unfocusedAnimation.Name;
+ background.CurrentChainName = unfocusedAnimation.Name;
};
- category.States.Add(enabledState);
// Create the focused state
- StateSave focusedState = new StateSave();
- focusedState.Name = FrameworkElement.FocusedStateName;
+ StateSave focusedState = buttonVisual.States.Focused;
focusedState.Apply = () =>
{
// When focused, use the focused animation and enable animation playback
- nineSliceInstance.CurrentChainName = focusedAnimation.Name;
- nineSliceInstance.Animate = true;
+ background.CurrentChainName = focusedAnimation.Name;
+ background.Animate = true;
};
- category.States.Add(focusedState);
// Create the highlighted+focused state (for mouse hover while focused)
- // by cloning the focused state since they appear the same
- StateSave highlightedFocused = focusedState.Clone();
- highlightedFocused.Name = FrameworkElement.HighlightedFocusedStateName;
- category.States.Add(highlightedFocused);
+ StateSave highlightedFocused = buttonVisual.States.HighlightedFocused;
+ highlightedFocused.Apply = focusedState.Apply;
// Create the highlighted state (for mouse hover)
// by cloning the enabled state since they appear the same
- StateSave highlighted = enabledState.Clone();
- highlighted.Name = FrameworkElement.HighlightedStateName;
- category.States.Add(highlighted);
+ StateSave highlighted = buttonVisual.States.Highlighted;
+ highlighted.Apply = enabledState.Apply;
// Add event handlers for keyboard input.
KeyDown += HandleKeyDown;
// Add event handler for mouse hover focus.
- topLevelContainer.RollOn += HandleRollOn;
-
- // Assign the configured container as this button's visual
- Visual = topLevelContainer;
+ buttonVisual.RollOn += HandleRollOn;
}
///
diff --git a/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/UI/GameSceneUI.cs b/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/UI/GameSceneUI.cs
index 84be9293..fa164030 100644
--- a/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/UI/GameSceneUI.cs
+++ b/Tutorials/learn-monogame-2d/src/25-Packaging-Game/DungeonSlime/UI/GameSceneUI.cs
@@ -106,10 +106,10 @@ private Panel CreatePausePanel(TextureAtlas atlas)
{
Panel panel = new Panel();
panel.Anchor(Gum.Wireframe.Anchor.Center);
- panel.Visual.WidthUnits = DimensionUnitType.Absolute;
- panel.Visual.HeightUnits = DimensionUnitType.Absolute;
- panel.Visual.Width = 264.0f;
- panel.Visual.Height = 70.0f;
+ panel.WidthUnits = DimensionUnitType.Absolute;
+ panel.HeightUnits = DimensionUnitType.Absolute;
+ panel.Width = 264.0f;
+ panel.Height = 70.0f;
panel.IsVisible = false;
TextureRegion backgroundRegion = atlas.GetRegion("panel-background");
@@ -136,8 +136,8 @@ private Panel CreatePausePanel(TextureAtlas atlas)
_resumeButton = new AnimatedButton(atlas);
_resumeButton.Text = "RESUME";
_resumeButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- _resumeButton.Visual.X = 9.0f;
- _resumeButton.Visual.Y = -9.0f;
+ _resumeButton.X = 9.0f;
+ _resumeButton.Y = -9.0f;
_resumeButton.Click += OnResumeButtonClicked;
_resumeButton.GotFocus += OnElementGotFocus;
@@ -147,8 +147,8 @@ private Panel CreatePausePanel(TextureAtlas atlas)
AnimatedButton quitButton = new AnimatedButton(atlas);
quitButton.Text = "QUIT";
quitButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- quitButton.Visual.X = -9.0f;
- quitButton.Visual.Y = -9.0f;
+ quitButton.X = -9.0f;
+ quitButton.Y = -9.0f;
quitButton.Click += OnQuitButtonClicked;
quitButton.GotFocus += OnElementGotFocus;
@@ -162,10 +162,10 @@ private Panel CreateGameOverPanel(TextureAtlas atlas)
{
Panel panel = new Panel();
panel.Anchor(Gum.Wireframe.Anchor.Center);
- panel.Visual.WidthUnits = DimensionUnitType.Absolute;
- panel.Visual.HeightUnits = DimensionUnitType.Absolute;
- panel.Visual.Width = 264.0f;
- panel.Visual.Height = 70.0f;
+ panel.WidthUnits = DimensionUnitType.Absolute;
+ panel.HeightUnits = DimensionUnitType.Absolute;
+ panel.Width = 264.0f;
+ panel.Height = 70.0f;
panel.IsVisible = false;
TextureRegion backgroundRegion = atlas.GetRegion("panel-background");
@@ -193,8 +193,8 @@ private Panel CreateGameOverPanel(TextureAtlas atlas)
_retryButton = new AnimatedButton(atlas);
_retryButton.Text = "RETRY";
_retryButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- _retryButton.Visual.X = 9.0f;
- _retryButton.Visual.Y = -9.0f;
+ _retryButton.X = 9.0f;
+ _retryButton.Y = -9.0f;
_retryButton.Click += OnRetryButtonClicked;
_retryButton.GotFocus += OnElementGotFocus;
@@ -204,8 +204,8 @@ private Panel CreateGameOverPanel(TextureAtlas atlas)
AnimatedButton quitButton = new AnimatedButton(atlas);
quitButton.Text = "QUIT";
quitButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- quitButton.Visual.X = -9.0f;
- quitButton.Visual.Y = -9.0f;
+ quitButton.X = -9.0f;
+ quitButton.Y = -9.0f;
quitButton.Click += OnQuitButtonClicked;
quitButton.GotFocus += OnElementGotFocus;
diff --git a/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/DungeonSlime.csproj b/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/DungeonSlime.csproj
index 14e50b9a..fa855021 100644
--- a/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/DungeonSlime.csproj
+++ b/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/DungeonSlime.csproj
@@ -23,7 +23,7 @@
-
+
diff --git a/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/Game1.cs b/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/Game1.cs
index 3d0e602b..f886fc4a 100644
--- a/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/Game1.cs
+++ b/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/Game1.cs
@@ -2,6 +2,7 @@
using Microsoft.Xna.Framework.Media;
using MonoGameLibrary;
using MonoGameGum;
+using Gum.Forms;
using Gum.Forms.Controls;
namespace DungeonSlime;
@@ -33,7 +34,7 @@ protected override void Initialize()
private void InitializeGum()
{
// Initialize the Gum service
- GumService.Default.Initialize(this);
+ GumService.Default.Initialize(this, DefaultVisualsVersion.V3);
// Tell the Gum service which content manager to use. We will tell it to
// use the global content manager from our Core.
diff --git a/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/Scenes/TitleScene.cs b/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/Scenes/TitleScene.cs
index 248c48dd..4bf0b892 100644
--- a/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/Scenes/TitleScene.cs
+++ b/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/Scenes/TitleScene.cs
@@ -131,16 +131,16 @@ private void CreateTitlePanel()
AnimatedButton startButton = new AnimatedButton(_atlas);
startButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- startButton.Visual.X = 50;
- startButton.Visual.Y = -12;
+ startButton.X = 50;
+ startButton.Y = -12;
startButton.Text = "Start";
startButton.Click += HandleStartClicked;
_titleScreenButtonsPanel.AddChild(startButton);
_optionsButton = new AnimatedButton(_atlas);
_optionsButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- _optionsButton.Visual.X = -50;
- _optionsButton.Visual.Y = -12;
+ _optionsButton.X = -50;
+ _optionsButton.Y = -12;
_optionsButton.Text = "Options";
_optionsButton.Click += HandleOptionsClicked;
_titleScreenButtonsPanel.AddChild(_optionsButton);
@@ -192,7 +192,7 @@ private void CreateOptionsPanel()
musicSlider.Name = "MusicSlider";
musicSlider.Text = "MUSIC";
musicSlider.Anchor(Gum.Wireframe.Anchor.Top);
- musicSlider.Visual.Y = 30f;
+ musicSlider.Y = 30f;
musicSlider.Minimum = 0;
musicSlider.Maximum = 1;
musicSlider.Value = Core.Audio.SongVolume;
@@ -206,7 +206,7 @@ private void CreateOptionsPanel()
sfxSlider.Name = "SfxSlider";
sfxSlider.Text = "SFX";
sfxSlider.Anchor(Gum.Wireframe.Anchor.Top);
- sfxSlider.Visual.Y = 93;
+ sfxSlider.Y = 93;
sfxSlider.Minimum = 0;
sfxSlider.Maximum = 1;
sfxSlider.Value = Core.Audio.SoundEffectVolume;
diff --git a/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/UI/AnimatedButton.cs b/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/UI/AnimatedButton.cs
index 34a59c68..2f33ade4 100644
--- a/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/UI/AnimatedButton.cs
+++ b/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/UI/AnimatedButton.cs
@@ -1,10 +1,11 @@
using System;
using Gum.DataTypes;
using Gum.DataTypes.Variables;
+using Gum.Forms.Controls;
+using Gum.Forms.DefaultVisuals.V3;
using Gum.Graphics.Animation;
using Gum.Managers;
using Microsoft.Xna.Framework.Input;
-using Gum.Forms.Controls;
using MonoGameGum.GueDeriving;
using MonoGameLibrary.Graphics;
@@ -22,27 +23,26 @@ internal class AnimatedButton : Button
/// The texture atlas containing button graphics and animations
public AnimatedButton(TextureAtlas atlas)
{
- // Create the top-level container that will hold all visual elements
+ // Each Forms conrol has a general Visual property that
+ // has properties shared by all control types. This Visual
+ // type matches the Forms type. It can be casted to access
+ // controls-specific properties.
+ ButtonVisual buttonVisual = (ButtonVisual)Visual;
// Width is relative to children with extra padding, height is fixed
- ContainerRuntime topLevelContainer = new ContainerRuntime();
- topLevelContainer.Height = 14f;
- topLevelContainer.HeightUnits = DimensionUnitType.Absolute;
- topLevelContainer.Width = 21f;
- topLevelContainer.WidthUnits = DimensionUnitType.RelativeToChildren;
+ buttonVisual.Height = 14f;
+ buttonVisual.HeightUnits = DimensionUnitType.Absolute;
+ buttonVisual.Width = 21f;
+ buttonVisual.WidthUnits = DimensionUnitType.RelativeToChildren;
- // Create the nine-slice background that will display the button graphics
+ // Get a reference to the nine-slice background to display the button graphics
// A nine-slice allows the button to stretch while preserving corner appearance
- NineSliceRuntime nineSliceInstance = new NineSliceRuntime();
- nineSliceInstance.Height = 0f;
- nineSliceInstance.Texture = atlas.Texture;
- nineSliceInstance.TextureAddress = TextureAddress.Custom;
- nineSliceInstance.Dock(Gum.Wireframe.Dock.Fill);
- topLevelContainer.Children.Add(nineSliceInstance);
-
- // Create the text element that will display the button's label
- TextRuntime textInstance = new TextRuntime();
- // Name is required so it hooks in to the base Button.Text property
- textInstance.Name = "TextInstance";
+ NineSliceRuntime background = buttonVisual.Background;
+ background.Texture = atlas.Texture;
+ background.TextureAddress = TextureAddress.Custom;
+ background.Color = Microsoft.Xna.Framework.Color.White;
+ // texture coordinates for the background are set by AnimationChains below
+
+ TextRuntime textInstance = buttonVisual.TextInstance;
textInstance.Text = "START";
textInstance.Blue = 130;
textInstance.Green = 86;
@@ -53,7 +53,6 @@ public AnimatedButton(TextureAtlas atlas)
textInstance.Anchor(Gum.Wireframe.Anchor.Center);
textInstance.Width = 0;
textInstance.WidthUnits = DimensionUnitType.RelativeToChildren;
- topLevelContainer.Children.Add(textInstance);
// Get the texture region for the unfocused button state from the atlas
TextureRegion unfocusedTextureRegion = atlas.GetRegion("unfocused-button");
@@ -94,58 +93,47 @@ public AnimatedButton(TextureAtlas atlas)
}
// Assign both animation chains to the nine-slice background
- nineSliceInstance.AnimationChains = new AnimationChainList
+ background.AnimationChains = new AnimationChainList
{
unfocusedAnimation,
focusedAnimation
};
- // Create a state category for button states
- StateSaveCategory category = new StateSaveCategory();
- category.Name = Button.ButtonCategoryName;
- topLevelContainer.AddCategory(category);
- // Create the enabled (default/unfocused) state
- StateSave enabledState = new StateSave();
- enabledState.Name = FrameworkElement.EnabledStateName;
+ // Reset all state to default so we don't have unexpected variable assignments:
+ buttonVisual.ButtonCategory.ResetAllStates();
+
+ // Get the enabled (default/unfocused) state
+ StateSave enabledState = buttonVisual.States.Enabled;
enabledState.Apply = () =>
{
// When enabled but not focused, use the unfocused animation
- nineSliceInstance.CurrentChainName = unfocusedAnimation.Name;
+ background.CurrentChainName = unfocusedAnimation.Name;
};
- category.States.Add(enabledState);
// Create the focused state
- StateSave focusedState = new StateSave();
- focusedState.Name = FrameworkElement.FocusedStateName;
+ StateSave focusedState = buttonVisual.States.Focused;
focusedState.Apply = () =>
{
// When focused, use the focused animation and enable animation playback
- nineSliceInstance.CurrentChainName = focusedAnimation.Name;
- nineSliceInstance.Animate = true;
+ background.CurrentChainName = focusedAnimation.Name;
+ background.Animate = true;
};
- category.States.Add(focusedState);
// Create the highlighted+focused state (for mouse hover while focused)
- // by cloning the focused state since they appear the same
- StateSave highlightedFocused = focusedState.Clone();
- highlightedFocused.Name = FrameworkElement.HighlightedFocusedStateName;
- category.States.Add(highlightedFocused);
+ StateSave highlightedFocused = buttonVisual.States.HighlightedFocused;
+ highlightedFocused.Apply = focusedState.Apply;
// Create the highlighted state (for mouse hover)
// by cloning the enabled state since they appear the same
- StateSave highlighted = enabledState.Clone();
- highlighted.Name = FrameworkElement.HighlightedStateName;
- category.States.Add(highlighted);
+ StateSave highlighted = buttonVisual.States.Highlighted;
+ highlighted.Apply = enabledState.Apply;
// Add event handlers for keyboard input.
KeyDown += HandleKeyDown;
// Add event handler for mouse hover focus.
- topLevelContainer.RollOn += HandleRollOn;
-
- // Assign the configured container as this button's visual
- Visual = topLevelContainer;
+ buttonVisual.RollOn += HandleRollOn;
}
///
diff --git a/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/UI/GameSceneUI.cs b/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/UI/GameSceneUI.cs
index f724c13e..fa164030 100644
--- a/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/UI/GameSceneUI.cs
+++ b/Tutorials/learn-monogame-2d/src/26-Publish-To-Itch/DungeonSlime/UI/GameSceneUI.cs
@@ -5,7 +5,7 @@
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using MonoGameGum;
-using Forms.Controls;
+using Gum.Forms.Controls;
using MonoGameGum.GueDeriving;
using MonoGameLibrary;
using MonoGameLibrary.Graphics;
@@ -106,10 +106,10 @@ private Panel CreatePausePanel(TextureAtlas atlas)
{
Panel panel = new Panel();
panel.Anchor(Gum.Wireframe.Anchor.Center);
- panel.Visual.WidthUnits = DimensionUnitType.Absolute;
- panel.Visual.HeightUnits = DimensionUnitType.Absolute;
- panel.Visual.Width = 264.0f;
- panel.Visual.Height = 70.0f;
+ panel.WidthUnits = DimensionUnitType.Absolute;
+ panel.HeightUnits = DimensionUnitType.Absolute;
+ panel.Width = 264.0f;
+ panel.Height = 70.0f;
panel.IsVisible = false;
TextureRegion backgroundRegion = atlas.GetRegion("panel-background");
@@ -136,8 +136,8 @@ private Panel CreatePausePanel(TextureAtlas atlas)
_resumeButton = new AnimatedButton(atlas);
_resumeButton.Text = "RESUME";
_resumeButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- _resumeButton.Visual.X = 9.0f;
- _resumeButton.Visual.Y = -9.0f;
+ _resumeButton.X = 9.0f;
+ _resumeButton.Y = -9.0f;
_resumeButton.Click += OnResumeButtonClicked;
_resumeButton.GotFocus += OnElementGotFocus;
@@ -147,8 +147,8 @@ private Panel CreatePausePanel(TextureAtlas atlas)
AnimatedButton quitButton = new AnimatedButton(atlas);
quitButton.Text = "QUIT";
quitButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- quitButton.Visual.X = -9.0f;
- quitButton.Visual.Y = -9.0f;
+ quitButton.X = -9.0f;
+ quitButton.Y = -9.0f;
quitButton.Click += OnQuitButtonClicked;
quitButton.GotFocus += OnElementGotFocus;
@@ -162,10 +162,10 @@ private Panel CreateGameOverPanel(TextureAtlas atlas)
{
Panel panel = new Panel();
panel.Anchor(Gum.Wireframe.Anchor.Center);
- panel.Visual.WidthUnits = DimensionUnitType.Absolute;
- panel.Visual.HeightUnits = DimensionUnitType.Absolute;
- panel.Visual.Width = 264.0f;
- panel.Visual.Height = 70.0f;
+ panel.WidthUnits = DimensionUnitType.Absolute;
+ panel.HeightUnits = DimensionUnitType.Absolute;
+ panel.Width = 264.0f;
+ panel.Height = 70.0f;
panel.IsVisible = false;
TextureRegion backgroundRegion = atlas.GetRegion("panel-background");
@@ -193,8 +193,8 @@ private Panel CreateGameOverPanel(TextureAtlas atlas)
_retryButton = new AnimatedButton(atlas);
_retryButton.Text = "RETRY";
_retryButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- _retryButton.Visual.X = 9.0f;
- _retryButton.Visual.Y = -9.0f;
+ _retryButton.X = 9.0f;
+ _retryButton.Y = -9.0f;
_retryButton.Click += OnRetryButtonClicked;
_retryButton.GotFocus += OnElementGotFocus;
@@ -204,8 +204,8 @@ private Panel CreateGameOverPanel(TextureAtlas atlas)
AnimatedButton quitButton = new AnimatedButton(atlas);
quitButton.Text = "QUIT";
quitButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- quitButton.Visual.X = -9.0f;
- quitButton.Visual.Y = -9.0f;
+ quitButton.X = -9.0f;
+ quitButton.Y = -9.0f;
quitButton.Click += OnQuitButtonClicked;
quitButton.GotFocus += OnElementGotFocus;
diff --git a/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/DungeonSlime.csproj b/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/DungeonSlime.csproj
index 14e50b9a..fa855021 100644
--- a/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/DungeonSlime.csproj
+++ b/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/DungeonSlime.csproj
@@ -23,7 +23,7 @@
-
+
diff --git a/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/Game1.cs b/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/Game1.cs
index 3d0e602b..f886fc4a 100644
--- a/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/Game1.cs
+++ b/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/Game1.cs
@@ -2,6 +2,7 @@
using Microsoft.Xna.Framework.Media;
using MonoGameLibrary;
using MonoGameGum;
+using Gum.Forms;
using Gum.Forms.Controls;
namespace DungeonSlime;
@@ -33,7 +34,7 @@ protected override void Initialize()
private void InitializeGum()
{
// Initialize the Gum service
- GumService.Default.Initialize(this);
+ GumService.Default.Initialize(this, DefaultVisualsVersion.V3);
// Tell the Gum service which content manager to use. We will tell it to
// use the global content manager from our Core.
diff --git a/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/Scenes/TitleScene.cs b/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/Scenes/TitleScene.cs
index 248c48dd..4bf0b892 100644
--- a/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/Scenes/TitleScene.cs
+++ b/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/Scenes/TitleScene.cs
@@ -131,16 +131,16 @@ private void CreateTitlePanel()
AnimatedButton startButton = new AnimatedButton(_atlas);
startButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- startButton.Visual.X = 50;
- startButton.Visual.Y = -12;
+ startButton.X = 50;
+ startButton.Y = -12;
startButton.Text = "Start";
startButton.Click += HandleStartClicked;
_titleScreenButtonsPanel.AddChild(startButton);
_optionsButton = new AnimatedButton(_atlas);
_optionsButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- _optionsButton.Visual.X = -50;
- _optionsButton.Visual.Y = -12;
+ _optionsButton.X = -50;
+ _optionsButton.Y = -12;
_optionsButton.Text = "Options";
_optionsButton.Click += HandleOptionsClicked;
_titleScreenButtonsPanel.AddChild(_optionsButton);
@@ -192,7 +192,7 @@ private void CreateOptionsPanel()
musicSlider.Name = "MusicSlider";
musicSlider.Text = "MUSIC";
musicSlider.Anchor(Gum.Wireframe.Anchor.Top);
- musicSlider.Visual.Y = 30f;
+ musicSlider.Y = 30f;
musicSlider.Minimum = 0;
musicSlider.Maximum = 1;
musicSlider.Value = Core.Audio.SongVolume;
@@ -206,7 +206,7 @@ private void CreateOptionsPanel()
sfxSlider.Name = "SfxSlider";
sfxSlider.Text = "SFX";
sfxSlider.Anchor(Gum.Wireframe.Anchor.Top);
- sfxSlider.Visual.Y = 93;
+ sfxSlider.Y = 93;
sfxSlider.Minimum = 0;
sfxSlider.Maximum = 1;
sfxSlider.Value = Core.Audio.SoundEffectVolume;
diff --git a/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/UI/AnimatedButton.cs b/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/UI/AnimatedButton.cs
index 34a59c68..2f33ade4 100644
--- a/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/UI/AnimatedButton.cs
+++ b/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/UI/AnimatedButton.cs
@@ -1,10 +1,11 @@
using System;
using Gum.DataTypes;
using Gum.DataTypes.Variables;
+using Gum.Forms.Controls;
+using Gum.Forms.DefaultVisuals.V3;
using Gum.Graphics.Animation;
using Gum.Managers;
using Microsoft.Xna.Framework.Input;
-using Gum.Forms.Controls;
using MonoGameGum.GueDeriving;
using MonoGameLibrary.Graphics;
@@ -22,27 +23,26 @@ internal class AnimatedButton : Button
/// The texture atlas containing button graphics and animations
public AnimatedButton(TextureAtlas atlas)
{
- // Create the top-level container that will hold all visual elements
+ // Each Forms conrol has a general Visual property that
+ // has properties shared by all control types. This Visual
+ // type matches the Forms type. It can be casted to access
+ // controls-specific properties.
+ ButtonVisual buttonVisual = (ButtonVisual)Visual;
// Width is relative to children with extra padding, height is fixed
- ContainerRuntime topLevelContainer = new ContainerRuntime();
- topLevelContainer.Height = 14f;
- topLevelContainer.HeightUnits = DimensionUnitType.Absolute;
- topLevelContainer.Width = 21f;
- topLevelContainer.WidthUnits = DimensionUnitType.RelativeToChildren;
+ buttonVisual.Height = 14f;
+ buttonVisual.HeightUnits = DimensionUnitType.Absolute;
+ buttonVisual.Width = 21f;
+ buttonVisual.WidthUnits = DimensionUnitType.RelativeToChildren;
- // Create the nine-slice background that will display the button graphics
+ // Get a reference to the nine-slice background to display the button graphics
// A nine-slice allows the button to stretch while preserving corner appearance
- NineSliceRuntime nineSliceInstance = new NineSliceRuntime();
- nineSliceInstance.Height = 0f;
- nineSliceInstance.Texture = atlas.Texture;
- nineSliceInstance.TextureAddress = TextureAddress.Custom;
- nineSliceInstance.Dock(Gum.Wireframe.Dock.Fill);
- topLevelContainer.Children.Add(nineSliceInstance);
-
- // Create the text element that will display the button's label
- TextRuntime textInstance = new TextRuntime();
- // Name is required so it hooks in to the base Button.Text property
- textInstance.Name = "TextInstance";
+ NineSliceRuntime background = buttonVisual.Background;
+ background.Texture = atlas.Texture;
+ background.TextureAddress = TextureAddress.Custom;
+ background.Color = Microsoft.Xna.Framework.Color.White;
+ // texture coordinates for the background are set by AnimationChains below
+
+ TextRuntime textInstance = buttonVisual.TextInstance;
textInstance.Text = "START";
textInstance.Blue = 130;
textInstance.Green = 86;
@@ -53,7 +53,6 @@ public AnimatedButton(TextureAtlas atlas)
textInstance.Anchor(Gum.Wireframe.Anchor.Center);
textInstance.Width = 0;
textInstance.WidthUnits = DimensionUnitType.RelativeToChildren;
- topLevelContainer.Children.Add(textInstance);
// Get the texture region for the unfocused button state from the atlas
TextureRegion unfocusedTextureRegion = atlas.GetRegion("unfocused-button");
@@ -94,58 +93,47 @@ public AnimatedButton(TextureAtlas atlas)
}
// Assign both animation chains to the nine-slice background
- nineSliceInstance.AnimationChains = new AnimationChainList
+ background.AnimationChains = new AnimationChainList
{
unfocusedAnimation,
focusedAnimation
};
- // Create a state category for button states
- StateSaveCategory category = new StateSaveCategory();
- category.Name = Button.ButtonCategoryName;
- topLevelContainer.AddCategory(category);
- // Create the enabled (default/unfocused) state
- StateSave enabledState = new StateSave();
- enabledState.Name = FrameworkElement.EnabledStateName;
+ // Reset all state to default so we don't have unexpected variable assignments:
+ buttonVisual.ButtonCategory.ResetAllStates();
+
+ // Get the enabled (default/unfocused) state
+ StateSave enabledState = buttonVisual.States.Enabled;
enabledState.Apply = () =>
{
// When enabled but not focused, use the unfocused animation
- nineSliceInstance.CurrentChainName = unfocusedAnimation.Name;
+ background.CurrentChainName = unfocusedAnimation.Name;
};
- category.States.Add(enabledState);
// Create the focused state
- StateSave focusedState = new StateSave();
- focusedState.Name = FrameworkElement.FocusedStateName;
+ StateSave focusedState = buttonVisual.States.Focused;
focusedState.Apply = () =>
{
// When focused, use the focused animation and enable animation playback
- nineSliceInstance.CurrentChainName = focusedAnimation.Name;
- nineSliceInstance.Animate = true;
+ background.CurrentChainName = focusedAnimation.Name;
+ background.Animate = true;
};
- category.States.Add(focusedState);
// Create the highlighted+focused state (for mouse hover while focused)
- // by cloning the focused state since they appear the same
- StateSave highlightedFocused = focusedState.Clone();
- highlightedFocused.Name = FrameworkElement.HighlightedFocusedStateName;
- category.States.Add(highlightedFocused);
+ StateSave highlightedFocused = buttonVisual.States.HighlightedFocused;
+ highlightedFocused.Apply = focusedState.Apply;
// Create the highlighted state (for mouse hover)
// by cloning the enabled state since they appear the same
- StateSave highlighted = enabledState.Clone();
- highlighted.Name = FrameworkElement.HighlightedStateName;
- category.States.Add(highlighted);
+ StateSave highlighted = buttonVisual.States.Highlighted;
+ highlighted.Apply = enabledState.Apply;
// Add event handlers for keyboard input.
KeyDown += HandleKeyDown;
// Add event handler for mouse hover focus.
- topLevelContainer.RollOn += HandleRollOn;
-
- // Assign the configured container as this button's visual
- Visual = topLevelContainer;
+ buttonVisual.RollOn += HandleRollOn;
}
///
diff --git a/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/UI/GameSceneUI.cs b/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/UI/GameSceneUI.cs
index 84be9293..fa164030 100644
--- a/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/UI/GameSceneUI.cs
+++ b/Tutorials/learn-monogame-2d/src/27-Conclusion/DungeonSlime/UI/GameSceneUI.cs
@@ -106,10 +106,10 @@ private Panel CreatePausePanel(TextureAtlas atlas)
{
Panel panel = new Panel();
panel.Anchor(Gum.Wireframe.Anchor.Center);
- panel.Visual.WidthUnits = DimensionUnitType.Absolute;
- panel.Visual.HeightUnits = DimensionUnitType.Absolute;
- panel.Visual.Width = 264.0f;
- panel.Visual.Height = 70.0f;
+ panel.WidthUnits = DimensionUnitType.Absolute;
+ panel.HeightUnits = DimensionUnitType.Absolute;
+ panel.Width = 264.0f;
+ panel.Height = 70.0f;
panel.IsVisible = false;
TextureRegion backgroundRegion = atlas.GetRegion("panel-background");
@@ -136,8 +136,8 @@ private Panel CreatePausePanel(TextureAtlas atlas)
_resumeButton = new AnimatedButton(atlas);
_resumeButton.Text = "RESUME";
_resumeButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- _resumeButton.Visual.X = 9.0f;
- _resumeButton.Visual.Y = -9.0f;
+ _resumeButton.X = 9.0f;
+ _resumeButton.Y = -9.0f;
_resumeButton.Click += OnResumeButtonClicked;
_resumeButton.GotFocus += OnElementGotFocus;
@@ -147,8 +147,8 @@ private Panel CreatePausePanel(TextureAtlas atlas)
AnimatedButton quitButton = new AnimatedButton(atlas);
quitButton.Text = "QUIT";
quitButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- quitButton.Visual.X = -9.0f;
- quitButton.Visual.Y = -9.0f;
+ quitButton.X = -9.0f;
+ quitButton.Y = -9.0f;
quitButton.Click += OnQuitButtonClicked;
quitButton.GotFocus += OnElementGotFocus;
@@ -162,10 +162,10 @@ private Panel CreateGameOverPanel(TextureAtlas atlas)
{
Panel panel = new Panel();
panel.Anchor(Gum.Wireframe.Anchor.Center);
- panel.Visual.WidthUnits = DimensionUnitType.Absolute;
- panel.Visual.HeightUnits = DimensionUnitType.Absolute;
- panel.Visual.Width = 264.0f;
- panel.Visual.Height = 70.0f;
+ panel.WidthUnits = DimensionUnitType.Absolute;
+ panel.HeightUnits = DimensionUnitType.Absolute;
+ panel.Width = 264.0f;
+ panel.Height = 70.0f;
panel.IsVisible = false;
TextureRegion backgroundRegion = atlas.GetRegion("panel-background");
@@ -193,8 +193,8 @@ private Panel CreateGameOverPanel(TextureAtlas atlas)
_retryButton = new AnimatedButton(atlas);
_retryButton.Text = "RETRY";
_retryButton.Anchor(Gum.Wireframe.Anchor.BottomLeft);
- _retryButton.Visual.X = 9.0f;
- _retryButton.Visual.Y = -9.0f;
+ _retryButton.X = 9.0f;
+ _retryButton.Y = -9.0f;
_retryButton.Click += OnRetryButtonClicked;
_retryButton.GotFocus += OnElementGotFocus;
@@ -204,8 +204,8 @@ private Panel CreateGameOverPanel(TextureAtlas atlas)
AnimatedButton quitButton = new AnimatedButton(atlas);
quitButton.Text = "QUIT";
quitButton.Anchor(Gum.Wireframe.Anchor.BottomRight);
- quitButton.Visual.X = -9.0f;
- quitButton.Visual.Y = -9.0f;
+ quitButton.X = -9.0f;
+ quitButton.Y = -9.0f;
quitButton.Click += OnQuitButtonClicked;
quitButton.GotFocus += OnElementGotFocus;