Skip to content

Commit a72f631

Browse files
committed
3.0.4
1 parent 6d7b5cd commit a72f631

File tree

8 files changed

+211
-140
lines changed

8 files changed

+211
-140
lines changed

DSAnimStudio/ImguiOSD/Dialog.TaeAnimPropertiesEdit.cs

Lines changed: 112 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,45 @@ public abstract partial class Dialog
1212
{
1313
public class TaeAnimPropertiesEdit : Dialog
1414
{
15-
public long TaeAnimID;
15+
string GetAnimIDString(long id)
16+
{
17+
if (id < 0)
18+
return "";
19+
20+
var animID_Lower = GameDataManager.GameTypeHasLongAnimIDs
21+
? (id % 1_000000) : (id % 1_0000);
22+
23+
var animID_Upper = GameDataManager.GameTypeHasLongAnimIDs
24+
? (id / 1_000000) : (id / 1_0000);
25+
26+
string curIDText;
27+
if (GameDataManager.GameTypeHasLongAnimIDs)
28+
{
29+
bool ds2Meme = GameDataManager.CurrentAnimIDFormatType == GameDataManager.AnimIDFormattingType.aXX_YY_ZZZZ;
30+
if (ds2Meme)
31+
{
32+
curIDText = $"a{(animID_Upper):D2}_{animID_Lower:D6}";
33+
curIDText = curIDText.Insert(curIDText.Length - 4, "_");
34+
}
35+
else
36+
{
37+
curIDText = $"a{(animID_Upper):D3}_{animID_Lower:D6}";
38+
}
39+
}
40+
else
41+
{
42+
curIDText = $"a{(animID_Upper):D2}_{animID_Lower:D4}";
43+
}
44+
45+
return curIDText;
46+
}
47+
48+
public string TaeAnimID_String;
49+
public long? TaeAnimID_Value;
50+
51+
public string ImportFromAnimID_String;
52+
public int? ImportFromAnimID_Value;
53+
1654
public string TaeAnimName;
1755
public TAE.Animation.AnimMiniHeader TaeAnimHeader;
1856
public bool WasAnimDeleted = false;
@@ -21,7 +59,9 @@ public TaeAnimPropertiesEdit(TAE.Animation anim)
2159
{
2260
Title = "Edit Animation Properties";
2361

24-
TaeAnimID = anim.ID;
62+
TaeAnimID_String = GetAnimIDString(anim.ID);
63+
TaeAnimID_Value = anim.ID;
64+
2565
TaeAnimName = anim.AnimFileName;
2666
if (anim.MiniHeader is TAE.Animation.AnimMiniHeader.ImportOtherAnim asImportOtherAnim)
2767
{
@@ -30,6 +70,8 @@ public TaeAnimPropertiesEdit(TAE.Animation anim)
3070
ImportFromAnimID = asImportOtherAnim.ImportFromAnimID,
3171
Unknown = asImportOtherAnim.Unknown,
3272
};
73+
ImportFromAnimID_String = GetAnimIDString(asImportOtherAnim.ImportFromAnimID);
74+
ImportFromAnimID_Value = asImportOtherAnim.ImportFromAnimID;
3375
}
3476
else if (anim.MiniHeader is TAE.Animation.AnimMiniHeader.Standard asStandard)
3577
{
@@ -40,6 +82,8 @@ public TaeAnimPropertiesEdit(TAE.Animation anim)
4082
ImportsHKX = asStandard.ImportsHKX,
4183
IsLoopByDefault = asStandard.IsLoopByDefault,
4284
};
85+
ImportFromAnimID_String = GetAnimIDString(asStandard.ImportHKXSourceAnimID);
86+
ImportFromAnimID_Value = asStandard.ImportHKXSourceAnimID;
4387
}
4488
}
4589

@@ -48,7 +92,23 @@ protected override void BuildInsideOfWindow()
4892
bool isCurrentlyStandard = TaeAnimHeader.Type == TAE.Animation.MiniHeaderType.Standard;
4993
bool isCurrentlyImportOther = TaeAnimHeader.Type == TAE.Animation.MiniHeaderType.ImportOtherAnim;
5094

51-
TaeAnimID = MenuBar.IntItem("Animation ID", (int)TaeAnimID);
95+
if (TaeAnimID_Value == null)
96+
ImGui.PushStyleColor(ImGuiCol.Text, new System.Numerics.Vector4(1, 0, 0, 1));
97+
ImGui.InputText("Animation ID", ref TaeAnimID_String, 256);
98+
if (TaeAnimID_Value == null)
99+
ImGui.PopStyleColor();
100+
if (string.IsNullOrWhiteSpace(TaeAnimID_String))
101+
{
102+
TaeAnimID_Value = null;
103+
}
104+
else if (long.TryParse(TaeAnimID_String.Replace("a", "").Replace("A", "").Replace("_", ""), out long animIdParsed))
105+
{
106+
TaeAnimID_Value = animIdParsed;
107+
}
108+
else
109+
{
110+
TaeAnimID_Value = null;
111+
}
52112

