Move `&&`/`||` to start of next line in EmuHawk project

This commit is contained in:
James Groom 2024-03-27 16:10:32 +00:00 committed by GitHub
parent 8987ba8650
commit b0ba7a1246
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 63 additions and 110 deletions

View File

@ -377,38 +377,27 @@ namespace BizHawk.Client.EmuHawk
/// </summary>
public void SetVideoParameters(int width, int height)
{
var change = _parameters.width != width ||
_parameters.height != height;
var change = width != _parameters.width || height != _parameters.height;
if (!change) return;
_parameters.width = width;
_parameters.height = height;
if (change)
{
Segment();
}
}
/// <summary>
/// set basic audio parameters for the avi file. must be set before the file isopened.
/// </summary>
public void SetAudioParameters(int sampleRate, int channels, int bits)
{
var change = _parameters.a_samplerate != sampleRate ||
_parameters.a_channels != channels ||
_parameters.a_bits != bits ||
_parameters.has_audio != true;
var change = !_parameters.has_audio || sampleRate != _parameters.a_samplerate
|| channels != _parameters.a_channels || bits != _parameters.a_bits;
if (!change) return;
_parameters.a_samplerate = sampleRate;
_parameters.a_channels = channels;
_parameters.a_bits = bits;
_parameters.has_audio = true;
if (change)
{
Segment();
}
}
public class CodecToken : IDisposable
{

View File

@ -1593,8 +1593,8 @@ namespace BizHawk.Client.EmuHawk
_lastCell = CurrentCell;
CurrentCell = newCell;
if (PointedCellChanged != null &&
(_lastCell?.Column != CurrentCell.Column || _lastCell?.RowIndex != CurrentCell.RowIndex))
if (PointedCellChanged is not null
&& !(_lastCell?.Column == CurrentCell.Column && _lastCell?.RowIndex == CurrentCell.RowIndex)) //TODO isn't this just `Cell.==`? --yoshi
{
PointedCellChanged(this, new CellEventArgs(_lastCell, CurrentCell));
}

View File

@ -15,8 +15,8 @@ namespace BizHawk.Client.EmuHawk
/// <remarks>http://stackoverflow.com/questions/139010/how-to-resolve-a-lnk-in-c-sharp</remarks>
public static string ResolveShortcut(string filename)
{
if (filename.Contains("|") || OSTailoredCode.IsUnixHost ||
!".lnk".Equals(Path.GetExtension(filename), StringComparison.OrdinalIgnoreCase))
if (OSTailoredCode.IsUnixHost || filename.Contains("|")
|| !".lnk".Equals(Path.GetExtension(filename), StringComparison.OrdinalIgnoreCase))
{
return filename; // archive internal files are never shortcuts (and choke when analyzing any further)
}

View File

@ -1944,10 +1944,8 @@ namespace BizHawk.Client.EmuHawk
DumpStatusButton.ToolTipText = "Verified good dump";
}
if (_multiDiskMode && !(
Game.Status == RomStatus.Imperfect ||
Game.Status == RomStatus.Unimplemented ||
Game.Status == RomStatus.NotWorking))
if (_multiDiskMode
&& Game.Status is not (RomStatus.Imperfect or RomStatus.Unimplemented or RomStatus.NotWorking))
{
DumpStatusButton.ToolTipText = "Multi-disk bundler";
DumpStatusButton.Image = Properties.Resources.RetroQuestion;
@ -3264,14 +3262,17 @@ namespace BizHawk.Client.EmuHawk
CalcFramerateAndUpdateDisplay(currentTimestamp, isRewinding, isFastForwarding);
}
if (Tools.IsLoaded<TAStudio>() &&
Tools.TAStudio.LastPositionFrame == Emulator.Frame)
if (IsSeeking && PauseOnFrame.Value <= Emulator.Frame)
{
if (PauseOnFrame.HasValue &&
PauseOnFrame.Value <= Tools.TAStudio.LastPositionFrame)
if (PauseOnFrame.Value == Emulator.Frame)
{
var record = (MovieSession.Movie as ITasMovie)[Emulator.Frame];
if (!record.Lagged.HasValue && IsSeeking)
PauseEmulator();
if (Tools.IsLoaded<TAStudio>()) Tools.TAStudio.StopSeeking();
else PauseOnFrame = null;
}
else if (Tools.IsLoaded<TAStudio>()
&& Tools.TAStudio.LastPositionFrame == Emulator.Frame
&& ((ITasMovie) MovieSession.Movie)[Emulator.Frame].Lagged is null)
{
// haven't yet greenzoned the frame, hence it's after editing
// then we want to pause here. taseditor fashion
@ -3279,20 +3280,6 @@ namespace BizHawk.Client.EmuHawk
}
}
}
if (IsSeeking && Emulator.Frame == PauseOnFrame.Value)
{
PauseEmulator();
if (Tools.IsLoaded<TAStudio>())
{
Tools.TAStudio.StopSeeking();
}
else
{
PauseOnFrame = null;
}
}
}
else if (isRewinding)
{
// Tools will want to be updated after rewind (load state), but we only need to manually do this if we did not frame advance.

View File

@ -48,10 +48,9 @@ namespace BizHawk.Client.EmuHawk
private void OkBtn_Click(object sender, EventArgs e)
{
bool changed =
_settings.OSDMessageVerbosity.ToString() != osdMessageVerbositycomboBox1.SelectedItem.ToString() ||
_settings.BackgroundColor != _bgColor ||
_settings.UseCoreBorderForBackground != checkBoxShowCoreBrdColor.Checked;
var changed = checkBoxShowCoreBrdColor.Checked != _settings.UseCoreBorderForBackground
|| _bgColor != _settings.BackgroundColor
|| osdMessageVerbositycomboBox1.SelectedItem.ToString() != _settings.OSDMessageVerbosity.ToString();
if (changed)
{

View File

@ -595,15 +595,11 @@ namespace BizHawk.Client.EmuHawk
_config.TurboSeek = TurboCheckbox.Checked;
Run();
_movieSession.ReadOnly = ReadOnlyCheckBox.Checked;
if (StopOnFrameCheckbox.Checked &&
(StopOnFrameTextBox.ToRawInt().HasValue || LastFrameCheckbox.Checked))
if (StopOnFrameCheckbox.Checked)
{
_mainForm.PauseOnFrame = LastFrameCheckbox.Checked
? _movieSession.Movie.InputLogLength
: StopOnFrameTextBox.ToRawInt();
if (LastFrameCheckbox.Checked) _mainForm.PauseOnFrame = _movieSession.Movie.InputLogLength;
else if (StopOnFrameTextBox.ToRawInt() is int i) _mainForm.PauseOnFrame = i;
}
Close();
}

View File

@ -94,12 +94,11 @@ namespace BizHawk.Client.EmuHawk
{
foreach (var callback in Mcs)
{
if (!_breakpoints.Any(b =>
b.Type == callback.Type &&
b.Address == callback.Address &&
b.AddressMask == callback.AddressMask &&
b.Name == callback.Name &&
b.Callback == callback.Callback))
if (!_breakpoints.Any(b => b.Type == callback.Type
&& b.Address == callback.Address
&& b.AddressMask == callback.AddressMask
&& b.Name == callback.Name
&& b.Callback == callback.Callback))
{
_breakpoints.Add(new Breakpoint(Core, callback));
}

View File

@ -906,9 +906,8 @@ namespace BizHawk.Client.EmuHawk
if (_secondaryHighlightedAddresses.Any())
{
MainForm.CheatList.RemoveRange(
MainForm.CheatList.Where(
cheat => !cheat.IsSeparator && cheat.Domain == _domain &&
_secondaryHighlightedAddresses.Contains(cheat.Address ?? 0)));
MainForm.CheatList.Where(cheat => !cheat.IsSeparator && cheat.Domain == _domain
&& _secondaryHighlightedAddresses.Contains(cheat.Address ?? 0)));
}
MemoryViewerBox.Refresh();
@ -1539,10 +1538,8 @@ namespace BizHawk.Client.EmuHawk
AddToRamWatchMenuItem.Enabled =
_highlightedAddress.HasValue;
PokeAddressMenuItem.Enabled =
FreezeAddressMenuItem.Enabled =
_highlightedAddress.HasValue &&
_domain.Writable;
PokeAddressMenuItem.Enabled = FreezeAddressMenuItem.Enabled
= _highlightedAddress is not null && _domain.Writable;
}
private void MemoryDomainsMenuItem_DropDownOpened(object sender, EventArgs e)
@ -1966,25 +1963,19 @@ namespace BizHawk.Client.EmuHawk
{
var data = Clipboard.GetDataObject();
CopyContextItem.Visible =
AddToRamWatchContextItem.Visible =
_highlightedAddress.HasValue || _secondaryHighlightedAddresses.Any();
var selectionNotEmpty = _highlightedAddress is not null || _secondaryHighlightedAddresses.Any();
CopyContextItem.Visible = AddToRamWatchContextItem.Visible = selectionNotEmpty;
FreezeContextItem.Visible =
PokeContextItem.Visible =
IncrementContextItem.Visible =
DecrementContextItem.Visible =
ContextSeparator2.Visible =
(_highlightedAddress.HasValue || _secondaryHighlightedAddresses.Any()) &&
_domain.Writable;
FreezeContextItem.Visible = PokeContextItem.Visible
= IncrementContextItem.Visible
= DecrementContextItem.Visible
= ContextSeparator2.Visible
= selectionNotEmpty && _domain.Writable;
UnfreezeAllContextItem.Visible = MainForm.CheatList.AnyActive;
PasteContextItem.Visible = _domain.Writable && data != null && data.GetDataPresent(DataFormats.Text);
ContextSeparator1.Visible =
_highlightedAddress.HasValue ||
_secondaryHighlightedAddresses.Any() ||
(data != null && data.GetDataPresent(DataFormats.Text));
ContextSeparator1.Visible = selectionNotEmpty || data?.GetDataPresent(DataFormats.Text) is true;
if (_highlightedAddress.HasValue && IsFrozen(_highlightedAddress.Value))
{

View File

@ -50,8 +50,8 @@ namespace BizHawk.Client.EmuHawk
private void PathBox_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop) &&
((string[])e.Data.GetData(DataFormats.FileDrop)).Length == 1)
if (e.Data.GetDataPresent(DataFormats.FileDrop)
&& ((string[]) e.Data.GetData(DataFormats.FileDrop)).Length is 1)
{
e.Effect = DragDropEffects.Copy;
}

View File

@ -142,10 +142,8 @@ namespace BizHawk.Client.EmuHawk
}
// Highlight the branch cell a little, if hovering over it
if (BranchView.CurrentCell.IsDataCell()
&& BranchView.CurrentCell.Column.Name == BranchNumberColumnName &&
column.Name == BranchNumberColumnName &&
index == BranchView.CurrentCell.RowIndex)
if (BranchView.CurrentCell is { RowIndex: int targetRow, Column.Name: BranchNumberColumnName }
&& index == targetRow && column.Name is BranchNumberColumnName)
{
color = Color.FromArgb((byte)(color.A - 24), (byte)(color.R - 24), (byte)(color.G - 24), (byte)(color.B - 24));
}
@ -676,11 +674,10 @@ namespace BizHawk.Client.EmuHawk
{
if (e.NewCell?.RowIndex != null && e.NewCell.Column != null && e.NewCell.RowIndex < Branches.Count)
{
if (BranchView.CurrentCell.Column.Name == BranchNumberColumnName &&
BranchView.CurrentCell.RowIndex.HasValue &&
BranchView.CurrentCell.RowIndex < Branches.Count)
if (BranchView.CurrentCell is { RowIndex: int targetRow, Column.Name: BranchNumberColumnName }
&& targetRow < Branches.Count)
{
var branch = Branches[BranchView.CurrentCell.RowIndex.Value];
var branch = Branches[targetRow];
Point location = PointToScreen(Location);
int width = branch.OSDFrameBuffer.Width;
int height = branch.OSDFrameBuffer.Height;

View File

@ -915,9 +915,7 @@ namespace BizHawk.Client.EmuHawk
if (e.Button == MouseButtons.Left)
{
if (TasView.CurrentCell.RowIndex.HasValue &&
TasView.CurrentCell.Column.Name == FrameColumnName &&
!AxisEditingMode)
if (!AxisEditingMode && TasView.CurrentCell is { RowIndex: not null, Column.Name: FrameColumnName })
{
var existingMarker = CurrentTasMovie.Markers.FirstOrDefault(m => m.Frame == TasView.CurrentCell.RowIndex.Value);

View File

@ -22,9 +22,8 @@ namespace BizHawk.Client.EmuHawk
private void FileSubMenu_DropDownOpened(object sender, EventArgs e)
{
ToBk2MenuItem.Enabled =
!string.IsNullOrWhiteSpace(CurrentTasMovie.Filename) &&
(CurrentTasMovie.Filename != DefaultTasProjName());
ToBk2MenuItem.Enabled = !string.IsNullOrWhiteSpace(CurrentTasMovie.Filename)
&& CurrentTasMovie.Filename != DefaultTasProjName();
saveSelectionToMacroToolStripMenuItem.Enabled =
placeMacroAtSelectionToolStripMenuItem.Enabled =

View File

@ -1137,13 +1137,11 @@ namespace BizHawk.Client.EmuHawk
MoveBottomContextMenuItem.Visible =
WatchListView.AnyRowsSelected;
ReadBreakpointContextMenuItem.Visible =
WriteBreakpointContextMenuItem.Visible =
Separator6.Visible =
SelectedWatches.Any() &&
Debuggable != null &&
Debuggable.MemoryCallbacksAvailable() &&
SelectedWatches.All(w => w.Domain.Name == (MemoryDomains != null ? MemoryDomains.SystemBus.Name : ""));
var sysBusName = MemoryDomains?.SystemBus?.Name ?? string.Empty;
ReadBreakpointContextMenuItem.Visible = WriteBreakpointContextMenuItem.Visible
= Separator6.Visible
= Debuggable?.MemoryCallbacksAvailable() is true
&& SelectedWatches.Any() && SelectedWatches.All(w => w.Domain.Name == sysBusName);
SplitContextMenuItem.Enabled = MaySplitAllSelected;