Handle the null control code case

This commit is contained in:
jeffman 2015-03-25 15:07:04 -04:00
parent 800ae858a5
commit 43431f3d1a
1 changed files with 88 additions and 63 deletions

View File

@ -341,72 +341,97 @@ namespace ScriptTool
i = str.IndexOf(']', i + 1) + 1; i = str.IndexOf(']', i + 1) + 1;
if (code == null)
switch (code.Identifier)
{ {
case 0xC: // Not matched to anything -- check if it's a valid character sequence
case 0xD: foreach (var codeString in codeStrings)
case 0xE: {
case 0xF: if (!IsHexByte(codeString))
case 0x10: {
case 0x11: sb.Append("[INVALID]");
case 0x12: }
case 0x15: else
case 0x1A: {
case 0x2D: byte b = Convert.ToByte(codeString, 16);
case 0x9F: if (!charLookup.ContainsKey(b))
case 0xAD: {
// Name/item code sb.Append("[INVALID]");
sb.Append("[NAME]"); }
currentWidth += 60; else
break; {
sb.Append(charLookup[b]);
case 0x1: currentWidth += virtualWidths[b - 0x50];
case 0x2: }
// Line break }
strings.Add(sb.ToString()); }
sb.Clear();
widths.Add(currentWidth);
currentWidth = 0;
break;
case 0x20:
sb.Append("[SMAAASH]");
currentWidth += 72;
break;
case 0x21:
sb.Append("[YOU WIN]");
currentWidth += 72;
break;
case 0x23:
case 0x63:
case 0x98:
case 0xB7:
sb.Append("[MONEY]");
currentWidth += 36;
break;
case 0x24:
case 0x25:
case 0x26:
case 0x27:
case 0x28:
case 0x29:
case 0x2A:
case 0x2B:
sb.Append("[STAT]");
currentWidth += 18;
break;
case 0x1E:
case 0x1F:
sb.Append("_");
currentWidth += 10;
break;
} }
else
{
switch (code.Identifier)
{
case 0xC:
case 0xD:
case 0xE:
case 0xF:
case 0x10:
case 0x11:
case 0x12:
case 0x15:
case 0x1A:
case 0x2D:
case 0x9F:
case 0xAD:
// Name/item code
sb.Append("[NAME]");
currentWidth += 60;
break;
case 0x1:
case 0x2:
// Line break
strings.Add(sb.ToString());
sb.Clear();
widths.Add(currentWidth);
currentWidth = 0;
break;
case 0x20:
sb.Append("[SMAAASH]");
currentWidth += 72;
break;
case 0x21:
sb.Append("[YOU WIN]");
currentWidth += 72;
break;
case 0x23:
case 0x63:
case 0x98:
case 0xB7:
sb.Append("[MONEY]");
currentWidth += 36;
break;
case 0x24:
case 0x25:
case 0x26:
case 0x27:
case 0x28:
case 0x29:
case 0x2A:
case 0x2B:
sb.Append("[STAT]");
currentWidth += 18;
break;
case 0x1E:
case 0x1F:
sb.Append("_");
currentWidth += 10;
break;
}
}
} }
else if (str[i] == ']') else if (str[i] == ']')
{ {