Beispiel #1
0
 public void SetWideFullscreen(bool borderless)
 {
     if (!GlobalControls.isInFight)
     {
         throw new CYFException("SetWideFullscreen is only usable from within battles.");
     }
     ScreenResolution.wideFullscreen = borderless;
     if (Screen.fullScreen)
     {
         ScreenResolution.SetFullScreen(true, 0);
     }
 }
    /// <summary>
    /// Control checking, and way more.
    /// </summary>
    void Update()
    {
        #if UNITY_STANDALONE_WIN
        if (fullscreenSwitch == 1)
        {
            StartCoroutine(RepositionWindow());
        }
        if (fullscreenSwitch > 0)
        {
            fullscreenSwitch--;
        }
        #endif

        stopScreenShake = false;
        if (isInFight || UnitaleUtil.IsOverworld)
        {
            frame++;
        }

        string sceneName = SceneManager.GetActiveScene().name;

        if (sceneName == "ModSelect")
        {
            lastSceneUnitale = true;
        }
        else
        {
            lastSceneUnitale = false;
        }

        // Activate Debugger
        if (UserDebugger.instance && Input.GetKeyDown(KeyCode.F9))
        {
            if (UserDebugger.instance.gameObject.activeSelf)
            {
                GameObject.Find("Text").transform.SetParent(UserDebugger.instance.gameObject.transform);
            }
            UserDebugger.instance.gameObject.SetActive(!UserDebugger.instance.gameObject.activeSelf);
            Camera.main.GetComponent <FPSDisplay>().enabled = UserDebugger.instance.gameObject.activeSelf;
            // Activate Hitbox Debugger
        }
        else if (isInFight && Input.GetKeyDown(KeyCode.H) && sceneName != "Error" && UserDebugger.instance.gameObject.activeSelf)
        {
            GameObject.Find("Main Camera").GetComponent <ProjectileHitboxRenderer>().enabled = !GameObject.Find("Main Camera").GetComponent <ProjectileHitboxRenderer>().enabled;
        }
        // Exit a battle or the Error scene
        else if (Input.GetKeyDown(KeyCode.Escape) && (canTransOW.Contains(sceneName) || isInFight))
        {
            if (isInFight && LuaEnemyEncounter.script.GetVar("unescape").Boolean&& sceneName != "Error")
            {
                return;
            }
            if (sceneName == "Error" && !modDev)
            {
                UnitaleUtil.ExitOverworld();
                SceneManager.LoadScene("Disclaimer");
                GameObject.Destroy(GameObject.Find("SpritePivot"));
                return;
            }

            if (GameOverBehavior.gameOverContainer)
            {
                if (GameOverBehavior.gameOverContainer.activeInHierarchy)
                {
                    GameObject.FindObjectOfType <GameOverBehavior>().EndGameOver();
                }
                else
                {
                    UIController.EndBattle();
                }
            }
            else
            {
                UIController.EndBattle();
            }
            //StaticInits.Reset();
            //Open the Menu in the Overworld
        }
        else if (input.Menu == UndertaleInput.ButtonState.PRESSED && !nonOWScenes.Contains(sceneName) && !isInFight && !isInShop && (!GameOverBehavior.gameOverContainerOw || !GameOverBehavior.gameOverContainerOw.activeInHierarchy))
        {
            if (!PlayerOverworld.instance.PlayerNoMove && EventManager.instance.script == null && !PlayerOverworld.instance.menuRunning[2] && !PlayerOverworld.instance.menuRunning[4] && (GameObject.Find("FadingBlack") == null || GameObject.Find("FadingBlack").GetComponent <Fading>().alpha <= 0))
            {
                StartCoroutine(PlayerOverworld.LaunchMenu());
            }
            //Wipe save and close CYF in the Error scene if save failed to load
        }
        else if (sceneName == "Error" && allowWipeSave && Input.GetKeyDown(KeyCode.R))
        {
            System.IO.File.Delete(Application.persistentDataPath + "/save.gd");
            Application.Quit();
        }

        if (isInFight)
        {
            switch (fleeIndex)
            {
            case 0:
                if (Input.GetKeyDown(KeyCode.F))
                {
                    fleeIndex++;
                }
                break;

            case 1:
                if (Input.GetKeyDown(KeyCode.L))
                {
                    fleeIndex++;
                }
                else if (Input.anyKeyDown)
                {
                    fleeIndex = 0;
                }
                break;

            case 2:
                if (Input.GetKeyDown(KeyCode.E))
                {
                    fleeIndex++;
                }
                else if (Input.anyKeyDown)
                {
                    fleeIndex = 0;
                }
                break;

            case 3:
                if (Input.GetKeyDown(KeyCode.E))
                {
                    fleeIndex++;
                }
                else if (Input.anyKeyDown)
                {
                    fleeIndex = 0;
                }
                break;

            case 4:
                if (Input.GetKeyDown(KeyCode.S))
                {
                    fleeIndex = -1; UIController.instance.SuperFlee();
                }
                else if (Input.anyKeyDown)
                {
                    fleeIndex = 0;
                }
                break;
            }
        }
        if (ScreenResolution.hasInitialized)
        {
            if (Input.GetKeyDown(KeyCode.F4) ||      // F4
                (Input.GetKeyDown(KeyCode.Return) &&
                 (Input.GetKey(KeyCode.LeftAlt) ||   // LAlt  + Enter
                  Input.GetKey(KeyCode.RightAlt))))  // RAlt  + Enter
            {
                ScreenResolution.SetFullScreen(!Screen.fullScreen);
                if (!Screen.fullScreen)
                {
                    StartCoroutine(UpdateMonitorSize());
                }
            }
        }
    }
