Esempio n. 1
0
        /// <summary>
        ///     使用json填充一个OnlineBestRecord对象,并指定模式
        /// </summary>
        /// <param name="json"></param>
        /// <param name="mode"></param>
        public OnlineBestRecord(string json, OsuGameMode mode)
        {
            Mode = mode;
            var jobj = (JObject)JsonConvert.DeserializeObject(json);

            int.TryParse(jobj["countgeki"].ToString(), out _countgeki);
            int.TryParse(jobj["countkatu"].ToString(), out _countkatu);
            int.TryParse(jobj["count300"].ToString(), out _count300);
            int.TryParse(jobj["count100"].ToString(), out _count100);
            int.TryParse(jobj["count50"].ToString(), out _count50);
            int.TryParse(jobj["countmiss"].ToString(), out _countmiss);
            int.TryParse(jobj["maxcombo"].ToString(), out _maxcombo);
            int.TryParse(jobj["score"].ToString(), out _score);
            int.TryParse(jobj["user_id"].ToString(), out _userId);
            int.TryParse(jobj["perfect"].ToString(), out _perfect);
            int.TryParse(jobj["enabled_mods"].ToString(), out _mods);
            int.TryParse(jobj["beatmap_id"].ToString(), out _beatmapId);
            int.TryParse(jobj["score_id"].ToString(), out _scoreId);
            double.TryParse(jobj["pp"].ToString(), out _pp);
            _date    = jobj["date"].ToString();
            Rank     = jobj["rank"].ToString();
            Mods     = new OsuGameModConverter().Convert(_mods, out _);
            Accuracy = AccCalc(mode);
            DateTime.TryParse(_date, out _d);
            if (_perfect == 1)
            {
                Perfect = true;
            }
            else if (_perfect == 0)
            {
                Perfect = false;
            }
        }
Esempio n. 2
0
 /// <summary>
 ///     使用特定的数据来构造一个ScoreDBData对象
 /// </summary>
 /// <param name="mode">游戏模式</param>
 /// <param name="ver">游戏版本</param>
 /// <param name="bmd5">谱面的MD5</param>
 /// <param name="name">玩家名</param>
 /// <param name="rmd5">回放的MD5</param>
 /// <param name="count300">300的数量</param>
 /// <param name="count100">100的数量</param>
 /// <param name="count50">50的数量</param>
 /// <param name="countGeki">激或彩300的数量</param>
 /// <param name="count200">喝或200的数量</param>
 /// <param name="cmiss">Miss的数量</param>
 /// <param name="score">分数</param>
 /// <param name="maxcombo">最大连击</param>
 /// <param name="per">是否为Perfect</param>
 /// <param name="mods">使用了的Mod的整数形式</param>
 /// <param name="empty">一个必须为空的字符串</param>
 /// <param name="playtime">游玩的时间,以Tick为单位</param>
 /// <param name="verify">一个值必须为-1的整数</param>
 /// <param name="scoreId">ScoreId</param>
 public OsuScoreInfo(OsuGameMode mode, int ver, string bmd5, string name, string rmd5, short count300, short count100,
                     short count50, short countGeki, short count200, short cmiss, int score, short maxcombo, bool per, int mods,
                     string empty, long playtime, int verify, long scoreId)
 {
     Mode = mode;
     //System.Windows.Forms.MessageBox.Show(Mode.ToString());
     GameVersion = ver;
     BeatmapMd5  = bmd5;
     ReplayMd5   = rmd5;
     PlayerName  = name;
     CountGeki   = countGeki;
     Count300    = count300;
     Count200    = count200;
     Count100    = count100;
     Count50     = count50;
     CountMiss   = cmiss;
     Score       = score;
     MaxCombo    = maxcombo;
     Perfect     = per;
     IternalMods = new OsuGameModConverter().Convert(mods, out _);
     PlayTime    = new DateTime(playtime);
     if (verify != -1 || !string.IsNullOrEmpty(empty))
     {
         throw new FailToParseException("验证失败");
     }
     ScoreId = scoreId;
     Debug.Assert(count300 + count100 + count50 + CountMiss != 0);
     Accuracy = AccCalc(mode);
 }
Esempio n. 3
0
        /// <summary>
        ///     使用json字符串和游戏模式初始化一个RecentOnlineResult
        /// </summary>
        /// <param name="json"></param>
        /// <param name="mode"></param>
        public RecentOnlineResult(string json, OsuGameMode mode)
        {
            Mode = mode;
            var jobj = (JObject)JsonConvert.DeserializeObject(json);

            int.TryParse(jobj["countgeki"].ToString(), out _countgeki);
            int.TryParse(jobj["countkatu"].ToString(), out _countkatu);
            int.TryParse(jobj["count300"].ToString(), out _count300);
            int.TryParse(jobj["count100"].ToString(), out _count100);
            int.TryParse(jobj["count50"].ToString(), out _count50);
            int.TryParse(jobj["countmiss"].ToString(), out _countmiss);
            int.TryParse(jobj["maxcombo"].ToString(), out _maxcombo);
            int.TryParse(jobj["score"].ToString(), out _score);
            int.TryParse(jobj["user_id"].ToString(), out _userId);
            int.TryParse(jobj["perfect"].ToString(), out _perfect);
            int.TryParse(jobj["enabled_mods"].ToString(), out _mod);
            Mods = ModList.FromInteger(_mod);
            int.TryParse(jobj["beatmap_id"].ToString(), out _beatmapId);
            _date = jobj["date"].ToString();
            Rank  = jobj["rank"].ToString();
            DateTime.TryParse(_date, out _d);
            var e = TimeZone.CurrentTimeZone.ToLocalTime(_d);

            _d = e;
            if (_perfect == 1)
            {
                Perfect = true;
            }
            else if (_perfect == 0)
            {
                Perfect = false;
            }
            Accuracy = AccCalc(Mode);
        }
