PixelToGameCoords() public static method

public static PixelToGameCoords ( int pixel ) : int
pixel int
return int
Esempio n. 1
0
        private void pctWorldMap_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Location Loc = worldmap.GetLocation(Display.PixelToGameCoords(e.X), Display.PixelToGameCoords(e.Y));

            if (Loc != null)
            {
                EditLocation = new frmEditLocation(Loc, worldmap.MapParser, worldmap.LocParser, false);
                EditLocation.ShowDialog();
                pctWorldMap.Refresh();
            }
        }
Esempio n. 2
0
        private void pctWorldMap_MouseMove(object sender, MouseEventArgs e)
        {
            int ZoneX = Display.PixelToZoneCoord(e.X);
            int ZoneY = Display.PixelToZoneCoord(e.Y);

            Point ZoneCoords = new Point(ZoneX, ZoneY);

            toolStripStatusLabelMouseCoords.Text = "| Coords: " + e.X.ToString() + ", " + e.Y.ToString();
            toolStripStatusLabelZoneCoords.Text  = "Zone: " + ZoneCoords.X.ToString() + ", " + ZoneCoords.Y.ToString();
            toolStripStatusLabelGameCoords.Text  = "Game Coords: " + Display.PixelToGameCoords(e.X).ToString() + ", " + Display.PixelToGameCoords(e.Y).ToString();

            if (AddLocation.Selected)
            {
                AddLocation.Loc.X          = Display.PixelToGameCoords(e.X);
                AddLocation.Loc.Y          = Display.PixelToGameCoords(e.Y);
                AddLocation.Loc.OnWorldmap = true;
                AddLocation.Loc.Modified   = true;
                pctWorldMap.Refresh();
            }

            if (Control.MouseButtons == MouseButtons.Left)
            {
                if (AnyBrushModeEnabled())
                {
                    worldmap.SetSelectedZone(ZoneX, ZoneY);
                }

                if (toolbtnClone.Checked)
                {
                    ReplaceSelectedZone(PaintZone, ICopyParams);
                    RefreshZoneProperties();
                }

                if (toolbtnErase.Checked)
                {
                    if (worldmap.ModifySelectedZoneWithBrush(BrushOptions.Groups, BrushOptions.Locations, BrushOptions.Flags, false, 0))
                    {
                        RefreshZoneProperties();
                    }
                }

                if (toolbtnBrush.Checked)
                {
                    int chance = 0;
                    if ((BrushOptions.OverwriteChance))
                    {
                        chance = BrushOptions.EncounterChance;
                    }
                    if (worldmap.ModifySelectedZoneWithBrush(BrushOptions.Groups, BrushOptions.Locations, BrushOptions.Flags, true, chance))
                    {
                        RefreshZoneProperties();
                    }
                }

                //if (AnyBrushModeEnabled())
                //    RefreshZoneProperties();
            }

            if (!Config.ShowTooltip || AddLocation.Selected)
            {
                return;
            }

            if (DrawToolTip)
            {
                int    x         = e.X + 15;
                int    y         = e.Y + 15;
                string str       = (string)LocationToolTip.Tag.ToString();
                int    strlength = str.Length;

                if ((Cursor.Position.X + (strlength * 4)) > Screen.PrimaryScreen.Bounds.Width)
                {
                    x -= ((Cursor.Position.X + (strlength * 4)) - Screen.PrimaryScreen.Bounds.Width);
                }
                if ((x != ToolTipLast.X) || (y != ToolTipLast.Y))
                {
                    LocationToolTip.Show((string)LocationToolTip.Tag, pctWorldMap, x, y, 100000);
                    ToolTipLast.X = x;
                    ToolTipLast.Y = y;
                }
            }

            MouseZoneLocation = ZoneCoords;

            if (worldmap == null)
            {
                return;
            }

            Location Loc = worldmap.GetLocation(Display.PixelToGameCoords(e.X), Display.PixelToGameCoords(e.Y));

            if (Loc != null && Loc.OnWorldmap)
            {
                LocationToolTip.Tag = Loc.Name + " (" + Loc.Pid + ")" + Environment.NewLine + Loc.WorldMapDescription
                                      + Environment.NewLine + (Loc.Visible ? "Visible: Yes" : "Visible: No");
                LocationToolTip.UseFading = true;
                DrawToolTip = true;
            }
            else
            {
                LocationToolTip.Hide(pctWorldMap);
                DrawToolTip = false;
                return;
            }
        }
