Skip to content

Commit

Permalink
Merge pull request #89 from FlaminSarge/prompt
Browse files Browse the repository at this point in the history
Replace non-Xbox location error prompt with flashing error icon
  • Loading branch information
Fr33dan authored Dec 4, 2024
2 parents 6ac391e + b024974 commit f6f541d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 24 deletions.
10 changes: 10 additions & 0 deletions GPSaveConverter/SaveFileConverterForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 27 additions & 24 deletions GPSaveConverter/SaveFileConverterForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,36 @@ private async Task fetchNonXboxSaveFiles()
await ActiveGame.fetchNonXboxSaveFiles();
}

private async Task<bool> promptForNonXboxSaveLocation(string reason)
private async void setNonXboxSaveLocationError(string reason)
{
DialogResult res;
if (reason != null)
if (reason != null && reason != string.Empty)
{
res = MessageBox.Show(this, reason + " Please select save file location.", "Non-Xbox save location not found", MessageBoxButtons.OKCancel);
nonXboxLocationError.SetError(promptNonXboxLocationButton, reason + " Please select save file location.");
}
else
{
res = DialogResult.OK;
nonXboxLocationError.SetError(promptNonXboxLocationButton, string.Empty);
}
}

private async Task<bool> promptForNonXboxSaveLocation()
{
VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog();
if (ActiveGame.BaseNonXboxSaveLocation != null && ActiveGame.BaseNonXboxSaveLocation != string.Empty)
{
dialog.SelectedPath = ActiveGame.BaseNonXboxSaveLocation;
}
DialogResult res = dialog.ShowDialog();
if (res == DialogResult.OK)
{
VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog();
if (ActiveGame.BaseNonXboxSaveLocation != null && ActiveGame.BaseNonXboxSaveLocation != string.Empty)
{
dialog.SelectedPath = ActiveGame.BaseNonXboxSaveLocation;
}
res = dialog.ShowDialog();
if (res == DialogResult.OK)
{
ActiveGame.BaseNonXboxSaveLocation = dialog.SelectedPath + "\\";
ActiveGame.BaseNonXboxSaveLocation = dialog.SelectedPath + "\\";

// Clear profiles when manual save file location is used.
ActiveGame.TargetProfiles = null;
// Clear profiles when manual save file location is used.
ActiveGame.TargetProfiles = null;

await fetchNonXboxSaveFiles();
return true;
}
else return false;
setNonXboxSaveLocationError(string.Empty);
await fetchNonXboxSaveFiles();
return true;
}
else return false;
}
Expand Down Expand Up @@ -200,12 +200,13 @@ private async Task fetchNonXboxProfiles(int index)
{
profileDataGrid.Rows[0].Selected = true;
nonXboxProfileTable_CellClicked(profileDataGrid, null);
setNonXboxSaveLocationError(string.Empty);
}
else if(profileList.Count == 0)
{
profileList.Add(new NonXboxProfile("No non-Xbox profiles found", index, NonXboxProfile.ProfileType.DisplayOnly));
profileDataGrid.Enabled = false;
await promptForNonXboxSaveLocation("Game library defines non-Xbox profiles, but none were found.");
setNonXboxSaveLocationError("Game library defines non-Xbox profiles, but none were found.");
}
}

Expand Down Expand Up @@ -485,12 +486,13 @@ private async void packagesDataGridView_Click(object sender, EventArgs e)

if (ActiveGame.BaseNonXboxSaveLocation == null || ActiveGame.BaseNonXboxSaveLocation == string.Empty)
{
await promptForNonXboxSaveLocation("Non-Xbox save location not found in game library.");
setNonXboxSaveLocationError("Non-Xbox save location not found in game library.");
}
else
{
if (ActiveGame.BaseNonXboxSaveLocation.Contains(Library.GameLibrary.NonSteamProfileMarker))
{
setNonXboxSaveLocationError(string.Empty);
await this.fetchNonXboxProfiles(0);
}
else
Expand All @@ -506,19 +508,20 @@ private async void packagesDataGridView_Click(object sender, EventArgs e)

if (Directory.Exists(ActiveGame.NonXboxSaveLocation))
{
setNonXboxSaveLocationError(string.Empty);
await fetchNonXboxSaveFiles();
}
else
{
await promptForNonXboxSaveLocation("Non-Xbox save location from library does not exist.");
setNonXboxSaveLocationError("Non-Xbox save location from library does not exist.");
}
}
}
}

private async void promptNonXboxLocationButton_Click(object sender, EventArgs e)
{
await this.promptForNonXboxSaveLocation(null);
await this.promptForNonXboxSaveLocation();
}

private bool suspendCrossMatch = false;
Expand Down
3 changes: 3 additions & 0 deletions GPSaveConverter/SaveFileConverterForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,7 @@
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>397, 17</value>
</metadata>
<metadata name="nonXboxLocationError.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>844, 17</value>
</metadata>
</root>

0 comments on commit f6f541d

Please sign in to comment.