Beispiel #3
0
    // Use this for initialization
    private void Start()
    {
        // add button functions

        // reset RealGlobals
        ResetRG.GetComponent <Button>().onClick.AddListener(() => {
            if (RealGlobalCooldown > 0)
            {
                LuaScriptBinder.ClearVariables();
                RealGlobalCooldown = 60 * 2;
                ResetRG.GetComponentInChildren <Text>().text = !GlobalControls.crate ? "Real Globals Erased!" : "REEL GOLBELZ DELEET!!!!!";
            }
            else
            {
                RealGlobalCooldown = 60 * 2;
                ResetRG.GetComponentInChildren <Text>().text = !GlobalControls.crate ? "Are you sure?" : "R U SUR???";
            }
        });

        // reset AlMightyGlobals
        ResetAG.GetComponent <Button>().onClick.AddListener(() => {
            if (AlMightyGlobalCooldown > 0)
            {
                LuaScriptBinder.ClearAlMighty();
                AlMightyGlobalCooldown = 60 * 2;
                ResetAG.GetComponentInChildren <Text>().text = !GlobalControls.crate ? "AlMighty Globals Erased!" : "ALMEIGHTIZ DELEET!!!!!";
            }
            else
            {
                AlMightyGlobalCooldown = 60 * 2;
                ResetAG.GetComponentInChildren <Text>().text = !GlobalControls.crate ? "Are you sure?" : "R U SUR???";
            }
        });

        // clear Save
        ClearSave.GetComponent <Button>().onClick.AddListener(() => {
            if (SaveCooldown > 0)
            {
                File.Delete(Application.persistentDataPath + "/save.gd");
                SaveCooldown = 60 * 2;
                ClearSave.GetComponentInChildren <Text>().text = !GlobalControls.crate ? "Save wiped!" : "RIP";
            }
            else
            {
                SaveCooldown = 60 * 2;
                ClearSave.GetComponentInChildren <Text>().text = !GlobalControls.crate ? "Are you sure?" : "R U SUR???";
            }
        });

        // toggle safe mode
        Safe.GetComponent <Button>().onClick.AddListener(() => {
            ControlPanel.instance.Safe = !ControlPanel.instance.Safe;

            // save Safe Mode preferences to AlMighties
            LuaScriptBinder.SetAlMighty(null, "CYFSafeMode", DynValue.NewBoolean(ControlPanel.instance.Safe), true);

            Safe.GetComponentInChildren <Text>().text = !GlobalControls.crate
                ? ("Safe mode: " + (ControlPanel.instance.Safe ? "On" : "Off"))
                : ("SFAE MDOE: " + (ControlPanel.instance.Safe ? "ON" : "OFF"));
        });
        Safe.GetComponentInChildren <Text>().text = !GlobalControls.crate
            ? ("Safe mode: " + (ControlPanel.instance.Safe ? "On" : "Off"))
            : ("SFAE MDOE: " + (ControlPanel.instance.Safe ? "ON" : "OFF"));

        // toggle retrocompatibility mode
        Retro.GetComponent <Button>().onClick.AddListener(() => {
            GlobalControls.retroMode = !GlobalControls.retroMode;

            // save RetroMode preferences to AlMighties
            LuaScriptBinder.SetAlMighty(null, "CYFRetroMode", DynValue.NewBoolean(GlobalControls.retroMode), true);

            Retro.GetComponentInChildren <Text>().text = !GlobalControls.crate
                ? ("Retrocompatibility Mode: " + (GlobalControls.retroMode ? "On" : "Off"))
                : ("RETORCMOAPTIILBIYT MOD: " + (GlobalControls.retroMode ? "ON" : "OFF"));
        });
        Retro.GetComponentInChildren <Text>().text = !GlobalControls.crate
            ? ("Retrocompatibility Mode: " + (GlobalControls.retroMode ? "On" : "Off"))
            : ("RETORCMOAPTIILBIYT MOD: " + (GlobalControls.retroMode ? "ON" : "OFF"));

        // toggle pixel-perfect fullscreen
        Fullscreen.GetComponent <Button>().onClick.AddListener(() => {
            ScreenResolution.perfectFullscreen = !ScreenResolution.perfectFullscreen;

            // save RetroMode preferences to AlMighties
            LuaScriptBinder.SetAlMighty(null, "CYFPerfectFullscreen", DynValue.NewBoolean(ScreenResolution.perfectFullscreen), true);

            Fullscreen.GetComponentInChildren <Text>().text = !GlobalControls.crate
                ? ("Blurless Fullscreen: " + (ScreenResolution.perfectFullscreen ? "On" : "Off"))
                : ("NOT UGLEE FULLSCREEN: " + (ScreenResolution.perfectFullscreen ? "ON" : "OFF"));
        });
        Fullscreen.GetComponentInChildren <Text>().text = !GlobalControls.crate
            ? ("Blurless Fullscreen: " + (ScreenResolution.perfectFullscreen ? "On" : "Off"))
            : ("NOT UGLEE FULLSCREEN: " + (ScreenResolution.perfectFullscreen ? "ON" : "OFF"));

        // change window scale
        Scale.GetComponent <Button>().onClick.AddListener(() => {
            double maxScale = System.Math.Floor(Screen.currentResolution.height / 480.0);
            if (ScreenResolution.windowScale < maxScale)
            {
                ScreenResolution.windowScale += 1;
            }
            else
            {
                ScreenResolution.windowScale = 1;
            }

            if (Screen.height != ScreenResolution.windowScale * 480 && !Screen.fullScreen)
            {
                ScreenResolution.SetFullScreen(false);
            }

            // save RetroMode preferences to AlMighties
            LuaScriptBinder.SetAlMighty(null, "CYFWindowScale", DynValue.NewNumber(ScreenResolution.windowScale), true);

            Scale.GetComponentInChildren <Text>().text = !GlobalControls.crate
                ? ("Window Scale: " + ScreenResolution.windowScale.ToString() + "x")
                : ("WEENDO STRECH: " + ScreenResolution.windowScale.ToString() + "X");
        });
        ScreenResolution.windowScale--;
        Scale.GetComponent <Button>().onClick.Invoke();

        // Discord Rich Presence
        // Change Discord Status Visibility
        Discord.GetComponent <Button>().onClick.AddListener(() => {
            Discord.GetComponentInChildren <Text>().text = (!GlobalControls.crate ? "Discord Display: " : "DEESCORD DESPLAY: ") + DiscordControls.ChangeVisibilitySetting(1);
        });
        Discord.GetComponentInChildren <Text>().text = (!GlobalControls.crate ? "Discord Display: " : "DEESCORD DESPLAY: ") + DiscordControls.ChangeVisibilitySetting(0);

        // exit
        Exit.GetComponent <Button>().onClick.AddListener(() => { SceneManager.LoadScene("ModSelect"); });

        // Crate Your Frisk
        if (!GlobalControls.crate)
        {
            return;
        }
        // labels
        GameObject.Find("OptionsLabel").GetComponent <Text>().text     = "OPSHUNS";
        GameObject.Find("DescriptionLabel").GetComponent <Text>().text = "MORE TXET";

        // buttons
        ResetRG.GetComponentInChildren <Text>().text   = "RESTE RELA GOLBALZ";
        ResetAG.GetComponentInChildren <Text>().text   = "RESTE ALMIGTY GOLBALZ";
        ClearSave.GetComponentInChildren <Text>().text = "WYPE SAV";
        Exit.GetComponentInChildren <Text>().text      = "EXIT TOO MAD SELCT";
    }
Beispiel #4
0
    /// <summary>
    /// Run once per frame.
    /// </summary>
    private void Update()
    {
        // Update Discord RPC
        DiscordControls.Update();

        #if UNITY_STANDALONE_WIN
        // Reposition the window to the middle of the screen after exiting fullscreen
        if (fullscreenSwitch == 1)
        {
            StartCoroutine(RepositionWindow());
        }
        if (fullscreenSwitch > 0)
        {
            fullscreenSwitch--;
        }
        #endif

        // Frame counter used for logging purposes
        if (isInFight || UnitaleUtil.IsOverworld)
        {
            frame++;
        }

        string sceneName = SceneManager.GetActiveScene().name;

        // Activate Debugger
        if (UserDebugger.instance && Input.GetKeyDown(KeyCode.F9) && UserDebugger.instance.canShow)
        {
            UserDebugger.instance.gameObject.SetActive(!UserDebugger.instance.gameObject.activeSelf);
            Camera.main.GetComponent <FPSDisplay>().enabled = UserDebugger.instance.gameObject.activeSelf;
        }
        // Activate Hitbox Debugger
        else if (isInFight && Input.GetKeyDown(KeyCode.H) && sceneName != "Error" && UserDebugger.instance.gameObject.activeSelf)
        {
            gameObject.GetComponent <ProjectileHitboxRenderer>().enabled = !gameObject.GetComponent <ProjectileHitboxRenderer>().enabled;
        }
        // Exit a battle or the Error scene
        else if (Input.GetKeyDown(KeyCode.Escape) && (canTransOW.Contains(sceneName) || isInFight))
        {
            if (isInFight && EnemyEncounter.script.GetVar("unescape").Boolean&& sceneName != "Error")
            {
                return;
            }
            // The Error scene can only be exited if we entered the mod through the mod selection screen
            if (sceneName == "Error" && !modDev)
            {
                UnitaleUtil.ExitOverworld();
                SceneManager.LoadScene("Disclaimer");
                DiscordControls.StartTitle();
                Destroy(GameObject.Find("SpritePivot"));
                return;
            }

            if (GameOverBehavior.gameOverContainer)
            {
                if (GameOverBehavior.gameOverContainer.activeInHierarchy)
                {
                    FindObjectOfType <GameOverBehavior>().EndGameOver();
                }
                else
                {
                    UIController.EndBattle();
                }
            }
            else
            {
                UIController.EndBattle();
            }
        }
        // Open the Menu in the Overworld
        else if (input.Menu == UndertaleInput.ButtonState.PRESSED && !nonOWScenes.Contains(sceneName) && !isInFight && !isInShop && (!GameOverBehavior.gameOverContainerOw || !GameOverBehavior.gameOverContainerOw.activeInHierarchy))
        {
            if (!PlayerOverworld.instance.PlayerNoMove && EventManager.instance.script == null && !PlayerOverworld.instance.menuRunning[2] && !PlayerOverworld.instance.menuRunning[4] && (GameObject.Find("FadingBlack") == null || GameObject.Find("FadingBlack").GetComponent <Fading>().alpha <= 0))
            {
                StartCoroutine(PlayerOverworld.LaunchMenu());
            }
        }
        // Wipe save and close CYF in the Error scene if save failed to load
        else if (sceneName == "Error" && allowWipeSave && Input.GetKeyDown(KeyCode.R))
        {
            System.IO.File.Delete(Application.persistentDataPath + "/save.gd");
            Application.Quit();
        }

        // Enter fullscreen using given shortcuts
        if (!ScreenResolution.hasInitialized)
        {
            return;
        }
        if (!Input.GetKeyDown(KeyCode.F4) && (!Input.GetKeyDown(KeyCode.Return) || !Input.GetKey(KeyCode.LeftAlt) && !Input.GetKey(KeyCode.RightAlt)))
        {
            return;                                                                                                                                            // RAlt  + Enter
        }
        ScreenResolution.SetFullScreen(!Screen.fullScreen);
        if (!Screen.fullScreen)
        {
            StartCoroutine(UpdateMonitorSize());
        }
    }