示例#1
0
        public static void Main()
        {
            Context.Initialize();
            Config.Load();
            WidgetManager.Initialize();
            WidgetManager.Register("Track", new TrackWidget(0f, 0f, 300f, 60f));
            WidgetManager.Register("Progress", new ProgressWidget(0f, 0f, 300f, 5f));
            WidgetManager.Register("Update", new UpdateWidget(0f, 0f, 300f, 30f));
            WidgetManager.Drawn["Update"] = false;
            WidgetManager.GetWidget("Track").SetPositionFromBottomRightCorner(new PointF(300f, 60f));
            WidgetManager.GetWidget("Update").SetPositionFromBottomRightCorner(new PointF(300f, 90f));
            WidgetManager.GetWidget("Progress").SetPositionFromBottomRightCorner(new PointF(300f, 5f));
            Game.Console.Print("[Ragify] Loaded successfully.");
            Game.DisplayHelp("Ragify has successfully loaded.");
            Game.DisplayHelp("Use the [CTRL] key in combination with a command to control Spotify.");
            if (Config.initializationFile.ReadBoolean("General", "checkForUpdates", true))
            {
                Updates.CheckForUpdates();
            }
            else
            {
                Game.Console.Print("[Ragify] Skipped update check based on config value");
            }
            if (!Config.initializationFile.ReadBoolean("General", "showDisplayOnStartup", true))
            {
                WidgetManager.Drawn["Track"]    = false;
                WidgetManager.Drawn["Progress"] = false;
                Context.Displayed = false;
            }
            while (true)
            {
                if (Game.IsControlKeyDownRightNow)
                {
                    if (Game.IsKeyDown(Config.GetKey("toggleDisplay")) && WidgetManager.Drawn.ContainsKey("Track") && WidgetManager.Drawn.ContainsKey("Progress"))
                    {
                        WidgetManager.Drawn["Track"]    = !WidgetManager.Drawn["Track"];
                        WidgetManager.Drawn["Progress"] = !WidgetManager.Drawn["Progress"];
                        Context.Displayed = !Context.Displayed;
                    }
                    if (Game.IsKeyDown(Config.GetKey("togglePlayback")))
                    {
                        if (Context.Playing)
                        {
                            Game.DisplaySubtitle("Playback paused");
#if DEFAULT
                            Context.Spotify.Pause();
#endif
                        }
                        else
                        {
#if DEFAULT
                            Context.Spotify.Play();
#endif
                            Game.DisplaySubtitle("Playback resumed");
                        }
                    }
                    if (Game.IsKeyDown(Config.GetKey("nextTrack")))
                    {
#if DEFAULT
                        Context.Spotify.Skip();
#endif
                        Game.DisplaySubtitle("Skipped track");
                    }
                    if (Game.IsKeyDown(Config.GetKey("previousTrack")))
                    {
#if DEFAULT
                        Context.Spotify.Previous();
#endif
                        Game.DisplaySubtitle("Previous track");
                    }
                    if (Game.IsKeyDownRightNow(Config.GetKey("volumeUp")))
                    {
#if DEFAULT
                        float num = Context.Spotify.GetSpotifyVolume();
                        if ((double)num <= 99.0)
                        {
                            num += 1f;
                            Context.Spotify.SetSpotifyVolume(num);
                            Game.DisplaySubtitle($"Set Volume to {num}");
                        }
#endif
                    }
                    if (Game.IsKeyDownRightNow(Config.GetKey("volumeDown")))
                    {
#if DEFAULT
                        float num2 = Context.Spotify.GetSpotifyVolume();
                        if ((double)num2 >= 1.0)
                        {
                            num2 -= 1f;
                            Context.Spotify.SetSpotifyVolume(num2);
                            Game.DisplaySubtitle($"Set Volume to {num2}");
                        }
#endif
                    }
                }
                GameFiber.Yield();
            }
        }
示例#2
0
        public static void Main()
        {
            //Widget widget = new Widget();

            //bool RenderHooked = false;

            Context.Initialize();
            Config.Load();
            WidgetManager.Initialize();

            WidgetManager.Register("Track", new TrackWidget(0, 0, 300, 60));
            WidgetManager.Register("Progress", new ProgressWidget(0, 0, 300, 5));
            WidgetManager.Register("Update", new UpdateWidget(0, 0, 300, 30));

            WidgetManager.Drawn["Update"] = false;

            WidgetManager.GetWidget("Track").SetPositionFromBottomRightCorner(new PointF(300, 60));
            WidgetManager.GetWidget("Update").SetPositionFromBottomRightCorner(new PointF(300, 90));
            WidgetManager.GetWidget("Progress").SetPositionFromBottomRightCorner(new PointF(300, 5));

            Rage.Game.DisplayHelp("Ragify has successfully loaded. Use the [CTRL] key in combination with a command to control Spotify.");

            Updates.CheckForUpdates();

            while (true)
            {
                if (Game.IsControlKeyDownRightNow)
                {
                    if (Game.IsKeyDown(Config.GetKey("toggleDisplay")))
                    {
                        if (WidgetManager.Drawn.ContainsKey("Track") && WidgetManager.Drawn.ContainsKey("Progress"))
                        {
                            WidgetManager.Drawn["Track"]    = !WidgetManager.Drawn["Track"];
                            WidgetManager.Drawn["Progress"] = !WidgetManager.Drawn["Progress"];
                            Context.Displayed = !Context.Displayed;
                        }
                    }

                    if (Game.IsKeyDown(Config.GetKey("togglePlayback")))
                    {
                        if (Context.Playing)
                        {
                            Game.DisplaySubtitle("Playback paused");
                            Context.Spotify.Pause();
                        }
                        else
                        {
                            Context.Spotify.Play();
                            Game.DisplaySubtitle("Playback resumed");
                        }
                    }

                    if (Game.IsKeyDown(Config.GetKey("nextTrack")))
                    {
                        Context.Spotify.Skip();
                    }

                    if (Game.IsKeyDown(Config.GetKey("previousTrack")))
                    {
                        Context.Spotify.Previous();
                    }

                    if (Game.IsKeyDownRightNow(Config.GetKey("volumeUp")))
                    {
                        float volume = Context.Spotify.GetSpotifyVolume();
                        if (!(volume > 99.0))
                        {
                            volume++;
                            Context.Spotify.SetSpotifyVolume(volume);
                        }
                    }

                    if (Game.IsKeyDownRightNow(Config.GetKey("volumeDown")))
                    {
                        float volume = Context.Spotify.GetSpotifyVolume();

                        if (!(volume < 1.0))
                        {
                            volume--;
                            Context.Spotify.SetSpotifyVolume(volume);
                        }
                    }
                }

                Rage.GameFiber.Yield();
            }
        }