Esempio n. 3
0
        private void pctWorldMap_MouseClick(object sender, MouseEventArgs e)
        {
            if (worldmap == null)
            {
                return;
            }

            this.ActiveControl = null;

            if (Config.ScriptingEnabled)
            {
                if (Scripting.Host.ScriptHost.worldmap_coords_clicked(e, e.X, e.Y))
                {
                    return;
                }
            }

            if (e.Button == MouseButtons.Right)
            {
                if (AddLocation.Loc != null)
                {
                    AddLocation.Selected       = false;
                    AddLocation.Loc.OnWorldmap = false;
                    AddLocation.Loc            = null;
                }
                worldmap.SetSelectedZone(-1, -1);
                pctWorldMap.Focus();
                pctWorldMap.Refresh();
                ChangeEnableStateOfZonePropertyControls(false);
                RefreshZoneProperties();
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                if (AddLocation.Selected)
                {
                    AddLocation.Loc.X          = Display.PixelToGameCoords(e.X);
                    AddLocation.Loc.Y          = Display.PixelToGameCoords(e.Y);
                    AddLocation.Loc.OnWorldmap = true;
                    AddLocation.Loc.Modified   = true;
                    AddLocation.Selected       = false;
                    AddLocation.Loc            = null;
                }
                else
                {
                    int ZoneX = Display.PixelToZoneCoord(e.X);
                    int ZoneY = Display.PixelToZoneCoord(e.Y);

                    if (Config.ScriptingEnabled)
                    {
                        if (Scripting.Host.ScriptHost.zone_activated(ZoneX, ZoneY))
                        {
                            return;
                        }
                    }

                    worldmap.SetSelectedZone(ZoneX, ZoneY);
                    ChangeEnableStateOfZonePropertyControls(true);
                    RefreshZoneProperties();
                    pctWorldMap.Refresh();
                }
            }
        }
        private void pctWorldMap_MouseClick(object sender, MouseEventArgs e)
        {
            if (worldmap == null)
            {
                return;
            }

            this.ActiveControl = null;

            if (Config.ScriptingEnabled)
            {
                if (Scripting.Host.ScriptHost.worldmap_coords_clicked(e, e.X, e.Y))
                {
                    return;
                }
            }

            if (e.Button == MouseButtons.Right)
            {
                if (AddLocation.Loc != null)
                {
                    AddLocation.Selected       = false;
                    AddLocation.Loc.OnWorldmap = false;
                    AddLocation.Loc            = null;
                }
                worldmap.SetSelectedZone(-1, -1);
                pctWorldMap.Focus();
                pctWorldMap.Refresh();
                ChangeEnableStateOfZonePropertyControls(false);
                RefreshZoneProperties();
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                if (AddLocation.Selected)
                {
                    AddLocation.Loc.X          = Display.PixelToGameCoords(e.X);
                    AddLocation.Loc.Y          = Display.PixelToGameCoords(e.Y);
                    AddLocation.Loc.OnWorldmap = true;
                    AddLocation.Loc.Modified   = true;
                    AddLocation.Selected       = false;
                    AddLocation.Loc            = null;
                }
                else
                {
                    int ZoneX = Display.PixelToZoneCoord(e.X);
                    int ZoneY = Display.PixelToZoneCoord(e.Y);

                    if (Config.ScriptingEnabled)
                    {
                        if (Scripting.Host.ScriptHost.zone_activated(ZoneX, ZoneY))
                        {
                            return;
                        }
                    }

                    worldmap.SetSelectedZone(ZoneX, ZoneY);
                    ChangeEnableStateOfZonePropertyControls(true);
                    RefreshZoneProperties();
                    pctWorldMap.Refresh();
                }

                if (checkBox2.Checked == true)
                {
                    IExtZone    zone  = (IExtZone)worldmap.GetSelectedZone();
                    frmAddGroup group = new frmAddGroup(worldmap.GroupParser.GetGroups(), zone.EncounterGroups);
                    group.ShowDialog();
                    //group.Show();
                    if (group.SelectedGroups.Count == 0)
                    {
                        return;
                    }

                    if (zone.EncounterGroups == null)
                    {
                        zone.EncounterGroups = new List <EncounterZoneGroup>();
                    }

                    zone.EncounterGroups.AddRange(group.SelectedGroups);
                    zone.Modified = true;
                    RefreshGroupList();
                }
            }
        }