private void Reload()
        {
            foreach (pSprite p in previewSprites)
            {
                p.FadeOut(100);
                p.AlwaysDraw = false;
            }

            previewSprites.Clear();

            int elementCount = previewGroups[currentGroup].Length;

            for (int i = 0; i < elementCount; i++)
            {
                float groupScale = 1;

                List <pSprite> group        = new List <pSprite>();
                float          currentDepth = 0;
                foreach (string element in previewGroups[currentGroup][i].Split('|'))
                {
                    Color  colour   = Color.White;
                    string baseName = element;

                    if (baseName.IndexOf('(') > 0)
                    {
                        //read colour
                        int index = baseName.IndexOf('(');
                        baseName = baseName.Remove(index);

                        string[] parts = element.Substring(index + 1).TrimEnd(')').Split(',');
                        colour = new Color(byte.Parse(parts[0]), byte.Parse(parts[1]), byte.Parse(parts[2]));
                    }

                    baseName = baseName.Replace(@"{default}", SkinManager.Current.FontHitCircle);
                    baseName = baseName.Replace(@"{score}", SkinManager.Current.FontScore);

                    pSprite p = new pSprite(baseName, new Vector2((i + 1) * OptionElement.ELEMENT_SIZE / (elementCount + 1), height / 2), SkinSource.Skin | SkinSource.Osu)
                    {
                        Depth         = currentDepth++ / 100f,
                        InitialColour = colour
                    };

                    groupScale = Math.Min(groupScale, Math.Min((OptionElement.ELEMENT_SIZE / (elementCount + 1)) / (p.DrawWidth / 1.6f), (height) / (p.DrawHeight / 1.6f)));
                    group.Add(p);
                    p.FadeInFromZero(50);
                }

                group.ForEach(p => p.Scale = groupScale);
                previewSprites.AddRange(group);
                spriteManager.Add(group);
            }
        }
Exemple #2
0
        public pStatusDialog(string initialStatus)
        {
            status        = new pText("", 14, new Vector2(GameBase.WindowManager.WidthScaled / 2, 240), 1, true, Color.White);
            status.Origin = Origins.Centre;

            spriteManager.Add(new pSprite(TextureManager.Load(@"beatmapimport-top", SkinSource.Osu), Vector2.Zero, 1, true, Color.White));
            spinner = CreateSpinner(new Color(255, 96, 171));
            spinner.FadeInFromZero(2000);
            spinner.Position.Y += 70;
            spriteManager.Add(spinner);

            SetStatus(initialStatus);
        }
        /// <summary>
        /// Overlay buttons which allow controlling of the replay.
        /// </summary>
        private void InitializeButtons()
        {
            Transformation tr = new Transformation(Color.White, new Color(255, 247, 197), 0, 100);


            int overlayY = 85;

            if (allowComments)
            {
                buttonComments =
                    new pSprite(TextureManager.Load(@"overlay-discussion", SkinSource.Osu), Fields.TopRight,
                                Origins.Centre,
                                Clocks.Game,
                                new Vector2(40, overlayY), 1, true, Color.White, "play");
                buttonComments.FadeInFromZero(500);
                buttonComments.HoverEffect = tr;
                buttonComments.HandleInput = true;
                buttonComments.OnClick    += buttonComments_OnClick;
                spriteManager.Add(buttonComments);

                overlayY += 20;
            }

            buttonFF =
                new pSprite(TextureManager.Load(@"overlay-1x", SkinSource.Osu), Fields.TopRight,
                            Origins.Centre,
                            Clocks.Game,
                            new Vector2(40, overlayY), 1, true, Color.White, "play");
            buttonFF.FadeInFromZero(500);
            buttonFF.HoverEffect = tr;
            buttonFF.HandleInput = true;
            buttonFF.OnClick    += buttonFF_OnClick;
            spriteManager.Add(buttonFF);

            overlayY += 20;

            //Replay overlay controls.
            buttonEndReplay =
                new pSprite(TextureManager.Load(@"overlay-endreplay", SkinSource.Osu), Fields.TopRight,
                            Origins.Centre, Clocks.Game,
                            new Vector2(40, overlayY), 1, true, Color.White, "play");
            buttonEndReplay.FadeInFromZero(500);
            buttonEndReplay.HoverEffect = tr;
            buttonEndReplay.HandleInput = true;
            buttonEndReplay.OnClick    += buttonEndReplay_OnClick;
            spriteManager.Add(buttonEndReplay);

            overlayY += 20;
        }
        internal override void UpdatePassing(bool value)
        {
            if (value)
            {
                mascot.SetState(Player.KiaiActive ? TaikoMascotStates.Kiai : TaikoMascotStates.Idle, false);
            }
            else
            {
                mascot.SetState(TaikoMascotStates.Fail, false);
            }

            List <pSprite> newSliderCollection = new List <pSprite>();

            taikoSliderActiveCollection.ForEach(s =>
            {
                pSprite clone = s.Clone();

                clone.Depth += 0.0001f;

                const int delay = 200;

                clone.FadeInFromZero(delay);
                s.Transformations.Add(new Transformation(TransformationType.Fade, 1, 0, AudioEngine.Time + delay, AudioEngine.Time + delay));

                if (value)
                {
                    clone.Texture = sliderTexturePass;
                }
                else
                {
                    clone.Texture = sliderTextureFail;
                }

                newSliderCollection.Add(clone);
            });

            Debug.Print("Cloned {0} sprites from {1} to state: {2}", newSliderCollection.Count, taikoSliderActiveCollection.Count, value);

            player.spriteManagerBelowHitObjectsWidescreen.Add(newSliderCollection);

            taikoSliderActiveCollection = newSliderCollection;
            if (newSliderCollection.Count > 0)
            {
                taikoSlider = newSliderCollection[newSliderCollection.Count - 1];
            }

            base.UpdatePassing(value);
        }
        void buyMore(object sender, EventArgs e)
        {
            if (coinsDialog != null)
            {
                coinsDialog.AlwaysDraw = false;
                coinsDialog            = null;
            }

            spriteManagerDialog.Add(coinsDialog = new pSprite(@"coins-dialog", new Vector2(0, 0), SkinSource.All, Origins.Centre, Fields.Centre)
            {
                Depth = 0.9f
            });
            coinsDialog.OnClick += delegate { };
            coinsDialog.FadeInFromZero(100);
            coinsDialog.HandleInput = true;
        }