Esempio n. 4
0
 private double AccCalc(OsuGameMode mode)
 {
     return(GameMode.FromLegacyMode(mode).AccuracyCalc(new ScoreInfo
     {
         CountGeki = CountGeki, Count300 = Count300, CountKatu = CountKatu, Count100 = Count100, Count50 = Count50, CountMiss = CountMiss
     }));
 }
Esempio n. 5
0
        /// <summary>
        ///     使用游戏模式来搜索谱面,可指定包括或不包括
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="option"></param>
        /// <returns></returns>
        public OsuBeatmapCollection Find(OsuGameMode mode,
                                         BeatmapCollection.BeatmapFindOption option = BeatmapCollection.BeatmapFindOption.Contains)
        {
            var bc = new OsuBeatmapCollection();

            foreach (var b in _beatmaps)
            {
                if (option == BeatmapCollection.BeatmapFindOption.Contains)
                {
                    if (b.Mode == mode)
                    {
                        if (!bc.Contains(b))
                        {
                            bc.Add(b);
                        }
                    }
                }
                if (option == BeatmapCollection.BeatmapFindOption.NotContains)
                {
                    if (b.Mode != mode)
                    {
                        if (!bc.Contains(b))
                        {
                            bc.Add(b);
                        }
                    }
                }
            }

            return(bc);
        }
Esempio n. 6
0
 /// <summary>
 ///     将<see cref="ILegacyMode" />转换成GameMode
 /// </summary>
 /// <param name="legacyMode"></param>
 /// <returns></returns>
 public static GameMode FromLegacyMode(OsuGameMode legacyMode)
 {
     if (LegacyModes.ContainsKey(legacyMode))
     {
         return(LegacyModes[legacyMode]);
     }
     return(new UnknownMode());
 }
Esempio n. 7
0
 /// <summary>
 ///     获取指定Mod在指定模式下对应的星星数
 /// </summary>
 /// <param name="mode"></param>
 /// <param name="modCombine"></param>
 /// <returns></returns>
 public double GetStars(OsuGameMode mode, int modCombine)
 {
     try
     {
         return(Difficuties[mode][modCombine]);
     }
     catch
     {
         return(0);
     }
 }
Esempio n. 8
0
 /// <summary>
 ///     设置指定Mod在指定模式下对应的星星数
 /// </summary>
 /// <param name="mode"></param>
 /// <param name="modCombine"></param>
 /// <param name="stars" />
 /// <returns></returns>
 public void SetStar(OsuGameMode mode, int modCombine, double stars)
 {
     try
     {
         Difficuties[mode][modCombine] = stars;
     }
     catch
     {
         // ignored
     }
 }
