コード例 #1
0
ファイル: Director.cs プロジェクト: indefined/osu-stream
        /// <summary>
        /// Changes the active game mode to a new requested mode, with a possible transition.
        /// </summary>
        /// <param name="mode">The new mode.</param>
        /// <param name="transition">The transition (null for instant switching).</param>
        /// <param name="retainState">Whether we want to save some kind of state.</param>
        /// <returns></returns>
        public static bool ChangeMode(OsuMode mode, Transition transition, bool retainState = false)
        {
            if (mode == OsuMode.Unknown || mode == PendingOsuMode)
            {
                return(false);
            }

            if (retainState)
            {
                //store a reference to the current mode to show that we want to keep state.
                savedStates[CurrentOsuMode] = CurrentMode;
            }
            else
            {
                savedStates.Remove(CurrentOsuMode);
            }

            if (transition == null)
            {
                changeMode(mode);

                //force a transition-end in this case.
                TriggerOnTransitionEnded();

                return(true);
            }

            PendingOsuMode   = mode;
            ActiveTransition = transition;

            return(true);
        }
コード例 #2
0
ファイル: OsuModuleEmbeds.cs プロジェクト: CakeAndBanana/Cake
 public static CakeEmbedBuilder ReturnUserRecent(OsuJsonUser user, OsuJsonBeatmap beatmap, OsuJsonUserRecent recent, string description, int mode, int retryCount)
 {
     return(ReturnUserRecentBase(user)
            .WithUrl(beatmap.beatmap_url)
            .WithThumbnailUrl(beatmap.thumbnail)
            .WithTimestamp(recent.date)
            .WithTitle($"{beatmap.complete_title} {Math.Round(recent.starrating, 2)}★")
            .WithFooter($"{OsuMode.GetOfficialName(mode)} ⌑ {GetNameofApproved(beatmap.approved)} ⌑ #{retryCount} try")
            .WithDescription(description)
            as CakeEmbedBuilder);
 }
コード例 #3
0
        public GameBase(OsuMode mode = OsuMode.Unknown)
        {
            startupMode = mode;
            Instance    = this;

            CrashHandler.Initialize();

            //initialise config before everything, because it may be used in Initialize() override.
            Config = new pConfigManager(Instance.PathConfig + "osum.cfg");

            Clock.USER_OFFSET = Config.GetValue("offset", 0);
        }
コード例 #4
0
        ///Finds and returns an OsuUser object containing all information
        public static OsuUser GetUser(string username, OsuMode mode = OsuMode.Standard)
        {
            List <OsuUser> users =
                APIHelper <List <OsuUser> > .GetData(
                    apiUrl + "get_user?k=" + OsuApiKey.Key + "&u=" + username + "&m=" + (int)mode);

            if (users != null && users.Count > 0)
            {
                //users[0].SetUserpage();
                return(users[0]);
            }

            return(null);
        }
コード例 #5
0
        ///Returns a Beatmap object containing information on the map
        public static OsuBeatmap GetBeatmap(string id, OsuMods mods = OsuMods.None, OsuMode mode = OsuMode.Standard)
        {
            string url = apiUrl + "get_beatmaps?k=" + OsuApiKey.Key + "&b=" + id + "&m=" + (int)mode + "&a=1&mods=" +
                         (int)mods.ModParser(true);
            List <OsuBeatmap> maps = APIHelper <List <OsuBeatmap> > .GetData(url, true);

            if (maps != null && maps.Count > 0)
            {
                maps[0].Mode     = mode;
                maps[0].Mods     = mods;
                maps[0].MapStats = new MapStats(maps[0], mods);
            }

            return((maps != null && maps.Count > 0) ? maps[0] : null);
        }
コード例 #6
0
ファイル: OsuModuleEmbeds.cs プロジェクト: CakeAndBanana/Cake
 public static CakeEmbedBuilder ReturnChannelCompare(OsuJsonUser user, OsuJsonBeatmap beatmap, string description, int mode)
 {
     return(new CakeEmbedBuilder()
            .WithAuthor(author =>
     {
         author
         .WithName($"Compare score(s) of {user.username}")
         .WithUrl(user.url)
         .WithIconUrl(user.image);
     })
            .WithThumbnailUrl(beatmap.thumbnail)
            .WithTitle(beatmap.complete_title)
            .WithUrl(beatmap.beatmap_url)
            .WithDescription(description)
            .WithFooter($"{OsuMode.GetOfficialName(mode)} ⌑ {GetNameofApproved(beatmap.approved)}") as CakeEmbedBuilder);
 }
