public static void SwitchToPlayingState(string titleId, string titleName)
        {
            if (File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "RPsupported.dat")).Contains(titleId))
            {
                DiscordPresence.Assets.LargeImageKey = titleId;
            }

            string state = titleId;

            if (state == null)
            {
                state = "Ryujinx";
            }
            else
            {
                state = state.ToUpper();
            }

            string details = "Idling";

            if (titleName != null)
            {
                details = $"Playing {titleName}";
            }

            DiscordPresence.Details = details;
            DiscordPresence.State   = state;
            DiscordPresence.Assets.LargeImageText = titleName;
            DiscordPresence.Assets.SmallImageKey  = "ryujinx";
            DiscordPresence.Assets.SmallImageText = LargeDescription;
            DiscordPresence.Timestamps            = new Timestamps(DateTime.UtcNow);

            DiscordClient?.SetPresence(DiscordPresence);
        }
        public static void SwitchToPlayingState(string titleId, string titleName)
        {
            if (SupportedTitles.Contains(titleId))
            {
                DiscordPresence.Assets.LargeImageKey = titleId;
            }

            string state = titleId;

            if (state == null)
            {
                state = "PangoNX Debugger";
            }
            else
            {
                state = state.ToUpper();
            }

            string details = "Idling";

            if (titleName != null)
            {
                details = $"Playing {titleName}";
            }

            DiscordPresence.Details = details;
            DiscordPresence.State   = state;
            DiscordPresence.Assets.LargeImageText = titleName;
            DiscordPresence.Assets.SmallImageKey  = "ryujinx";
            DiscordPresence.Assets.SmallImageText = LargeDescription;
            DiscordPresence.Timestamps            = new Timestamps(DateTime.UtcNow);

            _discordClient?.SetPresence(DiscordPresence);
        }
Ejemplo n.º 3
0
        private void UpdateDetails()
        {
            if (GameService.Player.Map == null)
            {
                return;
            }

            // rpcClient *shouldn't* be null at this point unless a rare race condition occurs
            // In the event that this occurs, it'll be resolved by the next loop
            rpcClient?.SetPresence(new RichPresence()
            {
                // Truncate length (requirements: https://discordapp.com/developers/docs/rich-presence/how-to)
                // Identified in: [BLISHHUD-11]
                Details = TruncateLength(GameService.Player.CharacterName, 128),
#if DEBUG
                State = "Working on Blish HUD",
#else
                State = TruncateLength($"in {GameService.Player.Map.Name}", 128),
#endif
                Assets = new Assets()
                {
                    LargeImageKey  = TruncateLength(mapOverrides.ContainsKey(GameService.Player.Map.Id) ? mapOverrides[GameService.Player.Map.Id] : GetDiscordSafeString(GameService.Player.Map.Name), 32),
                    LargeImageText = TruncateLength(GameService.Player.Map.Name, 128),
                    SmallImageKey  = TruncateLength(((MapType)GameService.Player.MapType).ToString().ToLower(), 32),
                    SmallImageText = TruncateLength(((MapType)GameService.Player.MapType).ToString().Replace("_", " "), 128)
                },
                Timestamps = new Timestamps()
                {
                    Start = startTime
                }
            });

            rpcClient?.Invoke();
        }
Ejemplo n.º 4
0
        public void Update(Track track, PlaybackStatus status)
        {
            string activity = string.Empty;
            string state    = string.Empty;

            switch (status)
            {
            case PlaybackStatus.Playing:
                activity = "play";
                state    = $"by {track.Artist}";
                break;

            case PlaybackStatus.Paused:
                activity = "pause";
                state    = "Paused";
                break;

            case PlaybackStatus.Stopped:
                activity = "idle";
                state    = "Idle";
                break;
            }
            client?.SetPresence(new RichPresence
            {
                Details = TruncateBytes(track.Title, 120),
                State   = TruncateBytes(state, 120),
                Assets  = new Assets
                {
                    LargeImageKey = "icon",
                    SmallImageKey = activity
                },
                Timestamps = Timestamps.Now
            });
        }
Ejemplo n.º 5
0
        public static void Initialize()
        {
            Presence = new RichPresence
            {
                Details = "In Main Menu",
                Assets  = new Assets
                {
                    LargeImageText = "Aerovelence",
                    LargeImageKey  = "aerodefault",
                    SmallImageKey  = "helditem"
                },
                State = ""
            };

            if (Main.netMode != NetmodeID.SinglePlayer)
            {
                Presence.Party = new Party
                {
                    Size = Main.ActivePlayersCount,
                    Max  = Main.maxNetPlayers
                }
            }
            ;

            Client = new DiscordRpcClient("828361668646928466");

            Presence.Timestamps = new Timestamps
            {
                Start = DateTime.UtcNow
            };

            Client?.Initialize();
            Client?.SetPresence(Presence);
        }
Ejemplo n.º 6
0
        private void UpdateDetails()
        {
            if (GameService.Player.Map == null)
            {
                return;
            }

            Logger.Debug($"Player changed maps to '{GameService.Player.Map.Name}' ({GameService.Player.Map.Id}).");

            // rpcClient *shouldn't* be null at this point unless a rare race condition occurs
            // In the event that this occurs, it'll be resolved by the next loop
            _rpcClient?.SetPresence(new RichPresence()
            {
                // Truncate length (requirements: https://discordapp.com/developers/docs/rich-presence/how-to)
                Details = DiscordUtil.TruncateLength(GameService.Player.CharacterName, 128),
                State   = DiscordUtil.TruncateLength($"in {GameService.Player.Map.Name}", 128),
                Assets  = new Assets()
                {
                    LargeImageKey = DiscordUtil.TruncateLength(_mapOverrides.ContainsKey(GameService.Player.Map.Id.ToString())
                                                                   ? _mapOverrides[GameService.Player.Map.Id.ToString()]
                                                                   : DiscordUtil.GetDiscordSafeString(GameService.Player.Map.Name), 32),
                    LargeImageText = DiscordUtil.TruncateLength(GameService.Player.Map.Name, 128),
                    SmallImageKey  = DiscordUtil.TruncateLength(((MapType)GameService.Player.MapType).ToString().ToLower(), 32),
                    SmallImageText = DiscordUtil.TruncateLength(((MapType)GameService.Player.MapType).ToString().Replace("_", " "), 128)
                },
                Timestamps = new Timestamps()
                {
                    Start = _startTime
                }
            });

            _rpcClient?.Invoke();
        }
