move some repetitive logic from tools to the RollColumns class
This commit is contained in:
parent
4a3e2113af
commit
a51eba88da
|
@ -29,27 +29,23 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public new void Add(RollColumn column)
|
||||
{
|
||||
if (this.Any(c => c.Name == column.Name))
|
||||
if (this[column.Name] == null)
|
||||
{
|
||||
throw new InvalidOperationException("A column with this name already exists.");
|
||||
base.Add(column);
|
||||
ColumnsChanged();
|
||||
}
|
||||
|
||||
base.Add(column);
|
||||
ColumnsChanged();
|
||||
}
|
||||
|
||||
public new void AddRange(IEnumerable<RollColumn> collection)
|
||||
{
|
||||
var items = collection.ToList();
|
||||
foreach (var column in items)
|
||||
foreach (var column in collection)
|
||||
{
|
||||
if (this.Any(c => c.Name == column.Name))
|
||||
if (this[column.Name] == null)
|
||||
{
|
||||
throw new InvalidOperationException("A column with this name already exists.");
|
||||
Add(column);
|
||||
}
|
||||
}
|
||||
|
||||
base.AddRange(items);
|
||||
ColumnsChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -163,15 +163,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
GeneralUpdate();
|
||||
}
|
||||
|
||||
private void SetColumns()
|
||||
private void SetColumns()
|
||||
{
|
||||
foreach (var column in Settings.Columns)
|
||||
{
|
||||
if (CheatListView.AllColumns[column.Name] == null)
|
||||
{
|
||||
CheatListView.AllColumns.Add(column);
|
||||
}
|
||||
}
|
||||
CheatListView.AllColumns.AddRange(Settings.Columns);
|
||||
CheatListView.Refresh();
|
||||
}
|
||||
|
||||
private void ColumnToggleCallback()
|
||||
|
@ -549,7 +544,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
CheatListView.AllColumns.Clear();
|
||||
SetColumns();
|
||||
CheatListView.Refresh();
|
||||
}
|
||||
|
||||
private void CheatListView_DoubleClick(object sender, EventArgs e)
|
||||
|
|
|
@ -264,13 +264,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SetColumns()
|
||||
{
|
||||
foreach (var column in Settings.Columns)
|
||||
{
|
||||
if (LuaListView.AllColumns[column.Name] == null)
|
||||
{
|
||||
LuaListView.AllColumns.Add(column);
|
||||
}
|
||||
}
|
||||
LuaListView.AllColumns.AddRange(Settings.Columns);
|
||||
LuaListView.Refresh();
|
||||
}
|
||||
|
||||
private void AddFileWatches()
|
||||
|
|
|
@ -367,15 +367,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
TasView.AllColumns.Clear();
|
||||
AddColumn(CursorColumnName, "", 18);
|
||||
AddColumn(
|
||||
new RollColumn
|
||||
{
|
||||
Name = FrameColumnName,
|
||||
Text = "Frame#",
|
||||
UnscaledWidth = 68,
|
||||
Type = ColumnType.Text,
|
||||
Rotatable = true
|
||||
});
|
||||
TasView.AllColumns.Add(new RollColumn
|
||||
{
|
||||
Name = FrameColumnName,
|
||||
Text = "Frame#",
|
||||
UnscaledWidth = 68,
|
||||
Type = ColumnType.Text,
|
||||
Rotatable = true
|
||||
});
|
||||
|
||||
var columnNames = MovieSession.Movie
|
||||
.LogGeneratorInstance(MovieSession.MovieController)
|
||||
|
@ -484,14 +483,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void AddColumn(string columnName, string columnText, int columnWidth, ColumnType columnType = ColumnType.Boolean)
|
||||
{
|
||||
AddColumn(
|
||||
new RollColumn
|
||||
{
|
||||
Name = columnName,
|
||||
Text = columnText,
|
||||
UnscaledWidth = columnWidth,
|
||||
Type = columnType
|
||||
});
|
||||
TasView.AllColumns.Add(new RollColumn
|
||||
{
|
||||
Name = columnName,
|
||||
Text = columnText,
|
||||
UnscaledWidth = columnWidth,
|
||||
Type = columnType
|
||||
});
|
||||
}
|
||||
|
||||
public void LoadBranchByIndex(int index) => BookMarkControl.LoadBranchExternal(index);
|
||||
|
@ -525,14 +523,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
private void AddColumn(RollColumn column)
|
||||
{
|
||||
if (TasView.AllColumns[column.Name] == null)
|
||||
{
|
||||
TasView.AllColumns.Add(column);
|
||||
}
|
||||
}
|
||||
|
||||
private void ConvertCurrentMovieToTasproj()
|
||||
{
|
||||
MovieSession.ConvertToTasProj();
|
||||
|
|
|
@ -241,13 +241,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SetColumns()
|
||||
{
|
||||
foreach (var column in Settings.Columns)
|
||||
{
|
||||
if (WatchListView.AllColumns[column.Name] == null)
|
||||
{
|
||||
WatchListView.AllColumns.Add(column);
|
||||
}
|
||||
}
|
||||
WatchListView.AllColumns.AddRange(Settings.Columns);
|
||||
WatchListView.Refresh();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -102,13 +102,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SetColumns()
|
||||
{
|
||||
foreach (var column in Settings.Columns)
|
||||
{
|
||||
if (WatchListView.AllColumns[column.Name] == null)
|
||||
{
|
||||
WatchListView.AllColumns.Add(column);
|
||||
}
|
||||
}
|
||||
WatchListView.AllColumns.AddRange(Settings.Columns);
|
||||
WatchListView.Refresh();
|
||||
}
|
||||
|
||||
[ConfigPersist]
|
||||
|
|
Loading…
Reference in New Issue