But -> ButtonBase, But1 -> Button

This commit is contained in:
2026-06-14 00:53:08 +02:00
parent 72c181950b
commit d54695d014
9 changed files with 155 additions and 155 deletions

View File

@@ -5,7 +5,7 @@ using System.Linq;
namespace _2DGAMELIB
{
public class But1 : But
public class Button : ButtonBase
{
public List<Color> BaseColors = new List<Color>();
@@ -15,7 +15,7 @@ namespace _2DGAMELIB
public List<Color> TextColors = new List<Color>();
public But1(ShapePartT ShapePartT, Action<But> Action)
public Button(ShapePartT ShapePartT, Action<ButtonBase> Action)
: base(ShapePartT, Action)
{
Setting();

View File

@@ -3,7 +3,7 @@ using System.Drawing;
namespace _2DGAMELIB
{
public class But
public class ButtonBase
{
private bool dra = true;
@@ -11,23 +11,23 @@ namespace _2DGAMELIB
protected PartGroup partGroup;
protected Action<But> Over = delegate
protected Action<ButtonBase> Over = delegate
{
};
protected Action<But> Push = delegate
protected Action<ButtonBase> Push = delegate
{
};
protected Action<But> Release = delegate
protected Action<ButtonBase> Release = delegate
{
};
protected Action<But> Out = delegate
protected Action<ButtonBase> Out = delegate
{
};
public Action<But> Action = delegate
public Action<ButtonBase> Action = delegate
{
};
@@ -50,7 +50,7 @@ namespace _2DGAMELIB
public PartGroup PartGroup => partGroup;
public But(ShapePartT ShapePartT, Action<But> Action)
public ButtonBase(ShapePartT ShapePartT, Action<ButtonBase> Action)
{
partGroup = new PartGroup(ShapePartT);
this.Action = Action;

View File

@@ -6,20 +6,20 @@ namespace _2DGAMELIB
{
public class ButtonMap
{
private OrderedDictionary<string, But> buts = new OrderedDictionary<string, But>();
private OrderedDictionary<string, ButtonBase> buts = new OrderedDictionary<string, ButtonBase>();
public But this[string Name] => buts[Name];
public ButtonBase this[string Name] => buts[Name];
public IEnumerable<But> EnumBut => buts.Values;
public IEnumerable<ButtonBase> EnumBut => buts.Values;
public void Add(string Name, But But)
public void Add(string Name, ButtonBase ButtonBase)
{
buts.Add(Name, But);
buts.Add(Name, ButtonBase);
}
public void Down(ref Color HitColor)
{
using IEnumerator<But> enumerator = buts.Values.GetEnumerator();
using IEnumerator<ButtonBase> enumerator = buts.Values.GetEnumerator();
while (enumerator.MoveNext() && !enumerator.Current.Down(ref HitColor))
{
}
@@ -27,7 +27,7 @@ namespace _2DGAMELIB
public void Up(ref Color HitColor)
{
using IEnumerator<But> enumerator = buts.Values.GetEnumerator();
using IEnumerator<ButtonBase> enumerator = buts.Values.GetEnumerator();
while (enumerator.MoveNext() && !enumerator.Current.Up(ref HitColor))
{
}
@@ -35,7 +35,7 @@ namespace _2DGAMELIB
public void Move(ref Color HitColor)
{
foreach (But value in buts.Values)
foreach (ButtonBase value in buts.Values)
{
value.Move(ref HitColor);
}
@@ -43,7 +43,7 @@ namespace _2DGAMELIB
public void Leave()
{
using IEnumerator<But> enumerator = buts.Values.GetEnumerator();
using IEnumerator<ButtonBase> enumerator = buts.Values.GetEnumerator();
while (enumerator.MoveNext() && !enumerator.Current.Leave())
{
}
@@ -51,7 +51,7 @@ namespace _2DGAMELIB
public void SetHitColor(ModeEventDispatcher Med)
{
foreach (But item in EnumBut)
foreach (ButtonBase item in EnumBut)
{
item.SetHitColor(Med);
}
@@ -59,7 +59,7 @@ namespace _2DGAMELIB
public void Draw(RenderArea Are)
{
foreach (But value in buts.Values)
foreach (ButtonBase value in buts.Values)
{
value.Draw(Are);
}
@@ -67,7 +67,7 @@ namespace _2DGAMELIB
public void Dispose()
{
foreach (But value in buts.Values)
foreach (ButtonBase value in buts.Values)
{
value.Dispose();
}

View File

@@ -41,7 +41,7 @@ namespace _2DGAMELIB
};
settings.Converters.Add(new OrderedDictionaryConverter<string, VariantGrid>());
settings.Converters.Add(new OrderedDictionaryConverter<string, object>());
settings.Converters.Add(new OrderedDictionaryConverter<string, But>());
settings.Converters.Add(new OrderedDictionaryConverter<string, ButtonBase>());
settings.Converters.Add(new OrderedDictionaryConverter<string, Lab>());
return settings;
}

View File

@@ -18,9 +18,9 @@ namespace _2DGAMELIB
this.OnColor = OnColor;
}
public void OnOff(But But)
public void OnOff(ButtonBase ButtonBase)
{
But1 but = (But1)But;
Button but = (Button)ButtonBase;
if (!flag)
{
flag = true;
@@ -89,9 +89,9 @@ namespace _2DGAMELIB
}
}
public void SetFlag(But But, bool On)
public void SetFlag(ButtonBase ButtonBase, bool On)
{
But1 but = (But1)But;
Button but = (Button)ButtonBase;
if (On)
{
flag = true;