Merge branch 'ui' of https://github.com/progtime-net/DangerousD into ui
This commit is contained in:
commit
01e60f9da4
3 changed files with 150 additions and 2 deletions
117
DangerousD/GameCore/GUI/LobbyGUI.cs
Normal file
117
DangerousD/GameCore/GUI/LobbyGUI.cs
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using MonogameLibrary.UI.Elements;
|
||||||
|
using MonogameLibrary.UI.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DangerousD.GameCore.GUI
|
||||||
|
{
|
||||||
|
class LobbyGUI : AbstractGui
|
||||||
|
{
|
||||||
|
public LobbyGUI()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
protected override void CreateUI()
|
||||||
|
{
|
||||||
|
int screenWidth = AppManager.Instance.resolution.X;
|
||||||
|
int screenHeight = AppManager.Instance.resolution.Y;
|
||||||
|
|
||||||
|
// CheckBoxs
|
||||||
|
Elements.Add(new Label(Manager) { rectangle = new Rectangle(screenWidth / 30 * 2, screenHeight / 30 * 5,
|
||||||
|
screenWidth / 30 * 26, screenHeight / 15 * 10) });
|
||||||
|
|
||||||
|
// Buttons
|
||||||
|
{
|
||||||
|
Button backButton = new Button(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(screenWidth / 30, screenHeight / 30, 60, 50),
|
||||||
|
text = "<-",
|
||||||
|
scale = 0.3f,
|
||||||
|
fontColor = Color.Black,
|
||||||
|
fontName = "font2"
|
||||||
|
};
|
||||||
|
backButton.LeftButtonPressed += () => {
|
||||||
|
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||||
|
};
|
||||||
|
|
||||||
|
Button hostButton = new Button(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(screenWidth / 30, screenHeight / 15 * 13, 120, 50),
|
||||||
|
text = "Host",
|
||||||
|
scale = 0.2f,
|
||||||
|
fontColor = Color.Black,
|
||||||
|
fontName = "font2"
|
||||||
|
};
|
||||||
|
hostButton.LeftButtonPressed += () => {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
Button refreshButton = new Button(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(screenWidth / 30 * 6, screenHeight / 15 * 13, 120, 50),
|
||||||
|
text = "Refresh",
|
||||||
|
scale = 0.2f,
|
||||||
|
fontColor = Color.Black,
|
||||||
|
fontName = "font2"
|
||||||
|
};
|
||||||
|
refreshButton.LeftButtonPressed += () => {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
Button joinSelectedButton = new Button(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(screenWidth / 30 * 25, screenHeight / 15 * 13, 120, 50),
|
||||||
|
text = "Join",
|
||||||
|
scale = 0.2f,
|
||||||
|
fontColor = Color.Black,
|
||||||
|
fontName = "font2"
|
||||||
|
};
|
||||||
|
joinSelectedButton.LeftButtonPressed += () => {
|
||||||
|
|
||||||
|
};
|
||||||
|
Button joinByIpButton = new Button(Manager)
|
||||||
|
{
|
||||||
|
rectangle = new Rectangle(screenWidth / 30 * 25, screenHeight / 30, 120, 50),
|
||||||
|
text = "JoinByIp",
|
||||||
|
scale = 0.2f,
|
||||||
|
fontColor = Color.Black,
|
||||||
|
fontName = "font2"
|
||||||
|
};
|
||||||
|
joinByIpButton.LeftButtonPressed += () => {
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// SearchBar
|
||||||
|
{
|
||||||
|
TextBox searchBarTextBox = new TextBox(Manager) {
|
||||||
|
rectangle = new Rectangle(screenWidth / 30 * 14, screenHeight / 30,
|
||||||
|
screenWidth / 30 * 10, screenHeight / 30 * 3),
|
||||||
|
text = "ip",
|
||||||
|
scale = 0.16f,
|
||||||
|
fontColor = Color.Gray,
|
||||||
|
fontName = "font2",
|
||||||
|
textAligment = TextAligment.Left
|
||||||
|
|
||||||
|
};
|
||||||
|
searchBarTextBox.TextChanged += input => {
|
||||||
|
if (searchBarTextBox.fontColor == Color.Gray)
|
||||||
|
{
|
||||||
|
searchBarTextBox.text = ""; searchBarTextBox.fontColor = Color.Black;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
searchBarTextBox.StopChanging += input => {
|
||||||
|
if (input.Length == 0)
|
||||||
|
{
|
||||||
|
searchBarTextBox.fontColor = Color.Gray;
|
||||||
|
searchBarTextBox.text = "ip";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,6 +12,12 @@ namespace DangerousD.GameCore.GUI
|
||||||
{
|
{
|
||||||
class LoginGUI : AbstractGui
|
class LoginGUI : AbstractGui
|
||||||
{
|
{
|
||||||
|
private string username;
|
||||||
|
private string password;
|
||||||
|
|
||||||
|
public string Username { get => username; }
|
||||||
|
public string Password { get => password; }
|
||||||
|
|
||||||
protected override void CreateUI()
|
protected override void CreateUI()
|
||||||
{
|
{
|
||||||
int screenWidth = AppManager.Instance.resolution.X;
|
int screenWidth = AppManager.Instance.resolution.X;
|
||||||
|
@ -43,6 +49,13 @@ namespace DangerousD.GameCore.GUI
|
||||||
loginTextBox.text = ""; loginTextBox.fontColor = Color.Black;
|
loginTextBox.text = ""; loginTextBox.fontColor = Color.Black;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
loginTextBox.StopChanging += input => {
|
||||||
|
if (input.Length == 0)
|
||||||
|
{
|
||||||
|
loginTextBox.text = "NickName";
|
||||||
|
loginTextBox.fontColor = Color.Gray;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
TextBox passwordTextBox = new TextBox(Manager)
|
TextBox passwordTextBox = new TextBox(Manager)
|
||||||
{
|
{
|
||||||
|
@ -59,6 +72,13 @@ namespace DangerousD.GameCore.GUI
|
||||||
passwordTextBox.text = ""; passwordTextBox.fontColor = Color.Black;
|
passwordTextBox.text = ""; passwordTextBox.fontColor = Color.Black;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
passwordTextBox.StopChanging += input => {
|
||||||
|
if (input.Length == 0)
|
||||||
|
{
|
||||||
|
passwordTextBox.text = "Password";
|
||||||
|
passwordTextBox.fontColor = Color.Gray;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Кнопки
|
// Кнопки
|
||||||
|
@ -71,7 +91,10 @@ namespace DangerousD.GameCore.GUI
|
||||||
fontName = "font2"
|
fontName = "font2"
|
||||||
};
|
};
|
||||||
logButton.LeftButtonPressed += () => {
|
logButton.LeftButtonPressed += () => {
|
||||||
AppManager.Instance.ChangeGameState(GameState.Lobby);
|
if (CheckUser())
|
||||||
|
{
|
||||||
|
AppManager.Instance.ChangeGameState(GameState.Lobby);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Button regButton = new Button(Manager)
|
Button regButton = new Button(Manager)
|
||||||
|
@ -102,5 +125,9 @@ namespace DangerousD.GameCore.GUI
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
private bool CheckUser()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,11 @@ namespace DangerousD.GameCore
|
||||||
|
|
||||||
resolution = new Point(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight);
|
resolution = new Point(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight);
|
||||||
GameManager = new GameManager();
|
GameManager = new GameManager();
|
||||||
gameState = GameState.Menu;
|
|
||||||
|
gameState = GameState.Lobby;
|
||||||
MenuGUI = new MenuGUI();
|
MenuGUI = new MenuGUI();
|
||||||
LoginGUI = new LoginGUI();
|
LoginGUI = new LoginGUI();
|
||||||
|
LobbyGUI = new LobbyGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Initialize()
|
protected override void Initialize()
|
||||||
|
@ -45,6 +47,7 @@ namespace DangerousD.GameCore
|
||||||
AnimationBuilder.LoadAnimations();
|
AnimationBuilder.LoadAnimations();
|
||||||
MenuGUI.Initialize(GraphicsDevice);
|
MenuGUI.Initialize(GraphicsDevice);
|
||||||
LoginGUI.Initialize(GraphicsDevice);
|
LoginGUI.Initialize(GraphicsDevice);
|
||||||
|
LobbyGUI.Initialize(GraphicsDevice);
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +56,7 @@ namespace DangerousD.GameCore
|
||||||
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||||
MenuGUI.LoadContent();
|
MenuGUI.LoadContent();
|
||||||
LoginGUI.LoadContent();
|
LoginGUI.LoadContent();
|
||||||
|
LobbyGUI.LoadContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(GameTime gameTime)
|
protected override void Update(GameTime gameTime)
|
||||||
|
|
Loading…
Add table
Reference in a new issue