diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb index 5b7403d..a27d614 100644 --- a/DangerousD/Content/Content.mgcb +++ b/DangerousD/Content/Content.mgcb @@ -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 diff --git a/DangerousD/Content/MenuFon2.jpg b/DangerousD/Content/MenuFon2.jpg new file mode 100644 index 0000000..7e89ce8 Binary files /dev/null and b/DangerousD/Content/MenuFon2.jpg differ diff --git a/DangerousD/Content/menuFon3.jpg b/DangerousD/Content/menuFon3.jpg new file mode 100644 index 0000000..b608638 Binary files /dev/null and b/DangerousD/Content/menuFon3.jpg differ diff --git a/DangerousD/GameCore/GUI/LobbyGUI.cs b/DangerousD/GameCore/GUI/LobbyGUI.cs index a2e613d..f782750 100644 --- a/DangerousD/GameCore/GUI/LobbyGUI.cs +++ b/DangerousD/GameCore/GUI/LobbyGUI.cs @@ -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", diff --git a/DangerousD/GameCore/GUI/LoginGUI.cs b/DangerousD/GameCore/GUI/LoginGUI.cs index f495d36..a81284f 100644 --- a/DangerousD/GameCore/GUI/LoginGUI.cs +++ b/DangerousD/GameCore/GUI/LoginGUI.cs @@ -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 = "<-", diff --git a/DangerousD/GameCore/GUI/MenuGUI.cs b/DangerousD/GameCore/GUI/MenuGUI.cs index 62ff7c0..91f7523 100644 --- a/DangerousD/GameCore/GUI/MenuGUI.cs +++ b/DangerousD/GameCore/GUI/MenuGUI.cs @@ -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" }; diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index f769129..a6dbaac 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -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(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); } diff --git a/MonogameLibrary/UI/Base/UIManager.cs b/MonogameLibrary/UI/Base/UIManager.cs index 505d012..f8c1178 100644 --- a/MonogameLibrary/UI/Base/UIManager.cs +++ b/MonogameLibrary/UI/Base/UIManager.cs @@ -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 {