コード例 #7
0
ファイル: OsuApi.cs プロジェクト: EngineerMark/nayuta-bot
        public static List <OsuPlay> GetUserRecent(string username, OsuMode mode = OsuMode.Standard, int limit = 1,
                                                   bool generateBeatmaps         = false)
        {
            List <OsuPlay> plays = APIHelper <List <OsuPlay> > .GetData(apiUrl + "get_user_recent?k=" + APIKeys.OsuAPIKey + "&u=" +
                                                                        username + "&m=" + (int)mode + "&limit=" + limit);

            plays.ForEach(play =>
            {
                play.Mode = mode;
                if (generateBeatmaps)
                {
                    play.Beatmap = GetBeatmap(play.MapID, play.Mods, mode);
                }
            });
            return(plays.Count > 0 ? plays : null);
        }
コード例 #8
0
ファイル: OsuModule.cs プロジェクト: CakeAndBanana/Cake
 public async Task SetMode(string mode)
 {
     try
     {
         var modeNumber = (int)OsuMode.GetOsuMode(mode);
         await _service.SetMode(modeNumber);
     }
     catch (CakeException e)
     {
         await Context.Channel.SendMessageAsync(e.Message);
     }
     catch (Exception e)
     {
         _logger.LogException(e);
     }
 }
コード例 #9
0
        ///Returns a list of the user's top plays
        public static List <OsuPlay> GetUserBest(string username, OsuMode mode = OsuMode.Standard, int limit = 5,
                                                 bool generateBeatmaps         = false)
        {
            List <OsuPlay> plays = APIHelper <List <OsuPlay> > .GetData(apiUrl + "get_user_best?k=" + OsuApiKey.Key + "&u=" +
                                                                        username + "&m=" + (int)mode + "&limit=" + limit);

            if (plays != null && plays.Count > 0)
            {
                plays.ForEach(play =>
                {
                    play.Mode = mode;
                    if (generateBeatmaps)
                    {
                        play.Beatmap = GetBeatmap(play.MapID, play.Mods, mode);
                    }
                });
            }
            return((plays != null && plays.Count > 0) ? plays : null);
        }
コード例 #10
0
        ///Calculate accuracy based on given values and gamemode
        public static double CalculateAccuracy(OsuMode mode, double cMiss, double c50, double c100, double c300,
                                               double cKatu = 0f, double cGeki = 0f)
        {
            switch (mode)
            {
            case OsuMode.Standard:
                return((c50 * 50 + c100 * 100f + c300 * 300f) / ((c50 + c100 + c300 + cMiss) * 300) * 100);

            case OsuMode.Mania:
                return(((c50 * 50 + c100 * 100 + cKatu * 200 + c300 * 300 + cGeki * 300) /
                        ((cMiss + c50 + c100 + cKatu + c300 + cGeki) * 300)) * 100);

            case OsuMode.Catch:
                return(((c50 + c100 + c300) / (cMiss + c50 + c100 + c300 + cKatu)) * 100);

            case OsuMode.Taiko:
                return((((c100 * 0.5 + c300 * 1) * 300) / ((cMiss + c100 + c300) * 300)) * 100);

            default:
                return((c50 * 50 + c100 * 100 + c300 * 300) / ((c50 + c100 + c300 + cMiss) * 300) * 100);
            }
        }
コード例 #11
0
 public GameBaseDesktop(OsuMode mode = OsuMode.Unknown) : base(mode)
 {
 }
コード例 #12
0
 ///Returns a list of the user's top plays
 public static List <OsuPlay> GetUserBest(OsuUser user, OsuMode mode = OsuMode.Standard, int limit = 5,
                                          bool generateBeatmaps      = false)
 {
     return(GetUserBest(user.Name, mode, limit, generateBeatmaps));
 }
コード例 #13
0
ファイル: Director.cs プロジェクト: indefined/osu-stream
        /// <summary>
        /// Handles switching to a new OsuMode. Acts as a fatory to create the material GameMode instance and dispose of any previous mode.
        /// </summary>
        /// <param name="newMode">The new mode specification.</param>
        private static void changeMode(OsuMode newMode)
        {
#if MONO
            if (Environment.CommandLine.Contains("Tester"))
            {
                switch (newMode)
                {
                case OsuMode.PlayTest:
                case OsuMode.PositioningTest:

                    break;

                default:
                    PendingOsuMode = OsuMode.PositioningTest;
                    newMode        = OsuMode.PositioningTest;
                    break;
                }
            }
#endif

            if (CurrentMode != null)
            {
                //check whether we want to retain state before outright disposing.
                GameMode check = null;

                if (!savedStates.TryGetValue(CurrentOsuMode, out check) || check != CurrentMode)
                {
                    if (check != null)
                    {
                        savedStates.Remove(CurrentOsuMode); //we should never get here, since only one state should be saved.
                    }
                    CurrentMode.Dispose();
                }
            }

            TextureManager.ModeChange();

            bool restored = false;

            Clock.ModeTimeReset();

            if (PendingMode == null)
            {
                //try to restore a saved state before loading fresh.
                if (savedStates.TryGetValue(newMode, out PendingMode))
                {
                    restored = true;
                }
                else
                {
                    loadNewMode(newMode);
                }
            }

            AudioEngine.Reset();

            CurrentMode = PendingMode;
            PendingMode = null;

            //enable dimming in case it got left on somewhere.
            if (GameBase.Instance != null)
            {
                GameBase.Instance.DisableDimming = true;
            }
            GameBase.ShowLoadingOverlay = false;

            AudioDimming = true;

            LastOsuMode = CurrentOsuMode; //the case for the main menu on first load.

            if (restored)
            {
                CurrentMode.Restore();
            }
            else
            {
                CurrentMode.Initialize();
            }

            if (PendingOsuMode != OsuMode.Unknown) //can be unknown on first startup
            {
                if (PendingOsuMode != newMode)
                {
                    changeMode(PendingOsuMode);
                    //we got a new request to load a *different* mode during initialisation...
                    return;
                }

                modeChangePending = true;
            }

            PendingOsuMode = OsuMode.Unknown;
            CurrentOsuMode = newMode;

            if (PendingOsuMode == OsuMode.Play)
            {
                GC.Collect(); //force a full collect before we start displaying the new mode.
            }
            GameBase.ThrottleExecution = false;
            //reset this here just in case it got stuck.
        }
