INIDrawGroupInfo.cpp 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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: INIDrawGroupInfo.cpp /////////////////////////////////////////////////////////////////////
  24. // Author: John McDonald, October 2002
  25. // Desc: Parsing DrawGroupInfo INI entries
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  28. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  29. #include "Common/INI.h"
  30. #include "GameClient/DrawGroupInfo.h"
  31. void parseInt( INI* ini, void * /*instance*/, void *store, const void* userData )
  32. {
  33. DrawGroupInfo *dgi = (DrawGroupInfo*) store;
  34. if (userData == 0) {
  35. store = &dgi->m_pixelOffsetX;
  36. dgi->m_usingPixelOffsetX = TRUE;
  37. } else {
  38. store = &dgi->m_pixelOffsetY;
  39. dgi->m_usingPixelOffsetY = TRUE;
  40. }
  41. INI::parseInt(ini, NULL, store, NULL);
  42. }
  43. void parsePercentToReal( INI* ini, void * /*instance*/, void *store, const void* userData )
  44. {
  45. DrawGroupInfo *dgi = (DrawGroupInfo*) store;
  46. if (userData == 0) {
  47. store = &dgi->m_pixelOffsetX;
  48. dgi->m_usingPixelOffsetX = FALSE;
  49. } else {
  50. store = &dgi->m_pixelOffsetY;
  51. dgi->m_usingPixelOffsetY = FALSE;
  52. }
  53. INI::parsePercentToReal(ini, NULL, store, NULL);
  54. }
  55. const FieldParse DrawGroupInfo::s_fieldParseTable[] =
  56. {
  57. { "UsePlayerColor", INI::parseBool, NULL, offsetof( DrawGroupInfo, m_usePlayerColor) },
  58. { "ColorForText", INI::parseColorInt, NULL, offsetof( DrawGroupInfo, m_colorForText ) },
  59. { "ColorForTextDropShadow", INI::parseColorInt, NULL, offsetof( DrawGroupInfo, m_colorForTextDropShadow ) },
  60. { "FontName", INI::parseQuotedAsciiString, NULL, offsetof( DrawGroupInfo, m_fontName ) },
  61. { "FontSize", INI::parseInt, NULL, offsetof( DrawGroupInfo, m_fontSize ) },
  62. { "FontIsBold", INI::parseBool, NULL, offsetof( DrawGroupInfo, m_fontIsBold ) },
  63. { "DropShadowOffsetX", INI::parseInt, NULL, offsetof( DrawGroupInfo, m_dropShadowOffsetX) },
  64. { "DropShadowOffsetY", INI::parseInt, NULL, offsetof( DrawGroupInfo, m_dropShadowOffsetY) },
  65. { "DrawPositionXPixel", parseInt, (void*)0, 0 },
  66. { "DrawPositionXPercent", parsePercentToReal, (void*)0, 0 },
  67. { "DrawPositionYPixel", parseInt, (void*)1, 0 },
  68. { "DrawPositionYPercent", parsePercentToReal, (void*)1, 0 },
  69. { 0, 0, 0, 0 }
  70. };
  71. /*static */ void INI::parseDrawGroupNumberDefinition(INI* ini)
  72. {
  73. if (!TheDrawGroupInfo) {
  74. throw INI_UNKNOWN_ERROR;
  75. }
  76. ini->initFromINI(TheDrawGroupInfo, TheDrawGroupInfo->getFieldParse());
  77. }