BasicSettings.cs 4.4 KB

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