Beispiel #1
0
        public void Initialize()
        {
            // Create effects from the assetbundle, they should read the required assets by themselves.

            // Wow such exception handling.
            try
            {
                m_menus.Add(MenuType.Bloom, new BloomEffect());
            }
            catch (Exception ex)
            {
                PPFXUtility.log(ex);
            }

            try
            {
                m_menus.Add(MenuType.AntiAliasing, new AntiAliasingEffect());
            }
            catch (Exception ex)
            {
                PPFXUtility.log(ex);
            }

            try
            {
                m_menus.Add(MenuType.AmbientOcclusion, new AmbientOcclusionEffect());
            }
            catch (Exception ex)
            {
                PPFXUtility.log(ex);
            }
        }
Beispiel #2
0
        private void save()
        {
            // For some reason there can be an exception in the constructor, but the object is still created.
            PPFXUtility.log("PostProcessFX: Saving settings.");

            foreach (KeyValuePair <MenuType, IEffectMenu> keyValue in m_menus)
            {
                keyValue.Value.save();
            }

            ConfigUtility.Serialize <GUIConfig>(configFilename, m_config);
        }
Beispiel #3
0
        public void OnDisabled()
        {
            ModLoader.removeConfigUI();

            if (loadedBundle)
            {
                loadedBundle.Unload(true);
                AssetBundle.Destroy(loadedBundle);
                PPFXUtility.log("Unloaded existing asset bundle.");
            }

            PPFXUtility.log(ModName + " " + VersionString + " disabled.");
        }
Beispiel #4
0
        public void OnEnabled()
        {
            PPFXUtility.log(ModName + " " + VersionString + " enabled");

            // Find the current directory of the mod
            string modPath   = PluginManager.instance.FindPluginInfo(Assembly.GetAssembly(typeof(ModDescription))).modPath;
            string assetsUri = "file:///" + modPath.Replace("\\", "/") + "/Resources/";

            // Add platform specific folder to it.
            if (Application.platform == RuntimePlatform.WindowsPlayer)
            {
                assetsUri += "Windows";
            }
            else if (Application.platform == RuntimePlatform.LinuxPlayer)
            {
                assetsUri += "Linux";
            }
            else if (Application.platform == RuntimePlatform.OSXPlayer)
            {
                assetsUri += "Mac";
            }


            // File is always called the same.
            assetsUri += "/postprocessfx";

            WWW www = new WWW(assetsUri);

            // Need to wait until the WWW loading has been done, this blocks the game.

            /*while (!www.isDone)
             * {
             *  System.Threading.Thread.Sleep(1000);
             *  PPFXUtility.log("Waiting for asset bundle to be loaded...");
             * }*/

            loadedBundle = www.assetBundle;
            if (loadedBundle == null)
            {
                PPFXUtility.log("Assetbundle with uri " + assetsUri + " couldn't be loaded.");

                // Don't throw, but just don't do anything.
                return;
            }

            // When we are already in the level we can also trigger it here.
            ModLoader.addConfigUI();
        }
Beispiel #5
0
        /**
         * Remove the ConfigUI from the camera if it exists.
         */
        public static void removeConfigUI()
        {
            if (Camera.main == null || Camera.main.gameObject == null)
            {
                return;
            }
            GameObject cameraObject = Camera.main.gameObject;

            // Remove any existing config UI that was added by us.
            Component oldUI = cameraObject.GetComponent("ConfigUI");

            if (oldUI != null)
            {
                Component.Destroy(oldUI);
                PPFXUtility.log("Destroyed the old ConfigUI game object.");
            }
        }
Beispiel #6
0
        /**
         * Add the config UI to the camera object.
         */
        public static void addConfigUI()
        {
            if (Camera.main == null || Camera.main.gameObject == null)
            {
                return;
            }
            GameObject cameraObject = Camera.main.gameObject;

            removeConfigUI();

            // Then try to add the new one again.
            ConfigUI newUI = cameraObject.AddComponent <ConfigUI>();

            if (newUI != null)
            {
                PPFXUtility.log("Added the ConfigUI game object.");
            }

            newUI.Initialize();
        }
Beispiel #7
0
        public void OnGUI()
        {
            if (!m_config.active)
            {
                return;
            }

            float x = m_config.menuPositionX;
            float y = m_config.menuPositionY;

            GUI.Box(new Rect(x, y, 320, 400), "");

            if (GUI.Button(new Rect(x, y, 300, 20), ModDescription.ModName + " UI " + ModDescription.VersionString))
            {
                m_dragging = true;
            }

            if (GUI.Button(new Rect(x + 300, y, 20, 20), "X"))
            {
                m_config.active = false;
            }

            x += 10;
            y += 25;
            if (GUI.Button(new Rect(x, y, 60, 20), "Global"))
            {
                m_activeMenu = MenuType.Global;
            }

            if (GUI.Button(new Rect(x + 60, y, 60, 20), "Bloom"))
            {
                m_activeMenu = MenuType.Bloom;
            }

            if (GUI.Button(new Rect(x + 120, y, 60, 20), "AA"))
            {
                m_activeMenu = MenuType.AntiAliasing;
            }

            if (GUI.Button(new Rect(x + 180, y, 60, 20), "SSAO"))
            {
                m_activeMenu = MenuType.AmbientOcclusion;
            }

            y += 25;

            // Handle the Global case as it is rendered here.
            if (m_activeMenu == MenuType.Global)
            {
                GUI.Label(new Rect(x, y, 200, 20), "Toggle Key: ");
                m_toggleKeyString = GUI.TextArea(new Rect(x + 150, y, 150, 20), m_toggleKeyString);
                y += 25;

                m_config.ctrlKey  = GUI.Toggle(new Rect(x, y, 50, 20), m_config.ctrlKey, "ctrl");
                m_config.shiftKey = GUI.Toggle(new Rect(x + 60, y, 50, 20), m_config.shiftKey, "shift");
                m_config.altKey   = GUI.Toggle(new Rect(x + 120, y, 50, 20), m_config.altKey, "alt");
                y += 25;

                try
                {
                    m_config.toggleUIKey = (int)Enum.Parse(typeof(KeyCode), m_toggleKeyString);
                }
                catch (Exception)
                {
                    // Silently ignore this exception, because it just means that it cannot be converted to a keycode.
                    m_config.toggleUIKey = (int)KeyCode.F9;
                    m_toggleKeyString    = "F9";
                }

                if (GUI.Button(new Rect(x, y, 50, 20), "Save"))
                {
                    save();
                }
            }
            else
            {
                try
                {
                    m_menus[m_activeMenu].onGUI(x, y);
                }
                catch (Exception ex)
                {
                    PPFXUtility.log(ex);
                    m_activeMenu = MenuType.Global;
                }
            }
        }