Debian Codegraph @

editor/DallasStrmAudioDlg.cpp

raw symbols SCIP
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 // DallasStrmAudioDlg.cpp : implementation file
20 //
21
22 #include "stdafx.h"
23 #include "editor.h"
24 #include "DallasUtilities.h"
25 #include "manage.h"
26 #include "streamaudio.h"
27 #include "DallasStrmAudioDlg.h"
28
29 #ifdef _DEBUG
30 #define new DEBUG_NEW
31 #undef THIS_FILE
32 static char THIS_FILE[] = __FILE__;
33 #endif
34
35 /////////////////////////////////////////////////////////////////////////////
36 // CDallasStrmAudioDlg dialog
37
38 CDallasStrmAudioDlg::CDallasStrmAudioDlg(CWnd *pParent /*=NULL*/) : CDialog(CDallasStrmAudioDlg::IDD, pParent) {
39 //{{AFX_DATA_INIT(CDallasStrmAudioDlg)
40 // NOTE: the ClassWizard will add member initialization here
41 //}}AFX_DATA_INIT
42 m_Filename = "";
43 }
44
45 void CDallasStrmAudioDlg::DoDataExchange(CDataExchange *pDX) {
46 CDialog::DoDataExchange(pDX);
47 //{{AFX_DATA_MAP(CDallasStrmAudioDlg)
48 DDX_Control(pDX, IDC_STRM_AUDIO_LIST, m_StrmAudioBox);
49 //}}AFX_DATA_MAP
50 }
51
52 BEGIN_MESSAGE_MAP(CDallasStrmAudioDlg, CDialog)
53 //{{AFX_MSG_MAP(CDallasStrmAudioDlg)
54 ON_LBN_DBLCLK(IDC_STRM_AUDIO_LIST, OnDblclkStrmAudioList)
55 ON_BN_CLICKED(IDC_PLAY_STRM_AUDIO_BUTTON, OnPlayStrmAudioButton)
56 //}}AFX_MSG_MAP
57 END_MESSAGE_MAP()
58
59 /////////////////////////////////////////////////////////////////////////////
60 // CDallasStrmAudioDlg message handlers
61
62 void CDallasStrmAudioDlg::OnOK() {
63 // TODO: Add extra validation here
64 int index = m_StrmAudioBox.GetCurSel();
65 if (index == LB_ERR)
66 return;
67
68 m_StrmAudioBox.GetText(index, m_Filename);
69
70 CDialog::OnOK();
71 }
72
73 void CDallasStrmAudioDlg::OnCancel() {
74 // TODO: Add extra cleanup here
75
76 CDialog::OnCancel();
77 }
78
79 BOOL CDallasStrmAudioDlg::OnInitDialog() {
80 CDialog::OnInitDialog();
81
82 FillStrmAudioList();
83
84 if (!m_Filename.IsEmpty())
85 m_StrmAudioBox.SelectString(-1, m_Filename.GetBuffer(0));
86
87 return TRUE; // return TRUE unless you set the focus to a control
88 // EXCEPTION: OCX Property Pages should return FALSE
89 }
90
91 void CDallasStrmAudioDlg::OnDblclkStrmAudioList() {
92 CString filename;
93
94 int index = m_StrmAudioBox.GetCurSel();
95 if (index == LB_ERR)
96 return;
97
98 m_StrmAudioBox.GetText(index, filename);
99 StreamPlay(filename.GetBuffer(0), 1, 0);
100 }
101
102 void CDallasStrmAudioDlg::OnPlayStrmAudioButton() { OnDblclkStrmAudioList(); }
103
104 void CDallasStrmAudioDlg::FillStrmAudioList(void) {
105 bool file_found;
106 char filename[PAGENAME_LEN + 1];
107
108 file_found = FindManageFirst(filename, "*.osf");
109 while (file_found) {
110 m_StrmAudioBox.AddString(filename);
111 file_found = FindManageNext(filename);
112 }
113 FindManageClose();
114 }