Skip to content

Commit

Permalink
Added System BIOS/Rom path controls
Browse files Browse the repository at this point in the history
  • Loading branch information
Asnivor committed Oct 11, 2016
1 parent d75a005 commit f85b858
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 13 deletions.
51 changes: 49 additions & 2 deletions MedLaunch/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3642,16 +3642,63 @@
<StackPanel x:Name="spSysBiosSettings">
<Grid Margin="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="90" />
<ColumnDefinition Width="300" />
<ColumnDefinition Width="110" />
<ColumnDefinition Width="280" />

</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />

<RowDefinition Height="*" />
</Grid.RowDefinitions>

<TextBox x:Name="cfg_gba__bios" Grid.Column="1" Grid.Row="0"></TextBox>
<Button x:Name="tbBiosGba" Grid.Column="0" Grid.Row="0" Click="btnMednafenBiosPaths_Click">GBA Bios</Button>

<TextBox x:Name="cfg_pce__gecdbios" Grid.Column="1" Grid.Row="1"></TextBox>
<Button x:Name="tbBiosPceGe" Grid.Column="0" Grid.Row="1" Click="btnMednafenBiosPaths_Click">PCE GE Bios</Button>

<TextBox x:Name="cfg_pce__cdbios" Grid.Column="1" Grid.Row="2"></TextBox>
<Button x:Name="tbBiosPceCd" Grid.Column="0" Grid.Row="2" Click="btnMednafenBiosPaths_Click">PCE CD Bios</Button>

<TextBox x:Name="cfg_pce_fast__cdbios" Grid.Column="1" Grid.Row="3"></TextBox>
<Button x:Name="tbBiosPceFastCd" Grid.Column="0" Grid.Row="3" Click="btnMednafenBiosPaths_Click">PCE_Fast CD Bios</Button>

<TextBox x:Name="cfg_pcfx__bios" Grid.Column="1" Grid.Row="4"></TextBox>
<Button x:Name="tbBiosPcfx" Grid.Column="0" Grid.Row="4" Click="btnMednafenBiosPaths_Click">PC-FX Bios</Button>

<TextBox x:Name="cfg_md__cdbios" Grid.Column="1" Grid.Row="5"></TextBox>
<Button x:Name="tbBiosMdCd" Grid.Column="0" Grid.Row="5" Click="btnMednafenBiosPaths_Click">MD CD Bios</Button>

<TextBox x:Name="cfg_nes__ggrom" Grid.Column="1" Grid.Row="6"></TextBox>
<Button x:Name="tbBiosNesGg" Grid.Column="0" Grid.Row="6" Click="btnMednafenBiosPaths_Click">NES GG Rom</Button>

<TextBox x:Name="cfg_ss__bios_jp" Grid.Column="1" Grid.Row="7"></TextBox>
<Button x:Name="tbBiosSsJp" Grid.Column="0" Grid.Row="7" Click="btnMednafenBiosPaths_Click">SS Japanese Bios</Button>

<TextBox x:Name="cfg_ss__bios_na_eu" Grid.Column="1" Grid.Row="8"></TextBox>
<Button x:Name="tbBiosSsNaEu" Grid.Column="0" Grid.Row="8" Click="btnMednafenBiosPaths_Click">SS NA/EU Bios</Button>

<TextBox x:Name="cfg_psx__bios_eu" Grid.Column="1" Grid.Row="9"></TextBox>
<Button x:Name="tbBiosPsxEu" Grid.Column="0" Grid.Row="9" Click="btnMednafenBiosPaths_Click">PSX EU Bios</Button>

<TextBox x:Name="cfg_psx__bios_jp" Grid.Column="1" Grid.Row="10"></TextBox>
<Button x:Name="tbBiosPsxJp" Grid.Column="0" Grid.Row="10" Click="btnMednafenBiosPaths_Click">PSX JP Bios</Button>

<TextBox x:Name="cfg_psx__bios_na" Grid.Column="1" Grid.Row="11"></TextBox>
<Button x:Name="tbBiosPsxNa" Grid.Column="0" Grid.Row="11" Click="btnMednafenBiosPaths_Click">PSX NA Bios</Button>

</Grid>
</StackPanel>
</Expander>
Expand Down
100 changes: 93 additions & 7 deletions MedLaunch/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using System.Reflection;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Microsoft.Win32;

