Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8118760
Revert "Fix `CheatList.SaveFile` returning success without writing an…
YoshiRulz Apr 27, 2026
617c80b
Revert "Improve `DialogControllerExtensions.DoWithTryAgainBox` dialog"
YoshiRulz Apr 27, 2026
01b5de3
Revert "Fix `FileWriter.Create` choking on relative paths"
YoshiRulz Apr 27, 2026
5c52441
revert intervening changeset 2 to `TAStudio.MenuItems.cs`
YoshiRulz Apr 27, 2026
5ac8cc0
revert intervening changes to `MovieZone.cs`
YoshiRulz Apr 27, 2026
1bee3a0
Revert "Handle file errors when saving a macro."
YoshiRulz Apr 27, 2026
c8ab1aa
Revert "Handle errors when saving config file."
YoshiRulz Apr 27, 2026
1f19635
revert intervening changes to `LuaConsole.cs`
YoshiRulz Apr 27, 2026
59b558d
Revert "Handle file writing errors for movies and all tools."
YoshiRulz Apr 27, 2026
8f8d592
Revert "Fix: CheatList was getting forcibly autosaved, after the meth…
YoshiRulz Apr 27, 2026
4c48610
Revert "Handle SRAM saving failure."
YoshiRulz Apr 27, 2026
2287081
Revert "Move stuff around to make more sense for ask-user-about-savin…
YoshiRulz Apr 27, 2026
399214d
revert intervening changeset 2 to `IMainFormForTools.cs`
YoshiRulz Apr 27, 2026
d82cc7e
revert intervening changeset 1 to `IMainFormForTools.cs`
YoshiRulz Apr 27, 2026
9b170ec
Revert "Update comments, rename method, and remove obsolete things."
YoshiRulz Apr 27, 2026
d26da27
Revert "Handle most errors related to savestate files. Autosave last …
YoshiRulz Apr 27, 2026
5c348c0
Revert "Add support for backup files in FileWriter and better error r…
YoshiRulz Apr 27, 2026
6d4754e
Revert "Handle exceptions while writing a movie file, and use a tempo…
YoshiRulz Apr 27, 2026
8ce0512
reapply intervening changeset 1 to `IMainFormForTools.cs`
YoshiRulz Apr 27, 2026
a164223
reapply intervening changeset 2 to `IMainFormForTools.cs`
YoshiRulz Apr 27, 2026
974dbc7
reapply intervening changes to `LuaConsole.cs`
YoshiRulz Apr 27, 2026
d98c3c2
reapply intervening changes to `MovieZone.cs`
YoshiRulz Apr 27, 2026
1c84b2b
reapply intervening changeset 2 to `TAStudio.MenuItems.cs`
YoshiRulz Apr 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .global.editorconfig.ini
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,6 @@ dotnet_diagnostic.CA2229.severity = silent
# Opt in to preview features before using them
dotnet_diagnostic.CA2252.severity = silent # CSharpDetectPreviewFeatureAnalyzer very slow

## Nullable rules; generics are a bit wonky and I have no idea why we're allowed to configure these to be not errors or why they aren't errors by default.

# Nullability of reference types in value doesn't match target type.
dotnet_diagnostic.CS8619.severity = error
# Make Foo<string?> an error for class Foo<T> where T : class. Use `where T : class?` if Foo<string?> should be allowed.
dotnet_diagnostic.CS8634.severity = error
# Nullability of type argument doesn't match 'notnull' constraint.
dotnet_diagnostic.CS8714.severity = error

## .NET DocumentationAnalyzers style rules

# Place text in paragraphs
Expand Down
14 changes: 2 additions & 12 deletions src/BizHawk.Client.Common/Api/Classes/EmuClientApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void CallStateSaved(object sender, StateSavedEventArgs args)

public void CloseEmulator(int? exitCode = null) => _mainForm.CloseEmulator(exitCode);

public void CloseRom() => _mainForm.LoadNullRom();
public void CloseRom() => _mainForm.CloseRom();

public void DisplayMessages(bool value) => _config.DisplayMessages = value;

Expand Down Expand Up @@ -160,19 +160,9 @@ public bool OpenRom(string path)

public void RebootCore() => _mainForm.RebootCore();

// TODO: Change return type to FileWriteResult.
public void SaveRam() => _mainForm.FlushSaveRAM();

// TODO: Change return type to FileWriteResult.
// We may wish to change more than that, since we have a mostly-dupicate ISaveStateApi.Save, neither has documentation indicating what the differences are.
public void SaveState(string name)
{
FileWriteResult result = _mainForm.SaveState(Path.Combine(_config.PathEntries.SaveStateAbsolutePath(Game.System), $"{name}.State"), name);
if (result.Exception != null && result.Exception is not UnlessUsingApiException)
{
throw result.Exception;
}
}
public void SaveState(string name) => _mainForm.SaveState(Path.Combine(_config.PathEntries.SaveStateAbsolutePath(Game.System), $"{name}.State"), name, fromLua: false);

public int ScreenHeight() => _displayManager.GetPanelNativeSize().Height;