Ejemplo n.º 7
0
 public void SetPresence()
 {
     client?.SetPresence(new RichPresence
     {
         Details = label3.Text,
         State   = textBox2.Text,
         Assets  = assets
     });
 }
        public virtual void DisplayPokemonNameRP(string name, bool shinyness)
        {
#if DEBUG
            return;
#endif
            if (shinyness)
            {
                name = name += " ✨";
            }
            client?.SetPresence(new RichPresence()
            {
                Details = "In-Game",
                State   = "Playing v0.4.2",
                Assets  = new Assets()
                {
                    LargeImageKey  = "largeimage2",
                    LargeImageText = "Merry Christmas!",
                    SmallImageKey  = "pokeball",
                    SmallImageText = "Using " + name
                },
                Timestamps = timestamp
            });
        }
Ejemplo n.º 9
0
        private static void UpdatePresence(String detail, String state)
        {
            Assets assets = new Assets()
            {
                LargeImageKey = "hs-logo"
            };

            discord?.SetPresence(new RichPresence()
            {
                Details = detail,
                State   = state,
                Assets  = assets
            });
        }
Ejemplo n.º 10
0
 public static void Load()
 {
     _rpc = new RichPresence()
     {
         Details = "Collecting Pages",
     };
     rpcClient       = new DiscordRpcClient("689253540505714732");
     _rpc.Timestamps = new Timestamps()
     {
         Start = DateTime.UtcNow,
     };
     rpcClient?.SetPresence(_rpc);
     rpcClient.Initialize();
 }
Ejemplo n.º 11
0
 public static void UpdateRPC(string Activity, string Artist = null, string Title = null)
 {
     client?.SetPresence(new RichPresence()
     {
         Details = Title,
         State   = $"by {Artist}",
         Assets  = new Assets()
         {
             LargeImageKey = "icon",
             SmallImageKey = Activity
         },
         Timestamps = Timestamps.Now
     }
                         );
 }
Ejemplo n.º 12
0
 public static void SwitchToPlayingState(string titleId, string titleName)
 {
     _discordClient?.SetPresence(new RichPresence
     {
         Assets = new Assets
         {
             LargeImageKey  = "game",
             LargeImageText = titleName,
             SmallImageKey  = "ryujinx",
             SmallImageText = Description,
         },
         Details    = $"Playing {titleName}",
         State      = (titleId == "0000000000000000") ? "Homebrew" : titleId.ToUpper(),
         Timestamps = Timestamps.Now,
         Buttons    = new Button[]
         {
             new Button()
             {
                 Label = "Website",
                 Url   = "https://ryujinx.org/"
             }
         }
     });
 }
Ejemplo n.º 13
0
        public override void PreSaveAndQuit()
        {
            TerramonPlayer p = Main.LocalPlayer.GetModPlayer <TerramonPlayer>();

            p.openingSfx?.Stop();
            client?.SetPresence(new RichPresence()
            {
                Details = "In Menu",
                State   = $"Playing v{ModContent.GetInstance<TerramonMod>().Version}",
                Assets  = new Assets()
                {
                    LargeImageKey  = "largeimage2",
                    LargeImageText = "Terramon Mod"
                }
            });
        }
Ejemplo n.º 14
0
        private void Initialize()
        {
            client = new DiscordRpcClient("645517082431062016")
            {
                Logger = new ConsoleLogger()
                {
                    Level = LogLevel.Warning
                }
            };

            //Subscribe to events
            client.OnReady += (sender, e) =>
            {
                //Console.WriteLine("Received Ready from user {0}", e.User.Username);
            };

            client.OnPresenceUpdate += (sender, e) =>
            {
                //Console.WriteLine("Received Update! {0}", e.Presence);
            };

            //Connect to the RPC
            client?.Initialize();

            //Set the rich presence
            //Call this as many times as you want and anywhere in your code.
            client?.SetPresence(new RichPresence()
            {
                Details = "Nostale PServer",
                State   = "Ancelloan",
                Assets  = new Assets()
                {
                    LargeImageKey  = "ancelloan",
                    LargeImageText = "Ancelloan.eu"
                }
            });

            var timer = new System.Timers.Timer(150);

            timer.Elapsed += (sender, args) => { client?.Invoke(); };
            timer.Start();
        }
Ejemplo n.º 15
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (m_Client != null)
            {
                m_Client.Invoke();

                var has = false;
                var rp  = new RichPresence();

                if (checkBox_Details.Checked &&
                    textBox_Details.Text.Length >= 2)
                {
                    rp.Details = textBox_Details.Text;
                    has        = true;
                }

                if (checkBox_State.Checked &&
                    textBox_State.Text.Length >= 2)
                {
                    rp.State = textBox_State.Text;
                    has      = true;
                }

                if (checkBox_LargeImageKey.Checked ||
                    checkBox_LargeImageText.Checked ||
                    checkBox_SmallImageKey.Checked ||
                    checkBox_SmallImageText.Checked)
                {
                    var a = new Assets();
                    if (checkBox_LargeImageKey.Checked)
                    {
                        a.LargeImageKey = textBox_LargeImageKey.Text;
                    }
                    if (checkBox_LargeImageText.Checked)
                    {
                        a.LargeImageText = textBox_LargeImageText.Text;
                    }
                    if (checkBox_SmallImageKey.Checked)
                    {
                        a.SmallImageKey = textBox_SmallImageKey.Text;
                    }
                    if (checkBox_SmallImageText.Checked)
                    {
                        a.SmallImageText = textBox_SmallImageText.Text;
                    }
                    rp.Assets = a;
                    has       = true;
                }

                // Details나 State가 설정되어야 값이 나옴
                // PC는 상관이 없는데 MOBILE에서 그럼
                if (checkBox_Start.Checked ||
                    checkBox_End.Checked)
                {
                    var timestamps = new Timestamps();
                    if (checkBox_Start.Checked)
                    {
                        timestamps.Start = dtp_Start.Value.ToUniversalTime();
                    }
                    // Start가 설정되어야 함.
                    // 안그럼 디코가 터짐
                    if (checkBox_Start.Checked &&
                        checkBox_End.Checked)
                    {
                        timestamps.End = dtp_End.Value.ToUniversalTime();
                    }
                    rp.Timestamps = timestamps;
                    has           = true;
                }

                if (checkBox_Party.Checked &&
                    nud_PartySize.Value < nud_PartyMax.Value)
                {
                    rp.WithParty(new Party
                    {
                        ID   = "pypy",
                        Size = (int)nud_PartySize.Value,
                        Max  = (int)nud_PartyMax.Value
                    });
                    has = true;
                }

                if (has)
                {
                    m_Client.SetPresence(rp);
                }
                else
                {
                    m_Client.SetPresence(null);
                }
            }
        }
Ejemplo n.º 16
0
        public static void Start()
        {
            Active = true;
            // loop
            Csecret = settings.Secret;
            while (client != null && Active)
            {
                // Get info
                FLInfo InitInfo = GetFLInfo();

                // Try to read any keys if available
                if (Console.In.Peek() != -1)
                {
                    switch (Console.ReadKey(true).Key)
                    {
                    case ConsoleKey.H:
                        Console.WriteLine("Commands: \n s: turn on secret mode \n q: Quit \n h: help \n Other settings can be changed in the settings.xml file");
                        break;

                    case ConsoleKey.S:
                        if (Csecret)
                        {
                            Csecret = false;
                            Console.WriteLine("\n Secret Mode turned off!");
                            rp.State = InitInfo.projectName;
                        }
                        else if (!Csecret)
                        {
                            Csecret = true;
                            Console.WriteLine("\n Secret Mode turned on!");
                            rp.State = settings.SecretMessage;
                        }

                        break;

                    case ConsoleKey.Q:
                        StopAndExit();
                        break;
                    }
                }


                if (client != null)
                {
                    client.Invoke();
                }


                //Skip update if nothing changes
                if (InitInfo.appName == rp.Details && InitInfo.projectName == rp.State && Csecret == Psecret)
                {
                    continue;
                }
                if (InitInfo.projectName == null && rp.State == settings.NoNameMessage && Csecret == Psecret)
                {
                    continue;
                }

                //Fill State and details
                if (InitInfo.projectName == null)
                {
                    rp.State   = settings.NoNameMessage;
                    rp.Details = InitInfo.appName;
                }

                else
                {
                    rp.Details = InitInfo.appName;
                    rp.State   = InitInfo.projectName;
                }
                if (Csecret)
                {
                    rp.State = settings.SecretMessage;
                }
                Psecret = Csecret;
                client.SetPresence(rp);
                Thread.Sleep(settings.RefeshInterval);
            }
        }
Ejemplo n.º 17
0
        public void Main(object sender, EventArgs e)
        {
            dynamic CurVehicle;

            if (Exists(Player.Character.CurrentVehicle))
            {
                CurVehicle = "In Vehicle: " + Player.Character.CurrentVehicle.ToString();
            }
            else
            {
                CurVehicle = "On Foot";
            }

            //I wish there was a better way...
            dynamic CurWeapon;
            dynamic CurWeaponIcon;

            if (Player.Character.Weapons.Current == Player.Character.Weapons.AssaultRifle_AK47)
            {
                CurWeapon     = "Weapon: AK-47";
                CurWeaponIcon = "assaultrifle_ak47";
            }
            else if (Player.Character.Weapons.Current == Player.Character.Weapons.AssaultRifle_M4)
            {
                CurWeapon     = "Weapon: M4";
                CurWeaponIcon = "assaultrifle_m4";
            }
            else if (Player.Character.Weapons.Current == Player.Character.Weapons.BarettaShotgun)
            {
                CurWeapon     = "Weapon: Beretta 1201";
                CurWeaponIcon = "barettashotgun";
            }
            else if (Player.Character.Weapons.Current == Player.Character.Weapons.BaseballBat)
            {
                CurWeapon     = "Weapon: Baseball Bat";
                CurWeaponIcon = "baseballbat";
            }
            else if (Player.Character.Weapons.Current == Player.Character.Weapons.BasicShotgun)
            {
                CurWeapon     = "Weapon: Shotgun";
                CurWeaponIcon = "basicshotgun";
            }
            else if (Player.Character.Weapons.Current == Player.Character.Weapons.BasicSniperRifle)
            {
                CurWeapon     = "Weapon: Sniper Rifle";
                CurWeaponIcon = "basicsniperrifle";
            }
            else if (Player.Character.Weapons.Current == Player.Character.Weapons.DesertEagle)
            {
                CurWeapon     = "Weapon: Desert Eagle";
                CurWeaponIcon = "deserteagle";
            }
            else if (Player.Character.Weapons.Current == Player.Character.Weapons.Glock)
            {
                CurWeapon     = "Weapon: Glock 17";
                CurWeaponIcon = "glock";
            }
            else if (Player.Character.Weapons.Current == Player.Character.Weapons.Grenades)
            {
                CurWeapon     = "Weapon: Grenade";
                CurWeaponIcon = "grenades";
            }
            else if (Player.Character.Weapons.Current == Player.Character.Weapons.Knife)
            {
                CurWeapon     = "Weapon: Knife";
                CurWeaponIcon = "knife";
            }
            else if (Player.Character.Weapons.Current == Player.Character.Weapons.MolotovCocktails)
            {
                CurWeapon     = "Weapon: Molotov Cocktail";
                CurWeaponIcon = "molotovcocktails";
            }
            else if (Player.Character.Weapons.Current == Player.Character.Weapons.MP5)
            {
                CurWeapon     = "Weapon: MP5";
                CurWeaponIcon = "mp5";
            }
            else if (Player.Character.Weapons.Current == Player.Character.Weapons.RocketLauncher)
            {
                CurWeapon     = "Weapon: Rocket Launcher";
                CurWeaponIcon = "rocketlauncher";
            }
            else if (Player.Character.Weapons.Current == Player.Character.Weapons.SniperRifle_M40A1)
            {
                CurWeapon     = "Weapon: M40A1";
                CurWeaponIcon = "sniperrifle_m40a1";
            }
            else if (Player.Character.Weapons.Current == Player.Character.Weapons.Uzi)
            {
                CurWeapon     = "Weapon: Uzi";
                CurWeaponIcon = "uzi";
            }
            else
            {
                CurWeapon     = "No Weapon";
                CurWeaponIcon = "unarmed";
            }

            client.SetPresence(new RichPresence()
            {
                Details = "Money: $" + Player.Money.ToString() + " | " + CurVehicle,
                State   = "Wanted Level: " + Player.WantedLevel.ToString() + " Stars | " + CurWeapon,
                //Timestamps = Timestamps.FromTimeSpan(StartTime.Second),
                Assets = new Assets()
                {
                    LargeImageKey  = "game_icon",
                    LargeImageText = "Location: Not Implemented Yet...",
                    SmallImageKey  = CurWeaponIcon,
                    SmallImageText = CurWeapon
                }
            });
        }
