private void BtnSaveSettings(object sender, RoutedEventArgs e) { try { Lazydata.ParrotData.UseSto0ZDrivingHack = ChkUseSto0ZCheckBox.IsChecked != null && ChkUseSto0ZCheckBox.IsChecked.Value; Lazydata.ParrotData.StoozPercent = (int)sTo0zZonePercent.Value; if (ChkFullAxisGas.IsChecked.HasValue) { Lazydata.ParrotData.FullAxisGas = ChkFullAxisGas.IsChecked.Value; } if (ChkReverseAxisGas.IsChecked.HasValue) { Lazydata.ParrotData.ReverseAxisGas = ChkReverseAxisGas.IsChecked.Value; } if (ChkFullAxisBrake.IsChecked.HasValue) { Lazydata.ParrotData.FullAxisBrake = ChkFullAxisBrake.IsChecked.Value; } if (ChkReverseAxisBrake.IsChecked.HasValue) { Lazydata.ParrotData.ReverseAxisBrake = ChkReverseAxisBrake.IsChecked.Value; } if (GunSensitivityPlayer1.Value != null) { Lazydata.ParrotData.GunSensitivityPlayer1 = (int)GunSensitivityPlayer1.Value; } if (GunSensitivityPlayer2.Value != null) { Lazydata.ParrotData.GunSensitivityPlayer2 = (int)GunSensitivityPlayer2.Value; } Lazydata.ParrotData.SaveLastPlayed = ChkSaveLastPlayed.IsChecked.Value; Lazydata.ParrotData.UseDiscordRPC = ChkUseDiscordRPC.IsChecked.Value; Lazydata.ParrotData.CheckForUpdates = ChkCheckForUpdates.IsChecked.Value; Lazydata.ParrotData.SilentMode = ChkSilentMode.IsChecked.Value; Lazydata.ParrotData.ConfirmExit = ChkConfirmExit.IsChecked.Value; Lazydata.ParrotData.DownloadIcons = ChkDownloadIcons.IsChecked.Value; Lazydata.ParrotData.UiDisableHardwareAcceleration = ChkUiDisableHardwareAcceleration.IsChecked.Value; Lazydata.ParrotData.UiColour = UiColour.SelectedItem.ToString(); Lazydata.ParrotData.UiDarkMode = ChkUiDarkMode.IsChecked.Value; Lazydata.ParrotData.UiHolidayThemes = ChkUiHolidayThemes.IsChecked.Value; DiscordRPC.StartOrShutdown(); JoystickHelper.Serialize(); Application.Current.Windows.OfType <MainWindow>().Single().ShowMessage(string.Format(Properties.Resources.SuccessfullySaved, "ParrotData.xml")); _contentControl.Content = _library; } catch (Exception exception) { MessageBoxHelper.ErrorOK(string.Format(Properties.Resources.ErrorCantSaveParrotData, exception.ToString())); } }
public static void UpdateRichPresence(string details = null) { if (!DiscordEnabled) { DiscordRPC.Shutdown(); controller = null; } else { if (controller == null) { InitRichPresence(); } details = ""; //don't like current imp. string detailsLine = string.IsNullOrEmpty(details) ? ToolkitSettings.CustomStateText : details; controller.presence.state = DiscordStateEnabled ? detailsLine : null; string vString = Debugger.IsAttached ? "DEBUG " : "RELEASE "; vString += Version; controller.presence.details = DiscordDetailsEnabled ? vString : null; controller.presence.startTimestamp = DiscordElapsedTimeEnabled ? ElapsedTime : 0; DiscordRPC.UpdatePresence(ref controller.presence); } }
static void Main(string[] args) { Console.WriteLine("Hello from C#!", Console.LogLevel.Info); Console.WriteLine(string.Format("args = [{0}]", string.Join(",", args)), Console.LogLevel.Info); Console.AddCommand("test", TestCommand); Console.Execute("print t"); Events.Add <Input.KeyEvent>(KeyCallback); Events.Add <TestEvent>(TestEventCallback); DiscordEventHandler discordEventHandler = new DiscordEventHandler(); DiscordRPC.Init("424302031822520320", ref discordEventHandler, true, "480"); DiscordPresence presence = new DiscordPresence(); presence.details = "Jazz weeb"; presence.state = ":3c:"; presence.largeImageKey = "icon-large"; presence.smallImageKey = "icon-small"; DiscordRPC.UpdatePresence(ref presence); SteamworksClient = new Client(480); }
private void BtnSaveSettings(object sender, RoutedEventArgs e) { try { Lazydata.ParrotData.UseSto0ZDrivingHack = ChkUseSto0ZCheckBox.IsChecked != null && ChkUseSto0ZCheckBox.IsChecked.Value; Lazydata.ParrotData.StoozPercent = (int)sTo0zZonePercent.Value; if (ChkFullAxisGas.IsChecked.HasValue) { Lazydata.ParrotData.FullAxisGas = ChkFullAxisGas.IsChecked.Value; } if (ChkReverseAxisGas.IsChecked.HasValue) { Lazydata.ParrotData.ReverseAxisGas = ChkReverseAxisGas.IsChecked.Value; } if (ChkFullAxisBrake.IsChecked.HasValue) { Lazydata.ParrotData.FullAxisBrake = ChkFullAxisBrake.IsChecked.Value; } if (ChkReverseAxisBrake.IsChecked.HasValue) { Lazydata.ParrotData.ReverseAxisBrake = ChkReverseAxisBrake.IsChecked.Value; } if (GunSensitivityPlayer1.Value != null) { Lazydata.ParrotData.GunSensitivityPlayer1 = (int)GunSensitivityPlayer1.Value; } if (GunSensitivityPlayer2.Value != null) { Lazydata.ParrotData.GunSensitivityPlayer2 = (int)GunSensitivityPlayer2.Value; } Lazydata.ParrotData.SaveLastPlayed = ChkSaveLastPlayed.IsChecked.Value; Lazydata.ParrotData.UseDiscordRPC = ChkUseDiscordRPC.IsChecked.Value; Lazydata.ParrotData.CheckForUpdates = ChkCheckForUpdates.IsChecked.Value; Lazydata.ParrotData.SilentMode = ChkSilentMode.IsChecked.Value; Lazydata.ParrotData.ConfirmExit = ChkConfirmExit.IsChecked.Value; Lazydata.ParrotData.DownloadIcons = ChkDownloadIcons.IsChecked.Value; Lazydata.ParrotData.UiDisableHardwareAcceleration = ChkUiDisableHardwareAcceleration.IsChecked.Value; Lazydata.ParrotData.UiColour = UiColour.SelectedItem.ToString(); Lazydata.ParrotData.UiDarkMode = ChkUiDarkMode.IsChecked.Value; DiscordRPC.StartOrShutdown(); JoystickHelper.Serialize(); MessageBox.Show("Successfully saved ParrotData.xml!"); } catch (Exception exception) { MessageBox.Show($"Exception happened during ParrotData.xml saving!{Environment.NewLine}{Environment.NewLine}{exception}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void UpdatePausedPresence() { presence.state = ""; presence.details = ""; presence.largeImageKey = ""; presence.largeImageText = ""; DiscordRPC.UpdatePresence(ref presence); }
public override void OnApplicationStart() { ConsoleUtil.SetTitle("Funeral Client V2 = Developed by Yaekith"); Configuration.CheckExistence(); DiscordRPC.Start(); Modules.Add(new GeneralHandlers()); ConsoleUtil.Info("Waiting for VRChat UI Manager to Initialise.."); }
void OnApplicationQuit() { WasQuitRequested = true; Properties.Save(); DiscordRPC.Dispose(); }
/// <summary> /// Shuts down the Discord integration then quits the program, terminating any threads that may still be running. /// </summary> public static void SafeExit() { if (ParrotData.UseDiscordRPC && File.Exists("discord-rpc.dll")) { DiscordRPC.Shutdown(); } Environment.Exit(0); }
public static void ProcessRunningStatusUpdated(bool isGameRunning) { if (!isGameRunning) { DiscordRPC.Shutdown(); rpcInitialized = false; } }
private void InitialiseDiscord() { DiscordRPC.DiscordEventHandlers handlers = new DiscordRPC.DiscordEventHandlers(); handlers.readyCallback = HandleReadyCallback; handlers.errorCallback = HandleErrorCallback; handlers.disconnectedCallback = HandleDisconnectedCallback; DiscordRPC.Initialize("381981355539693579", ref handlers, true, null); }
public static void Start() { DiscordRPC.EventHandlers eventHandler = default(DiscordRPC.EventHandlers); DiscordRPC.Initialize("702340191289081857", ref eventHandler, false, null); Started = true; }
private void BtnSaveSettings(object sender, RoutedEventArgs e) { try { if (_parrotData == null) { _parrotData = new ParrotData(); Lazydata.ParrotData = _parrotData; } _parrotData.UseSto0ZDrivingHack = ChkUseSto0ZCheckBox.IsChecked != null && ChkUseSto0ZCheckBox.IsChecked.Value; _parrotData.StoozPercent = (int)sTo0zZonePercent.Value; if (ChkFullAxisGas.IsChecked.HasValue) { _parrotData.FullAxisGas = ChkFullAxisGas.IsChecked.Value; } if (ChkReverseAxisGas.IsChecked.HasValue) { _parrotData.ReverseAxisGas = ChkReverseAxisGas.IsChecked.Value; } if (ChkFullAxisBrake.IsChecked.HasValue) { _parrotData.FullAxisBrake = ChkFullAxisBrake.IsChecked.Value; } if (ChkReverseAxisBrake.IsChecked.HasValue) { _parrotData.ReverseAxisBrake = ChkReverseAxisBrake.IsChecked.Value; } if (GunSensitivityPlayer1.Value != null) { _parrotData.GunSensitivityPlayer1 = (int)GunSensitivityPlayer1.Value; } if (GunSensitivityPlayer2.Value != null) { _parrotData.GunSensitivityPlayer2 = (int)GunSensitivityPlayer2.Value; } _parrotData.SaveLastPlayed = ChkSaveLastPlayed.IsChecked.Value; _parrotData.UseDiscordRPC = ChkUseDiscordRPC.IsChecked.Value; _parrotData.CheckForUpdates = ChkCheckForUpdates.IsChecked.Value; _parrotData.SilentMode = ChkSilentMode.IsChecked.Value; JoystickHelper.Serialize(_parrotData); DiscordRPC.Shutdown(); string[] psargs = Environment.GetCommandLineArgs(); System.Diagnostics.Process.Start(Application.ResourceAssembly.Location, psargs[0]); Application.Current.Shutdown(); } catch (Exception exception) { MessageBox.Show($"Exception happened during ParrotData.xml saving!{Environment.NewLine}{Environment.NewLine}{exception}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void InitialiseDiscord() { DiscordRPC.DiscordEventHandlers handlers = new DiscordRPC.DiscordEventHandlers(); handlers.readyCallback = HandleReadyCallback; handlers.errorCallback = HandleErrorCallback; handlers.disconnectedCallback = HandleDisconnectedCallback; // lampin's dev app client ID DiscordRPC.Initialize("794444362636328960", ref handlers, true, null); }
private void InitialiseDiscord() { DiscordRPC.DiscordEventHandlers handlers = new DiscordRPC.DiscordEventHandlers(); handlers.readyCallback = HandleReadyCallback; handlers.errorCallback = HandleErrorCallback; handlers.disconnectedCallback = HandleDisconnectedCallback; // Kuunikal's dev app client ID DiscordRPC.Initialize("432174690857910272", ref handlers, true, null); }
/// <summary> /// Shuts down the Discord integration then quits the program, terminating any threads that may still be running. /// </summary> public static void SafeExit() { if (Lazydata.ParrotData.UseDiscordRPC) { DiscordRPC.Shutdown(); } Environment.Exit(0); }
private void InitialiseDiscord() { DiscordRPC.DiscordEventHandlers handlers = new DiscordRPC.DiscordEventHandlers(); handlers.readyCallback = HandleReadyCallback; handlers.errorCallback = HandleErrorCallback; handlers.disconnectedCallback = HandleDisconnectedCallback; // first parameter is the application id from discord dev apps DiscordRPC.Initialize("", ref handlers, true, null); }
private void UpdatePresence(string artist, string track, string album, string duration, Boolean playing) { DiscordRPC.RichPresence presence = new DiscordRPC.RichPresence(); /* Discord RPC doesn't like strings that are only one character long, so I * add a space after each track to make sure it's over 1 character long */ track = Utility.Utf16ToUtf8(track + " "); artist = Utility.Utf16ToUtf8("by " + artist); // Next line, shows the artist // There are characters at the end of each line which Discord renders poorly // (side-effect of Utf8, I guess?) so we need touse a substring instead presence.state = artist.Substring(0, artist.Length - 1); presence.details = track.Substring(0, track.Length - 1); // Hovering over the image presents the album name presence.largeImageText = album; /* Next block is fetching the album image from Discord's * server. They don't allow spaces in their file names, so * we need to convert them into underscores. */ char[] albumArray = album.ToCharArray(); // Create a char array because we can't edit strings // Search album string for spaces for (int i = 0; i < album.Length; i++) { // If the current character is a space, turn it into an underscore // If the current character is an apostrophe, turn it into an underscore (discord doesnt support them and does this too) if (album[i] == ' ' || album[i] == '\'') { albumArray[i] = '_'; } // Otherwise, just continue on else { albumArray[i] = album[i]; } } // Create a string from the array, in lowercase string newAlbum = new String(albumArray).ToLower(); newAlbum = checkAlbumList(newAlbum); // Set the album art to the manipulated album string. presence.largeImageKey = newAlbum; // Set the small image to the playback status. if (playing) { presence.smallImageKey = "playing"; } else { presence.smallImageKey = "paused"; } DiscordRPC.UpdatePresence(ref presence); }
private static void Update() { Presence.details = "Hosting a Server"; Presence.state = $"on {GetIP()}:{GetPort()}"; Presence.largeImageKey = TShock_Presence.Utils.Configuration.LargeImageKey; Presence.largeImageText = $"With {GetPlayers()} player(s)"; Presence.smallImageKey = TShock_Presence.Utils.Configuration.SmallImageKey; Presence.smallImageText = $"Using {GetPluginCount()} plugin(s)"; DiscordRPC.UpdatePresence(Presence); }
private void InitialiseDiscord() { var handlers = new DiscordRPC.DiscordEventHandlers { readyCallback = HandleReadyCallback, errorCallback = HandleErrorCallback, disconnectedCallback = HandleDisconnectedCallback }; DiscordRPC.Initialize(DiscordId, ref handlers, true, null); }
void OnLeftRoom() { Gamemodes.CurrentMode.CleanUp(); PhotonNetwork.SetPlayerCustomProperties(null); DiscordRPC.SetPresence(new Discord.Activity { Details = "Idle..." }); }
void Update() { if (PhotonNetwork.isMasterClient) { Gamemodes.CurrentMode.OnUpdate(); } DiscordRPC.RunCallbacks(); FpsCounter.UpdateCounter(); }
public override void VRChat_OnUiManagerInit() { new MainMenu(GeneralUtils.GetMClientVRButton("MainMenu")); DiscordRPC.Start(); for (int i = 0; i < GeneralUtils.Modules.Count; i++) { GeneralUtils.Modules[i].OnUiLoad(); } }
public void CloseEvent() { if (!GlobalVars.LocalPlayMode) { WriteConfigValues(); } if (GlobalVars.UserConfiguration.DiscordPresence) { DiscordRPC.Shutdown(); } Application.Exit(); }
private void UpdatePlayedPresence(string name, string artist, string duration, int position) { presence.state = artist; name = Utility.Utf16ToUtf8(name); presence.details = name.Substring(0, name.Length - 1); presence.largeImageKey = ""; presence.largeImageText = ""; long now = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; presence.startTimestamp = now - position; DiscordRPC.UpdatePresence(ref presence); }
void Start() { // Load custom textures and audio clips { if (ResourceLoader.TryGetAsset("Custom/Textures/hud.png", out Texture2D hudTextures)) { GameObject backgroundGo = GameObject.Find("Background"); if (backgroundGo != null) { Material uiMat = backgroundGo.GetComponent <UISprite>().material; uiMat.mainTextureScale = hudTextures.GetScaleVector(2048, 2048); uiMat.mainTexture = hudTextures; } } StartCoroutine(CoWaitAndSetParticleTexture()); } GuiController = base.gameObject.AddComponent <Ui.GuiController>(); base.gameObject.AddComponent <MicEF>(); if (!IsFirstInit) { return; } IsFirstInit = false; // Load skin validation service SkinChecker.Init(); // Load name and guild (if possible) FengGameManagerMKII.NameField = PlayerPrefs.GetString("name", string.Empty); if (FengGameManagerMKII.NameField.StripNGUI().Length < 1) { FengGameManagerMKII.NameField = LoginFengKAI.Player.Name; } LoginFengKAI.Player.Guild = PlayerPrefs.GetString("guildname", string.Empty); // Load various features Commands.Load(); Gamemodes.Load(); Properties.Load(); // Load network validation service NetworkChecker.Init(); DiscordRPC.StartTime = GameHelper.CurrentTimeMillis(); DiscordRPC.Initialize(); // Check for an update StartCoroutine(CoCheckForUpdate()); }
private void UpdatePresence(string artist, string trackArtist, string track, string album, string duration, bool playing, int position, int volume, bool handleArtworks = false) { track = Utility.Utf16ToUtf8(track + " "); artist = Utility.Utf16ToUtf8("by " + artist); trackArtist = Utility.Utf16ToUtf8(trackArtist + " - " + album); _rpcPresence.state = Utility.AssureByteSize(trackArtist.Substring(0, trackArtist.Length - 1), 128); _rpcPresence.details = Utility.AssureByteSize(track.Substring(0, track.Length - 1), 128); string largeText = " "; if (string.IsNullOrEmpty(album)) { largeText = track + " "; } else { largeText = album + " "; } _rpcPresence.largeImageText = Utility.AssureByteSize(largeText.Substring(0, largeText.Length - 1), 128); string cleanedAlbum = Utility.SanitizeAlbumName(album); if (handleArtworks) { ProcessArtwork(cleanedAlbum); } long now = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; if (playing) { _rpcPresence.startTimestamp = now - position; string[] durations = duration.Split(':'); long end = System.Convert.ToInt64(durations[0]) * 60 + System.Convert.ToInt64(durations[1]); _rpcPresence.endTimestamp = _rpcPresence.startTimestamp + end; _rpcPresence.smallImageKey = "playing"; _rpcPresence.smallImageText = "Playing at " + volume.ToString() + "%"; } else { _rpcPresence.endTimestamp = 0; _rpcPresence.startTimestamp = 0; _rpcPresence.smallImageKey = "paused"; _rpcPresence.smallImageText = "Paused"; } DiscordRPC.UpdatePresence(ref _rpcPresence); }
private void App_OnStartup(object sender, StartupEventArgs e) { if (SingleApplicationDetector.IsRunning()) { if (MessageBox.Show( "TeknoParrot UI seems to already be running, want me to close it?", "Error", MessageBoxButton.YesNo, MessageBoxImage.Error) == MessageBoxResult.Yes) { TerminateProcesses(); } else { Application.Current.Shutdown(0); return; } } if (File.Exists("DumbJVSManager.exe")) { MessageBox.Show( "Seems you have extracted me to directory of old TeknoParrot, please extract me to a new directory instead!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Shutdown(0); return; } var parrotData = JoystickHelper.DeSerialize(); if (parrotData == null) { StartApp(); return; } if (parrotData.UseDiscordRPC && File.Exists("discord-rpc.dll")) { DiscordRPC.Initialize(APP_ID, IntPtr.Zero, false, null); } if (e.Args.Length != 0) { // Process command args if (HandleArgs(e.Args)) { // Args ok, let's do stuff TeknoParrotUi.Views.GameRunning g = new TeknoParrotUi.Views.GameRunning(_profile, _test, parrotData, _profile.TestMenuParameter, _profile.TestMenuIsExecutable, _profile.TestMenuExtraParameters, _emuOnly); g.Show(); return; } } StartApp(); }
private void UpdatePresence(string artist, string trackArtist, string track, string album, string duration, bool playing, int position, int volume, bool handleArtworks = false) { track = Utility.Utf16ToUtf8(track + " "); artist = Utility.Utf16ToUtf8("by " + artist); trackArtist = Utility.Utf16ToUtf8("by " + trackArtist); _rpcPresence.state = Utility.AssureByteSize(trackArtist.Substring(0, trackArtist.Length - 1), 128); _rpcPresence.details = Utility.AssureByteSize(track.Substring(0, track.Length - 1), 128); string largeText = album + " " + artist; string genre = MbApiInterface.NowPlaying_GetFileTag(MetaDataType.Genre); _rpcPresence.largeImageText = largeText.Substring(0, largeText.Length - 1); if (!string.IsNullOrEmpty(genre)) { _rpcPresence.largeImageText += $" ({genre})"; } string cleanedAlbum = Utility.SanitizeAlbumName(Utility.ValidateEncoding(album)); if (handleArtworks) { ProcessArtwork(cleanedAlbum); } long now = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; if (playing) { _rpcPresence.startTimestamp = now - position; string[] durations = duration.Split(':'); long end = Convert.ToInt64(durations[0]) * 60 + Convert.ToInt64(durations[1]); _rpcPresence.endTimestamp = _rpcPresence.startTimestamp + end; _rpcPresence.smallImageKey = "playing"; _rpcPresence.smallImageText = "Playing at " + volume + "%"; } else { _rpcPresence.endTimestamp = 0; _rpcPresence.startTimestamp = 0; _rpcPresence.smallImageKey = "paused"; _rpcPresence.smallImageText = "Paused"; } DiscordRPC.UpdatePresence(ref _rpcPresence); }
static void Main(string[] args) { Console.WriteLine("Hello! Press ENTER to start Rich Presence."); Console.WriteLine("Don't forget to add this process to \"Discord Games\" if is not working."); Console.ReadLine(); DiscordRPC client = new DiscordRPC(AppID); client.State = "Testing!"; client.Details = "Presence in C#"; Console.WriteLine("Rich Presence should now be working!"); Console.ReadLine(); }
/// <summary> /// When the window is loaded, the update checker is run and DiscordRPC is set /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Loaded(object sender, RoutedEventArgs e) { #if DEBUG Console.WriteLine("Updater disabled because this is a debug build."); #else new Thread(() => { ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Thread.CurrentThread.IsBackground = true; try { string contents; using (var wc = new WebClient()) contents = wc.DownloadString("https://teknoparrot.com/api/version"); if (!UpdateChecker.CheckForUpdate(GameVersion.CurrentVersion, contents)) { return; } if (MessageBox.Show( $"There is a new version available: {contents} (currently using {GameVersion.CurrentVersion}). Would you like to download it?", "New update!", MessageBoxButton.YesNo, MessageBoxImage.Information) != MessageBoxResult.Yes) { return; } Thread.CurrentThread.IsBackground = false; Process.Start("https://teknoparrot.com"); //Application.Current.Dispatcher.Invoke((Action)delegate { // var update = new DownloadWindow("https://teknoparrot.com/files/TeknoParrot_" + contents + ".zip", Environment.GetEnvironmentVariable("TEMP") + "\\teknoparrot.zip", true); // update.ShowDialog(); //}); } catch (Exception) { // Ignored } }).Start(); #endif if (ParrotData.UseDiscordRPC) { DiscordRPC.UpdatePresence(new DiscordRPC.RichPresence { details = "Main Menu", largeImageKey = "teknoparrot", }); } }