public bool CheckTagNumArgs(string arg, string tagName) { char[] tempCharArray = arg.ToCharArray(); bool argIsSafe = false; if (tempCharArray.Length == 0) { TagErrorHandler errorHandler = new TagErrorHandler("Numerical Argument Error", "The tag '" + tagName + "' requires a numerical argument." + Environment.NewLine + "Please enter a number after the ':'.", charData); DialogResult result = errorHandler.ShowDialog(); if (result == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandler.GetCorrectedData(); ProofReadTagstoCodes(); argIsSafe = false; return argIsSafe; } } foreach (char chara in tempCharArray) { if (char.IsDigit(chara) != true) { TagErrorHandler errorHandler = new TagErrorHandler("Numerical Argument Error", "The tag argument " + arg + " has letters in it." + Environment.NewLine + "Please use only numbers in tag arguments.", charData); DialogResult result = errorHandler.ShowDialog(); if (result == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandler.GetCorrectedData(); ProofReadTagstoCodes(); argIsSafe = false; return argIsSafe; } } } argIsSafe = true; return argIsSafe; }
public void ProofReadTagstoCodes() { List<byte> testList = new List<byte>(charData); for (int i = 0; i < testList.Count; i++) { if ((testList[i] != '<') && (testList[i] != '>')) { continue; } if (testList[i] == '>') { TagErrorHandler errorHandler = new TagErrorHandler("Unexpected Tag End", "An uexpected '>' bracket was found. Is there a" + Environment.NewLine + "missing '<' bracket?", charData); DialogResult result = errorHandler.ShowDialog(); if (result == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandler.GetCorrectedData(); ProofReadTagstoCodes(); return; } } List<byte> tagBuffer = new List<byte>(); uint tagSize = 1; while (testList[(int)(i + tagSize)] != '>') { tagBuffer.Add(testList[(int)(i + tagSize)]); tagSize += 1; if (i + tagSize >= testList.Count) { TagErrorHandler errorHandler = new TagErrorHandler("Endless Tag", "A '<' bracket was detected without a closing '>' bracket." + Environment.NewLine + "Please add a '>' bracket or delete the '<' bracket.", charData); DialogResult result = errorHandler.ShowDialog(); if (result == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandler.GetCorrectedData(); ProofReadTagstoCodes(); return; } } } //tagSize at this point only covers the text within the angled brackets. //This figures the brackets into the size tagSize += 1; string tempTag = new string(Encoding.ASCII.GetChars(tagBuffer.ToArray())); string[] tagArgs = tempTag.Split(':'); tagArgs[0] = tagArgs[0].ToLower(); if (tagArgs.Length > 1) { tagArgs[1] = tagArgs[1].ToLower(); } List<byte> code = new List<byte>(); switch (tagArgs[0]) { #region Five-Byte Codes case "player": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.PlayerName, 0); break; case "draw": if (tagArgs.Length > 1) { if (tagArgs[1] == "instant") { code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.CharDrawInstant, 0); break; } if (tagArgs[1] == "bychar") { code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.CharDrawByChar, 0); break; } else { TagErrorHandler errorHandler = new TagErrorHandler("Invalid 'Draw' Type", "A 'Draw' tag has an invalid type." + Environment.NewLine + "Please choose either 'Instant' or 'ByChar'.", charData); DialogResult result = errorHandler.ShowDialog(); if (result == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandler.GetCorrectedData(); ProofReadTagstoCodes(); return; } } } break; case "two choices": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.TwoChoices, 0); break; case "three choices": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.ThreeChoices, 0); break; case "a button": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.AButtonIcon, 0); break; case "b button": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.BButtonIcon, 0); break; case "c-stick": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.CStickIcon, 0); break; case "l trigger": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.LTriggerIcon, 0); break; case "r trigger": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.RTriggerIcon, 0); break; case "x button": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.XButtonIcon, 0); break; case "y button": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.YButtonIcon, 0); break; case "z button": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.ZButtonIcon, 0); break; case "d pad": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.DPadIcon, 0); break; case "control stick": if (tagArgs.Length == 1) { code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.StaticControlStickIcon, 0); } else { switch (tagArgs[1]) { #region Direction Switch case "up": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.ControlStickMovingUp, 0); break; case "down": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.ControlStickMovingDown, 0); break; case "left": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.ControlStickMovingLeft, 0); break; case "right": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.ControlStickMovingRight, 0); break; case "up+down": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.ControlStickMovingUpAndDown, 0); break; case "left+right": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.ControlStickMovingLeftAndRight, 0); break; default: TagErrorHandler errorHandler = new TagErrorHandler("Invalid 'Control Stick' Argument", "A 'Control Stick:' tag has an invalid argument." + Environment.NewLine + "Please choose from 'Up', 'Down', 'Left', 'Right'," + Environment.NewLine + " 'Up+Down', or 'Left+Right'.", charData); DialogResult result = errorHandler.ShowDialog(); if (result == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandler.GetCorrectedData(); ProofReadTagstoCodes(); return; } return; #endregion } } break; case "left arrow": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.LeftArrowIcon, 0); break; case "right arrow": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.RightArrowIcon, 0); break; case "up arrow": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.UpArrowIcon, 0); break; case "down arrow": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.DownArrowIcon, 0); break; case "choice one": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.ChoiceOne, 0); break; case "choice two": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.ChoiceTwo, 0); break; case "canon game balls": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.CanonGameBalls, 0); break; case "broken vase payment": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.BrokenVasePayment, 0); break; case "auction attendee": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.AuctionCharacter, 0); break; case "auction item name": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.AuctionItemName, 0); break; case "auction attendee bid": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.AuctionPersonBid, 0); break; case "auction starting bid": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.AuctionStartingBid, 0); break; case "player auction bid selector": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.PlayerAuctionBidSelector, 0); break; case "starburst a button": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.StarburstAIcon, 0); break; case "orca blow count": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.OrcaBlowCount, 0); break; case "pirate ship password": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.PirateShipPassword, 0); break; case "target starburst": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.TargetStarburstIcon, 0); break; case "player letter count": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.PostOfficeGamePlayerLetterCount, 0); break; case "letter rupee reward": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.PostOfficeGameRupeeReward, 0); break; case "letters": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.PostBoxLetterCount, 0); break; case "remaining koroks": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.RemainingKoroks, 0); break; case "remaining forest water time": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.RemainingForestWaterTime, 0); break; case "flight control game time": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.FlightPlatformGameTime, 0); break; case "flight control game record": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.FlightPlatformGameRecord, 0); break; case "beedle points": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.BeedlePointCount, 0); break; case "joy pendant count (ms. marie)": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.JoyPendantCountMsMarie, 0); break; case "pendant total": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.MsMariePendantTotal, 0); break; case "pig game time": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.PigGameTime, 0); break; case "sailing game rupee reward": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.SailingGameRupeeReward, 0); break; case "current bomb capacity": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.CurrentBombCapacity, 0); break; case "current arrow capacity": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.CurrentArrowCapacity, 0); break; case "heart icon": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.HeartIcon, 0); break; case "music note icon": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.MusicNoteIcon, 0); break; case "target letter count": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.TargetLetterCount, 0); break; case "fishman hit count": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.FishmanHitCount, 0); break; case "fishman rupee reward": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.FishmanRupeeReward, 0); break; case "boko baba seed count": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.BokoBabaSeedCount, 0); break; case "skull necklace count": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.SkullNecklaceCount, 0); break; case "chu jelly count": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.ChuJellyCount, 0); break; case "joy pendant count (beedle)": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.JoyPendantCountBeedle, 0); break; case "golden feather count": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.GoldenFeatherCount, 0); break; case "knight's crest count": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.KnightsCrestCount, 0); break; case "beedle price offer": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.BeedlePriceOffer, 0); break; case "boko baba seed sell selector": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.BokoBabaSeedSellSelector, 0); break; case "skull necklace sell selector": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.SkullNecklaceSellSelector, 0); break; case "chu jelly sell selector": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.ChuJellySellSelector, 0); break; case "joy pendant sell selector": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.JoyPendantSellSelector, 0); break; case "golden feather sell selector": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.GoldenFeatherSellSelector, 0); break; case "knight's crest sell selector": code = ConvertTagToFiveByteControlCode(i, 0, (byte)FiveByteTypes.KnightsCrestSellSelector, 0); break; case "sound": if (tagArgs.Length > 1) { bool tagSafe = CheckTagNumArgs(tagArgs[1], tagArgs[0]); if (tagSafe == false) { return; } code = ConvertTagToFiveByteControlCode(i, 1, 1, Convert.ToInt16(tagArgs[1])); } else { TagErrorHandler errorHandler = new TagErrorHandler("Missing Argument", "A tag '" + tagArgs[0] + "' requires a numerical argument." + Environment.NewLine + "Please add an argument by following the tag" + Environment.NewLine + "with a ':' and a number.", charData); DialogResult result = errorHandler.ShowDialog(); if (result == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandler.GetCorrectedData(); ProofReadTagstoCodes(); return; } } break; case "camera modifier": if (tagArgs.Length > 1) { bool tagSafe = CheckTagNumArgs(tagArgs[1], tagArgs[0]); if (tagSafe == false) { return; } code = ConvertTagToFiveByteControlCode(i, 2, 2, Convert.ToInt16(tagArgs[1])); } else { TagErrorHandler errorHandler = new TagErrorHandler("Missing Argument", "A tag '" + tagArgs[0] + "' requires a numerical argument." + Environment.NewLine + "Please add an argument by following the tag" + Environment.NewLine + "with a ':' and a number.", charData); DialogResult result = errorHandler.ShowDialog(); if (result == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandler.GetCorrectedData(); ProofReadTagstoCodes(); return; } } break; case "anim": if (tagArgs.Length > 1) { bool tagSafe = CheckTagNumArgs(tagArgs[1], tagArgs[0]); if (tagSafe == false) { return; } code = ConvertTagToFiveByteControlCode(i, 3, 3, Convert.ToInt16(tagArgs[1])); } else { TagErrorHandler errorHandler = new TagErrorHandler("Missing Argument", "A tag '" + tagArgs[0] + "' requires a numerical argument." + Environment.NewLine + "Please add an argument by following the tag" + Environment.NewLine + "with a ':' and a number.", charData); DialogResult result = errorHandler.ShowDialog(); if (result == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandler.GetCorrectedData(); ProofReadTagstoCodes(); return; } } break; #endregion #region Six-Byte Code case "color": if (tagArgs.Length > 1) { bool tagSafe = CheckTagNumArgs(tagArgs[1], tagArgs[0]); if (tagSafe == false) { return; } code.Add(0x1A); code.Add(0x06); code.Add(0xFF); code.Add(0x00); code.Add(0x00); code.Add(Convert.ToByte(tagArgs[1])); } else { TagErrorHandler errorHandler = new TagErrorHandler("Missing Argument", "A tag '" + tagArgs[0] + "' requires a numerical argument." + Environment.NewLine + "Please add an argument by following the tag" + Environment.NewLine + "with a ':' and a number.", charData); DialogResult result = errorHandler.ShowDialog(); if (result == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandler.GetCorrectedData(); ProofReadTagstoCodes(); return; } } break; #endregion #region Seven-Byte Codes case "scale": if (tagArgs.Length > 1) { bool tagSafe = CheckTagNumArgs(tagArgs[1], tagArgs[0]); if (tagSafe == false) { return; } code.Add(0x1A); code.Add(0x07); code.Add(0xFF); code.Add(0x00); code.Add((byte)SevenByteTypes.SetTextSize); byte[] tempShort = BitConverter.GetBytes(Convert.ToInt16(tagArgs[1])); code.Add(tempShort[1]); code.Add(tempShort[0]); } else { TagErrorHandler errorHandler = new TagErrorHandler("Missing Argument", "A tag '" + tagArgs[0] + "' requires a numerical argument." + Environment.NewLine + "Please add an argument by following the tag" + Environment.NewLine + "with a ':' and a number.", charData); DialogResult result = errorHandler.ShowDialog(); if (result == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandler.GetCorrectedData(); ProofReadTagstoCodes(); return; } } break; case "wait + dismiss (prompt)": if (tagArgs.Length > 1) { bool tagSafe = CheckTagNumArgs(tagArgs[1], tagArgs[0]); if (tagSafe == false) { return; } code.Add(0x1A); code.Add(0x07); code.Add(0x00); code.Add(0x00); code.Add((byte)SevenByteTypes.WaitAndDismissWithPrompt); byte[] tempShort = BitConverter.GetBytes(Convert.ToInt16(tagArgs[1])); code.Add(tempShort[1]); code.Add(tempShort[0]); } else { TagErrorHandler errorHandler = new TagErrorHandler("Missing Argument", "A tag '" + tagArgs[0] + "' requires a numerical argument." + Environment.NewLine + "Please add an argument by following the tag" + Environment.NewLine + "with a ':' and a number.", charData); DialogResult result = errorHandler.ShowDialog(); if (result == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandler.GetCorrectedData(); ProofReadTagstoCodes(); return; } } break; case "wait + dismiss": if (tagArgs.Length > 1) { bool tagSafe = CheckTagNumArgs(tagArgs[1], tagArgs[0]); if (tagSafe == false) { return; } code.Add(0x1A); code.Add(0x07); code.Add(0x00); code.Add(0x00); code.Add((byte)SevenByteTypes.WaitAndDismiss); byte[] tempShort = BitConverter.GetBytes(Convert.ToInt16(tagArgs[1])); code.Add(tempShort[1]); code.Add(tempShort[0]); } else { TagErrorHandler errorHandler = new TagErrorHandler("Missing Argument", "A tag '" + tagArgs[0] + "' requires a numerical argument." + Environment.NewLine + "Please add an argument by following the tag" + Environment.NewLine + "with a ':' and a number.", charData); DialogResult result = errorHandler.ShowDialog(); if (result == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandler.GetCorrectedData(); ProofReadTagstoCodes(); return; } } break; case "dismiss": if (tagArgs.Length > 1) { bool tagSafe = CheckTagNumArgs(tagArgs[1], tagArgs[0]); if (tagSafe == false) { return; } code.Add(0x1A); code.Add(0x07); code.Add(0x00); code.Add(0x00); code.Add((byte)SevenByteTypes.Dismiss); byte[] tempShort = BitConverter.GetBytes(Convert.ToInt16(tagArgs[1])); code.Add(tempShort[1]); code.Add(tempShort[0]); } else { TagErrorHandler errorHandler = new TagErrorHandler("Missing Argument", "A tag '" + tagArgs[0] + "' requires a numerical argument." + Environment.NewLine + "Please add an argument by following the tag" + Environment.NewLine + "with a ':' and a number.", charData); DialogResult result = errorHandler.ShowDialog(); if (result == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandler.GetCorrectedData(); ProofReadTagstoCodes(); return; } } break; case "dummy": if (tagArgs.Length > 1) { bool tagSafe = CheckTagNumArgs(tagArgs[1], tagArgs[0]); if (tagSafe == false) { return; } code.Add(0x1A); code.Add(0x07); code.Add(0x00); code.Add(0x00); code.Add((byte)SevenByteTypes.Dummy); byte[] tempShort = BitConverter.GetBytes(Convert.ToInt16(tagArgs[1])); code.Add(tempShort[1]); code.Add(tempShort[0]); } else { TagErrorHandler errorHandler = new TagErrorHandler("Missing Argument", "A tag '" + tagArgs[0] + "' requires a numerical argument." + Environment.NewLine + "Please add an argument by following the tag" + Environment.NewLine + "with a ':' and a number.", charData); DialogResult result = errorHandler.ShowDialog(); if (result == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandler.GetCorrectedData(); ProofReadTagstoCodes(); return; } } break; case "wait": if (tagArgs.Length > 1) { bool tagSafe = CheckTagNumArgs(tagArgs[1], tagArgs[0]); if (tagSafe == false) { return; } code.Add(0x1A); code.Add(0x07); code.Add(0x00); code.Add(0x00); code.Add((byte)SevenByteTypes.Wait); byte[] tempShort = BitConverter.GetBytes(Convert.ToInt16(tagArgs[1])); code.Add(tempShort[1]); code.Add(tempShort[0]); } else { TagErrorHandler errorHandler = new TagErrorHandler("Missing Argument", "A tag '" + tagArgs[0] + "' requires a numerical argument." + Environment.NewLine + "Please add an argument by following the tag" + Environment.NewLine + "with a ':' and a number.", charData); DialogResult result = errorHandler.ShowDialog(); if (result == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandler.GetCorrectedData(); ProofReadTagstoCodes(); return; } } break; default: TagErrorHandler errorHandlerDefault = new TagErrorHandler("Unknown Tag", "An unknown tag '" + tagArgs[0] + "' was found." + Environment.NewLine + "Please correct this error.", charData); DialogResult resultDefault = errorHandlerDefault.ShowDialog(); if (resultDefault == DialogResult.OK) { //MessageBox.Show("works"); charData = errorHandlerDefault.GetCorrectedData(); ProofReadTagstoCodes(); return; } return; #endregion } testList.InsertRange((int)(i + tagSize), code.ToArray()); testList.RemoveRange(i, (int)tagSize); i += code.Count - 1; } }