public static bool CopyPasteStdPegi(this ICfg cfg) { if (cfg == null) { return(false); } var changed = false; if (_toCopy == null && icon.Copy.Click("Copy {0}".F(cfg.GetNameForInspector())).changes(ref changed)) { _toCopy = cfg; } if (_toCopy == null) { return(changed); } if (icon.Close.Click("Empty copy buffer")) { _toCopy = null; } else if (!Equals(cfg, _toCopy) && icon.Paste.Click("Copy {0} into {1}".F(_toCopy, cfg))) { TryCopy_Std_AndOtherData(_toCopy, cfg); } return(changed); }
public static bool SendReceivePegi(this ICfg cfg, string name, string folderName, out string data) { if (icon.Email.Click("Send {0} to somebody via email.".F(folderName))) { cfg.EmailData(name, "Use this {0}".F(name)); } data = ""; if (pegi.edit(ref data).UnFocusIfTrue()) { data = ClearFromExternal(data); return(true); } if (icon.Folder.Click("Save {0} to the file".F(name))) { cfg.SaveToAssets(folderName, name); QcUnity.RefreshAssetDatabase(); } if (DropStringObject(out data)) { return(true); } pegi.nl(); return(false); }
public CfgEncoder Add(string tag, ICfg other) { if (QcUnity.IsNullOrDestroyed_Obj(other)) { return(this); } var safe = other as ICfgSafeEncoding; if (safe == null) { return(Add(tag, other.Encode())); } var ll = safe.GetLoopLock; if (ll.Unlocked) { using (ll.Lock()) { Add(tag, other.Encode()); } } else { Debug.LogError("Infinite encoding loop detected"); } return(this); }
public CfgEncoder Add(string tag, ICfg other) { if (QcUnity.IsNullOrDestroyed_Obj(other)) { return(this); } return(Add(tag, other.Encode())); }
public static bool Decode_ifNotNull(this ICfg istd, string data) { if (istd == null) { return(false); } istd.Decode(data); return(true); }
public static bool LoadFromPersistentPath(this ICfg s, string path, string filename) { var data = QcFile.Load.FromPersistentPath(path, filename, asBytes: true); if (data != null) { s.Decode(data); return(true); } return(false); }
public static CfgEncoder Encode(this ICfg cfg, ICfgSerializeNestedReferences keeper) { var prevKeeper = CfgEncoder.keeper; CfgEncoder.keeper = keeper; var ret = cfg.Encode(); CfgEncoder.keeper = prevKeeper; return(ret); }
public CfgEncoder Add_IfNotDefault(string tag, ICfg cfg) { if (QcUnity.IsNullOrDestroyed_Obj(cfg)) { return(this); } var def = cfg as ICanBeDefaultCfg; return((def == null || !def.IsDefault) ? Add(tag, cfg) : this); }
public static void EmailData(this ICfg cfg, string subject, string note) { if (cfg == null) { return; } QcUnity.SendEmail("*****@*****.**", subject, "{0} {1} Copy this entire email and paste it in the corresponding field on your side to paste it (don't change data before pasting it). {2} {3}{4}{5}".F(note, pegi.EnvironmentNl, pegi.EnvironmentNl, StdStart, cfg.Encode().ToString(), StdEnd)); }
public static bool LoadFromPersistentPath(this ICfg s, string path, string filename) { var data = FileLoadUtils.LoadJsonFromPersistentPath(path, filename); if (data != null) { s.Decode(data); return(true); } return(false); }
public static void UpdatePrefab(this ICfg s, GameObject go) { var iK = s as IKeepMyCfg; if (iK != null) { iK.SaveStdData(); } UnityUtils.UpdatePrefab(go); }
public static void UpdateCfgPrefab(this ICfg s, GameObject go) { var iK = s as IKeepMyCfg; if (iK != null) { iK.SaveCfgData(); } QcUnity.UpdatePrefab(go); }
public CfgEncoder Add(string tag, ICfg other, ICfgSerializeNestedReferences referencesKeeper) { var prevKeeper = keeper; keeper = referencesKeeper; Add(tag, other); keeper = prevKeeper; return(this); }
public static CfgEncoder Encode(this ICfg cfg, ICfgSerializeNestedReferences keeper) { var prevKeeper = CfgEncoder.keeper; CfgEncoder.keeper = keeper; var ret = cfg.Encode(); (keeper as UnityEngine.Object).SetToDirty(); CfgEncoder.keeper = prevKeeper; return(ret); }
public static bool PEGI_Static(ICfg target) { inspectedCfg = target; var changed = false; "Load File:".write(90); target.LoadOnDrop().nl(ref changed); if (icon.Copy.Click("Copy Component Data").nl()) { StdExtensions.copyBufferValue = target.Encode().ToString(); } pegi.nl(); return(changed); }
public static T TryDecodeInto <T>(this ICfg ovj, Type childType) { var val = (T)Activator.CreateInstance(childType); if (ovj == null) { return(val); } var std = val as ICfg; if (std == null) { return(val); } std.DecodeFull(new CfgData(ovj.Encode().ToString())); return(val); }
public static ICfg SaveToPersistentPath(this ICfg s, string path, string filename) { QcFile.Save.ToPersistentPath(path, filename, s.Encode().ToString(), asBytes: true); return(s); }
public static ICfg SaveToResources(this ICfg s, string resFolderPath, string insideResPath, string filename) { FileSaveUtils.SaveBytesToResources(resFolderPath, insideResPath, filename, s.Encode().ToString()); return(s); }
public static ICfg SaveToAssets(this ICfg s, string path, string filename) { FileSaveUtils.SaveBytesToAssetsByRelativePath(path, filename, s.Encode().ToString()); return(s); }
public static ICfg SaveToPersistentPath(this ICfg s, string path, string filename) { FileSaveUtils.SaveJsonToPersistentPath(path, filename, s.Encode().ToString()); return(s); }
public static void DecodeFromExternal(this ICfg cfg, string data) => cfg?.Decode(ClearFromExternal(data));
public static bool Decode(this ICfg cfg, string data, ICfgSerializeNestedReferences keeper) => data.DecodeInto(cfg, keeper);
public static ICfg SaveToAssets(this ICfg s, string path, string filename) { QcFile.Save.ToAssets(path, filename, s.Encode().ToString()); return(s); }
public bool Inspect(ICfg target) { var changed = false; inspectedCfg = target; inspected = this; var added = "Saved CFGs:".edit_List(ref states, ref inspectedState, ref changed); if (added != null && target != null) { added.dataExplorer.data = target.Encode().ToString(); added.NameForPEGI = target.ToPegiString(); added.comment = DateTime.Now.ToString(CultureInfo.InvariantCulture); } if (inspectedState == -1) { UnityEngine.Object myType = null; if ("From File:".edit(65, ref myType)) { added = new SavedIstd(); added.dataExplorer.data = FileLoadUtils.LoadTextAsset(myType); added.NameForPEGI = myType.name; added.comment = DateTime.Now.ToString(CultureInfo.InvariantCulture); states.Add(added); } var selfStd = target as IKeepMyCfg; if (selfStd != null) { if (icon.Save.Click("Save itself (IKeepMySTD)")) { selfStd.SaveStdData(); } var slfData = selfStd.ConfigStd; if (!string.IsNullOrEmpty(slfData)) { if (icon.Load.Click("Use IKeepMySTD data to create new CFG")) { var ss = new SavedIstd(); states.Add(ss); ss.dataExplorer.data = slfData; ss.NameForPEGI = "from Keep my STD"; ss.comment = DateTime.Now.ToString(CultureInfo.InvariantCulture); } if (icon.Refresh.Click("Load from itself (IKeepMySTD)")) { target.Decode(slfData); } } } pegi.nl(); } inspectedCfg = null; return(changed); }
public static ICfg SaveToResources(this ICfg s, string resFolderPath, string insideResPath, string filename) { QcFile.Save.ToResources(resFolderPath, insideResPath, filename, s.Encode().ToString(), asBytes: true); return(s); }
public Com(ICfg cfg) { _cfg = cfg; }