Debian Codegraph @

editor/BriefMovieEdit.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 // BriefMovieEdit.cpp : implementation file
20 //
21
22 #include "stdafx.h"
23 #include "editor.h"
24 #include "BriefMovieEdit.h"
25 #include "manage.h"
26 #include "BriefMissionFlagsDlg.h"
27 #include "ddio.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 // CBriefMovieEdit dialog
37
38 CBriefMovieEdit::CBriefMovieEdit(TCMOVIEDESC *d, CWnd *pParent /*=NULL*/) : CDialog(CBriefMovieEdit::IDD, pParent) {
39 //{{AFX_DATA_INIT(CBriefMovieEdit)
40 m_sFilename = _T("");
41 m_fFPS = 0.0f;
42 m_bLooping = FALSE;
43 m_fStartTime = 0.0f;
44 m_iX = 0;
45 m_iY = 0;
46 m_sDesc = _T("");
47 //}}AFX_DATA_INIT
48
49 memset(&desc, 0, sizeof(TCMOVIEDESC));
50
51 // set defaults
52 desc.fps = 20.0f;
53 desc.mission_mask_set = 0;
54 desc.mission_mask_unset = 0;
55
56 if (d) {
57 // get given values)
58 desc.caps = d->caps;
59
60 if (d->caps & TCMD_XY) {
61 desc.x = d->x;
62 desc.y = d->y;
63 }
64 if (d->caps & TCMD_LOOPING)
65 desc.looping = d->looping;
66 if (d->caps & TCMD_WAITTIME)
67 desc.waittime = d->waittime;
68 if (d->caps & TCMD_FPS)
69 desc.fps = d->fps;
70
71 desc.mission_mask_set = d->mission_mask_set;
72 desc.mission_mask_unset = d->mission_mask_unset;
73
74 strcpy(desc.filename, d->filename);
75 }
76
77 // fill in with whats valid
78 m_sFilename = desc.filename;
79 m_fFPS = desc.fps;
80 m_bLooping = desc.looping;
81 m_fStartTime = desc.waittime;
82 m_iX = desc.x;
83 m_iY = desc.y;
84 }
85
86 void CBriefMovieEdit::DoDataExchange(CDataExchange *pDX) {
87 CDialog::DoDataExchange(pDX);
88 //{{AFX_DATA_MAP(CBriefMovieEdit)
89 DDX_Text(pDX, IDC_BRIEF_M_FILENAME, m_sFilename);
90 DDX_Text(pDX, IDC_BRIEF_M_FPS, m_fFPS);
91 DDV_MinMaxFloat(pDX, m_fFPS, 0.f, 100.f);
92 DDX_Check(pDX, IDC_BRIEF_M_LOOPING, m_bLooping);
93 DDX_Text(pDX, IDC_BRIEF_M_STARTTIME, m_fStartTime);
94 DDV_MinMaxFloat(pDX, m_fStartTime, 0.f, 99999.f);
95 DDX_Text(pDX, IDC_BRIEF_M_X, m_iX);
96 DDV_MinMaxInt(pDX, m_iX, 0, 639);
97 DDX_Text(pDX, IDC_BRIEF_M_Y, m_iY);
98 DDV_MinMaxInt(pDX, m_iY, 0, 479);
99 DDX_Text(pDX, IDC_BRIEF_M_DESC, m_sDesc);
100 //}}AFX_DATA_MAP
101 }
102
103 BEGIN_MESSAGE_MAP(CBriefMovieEdit, CDialog)
104 //{{AFX_MSG_MAP(CBriefMovieEdit)
105 ON_BN_CLICKED(IDC_BRIEF_M_CHOOSE, OnBriefMChoose)
106 ON_BN_CLICKED(IDC_MISSIONFLAGS, OnMissionflags)
107 //}}AFX_MSG_MAP
108 END_MESSAGE_MAP()
109
110 /////////////////////////////////////////////////////////////////////////////
111 // CBriefMovieEdit message handlers
112
113 void CBriefMovieEdit::OnBriefMChoose() {
114 UpdateData(true);
115 char szFilter[] = "Outrage Movie Files (*.mve)|*.mve||";
116 CFileDialog dlg(true, NULL, NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, szFilter);
117
118 if (dlg.DoModal() == IDOK) {
119 // handle
120 m_sFilename = dlg.GetFileName();
121 UpdateData(false);
122 }
123 }
124
125 void CBriefMovieEdit::OnOK() {
126 UpdateData(true);
127
128 char path[_MAX_PATH];
129 ddio_MakePath(path, LocalD3Dir, "Movies", m_sFilename.GetBuffer(1), NULL);
130
131 if (!cfexist(path)) {
132 MessageBox("Invalid Filename", "Error");
133 return;
134 }
135
136 desc.caps = TCMD_XY | TCMD_LOOPING | TCMD_WAITTIME | TCMD_FPS;
137 strcpy(desc.filename, m_sFilename.GetBuffer(0));
138 desc.fps = m_fFPS;
139 desc.looping = (bool)(m_bLooping != 0);
140 desc.waittime = m_fStartTime;
141 desc.x = m_iX;
142 desc.y = m_iY;
143
144 CDialog::OnOK();
145 }
146
147 BOOL CBriefMovieEdit::OnInitDialog() {
148 CDialog::OnInitDialog();
149
150 UpdateData(false);
151
152 return TRUE;
153 }
154
155 void CBriefMovieEdit::OnMissionflags() {
156 CBriefMissionFlagsDlg dlg(desc.mission_mask_set, desc.mission_mask_unset);
157
158 if (dlg.DoModal()) {
159 desc.mission_mask_set = dlg.m_Set;
160 desc.mission_mask_unset = dlg.m_UnSet;
161 }
162 }