public async Task SaveAndDownloadAsync() { IsError = false; try { SramFile.ThrowIfNull(nameof(SramFile)); MemoryStream stream = new(); SramFile.Save(stream); byte[]? bytes; if (IsSavestate && ConvertSrmStreamToSavestate(Options, stream, CurrentFileStream !) is { } savestateData) { bytes = savestateData.GetBytes(); } else { bytes = stream.GetBuffer(); } await JsRuntime.StartDownloadAsync(CurrentFileName !, bytes); Changed = false; }
private void InternalGetOffsetValue() { IsError = false; try { CurrentFileSaveSlot.ThrowIfDefault(nameof(CurrentFileSaveSlot)); SramFile.ThrowIfNull(nameof(SramFile)); OffsetValue = SramFile.GetOffsetByte(CurrentFileSaveSlot.ToInt() - 1, OffsetAddress); var valueDisplayText = NumberFormatter.FormatDecHexBin((byte)OffsetValue); OutputMessage = Resources.StatusGetOffsetValueTemplate.InsertArgs(OffsetAddress, valueDisplayText) .ColorText(Color.Green).ToMarkup(); } catch (Exception ex) { OutputMessage = ex.GetColoredMessage(); IsError = true; } }
public async Task SetOffsetValueAsync() { IsError = false; try { await SaveOptionsAsync(); SramFile.ThrowIfNull(nameof(SramFile)); SramFile.SetOffsetValue(Options.CurrentFileSaveSlot - 1, OffsetAddress, (byte)OffsetValue); var valueDisplayText = NumberFormatter.FormatDecHexBin((byte)OffsetValue); OutputMessage = Resources.StatusSetOffsetValueTemplate.InsertArgs(OffsetAddress, valueDisplayText).ColorText(Color.Green).ToMarkup(); Changed = true; } catch (Exception ex) { OutputMessage = ex.GetColoredMessage(); IsError = true; } }