Пример #1
0
        internal void SetVolume(int val)
        {
            if (val == volume.Value)
            {
                return;
            }

            Visible = true;
            int volumeBefore = volume.Value;

            volume.Value = val;

            if (volume.Value == 100)
            {
                backgroundMax.Bypass = false;
                backgroundMax.FadeIn(150);
            }
            else
            {
                backgroundMax.FadeOut(150);
            }

            AudioEngine.Click(null, @"sliderbar", 1.1f - (0.5f - (volume.Value / 100f)) * 0.15f * (volume.Value != volumeBefore ? 1 : 4));
            return;
        }
Пример #2
0
 private void SpNextPage_Click(object sender, EventArgs e)
 {
     if (!spBriefing.IsLastTextPage)
     {
         AudioEngine.Click(); spBriefing.SetFade(FADE_STEPS); spBriefing.TextPage++;
     }
 }
Пример #3
0
 private void spPrevPage_Click(object sender, EventArgs e)
 {
     if (!spErrorText.IsFirstTextPage)
     {
         AudioEngine.Click(); spErrorText.TextPage--; UpdateControls();
     }
 }
Пример #4
0
 private void spNextPage_Click(object sender, EventArgs e)
 {
     if (!spKeyDesc.IsLastTextPage)
     {
         AudioEngine.Click(); spKeyDesc.TextPage++; UpdateControls();
     }
 }
Пример #5
0
        private void p_jump(object sender, EventArgs e)
        {
            if (!ShowControls)
            {
                return;
            }

            if (GameBase.ActiveDialog is JumpTo)
            {
                GameBase.ActiveDialog.Close();
                return;
            }

            AudioEngine.Click(null, @"click-short-confirm");

            if (GameBase.Options.PoppedOut)
            {
                GameBase.Options.PoppedOut = false;
            }

            JumpTo dialog = new JumpTo();

            dialog.Closed += delegate
            {
                if (dialog.SelectedMap != null)
                {
                    manualPause = false;
                }
            };

            GameBase.ShowDialog(dialog);
        }
        private void AddIcon(int houseIndex, MissionSet set, short regionID, string[] unitDescriptions)
        {
            if (regionID <= 0 || houseIndex < 0 || houseIndex > _iconSprite.Length)
            {
                return;
            }

            if (ParentForm is GameForm f)
            {
                // regionIDs are one-based
                int regIndex = regionID - 1;

                SpriteBox sp = new SpriteBox();
                // Add first
                _missionBoxes.Add(sp);
                spTerritories.Controls.Add(sp);

                sp.BaseImage = _iconSprite[houseIndex];
                sp.Click    += (o, e) => { AudioEngine.Click(); f.Push(new MissionBriefingScreen(set, unitDescriptions), TransitionStyle.FADE_BLACK); };

                float2 iconLoc = _centers[regIndex];
                float2 sz      = spTerritories.Size.ToFloat2() / _territoryBitmapSize.ToFloat2() * _iconSprite[houseIndex].Size.ToFloat2() * ICON_SCALE;
                float2 loc     = spTerritories.Size.ToFloat2() * iconLoc / _territoryBitmapSize.ToFloat2() - sz / 2;

                sp.Location = loc.ToPoint();
                sp.Size     = sz.ToSize();
            }
        }
Пример #7
0
 private void SpFind_Click(object sender, EventArgs e)
 {
     AudioEngine.Click();
     if (ofdGamePath.ShowDialog() == DialogResult.OK)
     {
         spGamePath.Text = ofdGamePath.FileName;
     }
 }
Пример #8
0
 void closeButton_OnClick(object sender, EventArgs e)
 {
     AudioEngine.Click(null, @"click-close");
     if (OnCloseTriggered != null)
     {
         OnCloseTriggered(this, null);
     }
 }
Пример #9
0
        private void p_pause(object sender, EventArgs e)
        {
            if (!ShowControls)
            {
                return;
            }

            AudioEngine.Click(null, @"click-short-confirm");

            NotificationManager.ShowMessageMassive(AudioEngine.Paused ? "Unpause" : "Pause", 1000);
            manualPause = AudioEngine.TogglePause();
        }
Пример #10
0
        private void p_stop(object sender, EventArgs e)
        {
            if (!ShowControls)
            {
                return;
            }

            NotificationManager.ShowMessageMassive("Stop Playing", 1000);
            AudioEngine.Click(null, @"click-short-confirm");

            AudioEngine.Stop();
            manualPause = true;
        }