Esempio n. 9
0
        public OsuBeatmap(RelativeFileInfo AudioFileName = default, int AudioLeadIn = 0, Hash AudioHash = default, int PreviewTime = -1, OsuCountdown Countdown = OsuCountdown.Normal, OsuSampleSet SampleSet = OsuSampleSet.Normal, decimal StackLeniency = 0.7M, OsuGameMode Mode = OsuGameMode.Osu, bool LetterboxInBreaks = false, bool StoryFireInFront = true, bool UseSkinSprites = true, bool AlwaysShowPlayfield = false, OsuDrawPosition OverlayPosition = OsuDrawPosition.NoChange, string SkinPreference = "", bool EpilepsyWarning = false, int CountdownOffset = 0, bool SpecialStyle = false, bool WidescreenStoryboard = false, bool SamplesMatchPlaybackRate = false, int[] Bookmarks = default, decimal DistanceSpacing = 0M, decimal BeatDivisor = 0M, int GridSize = 0, decimal TimelineZoom = 0M, string Title = "", string TitleUnicode = "", string Artist = "", string ArtistUnicode = "", string Creator = "", string Version = "", string Source = "", string[] Tags = default, int BeatmapID = 0, int BeatmapSetID = 0, decimal HPDrainRate = 5M, decimal CircleSize = 5M, decimal OverallDifficulty = 5M, decimal ApproachRate = 5M, decimal SliderMultiplier = 1M, decimal SliderTickRate = 1M, OsuEvent[] Events = default, OsuTimingPoint[] TimingPoints = default, OsuHitObject[] HitObjects = default)
        {
            this.AudioFileName = AudioFileName /* ?? throw new ArgumentNullException(nameof(AudioFileName))*/;
            this.AudioLeadIn   = AudioLeadIn;
#pragma warning disable CS0612 // Type or member is obsolete
            this.AudioHash = AudioHash /* ?? throw new ArgumentNullException(nameof(AudioHash))*/;
#pragma warning restore CS0612 // Type or member is obsolete
            this.PreviewTime       = PreviewTime;
            this.Countdown         = Countdown;
            this.SampleSet         = SampleSet;
            this.StackLeniency     = StackLeniency;
            this.Mode              = Mode;
            this.LetterboxInBreaks = LetterboxInBreaks;
#pragma warning disable CS0612 // Type or member is obsolete
            this.StoryFireInFront = StoryFireInFront;
#pragma warning restore CS0612 // Type or member is obsolete
            this.UseSkinSprites = UseSkinSprites;
#pragma warning disable CS0612 // Type or member is obsolete
            this.AlwaysShowPlayfield = AlwaysShowPlayfield;
#pragma warning restore CS0612 // Type or member is obsolete
            this.OverlayPosition          = OverlayPosition;
            this.SkinPreference           = SkinPreference /* ?? throw new ArgumentNullException(nameof(SkinPreference))*/;
            this.EpilepsyWarning          = EpilepsyWarning;
            this.CountdownOffset          = CountdownOffset;
            this.SpecialStyle             = SpecialStyle;
            this.WidescreenStoryboard     = WidescreenStoryboard;
            this.SamplesMatchPlaybackRate = SamplesMatchPlaybackRate;
            this.Bookmarks         = Bookmarks /* ?? throw new ArgumentNullException(nameof(Bookmarks))*/;
            this.DistanceSpacing   = DistanceSpacing;
            this.BeatDivisor       = BeatDivisor;
            this.GridSize          = GridSize;
            this.TimelineZoom      = TimelineZoom;
            this.Title             = Title /* ?? throw new ArgumentNullException(nameof(Title))*/;
            this.TitleUnicode      = TitleUnicode /* ?? throw new ArgumentNullException(nameof(TitleUnicode))*/;
            this.Artist            = Artist /* ?? throw new ArgumentNullException(nameof(Artist))*/;
            this.ArtistUnicode     = ArtistUnicode /* ?? throw new ArgumentNullException(nameof(ArtistUnicode))*/;
            this.Creator           = Creator /* ?? throw new ArgumentNullException(nameof(Creator))*/;
            this.Version           = Version /* ?? throw new ArgumentNullException(nameof(Version))*/;
            this.Source            = Source /* ?? throw new ArgumentNullException(nameof(Source))*/;
            this.Tags              = Tags /* ?? throw new ArgumentNullException(nameof(Tags))*/;
            this.BeatmapID         = BeatmapID;
            this.BeatmapSetID      = BeatmapSetID;
            this.HPDrainRate       = HPDrainRate;
            this.CircleSize        = CircleSize;
            this.OverallDifficulty = OverallDifficulty;
            this.ApproachRate      = ApproachRate;
            this.SliderMultiplier  = SliderMultiplier;
            this.SliderTickRate    = SliderTickRate;
            this.Events            = Events /* ?? throw new ArgumentNullException(nameof(Events))*/;
            this.TimingPoints      = TimingPoints /* ?? throw new ArgumentNullException(nameof(TimingPoints))*/;
            this.HitObjects        = HitObjects /* ?? throw new ArgumentNullException(nameof(HitObjects))*/;
        }
Esempio n. 10
0
        /// <summary>
        ///     使用游戏模式匹配录像
        /// </summary>
        /// <param name="mode"></param>
        /// <returns></returns>
        public ReplayCollection Find(OsuGameMode mode)
        {
            var r = new ReplayCollection();

            foreach (var replay in _rdata)
            {
                if (replay.Mode == mode)
                {
                    r._rdata.Add(replay);
                }
            }
            return(r);
        }
Esempio n. 11
0
 /// <summary>
 ///     使用游戏模式获取难度字典
 /// </summary>
 /// <param name="mode"></param>
 /// <returns></returns>
 public Dictionary <int, double> this[OsuGameMode mode]
 {
     get
     {
         try
         {
             return(Difficuties[mode]);
         }
         catch
         {
             return(new Dictionary <int, double> {
                 { 0, 0 }
             });
         }
     }
 }
Esempio n. 12
0
        private double AccCalc(OsuGameMode mode)
        {
            switch (mode)
            {
            case OsuGameMode.Osu:
                return((Count300 + Count100 * (1.0 / 3.0) + Count50 * (1.0 / 6)) / (Count300 + Count100 + Count50 + CountMiss));

            case OsuGameMode.Taiko: return((Count300 + Count100 * 0.5) / (Count300 + Count100 + CountMiss));

            case OsuGameMode.Catch: return((double)(Count300 + Count100 + Count50) / (Count300 + Count100 + Count50 + Count200 + CountMiss));

            case OsuGameMode.Mania:
                return((CountGeki + Count300 + Count200 * (2 / 3.0) + Count100 * (1 / 3.0) + Count50 * 1 / 6.0) /
                       (CountGeki + Count300 + Count200 + Count100 + Count50 + CountMiss));

            default: return(-1);
            }
        }
