systemsettings.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  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. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Commando/systemsettings.cpp $*
  25. * *
  26. * $Author:: Byon_g $*
  27. * *
  28. * $Modtime:: 2/21/02 10:49a $*
  29. * *
  30. * $Revision:: 38 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "systemsettings.h"
  36. #include "registry.h"
  37. //#include "menuentry.h"
  38. #include "_globals.h"
  39. #include "combat.h"
  40. #include "pscene.h"
  41. #include "consolefunction.h"
  42. #include "ccamera.h"
  43. #include "phys.h"
  44. #include "dx8wrapper.h"
  45. #include "dx8caps.h"
  46. #include "surfaceeffects.h"
  47. #include "dlgconfigvideotab.h"
  48. #include "wwstring.h"
  49. /*
  50. **
  51. */
  52. DynamicVectorClass<SystemSettingEntry *> SystemSettings::SettingList;
  53. /*
  54. **
  55. */
  56. void SystemSettings::Apply_All( void )
  57. {
  58. for ( int index = 0; index < SettingList.Count(); index++ ) {
  59. SettingList[ index ]->Apply();
  60. }
  61. }
  62. /*
  63. **
  64. */
  65. void SystemSettings::Registry_Save( const char * sub_key )
  66. {
  67. RegistryClass registry( sub_key );
  68. if ( registry.Is_Valid() ) {
  69. for ( int index = 0; index < SettingList.Count(); index++ ) {
  70. SettingList[ index ]->Registry_Save( registry );
  71. }
  72. }
  73. }
  74. void SystemSettings::Registry_Load( const char * sub_key )
  75. {
  76. RegistryClass registry( sub_key );
  77. if ( registry.Is_Valid() ) {
  78. for ( int index = 0; index < SettingList.Count(); index++ ) {
  79. SettingList[ index ]->Registry_Load( registry );
  80. }
  81. }
  82. }
  83. /*
  84. **
  85. */
  86. void SystemSettings::Add_Console_Functions( DynamicVectorClass<ConsoleFunctionClass *> & list )
  87. {
  88. #ifdef WWDEBUG
  89. for ( int index = 0; index < SettingList.Count(); index++ ) {
  90. list.Add( SettingList[ index ]->Create_Console_Function() );
  91. }
  92. #endif
  93. }
  94. /** BOOL ENTRY *********************************************************************************/
  95. class ConsoleFunctionSettingBool : public ConsoleFunctionClass {
  96. public:
  97. ConsoleFunctionSettingBool( SystemSettingEntryBool * entry ) : Entry( entry ) {}
  98. virtual const char * Get_Name( void ) { return Entry->Get_Name(); }
  99. virtual const char * Get_Help( void ) { return Entry->Get_Help(); }
  100. virtual void Activate( const char * input ) {
  101. Entry->Set_State( !Entry->Get_State() );
  102. Print( "%s %s\n", Entry->Get_Name(), Entry->Get_State() ? "ON" : "OFF" );
  103. }
  104. private:
  105. SystemSettingEntryBool * Entry;
  106. };
  107. SystemSettingEntryBool::SystemSettingEntryBool( void ) :
  108. State( false )
  109. {
  110. }
  111. void SystemSettingEntryBool::Apply( void )
  112. {
  113. State = Get_Bool();
  114. }
  115. void SystemSettingEntryBool::Registry_Save( RegistryClass & registry )
  116. {
  117. registry.Set_Bool( Get_Name(), Get_State() );
  118. }
  119. void SystemSettingEntryBool::Registry_Load( RegistryClass & registry )
  120. {
  121. State = Get_Bool();
  122. Set_State( registry.Get_Bool( Get_Name(), Get_State() ) );
  123. }
  124. ConsoleFunctionClass * SystemSettingEntryBool::Create_Console_Function()
  125. {
  126. return new ConsoleFunctionSettingBool( this );
  127. }
  128. bool SystemSettingEntryBool::Get_State( void )
  129. {
  130. return State;
  131. }
  132. void SystemSettingEntryBool::Set_State( bool state )
  133. {
  134. State = state;
  135. Set_Bool( State );
  136. State = Get_Bool();
  137. }
  138. /** SLIDER ENTRY *********************************************************************************/
  139. class ConsoleFunctionSettingSlider : public ConsoleFunctionClass {
  140. public:
  141. ConsoleFunctionSettingSlider( SystemSettingEntrySlider * entry ) : Entry( entry ) {}
  142. virtual const char * Get_Name( void ) { return Entry->Get_Name(); }
  143. virtual const char * Get_Help( void ) { return Entry->Get_Help(); }
  144. virtual void Activate( const char * input ) {
  145. Entry->Set_Value( atoi( input ) );
  146. Print( "%s = %d\n", Entry->Get_Name(), Entry->Get_Value() );
  147. }
  148. private:
  149. SystemSettingEntrySlider * Entry;
  150. };
  151. SystemSettingEntrySlider::SystemSettingEntrySlider( void ) :
  152. Value( 0 ),
  153. Min( 0 ),
  154. Max ( 10 ),
  155. StepSize( 1 )
  156. {
  157. }
  158. void SystemSettingEntrySlider::Apply( void )
  159. {
  160. Value = Get_Slider();
  161. }
  162. void SystemSettingEntrySlider::Registry_Save( RegistryClass & registry )
  163. {
  164. registry.Set_Int( Get_Name(), Get_Value() );
  165. }
  166. void SystemSettingEntrySlider::Registry_Load( RegistryClass & registry )
  167. {
  168. Set_Value( registry.Get_Int( Get_Name(), Get_Value() ) );
  169. }
  170. ConsoleFunctionClass * SystemSettingEntrySlider::Create_Console_Function()
  171. {
  172. return new ConsoleFunctionSettingSlider( this );
  173. }
  174. int SystemSettingEntrySlider::Get_Value( void )
  175. {
  176. return Value;
  177. }
  178. void SystemSettingEntrySlider::Set_Value( int value )
  179. {
  180. Value = (value > Max ) ? Max : ((value < Min) ? Min : value);
  181. Set_Slider( Value );
  182. Value = Get_Slider();
  183. }
  184. /** ENUM ENTRY *********************************************************************************/
  185. class ConsoleFunctionSettingEnum : public ConsoleFunctionClass {
  186. public:
  187. ConsoleFunctionSettingEnum( SystemSettingEntryEnum * entry ) : Entry( entry ) {}
  188. virtual const char * Get_Name( void ) { return Entry->Get_Name(); }
  189. virtual const char * Get_Help( void ) { return Entry->Get_Help(); }
  190. virtual void Activate( const char * input ) {
  191. Entry->Set_Selection( input );
  192. Print( "%s = %s\n", Entry->Get_Name(), Entry->Get_Enum_Name( Entry->Get_Selection() ) );
  193. }
  194. private:
  195. SystemSettingEntryEnum * Entry;
  196. };
  197. SystemSettingEntryEnum::SystemSettingEntryEnum( void ) :
  198. Selection( 0 )
  199. {
  200. }
  201. void SystemSettingEntryEnum::Apply( void )
  202. {
  203. Selection = Get_Enum();
  204. }
  205. void SystemSettingEntryEnum::Registry_Save( RegistryClass & registry )
  206. {
  207. registry.Set_Int( Get_Name(), Get_Selection() );
  208. }
  209. void SystemSettingEntryEnum::Registry_Load( RegistryClass & registry )
  210. {
  211. Set_Selection( registry.Get_Int( Get_Name(), Get_Selection() ) );
  212. }
  213. ConsoleFunctionClass * SystemSettingEntryEnum::Create_Console_Function()
  214. {
  215. return new ConsoleFunctionSettingEnum( this );
  216. }
  217. int SystemSettingEntryEnum::Get_Selection( void )
  218. {
  219. return Selection;
  220. }
  221. void SystemSettingEntryEnum::Set_Selection( int selection )
  222. {
  223. Selection = (selection >= Get_Enum_Count() ) ? Get_Enum_Count()-1 : ((selection < 0) ? 0 : selection);
  224. Set_Enum( Selection );
  225. Selection = Get_Enum();
  226. }
  227. void SystemSettingEntryEnum::Set_Selection( const char * name )
  228. {
  229. bool found = false;
  230. for ( int i = 0; i < Get_Enum_Count(); i++ ) {
  231. if ( stricmp( name, Get_Enum_Name( i ) ) == 0 ) {
  232. Set_Selection( i );
  233. found = true;
  234. }
  235. }
  236. if ( !found ) {
  237. Set_Selection( atoi( name ) );
  238. }
  239. }
  240. /***********************************************************************************************/
  241. class SystemSettingEntryStaticProjectors : public SystemSettingEntryBool {
  242. public:
  243. const char * Get_Name( void ) { return "Static_Projectors"; }
  244. const char * Get_Help( void ) { return "STATIC_PROJECTORS - toggles static projectors."; }
  245. virtual bool Get_Bool( void ) { if ( COMBAT_SCENE ) return COMBAT_SCENE->Are_Static_Projectors_Enabled(); return State; }
  246. virtual void Set_Bool( bool state ) { if ( COMBAT_SCENE ) COMBAT_SCENE->Enable_Static_Projectors( state ); }
  247. };
  248. /***********************************************************************************************/
  249. class SystemSettingEntryDynamicProjectors : public SystemSettingEntryBool {
  250. public:
  251. const char * Get_Name( void ) { return "Dynamic_Projectors"; }
  252. const char * Get_Help( void ) { return "DYNAMIC_PROJECTORS - toggles dynamic projectors."; }
  253. virtual bool Get_Bool( void ) { if ( COMBAT_SCENE ) return COMBAT_SCENE->Are_Dynamic_Projectors_Enabled(); return State; }
  254. virtual void Set_Bool( bool state ) { if ( COMBAT_SCENE ) COMBAT_SCENE->Enable_Dynamic_Projectors( state ); }
  255. };
  256. /***********************************************************************************************/
  257. class SystemSettingEntryWeaponHelp : public SystemSettingEntryBool {
  258. public:
  259. const char * Get_Name( void ) { return "Enable_Weapon_Help"; }
  260. const char * Get_Help( void ) { return "ENABLE_WEAPON_HELP - toggles weapon aiming help."; }
  261. virtual bool Get_Bool( void ) { if ( COMBAT_CAMERA ) return COMBAT_CAMERA->Is_Weapon_Help_Enabled(); return State; }
  262. virtual void Set_Bool( bool state ) { if ( COMBAT_CAMERA ) COMBAT_CAMERA->Enable_Weapon_Help( state ); }
  263. };
  264. /***********************************************************************************************/
  265. class SystemSettingEntryAutoTransitions : public SystemSettingEntryBool {
  266. public:
  267. const char * Get_Name( void ) { return "Enable_Auto_Transitions"; }
  268. const char * Get_Help( void ) { return "ENABLE_AUTO_TRANSITIONS - toggles automatic doors and transitions."; }
  269. virtual bool Get_Bool( void ) { return CombatManager::Are_Transitions_Automatic(); }
  270. virtual void Set_Bool( bool state ) { CombatManager::Set_Transitions_Automatic( state ); }
  271. };
  272. /***********************************************************************************************/
  273. class SystemSettingEntryGammaLevel : public SystemSettingEntrySlider {
  274. public:
  275. SystemSettingEntryGammaLevel( void ) {
  276. Set_Range( GAMMA_SLIDER_MIN, GAMMA_SLIDER_MAX );
  277. Set_Step_Size( 1 );
  278. Set_Value( GAMMA_SLIDER_DEFAULT );
  279. }
  280. const char * Get_Name( void ) { return "Gamma_Correction"; }
  281. const char * Get_Help( void ) { formatstring.Format ("GAMMA_CORRECTION [%d..%d] - Adjusts gamma correction curve for the display.", GAMMA_SLIDER_MIN, GAMMA_SLIDER_MAX); return (formatstring); }
  282. int Get_Slider( void ) { Value = DlgConfigVideoTabClass::Get_Gamma (); return Value; }
  283. void Set_Slider( int value ) { DlgConfigVideoTabClass::Set_Gamma (value); }
  284. void Registry_Save ( RegistryClass & registry ) { registry.Set_Int (Get_Name (), Get_Slider ()); }
  285. protected:
  286. StringClass formatstring;
  287. };
  288. /***********************************************************************************************/
  289. class SystemSettingEntryBrightnessLevel : public SystemSettingEntrySlider {
  290. public:
  291. SystemSettingEntryBrightnessLevel( void ) {
  292. Set_Range( BRIGHTNESS_SLIDER_MIN, BRIGHTNESS_SLIDER_MAX );
  293. Set_Step_Size( 1 );
  294. Set_Value( BRIGHTNESS_SLIDER_DEFAULT );
  295. }
  296. const char * Get_Name( void ) { return "Brightness"; }
  297. const char * Get_Help( void ) { formatstring.Format ("BRIGHTNESS [%d..%d] - Adjusts brightness for the display.", BRIGHTNESS_SLIDER_MIN, BRIGHTNESS_SLIDER_MAX); return (formatstring); }
  298. int Get_Slider( void ) { Value = DlgConfigVideoTabClass::Get_Brightness (); return Value; }
  299. void Set_Slider( int value ) { DlgConfigVideoTabClass::Set_Brightness (value); }
  300. void Registry_Save ( RegistryClass & registry ) { registry.Set_Int (Get_Name (), Get_Slider ()); }
  301. protected:
  302. StringClass formatstring;
  303. };
  304. /***********************************************************************************************/
  305. class SystemSettingEntryContrastLevel : public SystemSettingEntrySlider {
  306. public:
  307. SystemSettingEntryContrastLevel( void ) {
  308. Set_Range( CONTRAST_SLIDER_MIN, CONTRAST_SLIDER_MAX );
  309. Set_Step_Size( 1 );
  310. Set_Value( CONTRAST_SLIDER_DEFAULT );
  311. }
  312. const char * Get_Name( void ) { return "Contrast"; }
  313. const char * Get_Help( void ) { formatstring.Format ("CONTRAST [%d..%d] - Adjusts contrast for the display.", CONTRAST_SLIDER_MIN, CONTRAST_SLIDER_MAX); return (formatstring); }
  314. int Get_Slider( void ) { Value = DlgConfigVideoTabClass::Get_Contrast (); return Value; }
  315. void Set_Slider( int value ) { DlgConfigVideoTabClass::Set_Contrast (value); }
  316. void Registry_Save ( RegistryClass & registry ) { registry.Set_Int (Get_Name (), Get_Slider ()); }
  317. protected:
  318. StringClass formatstring;
  319. };
  320. /***********************************************************************************************/
  321. class SystemSettingEntryTextureResolution : public SystemSettingEntrySlider {
  322. public:
  323. SystemSettingEntryTextureResolution( void ) {
  324. Set_Range( 0, 7 );
  325. Set_Step_Size( 1 );
  326. Set_Value( 0 );
  327. }
  328. const char * Get_Name( void ) { return "Texture_Resolution"; }
  329. const char * Get_Help( void ) { return "TEXTURE_RESOLUTION [0..7] - sets the texture resolution."; }
  330. virtual int Get_Slider( void ) { return WW3D::Get_Texture_Reduction(); }
  331. virtual void Set_Slider( int value ) { if ( WW3D::Get_Texture_Reduction() != value ) { WW3D::Set_Texture_Reduction( value ); } }
  332. };
  333. /***********************************************************************************************/
  334. class SystemSettingEntryDynamicLODBudget : public SystemSettingEntrySlider {
  335. public:
  336. SystemSettingEntryDynamicLODBudget( void ) {
  337. Set_Range( 100, 100000 );
  338. Set_Step_Size( 100 );
  339. Set_Value( 10000 );
  340. }
  341. const char * Get_Name( void ) { return "Dynamic_LOD_Budget"; }
  342. const char * Get_Help( void ) { return "DYNAMIC_LOD_BUDGET <n> - sets the Dynamic LOD Budget."; }
  343. virtual int Get_Slider( void ) {
  344. int scount,dcount = Value;
  345. if ( PhysicsSceneClass::Get_Instance() ) {
  346. PhysicsSceneClass::Get_Instance()->Get_Polygon_Budgets(&scount,&dcount);
  347. }
  348. return dcount;
  349. }
  350. virtual void Set_Slider( int value ) {
  351. if ( PhysicsSceneClass::Get_Instance() ) {
  352. int scount,dcount;
  353. PhysicsSceneClass::Get_Instance()->Get_Polygon_Budgets(&scount,&dcount);
  354. PhysicsSceneClass::Get_Instance()->Set_Polygon_Budgets(scount,value);
  355. }
  356. }
  357. };
  358. /***********************************************************************************************/
  359. class SystemSettingEntryStaticLODBudget : public SystemSettingEntrySlider {
  360. public:
  361. SystemSettingEntryStaticLODBudget( void ) {
  362. Set_Range( 100, 10000 );
  363. Set_Step_Size( 100 );
  364. Set_Value( 3000 );
  365. }
  366. const char * Get_Name( void ) { return "Static_LOD_Budget"; }
  367. const char * Get_Help( void ) { return "STATIC_LOD_BUDGET <n> - sets the Static LOD Budget."; }
  368. virtual int Get_Slider( void ) {
  369. int dcount,scount = Value;
  370. if ( PhysicsSceneClass::Get_Instance() ) {
  371. PhysicsSceneClass::Get_Instance()->Get_Polygon_Budgets(&scount,&dcount);
  372. }
  373. return scount;
  374. }
  375. virtual void Set_Slider( int value ) {
  376. if ( PhysicsSceneClass::Get_Instance() ) {
  377. int scount,dcount;
  378. PhysicsSceneClass::Get_Instance()->Get_Polygon_Budgets(&scount,&dcount);
  379. PhysicsSceneClass::Get_Instance()->Set_Polygon_Budgets(value,dcount);
  380. }
  381. }
  382. };
  383. /***********************************************************************************************/
  384. class SystemSettingEntryShadowMode : public SystemSettingEntryEnum {
  385. public:
  386. const char * Get_Name( void ) { return "Shadow_Mode"; }
  387. const char * Get_Help( void ) { return "SHADOW_MODE <mode> - 0=none 1=blobs 2=blobs+ 3=projected textures"; }
  388. virtual int Get_Enum( void ) { if (COMBAT_SCENE) return COMBAT_SCENE->Get_Shadow_Mode(); return Selection; }
  389. virtual void Set_Enum( int selection ) { if (COMBAT_SCENE) COMBAT_SCENE->Set_Shadow_Mode( (PhysicsSceneClass::ShadowEnum)selection ); }
  390. virtual int Get_Enum_Count( void ) { return 4; }
  391. virtual const char * Get_Enum_Name( int selection ) {
  392. static const char * names[ 4 ] = { "None", "Blobs", "Blobs+", "Projections" };
  393. return names[ selection ];
  394. }
  395. };
  396. /***********************************************************************************************/
  397. class SystemSettingEntrySurfaceEffectDetail: public SystemSettingEntryEnum {
  398. public:
  399. const char * Get_Name( void ) { return "Surface_Effect_Detail"; }
  400. const char * Get_Help( void ) { return "SURFACE_EFFECT_DETAIL <level> - 0=off 1=no emitters 2=full"; }
  401. virtual int Get_Enum( void ) { return SurfaceEffectsManager::Get_Mode (); }
  402. virtual void Set_Enum( int value ) { SurfaceEffectsManager::Set_Mode ((SurfaceEffectsManager::MODE)value); }
  403. virtual int Get_Enum_Count( void ) { return 3; }
  404. virtual const char * Get_Enum_Name( int selection ) {
  405. static const char * names[ 3 ] = { "Off", "No Emitters", "Full" };
  406. return names[ selection ];
  407. }
  408. };
  409. /***********************************************************************************************/
  410. class SystemSettingEntryMeshDrawMode : public SystemSettingEntryEnum {
  411. static const char * names[7];
  412. public:
  413. const char * Get_Name( void ) { return "Mesh_Draw_Mode"; }
  414. const char * Get_Help( void ) { return "MESH_DRAW_MODE <mode> - 0=old 1=new 2=debug 3=debug clip 4=box 5=none 6=dx8 only"; }
  415. virtual int Get_Enum( void ) { return WW3D::Get_Mesh_Draw_Mode(); }
  416. virtual void Set_Enum( int selection ) {
  417. WW3D::Set_Mesh_Draw_Mode( (WW3D::MeshDrawModeEnum) selection );
  418. }
  419. virtual int Get_Enum_Count( void ) { return sizeof(names)/sizeof(char*); }
  420. virtual const char * Get_Enum_Name( int selection ) {
  421. WWASSERT(selection>=0 && selection<sizeof(names)/sizeof(char*));
  422. return names[ selection ];
  423. }
  424. };
  425. const char * SystemSettingEntryMeshDrawMode::names[] = { "Old", "New", "Debug Draw", "Debug Clip", "Box", "None", "DX8 only" };
  426. /***********************************************************************************************/
  427. class SystemSettingEntryNPatchGapFillingMode : public SystemSettingEntryEnum {
  428. static const char * names[3];
  429. public:
  430. const char * Get_Name( void ) { return "NPatches_Gap_Filling_Mode"; }
  431. const char * Get_Help( void ) { return "NPATCHES_GAP_FILLING_MODE <mode> - 0=disabled 1=enabled 2=force"; }
  432. virtual int Get_Enum( void ) { return WW3D::Get_NPatches_Gap_Filling_Mode(); }
  433. virtual void Set_Enum( int selection ) {
  434. WW3D::Set_NPatches_Gap_Filling_Mode( (WW3D::NPatchesGapFillingModeEnum) selection );
  435. }
  436. virtual int Get_Enum_Count( void ) { return sizeof(names)/sizeof(char*); }
  437. virtual const char * Get_Enum_Name( int selection ) {
  438. WWASSERT(selection>=0 && selection<sizeof(names)/sizeof(char*));
  439. return names[ selection ];
  440. }
  441. };
  442. const char * SystemSettingEntryNPatchGapFillingMode::names[] = { "Disabled", "Enabled", "FORCE (Enabled even when not using n-patches)" };
  443. /***********************************************************************************************/
  444. class SystemSettingEntryNPatches : public SystemSettingEntryEnum {
  445. static const char * names[9];
  446. StringClass Name;
  447. public:
  448. SystemSettingEntryNPatches()
  449. {
  450. Name="NPatches";
  451. }
  452. virtual ~SystemSettingEntryNPatches(void){};
  453. const char * Get_Name( void ) { return Name; }
  454. const char * Get_Help( void ) { return "NPatches <level> - 1=default, 8=max"; }
  455. virtual int Get_Enum( void ) { return WW3D::Get_NPatches_Level(); }
  456. virtual void Set_Enum( int selection ) {
  457. WW3D::Set_NPatches_Level( selection );
  458. if (DX8Wrapper::Get_Current_Caps() && !DX8Wrapper::Get_Current_Caps()->Support_NPatches()) {
  459. Name="NPatches (NOT SUPPORTED BY HARDWARE)";
  460. }
  461. }
  462. virtual int Get_Enum_Count( void ) { return sizeof(names)/sizeof(char*); }
  463. virtual const char * Get_Enum_Name( int selection ) {
  464. WWASSERT(selection>=0 && selection<sizeof(names)/sizeof(char*));
  465. return names[ selection ];
  466. }
  467. };
  468. const char * SystemSettingEntryNPatches::names[] = {
  469. "NPatches DISABLED",
  470. "NPatches DISABLED",
  471. "NPatches level 2",
  472. "NPatches level 3",
  473. "NPatches level 4",
  474. "NPatches level 5",
  475. "NPatches level 6",
  476. "NPatches level 7",
  477. "NPatches level 8"
  478. };
  479. /***********************************************************************************************/
  480. class SystemSettingEntryPrelitMode : public SystemSettingEntryEnum {
  481. public:
  482. const char * Get_Name( void ) { return "Prelit_Mode"; }
  483. const char * Get_Help( void ) { return "PRELIT_MODE <mode> - 0=vertex 1=multi-pass 2=multi-texture."; }
  484. virtual int Get_Enum( void ) { return WW3D::Get_Prelit_Mode(); }
  485. virtual void Set_Enum( int selection ) {
  486. if ( WW3D::Supports_Prelit_Mode( (WW3D::PrelitModeEnum) selection ) ) {
  487. WW3D::Set_Prelit_Mode( (WW3D::PrelitModeEnum) selection );
  488. }
  489. }
  490. virtual int Get_Enum_Count( void ) { return 3; }
  491. virtual const char * Get_Enum_Name( int selection ) {
  492. static const char * names[ 3 ] = { "Vertex", "Multi-pass", "Multi-texture" };
  493. return names[ selection ];
  494. }
  495. };
  496. /***********************************************************************************************/
  497. class SystemSettingEntryTextureFilterMode : public SystemSettingEntryEnum {
  498. public:
  499. const char * Get_Name( void ) { return "Texture_Filter_Mode"; }
  500. const char * Get_Help( void ) { return "TEXTURE_FILTER_MODE <mode> - 0=bilinear 1=trilinear 2=anisotropic."; }
  501. virtual int Get_Enum( void ) { return WW3D::Get_Texture_Filter(); }
  502. virtual void Set_Enum( int selection ) {
  503. WW3D::Set_Texture_Filter( selection );
  504. }
  505. virtual int Get_Enum_Count( void ) { return 3; }
  506. virtual const char * Get_Enum_Name( int selection ) {
  507. static const char * names[ 3 ] = { "Bilinear", "Trilinear", "Anisotropic" };
  508. return names[ selection ];
  509. }
  510. };
  511. /***********************************************************************************************/
  512. class SystemSettingEntryDifficulty : public SystemSettingEntryEnum {
  513. public:
  514. SystemSettingEntryDifficulty( void ) { Selection = Get_Enum(); }
  515. const char * Get_Name( void ) { return "Difficulty"; }
  516. const char * Get_Help( void ) { return "DIFFICULTY [0..2] - sets the difficulty level."; }
  517. virtual int Get_Enum( void ) { return CombatManager::Get_Difficulty_Level(); }
  518. virtual void Set_Enum( int value ) { CombatManager::Set_Difficulty_Level( value ); }
  519. virtual int Get_Enum_Count( void ) { return 3; }
  520. virtual const char * Get_Enum_Name( int selection ) {
  521. static const char * names[ 3 ] = { "Easy", "Average", "Difficult" };
  522. return names[ selection ];
  523. }
  524. };
  525. /***********************************************************************************************/
  526. void SystemSettings::Init( void )
  527. {
  528. Add_Setting( new SystemSettingEntryStaticProjectors );
  529. Add_Setting( new SystemSettingEntryDynamicProjectors );
  530. Add_Setting( new SystemSettingEntryTextureResolution );
  531. Add_Setting( new SystemSettingEntryDynamicLODBudget );
  532. Add_Setting( new SystemSettingEntryStaticLODBudget );
  533. Add_Setting( new SystemSettingEntryShadowMode );
  534. Add_Setting( new SystemSettingEntryPrelitMode );
  535. Add_Setting( new SystemSettingEntryMeshDrawMode );
  536. Add_Setting( new SystemSettingEntryNPatches );
  537. Add_Setting( new SystemSettingEntryNPatchGapFillingMode );
  538. // Add_Setting( new SystemSettingEntryTextureCompressionMode );
  539. Add_Setting( new SystemSettingEntryTextureFilterMode );
  540. // Add_Setting( new SystemSettingEntryTextureThumbnailMode );
  541. // Add_Setting( new SystemSettingEntryWeaponHelp );
  542. Add_Setting( new SystemSettingEntryAutoTransitions );
  543. Add_Setting( new SystemSettingEntryDifficulty );
  544. Add_Setting( new SystemSettingEntrySurfaceEffectDetail ) ;
  545. Add_Setting( new SystemSettingEntryGammaLevel ) ;
  546. Add_Setting( new SystemSettingEntryBrightnessLevel ) ;
  547. Add_Setting( new SystemSettingEntryContrastLevel ) ;
  548. Registry_Load( APPLICATION_SUB_KEY_NAME_SYSTEM_SETTINGS );
  549. }
  550. void SystemSettings::Shutdown( void )
  551. {
  552. Registry_Save( APPLICATION_SUB_KEY_NAME_SYSTEM_SETTINGS );
  553. /*
  554. ** Free the system setting so they don't look like memory leaks when we exit. ST - 6/11/2001 8:32PM
  555. */
  556. while (SettingList.Count()) {
  557. delete SettingList[0];
  558. SettingList.Delete(0);
  559. }
  560. }
  561. /*
  562. #if DEADMENU
  563. //
  564. //
  565. //
  566. MenuEntryClass * SystemSettings::Create_Menu_Entry( const char * setting_name )
  567. {
  568. for ( int index = 0; index < SettingList.Count(); index++ ) {
  569. if ( !stricmp( SettingList[ index ]->Get_Name(), setting_name ) ) {
  570. MenuEntryClass * entry = SettingList[ index ]->Create_Menu_Entry();
  571. if ( entry ) {
  572. entry->Set_Name( setting_name );
  573. }
  574. return entry;
  575. }
  576. }
  577. return NULL;
  578. }
  579. #endif //DEADMENU
  580. #if DEADMENU
  581. class MenuEntrySettingBool : public MenuEntryToggleClass {
  582. public:
  583. MenuEntrySettingBool( SystemSettingEntryBool * entry ) : Entry( entry ) {}
  584. virtual bool Get_State( void ) { return Entry->Get_State(); }
  585. virtual void Toggle( void ) { Entry->Set_State( !Entry->Get_State() ); }
  586. private:
  587. SystemSettingEntryBool * Entry;
  588. };
  589. #endif // DEADMENU
  590. #if DEADMENU
  591. MenuEntryClass * SystemSettingEntryBool::Create_Menu_Entry( void )
  592. {
  593. return new MenuEntrySettingBool( this );
  594. }
  595. #endif // DEADMENU
  596. #if DEADMENU
  597. class MenuEntrySettingSlider : public MenuEntryIntSliderClass {
  598. public:
  599. MenuEntrySettingSlider( SystemSettingEntrySlider * entry ) : Entry( entry ) {}
  600. virtual int Get_Value( void ) { return Entry->Get_Value(); }
  601. virtual void Set_Value( int value ) { Entry->Set_Value( value ); }
  602. virtual int Get_Step_Size( void ) { return Entry->Get_Step_Size(); }
  603. private:
  604. SystemSettingEntrySlider * Entry;
  605. };
  606. #endif // DEADMENU
  607. #if DEADMENU
  608. MenuEntryClass * SystemSettingEntrySlider::Create_Menu_Entry( void )
  609. {
  610. return new MenuEntrySettingSlider( this );
  611. }
  612. #endif // DEADMENU
  613. #if DEADMENU
  614. class MenuEntrySettingEnum : public MenuEntryEnumClass {
  615. public:
  616. MenuEntrySettingEnum( SystemSettingEntryEnum * entry ) : Entry( entry ) {}
  617. virtual const char * Get_Selection_Name( void )
  618. {
  619. return Entry->Get_Enum_Name( Entry->Get_Selection() );
  620. }
  621. virtual void Activate( void )
  622. {
  623. int selection = Entry->Get_Selection() + 1;
  624. if ( selection == Entry->Get_Enum_Count() ) {
  625. selection = 0;
  626. }
  627. Entry->Set_Selection( selection );
  628. }
  629. private:
  630. SystemSettingEntryEnum * Entry;
  631. };
  632. #endif // DEADMENU
  633. #if DEADMENU
  634. MenuEntryClass * SystemSettingEntryEnum::Create_Menu_Entry( void )
  635. {
  636. return new MenuEntrySettingEnum( this );
  637. }
  638. #endif // DEADMENU
  639. */