-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec5df93
commit 8a2a31d
Showing
10 changed files
with
241 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "submodules/myra"] | ||
path = submodules/myra | ||
url = https://github.com/rds1983/Myra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using Blocktest.UI; | ||
using Myra; | ||
using Myra.Graphics2D; | ||
using Myra.Graphics2D.Brushes; | ||
using Myra.Graphics2D.UI; | ||
|
||
namespace Blocktest.Scenes; | ||
|
||
|
||
public class MainMenuScene : IScene { | ||
private Desktop _desktop; | ||
private VerticalStackPanel _mainMenu; | ||
|
||
public MainMenuScene(BlocktestGame game) { | ||
_mainMenu = new VerticalStackPanel { | ||
HorizontalAlignment = HorizontalAlignment.Center, | ||
VerticalAlignment = VerticalAlignment.Center, | ||
BorderThickness = new Thickness(1), | ||
Background = new SolidBrush("#404040FF"), | ||
Border = new SolidBrush("#1BA1E2FF") | ||
}; | ||
|
||
var titleLabel = new Label { | ||
Text = "Blocktest", | ||
HorizontalAlignment = HorizontalAlignment.Center, | ||
VerticalAlignment = VerticalAlignment.Center, | ||
Padding = new Thickness(8) | ||
}; | ||
_mainMenu.Widgets.Add(titleLabel); | ||
|
||
var newGameButton = new TextButton { | ||
Text = "New Game", | ||
HorizontalAlignment = HorizontalAlignment.Stretch, | ||
Padding = new Thickness(5) | ||
}; | ||
newGameButton.Click += (_, _) => { | ||
game.SetScene(new GameScene(game, false, null)); | ||
}; | ||
_mainMenu.Widgets.Add(newGameButton); | ||
|
||
var connectButton = new TextButton { | ||
Text = "Connect", | ||
HorizontalAlignment = HorizontalAlignment.Stretch, | ||
Padding = new Thickness(5) | ||
}; | ||
connectButton.Click += (_, _) => { | ||
new ConnectionWindow(game).ShowModal(_desktop); | ||
}; | ||
_mainMenu.Widgets.Add(connectButton); | ||
|
||
var exitButton = new TextButton { | ||
Text = "Exit", | ||
HorizontalAlignment = HorizontalAlignment.Stretch, | ||
Padding = new Thickness(5) | ||
}; | ||
exitButton.Click += (_, _) => { | ||
game.Exit(); | ||
}; | ||
_mainMenu.Widgets.Add(exitButton); | ||
|
||
_desktop = new Desktop { Root = _mainMenu }; | ||
} | ||
|
||
public void Update(GameTime gameTime) { } | ||
|
||
public void Draw(GameTime gameTime, GraphicsDevice graphicsDevice) { | ||
graphicsDevice.Clear(Color.CadetBlue); | ||
|
||
_desktop.Render(); | ||
} | ||
|
||
public void EndScene() { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Blocktest.Scenes; | ||
using Myra.Graphics2D; | ||
using Myra.Graphics2D.UI; | ||
#pragma warning disable CS0618 // Type or member is obsolete, I don't care about this warning since it works fine | ||
|
||
namespace Blocktest.UI; | ||
|
||
public class ConnectionWindow : Window { | ||
public ConnectionWindow(BlocktestGame game) { | ||
var windowGrid = new Grid { | ||
RowSpacing = 8, | ||
ColumnSpacing = 8 | ||
}; | ||
|
||
var label1 = new Label { | ||
Text = "Enter IP:", | ||
Padding = new Thickness(5), | ||
GridColumn = 0, | ||
GridRow = 0 | ||
}; | ||
windowGrid.Widgets.Add(label1); | ||
|
||
var textBox = new TextBox { | ||
Text = "127.0.0.1", | ||
Padding = new Thickness(5), | ||
GridColumn = 1, | ||
GridRow = 0 | ||
}; | ||
windowGrid.Widgets.Add(textBox); | ||
|
||
var button = new TextButton { | ||
Text = "Connect", | ||
Padding = new Thickness(5), | ||
GridColumn = 0, | ||
GridRow = 1, | ||
GridColumnSpan = 2, | ||
HorizontalAlignment = HorizontalAlignment.Stretch | ||
}; | ||
|
||
button.Click += (_, _) => { | ||
game.SetScene(new GameScene(game, true, textBox.Text)); | ||
}; | ||
windowGrid.Widgets.Add(button); | ||
|
||
Content = windowGrid; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Myra.Graphics2D.UI; | ||
|
||
namespace Blocktest.UI; | ||
|
||
public sealed class DialogueWindow : Window { | ||
public DialogueWindow(string title, string text) { | ||
var label1 = new Label { | ||
Text = text | ||
}; | ||
|
||
|
||
Title = title; | ||
Content = label1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters