SkyPropPage.cpp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. // SkyPropPage.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "skyproppage.h"
  22. #include "backgroundmgr.h"
  23. #include "combat.h"
  24. #include "leveledit.h"
  25. #include "phys.h"
  26. #include "pscene.h"
  27. #ifdef _DEBUG
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32. // Defines.
  33. #define CLOUD_SLIDER_RESOLUTION 20
  34. /////////////////////////////////////////////////////////////////////////////
  35. // SkyPropPageClass property page
  36. IMPLEMENT_DYNCREATE(SkyPropPageClass, CPropertyPage)
  37. SkyPropPageClass::SkyPropPageClass() : CPropertyPage(SkyPropPageClass::IDD)
  38. {
  39. //{{AFX_DATA_INIT(SkyPropPageClass)
  40. //}}AFX_DATA_INIT
  41. }
  42. SkyPropPageClass::~SkyPropPageClass()
  43. {
  44. }
  45. void SkyPropPageClass::DoDataExchange(CDataExchange* pDX)
  46. {
  47. CPropertyPage::DoDataExchange(pDX);
  48. //{{AFX_DATA_MAP(SkyPropPageClass)
  49. DDX_Control(pDX, IDC_SKY_CLOUD_GLOOMINESS, CloudGloominessCtrl);
  50. DDX_Control(pDX, IDC_SKY_CLOUD_COVER, CloudCoverCtrl);
  51. DDX_Control(pDX, IDC_SKY_TIME_OF_DAY, TimeCtrl);
  52. //}}AFX_DATA_MAP
  53. }
  54. BEGIN_MESSAGE_MAP(SkyPropPageClass, CPropertyPage)
  55. //{{AFX_MSG_MAP(SkyPropPageClass)
  56. ON_BN_CLICKED(IDC_SKY_LIGHT_MOON, OnSkyLightMoon)
  57. ON_BN_CLICKED(IDC_SKY_LIGHT_SUN, OnSkyLightSun)
  58. ON_BN_CLICKED(IDC_SKY_MOON_FULL, OnSkyMoonFull)
  59. ON_BN_CLICKED(IDC_SKY_MOON_PARTIAL, OnSkyMoonPartial)
  60. //}}AFX_MSG_MAP
  61. END_MESSAGE_MAP()
  62. /////////////////////////////////////////////////////////////////////////////
  63. // SkyPropPageClass message handlers
  64. BOOL SkyPropPageClass::OnInitDialog()
  65. {
  66. const CTime starttime (2000, 01, 01, 00, 00, 00, 0);
  67. const CTime endtime (2000, 01, 01, 23, 59, 00, 0);
  68. unsigned hours, minutes;
  69. _SYSTEMTIME systemtime;
  70. BackgroundMgrClass::LightSourceTypeEnum lightsourcetype;
  71. SkyClass::MoonTypeEnum moontype;
  72. float cloudcover, gloominess;
  73. CPropertyPage::OnInitDialog();
  74. BackgroundMgrClass::Get_Time_Of_Day (hours, minutes);
  75. // Format time display to 24hr clock.
  76. TimeCtrl.SetFormat ("HH:mm");
  77. TimeCtrl.SetRange (&starttime, &endtime);
  78. memset (&systemtime, 0, sizeof (systemtime));
  79. systemtime.wYear = 2000;
  80. systemtime.wMonth = 01;
  81. systemtime.wDay = 01;
  82. systemtime.wHour = hours;
  83. systemtime.wMinute = minutes;
  84. TimeCtrl.SetTime (&systemtime);
  85. lightsourcetype = BackgroundMgrClass::Get_Light_Source_Type();
  86. switch (lightsourcetype) {
  87. case BackgroundMgrClass::LIGHT_SOURCE_TYPE_SUN:
  88. OnSkyLightSun();
  89. break;
  90. case BackgroundMgrClass::LIGHT_SOURCE_TYPE_MOON:
  91. OnSkyLightMoon();
  92. break;
  93. default:
  94. ASSERT (false);
  95. break;
  96. }
  97. moontype = BackgroundMgrClass::Get_Moon_Type();
  98. switch (moontype) {
  99. case SkyClass::MOON_TYPE_FULL:
  100. OnSkyMoonFull();
  101. break;
  102. case SkyClass::MOON_TYPE_PART:
  103. OnSkyMoonPartial();
  104. break;
  105. default:
  106. ASSERT (false);
  107. break;
  108. }
  109. BackgroundMgrClass::Get_Clouds (cloudcover, gloominess);
  110. CloudCoverCtrl.SetRange (0, CLOUD_SLIDER_RESOLUTION);
  111. CloudCoverCtrl.SetPos (WWMath::Float_To_Long (cloudcover * CLOUD_SLIDER_RESOLUTION));
  112. CloudGloominessCtrl.SetRange (0, CLOUD_SLIDER_RESOLUTION);
  113. CloudGloominessCtrl.SetPos (WWMath::Float_To_Long (gloominess * CLOUD_SLIDER_RESOLUTION));
  114. return TRUE; // return TRUE unless you set the focus to a control
  115. // EXCEPTION: OCX Property Pages should return FALSE
  116. }
  117. void SkyPropPageClass::OnSkyLightSun()
  118. {
  119. CheckDlgButton (IDC_SKY_LIGHT_SUN, 1);
  120. CheckDlgButton (IDC_SKY_LIGHT_MOON, 0);
  121. }
  122. void SkyPropPageClass::OnSkyLightMoon()
  123. {
  124. CheckDlgButton (IDC_SKY_LIGHT_SUN, 0);
  125. CheckDlgButton (IDC_SKY_LIGHT_MOON, 1);
  126. }
  127. void SkyPropPageClass::OnSkyMoonFull()
  128. {
  129. CheckDlgButton (IDC_SKY_MOON_FULL, 1);
  130. CheckDlgButton (IDC_SKY_MOON_PARTIAL, 0);
  131. }
  132. void SkyPropPageClass::OnSkyMoonPartial()
  133. {
  134. CheckDlgButton (IDC_SKY_MOON_FULL, 0);
  135. CheckDlgButton (IDC_SKY_MOON_PARTIAL, 1);
  136. }
  137. void SkyPropPageClass::OnOK()
  138. {
  139. const float oocloudsliderresolution = 1.0f / CLOUD_SLIDER_RESOLUTION;
  140. _SYSTEMTIME systemtime;
  141. float cloudcover, gloominess;
  142. TimeCtrl.GetTime (&systemtime);
  143. BackgroundMgrClass::Set_Time_Of_Day (systemtime.wHour, systemtime.wMinute);
  144. if (IsDlgButtonChecked (IDC_SKY_LIGHT_SUN) == 1) {
  145. BackgroundMgrClass::Set_Light_Source_Type (BackgroundMgrClass::LIGHT_SOURCE_TYPE_SUN);
  146. } else {
  147. BackgroundMgrClass::Set_Light_Source_Type (BackgroundMgrClass::LIGHT_SOURCE_TYPE_MOON);
  148. }
  149. if (IsDlgButtonChecked (IDC_SKY_MOON_FULL) == 1) {
  150. BackgroundMgrClass::Set_Moon_Type (SkyClass::MOON_TYPE_FULL);
  151. } else {
  152. BackgroundMgrClass::Set_Moon_Type (SkyClass::MOON_TYPE_PART);
  153. }
  154. cloudcover = CloudCoverCtrl.GetPos() * oocloudsliderresolution;
  155. gloominess = CloudGloominessCtrl.GetPos() * oocloudsliderresolution;
  156. BackgroundMgrClass::Set_Clouds (cloudcover, gloominess);
  157. CPropertyPage::OnOK();
  158. }