public static GonObject ArtAltsMerge(GonObject low, GonObject high) { // create new gonObject to return GonObject ret = new GonObject(); ret.Type = FieldType.ARRAY; List <string[]> lowArr = GonTo2DStringArray(low).ToList(); List <string[]> highArr = GonTo2DStringArray(high).ToList(); for (int i = 0; i < lowArr.Count(); i++) { bool found = false; for (int j = 0; j < highArr.Count(); j++) { if (lowArr[i][0] == highArr[j][0]) { ret.InsertChild(FromStringArray(highArr[j])); highArr.Remove(highArr[j]); found = true; break; } } if (!found) { ret.InsertChild(FromStringArray(lowArr[i])); } } foreach (var highItem in highArr) { ret.InsertChild(FromStringArray(highItem)); } return(ret); }
public static GonObject PriorityMerge(GonObject low, GonObject high) { // create new gonObject to return GonObject ret = new GonObject(); // iterate over the low-priority object's children for (int i = 0; i < low.Size(); i++) { string childName = low[i].Name; var lowChild = low[childName]; // step into if the same child exists in high priority object if (high[childName] != null) { var highChild = high[childName]; // special case for art_alts if (childName == "art_alts") { ret.InsertChild("art_alts", ArtAltsMerge(lowChild, highChild)); } // recurse if type is object else if (lowChild.Type == FieldType.OBJECT && highChild.Type == FieldType.OBJECT) { ret.InsertChild(PriorityMerge(lowChild, highChild)); } // otherwise just use the high-priority child else { ret.InsertChild(highChild); } } else { ret.InsertChild(lowChild); // if no high-priority child available, use low-priority child } } // iterate over high-priority object's children // copy those that do not already exist in low-priority object to return object for (int i = 0; i < high.Size(); i++) { string childName = high[i].Name; if (low[childName] == null) { ret.InsertChild(high[childName]); } } return(ret); }
public static void SaveShadersList(List <Shader> ShadersList) { if (ShadersList != null) { var gon = new GonObject(); foreach (var shader in ShadersList) { var item = new GonObject(); item.InsertChild(GonObject.Manip.FromBool(shader.Enabled, "enabled")); item.InsertChild(GonObject.Manip.FromString(shader.Content, "content")); gon.InsertChild(shader.Name, item); } gon.Save($"data/text/shaders.gon"); } }
public static GonObject FromStringArray(string[] arr, string name = "") { GonObject gon = new GonObject(); gon.Name = name; gon.Type = FieldType.ARRAY; foreach (string s in arr) { gon.InsertChild(FromString(s)); } return(gon); }
public static GonObject FromIntArray(int[] arr, string name = "") { GonObject gon = new GonObject(); gon.Name = name; gon.Type = FieldType.ARRAY; foreach (int i in arr) { gon.InsertChild(FromInt(i)); } return(gon); }
public void Save() { var gon = new GonObject(); gon.InsertChild(nameof(NumLevels), GonObject.Manip.FromInt(NumLevels)); gon.InsertChild(nameof(NumAreas), GonObject.Manip.FromInt(NumAreas)); gon.InsertChild(nameof(DoMusic), GonObject.Manip.FromBool(DoMusic)); gon.InsertChild(nameof(DoPalettes), GonObject.Manip.FromBool(DoPalettes)); gon.InsertChild(nameof(MusicPerLevel), GonObject.Manip.FromBool(MusicPerLevel)); gon.InsertChild(nameof(DoShaders), GonObject.Manip.FromBool(DoShaders)); gon.InsertChild(nameof(DoParticles), GonObject.Manip.FromBool(DoParticles)); gon.InsertChild(nameof(DoOverlays), GonObject.Manip.FromBool(DoOverlays)); gon.InsertChild(nameof(DoTileGraphics), GonObject.Manip.FromBool(DoTileGraphics)); gon.InsertChild(nameof(DoNevermoreTilt), GonObject.Manip.FromBool(DoNevermoreTilt)); gon.InsertChild(nameof(DoExodusWobble), GonObject.Manip.FromBool(DoExodusWobble)); gon.InsertChild(nameof(DoNPCs), GonObject.Manip.FromBool(DoNPCs)); gon.InsertChild(nameof(UseAreaTileset), GonObject.Manip.FromBool(UseAreaTileset)); gon.InsertChild(nameof(CacheRuns), GonObject.Manip.FromInt(CacheRuns)); gon.InsertChild(nameof(AreaType), GonObject.Manip.FromString(AreaType)); gon.InsertChild(nameof(RepeatTolerance), GonObject.Manip.FromInt(RepeatTolerance)); gon.InsertChild(nameof(AltLevel), GonObject.Manip.FromString(AltLevel)); gon.InsertChild(nameof(GenerateCustomParticles), GonObject.Manip.FromBool(GenerateCustomParticles)); gon.InsertChild(nameof(MaxParticles), GonObject.Manip.FromInt(MaxParticles)); gon.InsertChild(nameof(GameDirectory), GonObject.Manip.FromString(GameDirectory)); gon.InsertChild(nameof(MaxParticleEffects), GonObject.Manip.FromInt(MaxParticleEffects)); gon.InsertChild(nameof(ManualLoad), GonObject.Manip.FromBool(ManualLoad)); gon.InsertChild(nameof(DoCorruptions), GonObject.Manip.FromBool(DoCorruptions)); gon.InsertChild(nameof(MirrorMode), GonObject.Manip.FromBool(MirrorMode)); gon.InsertChild(nameof(DeadRacer), GonObject.Manip.FromBool(DeadRacer)); gon.InsertChild(nameof(CartLives), GonObject.Manip.FromInt(CartLives)); gon.InsertChild(nameof(DoPhysics), GonObject.Manip.FromBool(DoPhysics)); gon.InsertChild(nameof(PlatformPhysics), GonObject.Manip.FromBool(PlatformPhysics)); gon.InsertChild(nameof(PlayerPhysics), GonObject.Manip.FromBool(PlayerPhysics)); gon.InsertChild(nameof(WaterPhysics), GonObject.Manip.FromBool(WaterPhysics)); gon.InsertChild(nameof(LowGravPhysics), GonObject.Manip.FromBool(LowGravPhysics)); gon.InsertChild(nameof(LevelMerge), GonObject.Manip.FromBool(LevelMerge)); gon.InsertChild(nameof(ToolsInDirectory), GonObject.Manip.FromString(ToolsInDirectory)); gon.InsertChild(nameof(ToolsOutDirectory), GonObject.Manip.FromString(ToolsOutDirectory)); gon.InsertChild(nameof(RandomizeAreaType), GonObject.Manip.FromBool(RandomizeAreaType)); gon.InsertChild(nameof(CRSmart), GonObject.Manip.FromBool(CRSmart)); gon.InsertChild(nameof(CROverlays), GonObject.Manip.FromBool(CROverlays)); gon.InsertChild(nameof(CRTumors), GonObject.Manip.FromBool(CRTumors)); gon.InsertChild(nameof(CRAddTiles), GonObject.Manip.FromInt(CRAddTiles)); gon.InsertChild(nameof(CRAddEnemies), GonObject.Manip.FromInt(CRAddEnemies)); gon.InsertChild(nameof(CRSpikeStrips), GonObject.Manip.FromBool(CRSpikeStrips)); gon.InsertChild(nameof(CRCrumbles), GonObject.Manip.FromBool(CRCrumbles)); gon.InsertChild(nameof(CRCrushers), GonObject.Manip.FromBool(CRCrushers)); gon.InsertChild(nameof(CRChaos), GonObject.Manip.FromBool(CRChaos)); gon.InsertChild(nameof(CRWaterLevels), GonObject.Manip.FromBool(CRWaterLevels)); gon.InsertChild(nameof(UserName), GonObject.Manip.FromString(UserName)); gon.Save("data/text/settings.gon"); }