Beispiel #1
0
    // Goes to the next or previous mod with a little scrolling animation.
    // -1 for left, 1 for right
    private void ScrollMods(int dir)
    {
        // First, determine if the next mod should be shown
        bool animate = modDirs.Count > 1;

        //if ((dir == -1 && CurrentSelectedMod > 0) || (dir == 1 && CurrentSelectedMod < modDirs.Count - 1)) {

        // If the new mod is being shown, start the animation!
        if (!animate)
        {
            return;
        }
        animationTimer = dir / 10f;
        animationDone  = false;

        // Enable the "ANIM" assets
        AnimContainer.SetActive(true);
        AnimContainer.transform.localPosition               = new Vector2(0, 0);
        AnimModBackground.GetComponent <Image>().sprite     = ModBackground.GetComponent <Image>().sprite;
        AnimModTitleShadow.GetComponent <Text>().text       = ModTitleShadow.GetComponent <Text>().text;
        AnimModTitle.GetComponent <Text>().text             = ModTitle.GetComponent <Text>().text;
        AnimEncounterCountShadow.GetComponent <Text>().text = EncounterCountShadow.GetComponent <Text>().text;
        AnimEncounterCount.GetComponent <Text>().text       = EncounterCount.GetComponent <Text>().text;

        // Move all real assets to the side
        ModBackground.transform.Translate(640 * dir, 0, 0);
        ModTitleShadow.transform.Translate(640 * dir, 0, 0);
        ModTitle.transform.Translate(640 * dir, 0, 0);
        EncounterCountShadow.transform.Translate(640 * dir, 0, 0);
        EncounterCount.transform.Translate(640 * dir, 0, 0);

        // Actually choose the new mod
        CurrentSelectedMod = (CurrentSelectedMod + dir) % modDirs.Count;
        if (CurrentSelectedMod < 0)
        {
            CurrentSelectedMod += modDirs.Count;
        }

        ShowMod(CurrentSelectedMod);
    }
Beispiel #2
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
        ModBackground.GetComponent <Button>().onClick.RemoveAllListeners();
        ModBackground.GetComponent <Button>().onClick.AddListener(() => {
            if (animationDone)
            {
                encounterSelection();
            }
        });

        // Update the background
        var ImgComp = 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
        DirectoryInfo di         = new DirectoryInfo(Path.Combine(FileLoader.ModDataPath, "Lua/Encounters"));
        List <string> encounters = di.GetFiles("*.lua").Select(f => Path.GetFileNameWithoutExtension(f.Name)).ToList();

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

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

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

        // Update the color of the arrows
        if (CurrentSelectedMod == 0 && modDirs.Count == 1)
        {
            BackText.color = new Color(0.25f, 0.25f, 0.25f, 1f);
        }
        else
        {
            BackText.color = new Color(1f, 1f, 1f, 1f);
        }
        if (CurrentSelectedMod == modDirs.Count - 1 && modDirs.Count == 1)
        {
            NextText.color = new Color(0.25f, 0.25f, 0.25f, 1f);
        }
        else
        {
            NextText.color = new Color(1f, 1f, 1f, 1f);
        }
    }