Exemplo n.º 1
0
 private void Disconnect()
 {
     DiscordRpc.Shutdown();
     SetStatus("Disconnected");
     _tickTimer.Dispose();
     _tickTimer = null;
 }
Exemplo n.º 2
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            // [DISCORD RICH PRESENCE]
            DiscordRpc.Shutdown();

            Application.Exit(); //this code is for the x button to close the entire application, including other open forms
        }
        /// <summary>
        ///     Shutdown discord controller.
        /// </summary>
        public static void Shutdown(bool dontSaveAnything)
        {
            //Debug.Log($"JEMDiscordController.Shutdown isInitialized:{IsInitialized} dontSaveAnything:{dontSaveAnything}");

            if (!IsInitialized)
            {
                return;
            }
            IsInitialized = false;

            // Disconnect update.
            EditorApplication.update -= Update;

            // Save timestamp.
            SaveTimestamp(dontSaveAnything);
            if (IsConnected)
            {
                Debug.Log("Discord: shutdown");
                DiscordRpc.Shutdown();
            }

            // Save last discord initialization time.
            EditorPrefs.SetString("jem.discordRPC.lastInitialization", DateTime.Now.ToString(CultureInfo.InvariantCulture));
            IsConnected = false;
        }
Exemplo n.º 4
0
 void OnApplicationQuit()
 {
     debug("shutdown");
     #if UNITY_STANDALONE_WIN
     DiscordRpc.Shutdown();
     #endif
 }
Exemplo n.º 5
0
 public static void OnApplicationQuit()
 {
     if (!running)
     {
         return;
     }
     DiscordRpc.Shutdown();
 }
 private void OnDisable()
 {
     DiscordRpc.Shutdown();
     // ReSharper disable DelegateSubtraction
     _gameInfo.OnStateChange  -= StateChange;
     _bombInfo.OnBombExploded -= BombExploded;
     // ReSharper restore DelegateSubtraction
 }
Exemplo n.º 7
0
 private static void OnGameExit()
 {
     if (DiscordRpc.Initialize == null)
     {
         return;
     }
     DiscordRpc.Shutdown();
 }
Exemplo n.º 8
0
 private static void Disable()
 {
     if (EditorPrefs.GetBool("enabled"))
     {
         //If "enabled" is true that means we need to shut it down
         EditorPrefs.SetBool("enabled", false);
         DiscordRpc.Shutdown();
         Debug.Log("Unity Editor Rich Presence has been disabled");
     }
 }
 public void Dispose()
 {
     try
     {
         DiscordRpc.Shutdown();
     }
     catch (Exception ex)
     {
         Trace.TraceWarning("Exception shutting down discord-RPC: {0}", ex);
     }
 }
Exemplo n.º 10
0
 private static void Exit(string message = "")
 {
     DiscordRpc.Shutdown();
     #if !asdf
     MemoryHandler.Instance.UnsetProcess();
     #endif
     if (message != "")
     {
         MessageBox.Show(message);
     }
     Application.Exit();
 }
Exemplo n.º 11
0
        public static void Discord_RPC_Shutdown()
        {
            DiscordRpc.RichPresence discordPresence = new DiscordRpc.RichPresence();
            discordPresence.details       = "";
            discordPresence.state         = "";
            discordPresence.largeImageKey = "";

            DiscordRpc.UpdatePresence(ref discordPresence);
            DiscordRpc.Shutdown();
            bEnable      = false;
            bInitialized = false;
        }
Exemplo n.º 12
0
        private void Application_Exit(object sender, ExitEventArgs e)
        {
            Debug.WriteLine("Application_Exit");
            if (bEnable)
            {
                DiscordRpc.RichPresence discordPresence = new DiscordRpc.RichPresence();
                discordPresence.details       = "";
                discordPresence.state         = "";
                discordPresence.largeImageKey = "";

                DiscordRpc.UpdatePresence(ref discordPresence);
                DiscordRpc.Shutdown();
            }
        }
Exemplo n.º 13
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (e.CloseReason == CloseReason.UserClosing)
     {
         this.WindowState = FormWindowState.Minimized;
         e.Cancel         = true;
     }
     else
     {
         NotifyIcon.Visible = false;
         DiscordRpc.Shutdown();
         SaveSettings();
     }
 }
Exemplo n.º 14
0
        private static void ClearPresence()
        {
            if (global.presence == null)
            {
                // uninitialized
                return;
            }

            global.presence.FreeMem();
            global.presence = null;

            DiscordRpc.ClearPresence();
            DiscordRpc.Shutdown();
        }
