IEnumerator PhotoCor()
    {
        yield return(new WaitForSeconds(0.1f));

        string pname = "Screenshot " + System.DateTime.Now.Year + System.DateTime.Now.Month + System.DateTime.Now.Day + System.DateTime.Now.Hour + System.DateTime.Now.Minute + System.DateTime.Now.Second + ".png";

        if (!FilesSet.CheckDirectory(FastFind.GetDefaultPath() + "/SLywnow/rEFInd theme editor/Screenshots"))
        {
            FilesSet.CreateDirectory(FastFind.GetDefaultPath() + "/SLywnow/rEFInd theme editor/Screenshots");
        }
        ScreenCapture.CaptureScreenshot(FastFind.GetDefaultPath() + "/SLywnow/rEFInd theme editor/Screenshots/" + pname);
        //Debug.Log(FastFind.GetDefaultPath() + "/SLywnow/rEFInd theme editor/Screenshots/" + pname);
        makescreen.Play();
        yield return(new WaitForSeconds(0.1f));

        showui.SetActive(true);
    }
    public void OpenFolder(bool first)
    {
        string path;

        if (first)
        {
            path       = FastFind.GetDefaultPath() + "/SLywnow/rEFInd theme editor/projects";
            state.path = path;
        }
        else
        {
            path       = state.select;
            state.path = path;
        }
        state.prevpath = path;
        for (int i = state.prevpath.Length - 1; i >= 0; i--)
        {
            if (!(state.prevpath[i] == '/' || state.prevpath[i] == '\\'))
            {
                //Debug.Log(state.prevpath[i]);
                state.prevpath = state.prevpath.Remove(i);
            }
            else
            {
                state.prevpath = state.prevpath.Remove(i);
                break;
            }
        }
        browser.path.text = path;

        state.select = "";

        dirs      = FilesSet.GetFilesFromdirectories(path, "", false, FilesSet.TypeOfGet.Directory).ToList <string>();
        dirsnames = FilesSet.GetFilesFromdirectories(path, "", false, FilesSet.TypeOfGet.NamesOfDirectories).ToList <string>();

        string tpe = "";

        if (state.CurrentType == CurentState.current.image)
        {
            tpe = state.imagefiles;
        }
        if (state.CurrentType == CurentState.current.text)
        {
            tpe = state.textfiles;
        }
        if (state.CurrentType == CurentState.current.audio)
        {
            tpe = state.audfiles;
        }

        files      = FilesSet.GetFilesFromdirectories(path, tpe, false, FilesSet.TypeOfGet.Files).ToList <string>();
        filesnames = FilesSet.GetFilesFromdirectories(path, tpe, false, FilesSet.TypeOfGet.NamesOfFiles).ToList <string>();


        for (int i = browser.parrent.childCount - 1; i >= 0; i--)
        {
            Destroy(browser.parrent.GetChild(i).gameObject);
        }

        //setup
        {
            {
                GameObject obj = Instantiate(browser.FileBlock, browser.parrent);
                obj.SetActive(true);
                obj.GetComponent <openFileBlock>().id     = -1;
                obj.GetComponent <openFileBlock>().mypath = state.prevpath;
                obj.GetComponent <openFileBlock>().folder = true;
                if (string.IsNullOrEmpty(state.prevpath))
                {
                    obj.GetComponent <Button>().interactable = false;
                }

                FastFind.FindChild(obj.transform, "Name").GetComponent <Text>().text    = browser.moveuptext;
                FastFind.FindChild(obj.transform, "Icon").GetComponent <Image>().sprite = browser.moveup;
            }

            int idcur = 0;
            for (int i = 0; i < dirs.Count; i++)
            {
                GameObject obj = Instantiate(browser.FileBlock, browser.parrent);
                obj.SetActive(true);
                obj.GetComponent <openFileBlock>().id     = idcur;
                obj.GetComponent <openFileBlock>().mypath = dirs[i];
                obj.GetComponent <openFileBlock>().folder = true;
                FastFind.FindChild(obj.transform, "Name").GetComponent <Text>().text    = dirsnames[i];
                FastFind.FindChild(obj.transform, "Icon").GetComponent <Image>().sprite = browser.folder;
                idcur++;
            }
            for (int i = 0; i < files.Count; i++)
            {
                GameObject obj = Instantiate(browser.FileBlock, browser.parrent);
                obj.SetActive(true);
                obj.GetComponent <openFileBlock>().id     = idcur;
                obj.GetComponent <openFileBlock>().mypath = files[i];
                obj.GetComponent <openFileBlock>().folder = false;
                FastFind.FindChild(obj.transform, "Name").GetComponent <Text>().text    = filesnames[i];
                FastFind.FindChild(obj.transform, "Icon").GetComponent <Image>().sprite = browser.file;
                idcur++;
            }
        }
    }
    public void CreateNewProject(bool cancel)
    {
        if (cancel)
        {
            newthemename.text = "";
            newtheme.SetActive(false);
        }
        else
        {
            if (!string.IsNullOrEmpty(newthemename.text))
            {
                FilesSet.CreateDirectory(FastFind.GetDefaultPath() + "/SLywnow/rEFInd theme editor/projects/" + newthemename.text);
                List <string> tosave = new List <string>();
                for (int i = 0; i < configsc.text.Count; i++)
                {
                    string save = "";
                    if (configsc.text[i] == "<<bi>>")
                    {
                        save = "big_icon_size " + SaveSystemAlt.GetInt("Gconf_bi", 172).ToString();
                    }
                    else if (configsc.text[i] == "<<si>>")
                    {
                        save = "small_icon_size " + SaveSystemAlt.GetInt("Gconf_si", 72).ToString();
                    }
                    else if (configsc.text[i] == "<<st>>")
                    {
                        if (SaveSystemAlt.GetBool("Gconf_shd", true) || SaveSystemAlt.GetBool("Gconf_rb", true) || SaveSystemAlt.GetBool("Gconf_ex", false))
                        {
                            save = "showtools ";
                            bool firsthave = false;
                            if (SaveSystemAlt.GetBool("Gconf_shd", true))
                            {
                                save     += "shutdown";
                                firsthave = true;
                            }
                            if (SaveSystemAlt.GetBool("Gconf_rb", true))
                            {
                                if (firsthave)
                                {
                                    save += ",";
                                }
                                save     += "reboot";
                                firsthave = true;
                            }
                            if (SaveSystemAlt.GetBool("Gconf_ex", false))
                            {
                                if (firsthave)
                                {
                                    save += ",";
                                }
                                save     += "exit";
                                firsthave = true;
                            }
                        }
                        else
                        {
                            save = "#no showtools";
                        }
                    }
                    else
                    {
                        save = configsc.text[i];
                    }
                    tosave.Add(save);
                }

                if (!FilesSet.CheckFile(FastFind.GetDefaultPath() + "/SLywnow/rEFInd theme editor/projects/" + newthemename.text + "/theme.conf"))
                {
                    FilesSet.SaveStream(FastFind.GetDefaultPath() + "/SLywnow/rEFInd theme editor/projects/" + newthemename.text + "/theme.conf", tosave.ToArray());
                }

                newthemename.text = "";
                newtheme.SetActive(false);
                GetProjects();
            }
        }
    }
 public void OpenFolder()
 {
     Application.OpenURL(FastFind.GetDefaultPath() + "/SLywnow/rEFInd theme editor/Screenshots/");
 }
    void GetProjects()
    {
        for (int i = prew.parent.childCount - 1; i >= 0; i--)
        {
            Destroy(prew.parent.GetChild(i).gameObject);
        }

        string workdir = FastFind.GetDefaultPath() + "/SLywnow/rEFInd theme editor/projects";

        if (!FilesSet.CheckDirectory(workdir))
        {
            FilesSet.CreateDirectory(workdir);
        }

        dirs = FilesSet.GetFilesFromdirectories(workdir, "", false, FilesSet.TypeOfGet.NamesOfDirectories).ToList();

        bgs = new List <Sprite>();
        ics = new List <Sprite>();
        sls = new List <Sprite>();
        for (int i = 0; i < dirs.Count; i++)
        {
            string curdir = workdir + "/" + dirs[i];
            //create button
            GameObject obj = Instantiate(prew.block, prew.parent);
            obj.SetActive(true);

            FastFind.FindChild(obj.transform, "Name").GetComponent <Text>().text = dirs[i];

            obj.GetComponent <ProjSelButton>().i = i;

            Image bg  = FastFind.FindChild(obj.transform, "Bg").GetComponent <Image>();
            Image ico = FastFind.FindChild(obj.transform, "Icon").GetComponent <Image>();
            Image sel = FastFind.FindChild(obj.transform, "Selector").GetComponent <Image>();

            //load bg
            if (FilesSet.CheckFile(curdir + "/background.png", false))
            {
                FileStream streamimg = File.Open(curdir + "/background.png", FileMode.Open);
                byte[]     imgbt     = new byte[streamimg.Length];
                streamimg.Read(imgbt, 0, imgbt.Length);
                streamimg.Close();

                Texture2D imgtex = new Texture2D(0, 0);
                imgtex.LoadImage(imgbt);
                bgs.Add(Sprite.Create(imgtex, new Rect(0.0f, 0.0f, imgtex.width, imgtex.height), new Vector2(0.5f, 0.5f)));
                bg.sprite = bgs[bgs.Count - 1];
            }
            else
            {
                bgs.Add(prew.defbg);
                bg.sprite = bgs[bgs.Count - 1];
            }
            //load sel
            if (FilesSet.CheckFile(curdir + "/selection_big.png", false))
            {
                FileStream streamimg = File.Open(curdir + "/selection_big.png", FileMode.Open);
                byte[]     imgbt     = new byte[streamimg.Length];
                streamimg.Read(imgbt, 0, imgbt.Length);
                streamimg.Close();

                Texture2D imgtex = new Texture2D(0, 0);
                imgtex.LoadImage(imgbt);
                sls.Add(Sprite.Create(imgtex, new Rect(0.0f, 0.0f, imgtex.width, imgtex.height), new Vector2(0.5f, 0.5f)));
                sel.sprite = sls[sls.Count - 1];
            }
            else
            {
                sls.Add(prew.defsel);
                sel.sprite = sls[sls.Count - 1];
            }
            //load ico
            int      ind   = -1;
            string[] icons = null;
            if (FilesSet.CheckDirectory(curdir + "/icons"))
            {
                icons = FilesSet.GetFilesFromdirectories(curdir + "/icons", "png", false, FilesSet.TypeOfGet.NamesOfFiles);
                for (int a = 0; a < icons.Length; a++)
                {
                    if (icons[a].IndexOf("os_") >= 0)
                    {
                        ind = a; break;
                    }
                }
            }

            if ((ind > -1) && (FilesSet.CheckFile(curdir + "/icons/" + icons[ind] + ".png", false)))
            {
                FileStream streamimg = File.Open(curdir + "/icons/" + icons[ind] + ".png", FileMode.Open);
                byte[]     imgbt     = new byte[streamimg.Length];
                streamimg.Read(imgbt, 0, imgbt.Length);
                streamimg.Close();

                Texture2D imgtex = new Texture2D(0, 0);
                imgtex.LoadImage(imgbt);
                ics.Add(Sprite.Create(imgtex, new Rect(0.0f, 0.0f, imgtex.width, imgtex.height), new Vector2(0.5f, 0.5f)));
                ico.sprite = ics[ics.Count - 1];
            }
            else
            {
                ics.Add(prew.defico);
                ico.sprite = ics[ics.Count - 1];
            }
        }
    }
    public void GetProject(int i)
    {
        mode = md.editshow;
        //Debug.Log(i);
        projprev.SetActive(true);
        selectproj.SetActive(false);

        curProj.dir = FastFind.GetDefaultPath() + "/SLywnow/rEFInd theme editor/projects/" + dirs[i];

        //load structure
        //load bg
        if (FilesSet.CheckFile(curProj.dir + "/background.png", false))
        {
            FileStream streamimg = File.Open(curProj.dir + "/background.png", FileMode.Open);
            byte[]     imgbt     = new byte[streamimg.Length];
            streamimg.Read(imgbt, 0, imgbt.Length);
            streamimg.Close();

            Texture2D imgtex = new Texture2D(0, 0);
            imgtex.LoadImage(imgbt);
            curProj.bg = Sprite.Create(imgtex, new Rect(0.0f, 0.0f, imgtex.width, imgtex.height), new Vector2(0.5f, 0.5f));
        }
        else
        {
            curProj.bg = prew.defbg;
        }
        //load sel
        if (FilesSet.CheckFile(curProj.dir + "/selection_big.png", false))
        {
            FileStream streamimg = File.Open(curProj.dir + "/selection_big.png", FileMode.Open);
            byte[]     imgbt     = new byte[streamimg.Length];
            streamimg.Read(imgbt, 0, imgbt.Length);
            streamimg.Close();

            Texture2D imgtex = new Texture2D(0, 0);
            imgtex.LoadImage(imgbt);
            curProj.b_select = Sprite.Create(imgtex, new Rect(0.0f, 0.0f, imgtex.width, imgtex.height), new Vector2(0.5f, 0.5f));
        }
        else
        {
            curProj.b_select = prew.defsel;
        }
        if (FilesSet.CheckFile(curProj.dir + "/selection_small.png", false))
        {
            FileStream streamimg = File.Open(curProj.dir + "/selection_small.png", FileMode.Open);
            byte[]     imgbt     = new byte[streamimg.Length];
            streamimg.Read(imgbt, 0, imgbt.Length);
            streamimg.Close();

            Texture2D imgtex = new Texture2D(0, 0);
            imgtex.LoadImage(imgbt);
            curProj.l_select = Sprite.Create(imgtex, new Rect(0.0f, 0.0f, imgtex.width, imgtex.height), new Vector2(0.5f, 0.5f));
        }
        else
        {
            curProj.l_select = prew.defsel;
        }
        //load ico
        string[] icons = null;
        if (FilesSet.CheckDirectory(curProj.dir + "/icons"))
        {
            icons = FilesSet.GetFilesFromdirectories(curProj.dir + "/icons", "png", false, FilesSet.TypeOfGet.NamesOfFiles);
            for (int a = 0; a < icons.Length; a++)
            {
                if (icons[a].IndexOf("os_") >= 0)
                {
                    FileStream streamimg = File.Open(curProj.dir + "/icons/" + icons[a] + ".png", FileMode.Open);
                    byte[]     imgbt     = new byte[streamimg.Length];
                    streamimg.Read(imgbt, 0, imgbt.Length);
                    streamimg.Close();

                    Texture2D imgtex = new Texture2D(0, 0);
                    imgtex.LoadImage(imgbt);
                    curProj.oss.Add(Sprite.Create(imgtex, new Rect(0.0f, 0.0f, imgtex.width, imgtex.height), new Vector2(0.5f, 0.5f)));
                    curProj.ossp.Add(icons[a].Replace("os_", ""));
                }
                if (icons[a].IndexOf("func_") >= 0)
                {
                    FileStream streamimg = File.Open(curProj.dir + "/icons/" + icons[a] + ".png", FileMode.Open);
                    byte[]     imgbt     = new byte[streamimg.Length];
                    streamimg.Read(imgbt, 0, imgbt.Length);
                    streamimg.Close();

                    Texture2D imgtex = new Texture2D(0, 0);
                    imgtex.LoadImage(imgbt);
                    curProj.funcs.Add(Sprite.Create(imgtex, new Rect(0.0f, 0.0f, imgtex.width, imgtex.height), new Vector2(0.5f, 0.5f)));
                    curProj.funcsp.Add(icons[a].Replace("func_", ""));
                }
            }
        }

        //get theme.conf
        if (FilesSet.CheckFile(curProj.dir + "/theme.conf", false))
        {
            List <string> conf = FilesSet.LoadStream(curProj.dir + "/theme.conf", false).ToList();
            for (int c = 0; c < conf.Count; c++)
            {
                if (!((conf[c].IndexOf("#")) >= 0) && (conf[c].IndexOf("big_icon_size ") >= 0))
                {
                    curProj.bigicon = int.Parse(conf[c].Replace("big_icon_size ", ""));
                }
                if (!((conf[c].IndexOf("#")) >= 0) && (conf[c].IndexOf("small_icon_size ") >= 0))
                {
                    curProj.smallicon = int.Parse(conf[c].Replace("small_icon_size ", ""));
                }
            }
            if (curProj.bigicon == 0)
            {
                curProj.bigicon = 256;
            }
            if (curProj.smallicon == 0)
            {
                curProj.smallicon = 96;
            }
        }
        else
        {
            curProj.bigicon   = 256;
            curProj.smallicon = 96;
        }

        //setup workspace
        scene.bg.sprite         = curProj.bg;
        config.bigicon.text     = curProj.bigicon + "";
        config.smallicon.text   = curProj.smallicon + "";
        prevopt.screenX.text    = Screen.width + "";
        prevopt.screenY.text    = Screen.height + "";
        prevopt.selbig.sprite   = curProj.b_select;
        prevopt.selsmall.sprite = curProj.l_select;
        prevopt.bgimg.sprite    = curProj.bg;

        for (int o = 0; o < curProj.oss.Count; o++)
        {
            GameObject obj = Instantiate(prevopt.togpresset, prevopt.osscroll);
            obj.SetActive(true);
            FastFind.FindChild(obj.transform, "Icon").GetComponent <Image>().sprite = curProj.oss[o];
            FastFind.FindChild(obj.transform, "Name").GetComponent <Text>().text    = curProj.ossp[o];
            obj.GetComponent <ProjPrevToggle>().i   = o;
            obj.GetComponent <ProjPrevToggle>().tpe = ProjPrevToggle.tp.os;
            prevopt.ostog.Add(obj.GetComponent <Toggle>());
        }
        for (int f = 0; f < curProj.funcs.Count; f++)
        {
            GameObject obj = Instantiate(prevopt.togpresset, prevopt.funcscroll);
            obj.SetActive(true);
            FastFind.FindChild(obj.transform, "Icon").GetComponent <Image>().sprite = curProj.funcs[f];
            FastFind.FindChild(obj.transform, "Name").GetComponent <Text>().text    = curProj.funcsp[f];
            obj.GetComponent <ProjPrevToggle>().i   = f;
            obj.GetComponent <ProjPrevToggle>().tpe = ProjPrevToggle.tp.func;
            prevopt.functog.Add(obj.GetComponent <Toggle>());
        }
    }