INIAnimation.cpp 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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: INIAnimation.cpp /////////////////////////////////////////////////////////////////////////
  24. // Author: Colin Day, July 2002
  25. // Desc: Parsing animation INI entries for 2D image animations
  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/Anim2D.h"
  31. //-------------------------------------------------------------------------------------------------
  32. /** Parse animation entry */
  33. //-------------------------------------------------------------------------------------------------
  34. void INI::parseAnim2DDefinition( INI* ini )
  35. {
  36. AsciiString name;
  37. Anim2DTemplate *animTemplate;
  38. // read the name
  39. const char* c = ini->getNextToken();
  40. name.set( c );
  41. //
  42. // find existing item if present, note that we do not support overrides
  43. // in the animations like we do in systems that are more "design" oriented, images
  44. // are assets as they are
  45. //
  46. if( !TheAnim2DCollection )
  47. {
  48. //We don't need it if we're in the builder... which doesn't have this.
  49. return;
  50. } // end if
  51. // find existing animation template if present
  52. animTemplate = TheAnim2DCollection->findTemplate( name );
  53. if( animTemplate == NULL )
  54. {
  55. // item not found, create a new one
  56. animTemplate = TheAnim2DCollection->newTemplate( name );
  57. DEBUG_ASSERTCRASH( animTemplate, ("INI""parseAnim2DDefinition - unable to allocate animation template for '%s'\n",
  58. name.str()) );
  59. } // end if
  60. else
  61. {
  62. // we're loading over an existing animation template ... something is probably wrong
  63. DEBUG_CRASH(( "INI::parseAnim2DDefinition - Animation template '%s' already exists\n",
  64. animTemplate->getName().str() ));
  65. return;
  66. } // end else
  67. // parse the ini definition
  68. ini->initFromINI( animTemplate, animTemplate->getFieldParse() );
  69. } // end parseAnim2DDefinition