Exemple #6
0
        internal void AddOption(string text, Color textColour, EventHandler onClick, bool closePopup)
        {
            Color modColour = new Color(200, 200, 200, 255);

            pButton pbut = new pButton((options.Count + 1) + ". " + text, new Vector2(90, currentVerticalSpace), new Vector2(460, 40), 0.92f, textColour, onClick);

            ((pText)pbut.SpriteCollection[3]).TextShadow = true;
            for (int i = 0; i < 4; i++)
            {
                pSprite p = pbut.SpriteCollection[i];
                if (i < 3 && closePopup)
                {
                    p.OnClick += option_OnClick;
                    p.Tag      = pbut;
                }
                if (i == 0)
                {
                    options.Add(p);
                }
                p.FadeInFromZero(140);

                SpriteCollection.Add(p);
            }

            /*pText option =
             *  new pText((options.Count + 1) + ". " + text, 34, new Vector2(320, currentVerticalSpace), new Vector2(460, 150), 0.92F, true,
             *            modColour, false);
             * option.TextColour = textColour;
             * option.OriginType = OriginTypes.Centre;
             * option.TextAlignment = Alignment.Centre;
             * option.BackgroundColour = Color.Black;
             * option.HoverEffect = new Transformation(modColour, Color.White, 0, 100);
             * option.BorderColour = Color.Gray;
             * option.BorderWidth = 3;
             * option.IsClickable = true;
             * option.CatchUniversal = true;
             * if (closePopup)
             *  option.OnClick += option_OnClick;
             * if (onClick != null)
             *  option.OnClick += onClick;
             * SpriteCollection.Add(option);
             * option.FadeInFromZero(180);
             * options.Add(option);
             */
            currentVerticalSpace += 50;
        }
Exemple #7
0
        internal void AddOption(string text, Color textColour, EventHandler onClick, bool closePopup = true, bool halfWidth = false, bool leftHalf = true)
        {
            pButton pbut = new pButton((options.Count + 1) + ". " + text, new Vector2(GameBase.WindowManager.WidthScaled / 2 - 230 + (leftHalf ? 0 : 240), currentVerticalSpace) + ButtonOffset, new Vector2(halfWidth ? 220 : 460, 40), 0.92f, textColour, onClick, GameModeSpecific);

            ((pText)pbut.SpriteCollection[3]).TextShadow = true;
            for (int i = 0; i < 4; i++)
            {
                pSprite p = pbut.SpriteCollection[i];

                if (i < 3 && closePopup)
                {
                    p.OnClick += option_DoClose;
                    p.Tag      = pbut;
                }

                if (IsDisplayed)
                {
                    p.FadeInFromZero(140);
                }
                else
                {
                    int start = options.Count * 60;
                    p.Alpha = 0;
                    p.Transformations.Add(new Transformation(p.InitialPosition + new Vector2(AddOdd ? -40 : 40, 0), p.InitialPosition, start, start + 800, EasingTypes.OutBounce));
                    p.Transformations.Add(new Transformation(TransformationType.Fade, 0, 1, start, start + 800, EasingTypes.Out));
                    p.Position = p.Position + new Vector2(AddOdd ? -40 : 40, 0);
                }

                spriteManager.Add(p);
            }

            options.Add(pbut.SpriteCollection[0]);

            AddOdd = !AddOdd;

            currentVerticalSpace += 50;
        }
Exemple #8
0
        public BanchoStatusOverlay()
        {
            background = new pSprite(TextureManager.Load(@"notification", SkinSource.Osu), Fields.NativeBottomCentre, Origins.Centre, Clocks.Game, new Vector2(0, 0), 0.8f, true, new Color(0, 0, 0, 128));
            spriteManager.Add(background);

            spinner = new pSprite(TextureManager.Load(@"loading-small", SkinSource.Osu), Fields.NativeBottomCentre, Origins.Centre, Clocks.Game, new Vector2(-100, 11), 1, true, Color.White);
            Transformation tr = new Transformation(TransformationType.Rotation, 0, (float)Math.PI * 2, GameBase.Time, GameBase.Time + 1500);

            tr.Loop = true;

            spinner.Transformations.Add(tr);
            spinner.FadeInFromZero(2000);
            spriteManager.Add(spinner);

            message                    = new pText("Bancho is connecting...", 8, new Vector2(-88, 18), 1, true, Color.White);
            message.TextAa             = false;
            message.TextRenderSpecific = false;
            message.Field              = Fields.NativeBottomCentre;

            spriteManager.Add(message);

            spriteManager.SpriteList.ForEach(s => { s.Alpha = 0; s.Position.Y -= hide_offset; });
            spriteManager.Alpha = 0;
        }
