1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// TerrainSoundDialog.cpp : implementation file
//
#include "stdafx.h"
#include "editor.h"
#include "TerrainSoundDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTerrainSoundDialog dialog
CTerrainSoundDialog::CTerrainSoundDialog(CWnd *pParent /*=NULL*/) : CDialog(CTerrainSoundDialog::IDD, pParent) {
//{{AFX_DATA_INIT(CTerrainSoundDialog)
m_high_alt = 0;
m_low_alt = 0;
m_high_volume = 0.0f;
m_low_volume = 0.0f;
//}}AFX_DATA_INIT
for (int b = 0; b < NUM_TERRAIN_SOUND_BANDS; b++)
m_bands[b] = Terrain_sound_bands[b];
}
void CTerrainSoundDialog::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTerrainSoundDialog)
DDX_Control(pDX, IDC_TERRAIN_SOUND_COMBO, m_sound_combo);
DDX_Text(pDX, IDC_TERRAIN_SOUND_HIGH_ALT, m_high_alt);
DDV_MinMaxInt(pDX, m_high_alt, 0, 255);
DDX_Text(pDX, IDC_TERRAIN_SOUND_LOW_ALT, m_low_alt);
DDV_MinMaxInt(pDX, m_low_alt, 0, 255);
DDX_Text(pDX, IDC_TERRAIN_SOUND_HIGH_VOLUME, m_high_volume);
DDV_MinMaxFloat(pDX, m_high_volume, 0.f, 1.f);
DDX_Text(pDX, IDC_TERRAIN_SOUND_LOW_VOLUME, m_low_volume);
DDV_MinMaxFloat(pDX, m_low_volume, 0.f, 1.f);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTerrainSoundDialog, CDialog)
//{{AFX_MSG_MAP(CTerrainSoundDialog)
ON_BN_CLICKED(IDC_TERRAIN_SOUND_NEXT, OnTerrainSoundNext)
ON_BN_CLICKED(IDC_TERRAIN_SOUND_PREV, OnTerrainSoundPrev)
ON_CBN_SELCHANGE(IDC_TERRAIN_SOUND_COMBO, OnSelchangeTerrainSoundCombo)
ON_EN_KILLFOCUS(IDC_TERRAIN_SOUND_HIGH_ALT, OnKillfocusTerrainSoundHighAlt)
ON_EN_KILLFOCUS(IDC_TERRAIN_SOUND_HIGH_VOLUME, OnKillfocusTerrainSoundHighVolume)
ON_EN_KILLFOCUS(IDC_TERRAIN_SOUND_LOW_ALT, OnKillfocusTerrainSoundLowAlt)
ON_EN_KILLFOCUS(IDC_TERRAIN_SOUND_LOW_VOLUME, OnKillfocusTerrainSoundLowVolume)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTerrainSoundDialog message handlers
BOOL CTerrainSoundDialog::OnInitDialog() {
CDialog::OnInitDialog();
m_sound_combo.Init(Terrain_sound_bands[0].sound_index);
m_current = 0;
CopyToControls();
UpdateDialog();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CTerrainSoundDialog::EnableDisableAll(int flag) {
((CButton *)GetDlgItem(IDC_TERRAIN_SOUND_LOW_ALT))->EnableWindow(flag);
((CButton *)GetDlgItem(IDC_TERRAIN_SOUND_HIGH_ALT))->EnableWindow(flag);
((CButton *)GetDlgItem(IDC_TERRAIN_SOUND_LOW_VOLUME))->EnableWindow(flag);
((CButton *)GetDlgItem(IDC_TERRAIN_SOUND_HIGH_VOLUME))->EnableWindow(flag);
}
void CTerrainSoundDialog::UpdateDialog() {
// Enabled/disable edit boxes
EnableDisableAll(m_bands[m_current].sound_index != -1);
// Show which band
PrintToDlgItem(this, IDC_TERRAIN_SOUND_BAND_TEXT, "Band %d:", m_current);
// Enable/disable next & prev
((CButton *)GetDlgItem(IDC_TERRAIN_SOUND_NEXT))->EnableWindow(m_current < NUM_TERRAIN_SOUND_BANDS - 1);
((CButton *)GetDlgItem(IDC_TERRAIN_SOUND_PREV))->EnableWindow(m_current > 0);
}
void CTerrainSoundDialog::CopyToControls() {
m_low_alt = m_bands[m_current].low_alt;
m_high_alt = m_bands[m_current].high_alt;
m_low_volume = m_bands[m_current].low_volume;
m_high_volume = m_bands[m_current].high_volume;
m_sound_combo.SetSelected(m_bands[m_current].sound_index);
UpdateData(false);
}
void CTerrainSoundDialog::CopyFromControls() {
UpdateData(true);
m_bands[m_current].low_alt = m_low_alt;
m_bands[m_current].high_alt = m_high_alt;
m_bands[m_current].low_volume = m_low_volume;
m_bands[m_current].high_volume = m_high_volume;
m_bands[m_current].sound_index = m_sound_combo.GetSelected();
}
void CTerrainSoundDialog::OnTerrainSoundNext() {
ASSERT(m_current < NUM_TERRAIN_SOUND_BANDS - 1);
CopyFromControls();
if (m_low_alt > m_high_alt) {
OutrageMessageBox("High elevation must be greater than or equal to low elevation.");
return;
}
m_current++;
CopyToControls();
UpdateDialog();
}
void CTerrainSoundDialog::OnTerrainSoundPrev() {
ASSERT(m_current > 0);
CopyFromControls();
if (m_low_alt > m_high_alt) {
OutrageMessageBox("High elevation must be greater than or equal to low elevation.");
return;
}
m_current--;
CopyToControls();
UpdateDialog();
}
void CTerrainSoundDialog::OnOK() {
// Validate and make sure values ok
if (UpdateData(true)) {
// Make sure high/low alt values are ok
if (m_low_alt > m_high_alt) {
OutrageMessageBox("High elevation must be greater than or equal to low elevation.");
} else { // everything ok, so bail
CDialog::OnOK();
// Copy the new data into our original struct
for (int b = 0; b < NUM_TERRAIN_SOUND_BANDS; b++)
Terrain_sound_bands[b] = m_bands[b];
// It's possible that nothing has changed, but we'll assume something has
World_changed = 1;
}
}
}
void CTerrainSoundDialog::OnSelchangeTerrainSoundCombo() {
CopyFromControls();
UpdateDialog();
}
void CTerrainSoundDialog::OnKillfocusTerrainSoundHighAlt() {
// Force validation
UpdateData(true);
}
void CTerrainSoundDialog::OnKillfocusTerrainSoundHighVolume() {
// Force validation
UpdateData(true);
}
void CTerrainSoundDialog::OnKillfocusTerrainSoundLowAlt() {
// Force validation
UpdateData(true);
}
void CTerrainSoundDialog::OnKillfocusTerrainSoundLowVolume() {
// Force validation
UpdateData(true);
}
|