示例#1
0
        private void Indicator_RightClick(object sender, EventArgs e)
        {
            var indicator = (PlayerLocationIndicator)sender;

            if (!EnableContextMenu)
            {
                PlayerInfo pInfo = players.Find(p => p.Name == ProgramConstants.PLAYERNAME);

                if (pInfo.StartingLocation == (int)indicator.Tag + 1)
                {
                    LocalStartingLocationSelected?.Invoke(this, new LocalStartingLocationEventArgs(0));
                }

                return;
            }

            foreach (PlayerInfo pInfo in players.Union(aiPlayers))
            {
                if (pInfo.StartingLocation == (int)indicator.Tag + 1)
                {
                    pInfo.StartingLocation = 0;
                }
            }

            StartingLocationApplied?.Invoke(this, EventArgs.Empty);
        }
示例#2
0
        /// <summary>
        /// Allows the user to select their starting location by clicking on one of them
        /// in the map preview.
        /// </summary>
        private void Indicator_LeftClick(object sender, EventArgs e)
        {
            if (!EnableStartLocationSelection)
            {
                return;
            }

            var indicator = (PlayerLocationIndicator)sender;

            SoundPlayer.Play(sndClickSound);

            if (!EnableContextMenu)
            {
                if (Map.EnforceMaxPlayers)
                {
                    foreach (PlayerInfo pInfo in players.Concat(aiPlayers))
                    {
                        if (pInfo.StartingLocation == (int)indicator.Tag + 1)
                        {
                            return;
                        }
                    }
                }

                LocalStartingLocationSelected?.Invoke(this, new LocalStartingLocationEventArgs((int)indicator.Tag + 1));
                return;
            }

            //if (contextMenu.Visible)
            //{
            //    contextMenu.Visible = false;
            //    contextMenu.Enabled = false;
            //    return;
            //}

            //if (Map.EnforceMaxPlayers)
            //{
            //    foreach (PlayerInfo pInfo in players.Concat(aiPlayers))
            //    {
            //        if (pInfo.StartingLocation == (int)indicator.Tag + 1)
            //            return;
            //    }
            //}

            int x = indicator.Right;
            int y = indicator.Y;

            if (x + contextMenu.Width > Width)
            {
                x = indicator.X - contextMenu.Width;
            }

            if (y + contextMenu.Height > Height)
            {
                y = Height - contextMenu.Height;
            }

            contextMenu.Tag = indicator.Tag;

            int index = 0;

            foreach (PlayerInfo pInfo in players.Concat(aiPlayers))
            {
                contextMenu.Items[index].Selectable = pInfo.StartingLocation != (int)indicator.Tag + 1 &&
                                                      pInfo.SideId < sides.Length + RandomSelectorCount;
                index++;
            }
            lastContextMenuPoint = new Point(x, y);
            contextMenu.Open(lastContextMenuPoint);
        }
        /// <summary>
        /// Allows the user to select their starting location by clicking on one of them
        /// in the map preview.
        /// </summary>
        private void Indicator_LeftClick(object sender, EventArgs e)
        {
            var indicator = (PlayerLocationIndicator)sender;

            if (sndClickSound != null)
            {
                AudioMaster.PlaySound(sndClickSound);
            }

            if (!EnableContextMenu)
            {
                if (Map.EnforceMaxPlayers)
                {
                    foreach (PlayerInfo pInfo in players.Concat(aiPlayers))
                    {
                        if (pInfo.StartingLocation == (int)indicator.Tag + 1)
                        {
                            return;
                        }
                    }
                }

                LocalStartingLocationSelected?.Invoke(this, new LocalStartingLocationEventArgs((int)indicator.Tag + 1));
                return;
            }

            //if (contextMenu.Visible)
            //{
            //    contextMenu.Visible = false;
            //    contextMenu.Enabled = false;
            //    return;
            //}

            //if (Map.EnforceMaxPlayers)
            //{
            //    foreach (PlayerInfo pInfo in players.Concat(aiPlayers))
            //    {
            //        if (pInfo.StartingLocation == (int)indicator.Tag + 1)
            //            return;
            //    }
            //}

            int x = indicator.ClientRectangle.Right;
            int y = indicator.ClientRectangle.Top;

            if (x + contextMenu.ClientRectangle.Width > ClientRectangle.Width)
            {
                x = indicator.ClientRectangle.Left - contextMenu.ClientRectangle.Width;
            }

            if (y + contextMenu.ClientRectangle.Height > ClientRectangle.Height)
            {
                y = ClientRectangle.Height - contextMenu.ClientRectangle.Height;
            }

            contextMenu.ClientRectangle = new Rectangle(x, y, contextMenu.ClientRectangle.Width, contextMenu.ClientRectangle.Height);
            contextMenu.Tag             = indicator.Tag;

            int index = 0;

            foreach (PlayerInfo pInfo in players.Concat(aiPlayers))
            {
                contextMenu.Items[index].Selectable = pInfo.StartingLocation != (int)indicator.Tag + 1 &&
                                                      pInfo.SideId < sides.Length + 1;
                index++;
            }

            contextMenu.Enabled = true;
            contextMenu.Visible = true;
        }