Ejemplo n.º 18
0
#pragma warning restore VSTHRD100 // Avoid async void methods

        /// <summary>
        /// Updates the presence with the document
        /// </summary>
        /// <param name="document"></param>
        /// <param name="overrideTimestampReset"></param>
        /// <returns></returns>
        internal async Task UpdatePresenceAsync(Document document, bool overrideTimestampReset = false)
        {
            try
            {
                await JoinableTaskFactory.SwitchToMainThreadAsync();

                if (Settings.enabled)
                {
                    Presence = new RichPresence();
                    if (Settings.secretMode)
                    {
                        Assets           = null;
                        Presence.Details = "I'm working on something you're";
                        Presence.State   = "not allowed to know about, sorry.";
                    }
                    else
                    {
                        string[] language = new string[] { };
                        if (document != null)
                        {
                            string filename = Path.GetFileName(document.FullName).ToLower();
                            string ext      = Path.GetExtension(filename);
                            List <KeyValuePair <string[], string[]> > list = Languages.Where(lang => Array.IndexOf(lang.Key, filename) > -1 || Array.IndexOf(lang.Key, ext) > -1).ToList();
                            language = list.Count > 0 ? list[0].Value : new string[] { };
                        }

                        bool supported = language.Length > 0;
                        Assets = new Assets()
                        {
                            LargeImageKey  = Settings.largeLanguage ? supported ? language[0] : "text" : $"vs{ideVersion}",
                            LargeImageText = Settings.largeLanguage ? supported ? language[1] : "Unrecognized extension" : ideVersion,
                            SmallImageKey  = Settings.largeLanguage ? $"vs{ideVersion}" : supported ? language[0] : "text",
                            SmallImageText = Settings.largeLanguage ? ideVersion : supported ? language[1] : "Unrecognized extension"
                        };

                        if (Settings.showSolutionName)
                        {
                            bool idling = ide.Solution == null || ide.Solution.FullName == string.Empty || ide.Solution.FullName == null;
                            if (idling)
                            {
                                Assets = new Assets()
                                {
                                    LargeImageKey  = $"vs{ideVersion}",
                                    LargeImageText = ideVersion
                                }
                            }
                            ;
                            Presence.Details = idling ? "Idling" : Path.GetFileNameWithoutExtension(ide.Solution.FileName);
                        }

                        if (Settings.showFileName && document != null)
                        {
                            FileInfo fileInfo = new FileInfo(document.FullName);
                            if (fileInfo.IsReadOnly)
                            {
                                Presence.State = $"Reading {fileInfo.Name}";
                            }
                            else
                            {
                                Presence.State = $"Editing {fileInfo.Name}";
                            }
                        }

                        if (Settings.showTimestamp && document != null)
                        {
                            if (!InitializedTimestamp)
                            {
                                Presence.Timestamps = new Timestamps()
                                {
                                    Start = DateTime.UtcNow
                                };
                                InitialTimestamps    = Presence.Timestamps;
                                InitializedTimestamp = true;
                            }

                            if (Settings.resetTimestamp && !overrideTimestampReset)
                            {
                                Presence.Timestamps = new Timestamps()
                                {
                                    Start = DateTime.UtcNow
                                }
                            }
                            ;
                            else if (Settings.resetTimestamp && overrideTimestampReset)
                            {
                                Presence.Timestamps = CurrentTimestamps;
                            }
                            else if (!Settings.resetTimestamp && !overrideTimestampReset)
                            {
                                Presence.Timestamps = InitialTimestamps;
                            }
                            CurrentTimestamps = Presence.Timestamps;
                        }
                    }

                    if (!discordClient.IsInitialized)
                    {
                        discordClient.Initialize();
                    }

                    Presence.Assets = Assets;
                    discordClient.SetPresence(Presence);
                }
                else if (!Settings.enabled && discordClient.IsInitialized)
                {
                    discordClient.Deinitialize();
                }
            }
            catch (Exception e)
            {
                ActivityLog.LogError(e.Source, e.Message);
            }
        }
Ejemplo n.º 19
0
 public void SetPresence(RichPresence rp)
 {
     client?.SetPresence(rp);
 }
Ejemplo n.º 20
0
        public override void Load()
        {
            // Initalize Discord RP on Mod Load
            client        = new DiscordRpcClient("749707767203233792");
            client.Logger = new ConsoleLogger()
            {
                Level = LogLevel.Warning
            };
            //

            //Subscribe to events
            client.OnReady += (sender, e) =>
            {
                Console.WriteLine("Received Ready from user {0}", e.User.Username);
            };

            client.OnPresenceUpdate += (sender, e) =>
            {
                Console.WriteLine("Received Update! {0}", e.Presence);
            };

            //Connect to the RPC
            client.Initialize();

            client.SetPresence(new RichPresence()
            {
                Details = "In Menu",
                State   = "Playing v0.4.1",
                Assets  = new Assets()
                {
                    LargeImageKey  = "largeimage2",
                    LargeImageText = "Terramon Mod"
                }
            });

            //Load all mons to a store
            LoadPokemons();

            if (Main.netMode != NetmodeID.Server)
            {
                if (Localisation == null)
                {
                    Localisation = new LocalisationManager(locale);
                }
                locale = new Bindable <string>(Language.ActiveCulture.Name);
                Store  = new ResourceStore <byte[]>(new EmbeddedStore());
                Localisation.AddLanguage(GameCulture.English.Name, new LocalisationStore(Store, GameCulture.English));
                Localisation.AddLanguage(GameCulture.Russian.Name, new LocalisationStore(Store, GameCulture.Russian));
#if DEBUG
                var ss = Localisation.GetLocalisedString(new LocalisedString(("title", "Powered by broken code")));//It's terrible checking in ui from phone, so i can ensure everything works from version string
                Main.versionNumber = ss.Value + "\n" + Main.versionNumber;
#endif

                ChooseStarter = new ChooseStarter();
                ChooseStarter.Activate();
                ChooseStarterBulbasaur = new ChooseStarterBulbasaur();
                ChooseStarterBulbasaur.Activate();
                ChooseStarterCharmander = new ChooseStarterCharmander();
                ChooseStarterCharmander.Activate();
                ChooseStarterSquirtle = new ChooseStarterSquirtle();
                ChooseStarterSquirtle.Activate();
                PokegearUI = new PokegearUI();
                PokegearUI.Activate();
                PokegearUIEvents = new PokegearUIEvents();
                PokegearUIEvents.Activate();
                evolveUI = new EvolveUI();
                evolveUI.Activate();
                UISidebar = new UISidebar();
                UISidebar.Activate();
                Moves = new Moves();
                Moves.Activate();
                PartySlots = new PartySlots();
                PartySlots.Activate();
                _exampleUserInterface    = new UserInterface();
                _exampleUserInterfaceNew = new UserInterface();
                PokegearUserInterfaceNew = new UserInterface();
                evolveUserInterfaceNew   = new UserInterface();
                _uiSidebar  = new UserInterface();
                _moves      = new UserInterface();
                _partySlots = new UserInterface();


                _exampleUserInterface.SetState(ChooseStarter);       // Choose Starter
                _exampleUserInterfaceNew.SetState(PokegearUI);       // Pokegear Main Menu
                PokegearUserInterfaceNew.SetState(PokegearUIEvents); // Pokegear Events Menu
                evolveUserInterfaceNew.SetState(evolveUI);
                _uiSidebar.SetState(UISidebar);
                _moves.SetState(Moves);
                _partySlots.SetState(PartySlots);
            }


            if (Main.dedServ)
            {
                return;
            }

            FirstPKMAbility  = RegisterHotKey("First Pokémon Move", Keys.Z.ToString());
            SecondPKMAbility = RegisterHotKey("Second Pokémon Move", Keys.X.ToString());
            ThirdPKMAbility  = RegisterHotKey("Third Pokémon Move", Keys.C.ToString());
            FourthPKMAbility = RegisterHotKey("Fourth Pokémon Move", Keys.V.ToString());


            PartyCycle = RegisterHotKey("Quick Spawn First Party Pokémon", Keys.RightAlt.ToString());
        }
        private void start_Click(object sender, EventArgs e)
        {
            if (isEnabled)
            {
                return;
            }
            //string jsonstuff = "{\"Custom Status\": [{\"clientID\": \"{0}\",\"details\": \"{1}\",\"state\": \"{2}\",\"largeImageName\": \"{3}\",\"largeimageText\": \"{4}\",\"smallimageName\": \"{5}\",\"autoStartChk\": \"{6}\"}],\"Animated Status\":[{\"userID\": \"\",\"animation\": \"\",\"delay\": \"\"}]}";

            //MessageBox.Show(String.Format("{\"Custom Status\": [{\"clientID\": \"{0}\",\"details\": \"{1}\",\"state\": \"{2}\",\"largeImageName\": \"{3}\",\"largeimageText\": \"{4}\",\"smallimageName\": \"{5}\",\"autoStartChk\": \"{6}\"}],\"Animated Status\":[{\"userID\": \"\",\"animation\": \"\",\"delay\": \"\"}]}", textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text, textBox6.Text, checkBox2.Checked.ToString()));

            using (StreamWriter writer = File.CreateText("settings.json"))
            {
                writer.WriteLine(String.Format("{{ \"Custom Status\": [ {{\"clientID\": \"{0}\",\"details\": \"{1}\",\"state\": \"{2}\",\"largeImageName\": \"{3}\",\"largeimageText\": \"{4}\",\"smallimageName\": \"{5}\",\"autoStartChk\": \"{6}\"}}],\"Animated Status\":[{{\"userID\": \"\",\"animation\": \"\",\"delay\": \"\"}}]}}", textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text, textBox6.Text, checkBox2.Checked.ToString()));
            }

            var json = File.ReadAllText("settings.json");

            DataSet   dataSet      = JsonConvert.DeserializeObject <DataSet>(json);
            DataTable dataSettings = dataSet.Tables["Custom Status"];

            foreach (DataRow row in dataSettings.Rows)
            {
                textBox1.Text     = (string)row["clientID"];
                textBox2.Text     = (string)row["details"];
                textBox3.Text     = (string)row["state"];
                textBox4.Text     = (string)row["largeImageName"];
                textBox5.Text     = (string)row["largeimageText"];
                textBox6.Text     = (string)row["smallimageName"];
                checkBox2.Checked = (bool)Convert.ToBoolean(row["autoStartChk"]);
            }

            client = new DiscordRpcClient(textBox1.Text);


            isEnabled        = true;
            labelStatus.Text = "Status: RUNNING";
            if (String.IsNullOrWhiteSpace(textBox1.Text))
            {
                MessageBox.Show("Client ID is empty!");
                return;
            }
            client = new DiscordRpcClient(textBox1.Text);
            // You get a client id by creating an app from https://discord.com/developers/applications/


            //Connect to the RPC
            client.Initialize();

            //Set the rich presence
            //Call this as many times as you want and anywhere in your code.
            client.SetPresence(new RichPresence()
            {
                Details = textBox2.Text,
                State   = textBox3.Text,
                Assets  = new Assets()
                {
                    LargeImageKey  = textBox4.Text,
                    LargeImageText = textBox5.Text,
                    SmallImageKey  = textBox6.Text
                }
            });
            if (checkBox1.Checked)
            {
                client.UpdateStartTime();
            }
        }
