menu background

This commit is contained in:
gravity 2023-08-16 19:31:15 +03:00
parent 52743c1f89
commit 5d1800c90e
8 changed files with 88 additions and 30 deletions

View file

@ -41,6 +41,41 @@
/processorParam:TextureFormat=Compressed
/build:Font2.spritefont
#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 MenuFon2.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:MenuFon2.jpg
#begin menuFon3.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:menuFon3.jpg
#begin MonstersAnimations.png
/importer:TextureImporter
@ -54,18 +89,6 @@
/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.

After

Width:  |  Height:  |  Size: 464 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 KiB

View file

@ -7,6 +7,10 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DangerousD.GameCore.Managers;
using MonogameLibrary.UI.Base;
using System.Diagnostics;
namespace DangerousD.GameCore.GUI
{
class LobbyGUI : AbstractGui
@ -17,8 +21,12 @@ namespace DangerousD.GameCore.GUI
}
protected override void CreateUI()
{
int screenWidth = AppManager.Instance.resolution.X;
int screenHeight = AppManager.Instance.resolution.Y;
int screenWidth = AppManager.Instance.inGameResolution.X;
int screenHeight = AppManager.Instance.inGameResolution.Y;
var lobbyBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, screenWidth, screenHeight), textureName = "menuFon3" };
Elements.Add(lobbyBackground);
lobbyBackground.LoadTexture(AppManager.Instance.Content);
// CheckBoxs
Elements.Add(new Label(Manager) { rectangle = new Rectangle(screenWidth / 30 * 2, screenHeight / 30 * 5,
@ -26,7 +34,7 @@ namespace DangerousD.GameCore.GUI
// Buttons
{
Button backButton = new Button(Manager)
Button backButton = new ButtonText(Manager)
{
rectangle = new Rectangle(screenWidth / 30, screenHeight / 30, 60, 50),
text = "<-",
@ -38,7 +46,7 @@ namespace DangerousD.GameCore.GUI
AppManager.Instance.ChangeGameState(GameState.Menu);
};
Button hostButton = new Button(Manager)
Button hostButton = new ButtonText(Manager)
{
rectangle = new Rectangle(screenWidth / 30, screenHeight / 15 * 13, 120, 50),
text = "Host",
@ -50,7 +58,7 @@ namespace DangerousD.GameCore.GUI
};
Button refreshButton = new Button(Manager)
Button refreshButton = new ButtonText(Manager)
{
rectangle = new Rectangle(screenWidth / 30 * 6, screenHeight / 15 * 13, 120, 50),
text = "Refresh",
@ -62,7 +70,7 @@ namespace DangerousD.GameCore.GUI
};
Button joinSelectedButton = new Button(Manager)
Button joinSelectedButton = new ButtonText(Manager)
{
rectangle = new Rectangle(screenWidth / 30 * 25, screenHeight / 15 * 13, 120, 50),
text = "Join",
@ -73,7 +81,7 @@ namespace DangerousD.GameCore.GUI
joinSelectedButton.LeftButtonPressed += () => {
};
Button joinByIpButton = new Button(Manager)
Button joinByIpButton = new ButtonText(Manager)
{
rectangle = new Rectangle(screenWidth / 30 * 25, screenHeight / 30, 120, 50),
text = "JoinByIp",

View file

@ -5,6 +5,10 @@ using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using DangerousD.GameCore.Managers;
using MonogameLibrary.UI.Base;
using System.Diagnostics;
using MonogameLibrary.UI.Elements;
using MonogameLibrary.UI.Enums;
@ -20,8 +24,12 @@ namespace DangerousD.GameCore.GUI
protected override void CreateUI()
{
int screenWidth = AppManager.Instance.resolution.X;
int screenHeight = AppManager.Instance.resolution.Y;
int screenWidth = AppManager.Instance.inGameResolution.X;
int screenHeight = AppManager.Instance.inGameResolution.Y;
var loginBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, screenWidth, screenHeight), textureName = "menuFon2" };
Elements.Add(loginBackground);
loginBackground.LoadTexture(AppManager.Instance.Content);
Elements.Add(new Label(Manager) {
rectangle = new Rectangle(screenWidth / 2 - 250, screenHeight / 6 - 50, 500, 100),
@ -29,7 +37,7 @@ namespace DangerousD.GameCore.GUI
scale = 0.8f,
fontColor = Color.White,
mainColor = Color.Transparent,
fontName = "font2"
fontName = "ButtonFont"
});
// TextBox-ы
@ -83,7 +91,7 @@ namespace DangerousD.GameCore.GUI
// Кнопки
{
Button logButton = new Button(Manager) {
Button logButton = new ButtonText(Manager) {
rectangle = new Rectangle(screenWidth / 4 + 50, screenHeight / 6 * 4, 100, 50),
text = "LogIn",
scale = 0.2f,
@ -97,7 +105,7 @@ namespace DangerousD.GameCore.GUI
}
};
Button regButton = new Button(Manager)
Button regButton = new ButtonText(Manager)
{
rectangle = new Rectangle(screenWidth / 4 * 2 + 50, screenHeight / 6 * 4, 100, 50),
text = "Reg",
@ -107,7 +115,7 @@ namespace DangerousD.GameCore.GUI
};
regButton.LeftButtonPressed += GoToRegWebServer;
Button backButton = new Button(Manager)
Button backButton = new ButtonText(Manager)
{
rectangle = new Rectangle(screenWidth / 20, screenHeight / 15, 50, 50),
text = "<-",

View file

@ -3,6 +3,7 @@ using Microsoft.Xna.Framework;
using MonogameLibrary.UI.Base;
using MonogameLibrary.UI.Elements;
using System.Diagnostics;
using System.Runtime.Serialization;
namespace DangerousD.GameCore.GUI;
@ -10,6 +11,8 @@ internal class MenuGUI : 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 = "menuFon" };

View file

@ -8,6 +8,7 @@ using DangerousD.GameCore.GUI;
using Microsoft.Xna.Framework.Input;
using DangerousD.GameCore.Graphics;
using DangerousD.GameCore.Network;
using MonogameLibrary.UI.Base;
namespace DangerousD.GameCore
{
@ -17,7 +18,8 @@ namespace DangerousD.GameCore
public static AppManager Instance { get; private set; }
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
public Point resolution;
public Point resolution = new Point(1920, 1080);
public Point inGameResolution = new Point(800, 480);
GameState gameState;
IDrawableObject MenuGUI;
IDrawableObject OptionsGUI;
@ -27,6 +29,7 @@ namespace DangerousD.GameCore
public GameManager GameManager { get; private set; } = new GameManager();
public AnimationBuilder AnimationBuilder { get; private set; } = new AnimationBuilder();
public NetworkManager NetworkManager { get; private set; } = new NetworkManager();
private RenderTarget2D renderTarget;
public AppManager()
{
Instance = this;
@ -34,12 +37,16 @@ namespace DangerousD.GameCore
Content.RootDirectory = "Content";
IsMouseVisible = true;
TargetElapsedTime = TimeSpan.FromMilliseconds(1000 / 30);
resolution = new Point(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight);
_graphics.PreferredBackBufferWidth = resolution.X;
_graphics.PreferredBackBufferHeight = resolution.Y;
_graphics.IsFullScreen = true;
gameState = GameState.Menu;
MenuGUI = new MenuGUI();
LoginGUI = new LoginGUI();
LobbyGUI = new LobbyGUI();
UIManager.resolution = resolution;
UIManager.resolutionInGame = inGameResolution;
}
protected override void Initialize()
@ -59,6 +66,7 @@ namespace DangerousD.GameCore
LobbyGUI.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);
}
protected override void Update(GameTime gameTime)
@ -94,6 +102,7 @@ namespace DangerousD.GameCore
{
GraphicsDevice.Clear(Color.CornflowerBlue);
GraphicsDevice.SetRenderTarget(renderTarget);
switch (gameState)
{
case GameState.Menu:
@ -116,6 +125,10 @@ namespace DangerousD.GameCore
default:
break;
}
GraphicsDevice.SetRenderTarget(null);
_spriteBatch.Begin();
_spriteBatch.Draw(renderTarget, new Rectangle(0,0, _graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight), Color.White);
_spriteBatch.End();
base.Draw(gameTime);
}

View file

@ -7,7 +7,7 @@ using MonogameLibrary.UI.Interfaces;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using static System.Net.Mime.MediaTypeNames;
using static System.Net.Mime.MediaTypeNames;
namespace MonogameLibrary.UI.Base
{
@ -28,6 +28,7 @@ namespace MonogameLibrary.UI.Base
public KeyboardState GetKeyboardState { get { return keyboardState; } }
static MouseState mouseState, prevmouseState;
static KeyboardState keyboardState;
public static Point resolutionInGame, resolution;
public void LoadContent(ContentManager content, string font)
{
@ -48,11 +49,13 @@ namespace MonogameLibrary.UI.Base
}
}
public void Update()
{
{
try
{
keyboardState = Keyboard.GetState();
mouseState = Mouse.GetState();
mouseState = new MouseState((int)(mouseState.X*(float)resolutionInGame.X/resolution.X),
(int)(mouseState.Y * (float)resolutionInGame.Y / resolution.Y), mouseState.ScrollWheelValue, mouseState.LeftButton, mouseState.MiddleButton, mouseState.RightButton, mouseState.XButton1, mouseState.XButton2);
}
catch
{