Skip to content

Commit

Permalink
Support for multiple Blast Editor instances
Browse files Browse the repository at this point in the history
  • Loading branch information
ircluzar committed Feb 10, 2024
1 parent de44ed4 commit 4ae6953
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
XTesb3QPLh88M+QwdP6m681Lt7xuXbu94vbgcOjwnZHokdE77DtTd1PuvriXeW/h/sYH6AdFD6UeVjxS
fNTws+7PbaOWo6fHXMf6Hwc/vj/OGn/2S8Yv7ycKnpCfVEyqTDZPmU2dmnafvvF05dOJZ+nPFmYKf5X+
tfa5zvMffnP8rX82YnbiBf/Fp99LXsq/PPRq2aueuYC5R69TXy/MF72Rf3P4LeNt37vwd5MLWe+x7ys/
6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALEgAACxIB0t1+/AAAAJZJREFUOE/NkVENgDAM
6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALEQAACxEBf2RfkQAAAJZJREFUOE/NkVENgDAM
RJGABCRMApKQgAOkIAEpSMDByt1SklFaIOGHS97PXncroRGRT7iHNTnnXhmVRRHiXUg6sB1Dd3gFfM0d
9nhTsAJuNAF+Aj23LHN3Bcm6mscCe275cQHoAeO5mjIXCsRzLaAflFgg9UXCv7KCU0KB2IIZXBIK5E3B
FgpgCzqwgCPcOoUC2AIHaXaY21nPxgmCiQAAAABJRU5ErkJggg==
Expand Down Expand Up @@ -218,7 +218,7 @@
XTesb3QPLh88M+QwdP6m681Lt7xuXbu94vbgcOjwnZHokdE77DtTd1PuvriXeW/h/sYH6AdFD6UeVjxS
fNTws+7PbaOWo6fHXMf6Hwc/vj/OGn/2S8Yv7ycKnpCfVEyqTDZPmU2dmnafvvF05dOJZ+nPFmYKf5X+
tfa5zvMffnP8rX82YnbiBf/Fp99LXsq/PPRq2aueuYC5R69TXy/MF72Rf3P4LeNt37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reK1mdj5G1t7A7hl
Expand Down Expand Up @@ -327,7 +327,7 @@
XTesb3QPLh88M+QwdP6m681Lt7xuXbu94vbgcOjwnZHokdE77DtTd1PuvriXeW/h/sYH6AdFD6UeVjxS
fNTws+7PbaOWo6fHXMf6Hwc/vj/OGn/2S8Yv7ycKnpCfVEyqTDZPmU2dmnafvvF05dOJZ+nPFmYKf5X+
tfa5zvMffnP8rX82YnbiBf/Fp99LXsq/PPRq2aueuYC5R69TXy/MF72Rf3P4LeNt37vwd5MLWe+x7ys/
6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALEgAACxIB0t1+/AAAAOVJREFUOE+NklERwjAQ
6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALEQAACxEBf2RfkQAAAOVJREFUOE+NklERwjAQ
RCMBCUioBH74RwISkIADJCABCUhAAhIqodzrZDOb9GD4eMN1d+9yKS3LsXxjF8wV6iyTi5VrsFSos0wu
Bn76zy02QkWn8+v1JqtiCg4BoVvgp/o2eGTI0rM2Y+iujp+oLUZmH/AKzgHTs/ui4ZEh2wawioZgjo0j
ZNbmYJL475CuGc1NH7KvmoPWNcMY0t1GXeCRaZqbQOBpz7x9/zfwugNaEbAW5j3gru/6DNRoeDynVzgF
Expand Down
40 changes: 21 additions & 19 deletions Source/Frontend/UI/Forms/BlastEditorForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public partial class BlastEditorForm : Modular.ColorizedForm
private const int textBoxFillWeight = 30;
private const int numericUpDownFillWeight = 35;

private static Dictionary<string, MemoryInterface> _domainToMiDico;
private Dictionary<string, MemoryInterface> _domainToMiDico;