Ejemplo n.º 22
0
 public static void SetPresence(RichPresence presence)
 {
     client?.SetPresence(presence);
 }
Ejemplo n.º 23
0
        static async Task DiscordSetup()
        {
            var discordRpcClient = new DiscordRpcClient(ClientId);

            //Set the logger
            discordRpcClient.Logger = new ConsoleLogger()
            {
                Level = DiscordRPC.Logging.LogLevel.Info
            };

            //Subscribe to events
            discordRpcClient.OnReady += (sender, e) =>
            {
                Console.WriteLine("Received Ready from user {0}", e.User.Username);
            };

            discordRpcClient.OnPresenceUpdate += (sender, e) =>
            {
                Console.WriteLine("Received Update! {0}", e.Presence);
            };

            //Connect to the RPC
            discordRpcClient.Initialize();

            discordRpcClient.Authorize(DefaultScopes);

            while (string.IsNullOrWhiteSpace(discordRpcClient.AccessCode))
            {
                await Task.Delay(500, CancellableShellHelper.CancellationToken);
            }

            discordRpcClient.Authenticate(null);

            while (string.IsNullOrWhiteSpace(discordRpcClient.AccessToken))
            {
                await Task.Delay(500, CancellableShellHelper.CancellationToken);
            }

            discordRpcClient.RegisterUriScheme();

            discordRpcClient.GetVoiceSettings();

            var newPresence = new RichPresence()
            {
                State = "Accessing Named Pipes",
            };

            discordRpcClient.SetPresence(newPresence);

            discordRpcClient.Subscribe(EventType.VoiceSettingsUpdate);

            discordRpcClient.OnVoiceSettingsUpdate += ProcessDiscordVoiceStatus;

            while (!CancellableShellHelper.CancellationToken.WaitHandle.WaitOne(0))
            {
                await Task.Delay(500, CancellableShellHelper.CancellationToken);
            }

            discordRpcClient.ClearPresence();

            discordRpcClient.ShutdownOnly = true;
        }