Exemple #9
0
        public override void Initialize()
        {
            ReplayMode = InputManager.ReplayMode;

            Player.scoreBoard.topLeft = new Vector2(530, 120);
            foreach (ScoreboardEntry sbe in Player.scoreBoard.Entries)
            {
                sbe.spriteBackground.OriginPosition = new Vector2(26, 20);
                sbe.spriteBackground.OnClick       += spriteBackground_OnClick;
                sbe.spriteBackground.IsClickable    = true;
                sbe.spriteBackground.Tag            = sbe;
                sbe.spriteBackground.HoverEffect    = new Transformation(sbe.spriteBackground.StartColour,
                                                                         Color.YellowGreen, 0, 100);
            }

            Player.scoreBoard.spriteManager.Alpha = 1;

            InputManager.ReplayMode           = false;
            InputManager.ReplayStreaming      = false;
            InputManager.ReplayStreamingStart = 0;

            Randomizer = new Random();

            KeyboardHandler.OnKeyPressed += GameBase_OnKeyPressed;
            MouseHandler.OnClick         += GameBase_OnClick;

            spriteManager = new SpriteManager();

            pText noMatches = new pText("Click a player tab to view their score!\nHit F2 to export your replay.", 14
                                        , new Vector2(400, 60), new Vector2(240, 0), 1, true, Color.White, false);

            noMatches.TextBold = true;
            //noMatches.CurrentColour = Color.TransparentWhite;
            //noMatches.TextAlignment = Alignment.Centre;
            //noMatches.OriginType = OriginTypes.Centre;
            spriteManager.Add(noMatches);

            Texture2D ss = null;

            if (SkinManager.Current.RawName == "Default")
            {
                try
                {
                    ss = content.Load <Texture2D>("ranking-background");
                }
                catch
                {
                }
            }

            pSprite bg =
                new pSprite(ss ?? SkinManager.Load("playfield"), FieldTypes.Window, OriginTypes.TopLeft,
                            ClockTypes.Game, Vector2.Zero, 0, true, ss != null ? Color.White : new Color(146, 148, 214));

            spriteManager.Add(bg);

            pSprite p =
                new pSprite(SkinManager.Load("ranking-title"), FieldTypes.Window, OriginTypes.TopLeft,
                            ClockTypes.Game, new Vector2(360, 0), 0.8F, true, Color.White);

            spriteManager.Add(p);

            p =
                new pSprite(SkinManager.Load("ranking-graph"), FieldTypes.Window, OriginTypes.TopLeft,
                            ClockTypes.Game, new Vector2(20, 360), 0.8F, true, Color.White);
            spriteManager.Add(p);

            p =
                new pSprite(SkinManager.Load("ranking-panel"), FieldTypes.Window, OriginTypes.TopLeft,
                            ClockTypes.Game, new Vector2(0, 46), 0.2F, true, Color.White);
            spriteManager.Add(p);

            startTime = GameBase.Time + 300;

            Player.scoreBoard.trackingEntry.spriteBackground.Click();

            pSprite detailsBack =
                new pSprite(GameBase.WhitePixel, FieldTypes.Window,
                            OriginTypes.TopLeft,
                            ClockTypes.Game,
                            new Vector2(0, 0), 0.7F, true, Color.Black);

            detailsBack.VectorScale    = new Vector2(1024, 83);
            detailsBack.UseVectorScale = true;
            spriteManager.Add(detailsBack);

            pText pt =
                new pText("Multiplayer Results", 22, new Vector2(0, 0), Vector2.Zero, 0.79F, true,
                          Color.White, false);

            spriteManager.Add(pt);

            pt =
                new pText("Beatmap: " + BeatmapManager.Current.DisplayTitle, 16, new Vector2(1, 20), Vector2.Zero, 0.79F,
                          true, Color.White, false);
            spriteManager.Add(pt);
            pt = new pText("Match played at " +
                           score.date.ToString("yy/MM/dd hh:mm:ss", GameBase.nfi), 16, new Vector2(1, 34), Vector2.Zero,
                           0.79F, true, Color.White, false);
            spriteManager.Add(pt);

            b_back =
                new pSprite(SkinManager.Load("ranking-back"), FieldTypes.Window,
                            OriginTypes.Centre,
                            ClockTypes.Game,
                            new Vector2(520, 430), 0.94F, true,
                            new Color(255, 255, 255, 178));
            b_back.OnClick    += return_OnClick;
            b_back.IsClickable = true;
            b_back.HoverEffect = new Transformation(TransformationType.Fade, 0.7F, 1, 0, 200);
            spriteManager.Add(b_back);

            int   time = 0;
            float dep  = 0;
            int   x    = 360;

            foreach (Mods m in Enum.GetValues(typeof(Mods)))
            {
                if (ModManager.CheckActive(score.enabledMods, m))
                {
                    Transformation t2 =
                        new Transformation(TransformationType.Scale, 2, 1, GameBase.Time + time,
                                           GameBase.Time + time + 400);
                    Transformation t3 =
                        new Transformation(TransformationType.Fade, 0, 1, GameBase.Time + time,
                                           GameBase.Time + time + 400);
                    t2.Easing = EasingTypes.In;
                    t3.Easing = EasingTypes.In;

                    p =
                        new pSprite(SkinManager.Load("selection-mod-" + m.ToString().ToLower()),
                                    FieldTypes.Window,
                                    OriginTypes.Centre,
                                    ClockTypes.Game,
                                    new Vector2(x, 440), 0.92F + dep, true,
                                    Color.TransparentWhite);
                    p.Transformations.Add(t2);
                    p.Transformations.Add(t3);
                    spriteManager.Add(p);

                    time += 500;
                    dep  += 0.00001f;
                    x    -= 20;
                }
            }

            graphLine = new List <Line>();

            if (score.hpGraph != null && score.hpGraph.Count > 0)
            {
                float time1   = score.hpGraph[0].X;
                float time2   = score.hpGraph[score.hpGraph.Count - 1].X;
                float ratio   = 186 / (time2 - time1);
                int   height  = 86;
                int   offsetX = 94;
                int   offsetY = 373;

                Vector2[] va = score.hpGraph.ToArray();

                for (int i = 0; i < va.Length; i++)
                {
                    va[i].X = GameBase.WindowRatio * ((va[i].X - time1) * ratio + offsetX);
                    bool ok = va[i].Y > 0.5;
                    va[i].Y = GameBase.WindowRatio * ((1 - va[i].Y) * height + offsetY);

                    if (i > 0)
                    {
                        Line l = new Line(va[i - 1], va[i], 1, (ok ? Color.YellowGreen : Color.Red));
                        graphLine.Add(l);
                        graphLength += l.rho;
                    }
                }
            }

            Texture2D winner   = ((ScoreboardEntryExtended)Player.scoreBoard.Entries[0]).spriteAvatar.Texture;
            pSprite   winnerBg = new pSprite(SkinManager.Load("ranking-winner"), new Vector2(395, 70), 0.4f, true, Color.White);

            spriteManager.Add(winnerBg);
            if (winner != null)
            {
                pSprite largeAvatar = new pSprite(winner, OriginTypes.Centre, new Vector2(457.5f, 142f), 0.41f, true, Color.White);
                largeAvatar.CurrentScale = 185F / Math.Max(largeAvatar.Width, largeAvatar.Height);
                spriteManager.Add(largeAvatar);
                largeAvatar.MoveToRelative(new Vector2(0, 200), 2000, EasingTypes.In);
                largeAvatar.FadeInFromZero(1500);
            }

            winnerBg.MoveToRelative(new Vector2(0, 200), 2000, EasingTypes.In);
            winnerBg.FadeInFromZero(1500);

            Console.WriteLine("graph length is " + graphLength);
            drawList = new List <Line>();

            base.Initialize();

            GameBase.LoadComplete();

            if (ReplayMode)
            {
                Progress(false);
            }
            else
            {
                ApplauseChannel = AudioEngine.PlaySample(AudioEngine.s_Applause);
            }
        }
        public override void Update(GameTime gameTime)
        {
            if (IsDisplayed && pendingOnlineScores && OnlineRetrival)
            {
                if (score.onlineRank > 0)
                {
                    onlineRanking.Text = "Congratulations - you achieved rank #" + score.onlineRank +
                                         " online for this beatmap!";
                    onlineRanking.TextColour = Color.YellowGreen;
                }
                else
                {
                    onlineRanking.Text = "You have previously set a higher online record.";
                }

                GameBase.User.Refresh();

                if (GameBase.User.NextRank != 0)
                {
                    onlineRanking2.Text = string.Format("You need another {0:0,0} points to reach the next rank!",
                                                        GameBase.User.NextRank);
                }

                if (GameBase.User.AchievementImages != null)
                {
                    GameBase.ShowMessageMassive("Loading new achievements...", 1000);
                    for (int i = 0; i < GameBase.User.AchievementImages.Length; i++)
                    {
                        if (GameBase.User.AchievementImages[i].Length == 0)
                        {
                            continue;
                        }
                        DataNetRequest dnr =
                            new DataNetRequest("http://osu.ppy.sh/images/achievements/" + GameBase.User.AchievementImages[i]);
                        int locali = i;
                        dnr.onFinish += delegate(byte[] data, Exception e)
                        {
                            if (e != null)
                            {
                                return;
                            }
                            MemoryStream stream = new MemoryStream(data);
                            stream.Position = 0;
                            pSprite p =
                                new pSprite(
                                    Texture2D.FromFile(GameBase.graphics.GraphicsDevice, stream),
                                    new Vector2(
                                        320 - (GameBase.User.AchievementImages.Length * 84) / 2f + locali * 84,
                                        vspacing), 0.95f + locali * 0.001f, true, Color.White);
                            p.FadeInFromZero(500);
                            spriteManager.Add(p);
                            SpriteCollection.Add(p);
                        };

                        NetManager.AddRequest(dnr);
                    }
                }

                pendingOnlineScores = false;
            }

            if (acceptRating)
            {
                int found = -1;
                for (int i = 0; i < 10; i++)
                {
                    if (star[i].Hovering)
                    {
                        found = i;
                    }
                }
                for (int i = 0; i < 10; i++)
                {
                    star[i].FadeColour((i <= found ? Color.White : new Color(161, 73, 127, 255)), 100);
                }
            }
        }
        internal NotificationMassive(string text, int duration, NotificationType type)
        {
            Type = type;

            int startTime = GameBase.Time;
            int endTime   = startTime + duration;

            message               = new pText(text, 18, new Vector2(GameBase.WindowManager.WidthScaled / 2, 240), new Vector2(GameBase.WindowManager.Width / GameBase.WindowManager.Ratio, 0), 1, false, Color.White, false);
            message.Origin        = Origins.TopCentre;
            message.TextAlignment = TextAlignment.Centre;
            message.TextBorder    = true;
            message.Transformations.Add(new Transformation(TransformationType.Fade, 0, 1, startTime, startTime + FADE_IN_TIME));
            message.Transformations.Add(new Transformation(TransformationType.Fade, 1, 0, endTime, endTime + FADE_OUT_TIME));
            //Call the long version of MeasureText so we don't make a texture on the wrong thread.
            float yMeasure = message.MeasureText().Y;

            message.Position.Y -= yMeasure / 2;

            SpriteCollection.Add(message);

            yMeasure *= 1.5f;

            background = new pSprite(GameBase.WhitePixel, new Vector2(0, 240 - yMeasure / 2), 0.999f,
                                     false, new Color(0, 0, 0, 180));
            background.Scale       = 1.6f;
            background.Origin      = Origins.TopLeft;
            background.VectorScale = new Vector2(GameBase.WindowManager.WidthScaled, yMeasure);

            background.Transformations.Add(new Transformation(TransformationType.VectorScale, new Vector2(GameBase.WindowManager.WidthScaled, 0),
                                                              background.VectorScale, startTime, startTime + 300, EasingTypes.OutBack));
            background.Transformations.Add(new Transformation(new Vector2(0, 240), background.InitialPosition, startTime, startTime + 300, EasingTypes.OutBack));
            background.Transformations.Add(new Transformation(TransformationType.Fade, 180 / 255f, 0, endTime, endTime + FADE_OUT_TIME));

            SpriteCollection.Add(background);

            switch (type)
            {
            case NotificationType.Error:
                background.InitialColour = Color.Red;
                //has not been tested. will look horrible.
                break;

            case NotificationType.Warning:
                message.BorderColour     = new Color(146, 82, 0);
                background.InitialColour = new Color(255, 186, 0);

                pSprite border = new pSprite(TextureManager.Load(@"test-build-overlay", SkinSource.Osu), Origins.BottomLeft, new Vector2(0, 240 - yMeasure / 2), 0.9991f, false, Color.White);
                border.Scale = 1.5f;
                border.FadeInFromZero(300);
                border.MoveToX(-100, duration);
                border.Transformations.Add(new Transformation(TransformationType.Fade, 1, 0, endTime, endTime + FADE_OUT_TIME));

                SpriteCollection.Add(border);

                border = new pSprite(TextureManager.Load(@"test-build-overlay", SkinSource.Osu), new Vector2(-100, 240 + yMeasure / 2), 0.9991f, false, Color.White);
                border.FlipVertical = true;
                border.MoveToX(0, duration);
                border.Scale = 1.5f;
                border.FadeInFromZero(300);
                border.Transformations.Add(new Transformation(TransformationType.Fade, 1, 0, endTime, endTime + FADE_OUT_TIME));

                SpriteCollection.Add(border);
                break;
            }
        }
        private void updateBackground(AlignmentMode alignmentMode, BackgroundAdjustmentDelegate backgroundAdjustment, pTexture loadedTexture = null)
        {
            if (!showBackground)
            {
                return;
            }

            if (BackgroundSprite != null && GameBase.Time >= Menu.IntroLength)
            {
                BackgroundSprite.FadeTo(1, 100);
            }

            if (loadedTexture == null || loadedTexture.IsDisposed)
            {
                //we need to load a new texture.
                int updateCountAtStart = backgroundUpdateCount;

                GameBase.RunBackgroundThread(delegate
                {
                    if (updateCountAtStart != backgroundUpdateCount)
                    {
                        return;
                    }

                    pTexture loaded = null;

                    //load from beatmap
                    if (BeatmapManager.Current != null && !string.IsNullOrEmpty(BeatmapManager.Current.BackgroundImage))
                    {
                        switch (GameBase.Mode)
                        {
                        case OsuModes.Edit:
                        case OsuModes.SelectEdit:
                        case OsuModes.SelectMulti:
                        case OsuModes.SelectPlay:
                        case OsuModes.Play:
                        case OsuModes.Rank:
                        case OsuModes.RankingTagCoop:
                        case OsuModes.RankingTeam:
                        case OsuModes.RankingVs:
                            loaded = TextureManager.Load(BeatmapManager.Current.BackgroundImage, SkinSource.Beatmap);
                            if (loaded != null)
                            {
                                loaded.Disposable = true;
                            }
                            break;
                        }
                    }

#if CHRISTMAS
                    if (loaded == null)
                    {
                        const int available_xmas_backgrounds = 13;
                        if (loadedBackgroundIndex < 0)
                        {
                            loadedBackgroundIndex = RNG.Next(1, available_xmas_backgrounds + 1);
                        }
                        else if (GameBase.Mode == OsuModes.Menu)
                        {
                            loadedBackgroundIndex = Math.Max(1, (loadedBackgroundIndex + 1) % (available_xmas_backgrounds + 1));
                        }

                        loaded = TextureManager.Load(@"menu-background-xmas-" + loadedBackgroundIndex, SkinSource.Osu);
                    }
#endif

                    //if we are a supporter, we can also check the skin for a custom menu-background.
                    if (loaded == null && (BanchoClient.Permission & Permissions.Supporter) > 0 && !SkinManager.IsDefault)
                    {
                        loaded = TextureManager.Load(@"menu-background.jpg", SkinSource.Skin);
                    }

                    //if we still haven't found a texture, we can fall back to the default.
                    if (loaded == null)
                    {
                        loaded = TextureManager.Load(@"menu-background", SkinSource.Osu);
                    }

                    //perform the final load.
                    if (loaded != null)
                    {
                        GameBase.Scheduler.Add(delegate
                        {
                            if (updateCountAtStart != backgroundUpdateCount)
                            {
                                return;
                            }

                            updateBackground(alignmentMode, backgroundAdjustment, loaded);
                        });
                    }
                });
            }
            else
            {
                //we have finished loading a texture.
                BackgroundTexture = loadedTexture;

                loadedBackgroundMode = BanchoClient.Permission;

                bool isSameTexture = BackgroundSprite != null && BackgroundTexture == BackgroundSprite.Texture;

                if (isSameTexture && currentBackgroundAdjustment == null && backgroundAdjustment == null && currentAlignmentMode == alignmentMode)
                {
                    return;
                }

                bool firstChange = BackgroundSprite == null;

                ClearBackground(false);
                BackgroundSprite = createBackgroundSprite(alignmentMode);
                if (GameBase.Time >= Menu.IntroLength)
                {
                    BackgroundSprite.FadeInFromZero(50);
                }
                else
                {
                    BackgroundSprite.Alpha = 0;
                }

                updateBackgroundAlignment(BackgroundSprite, alignmentMode, backgroundAdjustment);

                SpriteManager backgroundSpriteManager = (alignmentMode & AlignmentMode.Widescreen) != 0 ? spriteManagerBackWide : spriteManagerBack;
                backgroundSpriteManager.Add(BackgroundSprite);

                if (TrianglesBack != null)
                {
                    if (SkinManager.Current.TriangleColours.Count != 0)
                    {
                        GameBase.Scheduler.Add(delegate { TrianglesBack.SetColours(SkinManager.Current.TriangleColours); });
                    }
                    else
                    {
                        switch (BackgroundTexture.Source)
                        {
                        case SkinSource.Beatmap:
                            TrianglesBack.SetColours(BeatmapManager.Current.GetFileStream(BeatmapManager.Current.BackgroundImage), finishedReadingColours);
                            break;

                        case SkinSource.Skin:
                            Stream stream = new FileStream(BackgroundTexture.Filename, FileMode.Open, FileAccess.Read, FileShare.Read);
                            TrianglesBack.SetColours(stream, finishedReadingColours);
                            break;

                        default:
                            TrianglesBack.SetColours(null, finishedReadingColours);
                            break;
                        }
                    }
                }

                if (OnBackgroundChanged != null)
                {
                    OnBackgroundChanged();
                }
                TrianglesBack.VelocityCurrent = firstChange ? 150 : 50;
            }
        }
