コード例 #1
0
        public static async Task Load(UIReplayLoader loader)
        {
            if (!Dispatcher.UIThread.CheckAccess())
            {
                await Dispatcher.UIThread.InvokeAsync(() => Load(loader));

                return;
            }
            string errorMessage, result = null;

            do
            {
                try
                {
                    if ((errorMessage = await loader.Load()) == null)
                    {
                        Window.DataContext = new MissWindowViewModel(loader);
                        return;
                    }

                    if (loader.Options.WatchDogMode)
                    {
                        return;
                    }
                }
                catch (Exception e)
                {
                    errorMessage = e.Message;
                    File.WriteAllText("exception.log", e.ToString());
                }
                if (errorMessage != null)
                {
                    result = await ShowMessageBox($"An error has occurred.\n{errorMessage}", "OK", "Reload");

                    if (result != "Reload")
                    {
                        Window.Close();
                        return;
                    }
                    else
                    {
                        loader = new UIReplayLoader {
                            Options = loader.Options
                        };
                    }
                }
            } while (result == "Reload");
        }
コード例 #2
0
 // Avalonia configuration, don't remove; also used by visual designer.
 public static AppBuilder BuildAvaloniaApp(UIReplayLoader replayLoader)
 => AppBuilder.Configure <App>(() => new App(replayLoader))
 .UsePlatformDetect()
 .UseReactiveUI()
 .LogToTrace();
コード例 #3
0
        // Initialization code. Don't use any Avalonia, third-party APIs or any
        // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
        // yet and stuff might break.
        public static void Main(string[] args)
        {
            Debug.Print("Starting MissAnalyser... ");
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
            string        replay = null, beatmap = null;
            List <string> extras;
            var           optList     = new Dictionary <string, string>();
            bool          help        = false;
            int           getMiss     = -1;
            string        optionsFile = "options.cfg";

            var opts = new OptionSet()
            {
                { "o|osudir=", "Set osu! directory", o => optList["osudir"] = o },
                { "c|config=", "Set options.cfg", f => optionsFile = f },
                { "s|songsdir=", "Set songs directory", s => optList["songsdir"] = s },
                { "w|watchdogmode=", "watch and automatically load newest replays, requires osudir to be set", s => optList["watchdogmode"] = s },
                { "d|daemon", "Run without dialogs", d => headless = d != null },
                { "h|help", "Displays help", h => help = h != null },
                { "m|miss=", "Export miss #", (int m) => getMiss = m }
            };

            extras = opts.Parse(args);
            foreach (var arg in extras)
            {
                if (arg.EndsWith(".osu") && File.Exists(arg))
                {
                    beatmap = arg;
                }
                if (arg.EndsWith(".osr") && File.Exists(arg))
                {
                    replay = arg;
                }
            }
            if (!File.Exists(optionsFile))
            {
                File.Create(optionsFile).Close();
                Debug.Print("\nCreating options.cfg... ");
                Debug.Print("- In options.cfg, you can define various settings that impact the program. ");
                Debug.Print("- To add these to options.cfg, add a new line formatted <Setting Name>=<Value> ");
                Debug.Print("- Available settings : SongsDir | Value = Specify osu!'s songs dir.");
                Debug.Print("-                       APIKey  | Value = Your osu! API key (https://osu.ppy.sh/api/");
                Debug.Print("-                       OsuDir  | Value = Your osu! directory");
                Debug.Print("-                 WatchDogMode  | Value = true or false");
            }
            if (help)
            {
                Console.WriteLine("osu! Miss Analyzer");
                opts.WriteOptionDescriptions(Console.Out);
                return;
            }
            Options        options      = new Options("options.cfg", optList);
            UIReplayLoader replayLoader = new UIReplayLoader
            {
                Options     = options,
                ReplayFile  = replay,
                BeatmapFile = beatmap,
            };

            BuildAvaloniaApp(replayLoader).StartWithClassicDesktopLifetime(new string[] { });
        }
コード例 #4
0
 public App(UIReplayLoader replayLoader)
 {
     ReplayLoader = replayLoader;
 }
コード例 #5
0
 public MissWindowController(MissAnalyzer model, UIReplayLoader loader)
 {
     Model  = model;
     Loader = loader;
 }
コード例 #6
0
        public static void Main(string[] args)
        {
            MissAnalyzer         missAnalyzer;
            MissWindowController controller;
            MissWindow           window;

            Debug.Print("Starting MissAnalyser... ");
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
            string        replay = null, beatmap = null;
            List <string> extras;
            Dictionary <string, string> optList = new Dictionary <string, string>();
            bool   help        = false;
            int    getMiss     = -1;
            string optionsFile = "options.cfg";

            var opts = new OptionSet()
            {
                { "o|osudir=", "Set osu! directory", o => optList["osudir"] = o },
                { "c|config=", "Set options.cfg", f => optionsFile = f },
                { "s|songsdir=", "Set songs directory", s => optList["songsdir"] = s },
                { "d|daemon", "Run without dialogs", d => headless = d != null },
                { "h|help", "Displays help", h => help = h != null },
                { "m|miss=", "Export miss #", (int m) => getMiss = m }
            };

            extras = opts.Parse(args);
            foreach (var arg in extras)
            {
                if (arg.EndsWith(".osu") && File.Exists(arg))
                {
                    beatmap = arg;
                }
                if (arg.EndsWith(".osr") && File.Exists(arg))
                {
                    replay = arg;
                }
            }
            if (!File.Exists(optionsFile))
            {
                File.Create(optionsFile).Close();
                Debug.Print("\nCreating options.cfg... ");
                Debug.Print("- In options.cfg, you can define various settings that impact the program. ");
                Debug.Print("- To add these to options.cfg, add a new line formatted <Setting Name>=<Value> ");
                Debug.Print("- Available settings : SongsDir | Value = Specify osu!'s songs dir.");
                Debug.Print("-                       APIKey  | Value = Your osu! API key (https://osu.ppy.sh/api/");
                Debug.Print("-                       OsuDir  | Value = Your osu! directory");
            }
            if (help)
            {
                Console.WriteLine("osu! Miss Analyzer");
                opts.WriteOptionDescriptions(Console.Out);
                return;
            }

            try
            {
                Options        options      = new Options("options.cfg", optList);
                UIReplayLoader replayLoader = new UIReplayLoader(options);
                if (!replayLoader.Load(replay, beatmap))
                {
                    return;
                }
                if (replayLoader.Replay == null || replayLoader.Beatmap == null)
                {
                    ShowErrorDialog("Couldn't find " + (replayLoader.Replay == null ? "replay" : "beatmap"));
                    return;
                }

                missAnalyzer = new MissAnalyzer(replayLoader);
                controller   = new MissWindowController(missAnalyzer, replayLoader);
                window       = new MissWindow(controller);
                Application.Run(window);
            } catch (Exception e)
            {
                ShowErrorDialog(e.Message);
                File.WriteAllText("exception.log", e.ToString());
            }
        }