Fixing error loading games

It was erroring when loading games into
a blank shortcut screen. This was stopping
us being able to select any games at all.
Fixed another problem with Shortcut.IsValid
causing exception when loading a profle
that no longer existed. It now will correctly
report that the shortcut is isvalid.
This commit is contained in:
Terry MacDonald 2021-03-05 11:12:27 +13:00
parent 634322ed05
commit 001e351106
4 changed files with 33 additions and 17 deletions

View File

@ -1935,9 +1935,13 @@ namespace DisplayMagician
// Does the profile we want to Use still exist? // Does the profile we want to Use still exist?
// Is the profile still valid right now? i.e. are all the screens available? // Is the profile still valid right now? i.e. are all the screens available?
if (ProfileToUse == null)
{
return (false,string.Format("The profile is not valid right now and cannot be used."));
}
if (!ProfileToUse.IsPossible) if (!ProfileToUse.IsPossible)
{ {
return (false,string.Format("The profile '{0}' is not valid right now and cannot be used.",ProfileToUse.Name)); return (false, string.Format("The profile '{0}' is not valid right now and cannot be used.", ProfileToUse.Name));
} }
// Is the main application still installed? // Is the main application still installed?
if (Category.Equals(ShortcutCategory.Application)) if (Category.Equals(ShortcutCategory.Application))

View File

@ -786,7 +786,7 @@ namespace DisplayMagician.UIForms
allGames.AddRange(UplayLibrary.AllInstalledGames); allGames.AddRange(UplayLibrary.AllInstalledGames);
// Load the Steam Games into the Games ListView // Load all the Games into the Games ListView
foreach (var game in allGames.OrderBy(game => game.Name)) foreach (var game in allGames.OrderBy(game => game.Name))
{ {
// Get the bitmap out of the IconPath // Get the bitmap out of the IconPath
@ -805,10 +805,10 @@ namespace DisplayMagician.UIForms
// Add the images to the images array // Add the images to the images array
il_games.Images.Add(bm); il_games.Images.Add(bm);
if (!Visible) /*if (!Visible)
{ {
return; //return;
} }*/
// ADd the game to the game array // ADd the game to the game array
lv_games.Items.Add(new ListViewItem lv_games.Items.Add(new ListViewItem
@ -930,18 +930,22 @@ namespace DisplayMagician.UIForms
// Set the launcher items if we have them // Set the launcher items if we have them
if (_shortcutToEdit.GameLibrary.Equals(SupportedGameLibrary.Unknown)) if (_shortcutToEdit.GameLibrary.Equals(SupportedGameLibrary.Unknown))
{ {
// Fill in the game library information to highliught there isn't one detected. if (allGames.Count <= 0)
txt_game_launcher.Text = "None detected"; {
txt_game_name.Text = "No supported game libraries detected"; // Fill in the game library information to highliught there isn't one detected.
txt_args_game.Text = ""; txt_game_launcher.Text = "None detected";
txt_game_name.Text = "No supported game libraries detected";
txt_args_game.Text = "";
// Disable the Game library option, and select the Executable option instead. // Disable the Game library option, and select the Executable option instead.
p_game.Enabled = false; p_game.Enabled = false;
p_game.Visible = false; p_game.Visible = false;
rb_wait_executable.Checked = true; rb_wait_executable.Checked = true;
rb_launcher.Enabled = false; rb_launcher.Enabled = false;
rb_launcher.Visible = false; rb_launcher.Visible = false;
lbl_no_game_libraries.Visible = true; lbl_no_game_libraries.Visible = true;
}
} }
else else

View File

@ -186,6 +186,9 @@ namespace DisplayMagician.UIForms
if (_selectedShortcut == null) if (_selectedShortcut == null)
return; return;
if (!shortcutValidity[_selectedShortcut.Name])
return;
// Run the selected shortcut // Run the selected shortcut
btn_run.PerformClick(); btn_run.PerformClick();
} }

View File

@ -151,6 +151,7 @@ namespace DisplayMagicianShared
//Doublecheck it's been added //Doublecheck it's been added
if (ContainsProfile(profile)) if (ContainsProfile(profile))
{ {
IsPossibleRefresh();
return true; return true;
} }
else else
@ -199,6 +200,7 @@ namespace DisplayMagicianShared
if (numRemoved == 1) if (numRemoved == 1)
{ {
SaveProfiles(); SaveProfiles();
IsPossibleRefresh();
return true; return true;
} }
else if (numRemoved == 0) else if (numRemoved == 0)
@ -248,6 +250,7 @@ namespace DisplayMagicianShared
if (numRemoved == 1) if (numRemoved == 1)
{ {
SaveProfiles(); SaveProfiles();
IsPossibleRefresh();
return true; return true;
} }
else if (numRemoved == 0) else if (numRemoved == 0)
@ -296,6 +299,7 @@ namespace DisplayMagicianShared
if (numRemoved == 1) if (numRemoved == 1)
{ {
SaveProfiles(); SaveProfiles();
IsPossibleRefresh();
return true; return true;
} }
else if (numRemoved == 0) else if (numRemoved == 0)
@ -450,6 +454,7 @@ namespace DisplayMagicianShared
return false; return false;
} }
IsPossibleRefresh();
} }