Ejemplo n.º 1
0
        public void btnCompileCampaign_Click(Object sender, EventArgs e)
        {
            var ReturnResult = new Result("Compile campaign", false);

            logger.Info("Compile campaign");
            var 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());

            var MapName = "";
            var 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;
            }
            var CompileCampDialog = new FolderBrowserDialog();

            if (CompileCampDialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }
            SetScrollLimits(ref Map.InterfaceOptions.ScrollMin, ref Map.InterfaceOptions.ScrollMax);
            Map.InterfaceOptions.CompileName      = MapName;
            Map.InterfaceOptions.CompileType      = CompileType.Campaign;
            Map.InterfaceOptions.CampaignGameType = TypeNum;

            var wzFormat = new WzSaver(Map);

            ReturnResult.Add(wzFormat.Save(CompileCampDialog.SelectedPath, false, true));
            App.ShowWarnings(ReturnResult);
            if (!ReturnResult.HasWarnings)
            {
                Close();
            }
        }
Ejemplo n.º 2
0
        public void btnCompile_Click(Object sender, EventArgs e)
        {
            var ReturnResult = new Result("Compile multiplayer", false);

            logger.Info("Compile multiplayer");
            var A = 0;

            SaveToMap();

            var MapName     = "";
            var License     = cboLicense.Text;
            var PlayerCount = 0;

            if (!IOUtil.InvariantParse(txtMultiPlayers.Text, ref PlayerCount))
            {
                PlayerCount = 0;
            }
            if (PlayerCount <2 | PlayerCount> Constants.PlayerCountMax)
            {
                ReturnResult.ProblemAdd(string.Format("The number of players must be from 2 to {0}", Constants.PlayerCountMax));
            }

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

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

            MapName = txtName.Text;
            var 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;
            }
            var 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;
            }

            SetScrollLimits(ref Map.InterfaceOptions.ScrollMin, ref Map.InterfaceOptions.ScrollMax);
            Map.InterfaceOptions.CompileName         = MapName;
            Map.InterfaceOptions.CompileMultiAuthor  = txtAuthor.Text;
            Map.InterfaceOptions.CompileMultiPlayers = PlayerCount.ToString();
            Map.InterfaceOptions.CompileMultiLicense = License;
            Map.InterfaceOptions.CompileType         = CompileType.Multiplayer;
            var wzFormat = new WzSaver(Map);

            ReturnResult.Add(wzFormat.Save(CompileMultiDialog.FileName, true, true));
            App.ShowWarnings(ReturnResult);
            if (!ReturnResult.HasWarnings)
            {
                Close();
            }
        }