예제 #1
0
        /* Setup the initial default position of the windows hud instances
         * The guess is often not perfect, but the user can adjust the position
         * later. */
        public void SetupDefaultPositions(Rectangle windowRect)
        {
            Trace.Assert(windowRect.Width != 0, "Invalid windowRect sent for setting up hud windows default position. Zero.");

            Point relativeTableCenter = FindRelativeTableCenter(windowRect.Width);
            Point absoluteTableCenter = new Point(windowRect.X + relativeTableCenter.X,
                                                  windowRect.Y + relativeTableCenter.Y);

            int   numberOfWindows     = windowsList.Count;
            float skipAngle           = SKIP_ANGLE;
            float angleBetweenPlayers = HUD_DISTANCE_FROM_PLAYERS_ANGLE;

            int distanceFromCenterX = GetDistanceXFromCenter(relativeTableCenter);
            int distanceFromCenterY = GetDistanceYFromCenter(relativeTableCenter);

            /* Here's how we setup the initial position */

            // 1. Set current angle at -PI/2 (top of the clock) + skip angle (skip one!)
            float currentAngle = -(float)Math.PI / 2 + skipAngle;

            // 2. Draw lower half of windows and increment by angleBetweenPlayers
            int lowerHalf = (int)Math.Floor((double)numberOfWindows / 2);

            int i; // We'll use this later too

            for (i = 0; i < lowerHalf; i++)
            {
                HudWindow w           = windowsList[i];
                Point     newPosition = CalculatePoint(currentAngle, distanceFromCenterX, distanceFromCenterY, absoluteTableCenter);
                SetWindowLocation(w, newPosition);

                currentAngle += angleBetweenPlayers;
            }


            // 3. (optional) If we had an odd number of windows, this is where middle windows gets placed
            if (numberOfWindows % 2 == 1)
            {
                float     sixClockAngle = (float)Math.PI / 2; // 6 o'clock angle
                HudWindow w             = windowsList[i];
                Point     newPosition   = CalculatePoint(sixClockAngle, distanceFromCenterX, distanceFromCenterY, absoluteTableCenter);
                SetWindowLocation(w, newPosition);
                i++;
            }

            // 4. Draw the remaining half, we start at the top of the clock again,
            // but this time we go backwards (from last to first and counter clockwise)

            currentAngle = -(float)Math.PI / 2 - skipAngle;
            int remainingWindows = numberOfWindows - i;

            for (int j = 0; j < remainingWindows; j++)
            {
                HudWindow w           = windowsList[numberOfWindows - 1 - j];
                Point     newPosition = CalculatePoint(currentAngle, distanceFromCenterX, distanceFromCenterY, absoluteTableCenter);
                SetWindowLocation(w, newPosition);

                currentAngle -= angleBetweenPlayers;
            }
        }
예제 #2
0
        public override bool Equals(object obj)
        {
            if (!(obj is HudWindow))
            {
                return(false);
            }

            HudWindow otherObj = (HudWindow)obj;

            // Two windows are equal if the playername label is the same (and initialized)
            return(otherObj.lblPlayerName.Text == this.lblPlayerName.Text &&
                   this.lblPlayerName.Text != "playerName");
        }
예제 #3
0
파일: Table.cs 프로젝트: njisom13/PokerMuck
        /* The user requested that all statistics get reset */
        public void window_OnResetAllStatisticsButtonPressed(HudWindow sender)
        {
            statistics.PrepareStatisticsForNewRound();

            foreach (Player p in PlayerList)
            {
                p.ResetAllStatistics();
                if (p.HudWindow != null)
                {
                    p.HudWindow.DisplayStatistics(p.GetStatistics());                      // TODO: is this thread safe?
                }
            }
        }
예제 #4
0
파일: Hud.cs 프로젝트: visualjc/PokerMuck
        public void window_OnPlayerStatisticsNeedToBeDisplayed(HudWindow sender)
        {
            Player p = FindPlayerAssociatedWith(sender);

            if (p != null)
            {
                table.DisplayWindow.DisplayStatistics(p);
            }
            else
            {
                Trace.WriteLine("A command to display the statistics of a player was received, but I couldn't find the player in the list.");
            }
        }
예제 #5
0
파일: Hud.cs 프로젝트: visualjc/PokerMuck
        private Player FindPlayerAssociatedWith(HudWindow w)
        {
            // Find which player is associated with this hud
            foreach (Player p in table.PlayerList)
            {
                if (p.HudWindow.Equals(w))
                {
                    // Found!
                    return(p);
                }
            }

            return(null);
        }