Ejemplo n.º 24
0
        public override void Load()
        {
            // Load movedb

            BaseMove.LoadMoveDb();

            // Initalize Discord RP on Mod Load
            if (!Main.dedServ)
            {
                client        = new DiscordRpcClient("790364236554829824");
                client.Logger = new ConsoleLogger()
                {
                    Level = LogLevel.Warning
                };
                //

                Logger.Info("Attempting to establish Discord RP connection");

                // Subscribe to events
                client.OnReady += (sender, e) =>
                {
                    Logger.Info("Established connection");
                    Console.WriteLine("Received Ready from user {0}", e.User.Username);
                };

                client.OnPresenceUpdate += (sender, e) =>
                {
                    Console.WriteLine("Received Update! {0}", e.Presence);
                };

                client.OnError += (sender, e) =>
                {
                    Logger.Error("Could not start Discord RP. Reason: " + e.Message);
                };

                //Connect to the RPC
                client.Initialize();

                client.SetPresence(new RichPresence()
                {
                    Details = "In Menu",
                    State   = "Playing v0.4.2",
                    Assets  = new Assets()
                    {
                        LargeImageKey  = "largeimage2",
                        LargeImageText = "Merry Christmas!"
                    }
                });
            }

            BaseMove._mrand = new UnifiedRandom(BaseMove._seed = new Random().Next());
            //Load all mons to a store
            LoadPokemons();

            if (Main.netMode != NetmodeID.Server)
            {
                if (Localisation == null)
                {
                    Localisation = new LocalisationManager(locale);
                }
                locale = new Bindable <string>(Language.ActiveCulture.Name);

                storage = new ModStorage("Terramon");                                                                  //Initialise local resource store
                Store   = new ResourceStore <byte[]>(new EmbeddedStore());                                             //Make new instance of ResourceStore with dependency what loads data from ModStore
                Store.AddStore(new StorageCachableStore(storage, new WebStore()));                                     //Add second dependency what checks if data exist in local store.
                                                                                                                       //If not and provided URL load data from web and save it on drive
                Textures = new Texture2DStore(Store);                                                                  //Initialise cachable texture store in order not creating new texture each call

                Localisation.AddLanguage(GameCulture.English.Name, new LocalisationStore(Store, GameCulture.English)); //Adds en-US.lang file handling
                Localisation.AddLanguage(GameCulture.Russian.Name, new LocalisationStore(Store, GameCulture.Russian)); //Adds ru-RU.lang file handling
#if DEBUG
                UseWebAssets = true;
                var ss = Localisation.GetLocalisedString(new LocalisedString(("title", "Powered by broken code")));//It's terrible checking in ui from phone, so i can ensure everything works from version string
                //Main.versionNumber = ss.Value + "\n" + Main.versionNumber;
#endif
                Ref <Effect> screenRef      = new Ref <Effect>(GetEffect("Effects/ShockwaveEffect")); // The path to the compiled shader file.
                Ref <Effect> whiteShaderRef = new Ref <Effect>(GetEffect("Effects/whiteshader"));     // The path to the compiled shader file.
                Filters.Scene["Shockwave"] = new Filter(new ScreenShaderData(screenRef, "Shockwave"), EffectPriority.VeryHigh);
                Filters.Scene["Shockwave"].Load();
                GameShaders.Misc["WhiteTint"] = new MiscShaderData(whiteShaderRef, "ArmorBasic");

                ChooseStarter = new ChooseStarter();
                ChooseStarter.Activate();
                ChooseStarterBulbasaur = new ChooseStarterBulbasaur();
                ChooseStarterBulbasaur.Activate();
                ChooseStarterCharmander = new ChooseStarterCharmander();
                ChooseStarterCharmander.Activate();
                ChooseStarterSquirtle = new ChooseStarterSquirtle();
                ChooseStarterSquirtle.Activate();
                PokegearUI = new PokegearUI();
                PokegearUI.Activate();
                PokegearUIEvents = new PokegearUIEvents();
                PokegearUIEvents.Activate();
                evolveUI = new EvolveUI();
                evolveUI.Activate();
                UISidebar = new UISidebar();
                UISidebar.Activate();
                Moves = new Moves();
                Moves.Activate();
                PartySlots = new PartySlots();
                PartySlots.Activate();
                _exampleUserInterface    = new UserInterface();
                _exampleUserInterfaceNew = new UserInterface();
                PokegearUserInterfaceNew = new UserInterface();
                evolveUserInterfaceNew   = new UserInterface();
                _uiSidebar  = new UserInterface();
                _moves      = new UserInterface();
                _partySlots = new UserInterface();
                _battle     = new UserInterface();
                ParentPokemonNPC.HighlightTexture = new Dictionary <string, Texture2D>();
                ParentPokemon.HighlightTexture    = new Dictionary <string, Texture2D>();

                //_exampleUserInterface.SetState(ChooseStarter); // Choose Starter
#if DEBUG
                _exampleUserInterface.SetState(new TestState());
#endif
                _exampleUserInterfaceNew.SetState(PokegearUI);       // Pokegear Main Menu
                PokegearUserInterfaceNew.SetState(PokegearUIEvents); // Pokegear Events Menu
                evolveUserInterfaceNew.SetState(evolveUI);
                _uiSidebar.SetState(UISidebar);
                _moves.SetState(Moves);
                _partySlots.SetState(PartySlots);
                _battle.SetState(BattleMode.UI = new BattleUI());// Automatically assign shortcut

                summaryUI = new AnimatorUI();
                summaryUI.Activate();

                summaryUIInterface = new UserInterface();
                summaryUIInterface.SetState(summaryUI);
            }


            if (Main.dedServ)
            {
                return;
            }

            Scheduler = new Scheduler(Thread.CurrentThread, schedulerClock = new GameTimeClock());

            FirstPKMAbility  = RegisterHotKey("First Pokémon Move", Keys.Z.ToString());
            SecondPKMAbility = RegisterHotKey("Second Pokémon Move", Keys.X.ToString());
            ThirdPKMAbility  = RegisterHotKey("Third Pokémon Move", Keys.C.ToString());
            FourthPKMAbility = RegisterHotKey("Fourth Pokémon Move", Keys.V.ToString());

            CompressSidebar = RegisterHotKey("Compress Sidebar", Keys.RightShift.ToString());

            PartyCycle = RegisterHotKey("Quick Spawn First Party Pokémon", Keys.RightAlt.ToString());
        }
