示例#1
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.GetNameForInspector();
                added.comment           = DateTime.Now.ToString(CultureInfo.InvariantCulture);
            }

            if (inspectedState == -1)
            {
                UnityEngine.Object myType = null;
                if ("From File:".edit(65, ref myType))
                {
                    added = new CfgState();
                    added.dataExplorer.data = QcFile.Loading.TryLoadAsTextAsset(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.SaveCfgData();
                    }
                    var slfData = selfStd.ConfigStd;
                    if (!string.IsNullOrEmpty(slfData))
                    {
                        if (icon.Load.Click("Use IKeepMySTD data to create new CFG"))
                        {
                            var ss = new CfgState();
                            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);
        }