コード例 #14
0
ファイル: Director.cs プロジェクト: indefined/osu-stream
        private static void loadNewMode(OsuMode newMode)
        {
            //Create the actual mode
            GameMode mode = null;

            switch (newMode)
            {
            case OsuMode.MainMenu:
                mode = new MainMenu();
                break;

            case OsuMode.SongSelect:
                mode = new SongSelectMode();
                break;

            case OsuMode.Results:
                mode = new Results();
                break;

#if MONO
            case OsuMode.PlayTest:
                mode = new PlayTest();
                break;
#endif
            case OsuMode.Play:
                if (CurrentOsuMode == OsuMode.VideoPreview)
                {
                    mode = new PreviewPlayer();
                }
                else
                {
                    mode = new Player();
                }
                break;

            case OsuMode.Store:
#if iOS
                mode = new StoreModeIphone();
#else
                mode = new StoreMode();
#endif
                break;

            case OsuMode.Options:
                mode = new Options();
                break;

            case OsuMode.Tutorial:
                mode = new Tutorial();
                break;

            case OsuMode.Credits:
                mode = new Credits();
                break;

            case OsuMode.VideoPreview:
                mode = new VideoPreview();
                break;

            case OsuMode.Empty:
                mode = new Empty();
                break;

#if MONO
            case OsuMode.PositioningTest:
                mode = new PositioningTest();
                break;
#endif
            }

            PendingMode = mode;
        }
コード例 #15
0
ファイル: CommandOsu.cs プロジェクト: EngineerMark/nayuta-bot
        protected void ApplyMode(CommandArguments args)
        {
            _osuMode = OsuMode.Standard;

            if (args.Get("m") != null)
            {
                switch (args.Get("m"))
                {
                case "standard":
                    _osuMode = OsuMode.Standard;
                    break;

                case "mania":
                    _osuMode = OsuMode.Mania;
                    break;

                case "ctb":
                case "catch":
                    _osuMode = OsuMode.Catch;
                    break;

                case "taiko":
                    _osuMode = OsuMode.Taiko;
                    break;

                default:
                    _osuMode = OsuMode.Standard;
                    break;
                }
            }

            // if (string.IsNullOrEmpty(input))
            //     return input;
            // if (input.Contains("-m ") || input.Contains(" -m "))
            // {
            //     string foundMode = "";
            //     if (input.Contains(" -m "))
            //     {
            //         foundMode = input.Substring(input.IndexOf(" -m ", StringComparison.Ordinal) + " -m ".Length);
            //         input = input.Substring(0, input.IndexOf(" -m ", StringComparison.Ordinal));
            //     }
            //     else
            //     {
            //         foundMode = input.Substring(input.IndexOf("-m ", StringComparison.Ordinal) + "-m ".Length);
            //         input = input.Substring(0, input.IndexOf("-m ", StringComparison.Ordinal));
            //     }
            //
            //     switch (foundMode.ToLower())
            //     {
            //         case "standard":
            //             _osuMode = OsuMode.Standard;
            //             break;
            //         case "mania":
            //             _osuMode = OsuMode.Mania;
            //             break;
            //         case "ctb":
            //         case "catch":
            //             _osuMode = OsuMode.Catch;
            //             break;
            //         case "taiko":
            //             _osuMode = OsuMode.Taiko;
            //             break;
            //         default:
            //             _osuMode = OsuMode.Standard;
            //             break;
            //     }
            // }
            // return input;
        }
コード例 #16
0
 public void SettingsSetGamemode(OsuMode val) => AttachedJavascriptWrapper.SelectInput.SetValue("#settingsInputGamemodeDropdown", ((int)val).ToString());
コード例 #17
0
ファイル: Director.cs プロジェクト: indefined/osu-stream
 public static bool ChangeMode(OsuMode mode, bool retainState = false)
 {
     return(ChangeMode(mode, new FadeTransition(), retainState));
 }