/// <summary>
    /// Changes the Discord Rich Presence visibility setting.
    /// </summary>
    /// <param name="spd">Added so the setting can be written out at init time without changing it.</param>
    /// <returns>The name of the current setting.</returns>
    public static string ChangeVisibilitySetting(int spd)
    {
        curr_setting += spd;
        if (curr_setting >= settingNames.Length)
        {
            curr_setting = 0;
        }

        if (spd > 0)
        {
            LuaScriptBinder.SetAlMighty(null, "CYFDiscord", DynValue.NewNumber(curr_setting), true);
        }

        switch (curr_setting)
        {
        case 0:
            StartModSelect(false);
            break;

        case 1:
            activity.Details          = "";
            activity.State            = "";
            activity.Timestamps.Start = 0;
            activity.Timestamps.End   = 0;
            UpdatePresence(true);
            break;

        default:
            Clear();
            break;
        }

        return(GlobalControls.crate ? Temmify.Convert(settingNames[curr_setting]) : settingNames[curr_setting]);
    }
Esempio n. 2
0
    // Opens the scrolling interface and lets the user browse their mods.
    private void modFolderMiniMenu()
    {
        // Hide the mod list button
        btnList.SetActive(false);

        // Automatically select the current mod when the mod list appears
        selectedItem = CurrentSelectedMod + 1;

        // Grab pre-existing objects
        GameObject content = encounterBox.transform.Find("ScrollCutoff/Content").gameObject;
        // Give the back button its function
        GameObject back = content.transform.Find("Back").gameObject;

        back.GetComponent <Button>().onClick.RemoveAllListeners();
        back.GetComponent <Button>().onClick.AddListener(() => {
            // Reset the encounter box's position
            modListScroll = 0.0f;
            modFolderSelection();
        });

        // Make clicking the background exit this menu
        GameObject.Find("ModBackground").GetComponent <Button>().onClick.RemoveAllListeners();
        GameObject.Find("ModBackground").GetComponent <Button>().onClick.AddListener(() => {
            if (animationDone)
            {
                // Store the encounter box's position so it can be remembered upon exiting a mod
                modListScroll = content.GetComponent <RectTransform>().anchoredPosition.y;
                modFolderSelection();
            }
        });
        // Show the encounter selection box
        encounterBox.SetActive(true);
        // Move the encounter box to the stored position, for easier mod browsing
        content.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, modListScroll);

        int count = -1;

        foreach (DirectoryInfo mod in modDirs)
        {
            count += 1;

            // Create a button for each mod
            GameObject button = Instantiate(back);

            //set parent and name
            button.transform.SetParent(content.transform);
            button.name = "ModButton";

            //set position
            button.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 100 - ((count + 1) * 30));

            //set color
            button.GetComponent <Image>().color                        = new Color(0.75f, 0.75f, 0.75f, 0.5f);
            button.GetComponent <MenuButton>().NormalColor             = new Color(0.75f, 0.75f, 0.75f, 0.5f);
            button.GetComponent <MenuButton>().HoverColor              = new Color(0.75f, 0.75f, 0.75f, 1f);
            button.transform.Find("Fill").GetComponent <Image>().color = new Color(0.5f, 0.5f, 0.5f, 0.5f);

            //set text
            button.transform.Find("Text").GetComponent <Text>().text = mod.Name;
            if (GlobalControls.crate)
            {
                button.transform.Find("Text").GetComponent <Text>().text = Temmify.Convert(mod.Name, true);
            }

            //finally, set function!
            int tempCount = count;

            button.GetComponent <Button>().onClick.RemoveAllListeners();
            button.GetComponent <Button>().onClick.AddListener(() => {
                // Store the encounter box's position so it can be remembered upon exiting a mod
                modListScroll = content.GetComponent <RectTransform>().anchoredPosition.y;

                CurrentSelectedMod = tempCount;
                modFolderSelection();
                ShowMod(CurrentSelectedMod);
            });
        }
    }
