public bool Start()
        {
            // try
            // {
            var appInfo = new APPINFOTYPE
            {
                Title           = "RainbowKnight",
                Description     = "Hollow Knight RainbowKnight mod",
                Author_Name     = "Webcretaire",
                Author_Contact  = "https://github.com/Webcretaire/HollowKnight.RainbowKnight",
                SupportedDevice = (int)ChromaAnimationAPI.Device.Keyboard |
                                  (int)ChromaAnimationAPI.Device.Mouse |
                                  (int)ChromaAnimationAPI.Device.ChromaLink,
                Category = 0x02     // 0x01 = Utility ; 0x02 = Game
            };

            _mResult = ChromaAnimationAPI.InitSDK(ref appInfo);
            switch (_mResult)
            {
            case RazerErrors.RZRESULT_DLL_NOT_FOUND:
                LogError("Chroma DLL is not found! " + RazerErrors.GetResultString(_mResult));
                return(false);

            case RazerErrors.RZRESULT_DLL_INVALID_SIGNATURE:
                LogError("Chroma DLL has an invalid signature! " + RazerErrors.GetResultString(_mResult));
                return(false);

            case RazerErrors.RZRESULT_SUCCESS:
                return(true);

            default:
                LogError("Failed to initialize Chroma! " + RazerErrors.GetResultString(_mResult));
                return(false);
            }
            // }
            // catch (Exception e)
            // {
            //     LogError("Error during Chroma Helper Start: " + e.Message);
            //     return false;
            // }
        }
        public override void Initialize()
        {
            Log("Start RainbowKnight Init");

            _chromaHelper = new RainbowChromaHelper();

            if (!_chromaHelper.Start())
            {
                return;                         // There was an error at startup, don't register any hook
            }
            Log("Razer SDK init: " + RazerErrors.GetResultString(_chromaHelper.GetInitResult()));

            ModHooks.Instance.TakeHealthHook       += OnTakeHealth;
            ModHooks.Instance.BeforePlayerDeadHook += OnPlayerDead;
            ModHooks.Instance.ApplicationQuitHook  += OnApplicationQuit;
            ModHooks.Instance.HeroUpdateHook       += OnHeroUpdate;
            ModHooks.Instance.LanguageGetHook      += OnLanguageGet;
            ModHooks.Instance.SetPlayerBoolHook    += OnSetPlayerBool;

            _chromaHelper.PlayBackground();
        }
Ejemplo n.º 3
0
    public void Start()
    {
        ChromaAnimationAPI._sStreamingAssetPath = Application.streamingAssetsPath;
        _mResult      = ChromaAnimationAPI.Init();
        _mInitialized = true;
        switch (_mResult)
        {
        case RazerErrors.RZRESULT_DLL_NOT_FOUND:
            Debug.LogError(string.Format("Chroma DLL is not found! {0}", RazerErrors.GetResultString(_mResult)));
            break;

        case RazerErrors.RZRESULT_DLL_INVALID_SIGNATURE:
            Debug.LogError(string.Format("Chroma DLL has an invalid signature! {0}", RazerErrors.GetResultString(_mResult)));
            break;

        case RazerErrors.RZRESULT_SUCCESS:
            break;

        default:
            Debug.LogError(string.Format("Failed to initialize Chroma! {0}", RazerErrors.GetResultString(_mResult)));
            break;
        }
    }
