gui
This commit is contained in:
parent
5d1800c90e
commit
144a6fdfe7
12 changed files with 112 additions and 13 deletions
|
@ -20,6 +20,18 @@
|
|||
/processorParam:TextureFormat=Compressed
|
||||
/build:ButtonFont.spritefont
|
||||
|
||||
#begin deathBackground.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:deathBackground.jpg
|
||||
|
||||
#begin Font_25.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
|
@ -101,6 +113,30 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png
|
||||
|
||||
#begin textboxbackground.png
|
||||
/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:textboxbackground.png
|
||||
|
||||
#begin textboxbackground2.png
|
||||
/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:textboxbackground2.png
|
||||
|
||||
#begin wall.jpg
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
|
BIN
DangerousD/Content/deathBackground.jpg
Normal file
BIN
DangerousD/Content/deathBackground.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 396 KiB |
BIN
DangerousD/Content/textboxbackground.png
Normal file
BIN
DangerousD/Content/textboxbackground.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
DangerousD/Content/textboxbackground2.png
Normal file
BIN
DangerousD/Content/textboxbackground2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
33
DangerousD/GameCore/GUI/DeathGUI.cs
Normal file
33
DangerousD/GameCore/GUI/DeathGUI.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using DangerousD.GameCore.Managers;
|
||||
using Microsoft.Xna.Framework;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using MonogameLibrary.UI.Elements;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace DangerousD.GameCore.GUI;
|
||||
|
||||
internal class DeathGUI : AbstractGui
|
||||
{
|
||||
protected override void CreateUI()
|
||||
{
|
||||
int wigth = AppManager.Instance.Window.ClientBounds.Width;
|
||||
int height = AppManager.Instance.Window.ClientBounds.Height;
|
||||
var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "deathBackground" };
|
||||
Elements.Add(menuBackground);
|
||||
menuBackground.LoadTexture(AppManager.Instance.Content);
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2, 120, 50, 50), text = "You death", mainColor = Color.Transparent, scale = 0.5f, fontName = "ButtonFont", fontColor = Color.White });
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle((wigth - 50) / 2, 190, 50, 50), text = $"Score = {0}", mainColor = Color.Transparent, scale = 0.5f, fontName = "ButtonFont", fontColor = Color.White });
|
||||
var butMenu = new ButtonText(Manager) { rectangle = new Rectangle((wigth - 300) / 2, 260, 300, 50), text = "Back to menu", fontName = "ButtonFont" };
|
||||
Elements.Add(butMenu);
|
||||
butMenu.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.Menu);
|
||||
};
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
base.Update(gameTime);
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ using System.Threading.Tasks;
|
|||
using DangerousD.GameCore.Managers;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using System.Diagnostics;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace DangerousD.GameCore.GUI
|
||||
{
|
||||
|
@ -29,8 +30,11 @@ namespace DangerousD.GameCore.GUI
|
|||
lobbyBackground.LoadTexture(AppManager.Instance.Content);
|
||||
|
||||
// CheckBoxs
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle(screenWidth / 30 * 2, screenHeight / 30 * 5,
|
||||
screenWidth / 30 * 26, screenHeight / 15 * 10) });
|
||||
var lobby = new Label(Manager) { rectangle = new Rectangle(screenWidth / 30 * 2, screenHeight / 30 * 5,
|
||||
screenWidth / 30 * 26, screenHeight / 15 * 10), textureName = "textboxbackground2" };
|
||||
Elements.Add(lobby);
|
||||
lobby.LoadTexture(AppManager.Instance.Content);
|
||||
|
||||
|
||||
// Buttons
|
||||
{
|
||||
|
@ -101,11 +105,13 @@ namespace DangerousD.GameCore.GUI
|
|||
screenWidth / 30 * 10, screenHeight / 30 * 3),
|
||||
text = "ip",
|
||||
scale = 0.16f,
|
||||
fontColor = Color.Gray,
|
||||
fontColor = Color.White,
|
||||
fontName = "font2",
|
||||
textAligment = TextAligment.Left
|
||||
textAligment = TextAligment.Left,
|
||||
textureName = "textboxbackground"
|
||||
|
||||
};
|
||||
searchBarTextBox.LoadTexture(AppManager.Instance.Content);
|
||||
searchBarTextBox.TextChanged += input => {
|
||||
if (searchBarTextBox.fontColor == Color.Gray)
|
||||
{
|
||||
|
|
|
@ -49,8 +49,11 @@ namespace DangerousD.GameCore.GUI
|
|||
scale = 0.16f,
|
||||
fontColor = Color.Gray,
|
||||
fontName = "Font2",
|
||||
textAligment = TextAligment.Left
|
||||
textAligment = TextAligment.Left,
|
||||
textureName = "textboxbackground"
|
||||
|
||||
};
|
||||
loginTextBox.LoadTexture(AppManager.Instance.Content);
|
||||
loginTextBox.TextChanged += input => {
|
||||
if (loginTextBox.fontColor == Color.Gray)
|
||||
{
|
||||
|
@ -72,8 +75,10 @@ namespace DangerousD.GameCore.GUI
|
|||
scale = 0.16f,
|
||||
fontColor = Color.Gray,
|
||||
fontName = "font2",
|
||||
textAligment = TextAligment.Left
|
||||
textAligment = TextAligment.Left,
|
||||
textureName = "textboxbackground"
|
||||
};
|
||||
passwordTextBox.LoadTexture(AppManager.Instance.Content);
|
||||
passwordTextBox.TextChanged += input => {
|
||||
if (passwordTextBox.fontColor == Color.Gray)
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using MonogameLibrary.UI.Base;
|
||||
using MonogameLibrary.UI.Elements;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
|
@ -9,10 +10,9 @@ namespace DangerousD.GameCore.GUI;
|
|||
|
||||
internal class MenuGUI : AbstractGui
|
||||
{
|
||||
int selected = 0;
|
||||
protected override void CreateUI()
|
||||
{
|
||||
|
||||
|
||||
int wigth = AppManager.Instance.Window.ClientBounds.Width;
|
||||
int height = AppManager.Instance.Window.ClientBounds.Height;
|
||||
var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "menuFon" };
|
||||
|
|
|
@ -10,6 +10,7 @@ using System.Runtime.InteropServices;
|
|||
namespace DangerousD.GameCore
|
||||
{
|
||||
public enum ScopeState { Up, Middle, Down }
|
||||
public enum ControlsState { Gamepad, Keyboard, Mouse }
|
||||
class InputManager
|
||||
{
|
||||
public delegate void Delegat();
|
||||
|
@ -19,21 +20,27 @@ namespace DangerousD.GameCore
|
|||
|
||||
Vector2 vectorMovementDirection;
|
||||
ScopeState scopeState; // Положение оружия. Up, Middle, Down.
|
||||
ControlsState controlsState;
|
||||
|
||||
private bool isJumpDown; // Блокирует физическое нажатие прыжка и спуска
|
||||
private bool isShoot;
|
||||
|
||||
public Vector2 VectorMovementDirection { get => vectorMovementDirection; }
|
||||
public ScopeState ScopeState { get => scopeState; }
|
||||
public string currentControlsState = "";
|
||||
|
||||
public InputManager()
|
||||
{
|
||||
this.isJumpDown = false;
|
||||
this.isShoot = false;
|
||||
scopeState = ScopeState.Middle;
|
||||
controlsState= ControlsState.Mouse;
|
||||
vectorMovementDirection = new Vector2(0, 0);
|
||||
}
|
||||
|
||||
public void SetState(ControlsState controlsStates)
|
||||
{
|
||||
currentControlsState = controlsStates.ToString();
|
||||
}
|
||||
public void Update()
|
||||
{
|
||||
// Работа с GamePad
|
||||
|
@ -86,6 +93,7 @@ namespace DangerousD.GameCore
|
|||
{
|
||||
isShoot = false;
|
||||
}
|
||||
SetState(ControlsState.Gamepad);
|
||||
}
|
||||
|
||||
// Работа с KeyBoard
|
||||
|
|
|
@ -12,7 +12,7 @@ using MonogameLibrary.UI.Base;
|
|||
|
||||
namespace DangerousD.GameCore
|
||||
{
|
||||
public enum GameState { Menu, Options, Lobby, Game, Login }
|
||||
public enum GameState { Menu, Options, Lobby, Game, Login, Death }
|
||||
public class AppManager : Game
|
||||
{
|
||||
public static AppManager Instance { get; private set; }
|
||||
|
@ -25,6 +25,7 @@ namespace DangerousD.GameCore
|
|||
IDrawableObject OptionsGUI;
|
||||
IDrawableObject LoginGUI;
|
||||
IDrawableObject LobbyGUI;
|
||||
IDrawableObject DeathGUI;
|
||||
|
||||
public GameManager GameManager { get; private set; } = new GameManager();
|
||||
public AnimationBuilder AnimationBuilder { get; private set; } = new AnimationBuilder();
|
||||
|
@ -40,11 +41,12 @@ namespace DangerousD.GameCore
|
|||
|
||||
_graphics.PreferredBackBufferWidth = resolution.X;
|
||||
_graphics.PreferredBackBufferHeight = resolution.Y;
|
||||
_graphics.IsFullScreen = true;
|
||||
//_graphics.IsFullScreen = true;
|
||||
gameState = GameState.Menu;
|
||||
MenuGUI = new MenuGUI();
|
||||
LoginGUI = new LoginGUI();
|
||||
LobbyGUI = new LobbyGUI();
|
||||
DeathGUI = new DeathGUI();
|
||||
UIManager.resolution = resolution;
|
||||
UIManager.resolutionInGame = inGameResolution;
|
||||
}
|
||||
|
@ -55,6 +57,7 @@ namespace DangerousD.GameCore
|
|||
MenuGUI.Initialize(GraphicsDevice);
|
||||
LoginGUI.Initialize(GraphicsDevice);
|
||||
LobbyGUI.Initialize(GraphicsDevice);
|
||||
DeathGUI.Initialize(GraphicsDevice);
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
|
@ -64,6 +67,7 @@ namespace DangerousD.GameCore
|
|||
MenuGUI.LoadContent();
|
||||
LoginGUI.LoadContent();
|
||||
LobbyGUI.LoadContent();
|
||||
DeathGUI.LoadContent();
|
||||
GameObject.debugTexture = new Texture2D(GraphicsDevice, 1, 1);
|
||||
GameObject.debugTexture.SetData<Color>(new Color[] { new Color(1, 0,0,0.25f) });
|
||||
renderTarget = new RenderTarget2D(GraphicsDevice, inGameResolution.X, inGameResolution.Y);
|
||||
|
@ -88,6 +92,9 @@ namespace DangerousD.GameCore
|
|||
case GameState.Lobby:
|
||||
LobbyGUI.Update(gameTime);
|
||||
break;
|
||||
case GameState.Death:
|
||||
DeathGUI.Update(gameTime);
|
||||
break;
|
||||
case GameState.Game:
|
||||
GameManager.Update(gameTime);
|
||||
break;
|
||||
|
@ -117,6 +124,9 @@ namespace DangerousD.GameCore
|
|||
case GameState.Lobby:
|
||||
LobbyGUI.Draw(_spriteBatch);
|
||||
break;
|
||||
case GameState.Death:
|
||||
DeathGUI.Draw(_spriteBatch);
|
||||
break;
|
||||
case GameState.Game:
|
||||
_spriteBatch.Begin(SpriteSortMode.Deferred,null,SamplerState.PointClamp);
|
||||
GameManager.Draw(_spriteBatch);
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace MonogameLibrary.UI.Base
|
|||
static KeyboardState keyboardState;
|
||||
public static Point resolutionInGame, resolution;
|
||||
|
||||
|
||||
public void LoadContent(ContentManager content, string font)
|
||||
{
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue