Пример #1
0
        /// <summary>
        /// Moves all FlagContainers forwards in the queue. The one at the end is moved to the beginning and is given the new flag.
        /// </summary>
        /// <param name="flag">Flag to add. Can be null.</param>
        private void Enqueue(Flag flag)
        {
            FlagContainer temp = flags[flags.Length - 1];

            for (int i = flags.Length - 1; i > 0; i--)
            {
                flags[i] = flags[i - 1];
            }

            if (temp == null)
            {
                temp = new FlagContainer();
            }
            else
            {
                temp.Flag.UnloadImage();
            }

            if (flag == null)
            {
                temp = null;
            }
            else
            {
                temp.Flag = flag;
                flag.LoadImage();
            }

            flags[0] = temp;
        }
Пример #2
0
        private void UpdateContainers()
        {
            if (Program.Input.MouseLocation.Equals(lastMouseLocation))
            {
                return;
            }

            lastMouseLocation = Program.Input.MouseLocation;

            Rectangle r       = new Rectangle(0, 0, flagWidth, flagHeight);
            bool      nameSet = false;

            for (int i = firstDrawIndex; i <= lastDrawIndex; i++)
            {
                FlagContainer f = containers[i];

                r.Location = f.GetOrigin();
                r.Size     = f.Flag.ImageSize;

                if (r.Contains(Program.Input.MouseLocation))
                {
                    if (NameLabel.Text != f.Flag.Country)
                    {
                        nameLabelFade = 0;
                    }

                    NameLabel.SetLocation(f.Location.X, f.Location.Y + (f.Flag.ImageSize.Height / 3));
                    NameLabel.Text = f.Flag.Country;

                    nameSet = true;
                }
            }

            drawNameLabel = nameSet;
        }
Пример #3
0
        private void PopulateContainers()
        {
            var flags = Program.Flags.GetFlags();

            containers = new FlagContainer[flags.Count];

            for (int i = 0; i < flags.Count; i++)
            {
                containers[i] = new FlagContainer()
                {
                    Flag = flags[i]
                }
            }
            ;
        }
Пример #4
0
        /// <summary>
        /// Sets the onscreen location of FlagContainers.
        /// </summary>
        private void SetFlagLocations()
        {
            float slideOffset = freezeTime <= 0 ? 0 : bezier.GetValue(maxFreezeTime - freezeTime) * (float)flagSpacing;

            for (int i = 0; i < flags.Length; i++)
            {
                FlagContainer c = flags[i];

                if (c == null)
                {
                    continue;
                }

                int offset = currentFlagIndex - i;

                c.SetLocation(currentFlagX + (offset * flagSpacing) - (int)slideOffset, currentFlagY);
            }
        }
Пример #5
0
        private void SetContainerLocations()
        {
            bool firstVis = false;

            lastDrawIndex = -1;

            for (int i = 0; i < containers.Length; i++)
            {
                FlagContainer f = containers[i];

                int x = ((i % 3) * flagWidth) + (flagWidth / 2);
                int y = ((i / 3) * flagHeight) + (flagHeight / 2) - scrollY;

                f.Location = new Point(x, y);

                bool visible = IsVisible(y);

                if (visible != firstVis)
                {
                    if (visible)
                    {
                        firstDrawIndex = i;
                    }
                    else
                    {
                        lastDrawIndex = i - 1;
                    }

                    firstVis = visible;
                }

                if (visible != f.Flag.IsImageLoaded)
                {
                    f.Flag.ToggleImage();
                }

                f.DrawPlaceholder = visible;
            }

            if (lastDrawIndex < 0)
            {
                lastDrawIndex = containers.Length - 1;
            }
        }