From 0f62ed8b33035da295cf8a2ac21e965c8162eb53 Mon Sep 17 00:00:00 2001 From: gravity Date: Thu, 17 Aug 2023 20:51:51 +0300 Subject: [PATCH] gui --- DangerousD/Content/Content.mgcb | 109 ++++++++++++------------ DangerousD/Content/slider.png | Bin 0 -> 1878 bytes DangerousD/Content/sliderBackground.png | Bin 0 -> 1272 bytes DangerousD/GameCore/GUI/LobbyGUI.cs | 5 +- DangerousD/GameCore/GUI/OptionsGUI.cs | 4 +- MonogameLibrary/UI/Elements/Slider.cs | 18 +++- 6 files changed, 74 insertions(+), 62 deletions(-) create mode 100644 DangerousD/Content/slider.png create mode 100644 DangerousD/Content/sliderBackground.png diff --git a/DangerousD/Content/Content.mgcb b/DangerousD/Content/Content.mgcb index 87478e5..c977303 100644 --- a/DangerousD/Content/Content.mgcb +++ b/DangerousD/Content/Content.mgcb @@ -14,30 +14,6 @@ #---------------------------------- Content ---------------------------------# -#begin MonstersAnimations.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:MonstersAnimations.png - -#begin deathAnimation.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:deathAnimation.png - #begin ButtonFont.spritefont /importer:FontDescriptionImporter /processor:FontDescriptionProcessor @@ -45,13 +21,6 @@ /processorParam:TextureFormat=Compressed /build:ButtonFont.spritefont - -#begin DoomTestSong.mp3 -/importer:Mp3Importer -/processor:SoundEffectProcessor -/processorParam:Quality=Best -/build:DoomTestSong.mp3 - #begin checkboxs_off-on.png /importer:TextureImporter /processor:TextureProcessor @@ -88,6 +57,18 @@ /processorParam:TextureFormat=Color /build:checkboxs_on.png +#begin deathAnimation.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:deathAnimation.png + #begin deathBackground.jpg /importer:TextureImporter /processor:TextureProcessor @@ -100,6 +81,12 @@ /processorParam:TextureFormat=Color /build:deathBackground.jpg +#begin DoomTestSong.mp3 +/importer:Mp3Importer +/processor:SoundEffectProcessor +/processorParam:Quality=Best +/build:DoomTestSong.mp3 + #begin Font_25.spritefont /importer:FontDescriptionImporter /processor:FontDescriptionProcessor @@ -133,18 +120,6 @@ /processorParam:TextureFormat=Color /build:menuFon.jpg -#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 @@ -169,18 +144,6 @@ /processorParam:TextureFormat=Color /build:menuFon3.jpg -#begin tiles.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:tiles.png - #begin MonstersAnimations.png /importer:TextureImporter /processor:TextureProcessor @@ -217,6 +180,30 @@ /processorParam:TextureFormat=Color /build:PC_Computer_Dangerous_Dave_In_The_Haunted_Mansion_Death_Sequences.png +#begin slider.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:slider.png + +#begin sliderBackground.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:sliderBackground.png + #begin textboxbackground1-1.png /importer:TextureImporter /processor:TextureProcessor @@ -265,6 +252,18 @@ /processorParam:TextureFormat=Color /build:textboxbackground6-1.png +#begin tiles.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:tiles.png + #begin wall.jpg /importer:TextureImporter /processor:TextureProcessor diff --git a/DangerousD/Content/slider.png b/DangerousD/Content/slider.png new file mode 100644 index 0000000000000000000000000000000000000000..624b53396335615ce7477827170fa720e90b8708 GIT binary patch literal 1878 zcmV-c2dVgpP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D2J1;gK~zXfotNKl z9Mu)a&(7@ZuJ@;R4UQcgVoVSTN!3EylwSfVDxzwis;Y?oK(r6Eed-%hrAlpI`UkXC zRiQq#Qu@$RRjq&r!~-Cxsv?L<15KJhf)h}j#!l?myPn;d*_nR6GrNv|5Ck0Q>wE9) z%=zAP?m6ck=e&YrVG!G6W(Upe*b%cnqt*_?H?NxA-!MDQ{88{(co6(%u>J*j63n7=UC`^X4&At)XmN3_H!}Y|xDAYg zeP97Jdag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{21{MV(Gl973-A@ySF1!$=Sr1Di$WRncc5lmO5Xs7 zK)yLW@l1EQEppxWE~E-$opE}7s#LUEjk|om_hY7NZ&m-Ld!@b9eU|Z;;4p^12k`*~ zmvVO}q-q9K_hh*`O>IJLiabz-G>_>!F-0LRGTmEwuVir?r2!m6s@Rij>EG=IprcT0 zB}3HqoKaH_&ZohF)skCr!!q1Tti-!XIl54KQ6r4*rk Qod5s;07*qoM6N<$f{UV;+5i9m literal 0 HcmV?d00001 diff --git a/DangerousD/Content/sliderBackground.png b/DangerousD/Content/sliderBackground.png new file mode 100644 index 0000000000000000000000000000000000000000..8560739a00f14a08673daffac2a1235991c8a2f4 GIT binary patch literal 1272 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1dT~VK~#8N?cLvN z)nyz9@K0yk*$;J_lTM}iV=x=c3kzqaj?rBWN)4iU;UFkNNRa-BF1m|AvYTM|A-$4EQk=8w&@Uryie&-dB!Y;&F%ZRdO7{elnA_j%OIx6k>0zt8u1 zp0WR^%Zz__7wXN>Hlv=psB>&jm_0;WP{9BrxD4n=s3WK*j)};! z`U7T`ZOguWw!XdH%96=2DkA^42a}U_{rq_w>gln`J9omU`w{gv zLVP#sM&<-K%)Gs*TzH?`z1x}(9kPm5tHOwgEH}==S5Ka_8-0CY#4*Hg^AF z(~RbwsAtyH*=a8wJg8Y$WQ8RvDlD~Qhu@+O4-AA++l<=qi&;<9%?ogNVD(wli^99P zqa*Z0q!{YAZk-?ES1{4`BgDV5;{ir^`Ksu9R2}>L+02<&M2e3g&So+;dhJ>mu|52? zj1W&H!T{g%`l}*7u;M+hh{Q*8SC=L0e14@DQHObv!0gKhSzM&y__SFMtVH6ayt>*N z5AZHG=LoW!;0(-Vk-ox;?|J#ENJQf2g}r;N{PE=4hiZCl9= zwnQYpxMxY*QC=#MT#xm+iQQFJsW!NL(INE z^CEXL19y5yh_~SKW%h^r`xRo5B4c=eKYcp%TsOk|X}Df+HqsAhUPt-nSPXIY=1ps8 zY4NjKL}X>~p7*!z?)ft>pD=e~vYn2)iytq_f7Rv#kgTt_#{K(keOsG?EV7LFs)$dU z`M@ggo|hQjw=nz8IdgQe1HP-!e2IGB2ZD;#tL@p=R^Qr^yW??#E$t&MvUFT`!R3*D z!1us_zvs<+RWz#`br|6-e86`;1o>SwpQASTfQYOlK5hO4!Tl!cF7(s@6GB{rh6gF} z{3IUdAR^0)i!``4<2b@Q<|B(J7~okvND0jz6pvzg6~ztVQz-u27Lldl&*BVf5XJ8j ixU{(s!JR={fY~Dw9UzX^j~@vD0000 { diff --git a/DangerousD/GameCore/GUI/OptionsGUI.cs b/DangerousD/GameCore/GUI/OptionsGUI.cs index b086967..2236613 100644 --- a/DangerousD/GameCore/GUI/OptionsGUI.cs +++ b/DangerousD/GameCore/GUI/OptionsGUI.cs @@ -23,7 +23,9 @@ namespace DangerousD.GameCore.GUI { MinValue = 0, MaxValue = 1, - rectangle = new Rectangle(wigth / 2 + 220, 275, (int)(100 * 2.4), 40) + rectangle = new Rectangle(wigth / 2 + 220, 275, (int)(100 * 2.4), 40), + indentation = 5, + textureName = "sliderBackground" }; var cB = new CheckBox(Manager); diff --git a/MonogameLibrary/UI/Elements/Slider.cs b/MonogameLibrary/UI/Elements/Slider.cs index 7888d70..8db7152 100644 --- a/MonogameLibrary/UI/Elements/Slider.cs +++ b/MonogameLibrary/UI/Elements/Slider.cs @@ -1,4 +1,5 @@ using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using MonogameLibrary.UI.Base; @@ -17,7 +18,9 @@ namespace MonogameLibrary.UI.Elements } public delegate void OnSliderChanges(float value); public event OnSliderChanges? SliderChanged; + public int indentation = 5; + Texture2D texture2; public Rectangle sliderRect = new Rectangle(0, 0, 30, 30); private float sliderValue = 0; private float minValue = 0, maxValue = 1; @@ -50,6 +53,13 @@ namespace MonogameLibrary.UI.Elements sliderState = SliderState.None; return false; } + + public override void LoadTexture(ContentManager content) + { + texture2 = content.Load("slider"); + base.LoadTexture(content); + } + public void SetValue(float setvalue) { sliderValue = setvalue; @@ -60,14 +70,14 @@ namespace MonogameLibrary.UI.Elements { base.Draw(_spriteBatch); sliderRect.Location = rectangle.Location; - sliderRect.X += (int)(sliderValue * (rectangle.Width - sliderRect.Width)); + sliderRect.X += (int)(sliderValue * (rectangle.Width - sliderRect.Width - indentation * 2) + indentation); sliderRect.Y -= sliderRect.Height / 2 - rectangle.Height / 2; if (sliderState == SliderState.Moving) - _spriteBatch.Draw(texture, sliderRect, Color.DarkRed); + _spriteBatch.Draw(texture2, sliderRect, Color.DarkRed); else if(sliderState == SliderState.HoveringOverSliderButton) - _spriteBatch.Draw(texture, sliderRect, new Color(200,0,0)); + _spriteBatch.Draw(texture2, sliderRect, new Color(200,0 ,0)); else - _spriteBatch.Draw(texture, sliderRect, Color.Red); + _spriteBatch.Draw(texture2, sliderRect, Color.Red); DrawText(_spriteBatch); } }