public static void UpdateRichPresence(string details = null)
        {
            if (!DiscordEnabled)
            {
                controller?.Shutdown();
                controller = null;
            }
            else
            {
                if (controller == null)
                {
                    InitRichPresence();
                }

                details = ""; //don't like current imp.
                string detailsLine = string.IsNullOrEmpty(details) ? 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;

                controller.UpdatePresence();
            }
        }
        private async void OnEnableApplicationClick(Object sender, EventArgs e)
        {
            this.EnableApplicationButton.IsEnabled = false;
            this.ApplicationIdTextBox.IsEnabled    = false;

            this._appId = this.ApplicationIdTextBox.Text;

            if (!await this.UpdateAssets())
            {
                this.EnableApplicationButton.IsEnabled = true;
                this.ApplicationIdTextBox.IsEnabled    = true;

                return;
            }


            this._controller = new DiscordController();

            this.PresenceControl.IsEnabled      = true;
            this.UpdateAssetsButton.IsEnabled   = true;
            this.UpdatePresenceButton.IsEnabled = true;
            this.RemovePresenceButton.IsEnabled = true;

            this._controller.OnEnable(this._appId);
        }
Example #3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            updateThread = new Thread(UpdateThread);
            updateThread.Start();
            Mouse.ButtonDown += Mouse_ButtonDown;
            Mouse.ButtonUp   += Mouse_ButtonUp;

            lastFrameCollection = DateTime.Now;

            RenderShared.Init(new Vector2(GlobalSettings.Default.renderResolutionX, GlobalSettings.Default.renderResolutionY));

            Logging.Write("Gamepad info:");
            var capabilities = GamePad.GetCapabilities(0);

            if (capabilities.IsConnected)
            {
                Logging.Write(capabilities.GamePadType.ToString());
                GamePad.SetVibration(0, 1f, 1f);
            }
            else
            {
                Logging.Write("Gamepad not connected");
            }
            Init();
            DiscordController.Init();
        }
Example #4
0
    public virtual void log(string message)
    {
        string path = this.GetType().Name;

        path = path.Replace("Controller", "");
        DiscordController.log($"{path}:// {message}");
    }
Example #5
0
        public ChobbylaLocalListener(Chobbyla chobbyla, SteamClientHelper steam, ulong initialConnectLobbyID)
        {
            LastUserAction             = DateTime.Now;
            this.chobbyla              = chobbyla;
            this.steam                 = steam;
            steam.Listener             = this;
            this.initialConnectLobbyID = initialConnectLobbyID;
            serializer                 = new CommandJsonSerializer(Utils.GetAllTypesWithAttribute <ChobbyMessageAttribute>());
            tts = TextToSpeechBase.Create();
            steam.JoinFriendRequest          += SteamOnJoinFriendRequest;
            steam.OverlayActivated           += SteamOnOverlayActivated;
            steam.SteamOnline                += () => { SendSteamOnline(); };
            steam.SteamOffline               += () => { SendSteamOffline(); };
            discordController                 = new DiscordController(GlobalConst.ZeroKDiscordID, GlobalConst.SteamAppID.ToString());
            discordController.OnJoin         += DiscordOnJoinCallback;
            discordController.OnDisconnected += DiscordOnDisconnectedCallback;
            discordController.OnError        += DiscordOnErrorCallback;
            discordController.OnReady        += DiscordOnReadyCallback;
            discordController.OnRequest      += DiscordOnRequestCallback;
            discordController.OnSpectate     += DiscordOnSpectateCallback;

            timer      = new Timer((o) => OnTimerTick(), this, 500, 500);
            idleReport = new Timer((o) => SendCommand(new UserActivity()
            {
                IdleSeconds = WindowsApi.IdleTime.TotalSeconds
            }), this, 5000, 5000);
        }
Example #6
0
        public static bool Prefix(DiscordController __instance)
        {
            bool rpc_overwrite = !Utils.Common.IsInLevelEditor() && Utils.Campaign.IsCustomCampaignLevel(Utils.Common.LevelFile);

            if (G.Sys.GameManager_.IsLevelEditorMode_ || !rpc_overwrite)
            {
                return(true);
            }

            CampaignInfo info = Utils.Campaign.GetCampaign(Utils.Common.LevelFile);

            string rpc_imagekey = G.Sys.GameManager_.ModeID_ == GameModeID.Sprint ? "community_level" : "official_level";
            string rpc_mode     = rpc_imagekey == "community_level" ? "Sprint" : info.Name;

            __instance.presence.state         = "Custom Campaign";
            __instance.presence.largeImageKey = rpc_imagekey;

            __instance.presence.startTimestamp = 0L;
            __instance.presence.endTimestamp   = 0L;
            __instance.presence.partySize      = 0;
            __instance.presence.partyMax       = 0;
            __instance.presence.smallImageKey  = string.Empty;
            __instance.presence.smallImageText = string.Empty;
            __instance.presence.largeImageText = string.Empty;

            if (true || rpc_imagekey == "official_level")
            {
                __instance.presence.details = $"{rpc_mode} | {__instance.GetGameTypeString()}";
            }

            DiscordRpc.UpdatePresence(ref __instance.presence);

            return(false);
        }