Ejemplo n.º 25
0
        static void FullClientExample()
        {
            //Create a new DiscordRpcClient. We are filling some of the defaults as examples.
            using (client = new DiscordRpcClient("424087019149328395",                              //The client ID of your Discord Application
                                                 pipe: discordPipe,                                 //The pipe number we can locate discord on. If -1, then we will scan.
                                                 logger: new Logging.ConsoleLogger(logLevel, true), //The loger to get information back from the client.
                                                 autoEvents: true,                                  //Should the events be automatically called?
                                                 client: new IO.ManagedNamedPipeClient()            //The pipe client to use. Required in mono to be changed.
                                                 ))
            {
                //If you are going to make use of the Join / Spectate buttons, you are required to register the URI Scheme with the client.
                client.RegisterUriScheme();

                //Set the logger. This way we can see the output of the client.
                //We can set it this way, but doing it directly in the constructor allows for the Register Uri Scheme to be logged too.
                //System.IO.File.WriteAllBytes("discord-rpc.log", new byte[0]);
                //client.Logger = new Logging.FileLogger("discord-rpc.log", DiscordLogLevel);

                //Register to the events we care about. We are registering to everyone just to show off the events

                client.OnReady += OnReady;                                      //Called when the client is ready to send presences
                client.OnClose += OnClose;                                      //Called when connection to discord is lost
                client.OnError += OnError;                                      //Called when discord has a error

                client.OnConnectionEstablished += OnConnectionEstablished;      //Called when a pipe connection is made, but not ready
                client.OnConnectionFailed      += OnConnectionFailed;           //Called when a pipe connection failed.

                client.OnPresenceUpdate += OnPresenceUpdate;                    //Called when the presence is updated

                client.OnSubscribe   += OnSubscribe;                            //Called when a event is subscribed too
                client.OnUnsubscribe += OnUnsubscribe;                          //Called when a event is unsubscribed from.

                client.OnJoin          += OnJoin;                               //Called when the client wishes to join someone else. Requires RegisterUriScheme to be called.
                client.OnSpectate      += OnSpectate;                           //Called when the client wishes to spectate someone else. Requires RegisterUriScheme to be called.
                client.OnJoinRequested += OnJoinRequested;                      //Called when someone else has requested to join this client.

                //Before we send a initial presence, we will generate a random "game ID" for this example.
                // For a real game, this "game ID" can be a unique ID that your Match Maker / Master Server generates.
                // This is used for the Join / Specate feature. This can be ignored if you do not plan to implement that feature.
                presence.Secrets = new Secrets()
                {
                    //These secrets should contain enough data for external clients to be able to know which
                    // game to connect too. A simple approach would be just to use IP address, but this is highly discouraged
                    // and can leave your players vulnerable!
                    JoinSecret     = "join_myuniquegameid",
                    SpectateSecret = "spectate_myuniquegameid"
                };

                //We also need to generate a initial party. This is because Join requires the party to be created too.
                // If no party is set, the join feature will not work and may cause errors within the discord client itself.
                presence.Party = new Party()
                {
                    ID   = Secrets.CreateFriendlySecret(new Random()),
                    Size = 1,
                    Max  = 4
                };

                //Give the game some time so we have a nice countdown
                presence.Timestamps = new Timestamps()
                {
                    Start = DateTime.UtcNow,
                    End   = DateTime.UtcNow + TimeSpan.FromSeconds(15)
                };

                //Subscribe to the join / spectate feature.
                //These require the RegisterURI to be true.
                client.SetSubscription(EventType.Join | EventType.Spectate | EventType.JoinRequest);        //This will alert us if discord wants to join a game

                //Set some new presence to tell Discord we are in a game.
                // If the connection is not yet available, this will be queued until a Ready event is called,
                // then it will be sent. All messages are queued until Discord is ready to receive them.
                client.SetPresence(presence);

                //Initialize the connection. This must be called ONLY once.
                //It must be called before any updates are sent or received from the discord client.
                client.Initialize();

                //Start our main loop. In a normal game you probably don't have to do this step.
                // Just make sure you call .Invoke() or some other dequeing event to receive your events.
                MainLoop();
            }
        }
Ejemplo n.º 26
0
        void SetStatus(DiscordState state, string details = null, string secret = null, int?players = null, int?slots = null)
        {
            if (currentState == state)
            {
                return;
            }

            if (instance == null)
            {
                return;
            }

            string   stateText;
            DateTime?timestamp = null;
            Party    party     = null;
            Secrets  secrets   = null;

            switch (state)
            {
            case DiscordState.InMenu:
                stateText = "In menu";
                break;

            case DiscordState.InMapEditor:
                stateText = "In Map Editor";
                break;

            case DiscordState.InSkirmishLobby:
                stateText = "In Skirmish Lobby";
                break;

            case DiscordState.InMultiplayerLobby:
                stateText = "In Multiplayer Lobby";
                timestamp = DateTime.UtcNow;
                party     = new Party
                {
                    ID   = Secrets.CreateFriendlySecret(new Random()),
                    Size = players.Value,
                    Max  = slots.Value
                };
                secrets = new Secrets
                {
                    JoinSecret = secret
                };
                break;

            case DiscordState.PlayingMultiplayer:
                stateText = "Playing Multiplayer";
                timestamp = DateTime.UtcNow;
                break;

            case DiscordState.PlayingCampaign:
                stateText = "Playing Campaign";
                timestamp = DateTime.UtcNow;
                break;

            case DiscordState.WatchingReplay:
                stateText = "Watching Replay";
                timestamp = DateTime.UtcNow;
                break;

            case DiscordState.PlayingSkirmish:
                stateText = "Playing Skirmish";
                timestamp = DateTime.UtcNow;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(state), state, null);
            }

            var richPresence = new RichPresence
            {
                Details = details,
                State   = stateText,
                Assets  = new Assets
                {
                    LargeImageKey  = "large",
                    LargeImageText = Game.ModData.Manifest.Metadata.Title,
                },
                Timestamps = timestamp.HasValue ? new Timestamps(timestamp.Value) : null,
                Party      = party,
                Secrets    = secrets
            };

            client.SetPresence(richPresence);
            currentState = state;
        }
Ejemplo n.º 27
0
        public static void Update()
        {
            rpcClient?.Invoke();

            if (Main.menuMode == MenuModeID.HowToPlay)
            {
                _rpc.Details = $"Viewing how to Play";
            }
            if (Main.menuMode == MenuModeID.SlenderChangeLogs)
            {
                _rpc.Details = $"Looking at the Change Logs";
            }
            if (!Main.gameMenu)
            {
                if (RPCPlayer != null)
                {
                    if (!RPCPlayer.dead)
                    {
                        _rpc.Assets = new Assets()
                        {
                            LargeImageKey  = "spookyterraria",
                            SmallImageKey  = "paper",
                            SmallImageText = $"{SpookyPlayer.Pages} of 8 Pages",
                            LargeImageText = $"Player Name: {RPCPlayer.name}"
                        };
                        _rpc.Details = "In World - Collecting Pages";
                    }
                    else
                    {
                        _rpc.Assets = new Assets()
                        {
                            LargeImageKey  = "spookyterraria",
                            SmallImageKey  = "paper",
                            SmallImageText = $"Player is dead: Had {SpookyPlayer.Pages} out of 8 pages",
                            LargeImageText = $"{RPCPlayer.name}"
                        };
                        _rpc.Details = "Player Dead, Game Over";
                    }
                }
                else
                {
                    _rpc.Assets = new Assets()
                    {
                        LargeImageKey  = "spookyterraria",
                        SmallImageKey  = "paper",
                        SmallImageText = $"null (please report this)",
                        LargeImageText = $"null (please report this)"
                    };
                }
            }
            else if (Main.menuMode != MenuModeID.HowToPlay &&
                     Main.menuMode != MenuModeID.SlenderChangeLogs &&
                     Main.menuMode != MenuModeID.SlenderModesMenu)
            {
                _rpc.Assets = new Assets()
                {
                    LargeImageKey  = "spookyterraria",
                    LargeImageText = $"Username: {Steamworks.SteamFriends.GetPersonaName()}"
                };
                _rpc.Details = $"Browsing the Menus";
                _rpc.State   = "Playing the Spooky Terraria Mod";
            }
            if (!rpcClient.IsDisposed)
            {
                rpcClient?.SetPresence(_rpc);
            }
        }
