Beispiel #1
0
 private void btnCompile_Click(object sender, EventArgs e)
 {
     int num2;
     clsResult result = new clsResult("Compile multiplayer");
     this.SaveToMap();
     string text = this.cboLicense.Text;
     if (!modIO.InvariantParse_int(this.txtMultiPlayers.Text, ref num2))
     {
         num2 = 0;
     }
     bool isXPlayerFormat = this.cbxLevFormat.Checked;
     if ((num2 < 2) | (num2 > 10))
     {
         result.ProblemAdd("The number of players must be from 2 to " + Conversions.ToString(10));
     }
     if (!isXPlayerFormat && (((num2 != 2) & (num2 != 4)) & (num2 != 8)))
     {
         result.ProblemAdd("You must enable support for this number of players.");
     }
     int num = this.ValidateMap_WaterTris();
     if (num > 0)
     {
         result.WarningAdd(Conversions.ToString(num) + " water tiles have an incorrect triangle direction. There might be in-game graphical glitches on those tiles.");
     }
     result.Add(this.ValidateMap());
     result.Add(this.ValidateMap_UnitPositions());
     result.Add(this.ValidateMap_Multiplayer(num2, isXPlayerFormat));
     string str2 = this.txtName.Text;
     int num3 = str2.Length - 1;
     num = 0;
     while (num <= num3)
     {
         char ch = str2[num];
         if (!((((ch >= 'a') & (ch <= 'z')) | ((ch >= 'A') & (ch <= 'Z'))) | ((num >= 1) & ((((ch >= '0') & (ch <= '9')) | (ch == '-')) | (ch == '_')))))
         {
             break;
         }
         num++;
     }
     if (num < str2.Length)
     {
         result.ProblemAdd("The map's name must contain only letters, numbers, underscores and hyphens, and must begin with a letter.");
     }
     if ((str2.Length < 1) | (str2.Length > 0x10))
     {
         result.ProblemAdd("Map name must be from 1 to 16 characters.");
     }
     if (text == "")
     {
         result.ProblemAdd("Enter a valid license.");
     }
     if (result.HasProblems)
     {
         modProgram.ShowWarnings(result);
     }
     else
     {
         SaveFileDialog dialog = new SaveFileDialog();
         if (this.Map.PathInfo != null)
         {
             dialog.InitialDirectory = this.Map.PathInfo.Path;
         }
         dialog.FileName = Conversions.ToString(num2) + "c-" + str2;
         dialog.Filter = "WZ Files (*.wz)|*.wz";
         if (dialog.ShowDialog(this) == DialogResult.OK)
         {
             clsMap.sWrite_WZ_Args args = new clsMap.sWrite_WZ_Args {
                 MapName = str2,
                 Path = dialog.FileName,
                 Overwrite = true
             };
             this.SetScrollLimits(ref args.ScrollMin, ref args.ScrollMax);
             args.Multiplayer = new clsMap.sWrite_WZ_Args.clsMultiplayer();
             args.Multiplayer.AuthorName = this.txtAuthor.Text;
             args.Multiplayer.PlayerCount = num2;
             args.Multiplayer.IsBetaPlayerFormat = isXPlayerFormat;
             args.Multiplayer.License = text;
             args.CompileType = clsMap.sWrite_WZ_Args.enumCompileType.Multiplayer;
             result.Add(this.Map.Write_WZ(args));
             modProgram.ShowWarnings(result);
             if (!result.HasWarnings)
             {
                 this.Close();
             }
         }
     }
 }
Beispiel #2
0
 private void btnCompileCampaign_Click(object sender, EventArgs e)
 {
     clsResult result = new clsResult("Compile campaign");
     this.SaveToMap();
     int num = this.ValidateMap_WaterTris();
     if (num > 0)
     {
         result.WarningAdd(Conversions.ToString(num) + " water tiles have an incorrect triangle direction. There might be in-game graphical glitches on those tiles.");
     }
     result.Add(this.ValidateMap());
     result.Add(this.ValidateMap_UnitPositions());
     string text = this.txtName.Text;
     if (text.Length < 1)
     {
         result.ProblemAdd("Enter a name for the campaign files.");
     }
     int selectedIndex = this.cboCampType.SelectedIndex;
     if ((selectedIndex < 0) | (selectedIndex > 2))
     {
         result.ProblemAdd("Select a campaign type.");
     }
     if (result.HasProblems)
     {
         modProgram.ShowWarnings(result);
     }
     else
     {
         FolderBrowserDialog dialog = new FolderBrowserDialog();
         if (dialog.ShowDialog(this) == DialogResult.OK)
         {
             clsMap.sWrite_WZ_Args args = new clsMap.sWrite_WZ_Args {
                 MapName = text,
                 Path = dialog.SelectedPath,
                 Overwrite = false
             };
             this.SetScrollLimits(ref args.ScrollMin, ref args.ScrollMax);
             args.Campaign = new clsMap.sWrite_WZ_Args.clsCampaign();
             args.Campaign.GAMType = (uint) selectedIndex;
             args.CompileType = clsMap.sWrite_WZ_Args.enumCompileType.Campaign;
             result.Add(this.Map.Write_WZ(args));
             modProgram.ShowWarnings(result);
             if (!result.HasWarnings)
             {
                 this.Close();
             }
         }
     }
 }