예제 #6
0
 public void Add(HudWindow window)
 {
     windowsList.Add(window);
 }
예제 #7
0
 public void window_OnResetStatisticsButtonPressed(HudWindow sender)
 {
     ResetAllStatistics();
     sender.DisplayStatistics(GetStatistics());
 }
예제 #8
0
 public void Remove(HudWindow window)
 {
     Trace.Assert(window != null, "Trying to remove a null reference to a hud window");
     window.Close();
     windowsList.Remove(window);
 }
예제 #9
0
 public void Add(HudWindow window)
 {
     windowsList.Add(window);
 }
예제 #10
0
 private void SetWindowLocation(HudWindow w, Point location)
 {
     w.Location = location;
 }
예제 #11
0
파일: Hud.cs 프로젝트: visualjc/PokerMuck
        public void DisplayAndUpdate()
        {
            bool setupInitialWindowPositions = false; //Default

            // Do we have user specified positions?
            List <Point> positions = settings.RetrieveHudWindowPositions(table.PokerClientName, table.MaxSeatingCapacity, table.GameType);

            if (positions.Count > 0)
            {
                if (table.PlayerSeatingPositionIsRelative)
                {
                    positions = GetEffectivePositions(positions, table.PlayerList, table.CurrentHeroName, table.MaxSeatingCapacity);
                }
                Trace.Assert(positions.Count == table.MaxSeatingCapacity, "The number of available user defined hud positions is different that what we expected");
            }
            else
            {
                // We don't

                // The first time we'll need to setup the initial position of the windows
                setupInitialWindowPositions = true;
            }

            // Check for windows that have been set to be destroyed
            DisposeFlaggedWindows();

            // Now we're ready

            /* Check each player:
             * If the player doesn't have a hud window and is playing, create a window for him
             */
            foreach (Player p in table.PlayerList)
            {
                // Create window
                if (p.HudWindow == null && p.IsPlaying)
                {
                    HudWindow window = HudWindowFactory.CreateHudWindow(table);

                    Trace.WriteLine("Create window for " + p.Name + " (" + p.SeatNumber + ")");

                    // We set a 1:1 association between the player and the HudWindow
                    p.HudWindow = window;

                    window.RegisterHandlers(this, table, p);

                    windowsList.Add(window);
                    window.Show(); // Without this we cannot move the windows


                    // Move it to its proper location (if available)
                    if (positions.Count > 0)
                    {
                        window.SetAbsolutePosition(positions[p.SeatNumber - 1], table.WindowRect);
                    }
                }
            }

            if (setupInitialWindowPositions)
            {
                SetupHudInitialPosition();
            }

            UpdateHudData();

            table.PostHudDisplayAction();
        }
예제 #12
0
파일: Table.cs 프로젝트: smtheard/PokerMuck
        /* The user requested that all statistics get reset */
        public void window_OnResetAllStatisticsButtonPressed(HudWindow sender)
        {
            statistics.PrepareStatisticsForNewRound();

            foreach (Player p in PlayerList)
            {
                p.ResetAllStatistics();
                if (p.HudWindow != null) p.HudWindow.DisplayStatistics(p.GetStatistics()); // TODO: is this thread safe?
            }
        }
예제 #13
0
 public void Remove(HudWindow window)
 {
     Trace.Assert(window != null, "Trying to remove a null reference to a hud window");
     window.Close();
     windowsList.Remove(window);
 }
예제 #14
0
 private void SetWindowLocation(HudWindow w, Point location)
 {
     w.Location = location;
 }
예제 #15
0
파일: Hud.cs 프로젝트: smtheard/PokerMuck
        private Player FindPlayerAssociatedWith(HudWindow w)
        {
            // Find which player is associated with this hud
            foreach (Player p in table.PlayerList)
            {
                if (p.HudWindow.Equals(w))
                {
                    // Found!
                    return p;
                }
            }

            return null;
        }
예제 #16
0
파일: Hud.cs 프로젝트: smtheard/PokerMuck
 public void window_OnPlayerStatisticsNeedToBeDisplayed(HudWindow sender)
 {
     Player p = FindPlayerAssociatedWith(sender);
     if (p != null)
     {
         table.DisplayWindow.DisplayStatistics(p);
     }
     else
     {
         Trace.WriteLine("A command to display the statistics of a player was received, but I couldn't find the player in the list.");
     }
 }
예제 #17
0
 public void window_OnResetStatisticsButtonPressed(HudWindow sender)
 {
     ResetAllStatistics();
     sender.DisplayStatistics(GetStatistics());
 }