public void ReadOverride(Graph graph, Dictionary <Entry, object> ovd) ///Reads the graph's exposed values defaults, storing them to ovd ///If ovd already contains exposed value, it won't be overwritten { Dictionary <Guid, IExposedGuid> guidLut = graph.CompileGraphGuidLut(); ClearObsoleteEntries(graph); //required to avoid errors on getting fields ClearObsoleteOverride(ovd); //just in case if (entries == null || entries.Length == 0) { return; } for (int i = 0; i < entries.Length; i++) { if (ovd.ContainsKey(entries[i])) { continue; //already in list } IExposedGuid gen = guidLut[entries[i].guid]; Type genType = gen.GetType(); FieldInfo field = genType.GetField(entries[i].fieldName); object val = field.GetValue(gen); ovd.Add(entries[i], val); } }
public void ApplyOverride(Graph graph, Dictionary <Entry, object> ovd) ///Writes overridden value (ovd) to used graph { Dictionary <Guid, IExposedGuid> guidLut = graph.CompileGraphGuidLut(); ClearObsoleteEntries(graph); //required to avoid errors on getting fields if (entries == null || entries.Length == 0 || ovd == null || ovd.Count == 0) { return; } for (int i = 0; i < entries.Length; i++) { if (!ovd.ContainsKey(entries[i])) { continue; //exposed but not not overrided } IExposedGuid gen = guidLut[entries[i].guid]; Type genType = gen.GetType(); FieldInfo field = genType.GetField(entries[i].fieldName); object val = ovd[entries[i]]; field.SetValue(gen, val); } }
public void DrawGUI() { using (Cell.LinePx(32)) Draw.Label("WARNING: Keeping this asset selected in \nInspector can slow down editor GUI performance.", style: UI.current.styles.helpBox); Cell.EmptyLinePx(5); using (Cell.LinePx(24)) if (Draw.Button("Open Editor")) { GraphWindow.Show(graph); } using (Cell.LinePx(20)) if (Draw.Button("Open in New Tab")) { GraphWindow.ShowInNewTab(graph); } //seed Cell.EmptyLinePx(5); using (Cell.LineStd) { int newSeed = Draw.Field(graph.random.Seed, "Seed"); // if (newSeed != graph.random.Seed) { graph.random.Seed = newSeed; //Graph.OnChange.Raise(graph); } } using (Cell.LineStd) Draw.DualLabel("Nodes", graph.generators.Length.ToString()); using (Cell.LineStd) Draw.DualLabel("MapMagic ver", graph.serializedVersion.ToString()); Cell.EmptyLinePx(5); //global values /*using (Cell.LineStd) * using (new Draw.FoldoutGroup (ref showShared, "Global Values")) * if (showShared) * { * List<string> changedNames = new List<string>(); * List<object> changedVals = new List<object>(); * * (Type type, string name)[] typeNames = graph.sharedVals.GetTypeNames(); * for (int i=0; i<typeNames.Length; i++) * using (Cell.LineStd) GeneratorDraw.DrawGlobalVar(typeNames[i].type, typeNames[i].name); * * if (Cell.current.valChanged) * { * GraphWindow.current.mapMagic.ClearAllNodes(); * GraphWindow.current.mapMagic.StartGenerate(); * } * }*/ //exposed values using (Cell.LineStd) using (new Draw.FoldoutGroup(ref showExposed, "Exposed Values")) if (showExposed) { graph.exposed.ClearObsoleteEntries(graph); if (graph.exposed.entries != null) { for (int e = 0; e < graph.exposed.entries.Length; e++) { Exposed.Entry entry = graph.exposed.entries[e]; IExposedGuid gen = graph.FindGenByGuid(entry.guid); FieldInfo field = gen.GetType().GetField(entry.fieldName); using (Cell.LineStd) { if (field == null) { Draw.DualLabel(entry.guiName, "unknown"); } else { Draw.ClassField( field: field, type: entry.type, obj: gen, name: entry.guiName); } } if (Cell.current.valChanged) { GraphWindow.RefreshMapMagic(); } } } } //dependent graphs using (Cell.LineStd) using (new Draw.FoldoutGroup(ref showDependent, "Dependent Graphs")) if (showDependent) { using (Cell.LinePx(0)) DrawDependentGraphs(graph); } }