Ejemplo n.º 4
0
        public static void Init()
        {
            _mResult = ChromaAnimationAPI.Init();
            switch (_mResult)
            {
            case RazerErrors.RZRESULT_DLL_NOT_FOUND:
                Console.Error.WriteLine("Chroma DLL is not found! {0}", RazerErrors.GetResultString(_mResult));
                break;

            case RazerErrors.RZRESULT_DLL_INVALID_SIGNATURE:
                Console.Error.WriteLine("Chroma DLL has an invalid signature! {0}", RazerErrors.GetResultString(_mResult));
                break;

            case RazerErrors.RZRESULT_SUCCESS:
                break;

            default:
                Console.Error.WriteLine("Failed to initialize Chroma! {0}", RazerErrors.GetResultString(_mResult));
                break;
            }

            Update();
        }
    public IEnumerator Start()
    {
        ChromaAnimationAPI._sStreamingAssetPath = Application.streamingAssetsPath;

        ChromaSDK.APPINFOTYPE appInfo = new APPINFOTYPE();
        appInfo.Title       = "Razer Chroma CSharp Game Loop Sample Application";
        appInfo.Description = "A sample application using Razer Chroma SDK";

        appInfo.Author_Name    = "Razer";
        appInfo.Author_Contact = "https://developer.razer.com/chroma";

        //appInfo.SupportedDevice =
        //    0x01 | // Keyboards
        //    0x02 | // Mice
        //    0x04 | // Headset
        //    0x08 | // Mousepads
        //    0x10 | // Keypads
        //    0x20   // ChromaLink devices
        //    ;
        appInfo.SupportedDevice = (0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20);
        appInfo.Category        = 1;
        int result = ChromaAnimationAPI.InitSDK(ref appInfo);

        switch (result)
        {
        case RazerErrors.RZRESULT_DLL_NOT_FOUND:
            Debug.LogError(string.Format("Chroma DLL is not found! {0}", RazerErrors.GetResultString(result)));
            yield break;

        case RazerErrors.RZRESULT_DLL_INVALID_SIGNATURE:
            Debug.LogError(string.Format("Chroma DLL has an invalid signature! {0}", RazerErrors.GetResultString(result)));
            yield break;

        case RazerErrors.RZRESULT_SUCCESS:
            Debug.Log("ChromaSDK initialized!");
            yield return(new WaitForSeconds(0.1f));

            break;

        default:
            Debug.LogError(string.Format("Failed to initialize Chroma! {0}", RazerErrors.GetResultString(result)));
            yield break;
        }

        // setup scene
        _mScene = new Scene();

        Effect effect = new Effect();

        effect._mAnimation = "Animations/Landscape";
        effect._mSpeed     = 1;
        effect._mBlend     = "none";
        effect._mState     = false;
        effect._mMode      = "replace";
        _mScene._mEffects.Add(effect);
        _mIndexLandscape = (int)_mScene._mEffects.Count - 1;

        effect             = new Effect();
        effect._mAnimation = "Animations/Fire";
        effect._mSpeed     = 1;
        effect._mBlend     = "none";
        effect._mState     = false;
        effect._mMode      = "replace";
        _mScene._mEffects.Add(effect);
        _mIndexFire = (int)_mScene._mEffects.Count - 1;

        effect             = new Effect();
        effect._mAnimation = "Animations/Rainbow";
        effect._mSpeed     = 1;
        effect._mBlend     = "none";
        effect._mState     = false;
        effect._mMode      = "replace";
        _mScene._mEffects.Add(effect);
        _mIndexRainbow = (int)_mScene._mEffects.Count - 1;

        effect             = new Effect();
        effect._mAnimation = "Animations/Spiral";
        effect._mSpeed     = 1;
        effect._mBlend     = "none";
        effect._mState     = false;
        effect._mMode      = "replace";
        _mScene._mEffects.Add(effect);
        _mIndexSpiral = (int)_mScene._mEffects.Count - 1;

        ThreadStart ts = new ThreadStart(GameLoop);

        _mThread = new Thread(ts);
        _mThread.Start();
    }
