private static string get_map_description(Homm5RMG.Properties.Settings settings, int[] SelectedFactions, int[][] ExcludedPlayersFactions) { StringBuilder desc = new StringBuilder(); String[] excludedrace = new string[4]; for (int pl = 0; pl < (Program.frmMainMenu.RadioButton3.Checked || Program.frmMainMenu.RadioButton4.Checked ? 4: Program.frmMainMenu.RadioButton2.Checked?3:2); pl++) { if (SelectedFactions[pl] == 1) { for (int fac = 0; fac < 8; fac++) { if (ExcludedPlayersFactions[pl][fac] == 1) { excludedrace[pl] = String.Concat(excludedrace[pl], excludedrace[pl] == null ? Enum.GetNames(typeof(eTownType))[fac + 2] : "," + Enum.GetNames(typeof(eTownType))[fac + 2]); } } if (excludedrace[pl] != null) { excludedrace[pl] = String.Concat("(Excluding:", excludedrace[pl], ")"); } } } try { System.IO.FileInfo f = new System.IO.FileInfo(settings.DefaultTemplateFile); desc.AppendFormat(Program.frmMainMenu.RadioButton3.Checked ? ("{0}{4} + {3}{7} vs {1}{5} + {2}{6} ") : ("{0}{4} vs {1}{5}" + ((Program.frmMainMenu.RadioButton2.Checked || Program.frmMainMenu.RadioButton4.Checked) ? " vs {2}{6}" : "") + (Program.frmMainMenu.RadioButton4.Checked ? " vs {3}{7}" : "")) + ", ", Enum.GetNames(typeof(eTownType))[SelectedFactions[0]], Enum.GetNames(typeof(eTownType))[SelectedFactions[1]], Enum.GetNames(typeof(eTownType))[SelectedFactions[2]], Enum.GetNames(typeof(eTownType))[SelectedFactions[3]], excludedrace[0], excludedrace[1], excludedrace[2], excludedrace[3]); desc.AppendFormat("template: {0}, ", settings.RandomTemplate ? "random(" + frmMain.templatelist + ")" : f.Name.Split('.')[0] + "(T:" + f.LastWriteTime + ",S:" + f.Length + ")"); string[] sizes = Enum.GetNames(typeof(MapSize)); desc.AppendFormat("size: {0}, ", sizes[settings.SelectedSizeIndex]); desc.AppendFormat("start zone dwellings: {0}, ", Enum.GetNames(typeof(eDwellingStatus))[settings.DwellingStatus]); desc.AppendFormat("random seed: {0}, ", settings.RandomSeed); desc.AppendFormat("IRMG : {0}, ", frmMain.STR_VERSION); desc.AppendFormat("date: {0}", DateTime.Now); } catch (Exception) { return(""); } return(desc.ToString()); }
public static void SetMapParameters(Homm5RMG.Properties.Settings settings, int [] SelectedFactions, int[][] ExcludedPlayersFactions) { System.IO.StreamWriter file = new StreamWriter(MAPS_INITIAL_DIR + "\\" + strMapName + "\\description.txt", true, Encoding.Unicode); file.Write(get_map_description(settings, SelectedFactions, ExcludedPlayersFactions)); file.Close(); }
public static void CreateTempMapFiles(MapSize SizeToCreate, string strNameOfMap, Homm5RMG.Properties.Settings settings, int [] SelectedFactions, int[][] ExcludedPlayersFactions) { DeleteTempMapFiles(); strMapName = strNameOfMap; string strTargetTemp = MAPS_INITIAL_DIR + strMapName; Directory.CreateDirectory(strTargetTemp); DirectoryInfo dirinfEmptyMapFiles = new DirectoryInfo(Assembly.GetExecutingAssembly().CodeBase.Substring(0, Assembly.GetExecutingAssembly().CodeBase.Length - 12).Substring(8) + "Data\\Basic Empty Map Files\\" + SizeToCreate.ToString()); CopyToTarget(dirinfEmptyMapFiles, "", strTargetTemp); SetMapName(); SetMapParameters(settings, SelectedFactions, ExcludedPlayersFactions); }