Пример #11
0
        private void spriteBackground_OnHover(object sender, EventArgs e)
        {
            if (spriteStatus != null)
            {
                //This logic is only for user list panels, which alternate between display modes
                spriteInfo.FadeOut(100);
                spriteStatus.FadeIn(100);
                spriteStatus.IsVisible = true;
            }

            AudioEngine.Click(null, @"click-short");

            spriteForeground.FadeColour(CurrentForegroundColour, 200);
            spriteBackground.FadeColour(CurrentBackgroundColour, 200);
        }
Пример #12
0
        public ModButton(Vector2 position, params Mods[] states)
        {
            AvailableStates = new List <Mods>(states);

            foreach (Mods m in states)
            {
                string spriteName = @"selection-mod-" + m.ToString().ToLower();

                pSprite s = new pSprite(TextureManager.Load(spriteName), Fields.TopLeft, Origins.Centre, Clocks.Game, position, 0.94F, true, Color.TransparentWhite);
                s.TagNumeric = (int)m;

                s.OnHover += delegate { AudioEngine.Click(null, @"click-short"); };
                s.OnClick += delegate
                {
                    Cycle(MouseManager.MouseRight == ButtonState.Pressed);
                };
                s.HandleInput = true;

                //check for mode-specific tooltip.
                if (Player.Mode != PlayModes.Osu)
                {
                    try
                    {
                        s.ToolTip = LocalisationManager.GetString((OsuString)Enum.Parse(typeof(OsuString), "ModSelection_Mod_" + m.ToString() + "_" + Player.Mode.ToString()));
                    }
                    catch { }
                }

                //fallback to default tooltip.
                if (s.ToolTip == null)
                {
                    try
                    {
                        s.ToolTip = LocalisationManager.GetString((OsuString)Enum.Parse(typeof(OsuString), "ModSelection_Mod_" + m.ToString()));
                    }
                    catch { }
                }

                Sprites.Add(s);
            }

            glow          = new pSprite(TextureManager.Load(@"lighting", SkinSource.Osu), Origins.Centre, position, 0.99f, true, Color.SkyBlue);
            glow.Alpha    = 0;
            glow.Additive = true;

            Sprites.Add(glow);
        }
Пример #13
0
        void pButton_OnHover(object sender, EventArgs e)
        {
            if (hovering || !enabled)
            {
                return;
            }
            hovering = true;

            SpriteCollection[0].FadeColour(litUp, 50, true);
            SpriteCollection[1].FadeColour(litUp, 50, true);
            SpriteCollection[2].FadeColour(litUp, 50, true);

            if (SoundsEnabled)
            {
                AudioEngine.Click(null, @"click-short");
            }
        }
Пример #14
0
        private void p_prev(object sender, EventArgs e)
        {
            if (!ShowControls)
            {
                return;
            }

            AudioEngine.Click(null, @"click-short-confirm");

            NotificationManager.ShowMessageMassive("<< Prev", 1000);
            if (playHistory.Count > 0 && BeatmapManager.Current != null)
            {
                playFuture.Push(BeatmapManager.Current.BeatmapChecksum);
                BeatmapManager.Current = BeatmapManager.GetBeatmapByChecksum(playHistory.Pop());
            }
            ChooseRandomSong(false);
            manualPause = false;
        }
Пример #15
0
        internal void SetStatus(bool status, Mods specificStatus = Mods.None, bool playSound = true)
        {
            Sprites.ForEach(s =>
            {
                s.FadeOut(100);
                s.ScaleTo(1, 400, EasingTypes.OutElastic);
                s.RotateTo(0, 400, EasingTypes.OutElastic);
            });

            Mods lastState = State;

            if (!status)
            {
                State = Mods.None;
                Sprites[0].FadeIn(100);
            }
            else
            {
                pSprite match = Sprites.Find(s => s.TagNumeric == (int)specificStatus);
                if (match == null || specificStatus == Mods.None)
                {
                    match = Sprites[0];
                }

                State = (Mods)match.TagNumeric;

                match.FadeIn(100);
                match.ScaleTo(1.2f, 400, EasingTypes.OutElastic);
                match.RotateTo(0.1f, 400, EasingTypes.OutElastic);
            }

            glow.FadeTo(State == Mods.None ? 0 : 0.2f, 100);

            if (lastState != State && playSound)
            {
                AudioEngine.Click(null, State != Mods.None ? @"check-on" : @"check-off");
            }

            if (StateChanged != null)
            {
                StateChanged(this, null);
            }
        }
Пример #16
0
        void HoverGainedEffect(object sender, EventArgs e)
        {
            pText senderText = sender as pText;

            if (senderText != null)
            {
                if (senderText.Tag is Color)
                {
                    senderText.BackgroundColour = ColourHelper.Lighten(senderText.BackgroundColour, 0.1f);
                }
                else
                {
                    senderText.BackgroundColour = HighlightColour;
                }

                AudioEngine.Click(null, @"click-short");

                senderText.TextChanged = true;
            }
        }
Пример #17
0
        private void p_play(object sender, EventArgs e)
        {
            if (!ShowControls)
            {
                return;
            }

            AudioEngine.Click(null, @"click-short-confirm");

            NotificationManager.ShowMessageMassive("Play", 1000);
            if (AudioEngine.Paused)
            {
                AudioEngine.TogglePause();
            }
            else
            {
                AudioEngine.Play();
                //ChooseRandomSong(false);
            }
            manualPause = false;
        }
Пример #18
0
        internal pTab(string name, object tag, Vector2 position, float depth, bool flip, bool skinnable, Transformation hoverEffect, float textSize = 1)
        {
            tabBackground = new pSprite(skinnable ? TextureManager.Load(@"selection-tab") : TextureManager.Load(@"selection-tab", SkinSource.Osu), Fields.TopLeft,
                                        Origins.TopLeft,
                                        Clocks.Game,
                                        position, depth, true, hoverEffect.StartColour);
            if (flip)
            {
                tabBackground.FlipVertical = true;
            }
            tabBackground.HoverEffect    = hoverEffect;
            tabBackground.OnHover       += delegate { AudioEngine.Click(null, @"click-short"); };
            tabBackground.OriginPosition = new Vector2(70, 12);
            tabBackground.Tag            = this;
            Tag = tag ?? this;

            int lengthLimit = (int)(13 / textSize);

            if (!string.IsNullOrEmpty(name))
            {
                name = name.Length > lengthLimit?name.Remove(lengthLimit) + ".." : name;

                tabBackground.HandleInput = true;
                tabBackground.OnClick    += tab_OnClick;
            }
            else //Dud
            {
                tabBackground.InitialColour = new Color(160, 8, 42);
            }

            tabText =
                new pText(name, 12 * textSize, position, new Vector2(82, 12) * textSize, depth + 0.0001F, true, Color.White, false);
            tabText.TextBold      = true;
            tabText.TextShadow    = true;
            tabText.Origin        = Origins.Centre;
            tabText.TextAlignment = TextAlignment.Centre;

            SpriteCollection.Add(tabBackground);
            SpriteCollection.Add(tabText);
        }
Пример #19
0
        internal void SetValue(double value, bool silent = false, bool final = false)
        {
            value = OsuMathHelper.Clamp(value, Min, Max);

            if (Current != value)
            {
                Current = value;

                if (!silent)
                {
                    if (OnValueChanged != null)
                    {
                        OnValueChanged(final);
                    }

                    if (IsDragging || final)
                    {
                        AudioEngine.Click(null, @"sliderbar", 1 + progress * 0.2f);
                    }
                }
            }

            updatePosition();
        }
