summaryrefslogtreecommitdiff
path: root/src/T2DLL/SoundDlg.cpp
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-06-28 22:22:32 +0100
committerAsh Wolf <ninji@wuffs.org>2023-06-28 22:22:32 +0100
commitc0c336500955a23e344651e5412c9d9d441ef4ee (patch)
tree790769c748db307cf3314f6e896e2f61c68561a2 /src/T2DLL/SoundDlg.cpp
parent37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff)
downloadt2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz
t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip
first pass of T2DLL
Diffstat (limited to '')
-rw-r--r--src/T2DLL/SoundDlg.cpp127
1 files changed, 127 insertions, 0 deletions
diff --git a/src/T2DLL/SoundDlg.cpp b/src/T2DLL/SoundDlg.cpp
new file mode 100644
index 0000000..858f906
--- /dev/null
+++ b/src/T2DLL/SoundDlg.cpp
@@ -0,0 +1,127 @@
+#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"
+
+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 const 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;
+}