Esempio n. 13
0
        private double AccCalc(OsuGameMode mode)
        {
            double c3G = CountGeki, c3 = Count300, c2 = CountKatu, c1 = Count100, c5 = Count50, cm = CountMiss;
            double a2 = 2.0 / 3, a1 = 1.0 / 3, a5 = 1.0 / 6;
            var    mall = c3 + c3G + c2 + c1 + c5 + cm;
            var    sall = c3 + c1 + c5 + cm;
            var    call = c3 + c1 + c2 + c5 + cm;
            var    tall = c3 + c3G + c1 + c2 + cm;

            switch (mode)
            {
            case OsuGameMode.Catch: return((c3 + c1 + c5) / call);

            case OsuGameMode.Osu: return((c3 + c1 * a1 + c5 * a5) / sall);

            case OsuGameMode.Taiko: return((c3 + c3G + (c1 + c2) * a1) / tall);

            case OsuGameMode.Mania: return((c3 + c3G + c2 * a2 + c1 * a1 + c5 * a5) / mall);

            default: return(0);
            }
        }
Esempio n. 14
0
        /// <summary>
        ///     使用一个Json和游戏模式填充一个OnlineUser对象
        /// </summary>
        /// <param name="jarr">json</param>
        /// <param name="mode"></param>
        public OnlineUser(JArray jarr, OsuGameMode mode)
        {
            if (jarr.Count == 0)
            {
                Failed = true;
                return;
            }

            try
            {
                _mode = mode;
                var jobj = jarr[0];
                int.TryParse(jobj["user_id"].ToString(), out _userId);
                int.TryParse(jobj["playcount"].ToString(), out _playcount);
                int.TryParse(jobj["pp_rank"].ToString(), out _ppRank);
                int.TryParse(jobj["count_rank_ss"].ToString(), out _countRankSs);
                int.TryParse(jobj["count_rank_ssh"].ToString(), out _countRankSsh);
                int.TryParse(jobj["count_rank_s"].ToString(), out _countRankS);
                int.TryParse(jobj["count_rank_sh"].ToString(), out _countRankSh);
                int.TryParse(jobj["count_rank_a"].ToString(), out _countRankA);
                int.TryParse(jobj["total_seconds_played"].ToString(), out _totalSecondsPlayed);
                int.TryParse(jobj["pp_country_rank"].ToString(), out _ppCountryRank);
                double.TryParse(jobj["ranked_score"].ToString(), out _rankedScore);
                double.TryParse(jobj["total_score"].ToString(), out _totalScore);
                double.TryParse(jobj["pp_raw"].ToString(), out _ppRaw);
                double.TryParse(jobj["level"].ToString(), out _level);
                double.TryParse(jobj["accuracy"].ToString(), out _accuracy);
                UserName  = jobj["username"].ToString();
                _joinDate = jobj["join_date"].ToString();
                Country   = jobj["country"].ToString();
                DateTime.TryParse(_joinDate, out _t);
            }
            catch (NullReferenceException)
            {
                Failed = true;
            }
        }
Esempio n. 15
0
        protected override void Load(BaseGame game)
        {
            if (!Host.IsPrimaryInstance)
            {
                Logger.Log(@"osu! does not support multiple running instances.", LoggingTarget.Runtime, LogLevel.Error);
                Environment.Exit(0);
            }

            base.Load(game);

            if (args?.Length > 0)
            {
                Schedule(delegate { Beatmaps.Import(args); });
            }

            //attach our bindables to the audio subsystem.
            Audio.Volume.Weld(Config.GetBindable <double>(OsuConfig.VolumeUniversal));
            Audio.VolumeSample.Weld(Config.GetBindable <double>(OsuConfig.VolumeEffect));
            Audio.VolumeTrack.Weld(Config.GetBindable <double>(OsuConfig.VolumeMusic));

            PlayMode = Config.GetBindable <PlayMode>(OsuConfig.PlayMode);

            Add(new Drawable[] {
                new VolumeControlReceptor
                {
                    RelativeSizeAxes  = Axes.Both,
                    ActivateRequested = delegate { volume.Show(); }
                },
                mainContent = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                },
                volume = new VolumeControl
                {
                    VolumeGlobal = Audio.Volume,
                    VolumeSample = Audio.VolumeSample,
                    VolumeTrack  = Audio.VolumeTrack
                },
                overlayContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                new GlobalHotkeys //exists because UserInputManager is at a level below us.
                {
                    Handler = globalHotkeyPressed
                }
            });

            (modeStack = new Intro
            {
                Beatmap = Beatmap
            }).Preload(game, d =>
            {
                mainContent.Add(d);

                modeStack.ModePushed += modeAdded;
                modeStack.Exited     += modeRemoved;
                modeStack.DisplayAsRoot();
            });

            //overlay elements
            (chat = new ChatConsole(API)
            {
                Depth = 0
            }).Preload(game, overlayContent.Add);
            (musicController = new MusicController()).Preload(game, overlayContent.Add);
            (Options = new OptionsOverlay {
                Depth = 1
            }).Preload(game, overlayContent.Add);
            (Toolbar = new Toolbar
            {
                Depth = 2,
                OnHome = delegate { mainMenu?.MakeCurrent(); },
                OnSettings = Options.ToggleVisibility,
                OnPlayModeChange = delegate(PlayMode m) { PlayMode.Value = m; },
                OnMusicController = musicController.ToggleVisibility
            }).Preload(game, t =>
            {
                PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
                PlayMode.TriggerChange();
                overlayContent.Add(Toolbar);
            });

            Cursor.Alpha = 0;
        }
