Skip to content

Commit 70bf77b

Browse files
committed
Get ROM name reversion working
1 parent 4ddf30f commit 70bf77b

File tree

7 files changed

+58
-11
lines changed

7 files changed

+58
-11
lines changed

EmulationManager/EmulationManager/Commands/RevertRomStreamingCompatibilityCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ public bool CanExecute(object parameter)
2424

2525
public event EventHandler CanExecuteChanged { add { } remove { } }
2626

27-
public void Execute(object parameter)
27+
public async void Execute(object parameter)
2828
{
2929
if (CanExecute(parameter))
3030
{
31-
_viewModel.RevertRomStreamingCompatibilityAsync();
31+
await _viewModel.RevertRomStreamingCompatibilityAsync();
3232
}
3333
}
3434
#endregion

EmulationManager/EmulationManager/EmulationManager.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848
<ErrorReport>prompt</ErrorReport>
4949
<WarningLevel>4</WarningLevel>
5050
</PropertyGroup>
51+
<PropertyGroup>
52+
<ApplicationIcon>References\tritium-icons.ico</ApplicationIcon>
53+
</PropertyGroup>
54+
<PropertyGroup>
55+
<NoWin32Manifest>true</NoWin32Manifest>
56+
</PropertyGroup>
5157
<ItemGroup>
5258
<Reference Include="Ookii.Dialogs.Wpf">
5359
<HintPath>..\packages\Ookii.Dialogs.1.0\lib\net35\Ookii.Dialogs.Wpf.dll</HintPath>
@@ -157,6 +163,9 @@
157163
<Install>false</Install>
158164
</BootstrapperPackage>
159165
</ItemGroup>
166+
<ItemGroup>
167+
<Resource Include="References\tritium-icons.ico" />
168+
</ItemGroup>
160169
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
161170
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
162171
Other similar extension points exist, see Microsoft.Common.targets.

EmulationManager/EmulationManager/Helpers/IOHelper.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,31 +213,51 @@ private static RomModel PopulateRomModelFromRomPathRomFileName(string file, stri
213213
/// <summary>
214214
/// Changes the ROM filename to be compatible with streaming over Steam Big Picture
215215
/// </summary>
216-
public static void FixRomsForStreaming(RomModel[] roms)
216+
public static RomModel[] FixRomsForStreaming(RomModel[] roms)
217217
{
218+
RomModel[] newRoms = new RomModel[roms.Length];
219+
220+
int i = 0;
218221
foreach (var rom in roms)
219222
{
220223
if (!string.IsNullOrEmpty(rom.Path) && !string.IsNullOrEmpty(rom.StreamingCompatiblePath))
221224
{
222-
File.Move(rom.Path, rom.StreamingCompatiblePath);
225+
if (rom.Path != rom.StreamingCompatiblePath)
226+
{
227+
File.Move(rom.Path, rom.StreamingCompatiblePath);
228+
}
223229
rom.UseStreamingCompatiblePath = true;
230+
roms[i] = rom;
224231
}
232+
i++;
225233
}
234+
return newRoms;
226235
}
227236

228237
/// <summary>
229238
/// Reverts the FixRomsForStreaming changes
230239
/// </summary>
231-
public static void RevertRomsFromStreaming(RomModel[] roms)
240+
public static RomModel[] RevertRomsFromStreaming(RomModel[] roms)
232241
{
242+
RomModel[] newRoms = new RomModel[roms.Length];
243+
244+
int i = 0;
233245
foreach (var rom in roms)
234246
{
235247
if (!string.IsNullOrEmpty(rom.Path) && !string.IsNullOrEmpty(rom.StreamingCompatiblePath))
236248
{
237-
File.Move(rom.StreamingCompatiblePath, rom.Path);
249+
rom.Path = rom.StreamingCompatiblePath.Replace(ConfigurationHelper.GetStreamingCompatiblityReplacementName(), " ");
250+
if (rom.Path != rom.StreamingCompatiblePath)
251+
{
252+
File.Move(rom.StreamingCompatiblePath, rom.Path);
253+
}
238254
rom.UseStreamingCompatiblePath = false;
255+
256+
newRoms[i] = rom;
239257
}
258+
i++;
240259
}
260+
return newRoms;
241261
}
242262
}
243263
}
189 KB
Binary file not shown.

