diff --git a/Src/ServerGridEditor/Forms/MainForm.cs b/Src/ServerGridEditor/Forms/MainForm.cs index 3c90cd8..969b0a4 100644 --- a/Src/ServerGridEditor/Forms/MainForm.cs +++ b/Src/ServerGridEditor/Forms/MainForm.cs @@ -82,6 +82,7 @@ public partial class MainForm : Form public Config editorConfig; public Spawners spawners; + public int mytestscroll; public MainForm() { @@ -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); @@ -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); + } + + } + } @@ -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() { @@ -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; @@ -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) @@ -1931,7 +1905,7 @@ void SetDiscoverZoneImage(string fileName) { if (currentProject == null) return; - + if (currentProject.DiscoveryZoneImage != null) currentProject.DiscoveryZoneImage.Dispose(); currentProject.DiscoveryZoneImage = null; @@ -2199,7 +2173,7 @@ private void localExportToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("Export failed!! Ex: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } - + } @@ -2385,10 +2359,69 @@ 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 = ""; @@ -2396,4 +2429,3 @@ public class Config public int AtlasImagesRes = 2048; public int ImageQuality = 75; } -} \ No newline at end of file