Пример #20
0
        internal bool DrawAt(Vector2 position, bool ext, int depth)
        {
            extended = ext;

            currentPosition = position;

            if (Sprites == null)
            {
                Sprites = new List <pSprite>();

                float fdepth = 0.92f + depth * 0.0001f;

                Vector2 panelOffset = new Vector2(-4, -4);

                spriteBackground          = new pSprite(TextureManager.Load(@"user-bg", SkinSource.Osu), Fields.TopLeft, Origins.TopLeft, Clocks.Game, position + panelOffset, fdepth, true, new Color(backgroundColour.R, backgroundColour.G, backgroundColour.B, (byte)(Visible ? 200 : 0)));
                spriteBackground.OnClick += delegate { AudioEngine.Click(null, @"click-short-confirm"); };
                Sprites.Add(spriteBackground);

                spriteForeground = new pSprite(TextureManager.Load(@"user-border", SkinSource.Osu), Fields.TopLeft, Origins.TopLeft, Clocks.Game, position + panelOffset, fdepth + 0.000002f, true, new Color(0, 0, 0, (byte)(Visible ? 255 : 0)));
                Sprites.Add(spriteForeground);

                spriteName = new pText(Name, 14, position + new Vector2(48, -2), Vector2.Zero, fdepth + 0.000003f, true, new Color(255, 255, 255, (byte)(Visible ? 255 : 0)), true);
                Sprites.Add(spriteName);
                spriteName.AggressiveCleanup = true;

                spriteInfo = new pText(InfoText, 10, position + new Vector2(48, 12), new Vector2(150, 33), fdepth + 0.000003f, true, new Color(255, 255, 255, (byte)(Visible ? 255 : 0)), true);
                spriteInfo.AggressiveCleanup = true;
                spriteInfo.TagNumeric        = 2;
                Sprites.Add(spriteInfo);

                spriteRank                   = new pText(RankText, 36, position + new Vector2(204, extended ? 14 : 7), Vector2.Zero, fdepth + 0.000001f, true, new Color(255, 255, 255, (byte)(Visible ? 255 : 0)), false);
                spriteRank.Origin            = Origins.TopRight;
                spriteRank.AggressiveCleanup = true;
                Sprites.Add(spriteRank);

                modeStatus = new pSprite(getModeTexture(), Fields.TopLeft, Origins.TopLeft, Clocks.Game, position + new Vector2(176, 0), fdepth + 0.000002f, true, new Color(255, 255, 255, (byte)(Visible ? 70 : 0)))
                {
                    TagNumeric = 1
                };
                Sprites.Add(modeStatus);

                InitializeAvatar();

                if (extended)
                {
                    spriteStatus = new pText(StatusText, 10, position + new Vector2(48, 12), new Vector2(150, 32), fdepth + 0.000004f, true, new Color(255, 255, 255, 0), true);
                    spriteStatus.AggressiveCleanup = true;
                    spriteStatus.TagNumeric        = 1;
                    Sprites.Add(spriteStatus);
                }
                else
                {
                    levelBarBackground = new pSprite(TextureManager.Load(@"levelbar-bg", SkinSource.Osu), position, fdepth + 0.000003f, true, new Color(255, 255, 255, (byte)(Visible && !ext ? 255 : 0)));
                    levelBarBackground.OriginPosition = new Vector2(-120, -62);

                    Sprites.Add(levelBarBackground);
                    levelBarBackground.TagNumeric = 1;


                    levelBarForeground = new pSprite(TextureManager.Load(@"levelbar", SkinSource.Osu), position, fdepth + 0.0000035f, true, new Color(252, 184, 6, (byte)(Visible && !ext ? 255 : 0)));
                    levelBarForeground.OriginPosition = new Vector2(-120, -62);
                    updateLevelBar();
                    Sprites.Add(levelBarForeground);
                    levelBarForeground.TagNumeric = 1;

                    levelBarBackground.Additive = true;
                    levelBarBackground.Alpha    = 0.4f;

                    levelBarForeground.Additive = true;
                    levelBarForeground.Alpha    = 0.7f;

                    spriteBackground.Additive = true;
                    backgroundColour          = spriteBackground.InitialColour = new Color(1, 1, 1);

                    spriteForeground.Bypass = true;
                }

                spriteBackground.OnHover     += spriteBackground_OnHover;
                spriteBackground.OnHoverLost += spriteBackground_OnHoverLost;

                UpdateColour();
                return(true);
            }

            Vector2 orig = Sprites[0].InitialPosition;

            bool moved = false;

            foreach (pSprite p in Sprites)
            {
                Vector2 destination = position + (p.InitialPosition - orig);

                if (destination == p.Position && p.Transformations.Count == 0)
                {
                    continue;
                }

                moved = true;

                if (extended && Visible && spriteManager.Alpha > 0 && spriteBackground.IsVisible)
                {
                    p.MoveTo(destination, 500, EasingTypes.OutElasticHalf);
                }
                else
                {
                    p.MoveTo(destination, 0);
                }

                p.InitialPosition = destination;

                if (p.TagNumeric == 0)
                {
                    p.Alpha = Visible ? 1 : 0;
                }
            }

            UpdateColour();

            if (moved)
            {
                //Stat change text gets tagged with the user - lets move these too.
                if (statUpdateSprite != null)
                {
                    if (!statUpdateSprite.IsVisible)
                    {
                        statUpdateSprite = null;
                    }
                    else
                    {
                        statUpdateSprite.MoveTo(position + (statUpdateSprite.Position - orig), 500, EasingTypes.Out);
                    }
                }
            }

            return(false);
        }