53113
ImGui.Separator();
54114

@@ -104,7 +164,24 @@ protected override void BuildInsideOfWindow()
104164
ImGui.Text("Properties - Duplicate of Other Anim Entry:");
105165
ImGui.Indent();
106166
{
107-
asImportOtherAnim.ImportFromAnimID = MenuBar.TaeAnimIDItem("Import From Anim ID", asImportOtherAnim.ImportFromAnimID);
167+
if (ImportFromAnimID_Value == null)
168+
ImGui.PushStyleColor(ImGuiCol.Text, new System.Numerics.Vector4(1, 0, 0, 1));
169+
ImGui.InputText("Duplicate of Animation ID", ref ImportFromAnimID_String, 256);
170+
if (ImportFromAnimID_Value == null)
171+
ImGui.PopStyleColor();
172+
if (string.IsNullOrWhiteSpace(ImportFromAnimID_String))
173+
{
174+
ImportFromAnimID_Value = asImportOtherAnim.ImportFromAnimID = -1;
175+
}
176+
else if (int.TryParse(ImportFromAnimID_String.Replace("a", "").Replace("A", "").Replace("_", ""), out int importFromIdParsed))
177+
{
178+
ImportFromAnimID_Value = asImportOtherAnim.ImportFromAnimID = importFromIdParsed;
179+
}
180+
else
181+
{
182+
ImportFromAnimID_Value = null;
183+
}
184+
108185
asImportOtherAnim.Unknown = MenuBar.IntItem("Unknown Value", asImportOtherAnim.Unknown);
109186
}
110187
ImGui.Unindent();
@@ -114,11 +191,26 @@ protected override void BuildInsideOfWindow()
114191
ImGui.Text("Properties - Standard Animation:");
115192
ImGui.Indent();
116193
{
117-
asStandard.ImportsHKX = MenuBar.CheckboxBig("Imports HKX From Elsewhere", asStandard.ImportsHKX);
118-
if (asStandard.ImportsHKX)
119-
asStandard.ImportHKXSourceAnimID = MenuBar.IntItem("Import HKX From ID", asStandard.ImportHKXSourceAnimID);
194+
asStandard.ImportsHKX = MenuBar.CheckboxBig("Import Other HKX", asStandard.ImportsHKX);
195+
196+
if (ImportFromAnimID_Value == null)
197+
ImGui.PushStyleColor(ImGuiCol.Text, new System.Numerics.Vector4(1, 0, 0, 1));
198+
ImGui.InputText("Import HKX ID", ref ImportFromAnimID_String, 256);
199+
if (ImportFromAnimID_Value == null)
200+
ImGui.PopStyleColor();
201+
if (string.IsNullOrWhiteSpace(ImportFromAnimID_String))
202+
{
203+
ImportFromAnimID_Value = asStandard.ImportHKXSourceAnimID = -1;
204+
}
205+
else if (int.TryParse(ImportFromAnimID_String.Replace("a", "").Replace("A", "").Replace("_", ""), out int importFromIdParsed))
206+
{
207+
ImportFromAnimID_Value = asStandard.ImportHKXSourceAnimID = importFromIdParsed;
208+
}
120209
else
121-
asStandard.ImportHKXSourceAnimID = -1;
210+
{
211+
ImportFromAnimID_Value = null;
212+
}
213+
122214
asStandard.AllowDelayLoad = MenuBar.CheckboxBig("Allow loading from DelayLoad ANIBNDs", asStandard.AllowDelayLoad);
123215
asStandard.IsLoopByDefault = MenuBar.CheckboxBig("Enable Looping", asStandard.IsLoopByDefault);
124216
}
@@ -151,11 +243,21 @@ protected override void BuildInsideOfWindow()
151243
Dismiss();
152244
}
153245

246+
bool invalidState = (ImportFromAnimID_Value == null || TaeAnimID_Value == null);
247+
154248
ImGui.Button("Apply & Save Changes");
155249
if (ImGui.IsItemClicked())
156250
{
157-
CancelType = CancelTypes.ClickedAcceptButton;
158-
Dismiss();
251+
if (invalidState)
252+
{
253+
DialogManager.DialogOK("Errors Present", "Cannot accept changes until the animation ID formatting errors (shown in red) are fixed.");
254+
}
255+
else
256+
{
257+
CancelType = CancelTypes.ClickedAcceptButton;
258+
Dismiss();
259+
}
260+
159261
}
160262

161263
//throw new NotImplementedException();

