Пример #1
0
 public static T LoadFromAssets <T>(this T s, string fullPath, string name) where T : ICfg, new()
 {
     if (s == null)
     {
         s = new T();
     }
     s.Decode(FileLoadUtils.LoadBytesFromAssets(fullPath, name));
     return(s);
 }
Пример #2
0
 public static T LoadFromResources <T>(this T s, string subFolder, string file) where T : ICfg, new()
 {
     if (s == null)
     {
         s = new T();
     }
     s.Decode(FileLoadUtils.LoadBytesFromResource(subFolder, file));
     return(s);
 }
Пример #3
0
        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);
        }
Пример #4
0
        public static bool LoadOnDrop(out string txt)
        {
            txt = null;
#if PEGI
            UnityEngine.Object myType = null;
            if (pegi.edit(ref myType))
            {
                txt = FileLoadUtils.TryLoadAsTextAsset(myType);
                ("Loaded " + myType.name).showNotificationIn3D_Views();

                return(true);
            }
#endif
            return(false);
        }
Пример #5
0
        public bool Inspect()
        {
            if (_tags == null && data.Contains("|"))
            {
                Decode(data);
            }

            if (_tags != null)
            {
                tag.edit_List(ref _tags, ref inspectedTag).changes(ref dirty);
            }

            if (inspectedTag == -1)
            {
                "data".edit(40, ref data).nl(ref dirty);

                UnityEngine.Object myType = null;

                if (pegi.edit(ref myType))
                {
                    dirty = true;
                    data  = FileLoadUtils.TryLoadAsTextAsset(myType);
                }

                if (dirty)
                {
                    if (icon.Refresh.Click("Update data string from tags"))
                    {
                        UpdateData();
                    }

                    if (icon.Load.Click("Load from data String").nl())
                    {
                        _tags = null;
                        Decode(data);//.DecodeTagsFor(this);
                        dirty = false;
                    }
                }
            }


            pegi.nl();

            return(dirty);
        }
Пример #6
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);
        }