Пример #21
0
        private void select(object sender, bool silent)
        {
            if (sender == null)
            {
                sender = SpriteMainBox;
            }

            pText senderText = (pText)sender;

            if (senderText == SpriteMainBox)
            {
                if (Visible)
                {
                    Close();
                }
                else
                {
                    Display();
                }

                return;
            }

            Close();

            if (senderText.Text != SpriteMainBox.Text)
            {
                SpriteMainBox.TextChanged = true;
            }

            if (lastSelected != null && senderText != SpriteMainBox)
            {
                lastSelected.TextBold    = false;
                lastSelected.TextChanged = true;
            }

            if (senderText != null)
            {
                senderText.TextBold = true;
                SpriteMainBox.Tag   = senderText.Tag;
            }

            if (senderText.Tag == null)
            {
                return;
            }

            SelectedObject  = senderText.Tag;
            SelectedString  = senderText.Text;
            SelectedNumeric = senderText.TagNumeric;

            if (senderText != SpriteMainBox)
            {
                lastSelected = senderText;
            }

            SpriteMainBox.Text = string.IsNullOrEmpty(senderText.Text) ? " " : senderText.Text;

            if (!silent)
            {
                AudioEngine.Click(null, @"click-short-confirm");
            }

            if (senderText.Tag is Color)
            {
                Color spriteCol = (Color)senderText.Tag;
                if (spriteCol.A < 1)
                {
                    SpriteMainBox.BackgroundColour = Color.Black; //disallow transparent bg colours for sake of style
                }
                else
                {
                    SpriteMainBox.BackgroundColour = spriteCol;
                }
            }

            // TODO: in case of non-pText clone the sprite.
            if (senderText.Tag != null && senderText != SpriteMainBox)
            {
                if (!silent && OnSelect != null)
                {
                    OnSelect(senderText.Tag, null);
                }
            }
        }
Пример #22
0
        private void Display()
        {
            if (Visible || !enabled || blockOpen)
            {
                return;
            }

            Visible = true;

            InputManager.Bind(InputEventType.OnClick, onClick, InputTargetPriority.Highest, BindLifetime.Manual);
            InputManager.Bind(InputEventType.OnClickUp, delegate
            {
                if (!Visible)
                {
                    return(false);
                }

                if (SpriteManager != null && SpriteManager.CurrentHoverSprite != null && SpriteManager.CurrentHoverSprite != SpriteMainBox)
                {
                    //allows drag-and-clickUp selection.
                    SpriteManager.CurrentHoverSprite.Click();
                    return(true);
                }

                return(false);
            }, InputTargetPriority.Highest, BindLifetime.Once);

            AudioEngine.Click(null, @"select-expand");

            if (OptionsSprites.Count > 0)
            {
                if (reverse)
                {
                    OptionsSprites[0].CornerBounds.X = 5;
                    OptionsSprites[0].CornerBounds.Y = 5;

                    OptionsSprites[OptionsSprites.Count - 2].CornerBounds.Z = 5;
                    OptionsSprites[OptionsSprites.Count - 2].CornerBounds.W = 5;
                }
                else
                {
                    OptionsSprites[0].CornerBounds.Z = 5;
                    OptionsSprites[0].CornerBounds.W = 5;

                    OptionsSprites[OptionsSprites.Count - 2].CornerBounds.X = 5;
                    OptionsSprites[OptionsSprites.Count - 2].CornerBounds.Y = 5;
                }
            }


            int i = 0;

            Vector2 offset = new Vector2(0, 0);

            foreach (pText p in OptionsSprites)
            {
                bool isTextAwesome = p is pTextAwesome;

                if (!isTextAwesome)
                {
                    offset.Y += (reverse ? -1 : 1) * p.MeasureText().Y + (reverse ? 0.5f : -0.5f);
                }

                int startTime = GameBase.Time + i * 10;
                p.Bypass = false;

                p.Transformations.Clear();

                p.Position = SpriteMainBox.Position + (isTextAwesome ? new Vector2(6, 9) : Vector2.Zero);
                p.MoveTo(p.Position + offset, (i > 0 ? 200 : 0) + i * 10, EasingTypes.OutCirc);

                p.Transformations.Add(new Transformation(TransformationType.Fade, 0, 1, startTime, startTime + 200, EasingTypes.Out));

                i++;
            }

            if (OnDisplayChanged != null)
            {
                OnDisplayChanged(this, null);
            }
        }