namespace MedLaunch
{
Expand Down Expand Up @@ -187,6 +188,7 @@ public MainWindow()

// load all MednafenPath settings
ConfigBaseSettings.LoadMednafenPathValues(spMedPathSettings);
ConfigBaseSettings.LoadBiosPathValues(spSysBiosSettings);



Expand All @@ -208,10 +210,10 @@ public MainWindow()

// settings buttons and borders
//btnMednafenPaths.Visibility = Visibility.Collapsed;
btnSystemBios.Visibility = Visibility.Collapsed;
//btnSystemBios.Visibility = Visibility.Collapsed;
//btnEmulator.Visibility = Visibility.Collapsed;
//brdMednafenPaths.Visibility = Visibility.Collapsed;
brdSystemBios.Visibility = Visibility.Collapsed;
/// brdSystemBios.Visibility = Visibility.Collapsed;
//brdEmulator.Visibility = Visibility.Collapsed;

wb.Navigated += new NavigatedEventHandler(wb_Navigated);
Expand Down Expand Up @@ -991,6 +993,69 @@ private void chkEnableSnes_faust_Unchecked(object sender, RoutedEventArgs e)
GlobalSettings.UpdateEnableSnes_faust(chkEnableSnes_faust);
}

// Mednafen BIOS Paths events
private void btnMednafenBiosPaths_Click(object sender, RoutedEventArgs e)
{
// convert the button name
string btnName = ((sender as Button).Name).Replace("tbBios", "");
// textbox name
string tbName = "";
switch (btnName)
{
case "Gba":
tbName = "cfg_gba__bios";
break;
case "PceGe":
tbName = "cfg_pce__gecdbioss";
break;
case "PceCd":
tbName = "cfg_pce__cdbios";
break;
case "PceFastCd":
tbName = "cfg_pce_fast__cdbios";
break;
case "Pcfx":
tbName = "cfg_pcfx__bios";
break;
case "MdCd":
tbName = "cfg_md__cdbios";
break;
case "NesGg":
tbName = "cfg_nes__ggrom";
break;
case "SsJp":
tbName = "cfg_ss__bios_jp";
break;
case "SsNaEu":
tbName = "cfg_ss__bios_na_eu";
break;
case "PsxEu":
tbName = "cfg_psx__bios_eu";
break;
case "PsxJp":
tbName = "cfg_psx__bios_jp";
break;
case "PsxNa":
tbName = "cfg_psx__bios_na";
break;

}
//string tbName = "cfg_filesys__path_" + btnName;
// get textbox
TextBox tb = (TextBox)(Application.Current.Windows.OfType<MainWindow>().FirstOrDefault()).FindName(tbName);

OpenFileDialog filePath = new OpenFileDialog();
filePath.Multiselect = false;
filePath.Title = "Select " + btnName + " BIOS/Rom";
filePath.ShowDialog();

if (filePath.FileName.Length > 0)
{
tb.Text = filePath.FileName;
}

}

// Mednafen Paths (cheats, saves etc..) events
private void btnMednafenPaths_Click(object sender, RoutedEventArgs e)
{
Expand Down Expand Up @@ -1664,15 +1729,35 @@ private void btnSettings_Checked(object sender, RoutedEventArgs e)
SettingsVisualHandler.ButtonClick();
}