Esempio n. 16
0
        public static void GetGeneralFields(List <string> Lines, out RelativeFileInfo AudioFileName, out int AudioLeadIn, out Hash AudioHash, out int PreviewTime, out OsuCountdown Countdown, out OsuSampleSet SampleSet, out decimal StackLeniency, out OsuGameMode Mode, out bool LetterboxInBreaks, out bool StoryFireInFront, out bool UseSkinSprites, out bool AlwaysShowPlayfield, out OsuDrawPosition OverlayPosition, out string SkinPreference, out bool EpilepsyWarning, out int CountdownOffset, out bool SpecialStyle, out bool WidescreenStoryboard, out bool SamplesMatchPlaybackRate)
        {
            AudioFileName     = default;
            AudioLeadIn       = CountdownOffset = 0;
            AudioHash         = default;
            PreviewTime       = -1;
            Countdown         = OsuCountdown.Normal;
            SampleSet         = OsuSampleSet.Normal;
            StackLeniency     = 0.7M;
            Mode              = OsuGameMode.Osu;
            LetterboxInBreaks = AlwaysShowPlayfield = EpilepsyWarning = SpecialStyle = WidescreenStoryboard = SamplesMatchPlaybackRate = false;
            StoryFireInFront  = UseSkinSprites = true;
            OverlayPosition   = OsuDrawPosition.NoChange;
            SkinPreference    = default;

            //Debug.WriteLine("Iterating through General values");
            foreach ((string Key, string Value) in GetValues(Lines, ": "))
            {
                switch (Key)
                {
                case @"audiofilename":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    AudioFileName = Value.ConvertToRelativeFileInfo();
                    break;

                case @"audioleadin":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    AudioLeadIn = Value.ConvertToInt(0);
                    break;

                case @"audiohash":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    //TODO Implement obtaining pre-generated hash stored in string
                    AudioHash = null;
                    break;

                case @"previewtime":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    PreviewTime = Value.ConvertToInt(-1);
                    break;

                case @"countdown":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    Countdown = Value.ConvertToEnum <OsuCountdown>();
                    break;

                case @"sampleset":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    SampleSet = Value.ConvertToEnum <OsuSampleSet>();
                    break;

                case @"stackleniency":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    StackLeniency = Value.ConvertToDecimal(0.7M);
                    break;

                case @"mode":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    Mode = Value.ConvertToEnum <OsuGameMode>();
                    break;

                case @"letterboxinbreaks":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    LetterboxInBreaks = Value.ConvertToBool();
                    break;

                case @"storyfireinfront":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    StoryFireInFront = Value.ConvertToBool();
                    break;

                case @"useskinsprites":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    UseSkinSprites = Value.ConvertToBool();
                    break;

                case @"alwaysshowplayfield":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    AlwaysShowPlayfield = Value.ConvertToBool();
                    break;

                case @"overlayposition":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    OverlayPosition = Value.ConvertToEnum <OsuDrawPosition>();
                    break;

                case @"skinpreference":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    SkinPreference = Value;
                    break;

                case @"epilepsywarning":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    EpilepsyWarning = Value.ConvertToBool();
                    break;

                case @"countdownoffset":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    CountdownOffset = Value.ConvertToInt(0);
                    break;

                case @"specialstyle":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    SpecialStyle = Value.ConvertToBool();
                    break;

                case @"widescreenstoryboard":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    WidescreenStoryboard = Value.ConvertToBool();
                    break;

                case @"samplesmatchplaybackrate":
                    //Debug.WriteLine($"\tFound: {Key} == {Value}");
                    SamplesMatchPlaybackRate = Value.ConvertToBool();
                    break;
                }
            }
        }
Esempio n. 17
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            Add(new Drawable[] {
                new VolumeControlReceptor
                {
                    RelativeSizeAxes = Axes.Both,
                    ActionRequested  = delegate(InputState state) { volume.Adjust(state); }
                },
                mainContent = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                },
                volume         = new VolumeControl(),
                overlayContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                new GlobalHotkeys //exists because UserInputManager is at a level below us.
                {
                    Handler = globalHotkeyPressed
                }
            });

            (modeStack = new Intro()).Preload(this, d =>
            {
                modeStack.ModePushed += modeAdded;
                modeStack.Exited     += modeRemoved;
                mainContent.Add(modeStack);
            });

            //overlay elements
            (chat = new ChatOverlay {
                Depth = 0
            }).Preload(this, overlayContent.Add);
            (options = new OptionsOverlay {
                Depth = -1
            }).Preload(this, overlayContent.Add);
            (musicController = new MusicController()
            {
                Depth = -2,
                Position = new Vector2(0, Toolbar.HEIGHT),
                Anchor = Anchor.TopRight,
                Origin = Anchor.TopRight,
            }).Preload(this, overlayContent.Add);

            (notificationManager = new NotificationManager
            {
                Depth = -2,
                Anchor = Anchor.TopRight,
                Origin = Anchor.TopRight,
            }).Preload(this, overlayContent.Add);

            Logger.NewEntry += entry =>
            {
                if (entry.Level < LogLevel.Important)
                {
                    return;
                }

                notificationManager.Post(new SimpleNotification
                {
                    Text = $@"{entry.Level}: {entry.Message}"
                });
            };

            Dependencies.Cache(options);
            Dependencies.Cache(musicController);
            Dependencies.Cache(notificationManager);

            (Toolbar = new Toolbar
            {
                Depth = -3,
                OnHome = delegate { mainMenu?.MakeCurrent(); },
                OnPlayModeChange = delegate(PlayMode m) { PlayMode.Value = m; },
            }).Preload(this, t =>
            {
                PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
                PlayMode.TriggerChange();
                overlayContent.Add(Toolbar);
            });

            options.StateChanged += delegate
            {
                switch (options.State)
                {
                case Visibility.Hidden:
                    intro.MoveToX(0, OptionsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint);
                    break;

                case Visibility.Visible:
                    intro.MoveToX(OptionsOverlay.SIDEBAR_WIDTH / 2, OptionsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint);
                    break;
                }
            };

            Cursor.Alpha = 0;
        }