DSAnimStudio/ImguiOSD/Dialog.TextInput.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected override void BuildInsideOfWindow()
3434
ImGui.SetKeyboardFocusHere();
3535

3636
bool accepted = ImGui.InputTextWithHint(Question, TextHint, InputtedString,
37-
256, ImGuiInputTextFlags.EnterReturnsTrue | ImGuiInputTextFlags.CallbackAlways,
37+
256, ImGuiInputTextFlags.EnterReturnsTrue | ImGuiInputTextFlags.CallbackAlways | ImGuiInputTextFlags.AutoSelectAll,
3838
TextCallbackDelegate);
3939
if (accepted)
4040
{

DSAnimStudio/ImguiOSD/DialogManager.cs

Lines changed: 88 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -51,109 +51,125 @@ public static void DialogOK(string title, string text)
5151

5252
public static void ShowTaeAnimPropertiesEditor(TAE.Animation anim)
5353
{
54-
var dlg = new Dialog.TaeAnimPropertiesEdit(anim);
55-
dlg.OnDismiss = () =>
54+
Task.Run(new Action(() =>
5655
{
57-
if (dlg.CancelType == Dialog.CancelTypes.ClickedAcceptButton)
56+
var dlg = new Dialog.TaeAnimPropertiesEdit(anim);
57+
dlg.OnDismiss = () =>
5858
{
59-
if (dlg.WasAnimDeleted)
59+
if (dlg.CancelType == Dialog.CancelTypes.ClickedAcceptButton)
6060
{
61-
if (Tae.SelectedTae.Animations.Count <= 1)
61+
if (dlg.WasAnimDeleted)
6262
{
63-
DialogOK("Can't Delete Last Animation",
64-
"Cannot delete the only animation remaining in the TAE.");
63+
if (Tae.SelectedTae.Animations.Count <= 1)
64+
{
65+
DialogOK("Can't Delete Last Animation",
66+
"Cannot delete the only animation remaining in the TAE.");
67+
}
68+
else
69+
{
70+
var indexOfCurrentAnim = Tae.SelectedTae.Animations.IndexOf(Tae.SelectedTaeAnim);
71+
Tae.SelectedTae.Animations.Remove(Tae.SelectedTaeAnim);
72+
73+
Tae.RecreateAnimList();
74+
Tae.UpdateSelectedTaeAnimInfoText();
75+
76+
if (indexOfCurrentAnim > Tae.SelectedTae.Animations.Count - 1)
77+
indexOfCurrentAnim = Tae.SelectedTae.Animations.Count - 1;
78+
79+
if (indexOfCurrentAnim >= 0)
80+
Tae.SelectNewAnimRef(Tae.SelectedTae, Tae.SelectedTae.Animations[indexOfCurrentAnim]);
81+
else
82+
Tae.SelectNewAnimRef(Tae.SelectedTae, Tae.SelectedTae.Animations[0]);
83+
84+
Tae.SelectedTae.SetIsModified(!Tae.IsReadOnlyFileMode);
85+
}
86+
87+
6588
}
6689
else
6790
{
68-
var indexOfCurrentAnim = Tae.SelectedTae.Animations.IndexOf(Tae.SelectedTaeAnim);
69-
Tae.SelectedTae.Animations.Remove(Tae.SelectedTaeAnim);
70-
91+
anim.MiniHeader = dlg.TaeAnimHeader;
92+
anim.ID = dlg.TaeAnimID_Value.Value;
93+
anim.AnimFileName = dlg.TaeAnimName;
94+
anim.SetIsModified(true);
7195
Tae.RecreateAnimList();
7296
Tae.UpdateSelectedTaeAnimInfoText();
73-
74-
if (indexOfCurrentAnim > Tae.SelectedTae.Animations.Count - 1)
75-
indexOfCurrentAnim = Tae.SelectedTae.Animations.Count - 1;
76-
77-
if (indexOfCurrentAnim >= 0)
78-
Tae.SelectNewAnimRef(Tae.SelectedTae, Tae.SelectedTae.Animations[indexOfCurrentAnim]);
79-
else
80-
Tae.SelectNewAnimRef(Tae.SelectedTae, Tae.SelectedTae.Animations[0]);
81-
82-
Tae.SelectedTae.SetIsModified(!Tae.IsReadOnlyFileMode);
8397
}
84-
85-
86-
}
87-
else
88-
{
89-
anim.MiniHeader = dlg.TaeAnimHeader;
90-
anim.ID = dlg.TaeAnimID;
91-
anim.AnimFileName = dlg.TaeAnimName;
92-
anim.SetIsModified(true);
93-
Tae.RecreateAnimList();
94-
Tae.UpdateSelectedTaeAnimInfoText();
9598
}
96-
}
97-
};
98-
AddDialog(dlg);
99+
};
100+
AddDialog(dlg);
101+
}));
99102
}
100103

