예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        public CfgEncoder Add(string tag, ICfg other)
        {
            if (QcUnity.IsNullOrDestroyed_Obj(other))
            {
                return(this);
            }

            return(Add(tag, other.Encode()));
        }
예제 #5
0
파일: Decoder.cs 프로젝트: NeatWolf/Tools
        public static bool Decode_ifNotNull(this ICfg istd, string data)
        {
            if (istd == null)
            {
                return(false);
            }

            istd.Decode(data);
            return(true);
        }
예제 #6
0
        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);
        }
예제 #7
0
파일: Encoder.cs 프로젝트: NeatWolf/Tools
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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));
        }
예제 #10
0
파일: ICfg.cs 프로젝트: Hengle/Tools-3
        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);
        }
예제 #11
0
파일: ICfg.cs 프로젝트: Hengle/Tools-3
        public static void UpdatePrefab(this ICfg s, GameObject go)
        {
            var iK = s as IKeepMyCfg;

            if (iK != null)
            {
                iK.SaveStdData();
            }

            UnityUtils.UpdatePrefab(go);
        }
예제 #12
0
        public static void UpdateCfgPrefab(this ICfg s, GameObject go)
        {
            var iK = s as IKeepMyCfg;

            if (iK != null)
            {
                iK.SaveCfgData();
            }

            QcUnity.UpdatePrefab(go);
        }
예제 #13
0
파일: Encoder.cs 프로젝트: NeatWolf/Tools
        public CfgEncoder Add(string tag, ICfg other, ICfgSerializeNestedReferences referencesKeeper)
        {
            var prevKeeper = keeper;

            keeper = referencesKeeper;

            Add(tag, other);

            keeper = prevKeeper;

            return(this);
        }
예제 #14
0
        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);
        }
예제 #15
0
        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);
        }
예제 #16
0
        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);
        }
예제 #17
0
 public static ICfg SaveToPersistentPath(this ICfg s, string path, string filename)
 {
     QcFile.Save.ToPersistentPath(path, filename, s.Encode().ToString(), asBytes: true);
     return(s);
 }
예제 #18
0
파일: ICfg.cs 프로젝트: Hengle/Tools-3
 public static ICfg SaveToResources(this ICfg s, string resFolderPath, string insideResPath, string filename)
 {
     FileSaveUtils.SaveBytesToResources(resFolderPath, insideResPath, filename, s.Encode().ToString());
     return(s);
 }
예제 #19
0
파일: ICfg.cs 프로젝트: Hengle/Tools-3
 public static ICfg SaveToAssets(this ICfg s, string path, string filename)
 {
     FileSaveUtils.SaveBytesToAssetsByRelativePath(path, filename, s.Encode().ToString());
     return(s);
 }
예제 #20
0
파일: ICfg.cs 프로젝트: Hengle/Tools-3
 public static ICfg SaveToPersistentPath(this ICfg s, string path, string filename)
 {
     FileSaveUtils.SaveJsonToPersistentPath(path, filename, s.Encode().ToString());
     return(s);
 }
예제 #21
0
 public static void DecodeFromExternal(this ICfg cfg, string data) => cfg?.Decode(ClearFromExternal(data));
예제 #22
0
 public static bool Decode(this ICfg cfg, string data, ICfgSerializeNestedReferences keeper) => data.DecodeInto(cfg, keeper);
예제 #23
0
파일: ICfg.cs 프로젝트: Vytek/Tools
 public static ICfg SaveToAssets(this ICfg s, string path, string filename)
 {
     QcFile.Save.ToAssets(path, filename, s.Encode().ToString());
     return(s);
 }
예제 #24
0
        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);
        }
예제 #25
0
 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);
 }
예제 #26
0
파일: Program.cs 프로젝트: bashocz/Examples
 public Com(ICfg cfg)
 {
     _cfg = cfg;
 }