public static Show ( string text, MessageBoxButtons buttons, MessageBoxIcon icon ) : DialogResult | ||
text | string | |
buttons | MessageBoxButtons | |
icon | MessageBoxIcon | |
return | DialogResult |
public bool Compile(string fileName, Dictionary <string, int> Defines, List <IZone> zones) { this.Defines = Defines; StreamWriter file; List <String> lines = new List <string>(); foreach (Zone zone in zones) { if (!ZoneContains(zone.Terrain, zone, "Terrain")) { return(false); } if (!ZoneContains(zone.Fill, zone, "Fill")) { return(false); } if (!ZoneContains(zone.Chance, zone, "Chance")) { return(false); } if (Utils.IsOutOfZoneBoundries(zone.X, zone.Y)) { if (Message.Show("Failed bound check on zone " + zone.X + "," + zone.Y + ". Do you want to skip this zone?", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.No) { return(false); } else { continue; } } string line = zone.X + "," + zone.Y + "|" + zone.Difficulty.ToString() + "," + Defines[zone.Terrain].ToString() + "," + Defines[zone.Fill].ToString() + "," + Defines[zone.Chance].ToString(); line += "|"; if (zone.EncounterLocations != null && zone.EncounterLocations.Count > 0) { for (int i = 0; i < zone.EncounterLocations.Count; i++) { if (zone.EncounterLocations[i].Name == "") { continue; } if (!Defines.ContainsKey(zone.EncounterLocations[i].Name)) { Message.Show("Unable to find Location define in _maps.fos for " + zone.EncounterLocations[i].Name, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (i == zone.EncounterLocations.Count - 1) { line += Defines[zone.EncounterLocations[i].Name]; } else { line += Defines[zone.EncounterLocations[i].Name] + ","; } } } line += "|"; if (zone.EncounterGroups != null && zone.EncounterGroups.Count > 0) { for (int i = 0; i < zone.EncounterGroups.Count; i++) { if (!ZoneContains(zone.EncounterGroups[i].Name, zone, "Group")) { return(false); } if (i == zone.EncounterGroups.Count - 1) { line += Defines[zone.EncounterGroups[i].Name] + ":" + zone.EncounterGroups[i].Quantity; } else { line += Defines[zone.EncounterGroups[i].Name] + ":" + zone.EncounterGroups[i].Quantity + ","; } } } line += "|"; if (zone.Flags.Count > 0) { for (int i = 0; i < zone.Flags.Count; i++) { if (!ZoneContains(zone.Flags[i], zone, "Flag")) { return(false); } if (i == zone.Flags.Count - 1) { line += Defines[zone.Flags[i]]; } else { line += Defines[zone.Flags[i]] + ","; } } } lines.Add(line); } file = File.CreateText(fileName); file.AutoFlush = false; file.NewLine = "\n"; foreach (String line in lines) { file.WriteLine(line); } file.Flush(); file.Close(); return(true); }
private void btnGenerate_Click(object sender, EventArgs e) { if (chkMaps.Checked) { List <String> MapDefines = new List <String>(); List <String> LocDefines = new List <String>(); List <Map> Maps = World.MapParser.GetMaps(); Maps = Maps.OrderBy(x => x.Pid).ToList <Map>(); List <Location> Locations = World.GetLocations(); Locations = Locations.OrderBy(x => x.Pid).ToList <Location>(); List <String> MapsLines = new List <string>(); MapsLines.Add("#ifndef __MAPS__"); MapsLines.Add("#define __MAPS__"); MapsLines.Add(""); MapsLines.Add(GetHeader()); MapsLines.Add(""); MapsLines.Add("//************************************************************************/"); MapsLines.Add("//* " + Locations.Count + " Locations */"); MapsLines.Add("//************************************************************************/"); foreach (Location Loc in Locations) { String LocName = ReplaceMapsDefinesCharacter(Loc.Name); bool UsePid = false; if (LocDefines.Contains(LocName)) { UsePid = true; } MapsLines.Add("#define LOCATION_" + Utils.GetSpacedLine(LocName + (UsePid ? Loc.Pid.ToString() : ""), "(" + Loc.Pid + ") // " + Loc.WorldMapDescription, 40)); LocDefines.Add(LocName); } MapsLines.Add(""); MapsLines.Add("//************************************************************************/"); MapsLines.Add("//* " + Maps.Count + " Maps */"); MapsLines.Add("//************************************************************************/"); MapsLines.Add(Utils.GetSpacedLine("", "// FileName, Script, Parent Location", 63)); foreach (Map Map in Maps) { bool UsePid = false; string MapName = ReplaceMapsDefinesCharacter(Map.Name); if (MapDefines.Contains(MapName)) { UsePid = true; } MapsLines.Add("#define MAP_" + Utils.GetSpacedLine(MapName + (UsePid ? Map.Pid.ToString() : ""), "(" + Map.Pid + ") // " + GetMapComment(Map), 45)); MapDefines.Add(MapName); } MapsLines.Add(""); if (chkEnum.Checked) { int enumCurrent = 0; int lastValue = -1; List <string> LocationEnums = new List <string>(); MapsLines.Add("shared enum LOCATIONS"); MapsLines.Add("{"); foreach (Location loc in Locations) { enumCurrent++; string name = ReplaceMapsDefinesCharacter(loc.Name); bool usePid = LocationEnums.Contains(name); MapsLines.Add("\tLOCATION__" + name + (usePid ? loc.Pid.ToString() : "") + (loc.Pid == lastValue + 1 ? "" : " = " + loc.Pid) + (enumCurrent != Locations.Count ? "," : "")); lastValue = loc.Pid; LocationEnums.Add(name); } MapsLines.Add("};"); MapsLines.Add(""); List <String> MapEnums = new List <String>(); MapsLines.Add("shared enum MAPS"); MapsLines.Add("{"); enumCurrent = 0; lastValue = -1; foreach (Map Map in Maps) { enumCurrent++; string name = ReplaceMapsDefinesCharacter(Map.Name); bool usePid = MapEnums.Contains(name); MapsLines.Add("\tMAP__" + name + (usePid ? Map.Pid.ToString() : "") + (Map.Pid == lastValue + 1 ? "" : " = " + Map.Pid) + (enumCurrent != Maps.Count ? "," : "")); lastValue = Map.Pid; MapEnums.Add(name); } MapsLines.Add("};"); MapsLines.Add(""); } MapsLines.Add("#endif // __MAPS__"); File.WriteAllLines(Config.PathScriptsDir + "_maps.fos", MapsLines.ToArray()); Message.Show("Defines generated and saved to _maps.fos", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (chkDialogs.Checked) { List <String> DlgDefines = new List <string>(); DlgDefines.Add("#ifndef __DIALOGS__"); DlgDefines.Add("#define __DIALOGS__"); DlgDefines.Add(""); DlgDefines.Add(GetHeader()); DlgDefines.Add("// Generated " + World.DialogListParser.GetDialogs(true).Count + " dialog defines (only enabled ones)."); DlgDefines.Add("#define DIALOG_" + Utils.GetSpacedLine("default", "(1)", 35)); List <ListDialog> dialogs = World.DialogListParser.GetDialogs(true); int dialogsCount = dialogs.Count; foreach (ListDialog Dlg in dialogs) { string name = ReplaceMapsDefinesCharacter(Dlg.Name); DlgDefines.Add("#define DIALOG_" + Utils.GetSpacedLine(name, "(" + Dlg.Id + ")", 35)); } DlgDefines.Add(""); if (chkEnum.Checked) { DlgDefines.Add("shared enum DIALOGS"); DlgDefines.Add("{"); int enumCurrent = 0; int lastValue = -1; foreach (ListDialog Dlg in dialogs) { enumCurrent++; string name = ReplaceMapsDefinesCharacter(Dlg.Name); DlgDefines.Add("\tDIALOG__" + name + (Dlg.Id == lastValue + 1 ? "" : " = " + Dlg.Id) + (enumCurrent != dialogsCount ? "," : "")); lastValue = Dlg.Id; } DlgDefines.Add("};"); DlgDefines.Add(""); } DlgDefines.Add("#endif // __DIALOGS__"); File.WriteAllLines(Config.PathScriptsDir + "_dialogs.fos", DlgDefines.ToArray()); Message.Show("Defines generated and saved to _dialogs.fos", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (chkNpcPids.Checked) { List <String> NpcsAdded = new List <string>(); List <String> NpcPidDefines = new List <string>(); NpcPidDefines.Add("#ifndef __NPC_PIDS__"); NpcPidDefines.Add("#define __NPC_PIDS__"); NpcPidDefines.Add(""); NpcPidDefines.Add(GetHeader()); NpcPidDefines.Add("// Generated " + ProtoEditor.ProtoManager.Protos.Count + " defines."); List <ProtoEditor.ProtoCritter> Crits = ProtoEditor.ProtoManager.Protos.Values.OrderBy(x => x.Id).ToList <ProtoEditor.ProtoCritter>(); foreach (ProtoEditor.ProtoCritter Crit in Crits) { string NpcName = ReplaceMapsDefinesCharacter(Crit.Name); if (String.IsNullOrEmpty(NpcName)) { NpcName = "Unknown"; } if (NpcsAdded.Contains(NpcName)) { int i = 1; do { } while (NpcsAdded.Contains(NpcName + ++i)); NpcName = NpcName + i; } NpcPidDefines.Add("#define NPC_PID_" + Utils.GetSpacedLine(NpcName, "(" + Crit.Id + ") // " + Crit.Desc, 45)); NpcsAdded.Add(NpcName); } NpcPidDefines.Add(""); if (chkEnum.Checked) { List <string> NpcEnums = new List <string>(); int npcCount = Crits.Count; int enumCurrent = 0; int lastValue = -1; NpcPidDefines.Add("shared enum NPC_PIDS"); NpcPidDefines.Add("{"); foreach (ProtoEditor.ProtoCritter Crit in Crits) { enumCurrent++; string name = ReplaceMapsDefinesCharacter(Crit.Name); if (string.IsNullOrEmpty(name)) { name = "Unknown"; } if (NpcEnums.Contains(name)) { int i = 1; do { }while(NpcEnums.Contains(name + ++i)); name = name + i; } NpcPidDefines.Add("\tNPC_PID__" + name + (Crit.Id == lastValue + 1 ? "" : " = " + Crit.Id) + (enumCurrent != npcCount ? "," : "")); NpcEnums.Add(name); lastValue = Crit.Id; } NpcPidDefines.Add("};"); NpcPidDefines.Add(""); } NpcPidDefines.Add("#endif __NPC_PIDS__"); File.WriteAllLines(Config.PathScriptsDir + "_npc_pids.fos", NpcPidDefines.ToArray()); Message.Show("Defines generated and saved to _npc_pids.fos", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static DialogResult Show(string text, MessageBoxButtons buttons, MessageBoxIcon icon) { return(Message.Show(text, buttons, icon, false)); }