DlgTipOfTheDay.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. // DlgTipOfTheDay.cpp : implementation file
  13. //
  14. #include "stdafx.h"
  15. #include "WorldEditor.h"
  16. #include "DlgTipOfTheDay.h"
  17. #include "CtlTipOfTheDayText.h"
  18. #ifdef _DEBUG
  19. #undef new
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CDlgTipOfTheDay dialog
  26. CDlgTipOfTheDay::CDlgTipOfTheDay(CWnd* pParent /*=NULL*/)
  27. : CDialog(CDlgTipOfTheDay::IDD, pParent)
  28. {
  29. //{{AFX_DATA_INIT(CDlgTipOfTheDay)
  30. m_bShowTipsAtStartup = FALSE;
  31. //}}AFX_DATA_INIT
  32. m_bShowTipsAtStartup = theApp.m_bShowTipOfTheDay;
  33. try {
  34. CTFileStream strm;
  35. strm.Open_t(CTString("Data\\SED_TipOfTheDay.txt"));
  36. while (!strm.AtEOF()) {
  37. strm.GetLine_t(m_astrTips.Push(), '$');
  38. }
  39. } catch (char *strError) {
  40. WarningMessage("Cannot show Tip of the Day:\n%s", strError);
  41. }
  42. }
  43. void CDlgTipOfTheDay::DoDataExchange(CDataExchange* pDX)
  44. {
  45. CDialog::DoDataExchange(pDX);
  46. INDEX ctTips = m_astrTips.Count();
  47. if (ctTips>0) {
  48. theApp.m_iCurrentTipOfTheDay = (theApp.m_iCurrentTipOfTheDay+ctTips)%ctTips;
  49. m_wndTipText.m_strTipText = (const char*)m_astrTips[theApp.m_iCurrentTipOfTheDay];
  50. } else {
  51. m_wndTipText.m_strTipText = "error";
  52. }
  53. //{{AFX_DATA_MAP(CDlgTipOfTheDay)
  54. DDX_Control(pDX, IDC_TIPTEXT, m_wndTipText);
  55. DDX_Check(pDX, IDC_SHOWTIPSATSTARTUP, m_bShowTipsAtStartup);
  56. //}}AFX_DATA_MAP
  57. theApp.m_bShowTipOfTheDay = m_bShowTipsAtStartup;
  58. }
  59. BEGIN_MESSAGE_MAP(CDlgTipOfTheDay, CDialog)
  60. //{{AFX_MSG_MAP(CDlgTipOfTheDay)
  61. ON_WM_CLOSE()
  62. ON_BN_CLICKED(IDC_NEXTTIP, OnNextTip)
  63. ON_BN_CLICKED(IDC_PREVTIP, OnPrevTip)
  64. //}}AFX_MSG_MAP
  65. END_MESSAGE_MAP()
  66. /////////////////////////////////////////////////////////////////////////////
  67. // CDlgTipOfTheDay message handlers
  68. void CDlgTipOfTheDay::OnCancel()
  69. {
  70. CDlgTipOfTheDay::OnOK();
  71. }
  72. void CDlgTipOfTheDay::OnClose()
  73. {
  74. CDlgTipOfTheDay::OnOK();
  75. }
  76. void CDlgTipOfTheDay::OnOK()
  77. {
  78. theApp.m_iCurrentTipOfTheDay++;
  79. CDialog::OnOK();
  80. }
  81. void CDlgTipOfTheDay::OnNextTip()
  82. {
  83. theApp.m_iCurrentTipOfTheDay++;
  84. Invalidate(FALSE);
  85. UpdateData();
  86. }
  87. void CDlgTipOfTheDay::OnPrevTip()
  88. {
  89. theApp.m_iCurrentTipOfTheDay--;
  90. Invalidate(FALSE);
  91. UpdateData();
  92. }