Example #7
0
        public IAccountController GetAccount([NotNull] string name)
        {
            if (_accounts.ContainsKey(name))
            {
                return(_accounts[name]);
            }

            var accountOpts = _configuration.Accounts.Single(x => x.Name == name);

            IAccountController account;

            switch (accountOpts.Type)
            {
            case BridgeType.Discord:
                account = new DiscordController(accountOpts, _serviceProvider.GetRequiredService <ILoggerFactory>());
                break;

            case BridgeType.Slack:
                // TODO MKA add slack support
                return(null);

            // account = new SlackController {Name = accountOpts.Name};
            // break;
            default:
                throw new ArgumentOutOfRangeException();
            }

            _accounts.Add(account.Name, account);

            return(account);
        }
    void Start()
    {
        audioCtrlScript = GetComponent <audioControl>();

        dedCam = GameObject.Find("waitingCam");


//	    if (PlayerPrefs.HasKey("coins"))
//	    {
//		    totalCoins = PlayerPrefs.GetInt("coins");
//	    }
//	    PlayerPrefs.SetInt ("coins", totalCoins);

        rb = GetComponent <Rigidbody2D> ();

        SetCheckpoint(false);

        res  = false;
        dead = false;

        dc = GetComponent <DiscordController>();
        dc.updateDetails(String.Format("In Multiplayer | ♥ {1}", SceneManager.GetActiveScene().name.Substring(3), health));
        dc.updateStartTime();
        if (!isServer)
        {
            dedCam.SetActive(false);
        }

        if (!GetComponent <Camera>().GetComponent <NetworkView>().isMine)
        {
            Camera.main.GetComponent <Camera>().enabled = false;
        }
    }
Example #9
0
    void Start()
    {
        dcController = GetComponent <DiscordController>();

        startTimeStamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
        dcController.presence.startTimestamp = startTimeStamp;
        dcController.presence.largeImageKey  = "logo";
    }
Example #10
0
    // Use this for initialization
    void Start()
    {
        if (!PlayerPrefs.HasKey("notFirstLaunch"))
        {
            doFirstLaunch();
        }

        dc = GameObject.Find("DRPCHandler").GetComponent <DiscordController>();
        dc.presence.details       = "In Main Menus";
        dc.presence.largeImageKey = "alejandro";
        dc.updatePresence();
    }
 private static void InitRichPresence()
 {
     controller = new DiscordController();
     controller.Initialize();
     controller.presence = new DiscordRPC.RichPresence()
     {
         smallImageKey  = "",
         smallImageText = "",
         largeImageKey  = "main_art",
         largeImageText = "",
         startTimestamp = ElapsedTime
     };
     UpdateRichPresence("Using the Game Explorer");
 }
Example #12
0
 private void Start()
 {
     this.CompileDictionaries();
     this._discordController = base.GetComponent <DiscordController>();
     UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
     this._discordController.enabled                 = false;
     this._discordController.presence.state          = this.GetSceneDescription();
     this._discordController.presence.details        = "Senpai... will... be... mine...";
     this._discordController.presence.largeImageKey  = "boxart";
     this._discordController.presence.largeImageText = "This might be the game's box art one day!";
     this._discordController.enabled                 = true;
     DiscordRpc.UpdatePresence(this._discordController.presence);
     base.InvokeRepeating("UpdatePresence", 0f, 10f);
 }
 static void Postfix(DiscordController __instance)
 {
     try
     {
         if (G.Sys.NetworkingManager_.IsOnline_)
         {
             __instance.presence.partyMax  = Math.Max(G.Sys.PlayerManager_.TotalPlayerCount_, G.Sys.NetworkingManager_.maxPlayerCount_);
             __instance.presence.partySize = G.Sys.PlayerManager_.TotalPlayerCount_;
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("UpdateNetworkDiscordInfo Patch errors!\n" + e);
     }
 }
 static bool Prefix(DiscordController __instance)
 {
     try
     {
         setPrivateField(__instance, "gameManager_", G.Sys.GameManager_);
         if (BuildType.useAdventureFinal_)
         {
             UnityEngine.Object.Destroy(__instance);
             return(false);
         }
         DiscordRpc.UpdatePresence(ref __instance.presence);
     }
     catch (Exception e)
     {
         Console.WriteLine("Start Patch errors!\n" + e);
     }
     return(false);
 }
Example #15
0
        protected void UpdateThread()
        {
            while (true)
            {
                if (!firstFrameRendered)
                {
                    continue;
                }
                if (Time.currentTime * 1000 - lastUpdate < 1)
                {
                    continue;
                }

                HandleInput();
                DiscordController.Update();
                Update(1000 / (Time.GetMilliseconds() - lastUpdate));
                lastUpdate = Time.GetMilliseconds();
                Thread.Sleep(1000 / 60);
            }
        }
Example #16
0
    void Start()
    {
        audioCtrlScript = GetComponent <audioControl>();

        PlayerPrefs.SetInt("health", 3);

        if (PlayerPrefs.HasKey("coins"))
        {
            totalCoins = PlayerPrefs.GetInt("coins");
        }
        PlayerPrefs.SetInt("coins", totalCoins);

        rb = GetComponent <Rigidbody2D> ();

        SetCheckpoint(false);

        res  = false;
        dead = false;

        dc = GetComponent <DiscordController>();
        dc.updateDetails(String.Format("In Level {0} | ♥ {1}", SceneManager.GetActiveScene().name.Substring(3), health));
        dc.updateStartTime();
    }
Example #17
0
 protected override void OnClosed(EventArgs e)
 {
     DiscordController.Shutdown();
     base.OnClosed(e);
     Environment.Exit(0);
 }
 void Awake()
 {
     discord = this;
 }
Example #19
0
 public void Start()
 {
     DiscordRp = gameObject.GetComponent <DiscordController>();
     StartCoroutine(LoadAvatar(Request.userId, Request.avatar));
     StartCoroutine(OnRequestExpired());
 }
Example #20
0
 void Awake()
 {
     main = this;
 }
Example #21
0
 public User GetUser(long id)
 {
     return(DiscordController.GetUser(id));
 }
 private void Start()
 {
     discordC = GetComponent <DiscordController>();
 }