Ejemplo n.º 28
0
        public void Main(object sender, EventArgs e)
        {
            string CurVehicle;

            if (Exists(Player.Character.CurrentVehicle))
            {
                CurVehicle = "In Vehicle: " + TextInfo.ToTitleCase(Player.Character.CurrentVehicle.Name.ToLower());
            }
            else
            {
                CurVehicle = "On Foot";
            }

            string CurWeapon     = Player.Character.Weapons.Current.Type.ToString();
            string CurWeaponIcon = Player.Character.Weapons.Current.Type.ToString().ToLower();

            if (CurWeapon == "Rifle_AK47")
            {
                CurWeapon = "AK-47";
            }
            else if (CurWeapon == "Rifle_M4")
            {
                CurWeapon = "M4";
            }
            else if (CurWeapon == "Shotgun_Baretta")
            {
                CurWeapon = "Beretta 1201";
            }
            else if (CurWeapon == "Melee_BaseballBat")
            {
                CurWeapon = "Baseball Bat";
            }
            else if (CurWeapon == "Shotgun_Basic")
            {
                CurWeapon = "Shotgun";
            }
            else if (CurWeapon == "SniperRifle_Basic")
            {
                CurWeapon = "Sniper Rifle";
            }
            else if (CurWeapon == "Handgun_DesertEagle")
            {
                CurWeapon = "Desert Eagle";
            }
            else if (CurWeapon == "Handgun_Glock")
            {
                CurWeapon = "Glock 17";
            }
            else if (CurWeapon == "Thrown_Grenade")
            {
                CurWeapon = "Grenade";
            }
            else if (CurWeapon == "Melee_Knife")
            {
                CurWeapon = "Knife";
            }
            else if (CurWeapon == "Thrown_Molotov")
            {
                CurWeapon = "Molotov Cocktail";
            }
            else if (CurWeapon == "SMG_MP5")
            {
                CurWeapon = "MP5";
            }
            else if (CurWeapon == "Heavy_RocketLauncher")
            {
                CurWeapon = "Rocket Launcher";
            }
            else if (CurWeapon == "SniperRifle_M40A1")
            {
                CurWeapon = "M40A1";
            }
            else if (CurWeapon == "SMG_Uzi")
            {
                CurWeapon = "Uzi";
            }
            else
            {
                CurWeapon = "Unarmed";
            }

            string CurWantedLevel;

            if (Player.WantedLevel == 1)
            {
                CurWantedLevel = "Wanted Level: 1 Star";
            }
            else if (Player.WantedLevel == 0)
            {
                CurWantedLevel = "Not Wanted";
            }
            else
            {
                CurWantedLevel = "Wanted Level: " + Player.WantedLevel.ToString() + " Stars";
            }

            client.SetPresence(new RichPresence()
            {
                Details = "Money: $" + Player.Money.ToString() + " | " + CurVehicle,
                State   = CurWantedLevel + " | " + CurWeapon,
                Assets  = new Assets()
                {
                    LargeImageKey  = "game_icon",
                    LargeImageText = "On Street: " + World.GetStreetName(Player.Character.Position).ToString(),
                    SmallImageKey  = CurWeaponIcon,
                    SmallImageText = CurWeapon
                }
            });
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            if (File.Exists("settings.json"))
            {
                if (!File.Exists("settings.json"))
                {
                    return;
                }
                var json = File.ReadAllText("settings.json");

                DataSet   dataSet      = JsonConvert.DeserializeObject <DataSet>(json);
                DataTable dataSettings = dataSet.Tables["Custom Status"];
                foreach (DataRow row in dataSettings.Rows)
                {
                    textBox1.Text     = (string)row["clientID"];
                    textBox2.Text     = (string)row["details"];
                    textBox3.Text     = (string)row["state"];
                    textBox4.Text     = (string)row["largeImageName"];
                    textBox5.Text     = (string)row["largeimageText"];
                    textBox6.Text     = (string)row["smallimageName"];
                    checkBox2.Checked = (bool)Convert.ToBoolean(row["autoStartChk"]);
                }

                /*
                 * string json = File.ReadAllText("settings.json");
                 * Dictionary<string, string> details = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
                 * /*
                 * var clientID1 = details["clientID"]);
                 * var details1 = details["details"]);
                 * var state1 = details["state"]);
                 * var largeImageName1 = details["largeImageName"]);
                 * var largeimageText1 = details["largeimageText"]);
                 * var smallimageName1 = details["smallimageName"]);*/
                // /account/login.aspx

                /*
                 * textBox1.Text = details["clientID"];
                 * textBox2.Text = details["details"];
                 * textBox3.Text = details["state"];
                 * textBox4.Text = details["largeImageName"];
                 * textBox5.Text = details["largeimageText"];
                 * textBox6.Text = details["smallimageName"];
                 * checkBox2.Checked = Convert.ToBoolean(details["autoStartChk"]);
                 * labelStatus.Text = "Status: STOPPED";
                 */
            }
            if (checkBox2.Checked)
            {
                var json = File.ReadAllText("settings.json");

                DataSet   dataSet      = JsonConvert.DeserializeObject <DataSet>(json);
                DataTable dataSettings = dataSet.Tables["Custom Status"];
                foreach (DataRow row in dataSettings.Rows)
                {
                    textBox1.Text     = (string)row["clientID"];
                    textBox2.Text     = (string)row["details"];
                    textBox3.Text     = (string)row["state"];
                    textBox4.Text     = (string)row["largeImageName"];
                    textBox5.Text     = (string)row["largeimageText"];
                    textBox6.Text     = (string)row["smallimageName"];
                    checkBox2.Checked = (bool)Convert.ToBoolean(row["autoStartChk"]);
                }



                client           = new DiscordRpcClient(textBox1.Text.ToString());
                isEnabled        = true;
                labelStatus.Text = "Status: RUNNING";
                if (String.IsNullOrWhiteSpace(textBox1.Text))
                {
                    MessageBox.Show("Client ID is empty!");
                    return;
                }
                client = new DiscordRpcClient(textBox1.Text);
                // You get a client id by creating an app from https://discord.com/developers/applications/


                //Connect to the RPC
                client.Initialize();

                //Set the rich presence
                //Call this as many times as you want and anywhere in your code.
                client.SetPresence(new RichPresence()
                {
                    Details = textBox2.Text.ToString(),
                    State   = textBox3.Text.ToString(),
                    Assets  = new Assets()
                    {
                        LargeImageKey  = textBox4.Text.ToString(),
                        LargeImageText = textBox5.Text.ToString(),
                        SmallImageKey  = textBox6.Text.ToString()
                    }
                });
                if (checkBox1.Checked)
                {
                    client.UpdateStartTime();
                }
            }
        }
Ejemplo n.º 30
0
 public void SetPresence(DiscordRPC.RichPresence newPresence)
 {
     this.CreateClient();
     RpcClient.SetPresence(newPresence);
 }