mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-25 14:08:34 +01:00
Compare commits
3 commits
7a0464e8d6
...
02b4626996
Author | SHA1 | Date | |
---|---|---|---|
02b4626996 | |||
5aaba0c583 | |||
8044cb59cb |
9 changed files with 26 additions and 25 deletions
|
@ -10,12 +10,17 @@ Jump to version:
|
|||
- [5.0.0](#500)
|
||||
|
||||
## 6.1.0
|
||||
### MLEM
|
||||
Improvements
|
||||
- Improved EnumHelper.GetValues signature to return an array
|
||||
|
||||
### MLEM.Ui
|
||||
Additions
|
||||
- Added some extension methods for querying Anchor types
|
||||
|
||||
Improvements
|
||||
- Allow elements to auto-adjust their size even when their children are aligned oddly
|
||||
- Close other dropdowns when opening a dropdown
|
||||
|
||||
## 6.0.0
|
||||
### MLEM
|
||||
|
|
|
@ -69,7 +69,6 @@ namespace Demos {
|
|||
|
||||
// create the root panel that all the other components sit on and add it to the ui system
|
||||
this.root = new Panel(Anchor.Center, new Vector2(80, 100), Vector2.Zero, false, true);
|
||||
this.root.ScrollBar.SmoothScrolling = true;
|
||||
// add the root to the demos' ui
|
||||
this.UiRoot.AddChild(this.root);
|
||||
|
||||
|
|
|
@ -42,7 +42,16 @@ namespace MLEM.Ui.Elements {
|
|||
});
|
||||
this.OnAreaUpdated += e => this.Panel.PositionOffset = new Vector2(0, e.Area.Height / this.Scale);
|
||||
this.OnOpenedOrClosed += e => this.Priority = this.IsOpen ? 10000 : 0;
|
||||
this.OnPressed += e => this.IsOpen = !this.IsOpen;
|
||||
this.OnPressed += e => {
|
||||
this.IsOpen = !this.IsOpen;
|
||||
// close other dropdowns in the same root when we open
|
||||
if (this.IsOpen) {
|
||||
this.Root.Element.AndChildren(o => {
|
||||
if (o != this && o is Dropdown d && d.IsOpen)
|
||||
d.IsOpen = false;
|
||||
});
|
||||
}
|
||||
};
|
||||
this.GetGamepadNextElement = (dir, usualNext) => {
|
||||
// Force navigate down to our first child if we're open
|
||||
if (this.IsOpen && dir == Direction2.Down)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
@ -28,7 +27,7 @@ namespace MLEM.Ui.Parsers {
|
|||
/// </remarks>
|
||||
public class UiMarkdownParser {
|
||||
|
||||
private static readonly ElementType[] ElementTypes = EnumHelper.GetValues<ElementType>().ToArray();
|
||||
private static readonly ElementType[] ElementTypes = EnumHelper.GetValues<ElementType>();
|
||||
|
||||
/// <summary>
|
||||
/// The base path for markdown images, which is prepended to the image link.
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace MLEM.Input {
|
|||
/// <summary>
|
||||
/// All enum values of <see cref="ModifierKey"/>
|
||||
/// </summary>
|
||||
public static readonly ModifierKey[] ModifierKeys = EnumHelper.GetValues<ModifierKey>().ToArray();
|
||||
public static readonly ModifierKey[] ModifierKeys = EnumHelper.GetValues<ModifierKey>();
|
||||
private static readonly Dictionary<ModifierKey, Keys[]> KeysLookup = new Dictionary<ModifierKey, Keys[]> {
|
||||
{ModifierKey.Shift, new[] {Keys.LeftShift, Keys.RightShift}},
|
||||
{ModifierKey.Control, new[] {Keys.LeftControl, Keys.RightControl}},
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using MLEM.Misc;
|
||||
|
||||
|
@ -12,7 +11,7 @@ namespace MLEM.Input {
|
|||
/// <summary>
|
||||
/// All enum values of <see cref="MouseButton"/>
|
||||
/// </summary>
|
||||
public static readonly MouseButton[] MouseButtons = EnumHelper.GetValues<MouseButton>().ToArray();
|
||||
public static readonly MouseButton[] MouseButtons = EnumHelper.GetValues<MouseButton>();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="ButtonState"/> of the given mouse button.
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace MLEM.Misc {
|
|||
/// <summary>
|
||||
/// All <see cref="Direction2"/> enum values
|
||||
/// </summary>
|
||||
public static readonly Direction2[] All = EnumHelper.GetValues<Direction2>().ToArray();
|
||||
public static readonly Direction2[] All = EnumHelper.GetValues<Direction2>();
|
||||
/// <summary>
|
||||
/// The <see cref="Direction2.Up"/> through <see cref="Direction2.Left"/> directions
|
||||
/// </summary>
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
|
||||
namespace MLEM.Misc {
|
||||
|
@ -12,19 +10,20 @@ namespace MLEM.Misc {
|
|||
/// <summary>
|
||||
/// All values of the <see cref="Buttons"/> enum.
|
||||
/// </summary>
|
||||
public static readonly Buttons[] Buttons = EnumHelper.GetValues<Buttons>().ToArray();
|
||||
public static readonly Buttons[] Buttons = EnumHelper.GetValues<Buttons>();
|
||||
/// <summary>
|
||||
/// All values of the <see cref="Keys"/> enum.
|
||||
/// </summary>
|
||||
public static readonly Keys[] Keys = EnumHelper.GetValues<Keys>().ToArray();
|
||||
public static readonly Keys[] Keys = EnumHelper.GetValues<Keys>();
|
||||
|
||||
/// <summary>
|
||||
/// Returns all of the values of the given enum type.
|
||||
/// Returns an array containing all of the values of the given enum type.
|
||||
/// Note that this method is a version-independent equivalent of .NET 5's <c>Enum.GetValues<TEnum></c>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type whose enum to get</typeparam>
|
||||
/// <returns>An enumerable of the values of the enum, in declaration order.</returns>
|
||||
public static IEnumerable<T> GetValues<T>() {
|
||||
return Enum.GetValues(typeof(T)).Cast<T>();
|
||||
public static T[] GetValues<T>() {
|
||||
return (T[]) Enum.GetValues(typeof(T));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using FontStashSharp;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using MLEM.Cameras;
|
||||
using MLEM.Data;
|
||||
using MLEM.Data.Content;
|
||||
using MLEM.Extended.Font;
|
||||
using MLEM.Extended.Tiled;
|
||||
using MLEM.Extensions;
|
||||
using MLEM.Font;
|
||||
using MLEM.Formatting;
|
||||
|
@ -23,9 +17,6 @@ using MLEM.Textures;
|
|||
using MLEM.Ui;
|
||||
using MLEM.Ui.Elements;
|
||||
using MLEM.Ui.Style;
|
||||
using MonoGame.Extended;
|
||||
using MonoGame.Extended.Tiled;
|
||||
using MonoGame.Extended.ViewportAdapters;
|
||||
|
||||
namespace Sandbox;
|
||||
|
||||
|
@ -348,7 +339,7 @@ public class GameImpl : MlemGame {
|
|||
widthPanel.AddChild(new Paragraph(Anchor.AutoCenter, 100000, "Test String " + Math.Pow(10, i), true) {
|
||||
OnUpdated = (e, time) => {
|
||||
if (Input.IsPressed(Keys.A)) {
|
||||
e.Anchor = (Anchor) (((int) e.Anchor + 1) % EnumHelper.GetValues<Anchor>().Count());
|
||||
e.Anchor = (Anchor) (((int) e.Anchor + 1) % EnumHelper.GetValues<Anchor>().Length);
|
||||
Console.WriteLine(e.Anchor);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue