GammaDialog.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. // GammaDialog.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "w3dview.h"
  22. #include "GammaDialog.h"
  23. #include "dx8wrapper.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. // GammaDialogClass dialog
  31. GammaDialogClass::GammaDialogClass(CWnd* pParent /*=NULL*/)
  32. : CDialog(GammaDialogClass::IDD, pParent)
  33. {
  34. //{{AFX_DATA_INIT(GammaDialogClass)
  35. m_gamma = 0;
  36. //}}AFX_DATA_INIT
  37. }
  38. void GammaDialogClass::DoDataExchange(CDataExchange* pDX)
  39. {
  40. CDialog::DoDataExchange(pDX);
  41. //{{AFX_DATA_MAP(GammaDialogClass)
  42. DDX_Control(pDX, IDC_GAMMA_SLIDER, m_gammaslider);
  43. DDX_Slider(pDX, IDC_GAMMA_SLIDER, m_gamma);
  44. //}}AFX_DATA_MAP
  45. }
  46. BEGIN_MESSAGE_MAP(GammaDialogClass, CDialog)
  47. //{{AFX_MSG_MAP(GammaDialogClass)
  48. ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_GAMMA_SLIDER, OnReleasedcaptureGammaSlider)
  49. //}}AFX_MSG_MAP
  50. END_MESSAGE_MAP()
  51. /////////////////////////////////////////////////////////////////////////////
  52. // GammaDialogClass message handlers
  53. BOOL GammaDialogClass::OnInitDialog()
  54. {
  55. CDialog::OnInitDialog();
  56. // TODO: Add extra initialization here
  57. m_gamma=AfxGetApp()->GetProfileInt("Config","Gamma",10);
  58. if (m_gamma<10) m_gamma=10;
  59. if (m_gamma>30) m_gamma=30;
  60. m_gammaslider.SetRange(10,30);
  61. m_gammaslider.SetPos(m_gamma);
  62. CString string;
  63. string.Format("%3.2f",m_gamma/10.0f);
  64. SetDlgItemText(IDC_GAMMA_DISPLAY,string);
  65. string.Format("Calibration instructions\n");
  66. string+="A. Set Gamma to 1.0 and Monitor Contrast and Brightness to maximum\n";
  67. string+="B. Adjust Monitor Brightness down so Bar 3 is barely visible\n";
  68. string+="C. Adjust Monitor Contrast as preferred but Bars 1,2,3,4 must be distinguishable from each other\n";
  69. string+="D. Set the Gamma using the Slider below so the gray box on the left matches it's checkered surroundings\n";
  70. string+="E. Press OK to save settings";
  71. SetDlgItemText(IDC_INSTRUCTIONS,string);
  72. return TRUE; // return TRUE unless you set the focus to a control
  73. // EXCEPTION: OCX Property Pages should return FALSE
  74. }
  75. void GammaDialogClass::OnOK()
  76. {
  77. // TODO: Add extra validation here
  78. m_gamma=m_gammaslider.GetPos();
  79. if (m_gamma<10) m_gamma=10;
  80. if (m_gamma>30) m_gamma=30;
  81. ::AfxGetApp()->WriteProfileInt("Config","Gamma",m_gamma);
  82. DX8Wrapper::Set_Gamma(m_gamma/10.0f,0.0f,1.0f);
  83. CDialog::OnOK();
  84. }
  85. void GammaDialogClass::OnReleasedcaptureGammaSlider(NMHDR* pNMHDR, LRESULT* pResult)
  86. {
  87. // TODO: Add your control notification handler code here
  88. m_gamma=m_gammaslider.GetPos();
  89. DX8Wrapper::Set_Gamma(m_gamma/10.0f,0.0f,1.0f);
  90. CString string;
  91. string.Format("%3.2f",m_gamma/10.0f);
  92. SetDlgItemText(IDC_GAMMA_DISPLAY,string);
  93. *pResult = 0;
  94. }