Skip to content

Commit

Permalink
Merge pull request #44 from burninrubber0/pvs-editor-update
Browse files Browse the repository at this point in the history
PVS editor update
  • Loading branch information
burninrubber0 authored Jul 13, 2023
2 parents 4f8e6f7 + 7e01012 commit a258167
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 29 deletions.
2 changes: 1 addition & 1 deletion PVSFormat/AddZone.Designer.cs

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

1 change: 1 addition & 0 deletions PVSFormat/AddZone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ private void okButton_Click(object sender, EventArgs e)

private void cancelButton_Click(object sender, EventArgs e)
{
zone = ulong.MaxValue;
Close();
}
}
Expand Down
2 changes: 1 addition & 1 deletion PVSFormat/PVSEditControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected enum MapSectionType
Neighbour
}

protected PointF MousePosOnMap
internal PointF MousePosOnMap
{
get
{
Expand Down
21 changes: 11 additions & 10 deletions PVSFormat/PVSEditor.Designer.cs

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

78 changes: 61 additions & 17 deletions PVSFormat/PVSEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void PVSEditor_FormClosing(object sender, FormClosingEventArgs e)
Edit?.Invoke();
}

private void pvsMain_DoubleClick(object sender, System.EventArgs e)
private void pvsMain_DoubleClick(object sender, EventArgs e)
{
ulong zoneId = pvsMain.GetZoneId();
if (zoneId == ulong.MaxValue)
Expand All @@ -111,7 +111,46 @@ private void pvsMain_DoubleClick(object sender, System.EventArgs e)
zonesListBox.SelectedIndex = zonesListBox.FindStringExact(zoneId.ToString("000"));
}

private void zonesListBox_SelectedIndexChanged(object sender, System.EventArgs e)
private void pvsMain_Click(object sender, EventArgs e)
{
if (((MouseEventArgs)e).Button == MouseButtons.Right
&& pvsMain.PVS.selectedZoneId != ulong.MaxValue)
OpenContextMenu();
}

private void OpenContextMenu()
{
ContextMenuStrip menu = new();
for (int i = 0; i < 4; ++i)
menu.Items.Add("Use as point " + (i + 1).ToString());
menu.Items[0].Click += (s, e) =>
{
Vector2 pos = pvsMain.MousePosOnMap.ToVector2();
point1XNumericUpDown.Value = (decimal)pos.X;
point1YNumericUpDown.Value = (decimal)pos.Y;
};
menu.Items[1].Click += (s, e) =>
{
Vector2 pos = pvsMain.MousePosOnMap.ToVector2();
point2XNumericUpDown.Value = (decimal)pos.X;
point2YNumericUpDown.Value = (decimal)pos.Y;
};
menu.Items[2].Click += (s, e) =>
{
Vector2 pos = pvsMain.MousePosOnMap.ToVector2();
point3XNumericUpDown.Value = (decimal)pos.X;
point3YNumericUpDown.Value = (decimal)pos.Y;
};
menu.Items[3].Click += (s, e) =>
{
Vector2 pos = pvsMain.MousePosOnMap.ToVector2();
point4XNumericUpDown.Value = (decimal)pos.X;
point4YNumericUpDown.Value = (decimal)pos.Y;
};
menu.Show(Cursor.Position);
}

private void zonesListBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (zonesListBox.SelectedIndex == -1)
return;
Expand All @@ -121,7 +160,7 @@ private void zonesListBox_SelectedIndexChanged(object sender, System.EventArgs e
deleteZoneButton.Enabled = true;
}

private void addZoneButton_Click(object sender, System.EventArgs e)
private void addZoneButton_Click(object sender, EventArgs e)
{
var zones = GetZones();
ulong newZoneId;
Expand All @@ -135,6 +174,9 @@ private void addZoneButton_Click(object sender, System.EventArgs e)
}
break;
}
if (newZoneId == ulong.MaxValue)
return;

Zone newZone = new();
newZone.ZoneId = newZoneId;
zones.Add(newZone);
Expand All @@ -146,7 +188,7 @@ private void addZoneButton_Click(object sender, System.EventArgs e)
deleteZoneButton.Enabled = true;
}

private void deleteZoneButton_Click(object sender, System.EventArgs e)
private void deleteZoneButton_Click(object sender, EventArgs e)
{
int index = zonesListBox.SelectedIndex;
ulong zoneId = ulong.Parse(zonesListBox.Items[index].ToString());
Expand All @@ -165,71 +207,71 @@ private void deleteZoneButton_Click(object sender, System.EventArgs e)
zonesListBox.SelectedIndex = index;
}