Exemple #13
0
        protected override void InitializeSpecifics()
        {
            Player.ScoreBoard.topLeft = new Vector2(GameBase.WindowManager.WidthScaled - 125, 120);

            foreach (ScoreboardEntry sbe in Player.ScoreBoard.Entries)
            {
                sbe.SpriteBackground.Texture        = TextureManager.Load(@"menu-button-background");
                sbe.SpriteBackground.OriginPosition = new Vector2(26, 20);
                sbe.SpriteBackground.OnClick       += spriteBackground_OnClick;
                sbe.SpriteBackground.HandleInput    = true;
                sbe.SpriteBackground.Tag            = sbe;
                sbe.SpriteBackground.HoverEffect    = new Transformation(sbe.SpriteBackground.InitialColour,
                                                                         Color.YellowGreen, 0, 100);
                if (sbe.name == GameBase.User.Name)
                {
                    ChatEngine.AddUserLog(string.Format(LocalisationManager.GetString(OsuString.Userlog_Multiplayer), sbe.rank, Player.ScoreBoard.Entries.Count, BeatmapManager.Current.DisplayTitleFull, OsuCommon.PlayModeString(Player.Mode)));
                }
            }

            Player.ScoreBoard.spriteManager.Alpha = 1;

            pText noMatches = new pText("Click a player tab to view their score! Hit F2 to export your replay.", 14
                                        , new Vector2(GameBase.WindowManager.WidthScaled, 60), Vector2.Zero, 1, true, Color.White, false)
            {
                TextAlignment    = Graphics.Renderers.TextAlignment.Right,
                Origin           = Origins.TopRight,
                ViewOffsetImmune = true
            };

            noMatches.TextBold = true;
            spriteManagerWideScrolling.Add(noMatches);

            startTime = GameBase.Time + 300;

            if (Player.ScoreBoard.trackingEntry != null)
            {
                Player.ScoreBoard.trackingEntry.SpriteBackground.Click();
            }

            pText pt =
                new pText(BeatmapManager.Current.DisplayTitle, 22, new Vector2(0, 0), Vector2.Zero, 0.991F, true,
                          Color.White, false);

            pt.ViewOffsetImmune = true;
            spriteManagerWideScrolling.Add(pt);

            pt =
                new pText("Beatmap by " + BeatmapManager.Current.Creator, 16, new Vector2(1, 20), Vector2.Zero, 0.991F,
                          true, Color.White, false);
            pt.ViewOffsetImmune = true;
            spriteManagerWideScrolling.Add(pt);

            pt = new pText("Match played at " + score.Date.ToString("yy/MM/dd hh:mm:ss", GameBase.nfi), 16, new Vector2(1, 34), Vector2.Zero,
                           0.991F, true, Color.White, false);
            pt.ViewOffsetImmune = true;
            spriteManagerWideScrolling.Add(pt);

            if (!MatchSetup.Match.TeamMode && Player.ScoreBoard.Entries.Count > 1 && Player.ScoreBoard.Entries[0].score != Player.ScoreBoard.Entries[1].score) //don't display in a tied situation.
            {
                pTexture winner   = ((ScoreboardEntryExtended)Player.ScoreBoard.Entries[0]).SpriteAvatar.Texture;
                pSprite  winnerBg = new pSprite(TextureManager.Load(@"ranking-winner"), new Vector2(395, 10), 0.4f, true, Color.White);
                spriteManagerWideScrolling.Add(winnerBg);
                if (winner != null)
                {
                    pSprite largeAvatar = new pSprite(winner, Origins.Centre, new Vector2(457.5f, 89f), 0.41f, true, Color.White);
                    largeAvatar.Scale = 185F / Math.Max(largeAvatar.Width, largeAvatar.Height);
                    spriteManagerWideScrolling.Add(largeAvatar);
                    largeAvatar.MoveToRelative(new Vector2(0, 200), 2000, EasingTypes.Out);
                    largeAvatar.FadeInFromZero(1500);
                }

                winnerBg.MoveToRelative(new Vector2(0, 200), 2000, EasingTypes.Out);
                winnerBg.FadeInFromZero(1500);
            }
        }
