mainMenu
This commit is contained in:
parent
fb2b685136
commit
4207258d15
9 changed files with 150 additions and 12 deletions
|
@ -59,8 +59,8 @@ namespace MonogameLibrary.UI.Base
|
|||
{
|
||||
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);
|
||||
//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
|
||||
{
|
||||
|
|
|
@ -20,6 +20,13 @@
|
|||
/processorParam:TextureFormat=Compressed
|
||||
/build:Fonts/Font.spritefont
|
||||
|
||||
#begin Fonts/Font2.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:Fonts/Font2.spritefont
|
||||
|
||||
#begin Textures/GUI/MenuBackground.jpg
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
|
BIN
ZoFo/Content/Fonts/CarltineRegular-K7z5l.ttf
Normal file
BIN
ZoFo/Content/Fonts/CarltineRegular-K7z5l.ttf
Normal file
Binary file not shown.
|
@ -17,7 +17,7 @@ with.
|
|||
Size is a float value, measured in points. Modify this value to change
|
||||
the size of the font.
|
||||
-->
|
||||
<Size>12</Size>
|
||||
<Size>100</Size>
|
||||
|
||||
<!--
|
||||
Spacing is a float value, measured in pixels. Modify this value to change
|
||||
|
|
60
ZoFo/Content/Fonts/Font2.spritefont
Normal file
60
ZoFo/Content/Fonts/Font2.spritefont
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file contains an xml description of a font, and will be read by the XNA
|
||||
Framework Content Pipeline. Follow the comments to customize the appearance
|
||||
of the font in your game, and to change the characters which are available to draw
|
||||
with.
|
||||
-->
|
||||
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
|
||||
<Asset Type="Graphics:FontDescription">
|
||||
|
||||
<!--
|
||||
Modify this string to change the font that will be imported.
|
||||
-->
|
||||
<FontName>CarltineRegular-K7z5l.ttf</FontName>
|
||||
|
||||
<!--
|
||||
Size is a float value, measured in points. Modify this value to change
|
||||
the size of the font.
|
||||
-->
|
||||
<Size>15</Size>
|
||||
|
||||
<!--
|
||||
Spacing is a float value, measured in pixels. Modify this value to change
|
||||
the amount of spacing in between characters.
|
||||
-->
|
||||
<Spacing>0</Spacing>
|
||||
|
||||
<!--
|
||||
UseKerning controls the layout of the font. If this value is true, kerning information
|
||||
will be used when placing characters.
|
||||
-->
|
||||
<UseKerning>true</UseKerning>
|
||||
|
||||
<!--
|
||||
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
|
||||
and "Bold, Italic", and are case sensitive.
|
||||
-->
|
||||
<Style>Regular</Style>
|
||||
|
||||
<!--
|
||||
If you uncomment this line, the default character will be substituted if you draw
|
||||
or measure text that contains characters which were not included in the font.
|
||||
-->
|
||||
<!-- <DefaultCharacter>*</DefaultCharacter> -->
|
||||
|
||||
<!--
|
||||
CharacterRegions control what letters are available in the font. Every
|
||||
character from Start to End will be built and made available for drawing. The
|
||||
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
|
||||
character set. The characters are ordered according to the Unicode standard.
|
||||
See the documentation for more information.
|
||||
-->
|
||||
<CharacterRegions>
|
||||
<CharacterRegion>
|
||||
<Start> </Start>
|
||||
<End>~</End>
|
||||
</CharacterRegion>
|
||||
</CharacterRegions>
|
||||
</Asset>
|
||||
</XnaContent>
|
|
@ -41,7 +41,7 @@ public abstract class AbstractGUI
|
|||
|
||||
public virtual void Update(GameTime gameTime)
|
||||
{
|
||||
|
||||
Manager.Update(gameTime);
|
||||
}
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
|
|
|
@ -20,7 +20,7 @@ public class DebugHUD
|
|||
|
||||
public void LoadContent()
|
||||
{
|
||||
_spriteFont = AppManager.Instance.Content.Load<SpriteFont>("Fonts\\Font");
|
||||
_spriteFont = AppManager.Instance.Content.Load<SpriteFont>("Fonts\\Font2");
|
||||
}
|
||||
|
||||
public void Update(GameTime gameTime)
|
||||
|
|
|
@ -15,19 +15,68 @@ namespace ZoFo.GameCore.GUI;
|
|||
|
||||
public class MainMenuGUI : AbstractGUI
|
||||
{
|
||||
DrawableUIElement menuBackground;
|
||||
private DrawableUIElement menuBackground;
|
||||
Color mainBackgroundColor = Color.White;
|
||||
protected override void CreateUI()
|
||||
{
|
||||
int width = AppManager.Instance.CurentScreenResolution.X;
|
||||
int height = AppManager.Instance.CurentScreenResolution.Y;
|
||||
|
||||
menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), textureName = "Textures\\GUI\\MenuBackground" };
|
||||
menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), mainColor = mainBackgroundColor, textureName = "Textures\\GUI\\MenuBackground" };
|
||||
Elements.Add(menuBackground);
|
||||
menuBackground.LoadTexture(AppManager.Instance.Content);
|
||||
|
||||
Elements.Add(new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 5, (int)(width / 4), (int)(height / 20)), text = "ZoFo", fontColor = Color.White, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts\\Font"});
|
||||
|
||||
|
||||
Button playButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(width / 2 - (int)(width / 10), height / 3 + height / 20 + height / 40, (int)(width / 5), (int)(height / 20)),
|
||||
text = "Play",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts\\Font"
|
||||
};
|
||||
playButton.LeftButtonPressed += () =>
|
||||
{
|
||||
|
||||
};
|
||||
Elements.Add(playButton);
|
||||
Button optionButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(width / 2 - (int)(width / 10), height / 3 + (height / 20 + height / 40) * 2, (int)(width / 5), (int)(height / 20)),
|
||||
text = "Options",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts\\Font"
|
||||
};
|
||||
optionButton.LeftButtonPressed += () =>
|
||||
{
|
||||
|
||||
};
|
||||
Elements.Add(optionButton);
|
||||
Button exitButton = new Button(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(width / 2 - (int)(width / 10), height / 3 + (height / 20 + height / 40) * 3, (int)(width / 5), (int)(height / 20)),
|
||||
text = "Exit",
|
||||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts\\Font"
|
||||
};
|
||||
exitButton.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.Exit();
|
||||
};
|
||||
Elements.Add(exitButton);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
|
||||
base.Update(gameTime);
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ using Microsoft.Xna.Framework.Graphics;
|
|||
using Microsoft.Xna.Framework.Input;
|
||||
using ZoFo.GameCore.GUI;
|
||||
using static System.Collections.Specialized.BitVector32;
|
||||
using MonogameLibrary.UI.Base;
|
||||
|
||||
namespace ZoFo.GameCore.GameManagers
|
||||
{
|
||||
|
@ -17,7 +18,8 @@ namespace ZoFo.GameCore.GameManagers
|
|||
{
|
||||
private GraphicsDeviceManager _graphics;
|
||||
private SpriteBatch _spriteBatch;
|
||||
|
||||
|
||||
|
||||
|
||||
public static AppManager Instance { get; private set; }
|
||||
public GameState gamestate;
|
||||
|
@ -37,11 +39,17 @@ namespace ZoFo.GameCore.GameManagers
|
|||
public AppManager()
|
||||
{
|
||||
_graphics = new GraphicsDeviceManager(this);
|
||||
SetResolution(CurentScreenResolution.X, CurentScreenResolution.Y);
|
||||
FulscrreenSwitch();
|
||||
|
||||
|
||||
Content.RootDirectory = "Content";
|
||||
IsMouseVisible = true;
|
||||
|
||||
Instance = this;
|
||||
InputManager = new InputManager();
|
||||
|
||||
|
||||
|
||||
currentGUI = new MainMenuGUI();
|
||||
debugHud = new DebugHUD();
|
||||
|
@ -73,9 +81,11 @@ namespace ZoFo.GameCore.GameManagers
|
|||
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
|
||||
Keyboard.GetState().IsKeyDown(Keys.Escape))
|
||||
Exit();
|
||||
|
||||
|
||||
debugHud.Set("key", "value");
|
||||
|
||||
InputManager.Update();
|
||||
//currentGUI.Update();
|
||||
currentGUI.Update(gameTime);
|
||||
switch (gamestate)
|
||||
{
|
||||
case GameState.NotPlaying:
|
||||
|
@ -98,9 +108,10 @@ namespace ZoFo.GameCore.GameManagers
|
|||
{
|
||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||
|
||||
|
||||
|
||||
currentGUI.Draw(_spriteBatch);
|
||||
debugHud.Draw(_spriteBatch);
|
||||
currentGUI.Draw(_spriteBatch);
|
||||
switch (gamestate)
|
||||
{
|
||||
case GameState.ClientPlaying:
|
||||
|
@ -129,5 +140,16 @@ namespace ZoFo.GameCore.GameManagers
|
|||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
public void SetResolution(int x, int y)
|
||||
{
|
||||
_graphics.PreferredBackBufferWidth = x;
|
||||
_graphics.PreferredBackBufferHeight = y;
|
||||
}
|
||||
|
||||
public void FulscrreenSwitch()
|
||||
{
|
||||
_graphics.IsFullScreen = !_graphics.IsFullScreen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue