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

View File

@ -1593,8 +1593,8 @@ namespace BizHawk.Client.EmuHawk
_lastCell = CurrentCell; _lastCell = CurrentCell;
CurrentCell = newCell; CurrentCell = newCell;
if (PointedCellChanged != null && if (PointedCellChanged is not null
(_lastCell?.Column != CurrentCell.Column || _lastCell?.RowIndex != CurrentCell.RowIndex)) && !(_lastCell?.Column == CurrentCell.Column && _lastCell?.RowIndex == CurrentCell.RowIndex)) //TODO isn't this just `Cell.==`? --yoshi
{ {
PointedCellChanged(this, new CellEventArgs(_lastCell, CurrentCell)); 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> /// <remarks>http://stackoverflow.com/questions/139010/how-to-resolve-a-lnk-in-c-sharp</remarks>
public static string ResolveShortcut(string filename) public static string ResolveShortcut(string filename)
{ {
if (filename.Contains("|") || OSTailoredCode.IsUnixHost || if (OSTailoredCode.IsUnixHost || filename.Contains("|")
!".lnk".Equals(Path.GetExtension(filename), StringComparison.OrdinalIgnoreCase)) || !".lnk".Equals(Path.GetExtension(filename), StringComparison.OrdinalIgnoreCase))
{ {
return filename; // archive internal files are never shortcuts (and choke when analyzing any further) 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"; DumpStatusButton.ToolTipText = "Verified good dump";
} }
if (_multiDiskMode && !( if (_multiDiskMode
Game.Status == RomStatus.Imperfect || && Game.Status is not (RomStatus.Imperfect or RomStatus.Unimplemented or RomStatus.NotWorking))
Game.Status == RomStatus.Unimplemented ||
Game.Status == RomStatus.NotWorking))
{ {
DumpStatusButton.ToolTipText = "Multi-disk bundler"; DumpStatusButton.ToolTipText = "Multi-disk bundler";
DumpStatusButton.Image = Properties.Resources.RetroQuestion; DumpStatusButton.Image = Properties.Resources.RetroQuestion;
@ -3264,14 +3262,17 @@ namespace BizHawk.Client.EmuHawk
CalcFramerateAndUpdateDisplay(currentTimestamp, isRewinding, isFastForwarding); CalcFramerateAndUpdateDisplay(currentTimestamp, isRewinding, isFastForwarding);
} }
if (Tools.IsLoaded<TAStudio>() && if (IsSeeking && PauseOnFrame.Value <= Emulator.Frame)
Tools.TAStudio.LastPositionFrame == Emulator.Frame)
{ {
if (PauseOnFrame.HasValue && if (PauseOnFrame.Value == Emulator.Frame)
PauseOnFrame.Value <= Tools.TAStudio.LastPositionFrame)
{ {
var record = (MovieSession.Movie as ITasMovie)[Emulator.Frame]; PauseEmulator();
if (!record.Lagged.HasValue && IsSeeking) 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 // haven't yet greenzoned the frame, hence it's after editing
// then we want to pause here. taseditor fashion // 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) 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. // 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) private void OkBtn_Click(object sender, EventArgs e)
{ {
bool changed = var changed = checkBoxShowCoreBrdColor.Checked != _settings.UseCoreBorderForBackground
_settings.OSDMessageVerbosity.ToString() != osdMessageVerbositycomboBox1.SelectedItem.ToString() || || _bgColor != _settings.BackgroundColor
_settings.BackgroundColor != _bgColor || || osdMessageVerbositycomboBox1.SelectedItem.ToString() != _settings.OSDMessageVerbosity.ToString();
_settings.UseCoreBorderForBackground != checkBoxShowCoreBrdColor.Checked;
if (changed) if (changed)
{ {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -915,9 +915,7 @@ namespace BizHawk.Client.EmuHawk
if (e.Button == MouseButtons.Left) if (e.Button == MouseButtons.Left)
{ {
if (TasView.CurrentCell.RowIndex.HasValue && if (!AxisEditingMode && TasView.CurrentCell is { RowIndex: not null, Column.Name: FrameColumnName })
TasView.CurrentCell.Column.Name == FrameColumnName &&
!AxisEditingMode)
{ {
var existingMarker = CurrentTasMovie.Markers.FirstOrDefault(m => m.Frame == TasView.CurrentCell.RowIndex.Value); 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) private void FileSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
ToBk2MenuItem.Enabled = ToBk2MenuItem.Enabled = !string.IsNullOrWhiteSpace(CurrentTasMovie.Filename)
!string.IsNullOrWhiteSpace(CurrentTasMovie.Filename) && && CurrentTasMovie.Filename != DefaultTasProjName();
(CurrentTasMovie.Filename != DefaultTasProjName());
saveSelectionToMacroToolStripMenuItem.Enabled = saveSelectionToMacroToolStripMenuItem.Enabled =
placeMacroAtSelectionToolStripMenuItem.Enabled = placeMacroAtSelectionToolStripMenuItem.Enabled =

View File

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