Exemple #14
0
        private void Director_OnTransitionEnded()
        {
            //hit -> combo -> accuracy -> spin

            int time      = cameFromSongSelect ? 0 : 500;
            int increment = cameFromSongSelect ? 0 : 500;

            GameBase.Scheduler.Add(delegate
            {
                AudioEngine.PlaySample(OsuSamples.RankingBam);
                countScoreHit.ShowInt(RankableScore.hitScore, 6);
                countScoreHit.AdditiveFlash(500, 1);

                addedScore += RankableScore.hitScore;
                countTotalScore.ShowInt(addedScore, 6, true);
                countTotalScore.FlashColour(Color4.White, 1000);
            }, time);

            time += increment;

            GameBase.Scheduler.Add(delegate
            {
                AudioEngine.PlaySample(OsuSamples.RankingBam);
                countScoreCombo.ShowInt(RankableScore.comboBonusScore, 6);
                countScoreCombo.AdditiveFlash(500, 1);


                addedScore += RankableScore.comboBonusScore;
                countTotalScore.ShowInt(addedScore, 6, true);
                countTotalScore.FlashColour(Color4.White, 1000);
            }, time);

            time += increment;

            GameBase.Scheduler.Add(delegate
            {
                AudioEngine.PlaySample(OsuSamples.RankingBam);
                countScoreAccuracy.ShowInt(RankableScore.accuracyBonusScore, 6);
                countScoreAccuracy.AdditiveFlash(500, 1);

                addedScore += RankableScore.accuracyBonusScore;
                countTotalScore.ShowInt(addedScore, 6, true);
                countTotalScore.FlashColour(Color4.White, 1000);
            }, time);

            time += increment;

            GameBase.Scheduler.Add(delegate
            {
                AudioEngine.PlaySample(OsuSamples.RankingBam);
                countScoreSpin.ShowInt(RankableScore.spinnerBonusScore, 6);
                countScoreSpin.AdditiveFlash(500, 1);

                addedScore += RankableScore.spinnerBonusScore;
                countTotalScore.ShowInt(addedScore, 6, true);
                countTotalScore.FlashColour(Color4.White, 1000);
            }, time);

            time += increment;

            GameBase.Scheduler.Add(delegate
            {
                if (RankableScore.Ranking == Rank.D)
                {
                    AudioEngine.PlaySample(OsuSamples.RankFail);
                    rankGraphic.FadeIn(2000);
                    rankGraphic.ScaleScalar = 0.7f;
                    rankGraphic.ScaleTo(1, 1400, EasingTypes.In);
                    GameBase.Scheduler.Add(delegate
                    {
                        int interval = 100;
                        rankGraphic.Transform(new TransformationF(TransformationType.Rotation, 0, 0.3f, Clock.Time, Clock.Time + interval));
                        rankGraphic.Transform(new TransformationF(TransformationType.Rotation, 0.3f, -0.3f, Clock.Time + interval, Clock.Time + interval * 3));
                        rankGraphic.Transform(new TransformationF(TransformationType.Rotation, -0.3f, 0, Clock.Time + interval * 3, Clock.Time + interval * 4));
                    }, 1550);
                }
                else
                {
                    AudioEngine.PlaySample(OsuSamples.RankPass);
                    rankGraphic.FadeIn(4000);

                    GameBase.Scheduler.Add(delegate
                    {
                        rankGraphic.Transformations.Clear();
                        rankGraphic.Alpha = 1;
                        rankGraphic.AdditiveFlash(1500, 1);
                    }, 1400);
                }
            }, time);

            time += increment + 1200;

            if (isPersonalBest)
            {
                GameBase.Scheduler.Add(delegate
                {
                    pSprite personalBest = new pSprite(TextureManager.Load(OsuTexture.personalbest), FieldTypes.StandardSnapBottomRight, OriginTypes.Centre, ClockTypes.Mode, new Vector2(80, 250),
                                                       1, true, Color4.White);
                    personalBest.FadeInFromZero(250);
                    personalBest.ScaleScalar = 1.6f;
                    personalBest.RotateTo(0.2f, 250);
                    personalBest.ScaleTo(1, 250, EasingTypes.Out);

                    GameBase.Scheduler.Add(delegate { personalBest.AdditiveFlash(1000, 1).ScaleTo(1.05f, 1000); }, 250);

                    layer1.Add(personalBest);
                }, time);
            }

            time += increment;

            if (!cameFromSongSelect)
            {
                GameBase.Scheduler.Add(finishDisplaying, time);
            }
        }