Пример #23
0
        public bool DrawAt(Vector2 pos)
        {
            bool firstPopulation = SpriteCollection == null;

            if (firstPopulation)
            {
                position = pos;

                SpriteCollection = new List <pSprite>();

                bg = new pSprite(GameBase.WhitePixel, Fields.TopLeft,
                                 Origins.TopLeft, Clocks.Game, pos, 0.89F, true,
                                 new Color(255, 255, 255, 25));
                bg.VectorScale = new Vector2(GameBase.WindowManager.WidthScaled - 15, 48);
                bg.Scale       = 1.6f;
                bg.OnHover    += delegate
                {
                    bg.FadeColour(ColourHelper.ChangeAlpha(bg.InitialColour, 50), 100);
                    AudioEngine.Click(null, @"click-short");
                };
                bg.OnHoverLost += delegate { CheckUnhover(); };
                bg.ClickRequiresConfirmation = true;
                bg.OnClick += joinMatch;

                infoLeft1          = new pText(string.Empty, 12, pos + new Vector2(20, 0), 0.9f, true, Color.White);
                infoLeft1.TextBold = true;
                SpriteCollection.Add(infoLeft1);

                infoLeft2 = new pText(string.Empty, 11, pos + new Vector2(56, 13), 0.9f, true, Color.White);
                SpriteCollection.Add(infoLeft2);

                infoRight1          = new pText(string.Empty, 12, pos + new Vector2(240, 0), 0.9f, true, Color.White);
                infoRight1.TextBold = true;
                SpriteCollection.Add(infoRight1);
                infoRight2 = new pText(string.Empty, 11, pos + new Vector2(240, 11), 0.9f, true, Color.White);
                SpriteCollection.Add(infoRight2);

                password = new pSprite(TextureManager.Load(@"lobby-lock", SkinSource.Osu), pos + new Vector2(3, 5), 0.895f, true, Color.TransparentWhite);
                SpriteCollection.Add(password);

                gametype = new pSprite(null, pos + new Vector2(0, 3), 0.894f, true, Color.White);
                SpriteCollection.Add(gametype);

                Vector2 avPos = pos + new Vector2(210, 24);

                hostAvatar                  = new pSpriteDynamic(null, null, 200, avPos, 0.920001f);
                hostBackground              = new pSprite(TextureManager.Load(@"lobby-avatar", SkinSource.Osu), Origins.Centre, avPos, 0.92f, true, playerColour);
                hostBackground.Alpha        = 1;
                hostBackground.Scale        = 1f;
                hostBackground.HandleInput  = true;
                hostBackground.OnHoverLost += delegate { CheckUnhover(); };
                hostBackground.ClickRequiresConfirmation = true;
                hostBackground.OnClick += joinMatch;


                SpriteCollection.Add(hostAvatar);
                SpriteCollection.Add(hostBackground);

                slot_size = !GameBase.WindowManager.IsWidescreen && matchInfo.slotUsedAboveEight ? 0.75f : 1;

                for (int i = 0; i < bMatch.MAX_PLAYERS - 1; i++)
                {
                    avPos = pos + new Vector2(i * 33f * slot_size + 251.4f, 24f + 10.4f);

                    avatars.Add(new pSpriteDynamic(null, null, 200, avPos, 0.920001f));
                    pSprite abg = new pSprite(TextureManager.Load(@"lobby-avatar", SkinSource.Osu), Origins.Centre, avPos, 0.92f, true, Color.TransparentWhite);
                    abg.Alpha        = 0;
                    abg.Scale        = 0.58f * slot_size;
                    abg.HandleInput  = true;
                    abg.OnHoverLost += delegate { CheckUnhover(); };
                    //Because these also get hovered, if the mouse moves from the avatar to another point outside the LobbyMatch the bg will not return states unless this triggers.

                    abg.OnClick += joinMatch;
                    abg.ClickRequiresConfirmation = true;
                    avatarBackgrounds.Add(abg);
                }

                SpriteCollection.AddRange(avatarBackgrounds);
                foreach (pSpriteDynamic p in avatars)
                {
                    SpriteCollection.Add(p);
                }

                SpriteCollection.Add(bg);
            }
            else
            {
                foreach (pSprite p in SpriteCollection)
                {
                    Vector2 destination = pos + (p.InitialPosition - position);
                    p.MoveTo(destination, 500, EasingTypes.Out);
                }
            }

            password.Bypass = !matchInfo.passwordRequired;

            float avgLevel     = 0;
            float avgRank      = 0;
            float minLevel     = 1000;
            float maxLevel     = 0;
            float minRank      = 1000000;
            float maxRank      = 0;
            bool  hasUnranked  = false;
            int   totalPlayers = 0;

            int k = -1;

            for (int j = 0; j < bMatch.MAX_PLAYERS; j++)
            {
                int s = matchInfo.slotId[j];

                pSpriteDynamic thisAvatar;
                pSprite        thisAvatarBackground;

                bool isHost = s == matchInfo.hostId;

                if (!isHost)
                {
                    //Add non-host players to the player list.

                    k++;
                    if (k >= avatars.Count)
                    {
                        break;
                    }
                    thisAvatar           = avatars[k];
                    thisAvatarBackground = avatarBackgrounds[k];

                    if (matchInfo.slotStatus[j] != SlotStatus.Locked)
                    {
                        thisAvatarBackground.Bypass = false;
                        if (matchInfo.slotStatus[j] != SlotStatus.Open)
                        {
                            thisAvatarBackground.HandleInput = true;
                            thisAvatarBackground.FadeColour(playerColour, 200);
                            thisAvatarBackground.FadeTo(1, 200, EasingTypes.None);
                        }
                        else
                        {
                            thisAvatarBackground.HandleInput = false;
                            thisAvatarBackground.FadeColour(openColour, 200);
                            thisAvatarBackground.FadeTo(100 / 255f, 200, EasingTypes.None);
                        }
                    }
                    else
                    {
                        thisAvatarBackground.HandleInput = false;
                        thisAvatarBackground.FadeColour(closedColour, 200);
                        thisAvatarBackground.FadeTo(100 / 255f, 200, EasingTypes.None);
                    }
                }
                else
                {
                    thisAvatar           = hostAvatar;
                    thisAvatarBackground = hostBackground;
                }

                if (s >= 0)
                {
                    User u = BanchoClient.GetUserById(s);

                    if (u == null)
                    {
                        continue;
                    }

                    avgLevel += u.Level;
                    avgRank  += u.Rank;

                    if (u.Level < minLevel)
                    {
                        minLevel = u.Level;
                    }
                    if (u.Level > maxLevel)
                    {
                        maxLevel = u.Level;
                    }

                    if (u.Rank < minRank)
                    {
                        if (u.Rank == 0)
                        {
                            hasUnranked = true;
                        }
                        else
                        {
                            minRank = u.Rank;
                        }
                    }
                    if (u.Rank > maxRank)
                    {
                        maxRank = u.Rank;
                    }

                    totalPlayers++;

                    if (string.IsNullOrEmpty(thisAvatarBackground.ToolTip) || thisAvatarBackground.ToolTip.StartsWith(User.LOADING_STRING))
                    {
                        thisAvatarBackground.ToolTip = string.Format(u.Name + " (#" + u.Rank + ")\n" + u.Location);
                    }

                    if (thisAvatar.Tag != u)
                    {
                        thisAvatar.Tag = u;

                        if (u.LoadAvatarInto(thisAvatar, (thisAvatar == hostAvatar ? 63f : 36f) * slot_size))
                        {
                            thisAvatar.OnTextureLoaded += delegate
                            {
                                thisAvatar.Transformations.Add(new Transformation(TransformationType.Scale, 0, thisAvatar.Scale, GameBase.Time, GameBase.Time + 200, EasingTypes.Out));
                                if (!Filtered)
                                {
                                    thisAvatar.FadeIn(500);
                                }
                            };
                        }
                    }
                }
                else
                {
                    if (thisAvatar.Tag != null)
                    {
                        thisAvatarBackground.ToolTip = null;
                        thisAvatar.Tag     = null;
                        thisAvatar.Texture = null;
                        thisAvatar.FadeOut(500);
                    }
                }
            }

            avgLevel /= totalPlayers;
            avgRank  /= totalPlayers;

            switch (matchInfo.playMode)
            {
            case PlayModes.Osu:
                gametype.Texture = TextureManager.Load(@"mode-osu-small", SkinSource.Osu);
                break;

            case PlayModes.CatchTheBeat:
                gametype.Texture = TextureManager.Load(@"mode-fruits-small", SkinSource.Osu);
                break;

            case PlayModes.Taiko:
                gametype.Texture = TextureManager.Load(@"mode-taiko-small", SkinSource.Osu);
                break;

            case PlayModes.OsuMania:
                gametype.Texture = TextureManager.Load(@"mode-mania-small", SkinSource.Osu);
                break;
            }


            bool foundBeatmapBefore = foundBeatmap;

            if (foundChecksum != matchInfo.beatmapChecksum)
            {
                foundBeatmap  = !string.IsNullOrEmpty(matchInfo.beatmapChecksum) && BeatmapManager.GetBeatmapByChecksum(matchInfo.beatmapChecksum) != null;
                foundChecksum = matchInfo.beatmapChecksum;
            }

            bg.HandleInput = true;
            if (foundBeatmapBefore != foundBeatmap)
            {
                bg.InitialColour = foundBeatmap ? new Color(185, 64, 255, 25) : new Color(202, 202, 202, 25);
            }

            infoLeft1.InitialColour  = matchInfo.inProgress ? Color.Gray : Color.White;
            infoRight1.InitialColour = matchInfo.inProgress ? Color.Gray : Color.White;

            infoLeft1.Text = string.Format(
                @"{0} ({3})
{1} / {2} ",
                GeneralHelper.FormatEnum(matchInfo.playMode.ToString()),
                matchInfo.slotUsedCount,
                matchInfo.slotOpenCount,
                GeneralHelper.FormatEnum(matchInfo.matchTeamType.ToString()));

            /*infoLeft2.Text =
             *  string.Format(minLevel != maxLevel ? @"lv{0:0}-{1:0}" : @"lv{0:0}", minLevel, maxLevel);*/

            if (hasUnranked)
            {
                //maxRank > 0 ensures that at least one non-null rank has been processed.
                infoLeft2.Text = @"rank: " + string.Format(maxRank > 0 ? @"{0:#,#} - ?" : @" ?", minRank, maxRank);
            }
            else
            {
                infoLeft2.Text = @"rank: " + string.Format(minRank != maxRank ? @"{0:#,#} - {1:#,#}" : @"{0:#,#}", minRank, maxRank);
            }

            infoRight1.Text = matchInfo.gameName + @" " + (matchInfo.inProgress ? LocalisationManager.GetString(OsuString.LobbyMatch_InProgress) : string.Empty);
            infoRight2.Text =
                string.IsNullOrEmpty(matchInfo.beatmapChecksum) ? LocalisationManager.GetString(OsuString.LobbyMatch_ChangingBeatmap) :
                string.Format(@"{0}{1}", ModManager.FormatShort(matchInfo.activeMods, true, true), matchInfo.beatmapName);//bofore mapname is better
            infoRight2.InitialColour = new Color(255, 215, 109);

            return(firstPopulation);
        }
Пример #24
0
 void p_OnHover(object sender, EventArgs e)
 {
     AudioEngine.Click(null, @"click-short");
 }
Пример #25
0
 private void SpBack_Click(object sender, EventArgs e)
 {
     AudioEngine.Click(); Clicked_Back?.Invoke();
 }
Пример #26
0
 private void SpEasy_Click(object sender, EventArgs e)
 {
     AudioEngine.Click(); UpdateDifficulty(Difficulty.EASY);
 }
Пример #27
0
 private void SpHard_Click(object sender, EventArgs e)
 {
     AudioEngine.Click(); UpdateDifficulty(Difficulty.HARD);
 }
Пример #28
0
 private void SpNormal_Click(object sender, EventArgs e)
 {
     AudioEngine.Click(); UpdateDifficulty(Difficulty.NORMAL);
 }
Пример #29
0
 private void OpenKeyHelp()
 {
     AudioEngine.Click();
     Clicked_KeyHelp?.Invoke();
 }
Пример #30
0
 private void SpStart_Click(object sender, EventArgs e)
 {
     AudioEngine.Click(); Clicked_Start?.Invoke();
 }