diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb index 8e2e30b..9decaf7 100644 --- a/DangerousD/Content/Content.mgcb +++ b/DangerousD/Content/Content.mgcb @@ -54,6 +54,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 @@ -67,18 +102,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 d897d93..f619d5f 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/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 {