Exemple #15
0
        private void doSubmission()
        {
            int deviceType = 0;

#if iOS
            if (!GameBase.Mapper)
            {
                deviceType = (int)osum.Support.iPhone.HardwareDetection.Version;

                //todo: for iOS5 twitter authentication, we need to double-check we actually have auth.
                string hash = GameBase.Config.GetValue <string>("hash", null);
                if (hash == null)
                {
                    //todo: no twitter auth. are we not submitting anymore?
                    return;
                }
                else if (hash.StartsWith("ios-"))
                {
                    hash = hash.Substring(4);
                    using (ACAccountStore store = new ACAccountStore())
                    {
                        ACAccount account = store.FindAccount(hash);
                        if (account != null)
                        {
                            //yay, i think.
                            //todo: test that this actually checks grants (it should in theory).
                        }
                        else
                        {
                            GameBase.Notify("Twitter authentication failed. Please visit the options screen to login again.");
                            GameBase.Config.SetValue <string>("username", null);
                            GameBase.Config.SetValue <string>("hash", null);
                            GameBase.Config.SetValue <string>("twitterId", null);
                            GameBase.Config.SaveConfig();
                            return;
                        }
                    }
                }

                string check = CryptoHelper.GetMd5String("moocow" +
                                                         GameBase.Instance.DeviceIdentifier +
                                                         RankableScore.count100 +
                                                         RankableScore.count300 +
                                                         RankableScore.count50 +
                                                         RankableScore.countMiss +
                                                         RankableScore.maxCombo +
                                                         RankableScore.spinnerBonusScore +
                                                         RankableScore.comboBonusScore +
                                                         RankableScore.accuracyBonusScore +
                                                         RankableScore.Ranking +
                                                         Path.GetFileName(Player.Beatmap.ContainerFilename) +
                                                         deviceType +
                                                         RankableScore.hitScore +
                                                         (int)Player.Difficulty);

                string postString =
                    "udid=" + GameBase.Instance.DeviceIdentifier +
                    "&count300=" + RankableScore.count300 +
                    "&count100=" + RankableScore.count100 +
                    "&count50=" + RankableScore.count50 +
                    "&countMiss=" + RankableScore.countMiss +
                    "&maxCombo=" + RankableScore.maxCombo +
                    "&spinnerBonus=" + RankableScore.spinnerBonusScore +
                    "&comboBonus=" + RankableScore.comboBonusScore +
                    "&accuracyBonus=" + RankableScore.accuracyBonusScore +
                    "&hitScore=" + RankableScore.hitScore +
                    "&rank=" + RankableScore.Ranking +
                    "&filename=" + NetRequest.UrlEncode(Path.GetFileName(Player.Beatmap.ContainerFilename)) +
                    "&cc=" + GameBase.Config.GetValue <string>("hash", string.Empty) +
                    "&c=" + check +
                    "&difficulty=" + (int)Player.Difficulty +
                    "&username="******"username", string.Empty) +
                    "&twitterid=" + GameBase.Config.GetValue <string>("twitterId", string.Empty) +
                    "&dt=" + deviceType +
                    "&offset=" + avg;

                spriteSubmitting = new pSprite(TextureManager.Load(OsuTexture.songselect_audio_preview), FieldTypes.StandardSnapRight, OriginTypes.Centre, ClockTypes.Game, new Vector2(20, 20), 0.999f, true, Color4.White)
                {
                    ExactCoordinates = false,
                    DimImmune        = true,
                    ScaleScalar      = 0.7f
                };

                spriteSubmitting.Transform(new TransformationF(TransformationType.Rotation, 0, MathHelper.Pi * 2, Clock.Time, Clock.Time + 1500)
                {
                    Looping = true
                });
                GameBase.MainSpriteManager.Add(spriteSubmitting);
                spriteSubmitting.FadeInFromZero(300);

                StringNetRequest nr = new StringNetRequest("https://www.osustream.com/score/submit.php", "POST", postString);
                nr.onFinish += delegate(string result, Exception e)
                {
                    spriteSubmitting.AlwaysDraw = false;
                    if (e == null)
                    {
                        spriteSubmitting.FadeOut(200);
                        spriteSubmitting.ScaleTo(3, 200);
                        spriteSubmitting.Colour = Color4.YellowGreen;
                    }
                    else
                    {
                        spriteSubmitting.FadeOut(1000);
                        spriteSubmitting.ScaleTo(1.2f, 200, EasingTypes.In);
                        spriteSubmitting.Colour = Color4.Red;
                    }

                    if (e == null && result != null && result.StartsWith("message:"))
                    {
                        rankingNotification = new Notification("Ranking", result.Replace("message:", string.Empty), NotificationStyle.Okay);
                        if (finishedDisplaying)
                        {
                            GameBase.Notify(rankingNotification);
                        }
                    }
                };
                NetManager.AddRequest(nr);
            }