private static Dictionary<string, MemoryInterface> DomainToMiDico
private Dictionary<string, MemoryInterface> DomainToMiDico
{
get => _domainToMiDico ?? (_domainToMiDico = new Dictionary<string, MemoryInterface>());
set => _domainToMiDico = value;
Expand Down Expand Up @@ -161,8 +161,10 @@ public static bool OpenBlastEditor(StashKey sk = null, bool silent = false)
silent = false;
}

S.GET<BlastEditorForm>().Close();
S.SET(new BlastEditorForm());
//S.GET<BlastEditorForm>().Close();
var BEF = new BlastEditorForm();

S.SET(BEF);

if (sk == null)
{
Expand All @@ -174,12 +176,12 @@ public static bool OpenBlastEditor(StashKey sk = null, bool silent = false)
//TODO
if (sk.BlastLayer.Layer.Count > 5000 && (DialogResult.Yes == MessageBox.Show($"You're trying to open a blastlayer of size " + sk.BlastLayer.Layer.Count + ". This could take a while. Are you sure you want to continue?", "Opening a large BlastLayer", MessageBoxButtons.YesNo)))
{
S.GET<BlastEditorForm>().LoadStashkey(sk, silent);
BEF.LoadStashkey(sk, silent);
return true;
}
else if (sk.BlastLayer.Layer.Count <= 5000)
{
S.GET<BlastEditorForm>().LoadStashkey(sk, silent);
BEF.LoadStashkey(sk, silent);
return true;
}
else
Expand Down Expand Up @@ -432,7 +434,7 @@ public void BreakDownUnits(bool breakSelected = false)
bs = new BindingSource { DataSource = new SortableBindingList<BlastUnit>(currentSK.BlastLayer.Layer) };
batchOperation = false;
dgvBlastEditor.DataSource = bs;
updateMaximum(dgvBlastEditor.Rows.Cast<DataGridViewRow>().ToList());
updateMaximum(this, dgvBlastEditor.Rows.Cast<DataGridViewRow>().ToList());
dgvBlastEditor.Refresh();
UpdateBottom();
}
Expand Down Expand Up @@ -465,11 +467,11 @@ private void OnBlastEditorCellValueChanged(object sender, DataGridViewCellEventA
//If the Domain or SourceDomain changed update the Maximum Value
if (changedColumn.Name == BuProperty.Domain.ToString())
{
updateMaximum(dgvBlastEditor.Rows[e.RowIndex].Cells[BuProperty.Address.ToString()] as DataGridViewNumericUpDownCell, dgvBlastEditor.Rows[e.RowIndex].Cells[BuProperty.Domain.ToString()].Value.ToString());
updateMaximum(this, dgvBlastEditor.Rows[e.RowIndex].Cells[BuProperty.Address.ToString()] as DataGridViewNumericUpDownCell, dgvBlastEditor.Rows[e.RowIndex].Cells[BuProperty.Domain.ToString()].Value.ToString());
}
else if (changedColumn.Name == BuProperty.SourceDomain.ToString())
{
updateMaximum(dgvBlastEditor.Rows[e.RowIndex].Cells[BuProperty.SourceAddress.ToString()] as DataGridViewNumericUpDownCell, dgvBlastEditor.Rows[e.RowIndex].Cells[BuProperty.SourceDomain.ToString()].Value.ToString());
updateMaximum(this, dgvBlastEditor.Rows[e.RowIndex].Cells[BuProperty.SourceAddress.ToString()] as DataGridViewNumericUpDownCell, dgvBlastEditor.Rows[e.RowIndex].Cells[BuProperty.SourceDomain.ToString()].Value.ToString());
}
UpdateBottom();
}
Expand Down Expand Up @@ -770,31 +772,31 @@ private void OnBlastEditorColumnHeaderMouseClick(object sender, DataGridViewCell
RefreshAllNoteIcons();
}

