Skip to content

Commit

Permalink
FIX: playlist iteration issues
Browse files Browse the repository at this point in the history
Playlist files will now be matched to avaialble entries in the plugin_codes dictionary.
  • Loading branch information
jshackles committed Sep 2, 2020
1 parent 66a8ee0 commit 962bc74
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 83 deletions.
Binary file modified RetroGOG.exe
Binary file not shown.
173 changes: 90 additions & 83 deletions src/RetroGOG/frmPluginSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ namespace RetroGOG
{
public partial class frmPluginSelect : Form
{
IDictionary<string, string> plugin_codes = new Dictionary<string, string>();
IDictionary<string, string> core_codes = new Dictionary<string, string>();

public frmPluginSelect()
{
InitializeComponent();
Expand All @@ -38,6 +41,53 @@ private void btnBack_Click(object sender, EventArgs e)

private void frmPluginSelect_Load(object sender, EventArgs e)
{
// Build dictionaries
plugin_codes.Add("The 3DO Company - 3DO", "3do_9d81c0ec-5646-4b1a-b809-e7e61e1d3577");
plugin_codes.Add("Nintendo - Nintendo 3DS", "3ds_f6acd3ed-2c31-47d6-bae4-07b6714c1e55");
plugin_codes.Add("Atari - 2600", "atari_830528d9-e621-48e9-8ed4-e03a4853843e");
plugin_codes.Add("Sega - Dreamcast", "dc_5d181ffd-48dc-4330-aa58-6f646e76a5c8");
plugin_codes.Add("Nintendo - Game Boy", "gb_4345afe1-a2c3-4c58-93d3-373c53a90a92");
plugin_codes.Add("Nintendo - Game Boy Advance", "gba_16a78ef5-fba6-4629-b83c-ef47adab5aab");
plugin_codes.Add("Nintendo - Game Boy Color", "gbc_9b53fc85-af7c-4ce2-af31-0d95234d783a");
plugin_codes.Add("Atari - Jaguar", "jaguar_b9773549-9c20-4729-b23d-f683762ce73a");
plugin_codes.Add("Nintendo - Nintendo 64", "n64_a3824d31-c2d3-4a1a-b321-7d0764da5513");
plugin_codes.Add("Nintendo - GameCube", "ncube_602422b9-ced5-476e-911a-7fa0adf0f7f7");
plugin_codes.Add("Nintendo - Nintendo DS", "nds_4704ed29-f516-4fd8-8477-ddbcdb7cedfc");
plugin_codes.Add("Nintendo - Nintendo Entertainment System", "nes_e2c630e1-3cbe-4dbd-9235-5e6a2d2955ad");
plugin_codes.Add("Nintendo - Wii", "nwii_2d0e97ac-0406-4e5f-a85b-ab5b1a042cba");
plugin_codes.Add("NEC - PC Engine - TurboGrafx 16", "pce_c0ffd4b8-41c3-46b8-b0f7-5f4e4bafc68a");
plugin_codes.Add("Sony - PlayStation", "ps1_ff02c67d-5962-4e79-a3a3-928814edb270");
plugin_codes.Add("Sony - PlayStation 2", "ps2_50ad79eb-393c-4f95-98ce-59f095ae47ea");
plugin_codes.Add("Sony - PlayStation Portable", "psp_05487532-ba29-411b-b799-784262d275bd");
plugin_codes.Add("Sega - Saturn", "saturn_bd6ec091-8ee0-440a-9e26-71bbf21c05af");
plugin_codes.Add("Sega - Mega-CD - Sega CD", "segacd_ec7197bf-a4e4-4b86-81b9-38ea7d56f3b2");
plugin_codes.Add("Sega - Mega Drive - Genesis", "segag_e3ac94e7-945e-459d-bc1e-676cff8173f9");
plugin_codes.Add("Sega - Master System - Mark III", "sms_c6689bfb-7ba4-4d24-98e3-bd2dc339926b");
plugin_codes.Add("Nintendo - Super Nintendo Entertainment System", "snes_bc831044-f772-4391-8c22-529f42cb9799");

core_codes.Add("The 3DO Company - 3DO", "opera_libretro.dll");
core_codes.Add("Nintendo - Nintendo 3DS", "citra_libretro.dll");
core_codes.Add("Atari - 2600", "stella_libretro.dll");
core_codes.Add("Sega - Dreamcast", "flycast_libretro.dll");
core_codes.Add("Nintendo - Game Boy", "mgba_libretro.dll");
core_codes.Add("Nintendo - Game Boy Advance", "mgba_libretro.dll");
core_codes.Add("Nintendo - Game Boy Color", "mgba_libretro.dll");
core_codes.Add("Atari - Jaguar", "virtualjaguar_libretro.dll");
core_codes.Add("Nintendo - Nintendo 64", "mupen64plus_next_libretro.dll");
core_codes.Add("Nintendo - GameCube", "dolphin_libretro.dll");
core_codes.Add("Nintendo - Nintendo DS", "desmume_libretro.dll");
core_codes.Add("Nintendo - Nintendo Entertainment System", "mesen_libretro.dll");
core_codes.Add("Nintendo - Wii", "dolphin_libretro.dll");
core_codes.Add("NEC - PC Engine - TurboGrafx 16", "mednafen_pce_fast_libretro.dll");
core_codes.Add("Sony - PlayStation", "pcsx_rearmed_libretro.dll");
core_codes.Add("Sony - PlayStation 2", "play_libretro.dll");
core_codes.Add("Sony - PlayStation Portable", "ppsspp_libretro.dll");
core_codes.Add("Sega - Saturn", "mednafen_saturn_libretro.dll");
core_codes.Add("Sega - Mega-CD - Sega CD", "genesis_plus_gx_libretro.dll");
core_codes.Add("Sega - Mega Drive - Genesis", "genesis_plus_gx_libretro.dll");
core_codes.Add("Sega - Master System - Mark III", "genesis_plus_gx_libretro.dll");
core_codes.Add("Nintendo - Super Nintendo Entertainment System", "snes9x_libretro.dll");

tmrCheck.Enabled = true;
string playlistpath = Globals.RAPath.Replace("retroarch.exe", "playlists\\");
string[] strPlaylists = Directory.GetFiles(playlistpath);
Expand All @@ -47,7 +97,11 @@ private void frmPluginSelect_Load(object sender, EventArgs e)
{
if (name.Substring(Math.Max(0, name.Length - 4)) == ".lpl")
{
chbPlaylists.Items.Add(name.Replace(playlistpath, "").Replace(".lpl", ""), true);
string playlist_name = name.Replace(playlistpath, "").Replace(".lpl", "");
if (plugin_codes.ContainsKey(playlist_name))
{
chbPlaylists.Items.Add(playlist_name, true);
}
}
}
}
Expand Down Expand Up @@ -101,56 +155,6 @@ private void btnNext_Click(object sender, EventArgs e)
barProgress.Value = 0;
barProgress.Maximum = chbPlaylists.CheckedItems.Count;

// Build dictionaries
IDictionary<string, string> plugin_codes = new Dictionary<string, string>();
plugin_codes.Add("The 3DO Company - 3DO", "3do_9d81c0ec-5646-4b1a-b809-e7e61e1d3577");
plugin_codes.Add("Nintendo - Nintendo 3DS", "3ds_f6acd3ed-2c31-47d6-bae4-07b6714c1e55");
plugin_codes.Add("Atari - 2600", "atari_830528d9-e621-48e9-8ed4-e03a4853843e");
plugin_codes.Add("Sega - Dreamcast", "dc_5d181ffd-48dc-4330-aa58-6f646e76a5c8");
plugin_codes.Add("Nintendo - Game Boy", "gb_4345afe1-a2c3-4c58-93d3-373c53a90a92");
plugin_codes.Add("Nintendo - Game Boy Advance", "gba_16a78ef5-fba6-4629-b83c-ef47adab5aab");
plugin_codes.Add("Nintendo - Game Boy Color", "gbc_9b53fc85-af7c-4ce2-af31-0d95234d783a");
plugin_codes.Add("Atari - Jaguar", "jaguar_b9773549-9c20-4729-b23d-f683762ce73a");
plugin_codes.Add("Nintendo - Nintendo 64", "n64_a3824d31-c2d3-4a1a-b321-7d0764da5513");
plugin_codes.Add("Nintendo - GameCube", "ncube_602422b9-ced5-476e-911a-7fa0adf0f7f7");
plugin_codes.Add("Nintendo - Nintendo DS", "nds_4704ed29-f516-4fd8-8477-ddbcdb7cedfc");
plugin_codes.Add("Nintendo - Nintendo Entertainment System", "nes_e2c630e1-3cbe-4dbd-9235-5e6a2d2955ad");
plugin_codes.Add("Nintendo - Wii", "nwii_2d0e97ac-0406-4e5f-a85b-ab5b1a042cba");
plugin_codes.Add("NEC - PC Engine - TurboGrafx 16", "pce_c0ffd4b8-41c3-46b8-b0f7-5f4e4bafc68a");
plugin_codes.Add("Sony - PlayStation", "ps1_ff02c67d-5962-4e79-a3a3-928814edb270");
plugin_codes.Add("Sony - PlayStation 2", "ps2_50ad79eb-393c-4f95-98ce-59f095ae47ea");
plugin_codes.Add("Sony - PlayStation Portable", "psp_05487532-ba29-411b-b799-784262d275bd");
plugin_codes.Add("Sega - Saturn", "saturn_bd6ec091-8ee0-440a-9e26-71bbf21c05af");
plugin_codes.Add("Sega - Mega-CD - Sega CD", "segacd_ec7197bf-a4e4-4b86-81b9-38ea7d56f3b2");
plugin_codes.Add("Sega - Mega Drive - Genesis", "segag_e3ac94e7-945e-459d-bc1e-676cff8173f9");
plugin_codes.Add("Sega - Master System - Mark III", "sms_c6689bfb-7ba4-4d24-98e3-bd2dc339926b");
plugin_codes.Add("Nintendo - Super Nintendo Entertainment System", "snes_bc831044-f772-4391-8c22-529f42cb9799");

IDictionary<string, string> core_codes = new Dictionary<string, string>();
core_codes.Add("The 3DO Company - 3DO", "opera_libretro.dll");
core_codes.Add("Nintendo - Nintendo 3DS", "citra_libretro.dll");
core_codes.Add("Atari - 2600", "stella_libretro.dll");
core_codes.Add("Sega - Dreamcast", "flycast_libretro.dll");
core_codes.Add("Nintendo - Game Boy", "mgba_libretro.dll");
core_codes.Add("Nintendo - Game Boy Advance", "mgba_libretro.dll");
core_codes.Add("Nintendo - Game Boy Color", "mgba_libretro.dll");
core_codes.Add("Atari - Jaguar", "virtualjaguar_libretro.dll");
core_codes.Add("Nintendo - Nintendo 64", "mupen64plus_next_libretro.dll");
core_codes.Add("Nintendo - GameCube", "dolphin_libretro.dll");
core_codes.Add("Nintendo - Nintendo DS", "desmume_libretro.dll");
core_codes.Add("Nintendo - Nintendo Entertainment System", "mesen_libretro.dll");
core_codes.Add("Nintendo - Wii", "dolphin_libretro.dll");
core_codes.Add("NEC - PC Engine - TurboGrafx 16", "mednafen_pce_fast_libretro.dll");
core_codes.Add("Sony - PlayStation", "pcsx_rearmed_libretro.dll");
core_codes.Add("Sony - PlayStation 2", "play_libretro.dll");
core_codes.Add("Sony - PlayStation Portable", "ppsspp_libretro.dll");
core_codes.Add("Sega - Saturn", "mednafen_saturn_libretro.dll");
core_codes.Add("Sega - Mega-CD - Sega CD", "genesis_plus_gx_libretro.dll");
core_codes.Add("Sega - Mega Drive - Genesis", "genesis_plus_gx_libretro.dll");
core_codes.Add("Sega - Master System - Mark III", "genesis_plus_gx_libretro.dll");
core_codes.Add("Nintendo - Super Nintendo Entertainment System", "snes9x_libretro.dll");


// Download latest galaxy API for plugins
using (var client = new WebClient())
{
Expand All @@ -160,42 +164,45 @@ private void btnNext_Click(object sender, EventArgs e)

foreach (string item in chbPlaylists.CheckedItems)
{
// Create Plugin directory
Directory.CreateDirectory(Globals.GOGPluginPath + "\\" + plugin_codes[item] + "\\");

using (var client = new WebClient())
if (plugin_codes.ContainsKey(item))
{
// Download Plugin from Github
client.Headers.Add("user-agent", "RetroGOG");
client.DownloadFile("https://raw.githubusercontent.com/jshackles/RetroGOG/master/plugins/" + plugin_codes[item] + "/manifest.json", Globals.GOGPluginPath + "\\" + plugin_codes[item] + "\\" + "manifest.json");
client.DownloadFile("https://raw.githubusercontent.com/jshackles/RetroGOG/master/plugins/" + plugin_codes[item] + "/plugin.py", Globals.GOGPluginPath + "\\" + plugin_codes[item] + "\\" + "plugin.py");
client.DownloadFile("https://raw.githubusercontent.com/jshackles/RetroGOG/master/plugins/" + plugin_codes[item] + "/version.py", Globals.GOGPluginPath + "\\" + plugin_codes[item] + "\\" + "version.py");

// Download Galaxy API and decompress
if (Directory.Exists(Globals.GOGPluginPath + "\\" + plugin_codes[item] + "\\galaxy\\"))
{
Directory.Delete(Globals.GOGPluginPath + "\\" + plugin_codes[item] + "\\galaxy\\", true);
}
System.IO.Compression.ZipFile.ExtractToDirectory(Globals.GOGPluginPath + "\\galaxy_api.zip", Globals.GOGPluginPath + "\\" + plugin_codes[item] + "\\galaxy\\");
// Create Plugin directory
Directory.CreateDirectory(Globals.GOGPluginPath + "\\" + plugin_codes[item] + "\\");

// Write user_config.py file
string[] lines = new string[3];
lines[0] = "# This file automatically generated by RetroGOG";
lines[1] = "emu_path = \"" + Globals.RAPath.Replace("\\", "/").Replace("retroarch.exe", "") + "\"";
if (File.Exists(Globals.RAPath.Replace("retroarch.exe", "cores\\") + core_codes[item]))
using (var client = new WebClient())
{
lines[2] = "core = \"" + core_codes[item] + "\"";
// Download Plugin from Github
client.Headers.Add("user-agent", "RetroGOG");
client.DownloadFile("https://raw.githubusercontent.com/jshackles/RetroGOG/master/plugins/" + plugin_codes[item] + "/manifest.json", Globals.GOGPluginPath + "\\" + plugin_codes[item] + "\\" + "manifest.json");
client.DownloadFile("https://raw.githubusercontent.com/jshackles/RetroGOG/master/plugins/" + plugin_codes[item] + "/plugin.py", Globals.GOGPluginPath + "\\" + plugin_codes[item] + "\\" + "plugin.py");
client.DownloadFile("https://raw.githubusercontent.com/jshackles/RetroGOG/master/plugins/" + plugin_codes[item] + "/version.py", Globals.GOGPluginPath + "\\" + plugin_codes[item] + "\\" + "version.py");

// Download Galaxy API and decompress
if (Directory.Exists(Globals.GOGPluginPath + "\\" + plugin_codes[item] + "\\galaxy\\"))
{
Directory.Delete(Globals.GOGPluginPath + "\\" + plugin_codes[item] + "\\galaxy\\", true);
}
System.IO.Compression.ZipFile.ExtractToDirectory(Globals.GOGPluginPath + "\\galaxy_api.zip", Globals.GOGPluginPath + "\\" + plugin_codes[item] + "\\galaxy\\");

// Write user_config.py file
string[] lines = new string[3];
lines[0] = "# This file automatically generated by RetroGOG";
lines[1] = "emu_path = \"" + Globals.RAPath.Replace("\\", "/").Replace("retroarch.exe", "") + "\"";
if (File.Exists(Globals.RAPath.Replace("retroarch.exe", "cores\\") + core_codes[item]))
{
lines[2] = "core = \"" + core_codes[item] + "\"";
}
else
{
Form frmCoreSelect = new frmCoreSelect();
frmCoreSelect.Text = item;
frmCoreSelect.ShowDialog(this);
lines[2] = "core = \"" + Globals.TempCore + "\"";
}
System.IO.File.WriteAllLines(Globals.GOGPluginPath + "\\" + plugin_codes[item] + "\\" + "user_config.py", lines);

barProgress.Value = barProgress.Value + 1;
}
else
{
Form frmCoreSelect = new frmCoreSelect();
frmCoreSelect.Text = item;
frmCoreSelect.ShowDialog(this);
lines[2] = "core = \"" + Globals.TempCore + "\"";
}
System.IO.File.WriteAllLines(Globals.GOGPluginPath + "\\" + plugin_codes[item] + "\\" + "user_config.py", lines);

barProgress.Value = barProgress.Value + 1;
}
}
}
Expand Down

0 comments on commit 962bc74

Please sign in to comment.