private void _Genrate() { if (ExistItems != null) { foreach (var existItem in ExistItems) { DestroyImmediate(existItem.gameObject); } ExistItems = null; } var us = new CultureInfo("en-US"); var saves = Frontend.GetStateFilePaths(); var list = new List <RectTransform>(); foreach (var save in saves) { var filename = Path.GetFileNameWithoutExtension(save); var time = filename.Substring(filename.Length - 17, 17); var date = DateTime.ParseExact(time, "yyyy'-'MM'-'dd'_'HHmmss", us); var obj = Instantiate(ItemPrefab, Container); var item = obj.GetComponent <ViewStateItem>(); item.LoadButton.onClick.AddListener(() => { Frontend.LoadState(save); Frontend.OnMenuOpen(""); }); item.DeleteButton.onClick.AddListener(() => { if (File.Exists(save)) { File.Delete(save); } _Refresh(); }); item.Label.text = $"{date:G}"; list.Add(obj); } ExistItems = list.ToArray(); NewItem.GetComponent <Button>().onClick.AddListener(() => { Frontend.SaveState(); _Refresh(); }); }
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(""); } } }
public void OnTouchBack() { Frontend.OnMenuOpen("ui/menus"); }
public void OnTouchBack() { Frontend.OnMenuOpen("ui/settings"); }