Expand Down
4 changes: 1 addition & 3 deletions src/BizHawk.Client.Common/Api/Classes/MovieApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public string GetInputAsMnemonic(int frame)
return Bk2LogEntryGenerator.GenerateLogEntry(_movieSession.Movie.GetInputState(frame));
}

// TODO: Change return type to FileWriteResult
public void Save(string filename)
{
if (_movieSession.Movie.NotActive())
Expand All @@ -70,8 +69,7 @@ public void Save(string filename)
}
_movieSession.Movie.Filename = filename;
}
FileWriteResult result = _movieSession.Movie.Save();
if (result.Exception != null) throw result.Exception;
_movieSession.Movie.Save();
}

public IReadOnlyDictionary<string, string> GetHeader()
Expand Down
17 changes: 2 additions & 15 deletions src/BizHawk.Client.Common/Api/Classes/SaveStateApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,8 @@ public bool LoadSlot(int slotNum, bool suppressOSD)
return _mainForm.LoadQuickSave(slotNum, suppressOSD: suppressOSD);
}

// TODO: Change return type FileWriteResult.
public void Save(string path, bool suppressOSD)
{
FileWriteResult result = _mainForm.SaveState(path, path, suppressOSD);
if (result.Exception != null && result.Exception is not UnlessUsingApiException)
{
throw result.Exception;
}
}
public void Save(string path, bool suppressOSD) => _mainForm.SaveState(path, path, true, suppressOSD);

// TODO: Change return type to FileWriteResult.
public void SaveSlot(int slotNum, bool suppressOSD)
{
if (slotNum is < 0 or > 10) throw new ArgumentOutOfRangeException(paramName: nameof(slotNum), message: ERR_MSG_NOT_A_SLOT);
Expand All @@ -58,11 +49,7 @@ public void SaveSlot(int slotNum, bool suppressOSD)
LogCallback(ERR_MSG_USE_SLOT_10);
slotNum = 10;
}
FileWriteResult result = _mainForm.SaveQuickSave(slotNum, suppressOSD: suppressOSD);
if (result.Exception != null && result.Exception is not UnlessUsingApiException)
{
throw result.Exception;
}
_mainForm.SaveQuickSave(slotNum, suppressOSD: suppressOSD, fromLua: true);
}
}
}
50 changes: 0 additions & 50 deletions src/BizHawk.Client.Common/DialogControllerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
#nullable enable

using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;

namespace BizHawk.Client.Common
{
public enum TryAgainResult
{
Saved,
IgnoredFailure,
Canceled,
}

public static class DialogControllerExtensions
{
public static void AddOnScreenMessage(
Expand Down Expand Up @@ -72,48 +64,6 @@ public static bool ModalMessageBox2(
EMsgBoxIcon? icon = null)
=> dialogParent.DialogController.ShowMessageBox3(owner: dialogParent, text: text, caption: caption, icon: icon);

public static void ErrorMessageBox(
this IDialogParent dialogParent,
FileWriteResult fileResult,
string? prefixMessage = null)
{
Debug.Assert(fileResult.IsError && fileResult.Exception != null, "Error box must have an error.");

string prefix = prefixMessage ?? "";
dialogParent.ModalMessageBox(
text: $"{prefix}\n{fileResult.UserFriendlyErrorMessage()}\n{fileResult.Exception!.Message}",
caption: "Error",
icon: EMsgBoxIcon.Error);
}

/// <summary>
/// If the action fails, asks the user if they want to try again.
/// The user will be repeatedly asked if they want to try again until either success or the user says no.
/// </summary>
/// <returns>Returns true on success or if the user said no. Returns false if the user said cancel.</returns>
public static TryAgainResult DoWithTryAgainBox(
this IDialogParent dialogParent,
Func<FileWriteResult> action,
string message)
{
FileWriteResult fileResult = action();
while (fileResult.IsError)
{
bool? askResult = dialogParent.ModalMessageBox3(
caption: "Failed to write file",
text: $"{message} Do you want to try again?"
+ $"\nError details: {fileResult.UserFriendlyErrorMessage()}"
+ $"\n\nFull info for debugging:\n--------------------\n{fileResult.Exception}\n--------------------"
+ "\n\n(Retry?)",
icon: EMsgBoxIcon.Warning);
if (askResult == null) return TryAgainResult.Canceled;
if (askResult == false) return TryAgainResult.IgnoredFailure;
if (askResult == true) fileResult = action();
}

return TryAgainResult.Saved;
}

/// <summary>Creates and shows a <c>System.Windows.Forms.OpenFileDialog</c> or equivalent with the receiver (<paramref name="dialogParent"/>) as its parent</summary>
/// <param name="discardCWDChange"><c>OpenFileDialog.RestoreDirectory</c> (isn't this useless when specifying <paramref name="initDir"/>? keeping it for backcompat)</param>
/// <param name="filter"><c>OpenFileDialog.Filter</c></param>
Expand Down
131 changes: 0 additions & 131 deletions src/BizHawk.Client.Common/FileWriteResult.cs

This file was deleted.

Loading
Loading