Exemplo n.º 15
0
        private void Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            Properties.Settings.Default.Lanuguage              = language.SelectedIndex;
            Properties.Settings.Default.Username               = userNameTextbox.Text;
            Properties.Settings.Default.Password               = userPassTextbox.Text;
            Properties.Settings.Default.DiscordRPC_Active      = DiscordRPC_Active.Checked;
            Properties.Settings.Default.DiscordRPC_Description = DiscordRPC_Description.Text;

            Properties.Settings.Default.Save();

            DiscordRpc.Shutdown();

            Application.Exit();
        }
Exemplo n.º 16
0
 private void button3_Click_1(object sender, EventArgs e)
 {
     if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0 || textBox4.Text.Length == 0 || textBox5.Text.Length == 0 || textBox6.Text.Length == 0)
     {
         MessageBox.Show("Put a valid informations!");
         richTextBox1.Text = "[ERROR] Failed to shutdown, reason : No valid information";
     }
     else
     {
         DiscordRpc.Shutdown();
         richTextBox1.Text = "[LOGS] RichPresence has been disconnected!";
         MessageBox.Show("RichPresence is disconnected");
     }
 }
Exemplo n.º 17
0
        public void OnClick(bool disconnect)
        {
            if (disconnect)
            {
                Debug.Log("Discord: on click - shutdown");
                DiscordRpc.Shutdown();
            }
            else
            {
                Debug.Log("Discord: on click!");
                clickCounter++;

                presence.details = string.Format("Button clicked {0} times", clickCounter);

                DiscordRpc.UpdatePresence(ref presence);
            }
        }
Exemplo n.º 18
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            if (CurrentApplication == null)
            {
                return;
            }

            DiscordRpc.Shutdown();
            DiscordRpc.Initialize(CurrentApplication.appId, ref handlers, false, string.Empty);

            DiscordRpc.RichPresence richPresence = new DiscordRpc.RichPresence();
            richPresence.details = detailsTextBox.Text;
            richPresence.state   = stateTextBox.Text;

            if (largeIconBox.SelectedIndex > 0)
            {
                richPresence.largeImageKey  = (string)largeIconBox.SelectedItem;
                richPresence.largeImageText = CurrentApplication.GetLargeIconText(largeIconBox.SelectedIndex);
            }
            if (smallIconBox.SelectedIndex > 0)
            {
                richPresence.smallImageKey  = (string)smallIconBox.SelectedItem;
                richPresence.smallImageText = CurrentApplication.GetSmallIconText(smallIconBox.SelectedIndex);
            }

            if (partyCheckBox.Checked)
            {
                richPresence.partySize = (int)partySizeNumeric.Value;
                richPresence.partyMax  = (int)partyMaxNumeric.Value;
            }

            if (timeCheckBox.Checked)
            {
                if (startTimeRadioButton.Checked)
                {
                    richPresence.startTimestamp = (long)dateTimePicker.Value.ToUniversalTime().Subtract(unixDateTimeStart).TotalSeconds;
                }
                else if (endTimeRadioButton.Checked)
                {
                    richPresence.endTimestamp = (long)dateTimePicker.Value.ToUniversalTime().Subtract(unixDateTimeStart).TotalSeconds;
                }
            }

            DiscordRpc.UpdatePresence(richPresence);
        }
Exemplo n.º 19
0
 void UpdatePresence()
 {
     if (DiscordRPC_Active.Checked)
     {
         DiscordRpc.EventHandlers handlers = new DiscordRpc.EventHandlers();
         DiscordRpc.RichPresence  presence = new DiscordRpc.RichPresence();
         DiscordRpc.Initialize("738137354589437972", ref handlers, true, null);
         presence.details        = DiscordRPC_Description.Text;
         presence.largeImageKey  = Properties.Settings.Default.DiscordRPC_Image;
         presence.largeImageText = "Seafight";
         presence.startTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
         DiscordRpc.UpdatePresence(ref presence);
     }
     else
     {
         DiscordRpc.Shutdown();
     }
 }
Exemplo n.º 20
0
 public void TogglePresence(Vegas vegas)
 {
     if (PresenceEnabled)
     {
         RichPresenceToggle rpct = new RichPresenceToggle(false);
         rpct.ShowDialog(vegas.MainWindow);
         idleTimer.Stop();
         PresenceEnabled = false;
         DiscordRpc.Shutdown();
     }
     else
     {
         RichPresenceToggle rpct = new RichPresenceToggle(true);
         rpct.ShowDialog(vegas.MainWindow);
         idleTimer.Start();
         PresenceEnabled = true;
         resetPresence(ref presence, vegas);
         DiscordRpc.Initialize("434711433112977427", ref callbacks, true, string.Empty);
         UpdateTrackNumber(vegas);
     }
 }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            // Register callbacks
            var Callbacks = new DiscordRpc.EventHandlers();

            Callbacks.readyCallback         = ReadyCallback;
            Callbacks.disconnectedCallback += DisconnectedCallback;
            Callbacks.errorCallback        += ErrorCallback;

            Task.Run((Action) delegate
            {
                // Connect (Using the 'send-presence.c' id for demo MAKE_YOUR_OWN)
                DiscordRpc.Initialize("345229890980937739", ref Callbacks, true, null);

                // Register status
                var Status     = new DiscordRpc.RichPresence();
                Status.details = "Doing a thing!";

                // Update status
                DiscordRpc.UpdatePresence(ref Status);

                while (Continue)
                {
                    // Callbacks
                    DiscordRpc.RunCallbacks();
                    System.Threading.Thread.Sleep(100);
                }
            });

            while (Continue)
            {
                System.Threading.Thread.Sleep(100);
            }

            // Clean up
            DiscordRpc.Shutdown();
        }
Exemplo n.º 22
0
 void OnDisable()
 {
     Debug.Log("Discord: shutdown");
     DiscordRpc.Shutdown();
 }
        /// <summary>
        /// Stop RPC.
        /// </summary>
        public void Shutdown()
        {
            DiscordRpc.Shutdown();

            this.SetStatusBarMessage("Shuted down.");
        }
Exemplo n.º 24
0
 public void OnDisable()
 {
     Debug.Log("Discord: shutdown");
     DiscordRpc.ClearPresence();
     DiscordRpc.Shutdown();
 }
Exemplo n.º 25
0
 private static void OnGameExit()
 {
     DiscordRpc.Shutdown();
 }
Exemplo n.º 26
0
            private static void WorkerLoop()
            {
                string lib = null;

                if (!string.IsNullOrEmpty(CoreModule.Settings.DiscordLib))
                {
                    lib = CoreModule.Settings.DiscordLib;
                }
                else if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                {
                    lib = "discord-rpc.dll";
                }
                else if (Environment.OSVersion.Platform == PlatformID.MacOSX)
                {
                    lib = "libdiscord-rpc.dylib";
                    // FIXME: macOS doesn't see libdiscord-rpc.dylib wherever Celeste.exe is.
                }
                else if (Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    lib = "libdiscord-rpc.so";
                }

                if (!string.IsNullOrEmpty(lib))
                {
                    DynDll.Mappings["discord-rpc"] = new DynDllMapping()
                    {
                        ResolveAs = lib
                    }
                }
                ;

                string discordID = "430794114037055489";

                if (!string.IsNullOrEmpty(CoreModule.Settings.DiscordID))
                {
                    discordID = CoreModule.Settings.DiscordID;
                }

                try {
                    typeof(DiscordRpc).ResolveDynDllImports();
                } catch {
                }
                if (DiscordRpc.Initialize == null)
                {
                    Logger.Log(LogLevel.Info, "discord", "Discord_Initialize not found - skipping Discord Rich Presence.");
                    return;
                }

                Logger.Log(LogLevel.Verbose, "discord", $"Discord_Initialize found - initializing Discord Rich Presence, app ID {discordID}");

                DiscordHandlers.readyCallback        += OnDiscordReady;
                DiscordHandlers.disconnectedCallback += OnDiscordDisconnect;
                DiscordHandlers.errorCallback        += OnDiscordError;

                DiscordRpc.Initialize.Invoke(discordID, ref DiscordHandlers, true, "504230");
                DiscordRpc.UpdatePresence(DiscordPresence);

                while (Worker != null)
                {
                    if (Queue.Count == 0)
                    {
                        Thread.Yield();
                        continue;
                    }

                    Action cb;
                    lock (Queue)
                        cb = Queue.Dequeue();
                    cb?.Invoke();
                }

                DiscordRpc.Shutdown();
            }
Exemplo n.º 27
0
 public void Shutdown()
 {
     dummyDocker.Dispose();
     DiscordRpc.Shutdown();
 }
Exemplo n.º 28
0
 void OnDestroy()
 {
     DiscordRpc.Shutdown();
 }
Exemplo n.º 29
0
 public void Shutdown()
 {
     Debug.Log("Shutting down Discord Rich Presence");
     DiscordRpc.Shutdown();
 }
Exemplo n.º 30
0
 static void TerminateProgram()
 {
     notifyIcon.Visible = false;
     DiscordRpc.Shutdown();
     Application.Exit();
 }