CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

BasicSettings.cs (4504B)


      1 //
      2 // Copyright 2020 Electronic Arts Inc.
      3 //
      4 // The Command & Conquer Map Editor and corresponding source code is free 
      5 // software: you can redistribute it and/or modify it under the terms of 
      6 // the GNU General Public License as published by the Free Software Foundation, 
      7 // either version 3 of the License, or (at your option) any later version.
      8 
      9 // The Command & Conquer Map Editor and corresponding source code is distributed 
     10 // in the hope that it will be useful, but with permitted additional restrictions 
     11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 
     12 // distributed with this program. You should have received a copy of the 
     13 // GNU General Public License along with permitted additional restrictions 
     14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
     15 using MobiusEditor.Interface;
     16 using System;
     17 using System.Data;
     18 using System.Linq;
     19 using System.Windows.Forms;
     20 
     21 namespace MobiusEditor.Controls
     22 {
     23     public partial class BasicSettings : UserControl
     24     {
     25         public BasicSettings(IGamePlugin plugin, dynamic basicSection)
     26         {
     27             InitializeComponent();
     28 
     29             playerComboBox.DataSource = plugin.Map.Houses.Select(h => h.Type.Name).ToArray();
     30             baseComboBox.DataSource = plugin.Map.Houses.Select(h => h.Type.Name).ToArray();
     31             introComboBox.DataSource = plugin.Map.MovieTypes.ToArray();
     32             briefComboBox.DataSource = plugin.Map.MovieTypes.ToArray();
     33             actionComboBox.DataSource = plugin.Map.MovieTypes.ToArray();
     34             winComboBox.DataSource = plugin.Map.MovieTypes.ToArray();
     35             win2ComboBox.DataSource = plugin.Map.MovieTypes.ToArray();
     36             win3ComboBox.DataSource = plugin.Map.MovieTypes.ToArray();
     37             win4ComboBox.DataSource = plugin.Map.MovieTypes.ToArray();
     38             loseComboBox.DataSource = plugin.Map.MovieTypes.ToArray();
     39 
     40             carryOverMoneyNud.DataBindings.Add("Value", basicSection, "CarryOverMoney");
     41             nameTxt.DataBindings.Add("Text", basicSection, "Name");
     42             percentNud.DataBindings.Add("Value", basicSection, "Percent");
     43             playerComboBox.DataBindings.Add("SelectedItem", basicSection, "Player");
     44             authorTxt.DataBindings.Add("Text", basicSection, "Author");
     45             isSinglePlayerCheckBox.DataBindings.Add("Checked", basicSection, "SoloMission");
     46             introComboBox.DataBindings.Add("SelectedItem", basicSection, "Intro");
     47             briefComboBox.DataBindings.Add("SelectedItem", basicSection, "Brief");
     48             actionComboBox.DataBindings.Add("SelectedItem", basicSection, "Action");
     49             winComboBox.DataBindings.Add("SelectedItem", basicSection, "Win");
     50             loseComboBox.DataBindings.Add("SelectedItem", basicSection, "Lose");
     51 
     52             switch (plugin.GameType)
     53             {
     54                 case GameType.TiberianDawn:
     55                     buidLevelNud.DataBindings.Add("Value", basicSection, "BuildLevel");
     56                     baseLabel.Visible = baseComboBox.Visible = false;
     57                     win2Label.Visible = win2ComboBox.Visible = false;
     58                     win3Label.Visible = win3ComboBox.Visible = false;
     59                     win4Label.Visible = win4ComboBox.Visible = false;
     60                     break;
     61                 case GameType.RedAlert:
     62                     buidLevelNud.Visible = buildLevelLabel.Visible = false;
     63                     baseComboBox.DataBindings.Add("SelectedItem", basicSection, "BasePlayer");
     64                     win2ComboBox.DataBindings.Add("SelectedItem", basicSection, "Win2");
     65                     win3ComboBox.DataBindings.Add("SelectedItem", basicSection, "Win3");
     66                     win4ComboBox.DataBindings.Add("SelectedItem", basicSection, "Win4");
     67                     break;
     68             }
     69 
     70             introComboBox.Enabled = briefComboBox.Enabled = actionComboBox.Enabled = loseComboBox.Enabled = isSinglePlayerCheckBox.Checked;
     71             winComboBox.Enabled = win2ComboBox.Enabled = win3ComboBox.Enabled = win4ComboBox.Enabled = isSinglePlayerCheckBox.Checked;
     72         }
     73 
     74         private void isSinglePlayerCheckBox_CheckedChanged(object sender, EventArgs e)
     75         {
     76             introComboBox.Enabled = briefComboBox.Enabled = actionComboBox.Enabled = loseComboBox.Enabled = isSinglePlayerCheckBox.Checked;
     77             winComboBox.Enabled = win2ComboBox.Enabled = win3ComboBox.Enabled = win4ComboBox.Enabled = isSinglePlayerCheckBox.Checked;
     78         }
     79     }
     80 }