Skip to content

Commit 828adb8

Browse files
committed
convert debriefing editor to modeless; add focus_sexp(); fix bugs
Convert debriefing_editor_dlg from a modal stack-allocated dialog to a modeless heap-allocated dialog, matching the pattern of the briefing editor. Update FRED infrastructure accordingly. Add focus_sexp(int node) to debriefing_editor_dlg, mirroring the existing method in briefing_editor_dlg. Fix both focus_sexp() implementations to search all team debriefings/briefings instead of only the currently selected team, so nodes in non-zero teams are found correctly in TVT missions. Fix debriefing set_modified() calls to only set the flag if the debriefing data actually changes, rather than every time the editor was opened.
1 parent ba1f11f commit 828adb8

7 files changed

Lines changed: 40 additions & 14 deletions

File tree

fred2/briefingeditordlg.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,12 @@ void briefing_editor_dlg::OnClose()
305305
if (dup)
306306
MessageBox("You have duplicate icon names. You should resolve these.", "Warning");
307307

308+
FREDDoc_ptr->autosave("briefing editor");
309+
308310
theApp.record_window_data(&Briefing_wnd_data, this);
309311
ptr = Briefing_dialog; // this juggling prevents a crash in certain situations
310-
Briefing_dialog = NULL;
312+
Briefing_dialog = nullptr;
311313
delete ptr;
312-
313-
FREDDoc_ptr->autosave("briefing editor");
314314
}
315315

316316
void briefing_editor_dlg::reset_editor()

fred2/debriefingeditordlg.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ debriefing_editor_dlg::debriefing_editor_dlg(CWnd* pParent /*=NULL*/)
5353
select_sexp_node = -1;
5454
}
5555

56+
void debriefing_editor_dlg::create()
57+
{
58+
CDialog::Create(IDD);
59+
theApp.init_window(&Debriefing_wnd_data, this);
60+
}
61+
5662
void debriefing_editor_dlg::DoDataExchange(CDataExchange* pDX)
5763
{
5864
CDialog::DoDataExchange(pDX);
@@ -425,7 +431,7 @@ void debriefing_editor_dlg::OnEndlabeleditTree(NMHDR* pNMHDR, LRESULT* pResult)
425431
*pResult = m_tree.end_label_edit(pTVDispInfo->item);
426432
}
427433

428-
void debriefing_editor_dlg::OnClose()
434+
void debriefing_editor_dlg::OnClose()
429435
{
430436
audiostream_close_file(m_voice_id, 0);
431437
m_voice_id = -1;
@@ -436,9 +442,12 @@ void debriefing_editor_dlg::OnClose()
436442
Mission_music[SCORE_DEBRIEFING_AVERAGE] = m_debriefAvg_music - 1;
437443
Mission_music[SCORE_DEBRIEFING_FAILURE] = m_debriefFail_music - 1;
438444

439-
CDialog::OnClose();
440-
441445
FREDDoc_ptr->autosave("debriefing editor");
446+
447+
theApp.record_window_data(&Debriefing_wnd_data, this);
448+
debriefing_editor_dlg *ptr = Debriefing_dialog;
449+
Debriefing_dialog = nullptr;
450+
delete ptr;
442451
}
443452

444453
void debriefing_editor_dlg::OnOK()

fred2/debriefingeditordlg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
*/
99

10+
#pragma once
1011

1112
#include "mission/missionbriefcommon.h"
1213

@@ -18,6 +19,7 @@ class debriefing_editor_dlg : public CDialog
1819
// Construction
1920
public:
2021
void OnOK();
22+
void create();
2123
void update_data(int update = 1);
2224
debriefing_editor_dlg(CWnd* pParent = NULL); // standard constructor
2325
int select_sexp_node;

fred2/fred.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ wing_editor Wing_editor_dialog;
121121
waypoint_path_dlg Waypoint_editor_dialog;
122122
jumpnode_dlg Jumpnode_editor_dialog;
123123
music_player_dlg Music_player_dialog;
124-
bg_bitmap_dlg* Bg_bitmap_dialog = NULL;
125-
briefing_editor_dlg* Briefing_dialog = NULL;
124+
bg_bitmap_dlg* Bg_bitmap_dialog = nullptr;
125+
briefing_editor_dlg* Briefing_dialog = nullptr;
126+
debriefing_editor_dlg* Debriefing_dialog = nullptr;
126127

127128
window_data Main_wnd_data;
128129
window_data Ship_wnd_data;
@@ -136,6 +137,7 @@ window_data Player_wnd_data;
136137
window_data Events_wnd_data;
137138
window_data Bg_wnd_data;
138139
window_data Briefing_wnd_data;
140+
window_data Debriefing_wnd_data;
139141
window_data Reinforcement_wnd_data;
140142
window_data Waypoint_wnd_data;
141143
window_data Jumpnode_wnd_data;

fred2/fred.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "BgBitmapDlg.h"
1919
#include "BriefingEditorDlg.h"
20+
#include "DebriefingEditorDlg.h"
2021
#include "resource.h"
2122
#include "ShipEditorDlg.h"
2223
#include "propdlg.h"
@@ -187,7 +188,8 @@ extern waypoint_path_dlg Waypoint_editor_dialog; //!< The waypoint editor ins
187188
extern jumpnode_dlg Jumpnode_editor_dialog; //!< The jumpnode editor instance
188189
extern music_player_dlg Music_player_dialog; //!< The music player instance
189190
extern bg_bitmap_dlg* Bg_bitmap_dialog; //!< The bitmap dialog instance
190-
extern briefing_editor_dlg* Briefing_dialog; //!< The briefing editor instance
191+
extern briefing_editor_dlg* Briefing_dialog; //!< The briefing editor instance
192+
extern debriefing_editor_dlg* Debriefing_dialog; //!< The debriefing editor instance
191193

192194
extern CFREDApp theApp; //!< The application instance
193195

@@ -203,6 +205,7 @@ extern window_data Player_wnd_data;
203205
extern window_data Events_wnd_data;
204206
extern window_data Bg_wnd_data;
205207
extern window_data Briefing_wnd_data;
208+
extern window_data Debriefing_wnd_data;
206209
extern window_data Reinforcement_wnd_data;
207210
extern window_data Waypoint_wnd_data;
208211
extern window_data Jumpnode_wnd_data;

fred2/fredview.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4213,9 +4213,14 @@ void CFREDView::OnEditorsBriefing()
42134213

42144214
void CFREDView::OnEditorsDebriefing()
42154215
{
4216-
debriefing_editor_dlg dlg;
4216+
if (!Debriefing_dialog) {
4217+
Debriefing_dialog = new debriefing_editor_dlg;
4218+
Debriefing_dialog->create();
4219+
}
42174220

4218-
dlg.DoModal();
4221+
Debriefing_dialog->SetWindowPos(&wndTop, 0, 0, 0, 0,
4222+
SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
4223+
Debriefing_dialog->ShowWindow(SW_RESTORE);
42194224
}
42204225

42214226
void CFREDView::OnSaveCamera()

fred2/management.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,10 +2283,15 @@ int sexp_reference_handler(int node, sexp_src source, int source_index, char *ms
22832283
}
22842284

22852285
case sexp_src::DEBRIEFING: {
2286-
debriefing_editor_dlg dlg;
2286+
if (!Debriefing_dialog) {
2287+
Debriefing_dialog = new debriefing_editor_dlg;
2288+
Debriefing_dialog->create();
2289+
}
22872290

2288-
dlg.select_sexp_node = node;
2289-
dlg.DoModal();
2291+
Debriefing_dialog->SetWindowPos(&CWnd::wndTop, 0, 0, 0, 0,
2292+
SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
2293+
Debriefing_dialog->ShowWindow(SW_RESTORE);
2294+
Debriefing_dialog->focus_sexp(node);
22902295
break;
22912296
}
22922297

0 commit comments

Comments
 (0)