public void StringRequester(RequesterCallbackFn callback) { RequesterMode = RequesterMode.String; RequesterStringText = string.Empty; RequesterStringCallback = callback; RefreshUi(); }
public void FileRequester(RequesterCallbackFn callback, bool isSaving) { RequesterMode = RequesterMode.File; RequesterFileCallback = callback; RequesterFileIsSaving = isSaving; RequesterFileOldPath = string.Empty; RequesterFilePath = System.IO.Directory.GetCurrentDirectory(); RequesterFilePageSize = ((Screen.height / 2) - 16 - (isSaving ? 16 : 0)) / 16; RefreshUi(); }
private void SaveTo(String value, RequesterMode mode, Boolean forWriting) { enabled = true; RefreshImage(); RefreshUi(); if (value == null) { return; } Debug.Log("Saving file " + value); string data = SaveToString(); System.IO.File.WriteAllText(value, data); }
void _FileRequesterSaveName(string value, RequesterMode mode, bool forWriting) { if (value == null) { RequesterFileCallback(value, RequesterMode.File, true); } else { try { string fullPath = System.IO.Path.Combine(RequesterSaveDirectory, value); RequesterFileCallback(fullPath, RequesterMode.File, true); } catch (System.Exception e) { RequesterFileCallback(null, RequesterMode.File, true); } } }
private void LoadFrom(String value, RequesterMode mode, Boolean forWriting) { enabled = true; RefreshImage(); RefreshUi(); if (value == null) { return; } Debug.Log("Loading file " + value); string[] lines = System.IO.File.ReadAllLines(value); SpriteWidth = 8; int y = 0; byte[] frame = new byte[24 * 24]; int numFrames = 1; frames.Clear(); image = null; foreach (var line in lines) { //; FRAMES F //0123456789 if (line.StartsWith("; FRAMES")) { numFrames = HexToInt(line[9]); continue; } if (line.StartsWith("; SIZE 8x8")) { SpriteWidth = 0; continue; } else if (line.StartsWith("; SIZE 16x16")) { SpriteWidth = 1; continue; } else if (line.StartsWith("; SIZE 24x24")) { SpriteWidth = 2; continue; } //; PAL F06 //0123456 if (line.StartsWith("; PAL")) { spritePalette[1] = (byte)(1 + HexToInt(line[6 + 0])); spritePalette[2] = (byte)(1 + HexToInt(line[6 + 1])); spritePalette[3] = (byte)(1 + HexToInt(line[6 + 2])); Debug.LogFormat("{0:X1}", spritePalette[1]); Debug.LogFormat("{0:X1}", spritePalette[2]); Debug.LogFormat("{0:X1}", spritePalette[3]); continue; } if (line.StartsWith(";") == false) { continue; } int lw = ((1 + SpriteWidth) * 8); int lineLength = 1 + lw; if (line.Length != lineLength) { continue; } for (int i = 0; i < lw; i++) { char c = line[1 + i]; Byte b = 0; if (c == '0') { b = 0; } else if (c == '1') { b = 1; } else if (c == '2') { b = 2; } else if (c == '3') { b = 3; } frame[i + (y * 24)] = b; } y++; if (y == 8) { image = frame; frames.Add(frame); frame = new byte[24 * 24]; y = 0; } } RefreshImage(); RefreshUi(); }
void StopStringRequester() { RequesterMode = RequesterMode.None; }
void StopFileRequester() { RequesterMode = RequesterMode.None; }