Esempio n. 18
0
        /// <summary>
        ///     使用Json填充OnlineScore对象并且指定游戏模式和BeatmapID
        /// </summary>
        /// <param name="json"></param>
        /// <param name="mode"></param>
        /// <param name="beatmapId"></param>
        public OnlineScore(string json, OsuGameMode mode, int beatmapId)
        {
            //try
            {
                BeatmapId = beatmapId;
                Mode      = mode;
                var jobj  = JsonConvert.DeserializeObject(json);
                var cjobj = new JObject();
                if (jobj.GetType() == typeof(JObject))
                {
                    cjobj = (JObject)jobj;
                }
                if (jobj.GetType() == typeof(JArray))
                {
                    cjobj = (JObject)((JArray)jobj)[0];
                }

                int.TryParse(cjobj["countgeki"].ToString(), out _countgeki);
                int.TryParse(cjobj["countkatu"].ToString(), out _countkatu);
                int.TryParse(cjobj["count300"].ToString(), out _count300);
                int.TryParse(cjobj["count100"].ToString(), out _count100);
                int.TryParse(cjobj["count50"].ToString(), out _count50);
                int.TryParse(cjobj["countmiss"].ToString(), out _countmiss);
                int.TryParse(cjobj["maxcombo"].ToString(), out _maxcombo);
                int.TryParse(cjobj["score"].ToString(), out _score);
                int.TryParse(cjobj["user_id"].ToString(), out _userId);
                int.TryParse(cjobj["perfect"].ToString(), out _perfect);
                int.TryParse(cjobj["replay_available"].ToString(), out _replayAvailable);
                uint.TryParse(cjobj["score_id"].ToString(), out _scoreId);
                int.TryParse(cjobj["enabled_mods"].ToString(), out _mod);
                double.TryParse(cjobj["pp"].ToString(), out _pp);
                _date    = cjobj["date"].ToString();
                Rank     = cjobj["rank"].ToString();
                Mods     = ModList.FromInteger(_mod);
                Accuracy = AccCalc(Mode);
                DateTime.TryParse(_date, out _d);
                if (_perfect == 1)
                {
                    Perfect = true;
                }
                else if (_perfect == 0)
                {
                    Perfect = false;
                }
                ReplayAvailable = _replayAvailable == 1;
            }

            /* catch
             *   {
             *       replay_available = 0;
             *       per = false;
             *       d = DateTime.MinValue;
             *       rep = false;
             *       score_id = 0;
             *       score = 0;
             *       pp = 0.0;
             *       maxcombo = 0;
             *       count300 = 0;
             *       count100 = 0;
             *       count50 = 0;
             *       countgeki = 0;
             *       countkatu = 0;
             *       countmiss = 0;
             *       perfect = 0;
             *       user_id = 0;
             *       date = "0-0-0 0:0:0";
             *       rank = "?";
             *   }*/
        }
Esempio n. 19
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            Add(new Drawable[] {
                new VolumeControlReceptor
                {
                    RelativeSizeAxes = Axes.Both,
                    ActionRequested  = delegate(InputState state) { volume.Adjust(state); }
                },
                mainContent = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                },
                volume         = new VolumeControl(),
                overlayContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                new GlobalHotkeys //exists because UserInputManager is at a level below us.
                {
                    Handler = globalHotkeyPressed
                }
            });

            (modeStack = new Intro()).Preload(this, d =>
            {
                mainContent.Add(d);

                modeStack.ModePushed += modeAdded;
                modeStack.Exited     += modeRemoved;
                modeStack.DisplayAsRoot();
            });

            //overlay elements
            (chat = new ChatConsole(API)
            {
                Depth = 0
            }).Preload(this, overlayContent.Add);
            (Options = new OptionsOverlay {
                Depth = 1
            }).Preload(this, overlayContent.Add);
            (musicController = new MusicController()
            {
                Depth = 3
            }).Preload(this, overlayContent.Add);
            (Toolbar = new Toolbar
            {
                Depth = 2,
                OnHome = delegate { mainMenu?.MakeCurrent(); },
                OnSettings = Options.ToggleVisibility,
                OnPlayModeChange = delegate(PlayMode m) { PlayMode.Value = m; },
                OnMusicController = musicController.ToggleVisibility
            }).Preload(this, t =>
            {
                PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
                PlayMode.TriggerChange();
                overlayContent.Add(Toolbar);
            });

            Cursor.Alpha = 0;
        }
