Created
June 14, 2025 09:11
-
-
Save ZedDevStuff/3b341661b559f9963dd3b01c59790602 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Runtime.CompilerServices; | |
using osu.Framework.Graphics; | |
namespace ProjectHarmony.Game.Extensions; | |
public static class DrawableExtensions | |
{ | |
private static readonly ConditionalWeakTable<Drawable, DrawableExtensionProperties> Properties = []; | |
extension(Drawable el) | |
{ | |
public string ClassName | |
{ | |
get => Properties.GetOrCreateValue(el).ClassName; | |
set => Properties.GetOrCreateValue(el).ClassName = value; | |
} | |
public string[] Classes | |
{ | |
get => el.ClassName.Split(' '); | |
set => el.ClassName = string.Join(' ', value); | |
} | |
} | |
public class DrawableExtensionProperties | |
{ | |
public string ClassName { get; set; } = string.Empty; | |
public string[] Classes | |
{ | |
get => ClassName.Split(' '); | |
set => ClassName = string.Join(' ', value); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment