11#include " ShipCustomWarpDialogModel.h"
22
33#include " ship/shipfx.h"
4+
45namespace fso ::fred::dialogs {
6+
57ShipCustomWarpDialogModel::ShipCustomWarpDialogModel (QObject* parent, EditorViewport* viewport, bool departure)
6- : AbstractDialogModel(parent, viewport), _m_departure (departure), _target(Target::Selection)
8+ : AbstractDialogModel(parent, viewport), _departure (departure), _target(Target::Selection)
79{
810 initializeData ();
911}
@@ -13,61 +15,61 @@ ShipCustomWarpDialogModel::ShipCustomWarpDialogModel(QObject* parent,
1315 bool departure,
1416 Target target,
1517 int wingIndex)
16- : AbstractDialogModel(parent, viewport), _m_departure (departure), _target(target), _wingIndex(wingIndex)
18+ : AbstractDialogModel(parent, viewport), _departure (departure), _target(target), _wingIndex(wingIndex)
1719{
1820 initializeData ();
1921}
2022
2123bool ShipCustomWarpDialogModel::apply ()
2224{
2325 WarpParams params;
24- params.direction = _m_departure ? WarpDirection::WARP_OUT : WarpDirection::WARP_IN ;
26+ params.direction = _departure ? WarpDirection::WARP_OUT : WarpDirection::WARP_IN ;
2527
26- if (_m_warp_type < Num_warp_types) {
27- params.warp_type = _m_warp_type ;
28+ if (_warpType < Num_warp_types) {
29+ params.warp_type = _warpType ;
2830 } else {
29- params.warp_type = (_m_warp_type - Num_warp_types) | WT_DEFAULT_WITH_FIREBALL ;
31+ params.warp_type = (_warpType - Num_warp_types) | WT_DEFAULT_WITH_FIREBALL ;
3032 }
3133
32- if (!_m_start_sound .empty ()) {
33- gamesnd_id id = gamesnd_get_by_name (_m_start_sound .c_str ());
34+ if (!_startSound .empty ()) {
35+ gamesnd_id id = gamesnd_get_by_name (_startSound .c_str ());
3436 if (id.value () == -1 ) {
35- Warning (LOCATION , " Game Sound \" %s\" does not exist. Skipping" , _m_start_sound .c_str ());
37+ Warning (LOCATION , " Game Sound \" %s\" does not exist. Skipping" , _startSound .c_str ());
3638 } else {
3739 params.snd_start = id;
3840 }
3941 }
4042
41- if (!_m_end_sound .empty ()) {
42- gamesnd_id id = gamesnd_get_by_name (_m_end_sound .c_str ());
43+ if (!_endSound .empty ()) {
44+ gamesnd_id id = gamesnd_get_by_name (_endSound .c_str ());
4345 if (id.value () == -1 ) {
44- Warning (LOCATION , " Game Sound \" %s\" does not exist. Skipping" , _m_end_sound .c_str ());
46+ Warning (LOCATION , " Game Sound \" %s\" does not exist. Skipping" , _endSound .c_str ());
4547 } else {
4648 params.snd_end = id;
4749 }
4850 }
4951
50- if (_m_departure && _m_warpout_engage_time ) {
51- params.warpout_engage_time = fl2i (_m_warpout_engage_time * 1000 .0f );
52+ if (_departure && _warpoutEngageTime ) {
53+ params.warpout_engage_time = fl2i (_warpoutEngageTime * 1000 .0f );
5254 }
53- if (_m_speed ) {
54- params.speed = _m_speed ;
55+ if (_speed ) {
56+ params.speed = _speed ;
5557 }
56- if (_m_time ) {
57- params.time = fl2i (_m_time * 1000 .0f );
58+ if (_time ) {
59+ params.time = fl2i (_time * 1000 .0f );
5860 }
59- if (_m_accel_exp ) {
60- params.accel_exp = _m_accel_exp ;
61+ if (_accelExp ) {
62+ params.accel_exp = _accelExp ;
6163 }
62- if (_m_radius ) {
63- params.radius = _m_radius ;
64+ if (_radius ) {
65+ params.radius = _radius ;
6466 }
65- if (!_m_anim .empty ()) {
66- strcpy_s (params.anim , _m_anim .c_str ());
67+ if (!_anim .empty ()) {
68+ strcpy_s (params.anim , _anim .c_str ());
6769 }
68- params.supercap_warp_physics = _m_supercap_warp_physics ;
69- if (_m_departure && _m_player_warpout_speed ) {
70- params.warpout_player_speed = _m_player_warpout_speed ;
70+ params.supercap_warp_physics = _supercapWarpPhysics ;
71+ if (_departure && _playerWarpoutSpeed ) {
72+ params.warpout_player_speed = _playerWarpoutSpeed ;
7173 }
7274 int index = find_or_add_warp_params (params);
7375
@@ -77,7 +79,7 @@ bool ShipCustomWarpDialogModel::apply()
7779 auto & sh = Ships[objp->instance ];
7880 if (sh.wingnum != _wingIndex)
7981 continue ;
80- if (!_m_departure )
82+ if (!_departure )
8183 sh.warpin_params_index = index;
8284 else
8385 sh.warpout_params_index = index;
@@ -88,7 +90,7 @@ bool ShipCustomWarpDialogModel::apply()
8890 if ((objp->type == OBJ_SHIP ) || (objp->type == OBJ_START )) {
8991 if (objp->flags [Object::Object_Flags::Marked]) {
9092 auto & sh = Ships[objp->instance ];
91- if (!_m_departure )
93+ if (!_departure )
9294 sh.warpin_params_index = index;
9395 else
9496 sh.warpout_params_index = index;
@@ -104,85 +106,85 @@ void ShipCustomWarpDialogModel::reject() {}
104106
105107int ShipCustomWarpDialogModel::getType () const
106108{
107- return _m_warp_type ;
109+ return _warpType ;
108110}
109111
110112SCP_string ShipCustomWarpDialogModel::getStartSound () const
111113{
112- return _m_start_sound ;
114+ return _startSound ;
113115}
114116
115117SCP_string ShipCustomWarpDialogModel::getEndSound () const
116118{
117- return _m_end_sound ;
119+ return _endSound ;
118120}
119121
120122float ShipCustomWarpDialogModel::getEngageTime () const
121123{
122- return _m_warpout_engage_time ;
124+ return _warpoutEngageTime ;
123125}
124126
125127float ShipCustomWarpDialogModel::getSpeed () const
126128{
127- return _m_speed ;
129+ return _speed ;
128130}
129131
130132float ShipCustomWarpDialogModel::getTime () const
131133{
132- return _m_time ;
134+ return _time ;
133135}
134136
135137float ShipCustomWarpDialogModel::getExponent () const
136138{
137- return _m_accel_exp ;
139+ return _accelExp ;
138140}
139141
140142float ShipCustomWarpDialogModel::getRadius () const
141143{
142- return _m_radius ;
144+ return _radius ;
143145}
144146
145147SCP_string ShipCustomWarpDialogModel::getAnim () const
146148{
147- return _m_anim ;
149+ return _anim ;
148150}
149151
150152bool ShipCustomWarpDialogModel::getSupercap () const
151153{
152- return _m_supercap_warp_physics ;
154+ return _supercapWarpPhysics ;
153155}
154156
155157float ShipCustomWarpDialogModel::getPlayerSpeed () const
156158{
157- return _m_player_warpout_speed ;
159+ return _playerWarpoutSpeed ;
158160}
159161
160162bool ShipCustomWarpDialogModel::departMode () const
161163{
162- return _m_departure ;
164+ return _departure ;
163165}
164166
165167bool ShipCustomWarpDialogModel::isPlayer () const
166168{
167- return _m_player ;
169+ return _player ;
168170}
169171
170172void ShipCustomWarpDialogModel::initializeData ()
171173{
172174 // find the params of the first marked ship
173175 WarpParams* params = nullptr ;
174176 if (_target == Target::Wing && _wingIndex >= 0 ) {
175- // Use first ship in the wing for initial values; mark _m_player if the wing contains the player
177+ // Use first ship in the wing for initial values; mark _player if the wing contains the player
176178 for (object* objp : list_range (&obj_used_list)) {
177179 if ((objp->type == OBJ_SHIP ) || (objp->type == OBJ_START )) {
178180 const auto & sh = Ships[objp->instance ];
179181 if (sh.wingnum == _wingIndex) {
180- if (!_m_departure )
182+ if (!_departure )
181183 params = &Warp_params[sh.warpin_params_index ];
182184 else
183185 params = &Warp_params[sh.warpout_params_index ];
184186 if (objp->type == OBJ_START )
185- _m_player = true ;
187+ _player = true ;
186188 break ;
187189 }
188190 }
@@ -192,12 +194,12 @@ void ShipCustomWarpDialogModel::initializeData()
192194 if ((objp->type == OBJ_SHIP ) || (objp->type == OBJ_START )) {
193195 if (objp->flags [Object::Object_Flags::Marked]) {
194196 const auto & sh = Ships[objp->instance ];
195- if (!_m_departure )
197+ if (!_departure )
196198 params = &Warp_params[sh.warpin_params_index ];
197199 else
198200 params = &Warp_params[sh.warpout_params_index ];
199201 if (objp->type == OBJ_START )
200- _m_player = true ;
202+ _player = true ;
201203 break ;
202204 }
203205 }
@@ -206,107 +208,118 @@ void ShipCustomWarpDialogModel::initializeData()
206208
207209 if (params != nullptr ) {
208210 if (params->warp_type & WT_DEFAULT_WITH_FIREBALL ) {
209- _m_warp_type = (params->warp_type & WT_FLAG_MASK ) + Num_warp_types;
211+ _warpType = (params->warp_type & WT_FLAG_MASK ) + Num_warp_types;
210212 } else if (params->warp_type >= 0 && params->warp_type < Num_warp_types) {
211- _m_warp_type = params->warp_type ;
213+ _warpType = params->warp_type ;
212214 }
213215
214216 if (params->snd_start .isValid ()) {
215- _m_start_sound = gamesnd_get_game_sound (params->snd_start )->name ;
217+ _startSound = gamesnd_get_game_sound (params->snd_start )->name ;
216218 }
217219 if (params->snd_end .isValid ()) {
218- _m_end_sound = gamesnd_get_game_sound (params->snd_end )->name ;
220+ _endSound = gamesnd_get_game_sound (params->snd_end )->name ;
219221 }
220222
221223 if (params->warpout_engage_time > 0 ) {
222- _m_warpout_engage_time = i2fl (params->warpout_engage_time ) / 1000 .0f ;
224+ _warpoutEngageTime = i2fl (params->warpout_engage_time ) / 1000 .0f ;
223225 }
224226
225227 if (params->speed > 0 .0f ) {
226- _m_speed = params->speed ;
228+ _speed = params->speed ;
227229 }
228230
229231 if (params->time > 0 .0f ) {
230- _m_time = i2fl (params->time ) / 1000 .0f ;
232+ _time = i2fl (params->time ) / 1000 .0f ;
231233 }
232234 if (params->accel_exp > 0 .0f ) {
233- _m_accel_exp = params->accel_exp ;
235+ _accelExp = params->accel_exp ;
234236 }
235237
236238 if (params->radius > 0 .0f ) {
237- _m_radius = params->radius ;
239+ _radius = params->radius ;
238240 }
239241
240242 if (strlen (params->anim ) > 0 ) {
241- _m_anim = params->anim ;
243+ _anim = params->anim ;
242244 }
243245
244- _m_supercap_warp_physics = params->supercap_warp_physics ;
246+ _supercapWarpPhysics = params->supercap_warp_physics ;
245247
246248 if (params->warpout_player_speed > 0 .0f ) {
247- _m_player_warpout_speed = params->warpout_player_speed ;
249+ _playerWarpoutSpeed = params->warpout_player_speed ;
248250 }
249251 }
250252 _modified = false ;
251253}
252254
253- void ShipCustomWarpDialogModel::setType (const int index)
255+ void ShipCustomWarpDialogModel::setType (int index)
254256{
255- modify (_m_warp_type , index);
257+ modify (_warpType , index);
256258}
257- void ShipCustomWarpDialogModel::setStartSound (const SCP_string& newSound)
259+
260+ void ShipCustomWarpDialogModel::setStartSound (const SCP_string& sound)
258261{
259- if (!newSound .empty ()) {
260- modify (_m_start_sound, newSound );
262+ if (!sound .empty ()) {
263+ modify (_startSound, sound );
261264 } else {
262- _m_start_sound = " " ;
265+ _startSound = " " ;
263266 set_modified ();
264267 }
265268}
266- void ShipCustomWarpDialogModel::setEndSound (const SCP_string& newSound)
269+
270+ void ShipCustomWarpDialogModel::setEndSound (const SCP_string& sound)
267271{
268- if (!newSound .empty ()) {
269- modify (_m_end_sound, newSound );
272+ if (!sound .empty ()) {
273+ modify (_endSound, sound );
270274 } else {
271- _m_end_sound = " " ;
275+ _endSound = " " ;
272276 set_modified ();
273277 }
274278}
275- void ShipCustomWarpDialogModel::setEngageTime (const double newValue)
279+
280+ void ShipCustomWarpDialogModel::setEngageTime (double engageTime)
276281{
277- modify (_m_warpout_engage_time , static_cast <float >(newValue ));
282+ modify (_warpoutEngageTime , static_cast <float >(engageTime ));
278283}
279- void ShipCustomWarpDialogModel::setSpeed (const double newValue)
284+
285+ void ShipCustomWarpDialogModel::setSpeed (double speed)
280286{
281- modify (_m_speed , static_cast <float >(newValue ));
287+ modify (_speed , static_cast <float >(speed ));
282288}
283- void ShipCustomWarpDialogModel::setTime (const double newValue)
289+
290+ void ShipCustomWarpDialogModel::setTime (double time)
284291{
285- modify (_m_time , static_cast <float >(newValue ));
292+ modify (_time , static_cast <float >(time ));
286293}
287- void ShipCustomWarpDialogModel::setExponent (const double newValue)
294+
295+ void ShipCustomWarpDialogModel::setExponent (double exponent)
288296{
289- modify (_m_accel_exp , static_cast <float >(newValue ));
297+ modify (_accelExp , static_cast <float >(exponent ));
290298}
291- void ShipCustomWarpDialogModel::setRadius (const double newValue)
299+
300+ void ShipCustomWarpDialogModel::setRadius (double radius)
292301{
293- modify (_m_radius , static_cast <float >(newValue ));
302+ modify (_radius , static_cast <float >(radius ));
294303}
295- void ShipCustomWarpDialogModel::setAnim (const SCP_string& newAnim)
304+
305+ void ShipCustomWarpDialogModel::setAnim (const SCP_string& anim)
296306{
297- if (!newAnim .empty ()) {
298- modify (_m_anim, newAnim );
307+ if (!anim .empty ()) {
308+ modify (_anim, anim );
299309 } else {
300- _m_anim = " " ;
310+ _anim = " " ;
301311 set_modified ();
302312 }
303313}
304- void ShipCustomWarpDialogModel::setSupercap (const bool checked)
314+
315+ void ShipCustomWarpDialogModel::setSupercap (bool supercap)
305316{
306- modify (_m_supercap_warp_physics, checked );
317+ modify (_supercapWarpPhysics, supercap );
307318}
308- void ShipCustomWarpDialogModel::setPlayerSpeed (const double newValue)
319+
320+ void ShipCustomWarpDialogModel::setPlayerSpeed (double playerSpeed)
309321{
310- modify (_m_player_warpout_speed , static_cast <float >(newValue ));
322+ modify (_playerWarpoutSpeed , static_cast <float >(playerSpeed ));
311323}
312- } // namespace dialogs
324+
325+ } // namespace fso::fred::dialogs
0 commit comments