Skip to content

Commit 766b8cb

Browse files
committed
Embedded ups binary and mother3.ups file. Both macOS and Windows versions now work. Updated README.md
1 parent b142478 commit 766b8cb

34 files changed

+393
-97
lines changed

Mother3Patcher.WPF/MainWindow.xaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
</Grid.RowDefinitions>
2121
<Image Grid.Row="0" Grid.ColumnSpan="2" Source="/Resources/banner.jpg" Margin="10,10,10,10" x:Name="imageBox"/>
2222
<Label Content="MOTHER 3 ROM:" Padding="10,0" Grid.Row="1"/>
23-
<TextBox Grid.Row="2" Margin="10,5,5,5"></TextBox>
24-
<Button Grid.Row="2" Grid.Column="1" Margin="5,5,10,5" x:Name="browseButton" Content="Browse..."></Button>
25-
<CheckBox Grid.Row="3" Margin="10,5,5,5" x:Name="backupChecked"></CheckBox>
23+
<TextBox Grid.Row="2" Margin="10,5,5,5" x:Name="fileBox"></TextBox>
24+
<Button Grid.Row="2" Grid.Column="1" Margin="5,5,10,5" x:Name="browseButton" Content="Browse..." Click="browseButton_Click"></Button>
25+
<CheckBox Grid.Row="3" Margin="10,5,5,5" x:Name="backupChecked" IsChecked="True"></CheckBox>
2626
<Label Content="Make a backup copy" Padding="10,0" Grid.Row="3" Margin="20,4,5,5"/>
27-
<Button Grid.Row="3" Grid.Column="1" Content="Apply Patch!" Margin="5,0,10,5" x:Name="applyButton"></Button>
27+
<Button Grid.Row="3" Grid.Column="1" Content="Apply Patch!" Margin="5,0,10,5" x:Name="applyButton" Click="applyButton_Click"></Button>
2828
</Grid>
2929
</StackPanel>
3030
</Window>

Mother3Patcher.WPF/MainWindow.xaml.cs

+91
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
using System.Windows.Media.Imaging;
1313
using System.Windows.Navigation;
1414
using System.Windows.Shapes;
15+
using System.IO;
16+
using Microsoft.Win32;
17+
using System.Diagnostics;
18+
using System.Resources;
19+
using Microsoft.VisualBasic;
1520

1621
namespace Mother3Patcher.WPF
1722
{
@@ -24,5 +29,91 @@ public MainWindow()
2429
{
2530
InitializeComponent();
2631
}
32+
33+
private void browseButton_Click(object sender, RoutedEventArgs e)
34+
{
35+
OpenFileDialog openFileDialog = new OpenFileDialog();
36+
openFileDialog.Filter = "GBA ROM files (*.gba)|*.gba|All files (*.*)|*.*";
37+
openFileDialog.InitialDirectory = Directory.GetCurrentDirectory();
38+
if (openFileDialog.ShowDialog() == true)
39+
{
40+
fileBox.Text = openFileDialog.FileName;
41+
}
42+
43+
}
44+
45+
private void applyButton_Click(object sender, RoutedEventArgs e)
46+
{
47+
48+
if (backupChecked.IsChecked == true)
49+
{
50+
51+
using (Process process = new Process { })
52+
{
53+
54+
process.StartInfo = new ProcessStartInfo
55+
{
56+
57+
58+
FileName = "CMD.exe",
59+
Arguments = String.Format("/C copy /b \"{0}\" \"{0}.bak\"", fileBox.Text)
60+
61+
};
62+
//Start the process
63+
process.Start();
64+
//Wait until the process is done
65+
process.WaitForExit();
66+
//Dispose the process
67+
process.Dispose();
68+
//Repeat
69+
}
70+
}
71+
72+
string tempExeName = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "ups.exe");
73+
string tempUpsName = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "mother3.ups");
74+
75+
76+
using (FileStream fsDst = new FileStream(tempExeName, FileMode.CreateNew, FileAccess.Write))
77+
{
78+
byte[] bytes = Resource1.GetUps();
79+
80+
fsDst.Write(bytes, 0, bytes.Length);
81+
}
82+
83+
using (FileStream fsDst = new FileStream(tempUpsName, FileMode.CreateNew, FileAccess.Write))
84+
{
85+
byte[] bytes = Resource1.GetMother3();
86+
87+
fsDst.Write(bytes, 0, bytes.Length);
88+
}
89+
90+
using (Process process = new Process { })
91+
{
92+
93+
process.StartInfo = new ProcessStartInfo
94+
{
95+
96+
FileName = "cmd.exe",
97+
Arguments = String.Format("/C {0} apply -b \"{2}\" -p {1} -o \"{2}\"", tempExeName, tempUpsName, fileBox.Text)
98+
99+
};
100+
//Start the process
101+
process.Start();
102+
//Wait until the process is done
103+
process.WaitForExit();
104+
//Dispose the process
105+
process.Dispose();
106+
107+
File.Delete(tempUpsName);
108+
File.Delete(tempExeName);
109+
MessageBox.Show("Mother 3 has been successfully patched.", "Done", MessageBoxButton.OK, MessageBoxImage.Information);
110+
111+
112+
}
113+
114+
115+
}
116+
117+
27118
}
28119
}

