MultiplayerSettings.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. ** Command & Conquer Generals(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. // FORWARD DECLARATIONS ///////////////////////////////////////////////////////////////////////////
  32. struct FieldParse;
  33. class MultiplayerSettings;
  34. // PUBLIC /////////////////////////////////////////////////////////////////////////////////////////
  35. class MultiplayerColorDefinition
  36. {
  37. public:
  38. MultiplayerColorDefinition();
  39. //-----------------------------------------------------------------------------------------------
  40. static const FieldParse m_colorFieldParseTable[]; ///< the parse table for INI definition
  41. const FieldParse *getFieldParse( void ) const { return m_colorFieldParseTable; }
  42. inline AsciiString getTooltipName(void) const { return m_tooltipName; };
  43. inline RGBColor getRGBValue(void) const { return m_rgbValue; };
  44. inline RGBColor getRGBNightValue(void) const { return m_rgbValueNight; };
  45. inline Color getColor(void) const { return m_color; }
  46. inline Color getNightColor(void) const { return m_colorNight; }
  47. void setColor( RGBColor rgb );
  48. void setNightColor( RGBColor rgb );
  49. MultiplayerColorDefinition * operator =(const MultiplayerColorDefinition& other);
  50. private:
  51. AsciiString m_tooltipName; ///< tooltip name for color combo box (AsciiString to pass to TheGameText->fetch())
  52. RGBColor m_rgbValue; ///< RGB color value
  53. Color m_color;
  54. RGBColor m_rgbValueNight; ///< RGB color value
  55. Color m_colorNight;
  56. };
  57. typedef std::map<Int, MultiplayerColorDefinition> MultiplayerColorList;
  58. typedef std::map<Int, MultiplayerColorDefinition>::iterator MultiplayerColorIter;
  59. //-------------------------------------------------------------------------------------------------
  60. /** Multiplayer Settings container class
  61. * Defines multiplayer settings */
  62. //-------------------------------------------------------------------------------------------------
  63. class MultiplayerSettings : public SubsystemInterface
  64. {
  65. public:
  66. MultiplayerSettings( void );
  67. void init() { }
  68. void update() { }
  69. void reset() { }
  70. //-----------------------------------------------------------------------------------------------
  71. static const FieldParse m_multiplayerSettingsFieldParseTable[]; ///< the parse table for INI definition
  72. const FieldParse *getFieldParse( void ) const { return m_multiplayerSettingsFieldParseTable; }
  73. // Color management --------------------
  74. MultiplayerColorDefinition * findMultiplayerColorDefinitionByName(AsciiString name);
  75. MultiplayerColorDefinition * newMultiplayerColorDefinition(AsciiString name);
  76. inline Int getInitialCreditsMin( void ) { return m_initialCreditsMin; }
  77. inline Int getInitialCreditsMax( void ) { return m_initialCreditsMax; }
  78. inline Int getStartCountdownTimerSeconds( void ) { return m_startCountdownTimerSeconds; }
  79. inline Int getMaxBeaconsPerPlayer( void ) { return m_maxBeaconsPerPlayer; }
  80. inline Bool isShroudInMultiplayer( void ) { return m_isShroudInMultiplayer; }
  81. inline Bool showRandomPlayerTemplate( void ) { return m_showRandomPlayerTemplate; }
  82. inline Bool showRandomStartPos( void ) { return m_showRandomStartPos; }
  83. inline Bool showRandomColor( void ) { return m_showRandomColor; }
  84. inline Int getNumColors( void )
  85. {
  86. if (m_numColors == 0) {
  87. m_numColors = m_colorList.size();
  88. }
  89. return m_numColors;
  90. }
  91. MultiplayerColorDefinition * getColor(Int which);
  92. private:
  93. Int m_initialCreditsMin;
  94. Int m_initialCreditsMax;
  95. Int m_startCountdownTimerSeconds;
  96. Int m_maxBeaconsPerPlayer;
  97. Bool m_isShroudInMultiplayer;
  98. Bool m_showRandomPlayerTemplate;
  99. Bool m_showRandomStartPos;
  100. Bool m_showRandomColor;
  101. MultiplayerColorList m_colorList;
  102. Int m_numColors;
  103. MultiplayerColorDefinition m_observerColor;
  104. MultiplayerColorDefinition m_randomColor;
  105. };
  106. // singleton
  107. extern MultiplayerSettings *TheMultiplayerSettings;
  108. #endif