mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-27 05:44:43 +00:00
Merge branch main into '3dSkinRenderer'
This commit is contained in:
@@ -90,7 +90,7 @@ namespace PckStudio.Forms.Editor
|
||||
checkbox.Checked = false;
|
||||
break;
|
||||
}
|
||||
_anim.SetFlag(item.Value, checkbox.Checked);
|
||||
_anim = _anim.SetFlag(item.Value, checkbox.Checked);
|
||||
});
|
||||
}
|
||||
OnCheckboxChanged?.Invoke(_anim);
|
||||
@@ -155,7 +155,7 @@ namespace PckStudio.Forms.Editor
|
||||
default:
|
||||
break;
|
||||
}
|
||||
_anim.SetFlag(checkBoxLinkage[checkBox], checkBox.Checked && checkBox.Enabled);
|
||||
_anim = _anim.SetFlag(checkBoxLinkage[checkBox], checkBox.Checked && checkBox.Enabled);
|
||||
OnCheckboxChanged?.Invoke(_anim);
|
||||
}
|
||||
}
|
||||
@@ -180,18 +180,6 @@ namespace PckStudio.Forms.Editor
|
||||
saveButton.Visible = !Settings.Default.AutoSaveChanges;
|
||||
}
|
||||
|
||||
public ANIMEditor(string animString) : this()
|
||||
{
|
||||
if (!SkinANIM.IsValidANIM(animString))
|
||||
{
|
||||
DialogResult = DialogResult.Abort;
|
||||
Close();
|
||||
}
|
||||
SkinANIM anim = initialANIM = SkinANIM.FromString(animString);
|
||||
setDisplayAnim(anim);
|
||||
ruleset.ApplyAnim(anim);
|
||||
}
|
||||
|
||||
public ANIMEditor(SkinANIM skinANIM) : this()
|
||||
{
|
||||
initialANIM = skinANIM;
|
||||
@@ -348,8 +336,8 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void resetButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
ruleset.ApplyAnim((SkinANIM)initialANIM.Clone());
|
||||
setDisplayAnim((SkinANIM)initialANIM.Clone());
|
||||
ruleset.ApplyAnim(initialANIM);
|
||||
setDisplayAnim(initialANIM);
|
||||
}
|
||||
|
||||
static readonly Dictionary<string, SkinAnimMask> Templates = new Dictionary<string, SkinAnimMask>()
|
||||
@@ -375,7 +363,7 @@ namespace PckStudio.Forms.Editor
|
||||
if (diag.ShowDialog(this) != DialogResult.OK)
|
||||
return;
|
||||
|
||||
var templateANIM = new SkinANIM(Templates[diag.SelectedItem]);
|
||||
SkinANIM templateANIM = SkinANIM.Empty.SetMask(Templates[diag.SelectedItem]);
|
||||
DialogResult prompt = MessageBox.Show(this, "Would you like to add this preset's effects to your current ANIM? Otherwise all of your effects will be cleared. Either choice can be undone by pressing \"Restore ANIM\".", "", MessageBoxButtons.YesNo);
|
||||
if (prompt == DialogResult.Yes)
|
||||
templateANIM |= ruleset.Value;
|
||||
|
||||
@@ -26,16 +26,11 @@ namespace PckStudio.Internal.Skin
|
||||
/// </summary>
|
||||
public class SkinANIM : ICloneable, IEquatable<SkinANIM>, IEquatable<SkinAnimMask>
|
||||
{
|
||||
public static readonly SkinANIM Empty = new SkinANIM();
|
||||
public static readonly SkinANIM Empty = new SkinANIM(0);
|
||||
|
||||
private BitVector32 _flags;
|
||||
private static readonly Regex _validator = new Regex(@"^0x[0-9a-f]{1,8}\b", RegexOptions.IgnoreCase);
|
||||
|
||||
public SkinANIM()
|
||||
: this(SkinAnimMask.NONE)
|
||||
{
|
||||
}
|
||||
|
||||
public SkinANIM(SkinAnimMask mask)
|
||||
: this((int)mask)
|
||||
{
|
||||
@@ -56,16 +51,16 @@ namespace PckStudio.Internal.Skin
|
||||
public static SkinANIM FromString(string value)
|
||||
=> IsValidANIM(value)
|
||||
? new SkinANIM(Convert.ToInt32(value.TrimEnd(' ', '\n', '\r'), 16))
|
||||
: new SkinANIM();
|
||||
: Empty;
|
||||
|
||||
public static SkinANIM operator |(SkinANIM @this, SkinANIM other) => new SkinANIM(@this._flags.Data | other._flags.Data);
|
||||
|
||||
public static SkinANIM operator |(SkinANIM @this, SkinAnimMask mask) => new SkinANIM(@this._flags.Data | (int)mask);
|
||||
|
||||
public static SkinANIM FromValue(int value) => new SkinANIM(value);
|
||||
|
||||
public int ToValue() => _flags.Data;
|
||||
|
||||
public static SkinANIM operator |(SkinANIM @this, SkinANIM other) => new SkinANIM(@this._flags.Data | other._flags.Data);
|
||||
|
||||
public static SkinANIM operator |(SkinANIM @this, SkinAnimMask mask) => new SkinANIM(@this._flags.Data | (int)mask);
|
||||
|
||||
public static implicit operator SkinANIM(SkinAnimMask mask) => new SkinANIM(mask);
|
||||
|
||||
public static bool operator ==(SkinANIM @this, SkinAnimMask mask) => @this.Equals(mask);
|
||||
@@ -92,11 +87,11 @@ namespace PckStudio.Internal.Skin
|
||||
/// </summary>
|
||||
/// <param name="flag">ANIM Flag to set</param>
|
||||
/// <param name="state">State of the flag</param>
|
||||
public void SetFlag(SkinAnimFlag flag, bool state)
|
||||
public SkinANIM SetFlag(SkinAnimFlag flag, bool state)
|
||||
{
|
||||
if (!Enum.IsDefined(typeof(SkinAnimFlag), flag))
|
||||
throw new ArgumentOutOfRangeException(nameof(flag));
|
||||
_flags[1 << (int)flag] = state;
|
||||
return new SkinANIM(state ? _flags.Data | 1 << (int)flag : _flags.Data & ~(1 << (int)flag));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -116,9 +111,9 @@ namespace PckStudio.Internal.Skin
|
||||
return MemberwiseClone();
|
||||
}
|
||||
|
||||
internal void SetMask(SkinAnimMask skinAnimMask)
|
||||
internal SkinANIM SetMask(SkinAnimMask skinAnimMask)
|
||||
{
|
||||
_flags = new BitVector32((int)skinAnimMask);
|
||||
return new SkinANIM(skinAnimMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace PckStudio.Internal.Skin
|
||||
}
|
||||
|
||||
public SkinModelInfo(Image texture)
|
||||
: this(texture, new SkinANIM())
|
||||
: this(texture, SkinANIM.Empty)
|
||||
{
|
||||
Texture = texture;
|
||||
}
|
||||
|
||||
@@ -1136,7 +1136,7 @@ namespace PckStudio
|
||||
case "ANIM" when asset.Type == PckAssetType.SkinFile:
|
||||
try
|
||||
{
|
||||
using ANIMEditor diag = new ANIMEditor(property.Value);
|
||||
using ANIMEditor diag = new ANIMEditor(SkinANIM.FromString(property.Value));
|
||||
if (diag.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
asset.SetProperty(asset.GetPropertyIndex(property), new KeyValuePair<string, string>("ANIM", diag.ResultAnim.ToString()));
|
||||
|
||||
Reference in New Issue
Block a user