widgets.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. ** Command & Conquer Renegade(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. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : WWPhys *
  23. * *
  24. * $Archive:: /Commando/Code/wwphys/widgets.cpp $*
  25. * *
  26. * Author:: Greg Hjelstrom *
  27. * *
  28. * $Modtime:: 7/29/99 11:25a $*
  29. * *
  30. * $Revision:: 3 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "widgets.h"
  36. #include "bin_aabox.h"
  37. #include "bin_axes.h"
  38. #include "bin_obbox.h"
  39. #include "bin_point.h"
  40. #include "bin_vector.h"
  41. #include "assetmgr.h"
  42. #include "rendobj.h"
  43. #include "ramfile.h"
  44. #ifdef WWDEBUG
  45. struct WidgetDefStruct
  46. {
  47. int Id;
  48. const unsigned char * Data;
  49. unsigned int Size;
  50. const char * Name;
  51. RenderObjClass * RObj;
  52. };
  53. static WidgetDefStruct _WidgetDefs[WidgetSystem::NUM_WIDGETS] =
  54. {
  55. { WidgetSystem::WIDGET_AABOX, _AABoxBinary, sizeof(_AABoxBinary), "AABox.Box",NULL },
  56. { WidgetSystem::WIDGET_OBBOX, _OBBoxBinary, sizeof(_OBBoxBinary), "OBBox.Box",NULL },
  57. { WidgetSystem::WIDGET_VECTOR,_VectorBinary, sizeof(_VectorBinary), "Vector", NULL },
  58. { WidgetSystem::WIDGET_AXES, _AxesBinary, sizeof(_AxesBinary), "Axes", NULL },
  59. { WidgetSystem::WIDGET_POINT, _PointBinary, sizeof(_PointBinary), "Point", NULL }
  60. };
  61. #endif
  62. void WidgetSystem::Init_Debug_Widgets(void)
  63. {
  64. #ifdef WWDEBUG //don't create debug widgets in release builds...
  65. for (int i=0; i<NUM_WIDGETS; i++) {
  66. WWASSERT(_WidgetDefs[i].Id == i);
  67. if (_WidgetDefs[i].RObj == NULL) {
  68. RAMFileClass file((void*)_WidgetDefs[i].Data,_WidgetDefs[i].Size);
  69. WW3DAssetManager::Get_Instance()->Load_3D_Assets(file);
  70. _WidgetDefs[i].RObj = WW3DAssetManager::Get_Instance()->Create_Render_Obj(_WidgetDefs[i].Name);
  71. SET_REF_OWNER( _WidgetDefs[i].RObj );
  72. }
  73. }
  74. #endif
  75. }
  76. void WidgetSystem::Release_Debug_Widgets(void)
  77. {
  78. #ifdef WWDEBUG
  79. for (int i=0; i<NUM_WIDGETS; i++) {
  80. REF_PTR_RELEASE(_WidgetDefs[i].RObj);
  81. }
  82. #endif
  83. }
  84. RenderObjClass * WidgetSystem::Get_Debug_Widget(WidgetType id)
  85. {
  86. #ifdef WWDEBUG
  87. if (_WidgetDefs[id].RObj != NULL) {
  88. _WidgetDefs[id].RObj->Add_Ref();
  89. }
  90. return _WidgetDefs[id].RObj;
  91. #else
  92. return NULL;
  93. #endif
  94. }