Ejemplo n.º 6
0
    public void OnGUI()
    {
        GUILayout.FlexibleSpace();
        GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
        GUILayout.FlexibleSpace();

        if (!_mInitialized)
        {
            GUILayout.BeginVertical(GUILayout.Height(Screen.height));
            GUILayout.FlexibleSpace();
            GUILayout.Label("Sample has not yet initialized!");
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
        }
        else
        {
            switch (_mResult)
            {
            case RazerErrors.RZRESULT_DLL_NOT_FOUND:
                GUILayout.BeginVertical(GUILayout.Height(Screen.height));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Chroma DLL is not found!");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                break;

            case RazerErrors.RZRESULT_DLL_INVALID_SIGNATURE:
                GUILayout.BeginVertical(GUILayout.Height(Screen.height));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Chroma DLL has an invalid signature!");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                break;

            case RazerErrors.RZRESULT_SUCCESS:
            {
                const float height = 40;

                for (int index = 1; index <= MAX_EFFECTS; ++index)
                {
                    if (ShowHeader(index))
                    {
                        GUILayout.BeginVertical(GUILayout.Height(Screen.height));
                        GUILayout.FlexibleSpace();
                    }

                    if (GUILayout.Button(GetEffectName(index), GUILayout.Height(height)))
                    {
                        ExecuteItem(index);
                    }

                    if (ShowFooter(index))
                    {
                        GUILayout.FlexibleSpace();
                        GUILayout.EndVertical();
                    }
                }
            }
            break;

            default:
                GUILayout.BeginVertical(GUILayout.Height(Screen.height));
                GUILayout.FlexibleSpace();
                GUILayout.Label(string.Format("Failed to initialize Chroma! {0}", RazerErrors.GetResultString(_mResult)));
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                break;
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();
        }
    }
Ejemplo n.º 7
0
        public void Start()
        {
            ChromaSDK.APPINFOTYPE appInfo = new APPINFOTYPE();
            appInfo.Title       = "Razer Chroma CSharp Game Loop Sample Application";
            appInfo.Description = "A sample application using Razer Chroma SDK";

            appInfo.Author_Name    = "Razer";
            appInfo.Author_Contact = "https://developer.razer.com/chroma";

            //appInfo.SupportedDevice =
            //    0x01 | // Keyboards
            //    0x02 | // Mice
            //    0x04 | // Headset
            //    0x08 | // Mousepads
            //    0x10 | // Keypads
            //    0x20   // ChromaLink devices
            appInfo.SupportedDevice = (0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20);
            //    0x01 | // Utility. (To specifiy this is an utility application)
            //    0x02   // Game. (To specifiy this is a game);
            appInfo.Category = 1;
            _mResult         = ChromaAnimationAPI.InitSDK(ref appInfo);
            switch (_mResult)
            {
            case RazerErrors.RZRESULT_DLL_NOT_FOUND:
                Console.Error.WriteLine("Chroma DLL is not found! {0}", RazerErrors.GetResultString(_mResult));
                return;

            case RazerErrors.RZRESULT_DLL_INVALID_SIGNATURE:
                Console.Error.WriteLine("Chroma DLL has an invalid signature! {0}", RazerErrors.GetResultString(_mResult));
                return;

            case RazerErrors.RZRESULT_SUCCESS:
                Thread.Sleep(100);
                break;

            default:
                Console.Error.WriteLine("Failed to initialize Chroma! {0}", RazerErrors.GetResultString(_mResult));
                return;
            }

            // setup scene
            _mScene = new FChromaSDKScene();

            FChromaSDKSceneEffect effect = new FChromaSDKSceneEffect();

            effect._mAnimation = "Animations/Landscape";
            effect._mSpeed     = 1;
            effect._mBlend     = EChromaSDKSceneBlend.SB_None;
            effect._mState     = false;
            effect._mMode      = EChromaSDKSceneMode.SM_Add;
            _mScene._mEffects.Add(effect);
            _mIndexLandscape = (int)_mScene._mEffects.Count - 1;

            effect             = new FChromaSDKSceneEffect();
            effect._mAnimation = "Animations/Fire";
            effect._mSpeed     = 1;
            effect._mBlend     = EChromaSDKSceneBlend.SB_None;
            effect._mState     = false;
            effect._mMode      = EChromaSDKSceneMode.SM_Add;
            _mScene._mEffects.Add(effect);
            _mIndexFire = (int)_mScene._mEffects.Count - 1;

            effect             = new FChromaSDKSceneEffect();
            effect._mAnimation = "Animations/Rainbow";
            effect._mSpeed     = 1;
            effect._mBlend     = EChromaSDKSceneBlend.SB_None;
            effect._mState     = false;
            effect._mMode      = EChromaSDKSceneMode.SM_Add;
            _mScene._mEffects.Add(effect);
            _mIndexRainbow = (int)_mScene._mEffects.Count - 1;

            effect             = new FChromaSDKSceneEffect();
            effect._mAnimation = "Animations/Spiral";
            effect._mSpeed     = 1;
            effect._mBlend     = EChromaSDKSceneBlend.SB_None;
            effect._mState     = false;
            effect._mMode      = EChromaSDKSceneMode.SM_Add;
            _mScene._mEffects.Add(effect);
            _mIndexSpiral = (int)_mScene._mEffects.Count - 1;
        }