MultiplayerSettings.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: MultiplayerSettings.h /////////////////////////////////////////////////////////////////////////////
  24. // Settings common to multiplayer games
  25. // Author: Matthew D. Campbell, January 2002
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef _MULTIPLAYERSETTINGS_H_
  29. #define _MULTIPLAYERSETTINGS_H_
  30. #include "GameClient/Color.h"
  31. #include "Common/Money.h"
  32. // FORWARD DECLARATIONS ///////////////////////////////////////////////////////////////////////////
  33. struct FieldParse;
  34. class MultiplayerSettings;
  35. // PUBLIC /////////////////////////////////////////////////////////////////////////////////////////
  36. class MultiplayerColorDefinition
  37. {
  38. public:
  39. MultiplayerColorDefinition();
  40. //-----------------------------------------------------------------------------------------------
  41. static const FieldParse m_colorFieldParseTable[]; ///< the parse table for INI definition
  42. const FieldParse *getFieldParse( void ) const { return m_colorFieldParseTable; }
  43. inline AsciiString getTooltipName(void) const { return m_tooltipName; };
  44. inline RGBColor getRGBValue(void) const { return m_rgbValue; };
  45. inline RGBColor getRGBNightValue(void) const { return m_rgbValueNight; };
  46. inline Color getColor(void) const { return m_color; }
  47. inline Color getNightColor(void) const { return m_colorNight; }
  48. void setColor( RGBColor rgb );
  49. void setNightColor( RGBColor rgb );
  50. MultiplayerColorDefinition * operator =(const MultiplayerColorDefinition& other);
  51. private:
  52. AsciiString m_tooltipName; ///< tooltip name for color combo box (AsciiString to pass to TheGameText->fetch())
  53. RGBColor m_rgbValue; ///< RGB color value
  54. Color m_color;
  55. RGBColor m_rgbValueNight; ///< RGB color value
  56. Color m_colorNight;
  57. };
  58. typedef std::map<Int, MultiplayerColorDefinition> MultiplayerColorList;
  59. typedef std::map<Int, MultiplayerColorDefinition>::iterator MultiplayerColorIter;
  60. // A list of values to display in the starting money dropdown
  61. typedef std::vector< Money > MultiplayerStartingMoneyList;
  62. //-------------------------------------------------------------------------------------------------
  63. /** Multiplayer Settings container class
  64. * Defines multiplayer settings */
  65. //-------------------------------------------------------------------------------------------------
  66. class MultiplayerSettings : public SubsystemInterface
  67. {
  68. public:
  69. MultiplayerSettings( void );
  70. virtual void init() { }
  71. virtual void update() { }
  72. virtual void reset() { }
  73. //-----------------------------------------------------------------------------------------------
  74. static const FieldParse m_multiplayerSettingsFieldParseTable[]; ///< the parse table for INI definition
  75. const FieldParse *getFieldParse( void ) const { return m_multiplayerSettingsFieldParseTable; }
  76. // Color management --------------------
  77. MultiplayerColorDefinition * findMultiplayerColorDefinitionByName(AsciiString name);
  78. MultiplayerColorDefinition * newMultiplayerColorDefinition(AsciiString name);
  79. inline Int getStartCountdownTimerSeconds( void ) { return m_startCountdownTimerSeconds; }
  80. inline Int getMaxBeaconsPerPlayer( void ) { return m_maxBeaconsPerPlayer; }
  81. inline Bool isShroudInMultiplayer( void ) { return m_isShroudInMultiplayer; }
  82. inline Bool showRandomPlayerTemplate( void ) { return m_showRandomPlayerTemplate; }
  83. inline Bool showRandomStartPos( void ) { return m_showRandomStartPos; }
  84. inline Bool showRandomColor( void ) { return m_showRandomColor; }
  85. inline Int getNumColors( void )
  86. {
  87. if (m_numColors == 0) {
  88. m_numColors = m_colorList.size();
  89. }
  90. return m_numColors;
  91. }
  92. MultiplayerColorDefinition * getColor(Int which);
  93. const Money & getDefaultStartingMoney() const
  94. {
  95. DEBUG_ASSERTCRASH( m_gotDefaultStartingMoney, ("You must specify a default starting money amount in multiplayer.ini") );
  96. return m_defaultStartingMoney;
  97. }
  98. const MultiplayerStartingMoneyList & getStartingMoneyList() const { return m_startingMoneyList; }
  99. void addStartingMoneyChoice( const Money & money, Bool isDefault );
  100. private:
  101. Int m_initialCreditsMin;
  102. Int m_initialCreditsMax;
  103. Int m_startCountdownTimerSeconds;
  104. Int m_maxBeaconsPerPlayer;
  105. Bool m_isShroudInMultiplayer;
  106. Bool m_showRandomPlayerTemplate;
  107. Bool m_showRandomStartPos;
  108. Bool m_showRandomColor;
  109. MultiplayerColorList m_colorList;
  110. Int m_numColors;
  111. MultiplayerColorDefinition m_observerColor;
  112. MultiplayerColorDefinition m_randomColor;
  113. MultiplayerStartingMoneyList m_startingMoneyList;
  114. Money m_defaultStartingMoney;
  115. Bool m_gotDefaultStartingMoney;
  116. };
  117. // singleton
  118. extern MultiplayerSettings *TheMultiplayerSettings;
  119. #endif