Skip to content

Commit

Permalink
- Update with new 1.1.4 commands
Browse files Browse the repository at this point in the history
- fix handling of conditionals
- parse animations preserves subaction index
  • Loading branch information
Sammi-Husky committed Feb 20, 2016
1 parent 7d5b615 commit da0d825
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 20 deletions.
28 changes: 28 additions & 0 deletions AnimCmd/Classes/Nodes/ACMDNode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sm4shCommand.Classes;
using System.Windows.Forms;
using System.ComponentModel;

namespace Sm4shCommand.Nodes
{
class ACMDNode : BaseNode
{
private static ContextMenuStrip _menu;
static ACMDNode()
{
_menu = new ContextMenuStrip();
_menu.Items.Add(new ToolStripMenuItem("New Script", null, NewScriptAction));
}
protected static void NewScriptAction(object sender, EventArgs e)
{

}
public void AcmdMain(ACMDFile resource)
{

}
}
}
2 changes: 1 addition & 1 deletion AnimCmd/Classes/Nodes/CommandListNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class CommandListNode : BaseNode
return $"[{CRC:X8}]";
}
}

public bool Dirty { get { return _list.Dirty; } }
public CommandList CommandList { get { return _list; } set { _list = value; } }
private CommandList _list;
}
Expand Down
4 changes: 2 additions & 2 deletions AnimCmd/Events.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ NONE
14FCC7E4
Special_Hitbox
0,0,0,1,0,0,0,0,1,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
ID,Part,Bone,Damage,Angle,KBG,FKB,BKB,Size,Z,Y,X,Effect,Trip,Hitlag,SDI,Clang,Unknown,SFXLevel,SFXType,Ground/Air,Direct/Indirect,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown
ID,Part,Bone,Damage,Angle,KBG,FKB,BKB,Size,Z,Y,X,Effect,Trip,Hitlag,SDI,Clang,Unknown,ShieldDamage,SFXType,Ground/Air,Direct/Indirect,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown,Unknown
NONE

1511931F
Expand Down Expand Up @@ -2474,7 +2474,7 @@ NONE
B738EABD
Hitbox
0,0,0,1,0,0,0,0,1,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0
ID,Part,Bone,Damage,Angle,KBG,FKB,BKB,Size,Z,Y,X,Effect,Trip,Hitlag,SDI,Clang,Unknown,SFXLevel,SFXType,Ground/Air,Direct/Indirect,Unknown,Unknown
ID,Part,Bone,Damage,Angle,KBG,FKB,BKB,Size,Z,Y,X,Effect,Trip,Hitlag,SDI,Clang,Unknown,ShieldDamage,SFXType,Ground/Air,Direct/Indirect,Unknown,Unknown
NONE

B73EF69C
Expand Down
2 changes: 1 addition & 1 deletion AnimCmd/Gui/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private void parseAnimations(string path)
AnimHashPairs.TryGetValue(node.CRC, out str);
if (string.IsNullOrEmpty(str))
str = node.Name;
n.Nodes[i].Text = str;
n.Nodes[i].Text = $"{i:X}-{str}";
}
tree.EndUpdate();
}
Expand Down
1 change: 1 addition & 0 deletions AnimCmd/Sm4shCommand.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<Compile Include="Classes\CommandList.cs" />
<Compile Include="Classes\Fighter.cs" />
<Compile Include="Classes\Mtable.cs" />
<Compile Include="Classes\Nodes\ACMDNode.cs" />
<Compile Include="Classes\Nodes\BaseNode.cs" />
<Compile Include="Classes\Nodes\CommandListGroupNode.cs" />
<Compile Include="Classes\Nodes\CommandListNode.cs" />
Expand Down
60 changes: 44 additions & 16 deletions AnimCmd/System/Windows/Components/ITSCodeBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,19 @@ private int SerializeConditional(int startIndex)

string str = _list[startIndex].ToString();
int len = (int)_list[startIndex].parameters[0] - 2;
str += '{';
Lines.Add(new Line(str, this));
while (len != 0)
Lines.Add(new Line($"{str}{{", this));
while ((len -= _list[++i].CalcSize() / 4) != 0)
{
len -= _list[++i].CalcSize() / 4;
i += SerializeCommand(i, _list[i]._commandInfo.Identifier);
Lines.Add(new Line(_list[i].ToString(), this));
if (IsCmdHandled(_list[i]._commandInfo.Identifier))
i += SerializeCommand(i, _list[i]._commandInfo.Identifier);
else
Lines.Add(new Line(_list[i].ToString(), this));
}
if (IsCmdHandled(_list[i]._commandInfo.Identifier))
SerializeCommand(i, _list[i]._commandInfo.Identifier);
else
Lines.Add(new Line(_list[i].ToString(), this));

Lines.Add(new Line("}", this));
return i - startIndex;
}
Expand Down Expand Up @@ -133,23 +138,24 @@ private int ParseCommands(int index, uint ident)
}
return 0;
}
private int ParseConditional(int index)
private int ParseConditional(int startIndex)
{
Command cmd = Lines[index].Parse();
int startIndex = index;
int i = index;
Command cmd = Lines[startIndex].Parse();
int i = startIndex;
int len = 2;
while (Lines[++i].Text != "}")
CommandList.Add(cmd);
while (Lines[++i].TrimText != "}")
{
Command tmp = Lines[i].Parse();
len += tmp.CalcSize() / 4;
i += ParseCommands(i, tmp._commandInfo.Identifier);
CommandList.Add(tmp);
if (IsCmdHandled(tmp._commandInfo.Identifier))
i += ParseCommands(i, tmp._commandInfo.Identifier);
else
CommandList.Add(tmp);
}
cmd.parameters[0] = len;
CommandList.Insert(startIndex, cmd);
CommandList[CommandList.IndexOf(cmd)].parameters[0] = len;
// Next line should be closing bracket, ignore and skip it
return ++i - index;
return i - startIndex;
}
private int ParseLoop(int index)
{
Expand All @@ -169,6 +175,20 @@ private int ParseLoop(int index)
// Next line should be closing bracket, ignore and skip it
return ++i - index;
}

private bool IsCmdHandled(uint ident)
{
switch (ident)
{
case 0xA5BD4F32:
case 0x895B9275:
case 0x870CF021:
return true;
case 0x0EB375E3:
return true;
}
return false;
}
#endregion

private void tooltipTimer_Tick(object sender, EventArgs e)
Expand Down Expand Up @@ -241,6 +261,7 @@ public StringToken TokenFromCaret()
GetCaretPos(out cp);
return TokenFromPoint(cp);
}

#region Properties
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Browsable(false)]
Expand Down Expand Up @@ -792,6 +813,13 @@ public string Text
Info = GetInfo();
}
}
public string TrimText
{
get
{
return Text.TrimStart();
}
}
private string _text;
private StringToken[] _tokens;
public int Length { get { return Text.Length; } }
Expand Down

0 comments on commit da0d825

Please sign in to comment.