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
|
/processorParam:TextureFormat=Compressed
|
||||||
/build:ButtonFont.spritefont
|
/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
|
#begin Font_25.spritefont
|
||||||
/importer:FontDescriptionImporter
|
/importer:FontDescriptionImporter
|
||||||
/processor:FontDescriptionProcessor
|
/processor:FontDescriptionProcessor
|
||||||
|
@ -101,6 +113,30 @@
|
||||||
/processorParam:TextureFormat=Color
|
/processorParam:TextureFormat=Color
|
||||||
/build:PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png
|
/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
|
#begin wall.jpg
|
||||||
/importer:TextureImporter
|
/importer:TextureImporter
|
||||||
/processor:TextureProcessor
|
/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 DangerousD.GameCore.Managers;
|
||||||
using MonogameLibrary.UI.Base;
|
using MonogameLibrary.UI.Base;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace DangerousD.GameCore.GUI
|
namespace DangerousD.GameCore.GUI
|
||||||
{
|
{
|
||||||
|
@ -29,8 +30,11 @@ namespace DangerousD.GameCore.GUI
|
||||||
lobbyBackground.LoadTexture(AppManager.Instance.Content);
|
lobbyBackground.LoadTexture(AppManager.Instance.Content);
|
||||||
|
|
||||||
// CheckBoxs
|
// CheckBoxs
|
||||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle(screenWidth / 30 * 2, screenHeight / 30 * 5,
|
var lobby = new Label(Manager) { rectangle = new Rectangle(screenWidth / 30 * 2, screenHeight / 30 * 5,
|
||||||
screenWidth / 30 * 26, screenHeight / 15 * 10) });
|
screenWidth / 30 * 26, screenHeight / 15 * 10), textureName = "textboxbackground2" };
|
||||||
|
Elements.Add(lobby);
|
||||||
|
lobby.LoadTexture(AppManager.Instance.Content);
|
||||||
|
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
{
|
{
|
||||||
|
@ -101,11 +105,13 @@ namespace DangerousD.GameCore.GUI
|
||||||
screenWidth / 30 * 10, screenHeight / 30 * 3),
|
screenWidth / 30 * 10, screenHeight / 30 * 3),
|
||||||
text = "ip",
|
text = "ip",
|
||||||
scale = 0.16f,
|
scale = 0.16f,
|
||||||
fontColor = Color.Gray,
|
fontColor = Color.White,
|
||||||
fontName = "font2",
|
fontName = "font2",
|
||||||
textAligment = TextAligment.Left
|
textAligment = TextAligment.Left,
|
||||||
|
textureName = "textboxbackground"
|
||||||
|
|
||||||
};
|
};
|
||||||
|
searchBarTextBox.LoadTexture(AppManager.Instance.Content);
|
||||||
searchBarTextBox.TextChanged += input => {
|
searchBarTextBox.TextChanged += input => {
|
||||||
if (searchBarTextBox.fontColor == Color.Gray)
|
if (searchBarTextBox.fontColor == Color.Gray)
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,8 +49,11 @@ namespace DangerousD.GameCore.GUI
|
||||||
scale = 0.16f,
|
scale = 0.16f,
|
||||||
fontColor = Color.Gray,
|
fontColor = Color.Gray,
|
||||||
fontName = "Font2",
|
fontName = "Font2",
|
||||||
textAligment = TextAligment.Left
|
textAligment = TextAligment.Left,
|
||||||
|
textureName = "textboxbackground"
|
||||||
|
|
||||||
};
|
};
|
||||||
|
loginTextBox.LoadTexture(AppManager.Instance.Content);
|
||||||
loginTextBox.TextChanged += input => {
|
loginTextBox.TextChanged += input => {
|
||||||
if (loginTextBox.fontColor == Color.Gray)
|
if (loginTextBox.fontColor == Color.Gray)
|
||||||
{
|
{
|
||||||
|
@ -72,8 +75,10 @@ namespace DangerousD.GameCore.GUI
|
||||||
scale = 0.16f,
|
scale = 0.16f,
|
||||||
fontColor = Color.Gray,
|
fontColor = Color.Gray,
|
||||||
fontName = "font2",
|
fontName = "font2",
|
||||||
textAligment = TextAligment.Left
|
textAligment = TextAligment.Left,
|
||||||
|
textureName = "textboxbackground"
|
||||||
};
|
};
|
||||||
|
passwordTextBox.LoadTexture(AppManager.Instance.Content);
|
||||||
passwordTextBox.TextChanged += input => {
|
passwordTextBox.TextChanged += input => {
|
||||||
if (passwordTextBox.fontColor == Color.Gray)
|
if (passwordTextBox.fontColor == Color.Gray)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using MonogameLibrary.UI.Base;
|
using MonogameLibrary.UI.Base;
|
||||||
using MonogameLibrary.UI.Elements;
|
using MonogameLibrary.UI.Elements;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
@ -9,10 +10,9 @@ namespace DangerousD.GameCore.GUI;
|
||||||
|
|
||||||
internal class MenuGUI : AbstractGui
|
internal class MenuGUI : AbstractGui
|
||||||
{
|
{
|
||||||
|
int selected = 0;
|
||||||
protected override void CreateUI()
|
protected override void CreateUI()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
int wigth = AppManager.Instance.Window.ClientBounds.Width;
|
int wigth = AppManager.Instance.Window.ClientBounds.Width;
|
||||||
int height = AppManager.Instance.Window.ClientBounds.Height;
|
int height = AppManager.Instance.Window.ClientBounds.Height;
|
||||||
var menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, wigth, height), textureName = "menuFon" };
|
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
|
namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
public enum ScopeState { Up, Middle, Down }
|
public enum ScopeState { Up, Middle, Down }
|
||||||
|
public enum ControlsState { Gamepad, Keyboard, Mouse }
|
||||||
class InputManager
|
class InputManager
|
||||||
{
|
{
|
||||||
public delegate void Delegat();
|
public delegate void Delegat();
|
||||||
|
@ -19,26 +20,32 @@ namespace DangerousD.GameCore
|
||||||
|
|
||||||
Vector2 vectorMovementDirection;
|
Vector2 vectorMovementDirection;
|
||||||
ScopeState scopeState; // Положение оружия. Up, Middle, Down.
|
ScopeState scopeState; // Положение оружия. Up, Middle, Down.
|
||||||
|
ControlsState controlsState;
|
||||||
|
|
||||||
private bool isJumpDown; // Блокирует физическое нажатие прыжка и спуска
|
private bool isJumpDown; // Блокирует физическое нажатие прыжка и спуска
|
||||||
private bool isShoot;
|
private bool isShoot;
|
||||||
|
|
||||||
public Vector2 VectorMovementDirection { get => vectorMovementDirection; }
|
public Vector2 VectorMovementDirection { get => vectorMovementDirection; }
|
||||||
public ScopeState ScopeState { get => scopeState; }
|
public ScopeState ScopeState { get => scopeState; }
|
||||||
|
public string currentControlsState = "";
|
||||||
|
|
||||||
public InputManager()
|
public InputManager()
|
||||||
{
|
{
|
||||||
this.isJumpDown = false;
|
this.isJumpDown = false;
|
||||||
this.isShoot = false;
|
this.isShoot = false;
|
||||||
scopeState = ScopeState.Middle;
|
scopeState = ScopeState.Middle;
|
||||||
|
controlsState= ControlsState.Mouse;
|
||||||
vectorMovementDirection = new Vector2(0, 0);
|
vectorMovementDirection = new Vector2(0, 0);
|
||||||
}
|
}
|
||||||
|
public void SetState(ControlsState controlsStates)
|
||||||
|
{
|
||||||
|
currentControlsState = controlsStates.ToString();
|
||||||
|
}
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
// Работа с GamePad
|
// Работа с GamePad
|
||||||
if (GamePad.GetState(0).IsConnected)
|
if (GamePad.GetState(0).IsConnected)
|
||||||
{
|
{
|
||||||
// Обработка гейм-пада. Задает Vector2 vectorMovementDirection являющийся вектором отклонения левого стика.
|
// Обработка гейм-пада. Задает Vector2 vectorMovementDirection являющийся вектором отклонения левого стика.
|
||||||
GamePadState gamePadState = GamePad.GetState(0);
|
GamePadState gamePadState = GamePad.GetState(0);
|
||||||
vectorMovementDirection = gamePadState.ThumbSticks.Left;
|
vectorMovementDirection = gamePadState.ThumbSticks.Left;
|
||||||
|
@ -86,6 +93,7 @@ namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
isShoot = false;
|
isShoot = false;
|
||||||
}
|
}
|
||||||
|
SetState(ControlsState.Gamepad);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Работа с KeyBoard
|
// Работа с KeyBoard
|
||||||
|
|
|
@ -12,7 +12,7 @@ using MonogameLibrary.UI.Base;
|
||||||
|
|
||||||
namespace DangerousD.GameCore
|
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 class AppManager : Game
|
||||||
{
|
{
|
||||||
public static AppManager Instance { get; private set; }
|
public static AppManager Instance { get; private set; }
|
||||||
|
@ -25,6 +25,7 @@ namespace DangerousD.GameCore
|
||||||
IDrawableObject OptionsGUI;
|
IDrawableObject OptionsGUI;
|
||||||
IDrawableObject LoginGUI;
|
IDrawableObject LoginGUI;
|
||||||
IDrawableObject LobbyGUI;
|
IDrawableObject LobbyGUI;
|
||||||
|
IDrawableObject DeathGUI;
|
||||||
|
|
||||||
public GameManager GameManager { get; private set; } = new GameManager();
|
public GameManager GameManager { get; private set; } = new GameManager();
|
||||||
public AnimationBuilder AnimationBuilder { get; private set; } = new AnimationBuilder();
|
public AnimationBuilder AnimationBuilder { get; private set; } = new AnimationBuilder();
|
||||||
|
@ -40,11 +41,12 @@ namespace DangerousD.GameCore
|
||||||
|
|
||||||
_graphics.PreferredBackBufferWidth = resolution.X;
|
_graphics.PreferredBackBufferWidth = resolution.X;
|
||||||
_graphics.PreferredBackBufferHeight = resolution.Y;
|
_graphics.PreferredBackBufferHeight = resolution.Y;
|
||||||
_graphics.IsFullScreen = true;
|
//_graphics.IsFullScreen = true;
|
||||||
gameState = GameState.Menu;
|
gameState = GameState.Menu;
|
||||||
MenuGUI = new MenuGUI();
|
MenuGUI = new MenuGUI();
|
||||||
LoginGUI = new LoginGUI();
|
LoginGUI = new LoginGUI();
|
||||||
LobbyGUI = new LobbyGUI();
|
LobbyGUI = new LobbyGUI();
|
||||||
|
DeathGUI = new DeathGUI();
|
||||||
UIManager.resolution = resolution;
|
UIManager.resolution = resolution;
|
||||||
UIManager.resolutionInGame = inGameResolution;
|
UIManager.resolutionInGame = inGameResolution;
|
||||||
}
|
}
|
||||||
|
@ -55,6 +57,7 @@ namespace DangerousD.GameCore
|
||||||
MenuGUI.Initialize(GraphicsDevice);
|
MenuGUI.Initialize(GraphicsDevice);
|
||||||
LoginGUI.Initialize(GraphicsDevice);
|
LoginGUI.Initialize(GraphicsDevice);
|
||||||
LobbyGUI.Initialize(GraphicsDevice);
|
LobbyGUI.Initialize(GraphicsDevice);
|
||||||
|
DeathGUI.Initialize(GraphicsDevice);
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +67,7 @@ namespace DangerousD.GameCore
|
||||||
MenuGUI.LoadContent();
|
MenuGUI.LoadContent();
|
||||||
LoginGUI.LoadContent();
|
LoginGUI.LoadContent();
|
||||||
LobbyGUI.LoadContent();
|
LobbyGUI.LoadContent();
|
||||||
|
DeathGUI.LoadContent();
|
||||||
GameObject.debugTexture = new Texture2D(GraphicsDevice, 1, 1);
|
GameObject.debugTexture = new Texture2D(GraphicsDevice, 1, 1);
|
||||||
GameObject.debugTexture.SetData<Color>(new Color[] { new Color(1, 0,0,0.25f) });
|
GameObject.debugTexture.SetData<Color>(new Color[] { new Color(1, 0,0,0.25f) });
|
||||||
renderTarget = new RenderTarget2D(GraphicsDevice, inGameResolution.X, inGameResolution.Y);
|
renderTarget = new RenderTarget2D(GraphicsDevice, inGameResolution.X, inGameResolution.Y);
|
||||||
|
@ -88,6 +92,9 @@ namespace DangerousD.GameCore
|
||||||
case GameState.Lobby:
|
case GameState.Lobby:
|
||||||
LobbyGUI.Update(gameTime);
|
LobbyGUI.Update(gameTime);
|
||||||
break;
|
break;
|
||||||
|
case GameState.Death:
|
||||||
|
DeathGUI.Update(gameTime);
|
||||||
|
break;
|
||||||
case GameState.Game:
|
case GameState.Game:
|
||||||
GameManager.Update(gameTime);
|
GameManager.Update(gameTime);
|
||||||
break;
|
break;
|
||||||
|
@ -117,6 +124,9 @@ namespace DangerousD.GameCore
|
||||||
case GameState.Lobby:
|
case GameState.Lobby:
|
||||||
LobbyGUI.Draw(_spriteBatch);
|
LobbyGUI.Draw(_spriteBatch);
|
||||||
break;
|
break;
|
||||||
|
case GameState.Death:
|
||||||
|
DeathGUI.Draw(_spriteBatch);
|
||||||
|
break;
|
||||||
case GameState.Game:
|
case GameState.Game:
|
||||||
_spriteBatch.Begin(SpriteSortMode.Deferred,null,SamplerState.PointClamp);
|
_spriteBatch.Begin(SpriteSortMode.Deferred,null,SamplerState.PointClamp);
|
||||||
GameManager.Draw(_spriteBatch);
|
GameManager.Draw(_spriteBatch);
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace MonogameLibrary.UI.Base
|
||||||
static MouseState mouseState, prevmouseState;
|
static MouseState mouseState, prevmouseState;
|
||||||
static KeyboardState keyboardState;
|
static KeyboardState keyboardState;
|
||||||
public static Point resolutionInGame, resolution;
|
public static Point resolutionInGame, resolution;
|
||||||
|
|
||||||
|
|
||||||
public void LoadContent(ContentManager content, string font)
|
public void LoadContent(ContentManager content, string font)
|
||||||
{
|
{
|
||||||
|
|
|
@ -93,7 +93,7 @@ namespace MonogameLibrary.UI.Elements
|
||||||
_spriteBatch.Draw(texture, rectangle, new Color(211, 211, 211));
|
_spriteBatch.Draw(texture, rectangle, new Color(211, 211, 211));
|
||||||
else
|
else
|
||||||
_spriteBatch.Draw(texture, rectangle, new Color(112, 128, 144));
|
_spriteBatch.Draw(texture, rectangle, new Color(112, 128, 144));
|
||||||
DrawText(_spriteBatch);
|
DrawText(_spriteBatch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue