| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | // SoundSourceDialog.cpp : implementation file |
| 20 | // |
| 21 | |
| 22 | #include "stdafx.h" |
| 23 | #include "editor.h" |
| 24 | #include "SoundSourceDialog.h" |
| 25 | |
| 26 | #ifdef _DEBUG |
| 27 | #define new DEBUG_NEW |
| 28 | #undef THIS_FILE |
| 29 | static char THIS_FILE[] = __FILE__; |
| 30 | #endif |
| 31 | |
| 32 | ///////////////////////////////////////////////////////////////////////////// |
| 33 | // CSoundSourceDialog dialog |
| 34 | |
| 35 | CSoundSourceDialog::CSoundSourceDialog(soundsource_info_s *data, CWnd *pParent /*=NULL*/) |
| 36 | : CDialog(CSoundSourceDialog::IDD, pParent) { |
| 37 | //{{AFX_DATA_INIT(CSoundSourceDialog) |
| 38 | m_volume = 0.0f; |
| 39 | //}}AFX_DATA_INIT |
| 40 | |
| 41 | m_data_ptr = data; |
| 42 | m_volume = data->volume; |
| 43 | } |
| 44 | |
| 45 | void CSoundSourceDialog::DoDataExchange(CDataExchange *pDX) { |
| 46 | CDialog::DoDataExchange(pDX); |
| 47 | //{{AFX_DATA_MAP(CSoundSourceDialog) |
| 48 | DDX_Control(pDX, IDC_SOUND_COMBO, m_sound_combo); |
| 49 | DDX_Text(pDX, IDC_VOLUME, m_volume); |
| 50 | DDV_MinMaxFloat(pDX, m_volume, 0.f, 1.f); |
| 51 | //}}AFX_DATA_MAP |
| 52 | } |
| 53 | |
| 54 | BEGIN_MESSAGE_MAP(CSoundSourceDialog, CDialog) |
| 55 | //{{AFX_MSG_MAP(CSoundSourceDialog) |
| 56 | ON_BN_CLICKED(IDC_SELECT, OnSelect) |
| 57 | //}}AFX_MSG_MAP |
| 58 | END_MESSAGE_MAP() |
| 59 | |
| 60 | ///////////////////////////////////////////////////////////////////////////// |
| 61 | // CSoundSourceDialog message handlers |
| 62 | |
| 63 | BOOL CSoundSourceDialog::OnInitDialog() { |
| 64 | CDialog::OnInitDialog(); |
| 65 | |
| 66 | m_sound_combo.Init(m_data_ptr->sound_index); |
| 67 | |
| 68 | return TRUE; // return TRUE unless you set the focus to a control |
| 69 | // EXCEPTION: OCX Property Pages should return FALSE |
| 70 | } |
| 71 | |
| 72 | void CSoundSourceDialog::OnOK() { |
| 73 | if (UpdateData(true)) { |
| 74 | m_data_ptr->volume = m_volume; |
| 75 | m_data_ptr->sound_index = m_sound_combo.GetSelected(); |
| 76 | |
| 77 | CDialog::OnOK(); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | #include "soundload.h" |
| 82 | #include "DallasSoundDlg.h" |
| 83 | |
| 84 | void CSoundSourceDialog::OnSelect() { |
| 85 | CDallasSoundDlg dlg; |
| 86 | |
| 87 | int selected = m_sound_combo.GetSelected(); |
| 88 | if (selected != -1) |
| 89 | dlg.m_SoundName = Sounds[selected].name; |
| 90 | |
| 91 | if (dlg.DoModal() == IDCANCEL) |
| 92 | return; |
| 93 | |
| 94 | m_sound_combo.SetSelected(dlg.m_SoundIndex); |
| 95 | } |