private static void updateMaximum(List<DataGridViewRow> rows)
private static void updateMaximum(BlastEditorForm BEF, List<DataGridViewRow> rows)
{
foreach (DataGridViewRow row in rows)
{
var bu = row.DataBoundItem as BlastUnit;
var domain = bu.Domain;
var sourceDomain = bu.SourceDomain;

if (domain != null && DomainToMiDico.ContainsKey(bu.Domain ?? ""))
if (domain != null && BEF.DomainToMiDico.ContainsKey(bu.Domain ?? ""))
{
(row.Cells[BuProperty.Address.ToString()] as DataGridViewNumericUpDownCell).Maximum = DomainToMiDico[domain].Size - 1;
(row.Cells[BuProperty.Address.ToString()] as DataGridViewNumericUpDownCell).Maximum = BEF.DomainToMiDico[domain].Size - 1;
}

if (sourceDomain != null && DomainToMiDico.ContainsKey(bu.SourceDomain ?? ""))
if (sourceDomain != null && BEF.DomainToMiDico.ContainsKey(bu.SourceDomain ?? ""))
{
(row.Cells[BuProperty.SourceAddress.ToString()] as DataGridViewNumericUpDownCell).Maximum = DomainToMiDico[sourceDomain].Size - 1;
(row.Cells[BuProperty.SourceAddress.ToString()] as DataGridViewNumericUpDownCell).Maximum = BEF.DomainToMiDico[sourceDomain].Size - 1;
}
}
}

private static void updateMaximum(DataGridViewNumericUpDownCell cell, string domain)
private static void updateMaximum(BlastEditorForm BEF, DataGridViewNumericUpDownCell cell, string domain)
{
if (DomainToMiDico.ContainsKey(domain))
if (BEF.DomainToMiDico.ContainsKey(domain))
{
cell.Maximum = DomainToMiDico[domain].Size - 1;
cell.Maximum = BEF.DomainToMiDico[domain].Size - 1;
}
else
{
Expand Down Expand Up @@ -867,7 +869,7 @@ private void OnBlastEditorSelectionChange(object sender, EventArgs e)
}

//Rather than setting all these values at load, we set it on the fly
updateMaximum(col);
updateMaximum(this, col);
}

private void OnBlastEditorCellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
Expand Down Expand Up @@ -1509,7 +1511,7 @@ public void RasterizeVMDs()

batchOperation = false;
dgvBlastEditor.DataSource = bs;
updateMaximum(dgvBlastEditor.Rows.Cast<DataGridViewRow>().ToList());
updateMaximum(this, dgvBlastEditor.Rows.Cast<DataGridViewRow>().ToList());
dgvBlastEditor.Refresh();
UpdateBottom();
}
Expand Down
1 change: 1 addition & 0 deletions Source/Frontend/UI/Forms/StockpilePlayerForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ private void OnStockpileMouseDown(object sender, MouseEventArgs e)
(columnsMenu.Items.Add("Show Game Name", null, new EventHandler((ob, ev) => { dgvStockpile.Columns["GameName"].Visible ^= true; })) as ToolStripMenuItem).Checked = dgvStockpile.Columns["GameName"].Visible;
(columnsMenu.Items.Add("Show System Name", null, new EventHandler((ob, ev) => { dgvStockpile.Columns["SystemName"].Visible ^= true; })) as ToolStripMenuItem).Checked = dgvStockpile.Columns["SystemName"].Visible;
(columnsMenu.Items.Add("Show System Core", null, new EventHandler((ob, ev) => { dgvStockpile.Columns["SystemCore"].Visible ^= true; })) as ToolStripMenuItem).Checked = dgvStockpile.Columns["SystemCore"].Visible;
//TODO: Blast Layer Size
(columnsMenu.Items.Add("Show Note", null, new EventHandler((ob, ev) => { dgvStockpile.Columns["Note"].Visible ^= true; })) as ToolStripMenuItem).Checked = dgvStockpile.Columns["Note"].Visible;
columnsMenu.Items.Add(stripSeparator);
(columnsMenu.Items.Add("Load on Select", null, new EventHandler((ob, ev) => { S.GET<GlitchHarvesterBlastForm>().LoadOnSelect ^= true; })) as ToolStripMenuItem).Checked = S.GET<GlitchHarvesterBlastForm>().LoadOnSelect;
Expand Down

0 comments on commit 4ae6953

Please sign in to comment.