Esempio n. 20
0
 /// <summary>
 ///     将模式的难度字典更改为指定字典
 /// </summary>
 /// <param name="mode"></param>
 /// <param name="dict"></param>
 public void SetModeDict(OsuGameMode mode, Dictionary <int, double> dict)
 {
     Difficuties[mode] = dict;
 }
Esempio n. 21
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            Add(new Drawable[] {
                new VolumeControlReceptor
                {
                    RelativeSizeAxes = Axes.Both,
                    ActionRequested  = delegate(InputState state) { volume.Adjust(state); }
                },
                mainContent = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                },
                volume         = new VolumeControl(),
                overlayContent = new Container {
                    RelativeSizeAxes = Axes.Both
                },
                new GlobalHotkeys //exists because UserInputManager is at a level below us.
                {
                    Handler = globalHotkeyPressed
                }
            });

            (modeStack = new Intro()).Preload(this, d =>
            {
                mainContent.Add(d);

                modeStack.ModePushed += modeAdded;
                modeStack.Exited     += modeRemoved;
                modeStack.DisplayAsRoot();
            });

            //overlay elements
            (chat = new ChatOverlay {
                Depth = 0
            }).Preload(this, overlayContent.Add);
            (options = new OptionsOverlay {
                Depth = -1
            }).Preload(this, overlayContent.Add);
            (musicController = new MusicController()
            {
                Depth = -3
            }).Preload(this, overlayContent.Add);

            Dependencies.Cache(options);
            Dependencies.Cache(musicController);

            (Toolbar = new Toolbar
            {
                Depth = -2,
                OnHome = delegate { mainMenu?.MakeCurrent(); },
                OnPlayModeChange = delegate(PlayMode m) { PlayMode.Value = m; },
            }).Preload(this, t =>
            {
                PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); };
                PlayMode.TriggerChange();
                overlayContent.Add(Toolbar);
            });

            options.StateChanged += delegate
            {
                switch (options.State)
                {
                case Visibility.Hidden:
                    intro.MoveToX(0, OptionsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint);
                    break;

                case Visibility.Visible:
                    intro.MoveToX(OptionsOverlay.SIDEBAR_WIDTH / 2, OptionsOverlay.TRANSITION_LENGTH, EasingTypes.OutQuint);
                    break;
                }
            };

            Cursor.Alpha = 0;
        }
