Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

189 lines
5.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. // SwitchProps.cpp : implementation file
  9. //
  10. #include "stdafx.h"
  11. #include "UI.h"
  12. #include "SwitchProps.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CSwitchProps dialog
  20. CSwitchProps::CSwitchProps(CWnd* pParent /*=NULL*/)
  21. : CPropertyPage(CSwitchProps::IDD),
  22. m_persistDefall("AllSwitchesDefault"),
  23. m_persistDisplayMM2("DefaultMM2"),
  24. m_persistDisplayStartupInfo("DefaultStartupInfo"),
  25. m_persistPersistPlayerStats("DefaultPersistPlayerStats"),
  26. m_persistUseSupportDir("DefaultUseSupportDir"),
  27. m_persistElimPlayers("DefaultElimPlayers"),
  28. m_persistElimDays("DefaultElimDays"),
  29. m_persistPause("DefaultPause"),
  30. m_persistPauseSecs("DefaultPauseSecs")
  31. {
  32. //{{AFX_DATA_INIT(CSwitchProps)
  33. //}}AFX_DATA_INIT
  34. m_psp.dwFlags &= ~PSP_HASHELP;
  35. alreadyAcknowledged=false;
  36. }
  37. void CSwitchProps::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CDialog::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CSwitchProps)
  41. DDX_Control(pDX, IDC_STATIC2, m_OnlyHereToBeDisabledToo);
  42. DDX_Control(pDX, IDC_STATICLBL, m_OnlyHereToBeDisabled);
  43. DDX_Control(pDX, IDC_PAUSE, m_Pause);
  44. DDX_Control(pDX, IDC_PAUSESECS, m_PauseSecs);
  45. DDX_Control(pDX, IDC_DEFALL, m_Defall);
  46. DDX_Control(pDX, IDC_STARTUPINFO, m_DisplayStartupInfo);
  47. DDX_Control(pDX, IDC_ELIMDAYS, m_elimDays);
  48. DDX_Control(pDX, IDC_ELIMINATEOLDPLRS, m_ElimOldPlrs);
  49. DDX_Control(pDX, IDC_USESUPPORT, m_UseSupportDir);
  50. DDX_Control(pDX, IDC_PLRPERSIST, m_PersistPlayerStats);
  51. DDX_Control(pDX, IDC_DISPLAYMM2, m_DisplayMM2);
  52. //}}AFX_DATA_MAP
  53. }
  54. BEGIN_MESSAGE_MAP(CSwitchProps, CDialog)
  55. //{{AFX_MSG_MAP(CSwitchProps)
  56. ON_BN_CLICKED(IDC_DEFALL, OnDefall)
  57. ON_BN_CLICKED(IDC_PLRPERSIST, OnPlrpersist)
  58. //}}AFX_MSG_MAP
  59. END_MESSAGE_MAP()
  60. /////////////////////////////////////////////////////////////////////////////
  61. // CSwitchProps message handlers
  62. #include "propsht.h"
  63. BOOL CSwitchProps::OnKillActive()
  64. {
  65. //call superclass
  66. BOOL bRes=this->CPropertyPage::OnKillActive();
  67. m_persistDefall=m_Defall.GetCheck();
  68. m_persistPause=theApp.pause=m_Pause.GetCheck();
  69. char buf[100];
  70. m_PauseSecs.GetWindowText(buf,100);
  71. m_persistPauseSecs=theApp.pauseSecs=atoi(buf);
  72. m_persistDisplayMM2=theApp.displayMM2=m_DisplayMM2.GetCheck()==1;
  73. m_persistPersistPlayerStats=theApp.persistPlayerStats=m_PersistPlayerStats.GetCheck()==1;
  74. m_persistUseSupportDir=theApp.useSupportDir=m_UseSupportDir.GetCheck()==1;
  75. m_persistDisplayStartupInfo=theApp.displayStartupInfo=m_DisplayStartupInfo.GetCheck()==1;
  76. m_persistElimPlayers=theApp.elimOldPlayers=m_ElimOldPlrs.GetCheck()==1;
  77. m_elimDays.GetWindowText(buf,100);
  78. m_persistElimDays=theApp.elimDays=atoi(buf);
  79. return bRes;
  80. }
  81. BOOL CSwitchProps::OnSetActive()
  82. {
  83. //call superclass
  84. BOOL bRes=this->CPropertyPage::OnSetActive();
  85. if (theApp.FirstEverTimeRun && !alreadyAcknowledged)
  86. {
  87. alreadyAcknowledged=true;
  88. m_persistDefall=1;
  89. m_Defall.SetCheck(1);
  90. OnDefall();
  91. return bRes;
  92. }
  93. bool temp;
  94. temp=m_persistDefall.toBool();
  95. m_Defall.SetCheck(temp);
  96. temp=theApp.pause=m_persistPause.toBool();
  97. m_Pause.SetCheck(temp);
  98. theApp.pauseSecs=m_persistPauseSecs.toInt();
  99. m_PauseSecs.SetWindowText(m_persistPauseSecs.toChars());
  100. temp=theApp.displayMM2=m_persistDisplayMM2.toBool();
  101. m_DisplayMM2.SetCheck(temp);
  102. temp=theApp.persistPlayerStats=m_persistPersistPlayerStats.toBool();
  103. m_PersistPlayerStats.SetCheck(temp);
  104. temp=theApp.useSupportDir=m_persistUseSupportDir.toBool();
  105. m_UseSupportDir.SetCheck(temp);
  106. temp=theApp.displayStartupInfo=m_persistDisplayStartupInfo.toBool();
  107. m_DisplayStartupInfo.SetCheck(temp);
  108. temp=theApp.elimOldPlayers=m_persistElimPlayers.toBool();
  109. m_ElimOldPlrs.SetCheck(temp);
  110. theApp.elimDays=m_persistElimDays.toInt();
  111. m_elimDays.SetWindowText(m_persistElimDays.toChars());
  112. OnDefall();
  113. OnPlrpersist();
  114. return bRes;
  115. }
  116. void CSwitchProps::OnDefall()
  117. {
  118. bool defall=m_Defall.GetCheck()!=0;
  119. if (defall)
  120. {
  121. m_DisplayMM2.SetCheck(0);
  122. m_DisplayStartupInfo.SetCheck(0);
  123. m_elimDays.SetWindowText("7");
  124. m_ElimOldPlrs.SetCheck(1);
  125. m_Pause.SetCheck(1);
  126. m_PauseSecs.SetWindowText("2");
  127. m_PersistPlayerStats.SetCheck(1);
  128. m_UseSupportDir.SetCheck(1);
  129. }
  130. m_DisplayMM2.EnableWindow(!defall);
  131. m_DisplayStartupInfo.EnableWindow(!defall);
  132. m_elimDays.EnableWindow(!defall);
  133. m_ElimOldPlrs.EnableWindow(!defall);
  134. m_Pause.EnableWindow(!defall);
  135. m_PauseSecs.EnableWindow(!defall);
  136. m_PersistPlayerStats.EnableWindow(!defall);
  137. m_UseSupportDir.EnableWindow(!defall);
  138. m_OnlyHereToBeDisabled.EnableWindow(!defall);
  139. m_OnlyHereToBeDisabledToo.EnableWindow(!defall);
  140. }
  141. void CSwitchProps::OnPlrpersist()
  142. {
  143. m_ElimOldPlrs.EnableWindow(m_PersistPlayerStats.GetCheck() && !m_Defall.GetCheck());
  144. m_elimDays.EnableWindow(m_PersistPlayerStats.GetCheck() && !m_Defall.GetCheck());
  145. m_OnlyHereToBeDisabledToo.EnableWindow(m_PersistPlayerStats.GetCheck() && !m_Defall.GetCheck());
  146. }