101104
public static void AskYesNo(string title, string question, Action<bool> onChoose,
102105
bool allowCancel = true, bool enterKeyForYes = true)
103106
{
104-
var allowedCancelTypes = Dialog.CancelTypes.None;
105-
if (allowCancel)
106-
allowedCancelTypes |= Dialog.CancelTypes.Combo_ClickTitleBarX_PressEscape;
107-
if (enterKeyForYes)
108-
allowedCancelTypes |= Dialog.CancelTypes.PressEnter;
109-
AskForMultiChoice(title, question, (cancelType, answer) =>
107+
Task.Run(new Action(() =>
110108
{
111-
if (cancelType == Dialog.CancelTypes.PressEnter)
112-
onChoose?.Invoke(true);
113-
else if (cancelType == Dialog.CancelTypes.PressEscape || cancelType == Dialog.CancelTypes.ClickTitleBarX)
114-
onChoose?.Invoke(false);
115-
else if (answer == "YES")
116-
onChoose?.Invoke(true);
117-
else if (answer == "NO")
118-
onChoose?.Invoke(false);
119-
120-
}, allowedCancelTypes, "YES", "NO");
109+
var allowedCancelTypes = Dialog.CancelTypes.None;
110+
if (allowCancel)
111+
allowedCancelTypes |= Dialog.CancelTypes.Combo_ClickTitleBarX_PressEscape;
112+
if (enterKeyForYes)
113+
allowedCancelTypes |= Dialog.CancelTypes.PressEnter;
114+
AskForMultiChoice(title, question, (cancelType, answer) =>
115+
{
116+
if (cancelType == Dialog.CancelTypes.PressEnter)
117+
onChoose?.Invoke(true);
118+
else if (cancelType == Dialog.CancelTypes.PressEscape || cancelType == Dialog.CancelTypes.ClickTitleBarX)
119+
onChoose?.Invoke(false);
120+
else if (answer == "YES")
121+
onChoose?.Invoke(true);
122+
else if (answer == "NO")
123+
onChoose?.Invoke(false);
124+
125+
}, allowedCancelTypes, "YES", "NO");
126+
}));
121127
}
122128

123129
public static void AskForMultiChoice(string title, string question,
124130
Action<Dialog.CancelTypes, string> onAnswer, Dialog.CancelTypes allowedCancelTypes, params string[] answers)
125131
{
126-
var dlg = new Dialog.MultiChoice()
132+
Task.Run(new Action(() =>
127133
{
128-
AllowedCancelTypes = allowedCancelTypes,
129-
Answers = answers.ToList(),
130-
Question = question,
131-
Title = title,
132-
};
133-
dlg.OnDismiss += () => onAnswer?.Invoke(dlg.CancelType, dlg.SelectedAnswer);
134-
AddDialog(dlg);
134+
var dlg = new Dialog.MultiChoice()
135+
{
136+
AllowedCancelTypes = allowedCancelTypes,
137+
Answers = answers.ToList(),
138+
Question = question,
139+
Title = title,
140+
};
141+
dlg.OnDismiss += () => onAnswer?.Invoke(dlg.CancelType, dlg.SelectedAnswer);
142+
AddDialog(dlg);
143+
}));
135144
}
136145

137146
public static void AskForInputString(string title, string question, string textHint,
138-
Action<string> onResult, bool canBeCancelled)
147+
Action<string> onResult, bool canBeCancelled, string startingText = null)
139148
{
140-
var dlg = new Dialog.TextInput()
149+
150+
Task.Run(new Action(() =>
141151
{
142-
AllowedCancelTypes = canBeCancelled ?
143-
Dialog.CancelTypes.Combo_ClickTitleBarX_PressEscape :
152+
var dlg = new Dialog.TextInput()
153+
{
154+
AllowedCancelTypes = canBeCancelled ?
155+
Dialog.CancelTypes.Combo_ClickTitleBarX_PressEscape :
144156
Dialog.CancelTypes.None,
145-
TextHint = textHint,
146-
Question = question,
147-
Title = title,
148-
};
157+
TextHint = textHint,
158+
Question = question,
159+
Title = title,
160+
InputtedString = startingText ?? string.Empty,
161+
};
149162

150-
dlg.OnDismiss += () =>
151-
{
152-
if (!dlg.WasCancelled)
153-
onResult?.Invoke(dlg.InputtedString);
154-
};
163+
dlg.OnDismiss += () =>
164+
{
165+
if (!dlg.WasCancelled)
166+
onResult?.Invoke(dlg.InputtedString);
167+
};
168+
169+
AddDialog(dlg);
170+
}));
155171

156-
AddDialog(dlg);
172+
157173
}
158174
}
159175
}

0 commit comments

Comments
 (0)