#include "StdAfx.h" #include "SoundDlg.h" #include "../T2.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() { T2DlgItemText *theText; T2DlgItem *theCheck, *theICheck; theCheck = GetT2DlgItem(100); theCheck->SetValue(1); for (int i = 0; i < 4; i++) { theICheck = GetT2DlgItem(101 + i); theICheck->SetValue(1); 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->GetSoundPlayer(); 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() { T2DlgItem *theCheck, *theICheck; T2SoundPlayer *theSoundPlayer = mDocument->GetSoundPlayer(); theCheck = GetT2DlgItem(100); if (theSoundPlayer->IsSoundOn()) { theCheck->SetValue(1); } else { theCheck->SetValue(0); T2DlgItemText *theText; for (int i = 0; i < 4; i++) { theText = (T2DlgItemText *) GetT2DlgItem(111 + i); theText->SetTextColor(RGB(128, 128, 128)); } } unsigned int theMask = theSoundPlayer->GetSEMask(); for (int i = 0; i < 4; i++) { theICheck = GetT2DlgItem(101 + i); if (theMask & masks[i]) theICheck->SetValue(1); else theICheck->SetValue(0); } } /*virtual*/ BOOL SoundDlg::OnT2DialogCommand(WPARAM inWParam, LPARAM inLParam) { COLORREF col; BOOL done = true; T2DlgItem *theCheck = GetT2DlgItem(100); BOOL value = theCheck->GetValue(); WORD id = LOWORD(inWParam); if (id == 100) { if (value) col = RGB(0, 0, 0); else col = RGB(128, 128, 128); T2DlgItemText *theText; for (int i = 0; i < 4; i++) { theText = (T2DlgItemText *) GetT2DlgItem(111 + i); theText->SetTextColor(col); } Invalidate(); } else if (id >= 101 && id < 105) { if (!value) { T2DlgItem *theICheck = GetT2DlgItem(id); int oldValue = theICheck->GetValue(); if (oldValue) theICheck->SetValue(0); else theICheck->SetValue(1); } } else { done = T2Dialog::OnT2DialogCommand(inWParam, inLParam); } return done; }