diff --git a/RecrownedAthenaeum/RecrownedAthenaeum.csproj b/RecrownedAthenaeum/RecrownedAthenaeum.csproj
index 757f9f5..9b14c2e 100644
--- a/RecrownedAthenaeum/RecrownedAthenaeum.csproj
+++ b/RecrownedAthenaeum/RecrownedAthenaeum.csproj
@@ -85,11 +85,13 @@
+
+
diff --git a/RecrownedAthenaeum/SpecialTypes/NinePatch.cs b/RecrownedAthenaeum/SpecialTypes/NinePatch.cs
index 17c8c07..69aa8c1 100644
--- a/RecrownedAthenaeum/SpecialTypes/NinePatch.cs
+++ b/RecrownedAthenaeum/SpecialTypes/NinePatch.cs
@@ -39,13 +39,8 @@ namespace RecrownedAthenaeum.SpecialTypes
this.bottom = bottom;
this.top = top;
- sourcePatches = GenerateSourcesPatches();
- }
-
- private Rectangle[] GenerateSourcesPatches()
- {
Rectangle[] patches =
- {
+{
new Rectangle(0, 0, left, bottom),
new Rectangle(left, 0, textureRegion.Width - left - right, bottom),
new Rectangle(textureRegion.Width - right, 0, right, bottom),
@@ -62,7 +57,9 @@ namespace RecrownedAthenaeum.SpecialTypes
patches[i].X += textureRegion.X;
patches[i].Y += textureRegion.Y;
}
- return patches;
+
+ sourcePatches = patches;
+
}
private Rectangle[] GenenerateDestinationRectangles(int width, int height)
@@ -122,7 +119,11 @@ namespace RecrownedAthenaeum.SpecialTypes
public void Draw(ConsistentSpriteBatch spriteBatch, Rectangle destination, Color color, float rotation = 0, Vector2 origin = default(Vector2))
{
if (rotation != 0) throw new NotImplementedException("Ninepatches can't be rotated.");
- if (origin != default(Vector2)) throw new NotImplementedException("Ninepatches can't have origin changed (hint: use the destination rectangle to shift and position).");
+ if (origin != default(Vector2))
+ {
+ destination.X -= (int)origin.X;
+ destination.Y -= (int)origin.Y;
+ }
Draw(spriteBatch, color, destination);
}
}
diff --git a/RecrownedAthenaeum/UI/BookSystem/Book.cs b/RecrownedAthenaeum/UI/BookSystem/Book.cs
index c8044fa..5285e61 100644
--- a/RecrownedAthenaeum/UI/BookSystem/Book.cs
+++ b/RecrownedAthenaeum/UI/BookSystem/Book.cs
@@ -97,7 +97,7 @@ namespace RecrownedAthenaeum.UI.BookSystem
if (targetPage != null)
{
Vector2 position;
- Rectangle targetBounds = targetPage.situation;
+ Rectangle targetBounds = targetPage.Boundaries;
position.X = targetBounds.X + (targetBounds.Width * 0.5f);
position.Y = targetBounds.Y + (targetBounds.Height * 0.5f);
camera.LinearInterpolationToPosition(0.4f, position, (float)gameTime.ElapsedGameTime.TotalSeconds);
@@ -173,7 +173,7 @@ namespace RecrownedAthenaeum.UI.BookSystem
/// Page to go to.
public void GoToPage(Page page)
{
- Rectangle targetBounds = page.situation;
+ Rectangle targetBounds = page.Boundaries;
camera.position.X = targetBounds.X + (targetBounds.Width * 0.5f);
camera.position.Y = targetBounds.Y + (targetBounds.Height * 0.5f);
}
diff --git a/RecrownedAthenaeum/UI/BookSystem/Page.cs b/RecrownedAthenaeum/UI/BookSystem/Page.cs
index ccb9992..5eae736 100644
--- a/RecrownedAthenaeum/UI/BookSystem/Page.cs
+++ b/RecrownedAthenaeum/UI/BookSystem/Page.cs
@@ -36,10 +36,10 @@ namespace RecrownedAthenaeum.UI.BookSystem
/// New Height
public virtual void ApplySize(int width, int height)
{
- situation.X = pageX * width;
- situation.Y = pageY * height;
- situation.Width = width;
- situation.Height = height;
+ X = pageX * width;
+ Y = pageY * height;
+ Width = width;
+ Height = height;
requiresSizeUpdate = false;
}
diff --git a/RecrownedAthenaeum/UI/Modular/Modules/Image.cs b/RecrownedAthenaeum/UI/Modular/Modules/Image.cs
index 6b31a74..8287695 100644
--- a/RecrownedAthenaeum/UI/Modular/Modules/Image.cs
+++ b/RecrownedAthenaeum/UI/Modular/Modules/Image.cs
@@ -24,12 +24,12 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
///
/// Scale of of the X axis.
///
- public float ScaleX { get { return (float)situation.Width / texture.Width; } set { situation.Width = (int)(texture.Width * value); } }
+ public float ScaleX { get { return (float)Width / texture.Width; } set { Width = (int)(texture.Width * value); } }
///
/// Scale of the Y axis.
///
- public float ScaleY { get { return (float)situation.Height / texture.Height; } set { situation.Height = (int)(texture.Height * value); } }
+ public float ScaleY { get { return (float)Height / texture.Height; } set { Height = (int)(texture.Height * value); } }
///
/// Sets scale of X and Y.
@@ -43,7 +43,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
public Image(Texture2D texture)
{
this.texture = texture ?? throw new ArgumentException("Image requires a texture.");
- situation = texture.Bounds;
+ SetPositionAndDimensions(texture.Bounds);
}
///
@@ -52,7 +52,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
/// The batch to use.
public override void Draw(ConsistentSpriteBatch batch)
{
- batch.Draw(texture, situation, null, color, rotation, origin, SpriteEffects.None, 0f);
+ batch.Draw(texture, new Rectangle(X, Y, Width, Height), null, color, rotation, origin, SpriteEffects.None, 0f);
base.Draw(batch);
}
@@ -69,8 +69,17 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
this.color = color;
this.rotation = rotation;
this.origin = origin;
- situation = destination;
+ SetPositionAndDimensions(destination);
Draw(spriteBatch);
}
+
+ ///
+ /// Center's the origin to the middle of the dimensions of the texture.
+ ///
+ public override void CenterOrigin()
+ {
+ origin.X = texture.Bounds.Width / 2f;
+ origin.Y = texture.Bounds.Height / 2f;
+ }
}
}
diff --git a/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs b/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs
index f262546..d7de55e 100644
--- a/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs
+++ b/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs
@@ -76,7 +76,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
/// Snapshot of information about time for game.
public override void Update(GameTime gameTime)
{
- text.situation = Boundaries;
+ text.SetPositionAndDimensions(Boundaries);
text.Update(gameTime);
base.Update(gameTime);
}
diff --git a/RecrownedAthenaeum/UI/Modular/Modules/Text.cs b/RecrownedAthenaeum/UI/Modular/Modules/Text.cs
index dcc73e8..3c9e8ec 100644
--- a/RecrownedAthenaeum/UI/Modular/Modules/Text.cs
+++ b/RecrownedAthenaeum/UI/Modular/Modules/Text.cs
@@ -66,8 +66,8 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
/// The game time.
public override void Update(GameTime gameTime)
{
- position.X = situation.X;
- position.Y = situation.Y;
+ position.X = X;
+ position.Y = Y;
if (useEllipses) AttemptToApplyEllipsis();
if (autoWrap) AttemptToWrapText();
@@ -92,7 +92,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
///
public void AttemptToApplyEllipsis()
{
- if (modifiedTextSize.X * scale > situation.Width && ModifiedText.Length > ellipsis.Length + 1)
+ if (modifiedTextSize.X * scale > Width && ModifiedText.Length > ellipsis.Length + 1)
{
RemoveLineBreaks();
StringBuilder stringBuilder = new StringBuilder(ModifiedText);
@@ -101,7 +101,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
stringBuilder.Remove(stringBuilder.Length, ellipsis.Length - 1);
stringBuilder.Insert(stringBuilder.Length, ellipsis);
}
- while (font.MeasureString(stringBuilder).X * scale > situation.Width);
+ while (font.MeasureString(stringBuilder).X * scale > Width);
ModifiedText = stringBuilder.ToString();
}
@@ -113,18 +113,18 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
public void AttemptToScaleFont()
{
- if (situation.Width < situation.Height)
+ if (Width < Height)
{
- if (Math.Round(modifiedTextSize.X * scale ) != situation.Width)
+ if (Math.Round(modifiedTextSize.X * scale ) != Width)
{
- scale = situation.Width / modifiedTextSize.X;
+ scale = Width / modifiedTextSize.X;
}
}
else
{
- if (Math.Round(modifiedTextSize.Y * scale ) != situation.Height)
+ if (Math.Round(modifiedTextSize.Y * scale ) != Height)
{
- scale = situation.Height / (modifiedTextSize.Y);
+ scale = Height / (modifiedTextSize.Y);
}
}
}
@@ -152,7 +152,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
public void AttemptToWrapText(bool unwrap = false)
{
if (unwrap) RemoveLineBreaks();
- if (modifiedTextSize.X * scale > situation.Width)
+ if (modifiedTextSize.X * scale > Width)
{
ModifiedText = ModifiedText.Replace("\n", " ");
string[] words = ModifiedText.Split(' ');
@@ -164,7 +164,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
string word = words[w];
float scaledWidth = font.MeasureString(word).X * scale;
- if (currentScaledLineWidth + scaledWidth <= situation.Width)
+ if (currentScaledLineWidth + scaledWidth <= Width)
{
stringBuilder.Append(word);
currentScaledLineWidth += scaledWidth;
@@ -183,18 +183,18 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
{
Vector2 textSize = new Vector2(modifiedTextSize.X * scale, modifiedTextSize.Y * scale);
- if (textSize.X <= situation.Width)
+ if (textSize.X <= Width)
{
- position.X = situation.X + (situation.Width - textSize.X) / 2f;
+ position.X = X + (Width - textSize.X) / 2f;
}
else
{
return false;
}
- if (textSize.Y <= situation.Height)
+ if (textSize.Y <= Height)
{
- position.Y = situation.Y + (situation.Height - textSize.Y) / 2f;
+ position.Y = Y + (Height - textSize.Y) / 2f;
}
else
{
diff --git a/RecrownedAthenaeum/UI/Modular/Modules/UIScrollable.cs b/RecrownedAthenaeum/UI/Modular/Modules/UIScrollable.cs
new file mode 100644
index 0000000..4462393
--- /dev/null
+++ b/RecrownedAthenaeum/UI/Modular/Modules/UIScrollable.cs
@@ -0,0 +1,319 @@
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Input;
+using RecrownedAthenaeum.Input;
+using RecrownedAthenaeum.Render;
+using RecrownedAthenaeum.SpecialTypes;
+using RecrownedAthenaeum.UI.SkinSystem;
+using RecrownedAthenaeum.UI.SkinSystem.Definitions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RecrownedAthenaeum.UI.Modular.Modules
+{
+ public class UIScrollable : UIModule
+ {
+ UIModuleGroup group;
+
+ float opacityOfBar;
+ bool showingBars;
+ int shiftX, shiftY;
+ int furthestX;
+ int furthestY;
+ UIModule furthestXMod, furthestYMod;
+
+ bool horScrollAvailable, vertScrollAvailable;
+
+ Rectangle horizontalScrollBarBounds, verticalScrollBarBounds;
+ ///
+ /// How fast the bars fade away in opacity (0 to 254) per second.
+ ///
+ public float barFadeSpeed;
+
+ ISpecialDrawable horizontalScrollBar, verticalScrollBar;
+ ISpecialDrawable background, horizontalBarTrack, verticalBarTrack;
+
+ private int topPadding, bottomPadding, leftPadding, rightPadding;
+ public int PadTop { get { return topPadding; } set { topPadding = value; HeightOrYChange(); } }
+ public int PadBottom { get { return bottomPadding; } set { bottomPadding = value; HeightOrYChange(); } }
+ public int PadLeft { get { return leftPadding; } set { leftPadding = value; WidthOrXChange(); } }
+ public int PadRight { get { return rightPadding; } set { rightPadding = value; WidthOrXChange(); } }
+
+ ///
+ /// The minimum bar length for the scroll bar.
+ ///
+ public int minimumBarLength = 16;
+ ///
+ /// The thickness of the scroll bars.
+ ///
+ int horizontalBarThickness, verticalBarThickness;
+ public int HorizontalBarThickness { get { return horizontalBarThickness; } set { horizontalBarThickness = value; HeightOrYChange(); } }
+ public int VerticalBarThickness { get { return verticalBarThickness; } set { verticalBarThickness = value; WidthOrXChange(); } }
+
+ ///
+ /// Whether or not to hide scroll bars.
+ ///
+ public bool HideScrollBars
+ {
+ get { return hideScrollBars; }
+ set
+ {
+ hideScrollBars = value;
+ WidthOrXChange();
+ HeightOrYChange();
+ }
+ }
+
+ bool hideScrollBars = true;
+
+ ///
+ /// Set to true to change from the normal position to the new position.
+ ///
+ public bool verticalBarLeftPosition, horizontalBarTopPosition;
+
+
+ public override int Width
+ {
+ get
+ {
+ return base.Width;
+ }
+ set
+ {
+ base.Width = value;
+ WidthOrXChange();
+ }
+ }
+
+ public override int Height
+ {
+ get
+ {
+ return base.Height;
+ }
+ set
+ {
+ base.Height = value;
+ HeightOrYChange();
+ }
+ }
+
+ public override int X
+ {
+ get
+ {
+ return base.X;
+ }
+ set
+ {
+ WidthOrXChange(true);
+ base.X = value;
+ }
+ }
+
+ public override int Y
+ {
+ get
+ {
+ return base.Y;
+ }
+ set
+ {
+ HeightOrYChange(true);
+ base.Y = value;
+ }
+ }
+
+ public UIScrollable(ISpecialDrawable horizontalScrollBar, ISpecialDrawable verticalScrollBar, ISpecialDrawable horizontalBarTrack = null, ISpecialDrawable verticalBarTrack = null, ISpecialDrawable background = null)
+ {
+ this.horizontalScrollBar = horizontalScrollBar;
+ this.verticalScrollBar = verticalScrollBar;
+ this.horizontalBarTrack = horizontalBarTrack;
+ this.verticalBarTrack = verticalBarTrack;
+ this.background = background;
+
+ group = new UIModuleGroup(new BasicScissor());
+ }
+
+ public UIScrollable(ISkin skin, string definition) :
+ this(skin.GetTextureAtlasRegion(skin.ObtainDefinition().horizontalBar, true),
+ skin.GetTextureAtlasRegion(skin.ObtainDefinition().verticalBar, true),
+ skin.GetTextureAtlasRegion(skin.ObtainDefinition().horizontalBarTrack),
+ skin.GetTextureAtlasRegion(skin.ObtainDefinition().verticalBarTrack),
+ skin.GetTextureAtlasRegion(skin.ObtainDefinition().background))
+ {
+ }
+
+ public override void Update(GameTime gameTime)
+ {
+ if (hideScrollBars)
+ {
+ if (!showingBars)
+ {
+ if (opacityOfBar <= 0)
+ {
+ opacityOfBar -= (barFadeSpeed / 255f) * gameTime.ElapsedGameTime.Seconds;
+ }
+ }
+ else
+ {
+ opacityOfBar = 1f;
+ }
+ }
+
+ if (horScrollAvailable)
+ {
+ horizontalScrollBarBounds.X = (int)(((float)-shiftX / furthestX) * (group.Width - horizontalScrollBarBounds.Width));
+ }
+
+ if (vertScrollAvailable)
+ {
+ verticalScrollBarBounds.Y = (int)(((float)-shiftY / furthestY) * (group.Height - verticalScrollBarBounds.Height));
+ }
+
+ base.Update(gameTime);
+ }
+
+ public override void Draw(ConsistentSpriteBatch spriteBatch)
+ {
+ background.Draw(spriteBatch, Boundaries, color, origin: origin);
+ if (horScrollAvailable)
+ {
+ horizontalScrollBar.Draw(spriteBatch, horizontalScrollBarBounds, color);
+ }
+ if (vertScrollAvailable)
+ {
+ horizontalScrollBar.Draw(spriteBatch, verticalScrollBarBounds, color);
+ }
+ base.Draw(spriteBatch);
+ }
+
+ public void AddModules(params UIModule[] addModules)
+ {
+ group.AddModules(addModules);
+
+ for (int i = 0; i < addModules.Length; i++)
+ {
+ UIModule m = addModules[i];
+ int mFurthestX = m.Boundaries.X + m.Boundaries.Width;
+ int mFurthestY = m.Boundaries.Y + m.Boundaries.Height;
+ if (mFurthestX > furthestX)
+ {
+ furthestXMod = m;
+ furthestX = mFurthestX;
+ }
+ if (mFurthestY > furthestY)
+ {
+ furthestYMod = m;
+ furthestY = mFurthestY;
+ }
+ }
+ }
+
+ public void RemoveModule(UIModule module)
+ {
+ group.RemoveModule(module);
+
+ if (module == furthestXMod)
+ {
+ furthestX = 0;
+ UIModule[] modules = group.GetCopyOfModules();
+ for (int i = 0; i < modules.Length; i++)
+ {
+ UIModule m = modules[i];
+ int mFurthestX = m.Boundaries.X + m.Boundaries.Width;
+ if (mFurthestX > furthestX)
+ {
+ furthestXMod = m;
+ furthestX = mFurthestX;
+ }
+ }
+ }
+
+ if (module == furthestYMod)
+ {
+ furthestY = 0;
+ UIModule[] modules = group.GetCopyOfModules();
+
+ for (int i = 0; i < modules.Length; i++)
+ {
+ UIModule m = modules[i];
+ int mFurthestY = m.Boundaries.Y + m.Boundaries.Height;
+ if (mFurthestY > furthestY)
+ {
+ furthestYMod = m;
+ furthestY = mFurthestY;
+ }
+ }
+ }
+ }
+
+ private void WidthOrXChange(bool onlyXChange = false)
+ {
+ group.X = X + leftPadding;
+ if (!onlyXChange)
+ {
+ group.Width = Width - rightPadding - leftPadding;
+ if (Width < furthestX)
+ {
+ horScrollAvailable = true;
+ horizontalScrollBarBounds.Width = (int)(Width * ((float)Width / furthestX));
+ horizontalScrollBarBounds.Width = Math.Max(horizontalScrollBarBounds.Width, minimumBarLength);
+ }
+ else { horScrollAvailable = false; }
+
+
+ if (!hideScrollBars)
+ {
+ if (verticalBarLeftPosition)
+ {
+ group.X += verticalBarThickness;
+ group.Width -= verticalBarThickness;
+ }
+ group.Height -= verticalBarThickness;
+ }
+ }
+ }
+
+ private void HeightOrYChange(bool onlyYChange = false)
+ {
+ group.Y = Y + bottomPadding;
+ if (!onlyYChange)
+ {
+ group.Height = Height - bottomPadding - topPadding;
+ if (Height < furthestY)
+ {
+ horScrollAvailable = true;
+ verticalScrollBarBounds.Height = (int)(Height * ((float)Height / furthestY));
+ verticalScrollBarBounds.Height = Math.Max(verticalScrollBarBounds.Height, minimumBarLength);
+ }
+ else { vertScrollAvailable = false; }
+
+ if (!hideScrollBars)
+ {
+ if (!horizontalBarTopPosition)
+ {
+ group.Y += horizontalBarThickness;
+ group.Height -= horizontalBarThickness;
+ }
+ group.Height -= horizontalBarThickness;
+ }
+ }
+ }
+
+ public override bool MouseStateChanged(MouseState state)
+ {
+ if (InputUtilities.MouseWithinBoundries(Boundaries))
+ {
+ showingBars = true;
+ }
+ else
+ {
+ showingBars = false;
+ }
+ return base.MouseStateChanged(state);
+ }
+ }
+}
diff --git a/RecrownedAthenaeum/UI/Modular/UIModule.cs b/RecrownedAthenaeum/UI/Modular/UIModule.cs
index a5ec66b..44ba01d 100644
--- a/RecrownedAthenaeum/UI/Modular/UIModule.cs
+++ b/RecrownedAthenaeum/UI/Modular/UIModule.cs
@@ -10,12 +10,27 @@ namespace RecrownedAthenaeum.UI.Modular
///
/// Module for UI layout.
///
- public class UIModule : IInputListener
+ public abstract class UIModule : IInputListener
{
///
- /// The bounds before factoring in the origin.
+ /// The width of the module.
///
- public Rectangle situation;
+ public virtual int Width { get; set; }
+
+ ///
+ /// The height of the module.
+ ///
+ public virtual int Height { get; set; }
+
+ ///
+ /// The X position of the module.
+ ///
+ public virtual int X { get; set; }
+
+ ///
+ /// The Y position of the module.
+ ///
+ public virtual int Y { get; set; }
///
/// Bounds of this module (after factoring in the origin).
@@ -24,7 +39,7 @@ namespace RecrownedAthenaeum.UI.Modular
{
get
{
- return new Rectangle((int)(situation.X - origin.X), (int)(situation.Y - origin.Y), situation.Width, situation.Height);
+ return new Rectangle((int)(X - origin.X), (int)(Y - origin.Y), Width, Height);
}
}
@@ -115,16 +130,16 @@ namespace RecrownedAthenaeum.UI.Modular
}
///
- /// Sets the origin to be the center of the bounds.
+ /// Sets the origin to be the center using the and .
///
- public void CenterOrigin()
+ public virtual void CenterOrigin()
{
- origin.X = situation.Width / 2f;
- origin.Y = situation.Height / 2f;
+ origin.X = Width / 2f;
+ origin.Y = Height / 2f;
}
///
- /// Centers this module's origin on the horizontal axis relative to the parent .
+ /// Centers this module's on the horizontal axis relative to the parent .
///
/// True if possible and false if not.
public bool CenterHorizontally()
@@ -134,7 +149,7 @@ namespace RecrownedAthenaeum.UI.Modular
Rectangle rectangle = parent.Boundaries;
if (parent != null && rectangle.Width >= Boundaries.Width)
{
- situation.X = rectangle.Width / 2 + situation.X;
+ X = rectangle.Width / 2 + X;
return true;
}
}
@@ -145,18 +160,30 @@ namespace RecrownedAthenaeum.UI.Modular
/// Centers this module's origin on the vertical axis relative to the parent .
///
/// True if possible.
- public bool CenterVertically()
+ public virtual bool CenterVertically()
{
if (parent != null)
{
Rectangle rectangle = parent.Boundaries;
if (rectangle.Height >= Boundaries.Height)
{
- situation.Y = rectangle.Height / 2 + situation.Y;
+ Y = rectangle.Height / 2 + Y;
return true;
}
}
return false;
}
+
+ ///
+ /// Sets the position and dimension of this module.
+ ///
+ /// The rectangle that represents the position and dimensions of the module.
+ public virtual void SetPositionAndDimensions(Rectangle rectangle)
+ {
+ X = rectangle.X;
+ Y = rectangle.Y;
+ Width = rectangle.Width;
+ Height = rectangle.Height;
+ }
}
}
diff --git a/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs b/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs
index 1dc152a..b0a0a46 100644
--- a/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs
+++ b/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs
@@ -19,6 +19,15 @@ namespace RecrownedAthenaeum.UI.Modular
///
public BasicScissor basicScissor;
+ ///
+ /// Instantiates the UI module group.
+ ///
+ /// Sets the field.
+ public UIModuleGroup(BasicScissor basicScissor = null)
+ {
+ this.basicScissor = basicScissor;
+ }
+
///
/// Draws this group of modules. If scissoring, will use the matrix and effect designated in the to begin the batch normally again.
///
@@ -33,13 +42,13 @@ namespace RecrownedAthenaeum.UI.Modular
foreach (UIModule module in modules)
{
- int offsetX = module.situation.X;
- int offsetY = module.situation.Y;
- module.situation.X = situation.X + offsetX;
- module.situation.Y = situation.Y + offsetY;
+ int offsetX = module.X;
+ int offsetY = module.Y;
+ module.X = X + offsetX;
+ module.Y = Y + offsetY;
module.Draw(spriteBatch);
- module.situation.X = offsetX;
- module.situation.Y = offsetY;
+ module.X = offsetX;
+ module.Y = offsetY;
}
if (basicScissor != null)
@@ -65,7 +74,7 @@ namespace RecrownedAthenaeum.UI.Modular
/// Adds module(s) to this group.
///
/// The module(s) to add.
- public void AddModule(params UIModule[] addModules)
+ public virtual void AddModules(params UIModule[] addModules)
{
foreach (UIModule module in addModules)
{
@@ -82,11 +91,19 @@ namespace RecrownedAthenaeum.UI.Modular
/// Removes given module from group.
///
/// module to remove.
- public void RemoveModule(UIModule module)
+ public virtual void RemoveModule(UIModule module)
{
module.parent = null;
modules.Remove(module);
}
+
+ ///
+ /// Obtains an array snapshot of all the modules.
+ ///
+ public UIModule[] GetCopyOfModules()
+ {
+ return modules.ToArray();
+ }
///
/// Updates the keyboard state of the modules in this group.
diff --git a/RecrownedAthenaeum/UI/SkinSystem/Definitions/ButtonSkinDefinition.cs b/RecrownedAthenaeum/UI/SkinSystem/Definitions/ButtonSkinDefinition.cs
index 712282f..a60ba8b 100644
--- a/RecrownedAthenaeum/UI/SkinSystem/Definitions/ButtonSkinDefinition.cs
+++ b/RecrownedAthenaeum/UI/SkinSystem/Definitions/ButtonSkinDefinition.cs
@@ -3,7 +3,7 @@
namespace RecrownedAthenaeum.UI.SkinSystem.Definitions
{
///
- /// Definition for a button.
+ /// Skin definition for a button.
///
public class ButtonSkinDefinition : SkinDefinitionData
{
diff --git a/RecrownedAthenaeum/UI/SkinSystem/Definitions/UIScrollableSkinDefinition.cs b/RecrownedAthenaeum/UI/SkinSystem/Definitions/UIScrollableSkinDefinition.cs
new file mode 100644
index 0000000..ee56c5a
--- /dev/null
+++ b/RecrownedAthenaeum/UI/SkinSystem/Definitions/UIScrollableSkinDefinition.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RecrownedAthenaeum.UI.SkinSystem.Definitions
+{
+ ///
+ /// Skin definition of a scroll module.
+ ///
+ public class UIScrollableSkinDefinition : SkinDefinitionData
+ {
+ ///
+ /// Name of the region that specifies the texture needed.
+ ///
+ public string horizontalBar, verticalBar, horizontalBarTrack, verticalBarTrack, background;
+
+ ///
+ /// Instantiates the definition with the minimum requirements.
+ ///
+ /// Name of the region used by the skin that defines what the horizontal scroll bar looks like.
+ /// Name of the region used by the skin that defines what the vertical scroll bar looks like.
+ public UIScrollableSkinDefinition(string horizontalBar, string verticalBar)
+ {
+ this.horizontalBar = horizontalBar;
+ this.verticalBar = verticalBar;
+ }
+ }
+}
diff --git a/RecrownedAthenaeum/UI/SkinSystem/Skin.cs b/RecrownedAthenaeum/UI/SkinSystem/Skin.cs
index 005cb9d..6749cfa 100644
--- a/RecrownedAthenaeum/UI/SkinSystem/Skin.cs
+++ b/RecrownedAthenaeum/UI/SkinSystem/Skin.cs
@@ -22,7 +22,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem
private TextureAtlas textureAtlas;
Dictionary colors;
- readonly Dictionary moduleTypeOfDefinition;
+ readonly Dictionary definitionOfType;
readonly Dictionary> definitions;
///
@@ -40,7 +40,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem
this.textureAtlas = textureAtlas;
this.CursorTexture = cursorTexture;
colors = new Dictionary();
- moduleTypeOfDefinition = new Dictionary();
+ definitionOfType = new Dictionary();
definitions = new Dictionary>();
}
@@ -105,7 +105,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem
/// The definition cast to T.
public T ObtainDefinition(string definitionName = null) where T : SkinDefinitionData
{
- return (T)ObtainDefinition(moduleTypeOfDefinition[typeof(T).FullName], definitionName);
+ return (T)ObtainDefinition(definitionOfType[typeof(T).FullName], definitionName);
}
///
@@ -120,7 +120,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem
if (definitionName == null) definitionName = "default";
if (!definitions.ContainsKey(skinDefinition.uiModuleTypeFullName))
{
- moduleTypeOfDefinition.Add(skinDefinition.GetType().FullName, skinDefinition.uiModuleTypeFullName);
+ definitionOfType.Add(skinDefinition.GetType().FullName, skinDefinition.uiModuleTypeFullName);
definitions.Add(skinDefinition.uiModuleTypeFullName, new Dictionary());
}
else if (definitions[skinDefinition.uiModuleTypeFullName].ContainsKey(definitionName)) throw new ArgumentException("Type of definition with that name already exists!");