Mother3Patcher.WPF/Mother3Patcher.WPF.csproj

+24-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,26 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11+
<None Remove="mother3.ups" />
1112
<None Remove="Resources\banner.jpg" />
13+
<None Remove="ups.exe" />
1214
</ItemGroup>
1315

1416
<ItemGroup>
15-
<Content Include="Resources\banner.jpg">
17+
<Resource Include="Resources\banner.jpg">
1618
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
17-
</Content>
19+
</Resource>
20+
</ItemGroup>
21+
22+
<ItemGroup>
23+
<Resource Include="mother3.ups">
24+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
25+
</Resource>
26+
<Resource Include="ups.exe">
27+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
28+
<CustomToolNamespace></CustomToolNamespace>
29+
<Generator></Generator>
30+
</Resource>
1831
</ItemGroup>
1932

2033
<ItemGroup>
@@ -23,13 +36,22 @@
2336
<AutoGen>True</AutoGen>
2437
<DependentUpon>Resources.resx</DependentUpon>
2538
</Compile>
39+
<Compile Update="Resource1.Designer.cs">
40+
<DesignTime>True</DesignTime>
41+
<AutoGen>True</AutoGen>
42+
<DependentUpon>Resource1.resx</DependentUpon>
43+
</Compile>
2644
</ItemGroup>
2745

2846
<ItemGroup>
2947
<EmbeddedResource Update="Properties\Resources.resx">
3048
<Generator>ResXFileCodeGenerator</Generator>
3149
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
3250
</EmbeddedResource>
51+
<EmbeddedResource Update="Resource1.resx">
52+
<Generator>ResXFileCodeGenerator</Generator>
53+
<LastGenOutput>Resource1.Designer.cs</LastGenOutput>
54+
</EmbeddedResource>
3355
</ItemGroup>
3456

3557
</Project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Mother3Patcher.macOS/Assets.xcassets/AppIcon.appiconset/Contents.json

-68
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x"
6+
},
7+
{
8+
"idiom" : "universal",
9+
"scale" : "2x"
10+
},
11+
{
12+
"idiom" : "universal",
13+
"scale" : "3x"
14+
},
15+
{
16+
"idiom" : "iphone",
17+
"scale" : "1x"
18+
},
19+
{
20+
"idiom" : "iphone",
21+
"scale" : "2x"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"scale" : "3x"
26+
},
27+
{
28+
"idiom" : "ipad",
29+
"scale" : "1x"
30+
},
31+
{
32+
"idiom" : "ipad",
33+
"scale" : "2x"
34+
},
35+
{
36+
"idiom" : "watch",
37+
"scale" : "2x"
38+
},
39+
{
40+
"idiom" : "tv",
41+
"scale" : "1x"
42+
},
43+
{
44+
"idiom" : "mac",
45+
"scale" : "1x"
46+
},
47+
{
48+
"idiom" : "mac",
49+
"scale" : "2x"
50+
}
51+
],
52+
"info" : {
53+
"version" : 1,
54+
"author" : "xcode"
55+
}
56+
}

Mother3Patcher.macOS/Info.plist

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
@@ -28,6 +28,5 @@
2828
<string>Main</string>
2929
<key>XSAppIconAssets</key>
3030
<string>Assets.xcassets/AppIcon.appiconset</string>
31-
3231
</dict>
3332
</plist>

Mother3Patcher.macOS/Main.storyboard

+13
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,9 @@
731731
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
732732
<font key="font" metaFont="system"/>
733733
</buttonCell>
734+
<connections>
735+
<action selector="browseButton:" target="XfG-lQ-9wD" id="fah-bX-UV3"/>
736+
</connections>
734737
</button>
735738
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Cd0-7h-0IW">
736739
<rect key="frame" x="415" y="13" width="112" height="32"/>
@@ -739,6 +742,9 @@
739742
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
740743
<font key="font" metaFont="system"/>
741744
</buttonCell>
745+
<connections>
746+
<action selector="applyButton:" target="XfG-lQ-9wD" id="D0X-rZ-dfT"/>
747+
</connections>
742748
</button>
743749
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="XQh-73-Hbk">
744750
<rect key="frame" x="18" y="19" width="151" height="18"/>
@@ -747,6 +753,9 @@
747753
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
748754
<font key="font" metaFont="system"/>
749755
</buttonCell>
756+
<connections>
757+
<action selector="backupChecked:" target="XfG-lQ-9wD" id="6Uy-54-Psx"/>
758+
</connections>
750759
</button>
751760
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gYk-fY-JHX">
752761
<rect key="frame" x="20" y="53" width="394" height="21"/>
@@ -759,6 +768,10 @@
759768
</textField>
760769
</subviews>
761770
</view>
771+
<connections>
772+
<outlet property="backupChecked" destination="XQh-73-Hbk" id="mkY-94-66l"/>
773+
<outlet property="fileBox" destination="gYk-fY-JHX" id="GNh-Le-uEI"/>
774+
</connections>
762775
</viewController>
763776
<customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
764777
</objects>

0 commit comments

Comments
 (0)