@@ -19,47 +19,45 @@ namespace NSMB_Randomiser
19
19
{
20
20
public partial class EditorForm : Form
21
21
{
22
+ public EditorForm ( )
23
+ {
24
+ InitializeComponent ( ) ;
25
+ }
22
26
23
27
//Variables, lists and whatever
24
28
private decimal currentSetSeed ;
25
29
private string overlayFilePath ;
26
- private long overlayFileLength = 0 ;
30
+ private long overlayFileSize = 0 ;
27
31
private int [ ] dataNodesWorldOffsets = new int [ 8 ] { 111092 , 111320 , 110204 , 110636 , 112068 , 111560 , 110420 , 110864 } ;
28
32
private int [ ] nodesPerWorld = new int [ 8 ] { 19 , 20 , 18 , 19 , 24 , 20 , 18 , 17 } ;
29
33
private int [ ] [ ] worldNodesAreas = new int [ 8 ] [ ] ;
30
34
31
35
private int [ ] secretExitNodesAreas = { 3 , 14 , 26 , 28 , 34 , 46 , 58 , 66 , 80 , 89 , 99 , 96 , 144 , 134 , 135 , 138 } ;
32
- private int [ ] secretExitAreasHexPos = { 111120 , 111144 , 111360 , 111372 , 111468 , 110256 , 110304 , 110652 , 110736 , 112108 , 112168 , 112264 , 110448 , 110496 , 110508 , 110616 } ;
36
+ private int [ ] secretExitAreasHexPos = { 111120 , 111144 , 111360 , 111372 , 111468 , 110256 , 110304 , 110652 , 110736 , 112108 , 112168 , 112264 , 110448 , 110496 , 110508 , 110616 } ;
33
37
34
- private int [ ] normalExitNodesAreas = { 0 , 6 , 7 , 10 , 17 , 12 , 21 , 24 , 37 , 30 , 32 , 40 , 44 , 61 , 48 , 63 , 51 , 54 , 56 , 67 , 69 , 83 , 71 , 73 , 76 , 85 , 78 , 88 , 102 , 91 , 93 , 104 , 94 , 97 , 107 , 109 , 122 , 111 , 113 , 124 , 114 , 116 , 126 , 119 , 121 , 129 , 130 , 132 , 147 , 141 , 142 , 149 , 151 , 153 , 167 , 156 , 158 , 171 , 160 , 162 , 164 , 165 , 169 , 173 } ;
35
- private int [ ] normalExitAreasHexPos = { 111108 , 111132 , 111156 , 111168 , 111180 , 111240 , 111336 , 111348 , 111384 , 111408 , 111432 , 111444 , 110232 , 110268 , 110292 , 110328 , 110340 , 110364 , 110388 , 110664 , 110676 , 110688 , 110712 , 110748 , 110760 , 110772 , 110808 , 112084 , 112132 , 112156 , 112192 , 112204 , 112228 , 112288 , 111588 , 111612 , 111624 , 111636 , 111648 , 111660 , 111684 , 111696 , 111708 , 111720 , 111792 , 110436 , 110460 , 110472 , 110484 , 110628 , 110520 , 110544 , 110880 , 110892 , 110904 , 110916 , 110928 , 110940 , 110952 , 110964 , 110976 , 110988 , 111000 , 111012 } ;
36
-
38
+ private int [ ] normalExitNodesAreas = { 0 , 6 , 7 , 10 , 17 , 12 , 21 , 24 , 37 , 30 , 32 , 40 , 44 , 61 , 48 , 63 , 51 , 54 , 56 , 67 , 69 , 83 , 71 , 73 , 76 , 85 , 78 , 88 , 102 , 91 , 93 , 104 , 94 , 97 , 107 , 109 , 122 , 111 , 113 , 124 , 114 , 116 , 126 , 119 , 121 , 129 , 130 , 132 , 147 , 141 , 142 , 149 , 151 , 153 , 167 , 156 , 158 , 171 , 160 , 162 , 164 , 165 , 169 , 173 } ;
39
+ private int [ ] normalExitAreasHexPos = { 111108 , 111132 , 111156 , 111168 , 111180 , 111240 , 111336 , 111348 , 111384 , 111408 , 111432 , 111444 , 110232 , 110268 , 110292 , 110328 , 110340 , 110364 , 110388 , 110664 , 110676 , 110688 , 110712 , 110748 , 110760 , 110772 , 110808 , 112084 , 112132 , 112156 , 112192 , 112204 , 112228 , 112288 , 111588 , 111612 , 111624 , 111636 , 111648 , 111660 , 111684 , 111696 , 111708 , 111720 , 111792 , 110436 , 110460 , 110472 , 110484 , 110628 , 110520 , 110544 , 110880 , 110892 , 110904 , 110916 , 110928 , 110940 , 110952 , 110964 , 110976 , 110988 , 111000 , 111012 } ;
37
40
//-----------------------------
38
- public EditorForm ( )
39
- {
40
- InitializeComponent ( ) ;
41
- }
42
- private void ofdButton_Click ( object sender , EventArgs e )
41
+ private void OpenButtonClicked ( object sender , EventArgs e )
43
42
{ ;
44
- #region ofd settings
43
+ #region OpenFileDialog settings
45
44
OpenFileDialog ofd = new OpenFileDialog ( ) ;
46
45
ofd . FileName = "overlay9_8.bin" ;
47
46
ofd . Filter = "Binary Files|*.bin|All Files|*.*" ;
48
47
ofd . Title = "Open overlay9_8" ;
49
48
#endregion
50
49
51
- //Runs Windows File Dialog to select your overlay9_8 file
52
- Console . WriteLine ( "Opening Windows File Dialog..." ) ;
53
- DialogResult ofdResult = ofd . ShowDialog ( ) ;
50
+ //Console.WriteLine("Opening Windows File Dialog...");
51
+ DialogResult ofdResult = ofd . ShowDialog ( ) ; //Runs Windows File Dialog to select your overlay9_8 file
54
52
overlayFilePath = ofd . FileName ;
55
53
try
56
54
{
57
- overlayFileLength = new FileInfo ( overlayFilePath ) . Length ;
55
+ overlayFileSize = new FileInfo ( overlayFilePath ) . Length ;
58
56
}
59
57
catch { }
60
- if ( ofdResult == DialogResult . OK && overlayFileLength == 139360 )
58
+ if ( ofdResult == DialogResult . OK && overlayFileSize == 139360 )
61
59
{
62
- Console . WriteLine ( "Overlay filepath saved successfully!" ) ;
60
+ // Console.WriteLine("Overlay filepath saved successfully!");
63
61
ofdButton . Enabled = false ;
64
62
try
65
63
{
@@ -82,21 +80,25 @@ private void ofdButton_Click(object sender, EventArgs e)
82
80
}
83
81
84
82
}
85
- else if ( ofdResult == DialogResult . Cancel ) { Console . WriteLine ( "Please select a file!" ) ; }
86
- else
83
+ else if ( ofdResult == DialogResult . Cancel )
87
84
{
88
- Console . WriteLine ( "This Overlay file has been modified, is corrupted or is not an Overlay file at all. Please make sure you grab a freshly extracted one from your ROM!" ) ;
85
+ //Console.WriteLine("Please select a file!");
86
+ }
87
+ else
88
+ {
89
+ //Console.WriteLine("This Overlay file has been modified, is corrupted or is not an Overlay file at all. Please make sure you grab a freshly extracted one from your ROM!");
90
+ MessageBox . Show ( "This Overlay file has been modified, is corrupted or is not an Overlay file at all. Please make sure you grab a freshly extracted one from your NTSC-U ROM." , "Error" ) ;
89
91
}
90
92
}
91
93
92
- //Most of this code was used to find all the hex positions and area ID locations
93
- #region readOverlay code, unneeded
94
- /*
94
+ /// <summary>
95
+ /// Most of this code was used to find all the hex positions and area ID locations. Left it for reference, obsolete now
96
+ /// </summary>
97
+ [ Obsolete ]
95
98
private void readOverlay ( )
96
99
{
97
100
98
101
#region long ass manual (working) way to do it
99
-
100
102
worldNodesAreas [ 0 ] = new int [ 19 ] ;
101
103
worldNodesAreas [ 1 ] = new int [ 20 ] ;
102
104
worldNodesAreas [ 2 ] = new int [ 18 ] ;
@@ -105,16 +107,13 @@ private void readOverlay()
105
107
worldNodesAreas [ 5 ] = new int [ 20 ] ;
106
108
worldNodesAreas [ 6 ] = new int [ 18 ] ;
107
109
worldNodesAreas [ 7 ] = new int [ 17 ] ;
108
-
109
110
#endregion
110
111
111
112
#region cool (broken) way to do it
112
-
113
113
//for (int i = 0; i < 8; i++)
114
114
//{
115
115
// worldNodesAreas[i] = new nodesPerWorld[i];
116
116
//}
117
-
118
117
#endregion
119
118
120
119
BinaryReader br = new BinaryReader ( File . Open ( "Temp/overlay9_8.tmp" , FileMode . Open ) ) ;
@@ -148,27 +147,24 @@ private void readOverlay()
148
147
catch
149
148
{
150
149
ofdButton . Enabled = true ;
151
- Console.WriteLine ("Failed to read the overlay file's data.");
150
+ MessageBox . Show ( "Failed to read the overlay file's data." , "Error ") ;
152
151
}
153
152
br . Close ( ) ;
154
153
}
155
- */
156
- #endregion
157
- //
158
154
159
- private void goButton_Click ( object sender , EventArgs e )
155
+ private void GoButtonClicked ( object sender , EventArgs e )
160
156
{
161
157
//Check whether the seed check box is ticked or not, and if it is use the seed entered in that checkbox
162
158
if ( seedCheckBox . Checked )
163
159
{
164
160
currentSetSeed = seedNumericBox . Value ;
165
- Console . WriteLine ( "Proceeding with seed: {0}" , currentSetSeed ) ;
161
+ // Console.WriteLine("Proceeding with seed: {0}", currentSetSeed);
166
162
}
167
163
else if ( ! seedCheckBox . Checked )
168
164
{
169
165
Random tempRand = new Random ( ) ;
170
166
currentSetSeed = tempRand . Next ( ) ;
171
- Console . WriteLine ( "Proceeding with random seed: {0}" , currentSetSeed ) ;
167
+ // Console.WriteLine("Proceeding with random seed: {0}", currentSetSeed);
172
168
}
173
169
else { }
174
170
goButton . Enabled = false ;
@@ -180,15 +176,14 @@ private void goButton_Click(object sender, EventArgs e)
180
176
int [ ] randomisedNormalExAreas = normalExitNodesAreas . OrderBy ( x => rand . Next ( ) ) . ToArray ( ) ;
181
177
//Write everything to the file
182
178
BinaryWriter bw = new BinaryWriter ( File . Open ( "Temp/overlay9_8.tmp" , FileMode . Open , FileAccess . Write ) ) ;
183
-
184
- Console . WriteLine ( "Writing randomized normal exits to the file..." ) ;
179
+ //Console.WriteLine("Writing randomized normal exits to the file...");
185
180
for ( int i = 0 ; i < 64 ; i ++ )
186
181
{
187
182
bw . Seek ( normalExitAreasHexPos [ i ] , 0 ) ;
188
183
189
184
bw . Write ( ( byte ) randomisedNormalExAreas [ i ] ) ;
190
185
}
191
- Console . WriteLine ( "Writing randomized secret exits to the file..." ) ;
186
+ // Console.WriteLine("Writing randomized secret exits to the file...");
192
187
for ( int i = 0 ; i < 16 ; i ++ )
193
188
{
194
189
bw . Seek ( secretExitAreasHexPos [ i ] , 0 ) ;
@@ -206,17 +201,27 @@ private void goButton_Click(object sender, EventArgs e)
206
201
File . Copy ( "Temp/overlay9_8.tmp" , "Out/overlay9_8.bin" , true ) ;
207
202
File . Delete ( "Temp/overlay9_8.tmp" ) ;
208
203
Directory . Delete ( "Temp" ) ;
209
- Console . WriteLine ( "All done! Find your randomized file in the Out folder!" ) ;
210
- MessageBox . Show ( "All done! Find your randomized file in the Out folder!" ) ;
204
+ //Console.WriteLine("All done! Find your randomized file in the Out folder!");
205
+ string [ ] seed = new string [ ] { currentSetSeed . ToString ( ) } ;
206
+ File . WriteAllLines ( "Out/seed.txt" , seed ) ;
207
+ MessageBox . Show ( "All done! Find your randomized file in the \" Out\" folder, and the seed that was used in the seed.txt!" , "Success!" ) ;
211
208
Application . Exit ( ) ;
212
209
213
210
}
214
- catch { Console . WriteLine ( "FAILED TO COPY RANDOMISED FILE, ABORT" ) ; Application . Exit ( ) ; }
211
+ catch
212
+ {
213
+ MessageBox . Show ( "Failed to copy randomized file, aborted" , "Critical Error!" ) ;
214
+ Application . Exit ( ) ;
215
+ }
215
216
}
216
- catch { Console . WriteLine ( "FAILED TO CREATE OUT DIRECTORY, ABORT" ) ; Application . Exit ( ) ; } ;
217
+ catch
218
+ {
219
+ MessageBox . Show ( "Failed to create out directory, aborted" , "Critical Error!" ) ;
220
+ Application . Exit ( ) ;
221
+ } ;
217
222
}
218
223
219
- private void seedCheckBox_CheckedChanged ( object sender , EventArgs e )
224
+ private void SeedBoxCheckChanged ( object sender , EventArgs e )
220
225
{
221
226
222
227
if ( seedCheckBox . Checked )
@@ -234,10 +239,9 @@ private void seedCheckBox_CheckedChanged(object sender, EventArgs e)
234
239
235
240
}
236
241
237
- private void EditorForm_Load ( object sender , EventArgs e )
242
+ private void EditorFormLoaded ( object sender , EventArgs e )
238
243
{
239
- Console . WriteLine ( "Randomizer window has loaded successfully!" ) ;
240
-
244
+ //Console.WriteLine("Randomizer window has loaded successfully!");
241
245
}
242
246
}
243
247
}
0 commit comments