示例#1
0
        private IEnumerator _LoadList(string url)
        {
            var files = new List <Uri>();

            SetText("thinking");
            using (var www = new WWW(url))
            {
                while (!www.isDone)
                {
                    yield return(null);
                }

                var retrode = JsonUtility.FromJson <Retrode>(www.text);
                foreach (var file in retrode.files)
                {
                    files.Add(new Uri($"{retrode.url}{file}"));
                }
            }

            if (files.Count == 0)
            {
                yield return(StartCoroutine(_ShowText("empty rom\ncheck your cartridge slot", 2f)));

                OnTouchBack();
            }
            else
            {
                var rom = string.Empty;
                for (var index = 0; index < files.Count; index++)
                {
                    var file = files[index];
                    var www  = new WWW(file.AbsoluteUri);
                    while (!www.isDone)
                    {
                        SetText($"download ({index+1}/{files.Count})\n[{www.progress:P}]");
                        SetProgress(www.progress);
                        yield return(null);
                    }

                    var fileext  = Path.GetExtension(file.AbsolutePath);
                    var filename = Path.GetFileName(file.AbsolutePath);
                    var filepath = Path.Combine(Application.persistentDataPath, filename);

                    Debug.Log(filepath);
                    File.WriteAllBytes(filepath, www.bytes);

                    if (string.IsNullOrEmpty(rom) && (fileext == ".sfc" || fileext == ".smc"))
                    {
                        rom = filename;
                    }
                }

                if (string.IsNullOrEmpty(rom))
                {
                    yield return(StartCoroutine(_ShowText("empty rom\ncheck your cartridge slot", 2f)));

                    OnTouchBack();
                }
                else
                {
                    SetText($"loading");
                    yield return(new WaitForSeconds(1f));

                    Frontend.ChangeGame(rom);
                    Frontend.OnMenuOpen("");
                }
            }
        }
示例#2
0
 protected virtual void Start()
 {
     Frontend = FindObjectOfType <Frontend>();
 }
示例#3
0
 public void OnTouchBack()
 {
     Frontend.OnMenuOpen("ui/menus");
 }
示例#4
0
 public void OnTouchBack()
 {
     Frontend.OnMenuOpen("ui/settings");
 }