INICommandButton.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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: INICommandButton.cpp /////////////////////////////////////////////////////////////////////
  24. // Author: Colin Day, March 2002
  25. // Desc: Command buttons are the atomic units we can configure into command sets to then
  26. // display in the context sensitive user interface
  27. ///////////////////////////////////////////////////////////////////////////////////////////////////
  28. // USER INCLUDES //////////////////////////////////////////////////////////////////////////////////
  29. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  30. #include "Common/INI.h"
  31. #include "GameClient/ControlBar.h"
  32. //-------------------------------------------------------------------------------------------------
  33. /** Parse a command button */
  34. //-------------------------------------------------------------------------------------------------
  35. void INI::parseCommandButtonDefinition( INI *ini )
  36. {
  37. ControlBar::parseCommandButtonDefinition(ini);
  38. }
  39. //-------------------------------------------------------------------------------------------------
  40. /** Parse a command button */
  41. //-------------------------------------------------------------------------------------------------
  42. void ControlBar::parseCommandButtonDefinition( INI *ini )
  43. {
  44. // read the name
  45. AsciiString name = ini->getNextToken();
  46. // find existing item if present
  47. CommandButton *button = TheControlBar->findNonConstCommandButton( name );
  48. if( button == NULL )
  49. {
  50. // allocate a new item
  51. button = TheControlBar->newCommandButton( name );
  52. if (ini->getLoadType() == INI_LOAD_CREATE_OVERRIDES)
  53. {
  54. button->markAsOverride();
  55. }
  56. } // end if
  57. else if( ini->getLoadType() != INI_LOAD_CREATE_OVERRIDES )
  58. {
  59. DEBUG_CRASH(( "[LINE: %d in '%s'] Duplicate commandbutton %s found!", ini->getLineNum(), ini->getFilename().str(), name.str() ));
  60. }
  61. else
  62. {
  63. button = TheControlBar->newCommandButtonOverride( button );
  64. }
  65. // parse the ini definition
  66. ini->initFromINI( button, button->getFieldParse() );
  67. } // end parseCommandButtonDefinition