Esempio n. 22
0
        public static OsuBeatmap GetBeatmap(string[] Lines, bool ParseGeneralValues = true, bool ParseEditorValues = true, bool ParseMetadataValues = true, bool ParseDifficultyValues = true, bool ParseEvents = true, bool ParseTimingPoints = true, bool ParseHitObjects = true)
        {
            Lines = NormaliseLines(Lines).ToArray();

            List <string> GeneralValues     = new List <string>();
            List <string> EditorValues      = new List <string>();
            List <string> MetadataValues    = new List <string>();
            List <string> DifficultyValues  = new List <string>();
            List <string> EventValues       = new List <string>();
            List <string> TimingPointValues = new List <string>();
            //List<string> ColourValues = new List<string>();
            List <string> HitObjectValues = new List <string>();

            string Section = null;

            // ReSharper disable once LoopCanBePartlyConvertedToQuery
            foreach (string Line in Lines)
            {
                if (Line.TrimStart(' ').StartsWith("//"))
                {
                    continue;
                }                                                       //Ignore comments
                if (TryGetSection(Line, out string NewSection))
                {
                    //Debug.WriteLine($"\tEntered new section {NewSection}...");
                    Section = NewSection;
                }

                switch (Section)
                {
                case "general" when ParseGeneralValues:
                    if (Line.Contains(": "))
                    {
                        //Debug.WriteLine($"\t\tLine '{Line}' is of type 'General'");
                        GeneralValues.Add(Line);
                    }
                    break;

                case "editor" when ParseEditorValues:
                    if (Line.Contains(": "))
                    {
                        //Debug.WriteLine($"\t\tLine '{Line}' is of type 'Editor'");
                        EditorValues.Add(Line);
                    }
                    break;

                case "metadata" when ParseMetadataValues:
                    if (Line.Contains(":"))
                    {
                        //Debug.WriteLine($"\t\tLine '{Line}' is of type 'Metadata'");
                        MetadataValues.Add(Line);
                    }
                    break;

                case "difficulty" when ParseDifficultyValues:
                    if (Line.Contains(':'))
                    {
                        //Debug.WriteLine($"\t\tLine '{Line}' is of type 'Difficulty'");
                        DifficultyValues.Add(Line);
                    }
                    break;

                case "events" when ParseEvents:
                    if (Line.Contains(','))
                    {
                        //Debug.WriteLine($"\t\tLine '{Line}' is of type 'Events'");
                        EventValues.Add(Line);
                    }
                    break;

                case "timingpoints" when ParseTimingPoints:
                    if (Line.Contains(','))
                    {
                        //Debug.WriteLine($"\t\tLine '{Line}' is of type 'TimingPoints'");
                        TimingPointValues.Add(Line);
                    }
                    break;

                //case "colours": //TODO Implement Colours Support
                //    if (Line.Contains(" : ")) {
                //        ColourValues.Add(Line);
                //    }
                //    break;
                case "hitobjects" when ParseHitObjects:
                    if (Line.Contains(','))
                    {
                        //Debug.WriteLine($"\t\tLine '{Line}' is of type 'HitObjects'");
                        HitObjectValues.Add(Line);
                    }
                    break;
                }
            }

            //Debug.WriteLine("\tParsing General Fields...");
            RelativeFileInfo AudioFileName = default;
            int             AudioLeadIn = 0, CountdownOffset = 0, PreviewTime = -1;
            Hash            AudioHash = default;
            OsuCountdown    Countdown = OsuCountdown.Normal;
            OsuSampleSet    SampleSet = OsuSampleSet.Normal;
            decimal         StackLeniency = 0.7M;
            OsuGameMode     Mode = OsuGameMode.Osu;
            bool            LetterboxInBreaks = false, AlwaysShowPlayfield = false, EpilepsyWarning = false, SpecialStyle = false, WidescreenStoryboard = false, SamplesMatchPlaybackRate = false;
            bool            StoryFireInFront = true, UseSkinSprites = true;
            OsuDrawPosition OverlayPosition = OsuDrawPosition.NoChange;
            string          SkinPreference  = default;

            if (ParseGeneralValues)
            {
                GetGeneralFields(GeneralValues, out AudioFileName, out AudioLeadIn, out AudioHash, out PreviewTime, out Countdown, out SampleSet, out StackLeniency, out Mode, out LetterboxInBreaks, out StoryFireInFront, out UseSkinSprites, out AlwaysShowPlayfield, out OverlayPosition, out SkinPreference, out EpilepsyWarning, out CountdownOffset, out SpecialStyle, out WidescreenStoryboard, out SamplesMatchPlaybackRate);
            }


            //Debug.WriteLine("\tParsing Editor Fields...");
            int[]   Bookmarks = Array.Empty <int>();
            decimal DistanceSpacing = 0M, BeatDivisor = 0M, TimelineZoom = 0M;
            int     GridSize = 0;

            if (ParseEditorValues)
            {
                GetEditorFields(EditorValues, out Bookmarks, out DistanceSpacing, out BeatDivisor, out GridSize, out TimelineZoom);
            }


            //Debug.WriteLine("\tParsing Metadata Fields...");
            string Title = string.Empty, TitleUnicode = string.Empty, Artist = string.Empty, ArtistUnicode = string.Empty, Creator = string.Empty, Version = string.Empty, Source = string.Empty;

            string[] Tags = Array.Empty <string>();
            int      BeatmapID = 0, BeatmapSetID = 0;

            if (ParseMetadataValues)
            {
                GetMetadataFields(MetadataValues, out Title, out TitleUnicode, out Artist, out ArtistUnicode, out Creator, out Version, out Source, out Tags, out BeatmapID, out BeatmapSetID);
            }

            //Debug.WriteLine("\tParsing Difficulty Fields...");
            decimal HPDrainRate = 5M, CircleSize = 5M, OverallDifficulty = 5M, ApproachRate = 5M, SliderMultiplier = 5M, SliderTickRate = 5M;

            if (ParseDifficultyValues)
            {
                GetDifficultyFields(DifficultyValues, out HPDrainRate, out CircleSize, out OverallDifficulty, out ApproachRate, out SliderMultiplier, out SliderTickRate);
            }

            //Debug.WriteLine("\tParsing Event Fields...");
            OsuEvent[] Events = Array.Empty <OsuEvent>();

            if (ParseEvents)
            {
                GetEventsField(EventValues, out Events);
            }

            //Debug.WriteLine("\tParsing TimingPoint Fields...");
            OsuTimingPoint[] TimingPoints = Array.Empty <OsuTimingPoint>();

            if (ParseTimingPoints)
            {
                GetTimingPointField(TimingPointValues, out TimingPoints);
            }

            //Debug.WriteLine("\tParsing HitObject Fields...");
            OsuHitObject[] HitObjects = Array.Empty <OsuHitObject>();

            if (ParseHitObjects)
            {
                GetHitObjectsField(HitObjectValues, out HitObjects);
            }

            return(new OsuBeatmap(AudioFileName, AudioLeadIn, AudioHash, PreviewTime, Countdown, SampleSet, StackLeniency, Mode, LetterboxInBreaks, StoryFireInFront, UseSkinSprites, AlwaysShowPlayfield, OverlayPosition, SkinPreference, EpilepsyWarning, CountdownOffset, SpecialStyle, WidescreenStoryboard, SamplesMatchPlaybackRate, Bookmarks, DistanceSpacing, BeatDivisor, GridSize, TimelineZoom, Title,
                                  TitleUnicode, Artist, ArtistUnicode, Creator, Version, Source, Tags, BeatmapID, BeatmapSetID, HPDrainRate, CircleSize, OverallDifficulty, ApproachRate, SliderMultiplier, SliderTickRate, Events, TimingPoints, HitObjects));
        }
Esempio n. 23
0
 internal void Add(OsuGameMode mode, int modCombine, double stars)
 {
     Difficuties[mode].Add(modCombine, stars);
 }