Esempio n. 3
0
    // Shows the list of available encounters in a mod.
    private void encounterSelection()
    {
        //hide the mod list button
        btnList.SetActive(false);

        //automatically choose "back"
        selectedItem = 0;

        // Make clicking the background exit the encounter selection screen
        GameObject.Find("ModBackground").GetComponent <Button>().onClick.RemoveAllListeners();
        GameObject.Find("ModBackground").GetComponent <Button>().onClick.AddListener(() => {
            if (animationDone)
            {
                modFolderSelection();
            }
        });
        //show the encounter selection box
        encounterBox.SetActive(true);
        //reset the encounter box's position
        encounterBox.transform.Find("ScrollCutoff/Content").GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0);

        //grab pre-existing objects
        GameObject content = encounterBox.transform.Find("ScrollCutoff/Content").gameObject;
        //give the back button its function
        GameObject back = content.transform.Find("Back").gameObject;

        back.GetComponent <Button>().onClick.RemoveAllListeners();
        back.GetComponent <Button>().onClick.AddListener(() => { modFolderSelection(); });

        DirectoryInfo di = new DirectoryInfo(Path.Combine(FileLoader.DataRoot, "Mods/" + StaticInits.MODFOLDER + "/Lua/Encounters"));

        if (di.Exists && di.GetFiles().Length > 0)
        {
            FileInfo[] encounterFiles = di.GetFiles("*.lua");

            int count = 0;
            foreach (FileInfo encounter in encounterFiles)
            {
                count += 1;

                //create a button for each encounter file
                GameObject button = Instantiate(back);

                //set parent and name
                button.transform.SetParent(content.transform);
                button.name = "EncounterButton";

                //set position
                button.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 100 - (count * 30));

                //set color
                button.GetComponent <Image>().color                        = new Color(0.75f, 0.75f, 0.75f, 0.5f);
                button.GetComponent <MenuButton>().NormalColor             = new Color(0.75f, 0.75f, 0.75f, 0.5f);
                button.GetComponent <MenuButton>().HoverColor              = new Color(0.75f, 0.75f, 0.75f, 1f);
                button.transform.Find("Fill").GetComponent <Image>().color = new Color(0.5f, 0.5f, 0.5f, 0.5f);

                // set text
                button.transform.Find("Text").GetComponent <Text>().text = Path.GetFileNameWithoutExtension(encounter.Name);
                if (GlobalControls.crate)
                {
                    button.transform.Find("Text").GetComponent <Text>().text = Temmify.Convert(Path.GetFileNameWithoutExtension(encounter.Name), true);
                }

                //finally, set function!
                string filename = Path.GetFileNameWithoutExtension(encounter.Name);

                int tempCount = count;

                button.GetComponent <Button>().onClick.RemoveAllListeners();
                button.GetComponent <Button>().onClick.AddListener(() => {
                    selectedItem          = tempCount;
                    StaticInits.ENCOUNTER = filename;
                    StartCoroutine(LaunchMod());
                });
            }
        }
    }
Esempio n. 4
0
    // Shows a mod's "page".
    private void ShowMod(int id)
    {
        // Error handler
        // If current index is now out of range OR currently selected mod is not present:
        if (CurrentSelectedMod < 0 || CurrentSelectedMod > modDirs.Count - 1 ||
            !(new DirectoryInfo(Path.Combine(FileLoader.DataRoot, "Mods/" + modDirs[CurrentSelectedMod].Name + "/Lua/Encounters"))).Exists ||
            (new DirectoryInfo(Path.Combine(FileLoader.DataRoot, "Mods/" + modDirs[CurrentSelectedMod].Name + "/Lua/Encounters"))).GetFiles("*.lua").Length == 0)
        {
            HandleErrors();
            return;
        }

        // Update currently selected mod folder
        //StaticInits.MODFOLDER = modDirs[id].Name;

        // Make clicking the background go to the encounter select screen
        GameObject.Find("ModBackground").GetComponent <Button>().onClick.RemoveAllListeners();
        GameObject.Find("ModBackground").GetComponent <Button>().onClick.AddListener(() => {
            if (animationDone)
            {
                encounterSelection();
            }
        });

        // Update the background
        var ImgComp = GameObject.Find("ModBackground").GetComponent <Image>();

        // First, check if we already have this mod's background loaded in memory
        if (bgs.ContainsKey(modDirs[CurrentSelectedMod].Name))
        {
            ImgComp.sprite = bgs[modDirs[CurrentSelectedMod].Name];
        }
        else
        {
            // if not, find it and store it
            try {
                Sprite thumbnail = SpriteUtil.FromFile(FileLoader.pathToModFile("Sprites/preview.png"));
                ImgComp.sprite = thumbnail;
            } catch {
                try {
                    Sprite bg = SpriteUtil.FromFile(FileLoader.pathToModFile("Sprites/bg.png"));
                    ImgComp.sprite = bg;
                } catch { ImgComp.sprite = SpriteUtil.FromFile("Sprites/black.png"); }
            }
            bgs.Add(modDirs[CurrentSelectedMod].Name, ImgComp.sprite);
        }

        // Get all encounters in the mod's Encounters folder
        List <string> encounters = new List <string>();
        DirectoryInfo di         = new DirectoryInfo(Path.Combine(FileLoader.ModDataPath, "Lua/Encounters"));

        foreach (FileInfo f in di.GetFiles("*.lua"))
        {
            encounters.Add(Path.GetFileNameWithoutExtension(f.Name));
        }

        // Update the text
        GameObject.Find("ModTitle").GetComponent <Text>().text = modDirs[id].Name;
        // Crate your frisk version
        if (GlobalControls.crate)
        {
            GameObject.Find("ModTitle").GetComponent <Text>().text = Temmify.Convert(modDirs[id].Name, true);
        }
        GameObject.Find("ModTitleShadow").GetComponent <Text>().text = GameObject.Find("ModTitle").GetComponent <Text>().text;

        // List # of encounters, or name of encounter if there is only one
        if (encounters.Count == 1)
        {
            GameObject.Find("EncounterCount").GetComponent <Text>().text = encounters[0];
            // crate your frisk version
            if (GlobalControls.crate)
            {
                GameObject.Find("EncounterCount").GetComponent <Text>().text = Temmify.Convert(encounters[0], true);
            }

            // Make clicking the bg directly open the encounter
            GameObject.Find("ModBackground").GetComponent <Button>().onClick.RemoveAllListeners();
            GameObject.Find("ModBackground").GetComponent <Button>().onClick.AddListener(() => {
                if (animationDone)
                {
                    StaticInits.ENCOUNTER = encounters[0];
                    StartCoroutine(LaunchMod());
                }
            });
        }
        else
        {
            GameObject.Find("EncounterCount").GetComponent <Text>().text = "Has " + encounters.Count + " encounters";
            // crate your frisk version
            if (GlobalControls.crate)
            {
                GameObject.Find("EncounterCount").GetComponent <Text>().text = "HSA " + encounters.Count + " ENCUOTNERS";
            }
        }
        GameObject.Find("EncounterCountShadow").GetComponent <Text>().text = GameObject.Find("EncounterCount").GetComponent <Text>().text;

        // Update the color of the arrows
        if (CurrentSelectedMod == 0 && modDirs.Count == 1)
        {
            GameObject.Find("BtnBack").transform.Find("Text").gameObject.GetComponent <Text>().color = new Color(0.25f, 0.25f, 0.25f, 1f);
        }
        else
        {
            GameObject.Find("BtnBack").transform.Find("Text").gameObject.GetComponent <Text>().color = new Color(1f, 1f, 1f, 1f);
        }
        if (CurrentSelectedMod == modDirs.Count - 1 && modDirs.Count == 1)
        {
            GameObject.Find("BtnNext").transform.Find("Text").gameObject.GetComponent <Text>().color = new Color(0.25f, 0.25f, 0.25f, 1f);
        }
        else
        {
            GameObject.Find("BtnNext").transform.Find("Text").gameObject.GetComponent <Text>().color = new Color(1f, 1f, 1f, 1f);
        }
    }
Esempio n. 5
0
    // Gets the text the description should use based on what button is currently being hovered over
    private string GetDescription(string buttonName)
    {
        string response;

        switch (buttonName)
        {
        case "ResetRG":
            response = "Resets all Real Globals.\n\n"
                       + "Real Globals are variables that persist through battles, but are deleted when CYF is closed.";
            return(!GlobalControls.crate ? response : Temmify.Convert(response));

        case "ResetAG":
            response = "Resets all AlMighty Globals.\n\n"
                       + "AlMighty Globals are variables that are saved to a file, and stay even when you close CYF.\n\n"
                       + "The options on this screen are stored as AlMighties.";
            return(!GlobalControls.crate ? response : Temmify.Convert(response));

        case "ClearSave":
            response = "Clears your save file.\n\n"
                       + "This is the save file used for CYF's Overworld.\n\n"
                       + "Your save file is located at:\n\n";
            if (!GlobalControls.crate)
            {
                // return response + Application.persistentDataPath + "/save.gd</size></b>";
                return(response + "<b><size='14'>" + Application.persistentDataPath + "/save.gd</size></b>");
            }
            else
            {
                return(Temmify.Convert(response) + "<b><size='14'>" + Application.persistentDataPath + "/save.gd</size></b>");
            }

        case "Safe":
            response = "Toggles safe mode.\n\n"
                       + "This does nothing on its own, but mod authors can detect if you have this enabled, and use it to filter unsafe content, such as blood, gore, and swear words.";
            return(!GlobalControls.crate ? response : Temmify.Convert(response));

        case "Retro":
            response = "Toggles retrocompatibility mode.\n\n"
                       + "This mode is designed specifically to make encounters imported from Unitale v0.2.1a act as they did on the old engine.\n\n\n\n";
            if (!GlobalControls.crate)
            {
                return(response + "<b>CAUTION!\nDISABLE</b> this for mods made for CYF. This feature should only be used with Mods made for\n<b>Unitale v0.2.1a</b>.");
            }
            else
            {
                return(Temmify.Convert(response) + "<b>" + Temmify.Convert("CAUTION!\nDISABLE") + "</b> " + Temmify.Convert("this for mods made for CYF."));
            }

        case "Fullscreen":
            response = "Toggles blurless Fullscreen mode.\n\n"
                       + "This controls whether fullscreen mode will appear \"blurry\" or not.\n\n\n"
                       + "Press <b>F4</b> or <b>Alt+Enter</b> to toggle Fullscreen.";
            return(!GlobalControls.crate ? response : Temmify.Convert(response));

        case "Scale":
            response = "Scales the window in Windowed mode.\n\n"
                       + "This is useful for especially large screens (such as 4k monitors).\n\n"
                       + "Has no effect in Fullscreen mode.";
            return(!GlobalControls.crate ? response : Temmify.Convert(response));

        case "Discord":
            response = "Changes how much Discord Rich Presence should display on your profile regarding you playing Create Your Frisk.\n\n"
                       + "<b>Everything</b>: Everything is displayed: the mod you're playing, a timestamp and a description.\n\n"
                       + "<b>Game Only</b>: Only shows that you're playing Create Your Frisk.\n\n"
                       + "<b>Nothing</b>: Disables Discord Rich Presence entirely.\n\n"
                       + "If CYF's connection to Discord is lost, you will have to restart CYF if you want your rich presence back.";
            return(!GlobalControls.crate ? response : Temmify.Convert(response));

        case "Exit":
            response = "Returns to the Mod Select screen.";
            return(!GlobalControls.crate ? response : Temmify.Convert(response));

        default:
            return(!GlobalControls.crate ? "Hover over an option and its description will appear here!" : "HOVR OVR DA TING N GET TEXT HEAR!!");
        }
    }