1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-06-20 12:09:10 +02:00

code cleanup

This commit is contained in:
Ell 2021-07-19 23:49:16 +02:00
parent a76c14b243
commit 1067055bb5
4 changed files with 10 additions and 15 deletions

View file

@ -14,7 +14,7 @@ Improvements
- Improved NinePatch memory performance
- Moved sound-related classes into Sound namespace
- Added customizable overloads for Keybind, Combination and GenericInput ToString methods
- Added ColorExtensions.Invert and made ColorHelper.Invert obsolete
- Moved ColorHelper.Invert to ColorExtensions.Invert
- Removed LINQ Any and All usage in various methods to improve memory usage
Fixes

View file

@ -1,6 +1,5 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@ -184,12 +183,8 @@ namespace MLEM.Ui.Elements {
this.SetText(text, true);
MlemPlatform.EnsureExists();
this.OnPressed += async e => {
var title = this.MobileTitle ?? this.PlaceholderText;
var result = await MlemPlatform.Current.OpenOnScreenKeyboard(title, this.MobileDescription, this.Text, false);
if (result != null)
this.SetText(result.Replace('\n', ' '), true);
};
this.OnPressed += OnPressed;
this.OnTextInput += (element, key, character) => {
if (!this.IsSelected || this.IsHidden)
return;
@ -206,6 +201,13 @@ namespace MLEM.Ui.Elements {
};
this.OnDeselected += e => this.CaretPos = 0;
this.OnSelected += e => this.CaretPos = this.text.Length;
async void OnPressed(Element e) {
var title = this.MobileTitle ?? this.PlaceholderText;
var result = await MlemPlatform.Current.OpenOnScreenKeyboard(title, this.MobileDescription, this.Text, false);
if (result != null)
this.SetText(result.Replace('\n', ' '), true);
}
}
private void HandleTextChange(bool textChanged = true) {

View file

@ -1,5 +1,4 @@
using System;
using System.Linq;
using Microsoft.Xna.Framework;
using MLEM.Ui.Style;

View file

@ -34,12 +34,6 @@ namespace MLEM.Extensions {
/// </summary>
public static class ColorHelper {
/// <inheritdoc cref="ColorExtensions.Invert"/>
[Obsolete("This method has been moved to ColorExtensions.Invert in 5.1.0")]
public static Color Invert(this Color color) {
return ColorExtensions.Invert(color);
}
/// <summary>
/// Parses a hexadecimal number into an rgba color.
/// The number should be in the format <c>0xaarrggbb</c>.