From 5c955ac90781cb5daa33946e52e43e309432e102 Mon Sep 17 00:00:00 2001 From: jeffman Date: Wed, 25 Mar 2015 11:55:09 -0400 Subject: [PATCH] Finish item mapping; add item help collection --- ScriptTool/ScriptTool/Decompiler.cs | 2 +- ScriptTool/ScriptTool/Program.cs | 6 +- ScriptTool/ScriptTool/ScriptTool.csproj | 3 + ScriptTool/ScriptTool/item-map.json | 1038 +++++++++++----------- ScriptTool/ScriptToolGui/IndexMapping.cs | 39 +- ScriptTool/ScriptToolGui/IndexPair.cs | 6 +- ScriptTool/ScriptToolGui/MainForm.cs | 65 +- ScriptTool/ScriptToolGui/MatchedGroup.cs | 13 +- 8 files changed, 609 insertions(+), 563 deletions(-) diff --git a/ScriptTool/ScriptTool/Decompiler.cs b/ScriptTool/ScriptTool/Decompiler.cs index d5a08bf..00f6062 100644 --- a/ScriptTool/ScriptTool/Decompiler.cs +++ b/ScriptTool/ScriptTool/Decompiler.cs @@ -110,7 +110,7 @@ namespace ScriptTool address += code.ComputeLength(rom, address); - /*if (code.IsEnd) + /*if (newLines && code.IsEnd && !suppressNextEnd) { builder.Append("(" + address.ToString("X") + ")"); }*/ diff --git a/ScriptTool/ScriptTool/Program.cs b/ScriptTool/ScriptTool/Program.cs index 18ca9fc..fa6ee46 100644 --- a/ScriptTool/ScriptTool/Program.cs +++ b/ScriptTool/ScriptTool/Program.cs @@ -220,12 +220,12 @@ namespace ScriptTool var tptTuple = M12TextTables.ReadTptRefs(m12Rom); allRefs.Add(Tuple.Create("m12-tpt-primary", tptTuple.Item1)); allRefs.Add(Tuple.Create("m12-tpt-secondary", tptTuple.Item2)); - allRefs.Add(Tuple.Create("m12-psihelp", M12TextTables.ReadPsiHelpRefs(m12Rom))); + allRefs.Add(Tuple.Create("m12-psi-help", M12TextTables.ReadPsiHelpRefs(m12Rom))); allRefs.Add(Tuple.Create("m12-battle-actions", M12TextTables.ReadBattleActionRefs(m12Rom))); - allRefs.Add(Tuple.Create("m12-itemhelp", M12TextTables.ReadItemHelpRefs(m12Rom))); + allRefs.Add(Tuple.Create("m12-item-help", M12TextTables.ReadItemHelpRefs(m12Rom))); allRefs.Add(Tuple.Create("m12-movements", M12TextTables.ReadMovementRefs(m12Rom))); allRefs.Add(Tuple.Create("m12-objects", M12TextTables.ReadObjectRefs(m12Rom))); - allRefs.Add(Tuple.Create("m12-phonelist", M12TextTables.ReadPhoneRefs(m12Rom))); + allRefs.Add(Tuple.Create("m12-phone-list", M12TextTables.ReadPhoneRefs(m12Rom))); allRefs.Add(Tuple.Create("m12-unknown", M12TextTables.ReadUnknownRefs(m12Rom))); allRefs.Add(Tuple.Create("m12-enemy-encounters", M12TextTables.ReadEnemyEncounters(m12Rom))); allRefs.Add(Tuple.Create("m12-prayers", M12TextTables.ReadPrayerRefs(m12Rom))); diff --git a/ScriptTool/ScriptTool/ScriptTool.csproj b/ScriptTool/ScriptTool/ScriptTool.csproj index ffe9800..2defe99 100644 --- a/ScriptTool/ScriptTool/ScriptTool.csproj +++ b/ScriptTool/ScriptTool/ScriptTool.csproj @@ -77,6 +77,9 @@ Always + + Always + Always diff --git a/ScriptTool/ScriptTool/item-map.json b/ScriptTool/ScriptTool/item-map.json index beceb51..10e62f8 100644 --- a/ScriptTool/ScriptTool/item-map.json +++ b/ScriptTool/ScriptTool/item-map.json @@ -1,7 +1,11 @@ [ { - "First": 0, - "Second": 0 + "First": 226, + "Second": 125 + }, + { + "First": 226, + "Second": 240 }, { "First": 1, @@ -16,1011 +20,991 @@ "Second": 176 }, { - "First": 0, - "Second": 0 + "First": 4, + "Second": 227 }, { - "First": 0, - "Second": 0 + "First": 5, + "Second": 228 }, { - "First": 0, - "Second": 0 + "First": 6, + "Second": 229 }, { - "First": 0, - "Second": 0 - }, - { - "First": 0, - "Second": 0 + "First": 7, + "Second": 230 }, { - "First": 0, - "Second": 0 + "First": 8, + "Second": 231 }, { - "First": 0, - "Second": 0 + "First": 9, + "Second": 232 }, { - "First": 0, - "Second": 0 + "First": 10, + "Second": 233 }, { - "First": 0, - "Second": 0 + "First": 11, + "Second": 234 }, { - "First": 0, - "Second": 0 + "First": 12, + "Second": 235 }, { - "First": 0, - "Second": 0 + "First": 13, + "Second": 236 }, { - "First": 0, - "Second": 0 + "First": 14, + "Second": 237 }, { - "First": 0, - "Second": 0 + "First": 15, + "Second": 238 }, { - "First": 0, - "Second": 0 + "First": 16, + "Second": 239 }, { - "First": 0, - "Second": 0 + "First": 17, + "Second": 1 }, { - "First": 0, - "Second": 0 + "First": 18, + "Second": 2 }, { - "First": 0, - "Second": 0 + "First": 19, + "Second": 3 }, { - "First": 0, - "Second": 0 + "First": 20, + "Second": 4 }, { - "First": 0, - "Second": 0 + "First": 21, + "Second": 5 }, { - "First": 0, - "Second": 0 - }, - { - "First": 0, - "Second": 0 + "First": 22, + "Second": 7 }, { - "First": 0, - "Second": 0 + "First": 23, + "Second": 8 }, { - "First": 0, - "Second": 0 + "First": 24, + "Second": 10 }, { - "First": 0, - "Second": 0 + "First": 25, + "Second": 11 }, { - "First": 0, - "Second": 0 + "First": 26, + "Second": 12 }, { - "First": 0, - "Second": 0 + "First": 27, + "Second": 13 }, { - "First": 0, - "Second": 0 + "First": 28, + "Second": 14 }, { - "First": 0, - "Second": 0 + "First": 29, + "Second": 15 }, { - "First": 0, - "Second": 0 + "First": 30, + "Second": 16 }, { - "First": 0, - "Second": 0 + "First": 31, + "Second": 17 }, { - "First": 0, - "Second": 0 + "First": 32, + "Second": 19 }, { - "First": 0, - "Second": 0 + "First": 33, + "Second": 20 }, { - "First": 0, - "Second": 0 + "First": 34, + "Second": 21 }, { - "First": 0, - "Second": 0 + "First": 35, + "Second": 22 }, { - "First": 0, - "Second": 0 + "First": 36, + "Second": 23 }, { - "First": 0, - "Second": 0 - }, - { - "First": 0, - "Second": 0 + "First": 37, + "Second": 24 }, { - "First": 0, - "Second": 0 + "First": 38, + "Second": 25 }, { - "First": 0, - "Second": 0 + "First": 39, + "Second": 26 }, { - "First": 0, - "Second": 0 + "First": 40, + "Second": 27 }, { - "First": 0, - "Second": 0 + "First": 41, + "Second": 28 }, { - "First": 0, - "Second": 0 + "First": 42, + "Second": 29 }, { - "First": 0, - "Second": 0 + "First": 43, + "Second": 31 }, { - "First": 0, - "Second": 0 + "First": 44, + "Second": 32 }, { - "First": 0, - "Second": 0 + "First": 45, + "Second": 34 }, { - "First": 0, - "Second": 0 + "First": 46, + "Second": 33 }, { - "First": 0, - "Second": 0 + "First": 47, + "Second": 35 }, { - "First": 0, - "Second": 0 + "First": 48, + "Second": 36 }, { - "First": 0, - "Second": 0 + "First": 49, + "Second": 37 }, { - "First": 0, - "Second": 0 + "First": 50, + "Second": 38 }, { - "First": 0, - "Second": 0 + "First": 51, + "Second": 39 }, { - "First": 0, - "Second": 0 - }, - { - "First": 0, - "Second": 0 + "First": 52, + "Second": 40 }, { - "First": 0, - "Second": 0 + "First": 53, + "Second": 41 }, { - "First": 0, - "Second": 0 + "First": 54, + "Second": 42 }, { - "First": 0, - "Second": 0 + "First": 55, + "Second": 43 }, { - "First": 0, - "Second": 0 + "First": 56, + "Second": 44 }, { - "First": 0, - "Second": 0 + "First": 57, + "Second": 45 }, { - "First": 0, - "Second": 0 + "First": 58, + "Second": 46 }, { - "First": 0, - "Second": 0 + "First": 59, + "Second": 47 }, { - "First": 0, - "Second": 0 + "First": 60, + "Second": 48 }, { - "First": 0, - "Second": 0 + "First": 61, + "Second": 49 }, { - "First": 0, - "Second": 0 + "First": 62, + "Second": 51 }, { - "First": 0, - "Second": 0 + "First": 63, + "Second": 52 }, { - "First": 0, - "Second": 0 + "First": 64, + "Second": 53 }, { - "First": 0, - "Second": 0 + "First": 65, + "Second": 54 }, { - "First": 0, - "Second": 0 + "First": 66, + "Second": 55 }, { - "First": 0, - "Second": 0 - }, - { - "First": 0, - "Second": 0 + "First": 67, + "Second": 56 }, { - "First": 0, - "Second": 0 + "First": 68, + "Second": 57 }, { - "First": 0, - "Second": 0 + "First": 69, + "Second": 58 }, { - "First": 0, - "Second": 0 + "First": 70, + "Second": 59 }, { - "First": 0, - "Second": 0 + "First": 71, + "Second": 60 }, { - "First": 0, - "Second": 0 + "First": 72, + "Second": 61 }, { - "First": 0, - "Second": 0 + "First": 73, + "Second": 62 }, { - "First": 0, - "Second": 0 + "First": 74, + "Second": 63 }, { - "First": 0, - "Second": 0 + "First": 75, + "Second": 64 }, { - "First": 0, - "Second": 0 + "First": 76, + "Second": 65 }, { - "First": 0, - "Second": 0 + "First": 77, + "Second": 66 }, { - "First": 0, - "Second": 0 + "First": 78, + "Second": 67 }, { - "First": 0, - "Second": 0 + "First": 79, + "Second": 68 }, { - "First": 0, - "Second": 0 + "First": 80, + "Second": 72 }, { - "First": 0, - "Second": 0 + "First": 81, + "Second": 73 }, { - "First": 0, - "Second": 0 + "First": 82, + "Second": 74 }, - { - "First": 0, - "Second": 0 + { + "First": 83, + "Second": 77 }, { - "First": 0, - "Second": 0 + "First": 84, + "Second": 78 }, { - "First": 0, - "Second": 0 + "First": 85, + "Second": 79 }, { - "First": 0, - "Second": 0 + "First": 86, + "Second": 80 }, { - "First": 0, - "Second": 0 + "First": 87, + "Second": 81 }, { - "First": 0, - "Second": 0 + "First": 88, + "Second": 83 }, { - "First": 0, - "Second": 0 + "First": 89, + "Second": 86 }, { - "First": 0, - "Second": 0 + "First": 90, + "Second": 93 }, { - "First": 0, - "Second": 0 + "First": 91, + "Second": 97 }, { - "First": 0, - "Second": 0 + "First": 92, + "Second": 90 }, { - "First": 0, - "Second": 0 + "First": 93, + "Second": 99 }, { - "First": 0, - "Second": 0 + "First": 94, + "Second": 103 }, { - "First": 0, - "Second": 0 + "First": 95, + "Second": 104 }, { - "First": 0, - "Second": 0 + "First": 96, + "Second": 110 }, { - "First": 0, - "Second": 0 + "First": 97, + "Second": 115 }, { - "First": 0, - "Second": 0 + "First": 98, + "Second": 119 }, - { - "First": 0, - "Second": 0 + { + "First": 99, + "Second": 121 }, { - "First": 0, - "Second": 0 + "First": 100, + "Second": 116 }, { - "First": 0, - "Second": 0 + "First": 101, + "Second": 225 }, { - "First": 0, - "Second": 0 + "First": 102, + "Second": 94 }, { - "First": 0, - "Second": 0 + "First": 103, + "Second": 88 }, { - "First": 0, - "Second": 0 + "First": 104, + "Second": 195 }, { - "First": 0, - "Second": 0 + "First": 105, + "Second": 186 }, { - "First": 0, - "Second": 0 + "First": 106, + "Second": 82 }, { - "First": 0, - "Second": 0 + "First": 107, + "Second": 96 }, { - "First": 0, - "Second": 0 + "First": 108, + "Second": 100 }, { - "First": 0, - "Second": 0 + "First": 109, + "Second": 114 }, { - "First": 0, - "Second": 0 + "First": 110, + "Second": 117 }, { - "First": 0, - "Second": 0 + "First": 111, + "Second": 214 }, { - "First": 0, - "Second": 0 + "First": 112, + "Second": 216 }, { - "First": 0, - "Second": 0 + "First": 113, + "Second": 220 }, { - "First": 0, - "Second": 0 + "First": 114, + "Second": 221 }, - { - "First": 0, - "Second": 0 + { + "First": 115, + "Second": 222 }, { - "First": 0, - "Second": 0 + "First": 116, + "Second": 223 }, { - "First": 0, - "Second": 0 + "First": 117, + "Second": 224 }, { - "First": 0, - "Second": 0 + "First": 118, + "Second": 127 }, { - "First": 0, - "Second": 0 + "First": 119, + "Second": 128 }, { - "First": 0, - "Second": 0 + "First": 120, + "Second": 132 }, { - "First": 0, - "Second": 0 + "First": 121, + "Second": 129 }, { - "First": 0, - "Second": 0 + "First": 122, + "Second": 126 }, { - "First": 0, - "Second": 0 + "First": 123, + "Second": 131 }, { - "First": 0, - "Second": 0 + "First": 124, + "Second": 130 }, { - "First": 0, - "Second": 0 + "First": 125, + "Second": 188 }, { - "First": 0, - "Second": 0 + "First": 126, + "Second": 133 }, { - "First": 0, - "Second": 0 + "First": 127, + "Second": 215 }, { - "First": 0, - "Second": 0 + "First": 128, + "Second": 217 }, { - "First": 0, - "Second": 0 + "First": 129, + "Second": 218 }, { - "First": 0, - "Second": 0 + "First": 130, + "Second": 219 }, - { - "First": 0, - "Second": 0 + { + "First": 131, + "Second": 135 }, { - "First": 0, - "Second": 0 + "First": 132, + "Second": 158 }, { - "First": 0, - "Second": 0 + "First": 133, + "Second": 187 }, { - "First": 0, - "Second": 0 + "First": 134, + "Second": 163 }, { - "First": 0, - "Second": 0 + "First": 135, + "Second": 173 }, { - "First": 0, - "Second": 0 + "First": 136, + "Second": 162 }, { - "First": 0, - "Second": 0 + "First": 137, + "Second": 161 }, { - "First": 0, - "Second": 0 + "First": 138, + "Second": 185 }, { - "First": 0, - "Second": 0 + "First": 139, + "Second": 146 }, { - "First": 0, - "Second": 0 + "First": 140, + "Second": 211 }, { - "First": 0, - "Second": 0 + "First": 141, + "Second": 201 }, { - "First": 0, - "Second": 0 + "First": 142, + "Second": 207 }, { - "First": 0, - "Second": 0 + "First": 143, + "Second": 198 }, { - "First": 0, - "Second": 0 + "First": 144, + "Second": 202 }, { - "First": 0, - "Second": 0 + "First": 145, + "Second": 203 }, { - "First": 0, - "Second": 0 + "First": 146, + "Second": 204 }, - { - "First": 0, - "Second": 0 + { + "First": 147, + "Second": 205 }, { - "First": 0, - "Second": 0 + "First": 148, + "Second": 164 }, { - "First": 0, - "Second": 0 + "First": 149, + "Second": 153 }, { - "First": 0, - "Second": 0 + "First": 150, + "Second": 155 }, { - "First": 0, - "Second": 0 + "First": 151, + "Second": 156 }, { - "First": 0, - "Second": 0 + "First": 152, + "Second": 199 }, { - "First": 0, - "Second": 0 + "First": 153, + "Second": 148 }, { - "First": 0, - "Second": 0 + "First": 154, + "Second": 189 }, { - "First": 0, - "Second": 0 + "First": 155, + "Second": 191 }, { - "First": 0, - "Second": 0 + "First": 156, + "Second": 194 }, { - "First": 0, - "Second": 0 + "First": 157, + "Second": 177 }, { - "First": 0, - "Second": 0 + "First": 158, + "Second": 246 }, { - "First": 0, - "Second": 0 + "First": 159, + "Second": 138 }, { - "First": 0, - "Second": 0 + "First": 160, + "Second": 182 }, { - "First": 0, - "Second": 0 + "First": 161, + "Second": 178 }, { - "First": 0, - "Second": 0 + "First": 162, + "Second": 196 }, - { - "First": 0, - "Second": 0 + { + "First": 163, + "Second": 179 }, { - "First": 0, - "Second": 0 + "First": 164, + "Second": 208 }, { - "First": 0, - "Second": 0 + "First": 165, + "Second": 141 }, { - "First": 0, - "Second": 0 + "First": 166, + "Second": 144 }, { - "First": 0, - "Second": 0 + "First": 167, + "Second": 247 }, { - "First": 0, - "Second": 0 + "First": 168, + "Second": 193 }, { - "First": 0, - "Second": 0 + "First": 169, + "Second": 183 }, { - "First": 0, - "Second": 0 + "First": 170, + "Second": 170 }, { - "First": 0, - "Second": 0 + "First": 171, + "Second": 212 }, { - "First": 0, - "Second": 0 + "First": 172, + "Second": 175 }, { - "First": 0, - "Second": 0 + "First": 174, + "Second": 165 }, { - "First": 0, - "Second": 0 + "First": 175, + "Second": 168 }, { - "First": 0, - "Second": 0 + "First": 176, + "Second": 159 }, { - "First": 0, - "Second": 0 + "First": 177, + "Second": 143 }, { - "First": 0, - "Second": 0 + "First": 178, + "Second": 172 }, { - "First": 0, - "Second": 0 + "First": 179, + "Second": 248 }, - { - "First": 0, - "Second": 0 + { + "First": 180, + "Second": 152 }, { - "First": 0, - "Second": 0 + "First": 181, + "Second": 160 }, { - "First": 0, - "Second": 0 + "First": 182, + "Second": 167 }, { - "First": 0, - "Second": 0 + "First": 183, + "Second": 151 }, { - "First": 0, - "Second": 0 + "First": 184, + "Second": 169 }, { - "First": 0, - "Second": 0 + "First": 185, + "Second": 192 }, { - "First": 0, - "Second": 0 + "First": 186, + "Second": 209 }, { - "First": 0, - "Second": 0 + "First": 187, + "Second": 150 }, { - "First": 0, - "Second": 0 + "First": 188, + "Second": 190 }, { - "First": 0, - "Second": 0 + "First": 189, + "Second": 136 }, { - "First": 0, - "Second": 0 + "First": 190, + "Second": 226 }, { - "First": 0, - "Second": 0 + "First": 191, + "Second": 95 }, { - "First": 0, - "Second": 0 + "First": 192, + "Second": 180 }, { - "First": 0, - "Second": 0 + "First": 193, + "Second": 139 }, { - "First": 0, - "Second": 0 + "First": 194, + "Second": 50 }, { - "First": 0, - "Second": 0 + "First": 195, + "Second": 174 }, - { - "First": 0, - "Second": 0 + { + "First": 196, + "Second": 142 }, { - "First": 0, - "Second": 0 + "First": 197, + "Second": 134 }, { - "First": 0, - "Second": 0 + "First": 198, + "Second": 89 }, { - "First": 0, - "Second": 0 + "First": 199, + "Second": 200 }, { - "First": 0, - "Second": 0 + "First": 200, + "Second": 181 }, { - "First": 0, - "Second": 0 + "First": 201, + "Second": 154 }, { - "First": 0, - "Second": 0 + "First": 202, + "Second": 206 }, { - "First": 0, - "Second": 0 + "First": 204, + "Second": 147 }, { - "First": 0, - "Second": 0 + "First": 205, + "Second": 213 }, { - "First": 0, - "Second": 0 + "First": 206, + "Second": 166 }, { - "First": 0, - "Second": 0 + "First": 207, + "Second": 120 }, { - "First": 0, - "Second": 0 + "First": 208, + "Second": 171 }, { - "First": 0, - "Second": 0 + "First": 209, + "Second": 157 }, { - "First": 0, - "Second": 0 + "First": 210, + "Second": 149 }, { - "First": 0, - "Second": 0 + "First": 211, + "Second": 145 }, { - "First": 0, - "Second": 0 + "First": 212, + "Second": 6 }, - { - "First": 0, - "Second": 0 + { + "First": 213, + "Second": 249 }, { - "First": 0, - "Second": 0 + "First": 214, + "Second": 9 }, { - "First": 0, - "Second": 0 + "First": 215, + "Second": 30 }, { - "First": 0, - "Second": 0 + "First": 216, + "Second": 250 }, { - "First": 0, - "Second": 0 + "First": 217, + "Second": 251 }, { - "First": 0, - "Second": 0 + "First": 218, + "Second": 69 }, { - "First": 0, - "Second": 0 + "First": 219, + "Second": 70 }, { - "First": 0, - "Second": 0 + "First": 220, + "Second": 71 }, { - "First": 0, - "Second": 0 + "First": 221, + "Second": 75 }, { - "First": 0, - "Second": 0 + "First": 222, + "Second": 252 }, { - "First": 0, - "Second": 0 + "First": 223, + "Second": 92 }, { - "First": 0, - "Second": 0 + "First": 224, + "Second": 123 }, { - "First": 0, - "Second": 0 + "First": 225, + "Second": 124 }, { - "First": 0, - "Second": 0 + "First": 227, + "Second": 241 }, { - "First": 0, - "Second": 0 + "First": 228, + "Second": 242 }, { - "First": 0, - "Second": 0 + "First": 229, + "Second": 243 }, - { - "First": 0, - "Second": 0 + { + "First": 230, + "Second": 244 }, { - "First": 0, - "Second": 0 + "First": 231, + "Second": 245 }, { - "First": 0, - "Second": 0 + "First": 232, + "Second": 84 }, { - "First": 0, - "Second": 0 + "First": 233, + "Second": 101 }, { - "First": 0, - "Second": 0 + "First": 234, + "Second": 102 }, { - "First": 0, - "Second": 0 + "First": 235, + "Second": 113 }, { - "First": 0, - "Second": 0 + "First": 236, + "Second": 109 }, { - "First": 0, - "Second": 0 + "First": 237, + "Second": 91 }, { - "First": 0, - "Second": 0 + "First": 238, + "Second": 98 }, { - "First": 0, - "Second": 0 + "First": 239, + "Second": 87 }, { - "First": 0, - "Second": 0 + "First": 240, + "Second": 105 }, { - "First": 0, - "Second": 0 + "First": 241, + "Second": 107 }, { - "First": 0, - "Second": 0 + "First": 242, + "Second": 106 }, { - "First": 0, - "Second": 0 + "First": 243, + "Second": 108 }, { - "First": 0, - "Second": 0 + "First": 244, + "Second": 111 }, { - "First": 0, - "Second": 0 + "First": 245, + "Second": 112 }, - { - "First": 0, - "Second": 0 + { + "First": 246, + "Second": 118 }, { - "First": 0, - "Second": 0 + "First": 247, + "Second": 122 }, { - "First": 0, - "Second": 0 + "First": 248, + "Second": 18 }, { - "First": 0, - "Second": 0 + "First": 249, + "Second": 76 }, { - "First": 0, - "Second": 0 + "First": 250, + "Second": 210 }, { - "First": 0, - "Second": 0 + "First": 251, + "Second": 85 }, { - "First": 0, - "Second": 0 + "First": 252, + "Second": 137 }, { - "First": 0, - "Second": 0 + "First": 253, + "Second": 140 } ] \ No newline at end of file diff --git a/ScriptTool/ScriptToolGui/IndexMapping.cs b/ScriptTool/ScriptToolGui/IndexMapping.cs index b83de73..396700b 100644 --- a/ScriptTool/ScriptToolGui/IndexMapping.cs +++ b/ScriptTool/ScriptToolGui/IndexMapping.cs @@ -6,9 +6,9 @@ using System.Threading.Tasks; namespace ScriptToolGui { - class IndexMapping : IEnumerable + class IndexMapping : IEnumerable, ICollection { - public IList Pairs { get; private set; } + public ICollection Pairs { get; private set; } public IndexMapping() { @@ -29,5 +29,40 @@ namespace ScriptToolGui { return GetEnumerator(); } + + public void Add(IndexPair item) + { + Pairs.Add(item); + } + + public void Clear() + { + Pairs.Clear(); + } + + public bool Contains(IndexPair item) + { + return Pairs.Contains(item); + } + + public void CopyTo(IndexPair[] array, int arrayIndex) + { + Pairs.CopyTo(array, arrayIndex); + } + + public int Count + { + get { return Pairs.Count; } + } + + public bool IsReadOnly + { + get { return Pairs.IsReadOnly; } + } + + public bool Remove(IndexPair item) + { + return Pairs.Remove(item); + } } } diff --git a/ScriptTool/ScriptToolGui/IndexPair.cs b/ScriptTool/ScriptToolGui/IndexPair.cs index 43781a9..1d55527 100644 --- a/ScriptTool/ScriptToolGui/IndexPair.cs +++ b/ScriptTool/ScriptToolGui/IndexPair.cs @@ -6,10 +6,10 @@ using System.Threading.Tasks; namespace ScriptToolGui { - struct IndexPair + class IndexPair { - public readonly int First; - public readonly int Second; + public int First { get; private set; } + public int Second { get; private set; } public IndexPair(int first, int second) { diff --git a/ScriptTool/ScriptToolGui/MainForm.cs b/ScriptTool/ScriptToolGui/MainForm.cs index dc01b7e..95598d8 100644 --- a/ScriptTool/ScriptToolGui/MainForm.cs +++ b/ScriptTool/ScriptToolGui/MainForm.cs @@ -41,6 +41,7 @@ namespace ScriptToolGui // Matched reference pairs MatchedGroupCollection tptGroups = new MatchedGroupCollection("TPT"); MatchedGroupCollection battleActionGroups = new MatchedGroupCollection("Battle actions"); + MatchedGroupCollection itemHelpGroups = new MatchedGroupCollection("Item help"); List matchedGroups = new List(); IList matchedCollections = new List(); @@ -48,6 +49,7 @@ namespace ScriptToolGui IDictionary currentIndex; NavigationEntry previousNavigationState = null; Stack navigationStack = new Stack(); + MatchedGroupCollection currentCollection = null; static MainForm() { @@ -55,11 +57,21 @@ namespace ScriptToolGui ebCharLookup = JsonConvert.DeserializeObject>(File.ReadAllText("eb-char-lookup.json")); } + string ReadEbString(byte[] rom, int address, int length) + { + var sb = new StringBuilder(); + for(int i=0;i g1.Index.CompareTo(g2.Index)); - + tptGroups.Groups.Sort((g1, g2) => g1.Refs[Game.Eb].Index.CompareTo(g2.Refs[Game.Eb].Index)); matchedGroups.AddRange(tptGroups); // Battle actions - var m12BattleActionRefs = ImportStringRefs(Path.Combine(folder, "m12-battle-actions.json")); - var ebBattleActionRefs = ImportStringRefs(Path.Combine(folder, "eb-battle-actions.json")); + var m12BattleActionRefs = ImportStringRefs("m12-battle-actions.json"); + var ebBattleActionRefs = ImportStringRefs("eb-battle-actions.json"); battleActionGroups.Groups.AddRange(MatchRefs(ebBattleActionRefs, m12BattleActionRefs)); - battleActionGroups.Groups.Sort((g1, g2) => g1.Index.CompareTo(g2.Index)); - + battleActionGroups.Groups.Sort((g1, g2) => g1.Refs[Game.Eb].Index.CompareTo(g2.Refs[Game.Eb].Index)); matchedGroups.AddRange(battleActionGroups); // Item help + itemMapping = JsonConvert.DeserializeObject(File.ReadAllText("item-map.json")); + var m12ItemHelpRefs = ImportStringRefs("m12-item-help.json"); + var ebItemHelpRefs = ImportStringRefs("eb-item-help.json"); + var itemHelpMappingGroups = itemMapping.Select(p => new MatchedGroup( + ebItemHelpRefs.First(e => e.Index == p.First), + m12ItemHelpRefs.First(m => m.Index == p.Second), + m12ItemHelpRefs.First(m => m.Index == p.Second))) + .OrderBy(g => g.Refs[Game.Eb].Index) + .ToArray(); + + itemHelpGroups.Groups.AddRange(itemHelpMappingGroups); + matchedGroups.AddRange(itemHelpGroups); + + matchedGroups.Sort((g1, g2) => g1.Refs[Game.Eb].Index.CompareTo(g2.Refs[Game.Eb].Index)); - matchedGroups.Sort((g1, g2) => g1.Index.CompareTo(g2.Index)); matchedCollections.Add(tptGroups); matchedCollections.Add(battleActionGroups); + matchedCollections.Add(itemHelpGroups); } private MatchedGroup[] MatchRefs(MainStringRef[] ebRefs, MainStringRef[] m12Refs) { - return ebRefs.Join(m12Refs, e => e.Index, m => m.Index, (e, m) => new { e, m }) + return ebRefs.Join(m12Refs, e => e.Index, m => m.Index, + (e, m) => new { e, m }) .Select(p => new MatchedGroup(p.e, p.m, p.m)) .ToArray(); } private MainStringRef[] ImportStringRefs(string fileName) { - string jsonString = File.ReadAllText(fileName); + string jsonString = File.ReadAllText(Path.Combine(workingFolder, fileName)); return JsonConvert.DeserializeObject(jsonString); } @@ -499,6 +523,13 @@ namespace ScriptToolGui else { var collection = (MatchedGroupCollection)collectionSelector.SelectedItem; + + // Take no action if we haven't actually changed the collection + // (otherwise, the group selector would jump to 0, probably unwanted) + if (collection == currentCollection) + return; + + currentCollection = collection; PopulateGroupSelector(collection); groupSelector.SelectedIndex = 0; diff --git a/ScriptTool/ScriptToolGui/MatchedGroup.cs b/ScriptTool/ScriptToolGui/MatchedGroup.cs index a4f78d5..c8bb213 100644 --- a/ScriptTool/ScriptToolGui/MatchedGroup.cs +++ b/ScriptTool/ScriptToolGui/MatchedGroup.cs @@ -10,7 +10,6 @@ namespace ScriptToolGui class MatchedGroup { public IDictionary Refs { get; private set; } - public int Index { get; private set; } public MatchedGroup() { @@ -20,22 +19,16 @@ namespace ScriptToolGui public MatchedGroup(MainStringRef ebRef, MainStringRef m12Ref, MainStringRef m12EnglishRef) : this() { - if (ebRef.Index != m12Ref.Index) - { - - } - Refs.Add(Game.Eb, ebRef); Refs.Add(Game.M12, m12Ref); Refs.Add(Game.M12English, m12EnglishRef); - - Index = ebRef.Index; } public override string ToString() { - return String.Format("[{0:X3}] EB: {1} / M12: {2}", Index.ToString("X3"), - Refs[Game.Eb].Label, Refs[Game.M12].Label); + return String.Format("[{0:X3}] EB: {1} / [{2:X3}] M12: {3}", + Refs[Game.Eb].Index, Refs[Game.Eb].Label, + Refs[Game.M12].Index, Refs[Game.M12].Label); } } }