#endif
        }
Exemple #16
0
        public override void Update()
        {
            base.Update();

            progressBar.SetProgress((float)(elapsedTime / test_time_cooldown));

            if (!running)
            {
                return;
            }

            elapsedTime += GameBase.ElapsedMilliseconds;

            if (elapsedTime > test_time_cooldown)
            {
                startNextStage();
                return;
            }
            else if (elapsedTime > test_time)
            {
                if (!cooldown)
                {
                    benchmarkSpriteManager.SpriteList.ForEach(s => s.FadeOut(300));
                    cooldown = true;
                }

                GC.Collect();
            }

            if (stageScores.ContainsKey(activeStage))
            {
                stageScores[activeStage]++;
            }

            if (cooldown)
            {
                return;
            }

            switch (activeStage)
            {
            case Stages.TextRendering:
                const int text_lines = 4;

                if (benchmarkSpriteManager.SpriteList.Count == 0)
                {
                    for (int i = 0; i < text_lines; i++)
                    {
                        benchmarkSpriteManager.Add(new pText("Testing text rendering", 20, new Vector2(RNG.Next(0, GameBase.WindowManager.Width), RNG.Next(0, GameBase.WindowManager.Height)), new Vector2(400, 0), 1, true, Color.White, true)
                        {
                            TextAlignment = TextAlignment.Centre,
                            Origin        = Origins.Centre,
                        });
                    }
                }

                for (int i = 0; i < text_lines; i++)
                {
                    ((pText)benchmarkSpriteManager.SpriteList[i]).Text = RNG.NextDouble().ToString();
                }
                break;

            case Stages.CPUPerformance:
            case Stages.GarbageCollection:
                Color col = Color.MediumPurple;
                if (activeStage == Stages.CPUPerformance)
                {
                    benchmarkSpriteManager.Clear();
                    col = Color.GreenYellow;
                }
                else
                {
                    benchmarkSpriteManager.SpriteList.Clear();
                }

                for (int i = 0; i < 1000; i++)
                {
                    benchmarkSpriteManager.Add(new pSprite(GameBase.WhitePixel, Fields.Native, Origins.TopLeft, Clocks.Game, new Vector2(RNG.Next(0, GameBase.WindowManager.Width), RNG.Next(0, GameBase.WindowManager.Height)), 0, true, col)
                    {
                        Alpha = 1, Additive = true
                    });
                }
                break;

            case Stages.TextureLoading:
            {
                TextureManager.ClearDefaultCache();
                pSprite p = new pSprite(TextureManager.Load(@"sliderb" + RNG.Next(0, 10), SkinSource.Osu), Fields.TopLeft, Origins.TopLeft, Clocks.Game, new Vector2(RNG.Next(0, GameBase.WindowManager.Width), RNG.Next(0, GameBase.WindowManager.Height)), 0, false, Color.White)
                {
                    Additive = true,
                };
                p.FadeOutFromOne(500);

                benchmarkSpriteManager.Add(p);

                benchmarkSpriteManager.SpriteList.ForEach(s => ((pSprite)s).Texture = TextureManager.Load(@"sliderb" + RNG.Next(0, 10), SkinSource.Osu));
            }
            break;

            case Stages.Threading:
                if (benchmarkSpriteManager.SpriteList.Count == 0)
                {
                    pSprite p = new pSprite(GameBase.WhitePixel, Fields.Native, Origins.TopLeft, Clocks.Game, Vector2.Zero, 0, true, Color.Orange)
                    {
                        Additive    = true,
                        VectorScale = new Vector2(GameBase.WindowManager.Width, GameBase.WindowManager.Height)
                    };
                    p.FadeInFromZero(test_time);
                    benchmarkSpriteManager.Add(p);

                    for (int i = 0; i < 2; i++)
                    {
                        GameBase.RunBackgroundThread(delegate { while (elapsedTime < test_time)
                                                                {
                                                                    Thread.SpinWait(1);
                                                                }
                                                     });
                    }
                }
                break;

            case Stages.FillRate:
                if (benchmarkSpriteManager.SpriteList.Count == 0)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        pSprite p = new pSprite(GameBase.WhitePixel, Fields.Native, Origins.TopLeft, Clocks.Game, Vector2.Zero, 0, true,
                                                new Color((byte)RNG.Next(0, 255), (byte)RNG.Next(0, 255), (byte)RNG.Next(0, 255), 255))
                        {
                            Additive    = true,
                            VectorScale = new Vector2(GameBase.WindowManager.Width, GameBase.WindowManager.Height)
                        };

                        p.FadeInFromZero(RNG.Next(10000, 30000));
                        benchmarkSpriteManager.Add(p);
                    }
                }
                break;

            case Stages.TexturedFillRate:
                if (benchmarkSpriteManager.SpriteList.Count == 0)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        pSprite p = new pSprite(TextureManager.Load(@"menu-background", SkinSource.Osu), Fields.Native, Origins.TopLeft, Clocks.Game, Vector2.Zero, 0, true, Color.White);

                        if (GameBase.WindowManager.Width / GameBase.WindowManager.Height > 1.6f)
                        {
                            p.VectorScale = new Vector2(GameBase.WindowManager.Width / GameBase.WindowManager.Ratio / WindowManager.DEFAULT_WIDTH, GameBase.WindowManager.Height / GameBase.WindowManager.Ratio / WindowManager.DEFAULT_HEIGHT);
                        }

                        p.Additive = true;

                        p.FadeInFromZero(20000);
                        benchmarkSpriteManager.Add(p);
                    }
                }
                break;
            }
        }