Skip to content

Commit dc44b1e

Browse files
committed
correctly clears selected brush if that brush is deleted
1 parent 0a6941f commit dc44b1e

File tree

1 file changed

+37
-25
lines changed

1 file changed

+37
-25
lines changed

Starstructor/GUI/MainWindow.cs

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -378,31 +378,42 @@ public void UpdateBottomBar(int gridX, int gridY)
378378

379379
public void SetSelectedBrush(EditorBrush brush)
380380
{
381-
m_selectedBrush = brush;
382-
string colour = m_selectedBrush.Colour.ToString();
383-
384-
// Tidy this display up at some point
385-
BottomBarBrushLabel.Text = m_selectedBrush.Comment;
386-
387-
if (m_selectedBrush.FrontAsset != null)
388-
{
389-
BottomBarBrushLabel.Text += " front: " + m_selectedBrush.FrontAsset.ToString();
390-
}
391-
392-
if (m_selectedBrush.BackAsset != null)
393-
{
394-
BottomBarBrushLabel.Text += " back: " + m_selectedBrush.BackAsset.ToString();
395-
}
396-
397-
BottomBarBrushLabel.Text += " " + colour;
398-
399-
// Populate the colour box
400-
VisualRgbaBrushImageBox.Image = EditorHelpers.GetGeneratedRectangle(1, 1,
401-
m_selectedBrush.Colour.R, m_selectedBrush.Colour.G,
402-
m_selectedBrush.Colour.B, m_selectedBrush.Colour.A);
403-
404-
VisualGraphicBrushImageBox.Image = m_selectedBrush.GetAssetPreview();
405-
381+
m_selectedBrush = brush;
382+
383+
if (brush != null)
384+
{
385+
string colour = m_selectedBrush.Colour.ToString();
386+
387+
// Tidy this display up at some point
388+
BottomBarBrushLabel.Text = m_selectedBrush.Comment;
389+
390+
if (m_selectedBrush.FrontAsset != null)
391+
{
392+
BottomBarBrushLabel.Text += " front: " + m_selectedBrush.FrontAsset.ToString();
393+
}
394+
395+
if (m_selectedBrush.BackAsset != null)
396+
{
397+
BottomBarBrushLabel.Text += " back: " + m_selectedBrush.BackAsset.ToString();
398+
}
399+
400+
BottomBarBrushLabel.Text += " " + colour;
401+
402+
// Populate the colour box
403+
VisualRgbaBrushImageBox.Image = EditorHelpers.GetGeneratedRectangle(1, 1,
404+
m_selectedBrush.Colour.R, m_selectedBrush.Colour.G,
405+
m_selectedBrush.Colour.B, m_selectedBrush.Colour.A);
406+
407+
VisualGraphicBrushImageBox.Image = m_selectedBrush.GetAssetPreview();
408+
}
409+
else
410+
{
411+
Image white = EditorHelpers.GetGeneratedRectangle(1, 1, 255, 255, 255, 255);
412+
BottomBarBrushLabel.Text = "";
413+
VisualRgbaBrushImageBox.Image = white;
414+
VisualGraphicBrushImageBox.Image = white;
415+
}
416+
406417
MainPictureBox.SetSelectedBrush(m_selectedBrush);
407418
UpdatePropertiesPanel();
408419
}
@@ -1175,6 +1186,7 @@ private void deleteBrushToolStripMenuItem_Click(object sender, EventArgs e)
11751186
part.UpdateCompositeCollisionMap();
11761187
}
11771188

1189+
SetSelectedBrush(null);
11781190
SelectedMap = SelectedMap;
11791191
}
11801192
}

0 commit comments

Comments
 (0)