Beispiel #1
0
        public void btnCompileCampaign_Click(Object sender, EventArgs e)
        {
            clsResult ReturnResult = new clsResult("Compile campaign");
            int A = 0;

            SaveToMap();

            A = ValidateMap_WaterTris();
            if ( A > 0 )
            {
                ReturnResult.WarningAdd(A + " water tiles have an incorrect triangle direction. There might be in-game graphical glitches on those tiles.");
            }

            ReturnResult.Add(ValidateMap());
            ReturnResult.Add(ValidateMap_UnitPositions());

            string MapName = "";
            int TypeNum = 0;

            MapName = txtName.Text;
            if ( MapName.Length < 1 )
            {
                ReturnResult.ProblemAdd("Enter a name for the campaign files.");
            }
            TypeNum = cboCampType.SelectedIndex;
            if ( TypeNum < 0 | TypeNum > 2 )
            {
                ReturnResult.ProblemAdd("Select a campaign type.");
            }
            if ( ReturnResult.HasProblems )
            {
                App.ShowWarnings(ReturnResult);
                return;
            }
            FolderBrowserDialog CompileCampDialog = new FolderBrowserDialog();
            if ( CompileCampDialog.ShowDialog(this) != DialogResult.OK )
            {
                return;
            }
            clsMap.sWrite_WZ_Args WriteWZArgs = new clsMap.sWrite_WZ_Args();
            WriteWZArgs.MapName = MapName;
            WriteWZArgs.Path = CompileCampDialog.SelectedPath;
            WriteWZArgs.Overwrite = false;
            SetScrollLimits(WriteWZArgs.ScrollMin, WriteWZArgs.ScrollMax);
            WriteWZArgs.Campaign = new clsMap.sWrite_WZ_Args.clsCampaign();
            WriteWZArgs.Campaign.GAMType = (uint)TypeNum;
            WriteWZArgs.CompileType = clsMap.sWrite_WZ_Args.enumCompileType.Campaign;
            ReturnResult.Add(Map.Write_WZ(WriteWZArgs));
            App.ShowWarnings(ReturnResult);
            if ( !ReturnResult.HasWarnings )
            {
                Close();
            }
        }
Beispiel #2
0
        public void btnCompile_Click(Object sender, EventArgs e)
        {
            clsResult ReturnResult = new clsResult("Compile multiplayer");
            int A = 0;

            SaveToMap();

            string MapName = "";
            string License = cboLicense.Text;
            int PlayerCount = 0;
            if ( !IOUtil.InvariantParse(txtMultiPlayers.Text, ref PlayerCount) )
            {
                PlayerCount = 0;
            }
            bool IsXPlayerFormat = cbxLevFormat.Checked;
            if ( PlayerCount < 2 | PlayerCount > 10 )
            {
                ReturnResult.ProblemAdd("The number of players must be from 2 to " + Convert.ToString(Constants.PlayerCountMax));
            }
            if ( !IsXPlayerFormat )
            {
                if ( PlayerCount != 2 & PlayerCount != 4 & PlayerCount != 8 )
                {
                    ReturnResult.ProblemAdd("You must enable support for this number of players.");
                }
            }

            A = ValidateMap_WaterTris();
            if ( A > 0 )
            {
                ReturnResult.WarningAdd(A + " water tiles have an incorrect triangle direction. There might be in-game graphical glitches on those tiles.");
            }

            ReturnResult.Add(ValidateMap());
            ReturnResult.Add(ValidateMap_UnitPositions());
            ReturnResult.Add(ValidateMap_Multiplayer(PlayerCount, IsXPlayerFormat));

            MapName = txtName.Text;
            char CurrentChar = (char)0;
            for ( A = 0; A <= MapName.Length - 1; A++ )
            {
                CurrentChar = MapName[A];
                if (
                    !((CurrentChar >= 'a' && CurrentChar <= 'z') || (CurrentChar >= 'A' && CurrentChar <= 'Z') ||
                      (A >= 1 && ((CurrentChar >= '0' && CurrentChar <= '9') || CurrentChar == '-' || CurrentChar == '_'))) )
                {
                    break;
                }
            }
            if ( A < MapName.Length )
            {
                ReturnResult.ProblemAdd("The map\'s name must contain only letters, numbers, underscores and hyphens, and must begin with a letter.");
            }
            if ( MapName.Length < 1 | MapName.Length > 16 )
            {
                ReturnResult.ProblemAdd("Map name must be from 1 to 16 characters.");
            }
            if ( string.IsNullOrEmpty(License) )
            {
                ReturnResult.ProblemAdd("Enter a valid license.");
            }
            if ( ReturnResult.HasProblems )
            {
                App.ShowWarnings(ReturnResult);
                return;
            }
            SaveFileDialog CompileMultiDialog = new SaveFileDialog();
            if ( Map.PathInfo != null )
            {
                CompileMultiDialog.InitialDirectory = Map.PathInfo.Path;
            }
            CompileMultiDialog.FileName = PlayerCount + "c-" + MapName;
            CompileMultiDialog.Filter = "WZ Files (*.wz)|*.wz";
            if ( CompileMultiDialog.ShowDialog(this) != DialogResult.OK )
            {
                return;
            }
            clsMap.sWrite_WZ_Args WriteWZArgs = new clsMap.sWrite_WZ_Args();
            WriteWZArgs.MapName = MapName;
            WriteWZArgs.Path = CompileMultiDialog.FileName;
            WriteWZArgs.Overwrite = true;
            SetScrollLimits(WriteWZArgs.ScrollMin, WriteWZArgs.ScrollMax);
            WriteWZArgs.Multiplayer = new clsMap.sWrite_WZ_Args.clsMultiplayer();
            WriteWZArgs.Multiplayer.AuthorName = txtAuthor.Text;
            WriteWZArgs.Multiplayer.PlayerCount = PlayerCount;
            WriteWZArgs.Multiplayer.IsBetaPlayerFormat = IsXPlayerFormat;
            WriteWZArgs.Multiplayer.License = License;
            WriteWZArgs.CompileType = clsMap.sWrite_WZ_Args.enumCompileType.Multiplayer;
            ReturnResult.Add(Map.Write_WZ(WriteWZArgs));
            App.ShowWarnings(ReturnResult);
            if ( !ReturnResult.HasWarnings )
            {
                Close();
            }
        }