#include "SoundDlg.h" #include "CT2App.h" #include "T2DlgItem.h" #include "T2DlgItemText.h" #include "T2MainWindow.h" #include "T2MWControl.h" #include "T2SoundPlayer.h" #include "T2TowerDoc.h" #include "T2WorldDef.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif SoundDlg::SoundDlg() { mDeleteOnClose = true; } /*virtual*/ SoundDlg::~SoundDlg() { } void SoundDlg::Setup(T2TowerDoc *inDoc, HINSTANCE inInstance, CWnd *inParentWnd, const POINT &inPt, T2ImageObj *inImageObj) { mDocument = inDoc; T2DLGTEMPLATE tmpl; tmpl.resID = 7020; tmpl.pt = inPt; tmpl.moduleHandle = inInstance; Realize(inParentWnd, &tmpl, inDoc, inImageObj, inDoc->mWorldDef->GetPalette(), false, inParentWnd, 201, true); ShowWindow(SW_HIDE); } void SoundDlg::Revert() { T2DlgItem *theCheck = GetT2DlgItem(100); theCheck->SetValue(1); for (int i = 0; i < 4; i++) { T2DlgItem *theICheck = GetT2DlgItem(101 + i); theICheck->SetValue(1); T2DlgItemText *theText = (T2DlgItemText *) GetT2DlgItem(111 + i); theText->SetTextColor(RGB(0, 0, 0)); } Invalidate(); } // T2DLL.dll 100DBC20 static unsigned int masks[4] = { 9, 2, 0x30, 4 }; void SoundDlg::Save() { T2SoundPlayer *theSoundPlayer = mDocument->towerDoc_vf134(); T2DlgItem *theCheck = GetT2DlgItem(100); if (theCheck->GetValue()) theSoundPlayer->SetSoundOn(true); else theSoundPlayer->SetSoundOn(false); unsigned int theMask = theSoundPlayer->GetSEMask(); for (int i = 0; i < 4; i++) { T2DlgItem *theICheck = GetT2DlgItem(101 + i); if (theICheck->GetValue()) theMask |= masks[i]; else theMask &= ~masks[i]; } theSoundPlayer->SetSEMask(theMask); } /*virtual*/ void SoundDlg::OnT2Create() { T2SoundPlayer *theSoundPlayer = mDocument->towerDoc_vf134(); T2DlgItem *theCheck = GetT2DlgItem(100); if (theSoundPlayer->IsSoundOn()) { theCheck->SetValue(1); } else { theCheck->SetValue(0); for (int i = 0; i < 4; i++) { T2DlgItemText *theText = (T2DlgItemText *) GetT2DlgItem(111 + i); theText->SetTextColor(RGB(128, 128, 128)); } } unsigned int theMask = theSoundPlayer->GetSEMask(); for (int i = 0; i < 4; i++) { T2DlgItem *theICheck = GetT2DlgItem(101 + i); if (theMask & masks[i]) theICheck->SetValue(1); else theICheck->SetValue(0); } } /*virtual*/ int SoundDlg::OnT2DialogCommand(UINT cmd, long data) { int result = 1; T2DlgItem *theCheck = GetT2DlgItem(100); BOOL isSoundOn = theCheck->GetValue(); WORD w = LOWORD(cmd); if (w == 100) { COLORREF col; if (isSoundOn) col = RGB(0, 0, 0); else col = RGB(128, 128, 128); for (int i = 0; i < 4; i++) { T2DlgItemText *theText = (T2DlgItemText *) GetT2DlgItem(111 + i); theText->SetTextColor(col); } Invalidate(); } else if (w >= 101 && w < 105) { if (!isSoundOn) { T2DlgItem *theICheck = GetT2DlgItem(w); int oldValue = theICheck->GetValue(); if (oldValue) theICheck->SetValue(0); else theICheck->SetValue(1); } } else { result = T2Dialog::OnT2DialogCommand(cmd, data); } return result; }