EmulationManager/EmulationManager/ViewModels/EmuManagerViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ await Task.Run(() =>
173173
IsLoading = true;
174174
LoadingText = "Fixing rom streaming compatibility...";
175175

176-
IOHelper.RevertRomsFromStreaming(RomModels);
176+
RomModels = IOHelper.RevertRomsFromStreaming(RomModels);
177177

178178
LoadingText = string.Empty;
179179
IsLoading = false;
@@ -192,9 +192,9 @@ public async Task FixRomStreamingCompatibilityAsync()
192192
await Task.Run(() =>
193193
{
194194
IsLoading = true;
195-
LoadingText = "Fixing rom streaming compatibility...";
195+
LoadingText = "Reverting rom streaming compatibility...";
196196

197-
IOHelper.FixRomsForStreaming(RomModels);
197+
RomModels = IOHelper.FixRomsForStreaming(RomModels);
198198

199199
LoadingText = string.Empty;
200200
IsLoading = false;

EmulationManager/EmulationManager/Views/EmuManager.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<StackPanel Orientation="Horizontal">
7272
<Button x:Name="FixRomsForStreamingCompatibilityButton" Command="{Binding FixRomStreamingCompatibilityCommand}" Margin="0,0,0,0" Padding="3" FontSize="16" Click="FixRomsForStreamingCompatibilityButton_Click">Fix Roms for Streaming Compatibility</Button>
7373
<TextBlock VerticalAlignment="Center" Margin="3,0,0,0"><Path Width="16" Height="16" Stretch="Uniform" Data="F1 M 15.6001,5.22C 17.3822,5.2515 18.82,5.87949 19.9133,7.104C 21.0067,8.32849 21.5689,9.96048 21.6,12C 21.5923,14.7711 20.4267,16.468 18.1031,17.0906L 18.1031,19.2L 13.1146,19.2L 13.1146,14.3069C 13.4637,14.3485 13.7175,14.3652 13.8762,14.3569C 15.7127,14.5413 16.6373,13.7557 16.65,12C 16.6584,10.3585 16.2917,9.5585 15.55,9.59998C 14.7667,9.59198 14.3834,10.392 14.4,12L 9.45001,12C 9.47205,7.54944 11.5221,5.28946 15.6001,5.22 Z M 15.6501,21.06C 16.4651,21.0844 17.1408,21.3759 17.6773,21.9342C 18.2138,22.4926 18.4919,23.1713 18.5118,23.9701C 18.492,24.769 18.2138,25.4475 17.6773,26.0059C 17.1408,26.5641 16.4651,26.8555 15.6501,26.88C 14.813,26.8555 14.1151,26.5641 13.5565,26.0059C 12.9979,25.4475 12.7079,24.769 12.6863,23.9701C 12.7079,23.1507 12.9979,22.4662 13.5565,21.9167C 14.1151,21.3671 14.813,21.0815 15.6501,21.06 Z M 15.6501,0C 11.2097,0.105347 7.51904,1.64291 4.57797,4.61276C 1.6369,7.58261 0.110931,11.3527 0,15.9231C 0.110931,20.2214 1.6369,23.8045 4.57797,26.6724C 7.51904,29.5402 11.2097,31.0294 15.6501,31.14C 19.9496,31.0294 23.5613,29.5402 26.4853,26.6724C 29.4093,23.8045 30.9309,20.2214 31.05,15.9231C 30.9309,11.3527 29.4093,7.58264 26.4853,4.61276C 23.5613,1.64291 19.9496,0.105347 15.6501,0 Z " Fill="{DynamicResource {x:Static SystemColors.ActiveCaptionBrushKey}}" Cursor="Hand"/></TextBlock>
74-
<Button x:Name="RevertRomStreamingCompatibilityButton" Command="{Binding RevertRomStreamingCompatibilityCommand}" Margin="10,0,0,0" Padding="3" FontSize="16">Revert Rom Names (Breaks Streaming)</Button>
74+
<Button x:Name="RevertRomStreamingCompatibilityButton" Command="{Binding RevertRomStreamingCompatibilityCommand}" Margin="10,0,0,0" Padding="3" FontSize="16" Click="RevertRomStreamingCompatibilityButton_Click">Revert Rom Names (Breaks Streaming)</Button>
7575
<TextBlock VerticalAlignment="Center" Margin="3,0,0,0"><Path Width="16" Height="16" Stretch="Uniform" Data="F1 M 15.6001,5.22C 17.3822,5.2515 18.82,5.87949 19.9133,7.104C 21.0067,8.32849 21.5689,9.96048 21.6,12C 21.5923,14.7711 20.4267,16.468 18.1031,17.0906L 18.1031,19.2L 13.1146,19.2L 13.1146,14.3069C 13.4637,14.3485 13.7175,14.3652 13.8762,14.3569C 15.7127,14.5413 16.6373,13.7557 16.65,12C 16.6584,10.3585 16.2917,9.5585 15.55,9.59998C 14.7667,9.59198 14.3834,10.392 14.4,12L 9.45001,12C 9.47205,7.54944 11.5221,5.28946 15.6001,5.22 Z M 15.6501,21.06C 16.4651,21.0844 17.1408,21.3759 17.6773,21.9342C 18.2138,22.4926 18.4919,23.1713 18.5118,23.9701C 18.492,24.769 18.2138,25.4475 17.6773,26.0059C 17.1408,26.5641 16.4651,26.8555 15.6501,26.88C 14.813,26.8555 14.1151,26.5641 13.5565,26.0059C 12.9979,25.4475 12.7079,24.769 12.6863,23.9701C 12.7079,23.1507 12.9979,22.4662 13.5565,21.9167C 14.1151,21.3671 14.813,21.0815 15.6501,21.06 Z M 15.6501,0C 11.2097,0.105347 7.51904,1.64291 4.57797,4.61276C 1.6369,7.58261 0.110931,11.3527 0,15.9231C 0.110931,20.2214 1.6369,23.8045 4.57797,26.6724C 7.51904,29.5402 11.2097,31.0294 15.6501,31.14C 19.9496,31.0294 23.5613,29.5402 26.4853,26.6724C 29.4093,23.8045 30.9309,20.2214 31.05,15.9231C 30.9309,11.3527 29.4093,7.58264 26.4853,4.61276C 23.5613,1.64291 19.9496,0.105347 15.6501,0 Z " Fill="{DynamicResource {x:Static SystemColors.ActiveCaptionBrushKey}}" Cursor="Hand"/></TextBlock>
7676
</StackPanel>
7777
</StackPanel>

EmulationManager/EmulationManager/Views/EmuManager.xaml.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,28 @@ private void AboutMenuItem_Click(object sender, RoutedEventArgs e)
164164
{
165165
System.Diagnostics.Process.Start("http://www.hometheatertablet.com/tritium-emulation-manager-steam/");
166166
}
167-
catch (Exception ex)
167+
catch (Exception)
168168
{
169169
MessageBox.Show("Unable to open website.");
170170
}
171171
}
172+
173+
private void RevertRomStreamingCompatibilityButton_Click(object sender, RoutedEventArgs e)
174+
{
175+
var result = MessageBox.Show("This will rename your rom files. This is recommended for streaming. Proceed?",
176+
"Rename Roms Confirmation", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel);
177+
178+
if (result != MessageBoxResult.Yes)
179+
return;
180+
var viewModel = mainGrid.DataContext as ViewModels.EmuManagerViewModel;
181+
if (viewModel != null && viewModel.FixRomStreamingCompatibilityCommand.CanExecute(null))
182+
{
183+
viewModel.FixRomStreamingCompatibilityCommand.Execute(null);
184+
}
185+
else
186+
{
187+
MessageBox.Show("Unable to execute command. Did you load Roms and Emulators?");
188+
}
189+
}
172190
}
173191
}

0 commit comments

Comments
 (0)