private void point1XNumericUpDown_ValueChanged(object sender, System.EventArgs e)
private void point1XNumericUpDown_ValueChanged(object sender, EventArgs e)
{
Vector2 point = GetPoints()[0];
point.X = (float)point1XNumericUpDown.Value;
GetPoints()[0] = point;
pvsMain.Invalidate();
}

private void point1YNumericUpDown_ValueChanged(object sender, System.EventArgs e)
private void point1YNumericUpDown_ValueChanged(object sender, EventArgs e)
{
Vector2 point = GetPoints()[0];
point.Y = (float)point1YNumericUpDown.Value;
GetPoints()[0] = point;
pvsMain.Invalidate();
}

private void point2XNumericUpDown_ValueChanged(object sender, System.EventArgs e)
private void point2XNumericUpDown_ValueChanged(object sender, EventArgs e)
{
Vector2 point = GetPoints()[1];
point.X = (float)point2XNumericUpDown.Value;
GetPoints()[1] = point;
pvsMain.Invalidate();
}

private void point2YNumericUpDown_ValueChanged(object sender, System.EventArgs e)
private void point2YNumericUpDown_ValueChanged(object sender, EventArgs e)
{
Vector2 point = GetPoints()[1];
point.Y = (float)point2YNumericUpDown.Value;
GetPoints()[1] = point;
pvsMain.Invalidate();
}

private void point3XNumericUpDown_ValueChanged(object sender, System.EventArgs e)
private void point3XNumericUpDown_ValueChanged(object sender, EventArgs e)
{
Vector2 point = GetPoints()[2];
point.X = (float)point3XNumericUpDown.Value;
GetPoints()[2] = point;
pvsMain.Invalidate();
}

private void point3YNumericUpDown_ValueChanged(object sender, System.EventArgs e)
private void point3YNumericUpDown_ValueChanged(object sender, EventArgs e)
{
Vector2 point = GetPoints()[2];
point.Y = (float)point3YNumericUpDown.Value;
GetPoints()[2] = point;
pvsMain.Invalidate();
}

private void point4XNumericUpDown_ValueChanged(object sender, System.EventArgs e)
private void point4XNumericUpDown_ValueChanged(object sender, EventArgs e)
{
Vector2 point = GetPoints()[3];
point.X = (float)point4XNumericUpDown.Value;
GetPoints()[3] = point;
pvsMain.Invalidate();
}

private void point4YNumericUpDown_ValueChanged(object sender, System.EventArgs e)
private void point4YNumericUpDown_ValueChanged(object sender, EventArgs e)
{
Vector2 point = GetPoints()[3];
point.Y = (float)point4YNumericUpDown.Value;
GetPoints()[3] = point;
pvsMain.Invalidate();
}

private void neighboursListBox_SelectedIndexChanged(object sender, System.EventArgs e)
private void neighboursListBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (neighboursListBox.SelectedIndex == -1)
return;
Expand All @@ -244,9 +286,11 @@ private void neighboursListBox_SelectedIndexChanged(object sender, System.EventA
immediateCheckBox.Enabled = true;
}

private void addNeighbourButton_Click(object sender, System.EventArgs e)
private void addNeighbourButton_Click(object sender, EventArgs e)
{
ulong newZoneId = new AddZone().GetNewZoneId();
if (newZoneId == ulong.MaxValue)
return;
var neighbours = GetUnsafeNeighbours();
Neighbour newNeighbour = new();
newNeighbour.ZoneId = newZoneId;
Expand All @@ -263,7 +307,7 @@ private void addNeighbourButton_Click(object sender, System.EventArgs e)
deleteNeighbourButton.Enabled = true;
}

private void deleteNeighbourButton_Click(object sender, System.EventArgs e)
private void deleteNeighbourButton_Click(object sender, EventArgs e)
{
int index = neighboursListBox.SelectedIndex;
ulong zoneId = ulong.Parse(neighboursListBox.Items[index].ToString());
Expand All @@ -290,7 +334,7 @@ private void deleteNeighbourButton_Click(object sender, System.EventArgs e)
neighboursListBox.SelectedIndex = index;
}

private void renderCheckBox_CheckedChanged(object sender, System.EventArgs e)
private void renderCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (neighboursListBox.SelectedIndex == -1)
return;
Expand All @@ -303,7 +347,7 @@ private void renderCheckBox_CheckedChanged(object sender, System.EventArgs e)
GetUnsafeNeighbours()[neighbourIndex] = neighbour;
}

private void immediateCheckBox_CheckedChanged(object sender, System.EventArgs e)
private void immediateCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (neighboursListBox.SelectedIndex == -1)
return;
Expand Down

0 comments on commit a258167

Please sign in to comment.