dlgconfigvideotab.cpp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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 : commando *
  23. * *
  24. * $Archive:: /Commando/Code/Commando/dlgconfigvideotab.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/07/02 6:29p $*
  29. * *
  30. * $Revision:: 10 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "dlgconfigvideotab.h"
  36. #include "resource.h"
  37. #include "ww3d.h"
  38. #include "sliderctrl.h"
  39. #include "dx8wrapper.h"
  40. #include "cardinalspline.h"
  41. #include "string_ids.h"
  42. ////////////////////////////////////////////////////////////////
  43. // Static member initialization
  44. ////////////////////////////////////////////////////////////////
  45. int DlgConfigVideoTabClass::GammaLevel = GAMMA_SLIDER_DEFAULT;
  46. int DlgConfigVideoTabClass::BrightnessLevel = BRIGHTNESS_SLIDER_DEFAULT;
  47. int DlgConfigVideoTabClass::ContrastLevel = CONTRAST_SLIDER_DEFAULT;
  48. ////////////////////////////////////////////////////////////////
  49. //
  50. // DlgConfigVideoTabClass
  51. //
  52. ////////////////////////////////////////////////////////////////
  53. DlgConfigVideoTabClass::DlgConfigVideoTabClass (void) :
  54. ChildDialogClass (IDD_CONFIG_VIDEO),
  55. UpdateGamma (true)
  56. {
  57. return ;
  58. }
  59. ////////////////////////////////////////////////////////////////
  60. //
  61. // ~DlgConfigVideoTabClass
  62. //
  63. ////////////////////////////////////////////////////////////////
  64. DlgConfigVideoTabClass::~DlgConfigVideoTabClass (void)
  65. {
  66. return ;
  67. }
  68. ////////////////////////////////////////////////////////////////
  69. //
  70. // On_Init_Dialog
  71. //
  72. ////////////////////////////////////////////////////////////////
  73. void
  74. DlgConfigVideoTabClass::On_Init_Dialog (void)
  75. {
  76. //
  77. // Get the name of the render device
  78. //
  79. int curr_device = WW3D::Get_Render_Device ();
  80. StringClass ascii_device_name = WW3D::Get_Render_Device_Name (curr_device);
  81. WideStringClass device_name;
  82. device_name.Convert_From (ascii_device_name);
  83. //
  84. // Get the current resolution
  85. //
  86. int width = 0;
  87. int height = 0;
  88. int bits = 0;
  89. bool is_windowed = false;
  90. WW3D::Get_Device_Resolution (width, height, bits, is_windowed);
  91. WideStringClass resolution;
  92. resolution.Format (L"%d x %d", width, height);
  93. //
  94. // Build a string with the current bit depth
  95. //
  96. WideStringClass bit_depth;
  97. bit_depth.Format (L"%d", bits);
  98. //
  99. // Put the data into the dialog
  100. //
  101. Set_Dlg_Item_Text (IDC_DISPLAY_DRIVER, device_name);
  102. Set_Dlg_Item_Text (IDC_RESOLUTION, resolution);
  103. Set_Dlg_Item_Text (IDC_BIT_DEPTH, bit_depth);
  104. Enable_Dlg_Item (IDC_DISPLAY_DRIVER, false);
  105. Enable_Dlg_Item (IDC_RESOLUTION, false);
  106. Enable_Dlg_Item (IDC_BIT_DEPTH, false);
  107. SliderCtrlClass *slider;
  108. // To avoid partial (and incorrect) gamma updates, disable it until all values have been correctly set.
  109. UpdateGamma = false;
  110. //
  111. // Configure the gamma slider
  112. //
  113. slider = (SliderCtrlClass *)Get_Dlg_Item (IDC_GAMMA_SLIDER);
  114. slider->Set_Range (GAMMA_SLIDER_MIN, GAMMA_SLIDER_MAX);
  115. slider->Set_Pos (GammaLevel);
  116. //
  117. // Configure the brightness slider
  118. //
  119. slider = (SliderCtrlClass *)Get_Dlg_Item (IDC_BRIGHTNESS_SLIDER);
  120. slider->Set_Range (BRIGHTNESS_SLIDER_MIN, BRIGHTNESS_SLIDER_MAX);
  121. slider->Set_Pos (BrightnessLevel);
  122. //
  123. // Configure the contrast slider
  124. //
  125. slider = (SliderCtrlClass *)Get_Dlg_Item (IDC_CONTRAST_SLIDER);
  126. slider->Set_Range (CONTRAST_SLIDER_MIN, CONTRAST_SLIDER_MAX);
  127. // Now the gamma can take effect.
  128. UpdateGamma = true;
  129. slider->Set_Pos (ContrastLevel);
  130. ChildDialogClass::On_Init_Dialog ();
  131. return ;
  132. }
  133. ////////////////////////////////////////////////////////////////
  134. //
  135. // On_End_Dialog
  136. //
  137. ////////////////////////////////////////////////////////////////
  138. void
  139. DlgConfigVideoTabClass::On_Destroy (void)
  140. {
  141. GammaLevel = ((SliderCtrlClass *)Get_Dlg_Item (IDC_GAMMA_SLIDER))->Get_Pos();
  142. BrightnessLevel = ((SliderCtrlClass *)Get_Dlg_Item (IDC_BRIGHTNESS_SLIDER))->Get_Pos();
  143. ContrastLevel = ((SliderCtrlClass *)Get_Dlg_Item (IDC_CONTRAST_SLIDER))->Get_Pos();
  144. }
  145. ////////////////////////////////////////////////////////////////
  146. //
  147. // On_SliderCtrl_Pos_Changed
  148. //
  149. ////////////////////////////////////////////////////////////////
  150. void
  151. DlgConfigVideoTabClass::On_SliderCtrl_Pos_Changed
  152. (
  153. SliderCtrlClass * slider_ctrl,
  154. int ctrl_id,
  155. int new_pos
  156. )
  157. {
  158. const WCHAR *formatstring = L"%.2f";
  159. WideStringClass settingstring;
  160. if (UpdateGamma) {
  161. int g, b, c;
  162. g = ((SliderCtrlClass *)Get_Dlg_Item (IDC_GAMMA_SLIDER))->Get_Pos();
  163. b = ((SliderCtrlClass *)Get_Dlg_Item (IDC_BRIGHTNESS_SLIDER))->Get_Pos();
  164. c = ((SliderCtrlClass *)Get_Dlg_Item (IDC_CONTRAST_SLIDER))->Get_Pos();
  165. Update_Gamma (g, b, c);
  166. }
  167. switch (ctrl_id) {
  168. case IDC_GAMMA_SLIDER:
  169. settingstring.Format (formatstring, Gamma_Scale (slider_ctrl->Get_Pos()));
  170. Set_Dlg_Item_Text (IDC_GAMMA_SETTING, settingstring);
  171. break;
  172. case IDC_BRIGHTNESS_SLIDER:
  173. settingstring.Format (formatstring, Gamma_Scale (slider_ctrl->Get_Pos()));
  174. Set_Dlg_Item_Text (IDC_BRIGHTNESS_SETTING, settingstring);
  175. break;
  176. case IDC_CONTRAST_SLIDER:
  177. settingstring.Format (formatstring, Gamma_Scale (slider_ctrl->Get_Pos()));
  178. Set_Dlg_Item_Text (IDC_CONTRAST_SETTING, settingstring);
  179. break;
  180. default:
  181. // Do nothing.
  182. break;
  183. }
  184. return ;
  185. }