add menuGUI
This commit is contained in:
commit
52743c1f89
14 changed files with 237 additions and 13 deletions
|
@ -11,7 +11,7 @@ with.
|
|||
<!--
|
||||
Modify this string to change the font that will be imported.
|
||||
-->
|
||||
<FontName>Handjet-ExtraLight.ttf</FontName>
|
||||
<FontName>RubikWetPaint-Regular.ttf</FontName>
|
||||
|
||||
<!--
|
||||
Size is a float value, measured in points. Modify this value to change
|
Binary file not shown.
|
@ -13,12 +13,12 @@
|
|||
|
||||
#---------------------------------- Content ---------------------------------#
|
||||
|
||||
#begin File.spritefont
|
||||
#begin ButtonFont.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:File.spritefont
|
||||
/build:ButtonFont.spritefont
|
||||
|
||||
#begin Font_25.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
|
@ -27,6 +27,13 @@
|
|||
/processorParam:TextureFormat=Compressed
|
||||
/build:Font_25.spritefont
|
||||
|
||||
#begin Font_30.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:Font_30.spritefont
|
||||
|
||||
#begin Font2.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
|
@ -34,6 +41,7 @@
|
|||
/processorParam:TextureFormat=Compressed
|
||||
/build:Font2.spritefont
|
||||
|
||||
|
||||
#begin MonstersAnimations.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
@ -46,6 +54,18 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:MonstersAnimations.png
|
||||
|
||||
#begin menuFon.jpg
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
/processorParam:ColorKeyEnabled=True
|
||||
/processorParam:GenerateMipmaps=False
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:menuFon.jpg
|
||||
|
||||
#begin PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
|
Binary file not shown.
BIN
DangerousD/Content/RubikWetPaint-Regular.ttf
Normal file
BIN
DangerousD/Content/RubikWetPaint-Regular.ttf
Normal file
Binary file not shown.
BIN
DangerousD/Content/menuFon.jpg
Normal file
BIN
DangerousD/Content/menuFon.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 197 KiB |
|
@ -26,7 +26,7 @@ public abstract class AbstractGui : IDrawableObject
|
|||
|
||||
public virtual void LoadContent()
|
||||
{
|
||||
Manager.LoadContent(AppManager.Instance.Content, "Font");
|
||||
Manager.LoadContent(AppManager.Instance.Content, "Font2");
|
||||
}
|
||||
|
||||
public virtual void Update(GameTime gameTime)
|
||||
|
|
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
|
||||
{
|
||||
private string username;
|
||||
private string password;
|
||||
|
||||
public string Username { get => username; }
|
||||
public string Password { get => password; }
|
||||
|
||||
protected override void CreateUI()
|
||||
{
|
||||
int screenWidth = AppManager.Instance.resolution.X;
|
||||
|
@ -34,7 +40,7 @@ namespace DangerousD.GameCore.GUI
|
|||
text = "NickName",
|
||||
scale = 0.16f,
|
||||
fontColor = Color.Gray,
|
||||
fontName = "font2",
|
||||
fontName = "Font2",
|
||||
textAligment = TextAligment.Left
|
||||
};
|
||||
loginTextBox.TextChanged += input => {
|
||||
|
@ -43,6 +49,13 @@ namespace DangerousD.GameCore.GUI
|
|||
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)
|
||||
{
|
||||
|
@ -59,6 +72,13 @@ namespace DangerousD.GameCore.GUI
|
|||
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"
|
||||
};
|
||||
logButton.LeftButtonPressed += () => {
|
||||
if (CheckUser())
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.Lobby);
|
||||
}
|
||||
};
|
||||
|
||||
Button regButton = new Button(Manager)
|
||||
|
@ -102,5 +125,9 @@ namespace DangerousD.GameCore.GUI
|
|||
{
|
||||
// TODO
|
||||
}
|
||||
private bool CheckUser()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using DangerousD.GameCore.Managers;
|
||||
using Microsoft.Xna.Framework;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using MonogameLibrary.UI.Elements;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace DangerousD.GameCore.GUI;
|
||||
|
||||
|
@ -10,29 +12,39 @@ internal class MenuGUI : AbstractGui
|
|||
{
|
||||
int wigth = AppManager.Instance.Window.ClientBounds.Width;
|
||||
int height = AppManager.Instance.Window.ClientBounds.Height;
|
||||
var butSingle = new Button(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 130, 300, 50), text = "Singleplayer", fontName = "File" };
|
||||
var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "menuFon" };
|
||||
Elements.Add(menuBackground);
|
||||
menuBackground.LoadTexture(AppManager.Instance.Content);
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 - 60, 60, 50, 50), text = "Dangerous", mainColor = Color.Transparent, scale = 0.7f, fontName = "Font2", fontColor = Color.White });
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2 + 250, 90, 50, 50), text = "D", mainColor = Color.Transparent, scale = 1.2f, fontName = "Font2", fontColor = Color.White });
|
||||
var butSingle = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 130, 300, 50), text = "Singleplayer", fontName = "ButtonFont" };
|
||||
Elements.Add(butSingle);
|
||||
butSingle.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.Game);
|
||||
};
|
||||
var butMulti = new Button(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 190, 300, 50), text = "Multiplayer", fontName = "File" };
|
||||
var butMulti = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 190, 300, 50), text = "Multiplayer", fontName = "ButtonFont" };
|
||||
Elements.Add(butMulti);
|
||||
butMulti.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.Login);
|
||||
};
|
||||
var butOption = new Button(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 250, 300, 50), text = "Option", fontName = "File" };
|
||||
var butOption = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 250, 300, 50), text = "Option", fontName = "ButtonFont" };
|
||||
Elements.Add(butOption);
|
||||
butOption.LeftButtonPressed += () =>
|
||||
{
|
||||
// открытие настроек
|
||||
};
|
||||
var butExit = new Button(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 310, 300, 50), text = "Exit", fontName = "File" };
|
||||
var butExit = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 310, 300, 50), text = "Exit", fontName = "ButtonFont" };
|
||||
Elements.Add(butExit);
|
||||
butExit.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.Exit();
|
||||
};
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
base.Update(gameTime);
|
||||
}
|
||||
}
|
|
@ -39,6 +39,7 @@ namespace DangerousD.GameCore
|
|||
gameState = GameState.Menu;
|
||||
MenuGUI = new MenuGUI();
|
||||
LoginGUI = new LoginGUI();
|
||||
LobbyGUI = new LobbyGUI();
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
|
@ -46,6 +47,7 @@ namespace DangerousD.GameCore
|
|||
AnimationBuilder.LoadAnimations();
|
||||
MenuGUI.Initialize(GraphicsDevice);
|
||||
LoginGUI.Initialize(GraphicsDevice);
|
||||
LobbyGUI.Initialize(GraphicsDevice);
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
|
@ -54,6 +56,7 @@ namespace DangerousD.GameCore
|
|||
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
MenuGUI.LoadContent();
|
||||
LoginGUI.LoadContent();
|
||||
LobbyGUI.LoadContent();
|
||||
GameObject.debugTexture = new Texture2D(GraphicsDevice, 1, 1);
|
||||
GameObject.debugTexture.SetData<Color>(new Color[] { new Color(1, 0,0,0.25f) });
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace MonogameLibrary.UI.Base
|
|||
protected Texture2D texture;
|
||||
protected int layerIndex;
|
||||
protected UIManager Manager;
|
||||
protected string textureName;
|
||||
public string textureName;
|
||||
public Rectangle rectangle = new Rectangle(0, 0, 10, 10);
|
||||
public Color mainColor = Color.White;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace MonogameLibrary.UI.Elements
|
|||
{
|
||||
}
|
||||
|
||||
public bool InteractUpdate(MouseState mouseState, MouseState prevmouseState)
|
||||
public virtual bool InteractUpdate(MouseState mouseState, MouseState prevmouseState)
|
||||
{
|
||||
if (rectangle.Intersects(new Rectangle(mouseState.Position, Point.Zero)))
|
||||
{
|
||||
|
@ -61,11 +61,19 @@ namespace MonogameLibrary.UI.Elements
|
|||
public override void Draw(SpriteBatch _spriteBatch)
|
||||
{
|
||||
if (hoverState == HoverState.None)
|
||||
{
|
||||
_spriteBatch.Draw(texture, rectangle, Color.White);
|
||||
}
|
||||
else if (hoverState == HoverState.Hovering)
|
||||
{
|
||||
_spriteBatch.Draw(texture, rectangle, new Color(211, 211, 211));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
_spriteBatch.Draw(texture, rectangle, new Color(112, 128, 144));
|
||||
}
|
||||
|
||||
DrawText(_spriteBatch);
|
||||
}
|
||||
}
|
||||
|
|
37
MonogameLibrary/UI/Elements/ButtonText.cs
Normal file
37
MonogameLibrary/UI/Elements/ButtonText.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using MonogameLibrary.UI.Enums;
|
||||
using MonogameLibrary.UI.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using static MonogameLibrary.UI.Elements.Button;
|
||||
|
||||
namespace MonogameLibrary.UI.Elements
|
||||
{
|
||||
public class ButtonText : Button
|
||||
{
|
||||
public ButtonText(UIManager manager, int layerIndex = 0) : base(manager, layerIndex)
|
||||
{
|
||||
}
|
||||
public override void Draw(SpriteBatch _spriteBatch)
|
||||
{
|
||||
if (hoverState == HoverState.None)
|
||||
{
|
||||
fontColor = Color.White;
|
||||
}
|
||||
else if (hoverState == HoverState.Hovering)
|
||||
{
|
||||
fontColor = new Color(211, 211, 211);
|
||||
}
|
||||
else
|
||||
{
|
||||
fontColor = new Color(112, 128, 144);
|
||||
}
|
||||
|
||||
DrawText(_spriteBatch);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue