Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 94 additions & 62 deletions Src/ServerGridEditor/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public partial class MainForm : Form
public Config editorConfig;

public Spawners spawners;
public int mytestscroll;

public MainForm()
{
Expand Down Expand Up @@ -118,6 +119,7 @@ public MainForm()
mapPanel.MouseUp += new System.Windows.Forms.MouseEventHandler(this.mapPanel_MouseUp);
mapPanel.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.mapPanel_MouseWheel);


((MapPanel)mapPanel).mainForm = this;

Controls.Remove(originalPanel);
Expand Down Expand Up @@ -909,11 +911,27 @@ private void mapPanel_MouseDown(object sender, MouseEventArgs e)
startRotation = null;
}
}

//// This section has been modified to include value modification to the global value mytestscroll
//// The Control Key will zoom in, the Shift key will zoom out using the middle mouse button click.
else if (e.Button == MouseButtons.Middle)
{
middlePressLocation.X = mapHScrollBar.Value;
middlePressLocation.Y = mapVScrollBar.Value;
}
middlePressLocation.Y = mapVScrollBar.Value;

if (ModifierKeys == Keys.Control)
{
mytestscroll = 1;
mapPanel_MouseWheel(this, e);
}
if (ModifierKeys == Keys.Shift)
{
mytestscroll = -1;
mapPanel_MouseWheel(this, e);
}

}

}


Expand Down Expand Up @@ -1059,53 +1077,7 @@ private void mapPanel_MouseUp(object sender, MouseEventArgs e)
}
}

private void mapPanel_MouseWheel(object sender, MouseEventArgs e)
{
Point mouseLocation = e.Location;
PointF desiredMouseLocation = e.Location;

float desiredHScroll = mapHScrollBar.Value;
float desiredVScroll = mapVScrollBar.Value;

if (e.Delta > 0)
{
currentProject.coordsScaling *= scrollSpeed;

UpdateScrollBars();

desiredMouseLocation.X *= scrollSpeed;
desiredMouseLocation.Y *= scrollSpeed;

desiredHScroll *= scrollSpeed;
desiredVScroll *= scrollSpeed;
}
else
{
currentProject.coordsScaling /= scrollSpeed;

UpdateScrollBars();

desiredMouseLocation.X /= scrollSpeed;
desiredMouseLocation.Y /= scrollSpeed;

desiredHScroll /= scrollSpeed;
desiredVScroll /= scrollSpeed;
}

SetScaleTxt(1 / currentProject.coordsScaling);

if (mapHScrollBar.Enabled)
mapHScrollBar.Value = Math.Max(0, Math.Min(mapHScrollBar.Maximum, (int)(desiredHScroll + desiredMouseLocation.X - mouseLocation.X)));
else
mapHScrollBar.Value = 0;

if (mapVScrollBar.Enabled)
mapVScrollBar.Value = Math.Max(0, Math.Min(mapVScrollBar.Maximum, (int)(desiredVScroll + desiredMouseLocation.Y - mouseLocation.Y)));
else
mapVScrollBar.Value = 0;

mapPanel.Invalidate();
}

public void SaveIslands()
{
Expand Down Expand Up @@ -1531,7 +1503,7 @@ public void ExportImage(string filePath, int cellX = -1, int cellY = -1, bool ex

if (image == null)
return;

MagickImage tgaImg = new MagickImage(image);
tgaImg.Format = MagickFormat.Jpeg;
tgaImg.Quality = editorConfig.ImageQuality;
Expand Down Expand Up @@ -1684,19 +1656,21 @@ private void mapImageToolStripMenuItem_Click(object sender, EventArgs e)
private void controlsToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Hold Left click (Move island)\n" +
"Hold Right click (Rotate island)\n" +
"Mouse wheel (Zoom)\n" +
"Delete button (Remove island)\n" +
"Ctrl + click on grid (Edit server info)\n" +
"Ctrl + click on island (Edit island info)\n" +
"Hold middle mouse + drag (Scroll map)\n" +
"Hold Right click (Rotate island)\n" +
"Mouse wheel (Zoom)\n" +
"Delete button (Remove island)\n" +
"Ctrl + click on grid (Edit server info)\n" +
"Ctrl + click on island (Edit island info)\n" +
"Hold middle mouse + drag (Scroll map)\n" +
"Shift + drag (Create discovery zone)\n" +
"Shift + click on discovery zone (Edit discovery zone)\n" +
"L while hovered on cell (Open locks form)\n"+
"P while on map (Spawn ship path)\n" +
"Delete on path nodes (Delete node)\n" +
"Ctrl + click on path node (Edit path)\n" +
"Shift + Delete on path nodes (Delete whole path)\n", "Controls");
"Shift + Delete on path nodes (Delete whole path)\n" +
"Shift + middle mouse Zooms out\n" +
"Ctrl + middle mouse Zooms in\n", "Controls");
}

private void customRatioTxtBox_KeyPress(object sender, KeyPressEventArgs e)
Expand Down Expand Up @@ -1931,7 +1905,7 @@ void SetDiscoverZoneImage(string fileName)
{
if (currentProject == null)
return;

if (currentProject.DiscoveryZoneImage != null)
currentProject.DiscoveryZoneImage.Dispose();
currentProject.DiscoveryZoneImage = null;
Expand Down Expand Up @@ -2199,7 +2173,7 @@ private void localExportToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Export failed!! Ex: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

}


Expand Down Expand Up @@ -2385,15 +2359,73 @@ private void cullInvalidPathsToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Did not find any invalid paths to cull!", "No Invalid Paths", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}

private void mapPanel_MouseWheel(object sender, MouseEventArgs e)
{
Point mouseLocation = e.Location;
PointF desiredMouseLocation = e.Location;

//// Test code msgbox for proper entry into event.
///int mytestscroll = 1;
///string Str_mytestscroll = mytestscroll.ToString();
/// MessageBox.Show("The value scroll = " + Str_mytestscroll);



float desiredHScroll = mapHScrollBar.Value;
float desiredVScroll = mapVScrollBar.Value;


//// This if statement has been altered from the original e.Delta value check to use the global public variable mytestscroll.
if (mytestscroll > 0)
{
currentProject.coordsScaling *= scrollSpeed;

UpdateScrollBars();

desiredMouseLocation.X *= scrollSpeed;
desiredMouseLocation.Y *= scrollSpeed;

desiredHScroll *= scrollSpeed;
desiredVScroll *= scrollSpeed;
}
else
{
currentProject.coordsScaling /= scrollSpeed;

UpdateScrollBars();

desiredMouseLocation.X /= scrollSpeed;
desiredMouseLocation.Y /= scrollSpeed;

desiredHScroll /= scrollSpeed;
desiredVScroll /= scrollSpeed;
}

SetScaleTxt(1 / currentProject.coordsScaling);

if (mapHScrollBar.Enabled)
mapHScrollBar.Value = Math.Max(0, Math.Min(mapHScrollBar.Maximum, (int)(desiredHScroll + desiredMouseLocation.X - mouseLocation.X)));
else
mapHScrollBar.Value = 0;

if (mapVScrollBar.Enabled)
mapVScrollBar.Value = Math.Max(0, Math.Min(mapVScrollBar.Maximum, (int)(desiredVScroll + desiredMouseLocation.Y - mouseLocation.Y)));
else
mapVScrollBar.Value = 0;

public class Config
mapPanel.Invalidate();
}
}

}

public class Config
{
//public string LastOpenedFolder = "";
//public string LastMapsFolder = "";
public int CellImagesRes = 2048;
public int AtlasImagesRes = 2048;
public int ImageQuality = 75;
}
}