private void btnSettingsSaveAllChanges_Click(object sender, RoutedEventArgs e)
private async void btnSettingsSaveAllChanges_Click(object sender, RoutedEventArgs e)
{
//SettingsHandler sh = new SettingsHandler();
//sh.SaveAllSettings();

Paths.SavePathSettings(tbPathMednafen, tbPathGb, tbPathGba, tbPathGg, tbPathLynx, tbPathMd, tbPathNes, tbPathSnes, tbPathNgp, tbPathPce, tbPathPcfx, tbPathMs, tbPathVb, tbPathWswan);
ConfigNetplaySettings.SaveNetplaySettings(tbNetplayNick, slLocalPlayersValue, slConsoleLinesValue, slConsoleScaleValue, resOne, resTwo, resThree, resFour, resFive);
ConfigServerSettings.SaveCustomServerSettings(tbServerDesc, tbHostname, slServerPort, tbPassword, tbGameKey);
ConfigBaseSettings.SaveMednafenPathValues(spMedPathSettings);
var mySettings = new MetroDialogSettings()
{
NegativeButtonText = "Cancel Scanning",
AnimateShow = false,
AnimateHide = true
};

var controller = await this.ShowProgressAsync("Please wait...", "Saving Settings\n(This may take a few seconds depending on your system)", settings: mySettings);
controller.SetIndeterminate();

await Task.Delay(200);


this.Dispatcher.Invoke(() =>
{
Paths.SavePathSettings(tbPathMednafen, tbPathGb, tbPathGba, tbPathGg, tbPathLynx, tbPathMd, tbPathNes, tbPathSnes, tbPathNgp, tbPathPce, tbPathPcfx, tbPathMs, tbPathVb, tbPathWswan);
ConfigNetplaySettings.SaveNetplaySettings(tbNetplayNick, slLocalPlayersValue, slConsoleLinesValue, slConsoleScaleValue, resOne, resTwo, resThree, resFour, resFive);
ConfigServerSettings.SaveCustomServerSettings(tbServerDesc, tbHostname, slServerPort, tbPassword, tbGameKey);
ConfigBaseSettings.SaveMednafenPathValues(spMedPathSettings);
ConfigBaseSettings.SaveBiosPathValues(spSysBiosSettings);
});

await controller.CloseAsync();


}

Expand All @@ -1685,6 +1770,7 @@ private void btnSettingsCancelAllChanges_Click(object sender, RoutedEventArgs e)
ConfigNetplaySettings.LoadNetplaySettings(tbNetplayNick, slLocalPlayersValue, slConsoleLinesValue, slConsoleScaleValue, resOne, resTwo, resThree, resFour, resFive);
ConfigServerSettings.PopulateCustomServer(tbServerDesc, tbHostname, slServerPort, tbPassword, tbGameKey);
ConfigBaseSettings.LoadMednafenPathValues(spMedPathSettings);
ConfigBaseSettings.LoadBiosPathValues(spSysBiosSettings);

}

Expand Down
41 changes: 39 additions & 2 deletions MedLaunch/Models/ConfigBaseSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,15 +491,15 @@ public static ConfigBaseSettings GetConfigDefaults()

gb__system_type = "auto", // placed

//gba__bios = "optional path the gba bios",
gba__bios = "",

npg__language = "english", // placed

nes__clipsides = false, // placed
nes__correct_aspect = false, // placed
nes__fnscan = true, // placed
nes__gg = false, // placed
// nes__ggrom = "game genie rom path"
nes__ggrom = "gg.rom",
nes__input__fcexp = "none", // placed
nes__input__port1 = "gamepad", // placed
nes__input__port2 = "gamepad", // placed
Expand Down Expand Up @@ -983,6 +983,43 @@ public static string ConvertControlNameToConfigName(string controlName)
return controlName.Replace("cfg_", "");
}

// populate settings - bios path controls
public static void LoadBiosPathValues(StackPanel wp)
{
// get a class object with all child controls
UIHandler ui = UIHandler.GetChildren(wp);

// get all config settings for base config
ConfigBaseSettings settings = GetConfig(2000000000);

SetControlValues(ui, settings, 1);
}

// save settings - mednafen paths controls
public static void SaveBiosPathValues(StackPanel wp)
{
// get a class object with all child controls
UIHandler ui = UIHandler.GetChildren(wp);

// get all config settings for base config
//ConfigBaseSettings settings = GetConfig(2000000000);

// get ALL config settings (as we are saving these to all configs)
List<ConfigBaseSettings> AllSettings = new List<ConfigBaseSettings>();
using (var context = new MyDbContext())
{
List<ConfigBaseSettings> aset = (from d in context.ConfigBaseSettings
select d).ToList();
AllSettings.AddRange(aset);
}

// iterate through each config and set all the settings for each config
foreach (ConfigBaseSettings settings in AllSettings)
{
SetControlValues(ui, settings, 2);
}
}

// populate settings - mednafen paths controls
public static void LoadMednafenPathValues(StackPanel wp)
{
Expand Down
4 changes: 2 additions & 2 deletions MedLaunch/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.15.5")]
[assembly: AssemblyFileVersion("0.1.15.5")]
[assembly: AssemblyVersion("0.1.15.7")]
[assembly: AssemblyFileVersion("0.1.15.7")]

0 comments on commit f85b858

Please sign in to comment.