diff --git a/.gitignore b/.gitignore index b06e864..42f6fca 100644 --- a/.gitignore +++ b/.gitignore @@ -209,4 +209,4 @@ FakesAssemblies/ # LightSwitch generated files GeneratedArtifacts/ _Pvt_Extensions/ -ModelManifest.xml +ModelManifest.xml \ No newline at end of file diff --git a/Galactic Colors Control GUI/Content/Fonts/basic.spritefont b/Galactic Colors Control GUI/Content/Fonts/basic.spritefont new file mode 100644 index 0000000..4095b04 --- /dev/null +++ b/Galactic Colors Control GUI/Content/Fonts/basic.spritefont @@ -0,0 +1,60 @@ + + + + + + + editundo + + + 16 + + + 0 + + + true + + + + + + + + + + + + ~ + + + + diff --git a/Galactic Colors Control GUI/Content/Fonts/small.spritefont b/Galactic Colors Control GUI/Content/Fonts/small.spritefont new file mode 100644 index 0000000..f4d712e --- /dev/null +++ b/Galactic Colors Control GUI/Content/Fonts/small.spritefont @@ -0,0 +1,60 @@ + + + + + + + Tahoma + + + 8 + + + 0 + + + true + + + + + + + + + + + + ~ + + + + \ No newline at end of file diff --git a/Galactic Colors Control GUI/Content/Fonts/title.spritefont b/Galactic Colors Control GUI/Content/Fonts/title.spritefont new file mode 100644 index 0000000..2504324 --- /dev/null +++ b/Galactic Colors Control GUI/Content/Fonts/title.spritefont @@ -0,0 +1,60 @@ + + + + + + + MV Boli + + + 50 + + + 0 + + + true + + + + + + + + + + + + ~ + + + + diff --git a/Galactic Colors Control GUI/Content/Sounds/alert.mp3 b/Galactic Colors Control GUI/Content/Sounds/alert.mp3 new file mode 100644 index 0000000..d80aed4 Binary files /dev/null and b/Galactic Colors Control GUI/Content/Sounds/alert.mp3 differ diff --git a/Galactic Colors Control GUI/Content/Sounds/bip.mp3 b/Galactic Colors Control GUI/Content/Sounds/bip.mp3 new file mode 100644 index 0000000..a28b430 Binary files /dev/null and b/Galactic Colors Control GUI/Content/Sounds/bip.mp3 differ diff --git a/Galactic Colors Control GUI/Content/Sounds/change.mp3 b/Galactic Colors Control GUI/Content/Sounds/change.mp3 new file mode 100644 index 0000000..71a3922 Binary files /dev/null and b/Galactic Colors Control GUI/Content/Sounds/change.mp3 differ diff --git a/Galactic Colors Control GUI/Content/Sounds/valid.mp3 b/Galactic Colors Control GUI/Content/Sounds/valid.mp3 new file mode 100644 index 0000000..903343c Binary files /dev/null and b/Galactic Colors Control GUI/Content/Sounds/valid.mp3 differ diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomCenter.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomCenter.png new file mode 100644 index 0000000..ba3882c Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomCenter.png differ diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomLeft.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomLeft.png new file mode 100644 index 0000000..0565eb6 Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomLeft.png differ diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomRight.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomRight.png new file mode 100644 index 0000000..f4030d1 Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/bottomRight.png differ diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerCenter.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerCenter.png new file mode 100644 index 0000000..cfff390 Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerCenter.png differ diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerLeft.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerLeft.png new file mode 100644 index 0000000..0904246 Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerLeft.png differ diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerRight.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerRight.png new file mode 100644 index 0000000..9547c0a Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/centerRight.png differ diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topCenter.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topCenter.png new file mode 100644 index 0000000..af78ce6 Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topCenter.png differ diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topLeft.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topLeft.png new file mode 100644 index 0000000..3fb9dc2 Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topLeft.png differ diff --git a/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topRight.png b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topRight.png new file mode 100644 index 0000000..e581211 Binary files /dev/null and b/Galactic Colors Control GUI/Content/Textures/Hub/Buttons/0/topRight.png differ diff --git a/Galactic Colors Control GUI/GUI/Button.cs b/Galactic Colors Control GUI/GUI/Button.cs new file mode 100644 index 0000000..e7e3b87 --- /dev/null +++ b/Galactic Colors Control GUI/GUI/Button.cs @@ -0,0 +1,112 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; + +namespace Galactic_Colors_Control_GUI.GUI +{ + class Button : Element + { + protected string _text; + protected SpriteFont _font; + protected Color _backColor, _backColorHover, _backColorFocus, _textColor, _textColorHover, _textColorFocus; + protected event EventHandler _click; + Texture2D _backSprite; + + public Button() { } + + public Button(Rectangle pos, Color backColor, EventHandler click = null) + { + _pos = pos; + _backColor = backColor; + _backColorHover = backColor; + _backColorFocus = backColor; + _backSprite = Game1.nullSprite; + _click = click; + } + + public Button(Rectangle pos, Color backColor, Color backColorHover, EventHandler click = null) + { + _pos = pos; + _backColor = backColor; + _backColorHover = backColorHover; + _backColorFocus = backColorHover; + _backSprite = Game1.nullSprite; + _click = click; + } + + public Button(Rectangle pos, Color backColor, Color backColorHover, Color backColorFocus, EventHandler click = null) + { + _pos = pos; + _backColor = backColor; + _backColorHover = backColorHover; + _backColorFocus = backColorFocus; + _backSprite = Game1.nullSprite; + _click = click; + } + + public Button(Rectangle pos, Color backColor, string text, SpriteFont font, Color textColor, EventHandler click = null) + { + _pos = pos; + _font = font; + _backColor = backColor; + _backColorHover = backColor; + _backColorFocus = backColor; + _textColor = textColor; + _textColorHover = textColor; + _textColorFocus = textColor; + _text = text; + _backSprite = Game1.nullSprite; + _click = click; + } + + public Button(Rectangle pos, Color backColor, Color backColorHover, string text, SpriteFont font, Color textColor, Color textColorHover, EventHandler click = null) + { + _pos = pos; + _font = font; + _backColor = backColor; + _backColorHover = backColorHover; + _backColorFocus = backColorHover; + _textColor = textColor; + _textColorHover = textColorHover; + _textColorFocus = textColorHover; + _text = text; + _backSprite = Game1.nullSprite; + _click = click; + } + + public Button(Rectangle pos, Color backColor, Color backColorHover, Color backColorFocus, string text, SpriteFont font, Color textColor, Color textColorHover, Color textColorFocus, EventHandler click = null) + { + _pos = pos; + _backColor = backColor; + _backColorHover = backColorHover; + _backColorFocus = backColorFocus; + _text = text; + _font = font; + _textColor = textColor; + _textColorHover = textColorHover; + _textColorFocus = textColorFocus; + _backSprite = Game1.nullSprite; + _click = click; + } + + public override void Click(object sender, EventArgs e) + { + if (_click != null) + { + _click.Invoke(sender, e); + } + } + + public override void Draw(SpriteBatch spriteBatch) + { + Color backColor = _isFocus ? _backColorFocus : (_isHover ? _backColorHover : _backColor); + spriteBatch.Draw(_backSprite, _pos, backColor); + if (_text != null) + { + Color textColor = _isFocus ? _textColorFocus : (_isHover ? _textColorHover : _textColor); + spriteBatch.DrawString(_font, _text, new Vector2(_pos.X + (_pos.Width - _font.MeasureString(_text).X) / 2, _pos.Y + (_pos.Height - _font.MeasureString(_text).Y) / 2), textColor); + } + if (_isFocus) { _isFocus = false; } + } + } +} diff --git a/Galactic Colors Control GUI/GUI/Element.cs b/Galactic Colors Control GUI/GUI/Element.cs new file mode 100644 index 0000000..c74b8ff --- /dev/null +++ b/Galactic Colors Control GUI/GUI/Element.cs @@ -0,0 +1,44 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using System; +using System.Collections.Generic; + +namespace Galactic_Colors_Control_GUI.GUI +{ + class Element + { + protected Rectangle _pos; + protected bool _isHover; + protected bool _isFocus; + + public bool Contain(int x, int y) + { + return _pos.Contains(x, y); + } + + public virtual void Draw(SpriteBatch spriteBatch) + { + + } + + public void Update(int x, int y, Mouse mouse, EventArgs e) + { + if (mouse.leftPress) + { + if (Contain(x, y)) + { + _isFocus = true; + Click(this, e); + } + else { _isFocus = false; } + } + else { _isHover = Contain(x, y); } + } + + public virtual void Click(object sender, EventArgs e) + { + + } + } +} diff --git a/Galactic Colors Control GUI/GUI/Label.cs b/Galactic Colors Control GUI/GUI/Label.cs new file mode 100644 index 0000000..22ec640 --- /dev/null +++ b/Galactic Colors Control GUI/GUI/Label.cs @@ -0,0 +1,75 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Galactic_Colors_Control_GUI.GUI +{ + class Label : Element + { + protected string _text; + protected SpriteFont _font; + protected Color _color, _colorHover, _colorFocus; + protected Vector _vector; + protected bool _center; + + public Label() { } + + public Label(Vector vector, string text, SpriteFont font, Color color, bool center = false) + { + _vector = vector; + _text = text; + _font = font; + _color = color; + _colorHover = color; + _colorFocus = color; + _center = center; + OnTextChange(text); + } + + public Label(Vector vector, string text, SpriteFont font, Color color, Color colorHover, bool center = false) + { + _vector = vector; + _text = text; + _font = font; + _color = color; + _colorHover = colorHover; + _colorFocus = colorHover; + _center = center; + OnTextChange(text); + } + + public Label(Vector vector, string text, SpriteFont font, Color color, Color colorHover, Color colorFocus, bool center = false) + { + _vector = vector; + _text = text; + _font = font; + _color = color; + _colorHover = colorHover; + _colorFocus = colorFocus; + _center = center; + OnTextChange(text); + } + + protected void OnTextChange(string text) + { + if (_center) + { + _pos = new Rectangle(_vector.X - (int)_font.MeasureString(text).X / 2, _vector.Y - (int)_font.MeasureString(text).Y / 2, (int)_font.MeasureString(text).X, (int)_font.MeasureString(text).Y); + } + else + { + _pos = new Rectangle(_vector.X, _vector.Y, (int)_font.MeasureString(text).X, (int)_font.MeasureString(text).Y); + } + } + + public override void Draw(SpriteBatch spriteBatch) + { + Color color = _isFocus ? _colorFocus : (_isHover ? _colorHover : _color); + spriteBatch.DrawString(_font, _text, new Vector2(_pos.X, _pos.Y), color); + } + } +} diff --git a/Galactic Colors Control GUI/GUI/Mouse.cs b/Galactic Colors Control GUI/GUI/Mouse.cs new file mode 100644 index 0000000..721c958 --- /dev/null +++ b/Galactic Colors Control GUI/GUI/Mouse.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Galactic_Colors_Control_GUI.GUI +{ + public struct Mouse + { + public bool leftPress; + public bool leftRelease; + public bool rightPress; + public bool rightRelease; + } +} diff --git a/Galactic Colors Control GUI/GUI/TexturedButton.cs b/Galactic Colors Control GUI/GUI/TexturedButton.cs new file mode 100644 index 0000000..b78e087 --- /dev/null +++ b/Galactic Colors Control GUI/GUI/TexturedButton.cs @@ -0,0 +1,113 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; + +namespace Galactic_Colors_Control_GUI.GUI +{ + class TexturedButton : Button + { + buttonSprites _backSprites; + + public TexturedButton(Rectangle pos, buttonSprites backSprites, Color backColor, EventHandler click = null) + { + _pos = pos; + _backSprites = backSprites; + _backColor = backColor; + _backColorHover = backColor; + _backColorFocus = backColor; + _click += click; + } + + public TexturedButton(Rectangle pos, buttonSprites backSprites, Color backColor, Color backColorHover, EventHandler click = null) + { + _pos = pos; + _backSprites = backSprites; + _backColor = backColor; + _backColorHover = backColorHover; + _backColorFocus = backColorHover; + _click += click; + } + + public TexturedButton(Rectangle pos, buttonSprites backSprites, Color backColor, Color backColorHover, Color backColorFocus, EventHandler click = null) + { + _pos = pos; + _backSprites = backSprites; + _backColor = backColor; + _backColorHover = backColorHover; + _backColorFocus = backColorFocus; + _click += click; + } + + public TexturedButton(Rectangle pos, buttonSprites backSprites, Color backColor, string text, SpriteFont font, Color textColor, EventHandler click = null) + { + _pos = pos; + _font = font; + _backSprites = backSprites; + _backColor = backColor; + _textColor = textColor; + _textColorHover = textColor; + _textColorFocus = textColor; + _text = text; + _click += click; + } + + public TexturedButton(Rectangle pos, buttonSprites backSprites, Color backColor, Color backColorHover, string text, SpriteFont font, Color textColor, Color textColorHover, EventHandler click = null) + { + _pos = pos; + _font = font; + _backSprites = backSprites; + _backColor = backColor; + _backColorHover = backColorHover; + _backColorFocus = backColorHover; + _textColor = textColor; + _textColorHover = textColorHover; + _textColorFocus = textColorHover; + _text = text; + _click += click; + } + + public TexturedButton(Rectangle pos, buttonSprites backSprites, Color backColor, Color backColorHover, Color backColorFocus, string text, SpriteFont font, Color textColor, Color textColorHover, Color textColorFocus, EventHandler click = null) + { + _pos = pos; + _backSprites = backSprites; + _backColor = backColor; + _backColorHover = backColorHover; + _backColorFocus = backColorFocus; + _text = text; + _font = font; + _textColor = textColor; + _textColorHover = textColorHover; + _textColorFocus = textColorFocus; + _click += click; + } + + public override void Draw(SpriteBatch spriteBatch) + { + Color backColor = _isFocus ? _backColorFocus : (_isHover ? _backColorHover : _backColor); + + int leftWidth = _backSprites.topLeft.Width; + int rightWidth = _backSprites.topRight.Width; + int centerWidth = _pos.Width - leftWidth - rightWidth; + + int topHeight = _backSprites.topLeft.Height; + int bottomHeight = _backSprites.bottomLeft.Height; + int centerHeight = _pos.Height - topHeight - bottomHeight; + + spriteBatch.Draw(_backSprites.topLeft, new Rectangle(_pos.X, _pos.Y, leftWidth, topHeight), backColor); + spriteBatch.Draw(_backSprites.topCenter, new Rectangle(_pos.X + leftWidth, _pos.Y, centerWidth, topHeight), backColor); + spriteBatch.Draw(_backSprites.topRight, new Rectangle(_pos.X + _pos.Width - rightWidth, _pos.Y, rightWidth, topHeight), backColor); + spriteBatch.Draw(_backSprites.centerLeft, new Rectangle(_pos.X, _pos.Y + topHeight, leftWidth, centerHeight), backColor); + spriteBatch.Draw(_backSprites.centerCenter, new Rectangle(_pos.X + leftWidth, _pos.Y + topHeight, centerWidth, centerHeight), backColor); + spriteBatch.Draw(_backSprites.centerRight, new Rectangle(_pos.X + _pos.Width - rightWidth, _pos.Y + topHeight, rightWidth, centerHeight), backColor); + spriteBatch.Draw(_backSprites.bottomLeft, new Rectangle(_pos.X, _pos.Y + _pos.Height - bottomHeight, leftWidth, bottomHeight), backColor); + spriteBatch.Draw(_backSprites.bottomCenter, new Rectangle(_pos.X + leftWidth, _pos.Y + _pos.Height - bottomHeight, centerWidth, bottomHeight), backColor); + spriteBatch.Draw(_backSprites.bottomRight, new Rectangle(_pos.X + _pos.Width - rightWidth, _pos.Y + _pos.Height - bottomHeight, rightWidth, bottomHeight), backColor); + if (_text != null) + { + Color textColor = _isFocus ? _textColorFocus : (_isHover ? _textColorHover : _textColor); + spriteBatch.DrawString(_font, _text, new Vector2(_pos.X + (_pos.Width - _font.MeasureString(_text).X) / 2, _pos.Y + (_pos.Height - _font.MeasureString(_text).Y) / 2), textColor); + } + if (_isFocus) { _isFocus = false; } + } + } +} diff --git a/Galactic Colors Control GUI/GUI/Vector.cs b/Galactic Colors Control GUI/GUI/Vector.cs new file mode 100644 index 0000000..0b40b01 --- /dev/null +++ b/Galactic Colors Control GUI/GUI/Vector.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Galactic_Colors_Control_GUI.GUI +{ + public class Vector + { + public int X; + public int Y; + + public Vector(int x, int y) + { + X = x; + Y = y; + } + } +} diff --git a/Galactic Colors Control GUI/GUI/buttonSprites.cs b/Galactic Colors Control GUI/GUI/buttonSprites.cs new file mode 100644 index 0000000..e501b4e --- /dev/null +++ b/Galactic Colors Control GUI/GUI/buttonSprites.cs @@ -0,0 +1,17 @@ +using Microsoft.Xna.Framework.Graphics; + +namespace Galactic_Colors_Control_GUI.GUI +{ + public struct buttonSprites + { + public Texture2D topLeft; + public Texture2D topCenter; + public Texture2D topRight; + public Texture2D centerLeft; + public Texture2D centerCenter; + public Texture2D centerRight; + public Texture2D bottomLeft; + public Texture2D bottomCenter; + public Texture2D bottomRight; + } +} \ No newline at end of file diff --git a/Galactic Colors Control GUI/Galactic Colors Control GUI.csproj b/Galactic Colors Control GUI/Galactic Colors Control GUI.csproj index 581d356..46d227f 100644 --- a/Galactic Colors Control GUI/Galactic Colors Control GUI.csproj +++ b/Galactic Colors Control GUI/Galactic Colors Control GUI.csproj @@ -39,8 +39,16 @@ + + + + + + + + @@ -57,6 +65,33 @@ + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -67,6 +102,7 @@ +