Skip to content

Commit ae5d458

Browse files
authored
fix a bunch of FRED dialog problems (#4102)
1) Fixes the ship and wing dialog resizing for both sexp help and arrival/departure cues 2) Restores the sexp help in the Mission Goals dialog, which had been broken since the mini-help-box was added
1 parent 1440200 commit ae5d458

File tree

10 files changed

+97
-88
lines changed

10 files changed

+97
-88
lines changed

fred2/eventeditor.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void maybe_add_head(CComboBox *box, char* name)
181181

182182
BOOL event_editor::OnInitDialog()
183183
{
184-
int i, adjust = 0;
184+
int i;
185185
BOOL r = TRUE;
186186
CListBox *list;
187187
CComboBox *box;
@@ -191,10 +191,7 @@ BOOL event_editor::OnInitDialog()
191191
m_play_bm.LoadBitmap(IDB_PLAY);
192192
((CButton *) GetDlgItem(IDC_PLAY)) -> SetBitmap(m_play_bm);
193193

194-
if (!Show_sexp_help)
195-
adjust = -SEXP_HELP_BOX_SIZE;
196-
197-
theApp.init_window(&Events_wnd_data, this, adjust);
194+
theApp.init_window(&Events_wnd_data, this, 0);
198195
m_event_tree.setup((CEdit *) GetDlgItem(IDC_HELP_BOX));
199196
load_tree();
200197
create_tree();

fred2/fred.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,22 +372,31 @@ void CFREDApp::OnAppAbout() {
372372
}
373373

374374
BOOL CFREDApp::OnIdle(LONG lCount) {
375-
int adjust = 0;
376375
CWnd *top, *wnd;
377376

378-
if (!Show_sexp_help)
379-
adjust = -SEXP_HELP_BOX_SIZE;
380-
381377
if (!app_init) {
382378
app_init = 1;
383-
theApp.init_window(&Ship_wnd_data, &Ship_editor_dialog, adjust, 1);
384-
theApp.init_window(&Wing_wnd_data, &Wing_editor_dialog, adjust, 1);
379+
theApp.init_window(&Ship_wnd_data, &Ship_editor_dialog, 0, 1);
380+
theApp.init_window(&Wing_wnd_data, &Wing_editor_dialog, 0, 1);
385381
theApp.init_window(&Waypoint_wnd_data, &Waypoint_editor_dialog, 0, 1);
386382
init_window(&Main_wnd_data, Fred_main_wnd);
387383
Fred_main_wnd->SetWindowPos(&CWnd::wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
388384

389385
Ship_editor_dialog.calc_cue_height();
386+
Ship_editor_dialog.calc_help_height();
387+
// on initial setup, these must be called in this order
388+
if (!Show_sexp_help)
389+
Ship_editor_dialog.show_hide_sexp_help();
390+
if (Hide_ship_cues)
391+
Ship_editor_dialog.show_hide_cues();
392+
390393
Wing_editor_dialog.calc_cue_height();
394+
Wing_editor_dialog.calc_help_height();
395+
// on initial setup, these must be called in this order
396+
if (!Show_sexp_help)
397+
Wing_editor_dialog.show_hide_sexp_help();
398+
if (Hide_wing_cues)
399+
Wing_editor_dialog.show_hide_cues();
391400
}
392401

393402
CWinApp::OnIdle(lCount);

fred2/fredview.cpp

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,13 +1150,9 @@ LRESULT CFREDView::OnGoodbye(WPARAM wParam, LPARAM lParam)
11501150

11511151
void CFREDView::OnEditorsShips()
11521152
{
1153-
int adjust = 0;
1154-
11551153
Assert(Ship_editor_dialog.GetSafeHwnd());
1156-
if (!Show_sexp_help)
1157-
adjust = -SEXP_HELP_BOX_SIZE;
11581154

1159-
if (!theApp.init_window(&Ship_wnd_data, &Ship_editor_dialog, adjust))
1155+
if (!theApp.init_window(&Ship_wnd_data, &Ship_editor_dialog, 0))
11601156
return;
11611157

11621158
Ship_editor_dialog.SetWindowPos(&wndTop, 0, 0, 0, 0,
@@ -2329,13 +2325,9 @@ void CFREDView::OnUpdateShowHorizon(CCmdUI* pCmdUI)
23292325

23302326
void CFREDView::OnEditorsWing()
23312327
{
2332-
int adjust = 0;
2333-
23342328
Assert(Wing_editor_dialog.GetSafeHwnd());
2335-
if (!Show_sexp_help)
2336-
adjust = -SEXP_HELP_BOX_SIZE;
23372329

2338-
if (!theApp.init_window(&Wing_wnd_data, &Wing_editor_dialog, adjust))
2330+
if (!theApp.init_window(&Wing_wnd_data, &Wing_editor_dialog, 0))
23392331
return;
23402332

23412333
Wing_editor_dialog.SetWindowPos(&wndTop, 0, 0, 0, 0,
@@ -3403,11 +3395,7 @@ int CFREDView::fred_check_sexp(int sexp, int type, const char *msg, ...)
34033395

34043396
void CFREDView::OnEditorsWaypoint()
34053397
{
3406-
int adjust = 0;
3407-
34083398
Assert(Waypoint_editor_dialog.GetSafeHwnd());
3409-
if (!Show_sexp_help)
3410-
adjust = -SEXP_HELP_BOX_SIZE;
34113399

34123400
if (!theApp.init_window(&Waypoint_wnd_data, &Waypoint_editor_dialog))
34133401
return;
@@ -4073,16 +4061,6 @@ void CFREDView::OnShowSexpHelp()
40734061
Show_sexp_help = !Show_sexp_help;
40744062
Ship_editor_dialog.show_hide_sexp_help();
40754063
Wing_editor_dialog.show_hide_sexp_help();
4076-
4077-
if (Event_editor_dlg) {
4078-
Event_editor_dlg->GetWindowRect(rect);
4079-
if (Show_sexp_help)
4080-
rect.bottom += SEXP_HELP_BOX_SIZE;
4081-
else
4082-
rect.bottom -= SEXP_HELP_BOX_SIZE;
4083-
4084-
Event_editor_dlg->MoveWindow(rect);
4085-
}
40864064
}
40874065

40884066
void CFREDView::OnUpdateShowSexpHelp(CCmdUI* pCmdUI)

fred2/fredview.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#define WM_MENU_POPUP_SHIPS (WM_USER+6)
1717
#define WM_MENU_POPUP_EDIT (WM_USER+7)
18-
#define SEXP_HELP_BOX_SIZE 170
1918

2019
typedef struct Marking_box {
2120
int x1, y1, x2, y2;

fred2/missiongoalsdlg.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,13 @@ BOOL CMissionGoalsDlg::OnInitDialog()
6262
int i, adjust = 0;
6363

6464
CDialog::OnInitDialog(); // let the base class do the default work
65+
6566
if (!Show_sexp_help)
66-
adjust = -SEXP_HELP_BOX_SIZE;
67+
{
68+
CRect rect;
69+
GetDlgItem(IDC_HELP_BOX)->GetWindowRect(rect);
70+
adjust = rect.top - rect.bottom - 20;
71+
}
6772

6873
theApp.init_window(&Mission_goals_wnd_data, this, adjust);
6974
m_goals_tree.setup((CEdit *) GetDlgItem(IDC_HELP_BOX));

fred2/sexp_tree.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4063,7 +4063,7 @@ void sexp_tree::update_help(HTREEITEM h)
40634063
return;
40644064

40654065
mini_help_box = (CEdit *) GetParent()->GetDlgItem(IDC_MINI_HELP_BOX);
4066-
if (!mini_help_box || !::IsWindow(mini_help_box->m_hWnd))
4066+
if (mini_help_box && !::IsWindow(mini_help_box->m_hWnd))
40674067
return;
40684068

40694069
for (i=0; i<(int)tree_nodes.size(); i++)
@@ -4072,13 +4072,15 @@ void sexp_tree::update_help(HTREEITEM h)
40724072

40734073
if ((i >= (int)tree_nodes.size()) || !tree_nodes[i].type) {
40744074
help_box->SetWindowText("");
4075-
mini_help_box->SetWindowText("");
4075+
if (mini_help_box)
4076+
mini_help_box->SetWindowText("");
40764077
return;
40774078
}
40784079

40794080
if (SEXPT_TYPE(tree_nodes[i].type) == SEXPT_OPERATOR)
40804081
{
4081-
mini_help_box->SetWindowText("");
4082+
if (mini_help_box)
4083+
mini_help_box->SetWindowText("");
40824084
}
40834085
else
40844086
{
@@ -4168,7 +4170,8 @@ void sexp_tree::update_help(HTREEITEM h)
41684170
sprintf(buffer, "%d:", sibling_place);
41694171
}
41704172

4171-
mini_help_box->SetWindowText(buffer);
4173+
if (mini_help_box)
4174+
mini_help_box->SetWindowText(buffer);
41724175
}
41734176

41744177
if (index >= 0) {

fred2/shipeditordlg.cpp

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,61 +1832,63 @@ void CShipEditorDlg::OnSelchangedDepartureTree(NMHDR* pNMHDR, LRESULT* pResult)
18321832
*pResult = 0;
18331833
}
18341834

1835+
void CShipEditorDlg::calc_help_height()
1836+
{
1837+
CRect minihelp, help;
1838+
1839+
GetDlgItem(IDC_MINI_HELP_BOX)->GetWindowRect(minihelp);
1840+
GetDlgItem(IDC_HELP_BOX)->GetWindowRect(help);
1841+
help_height = (help.bottom - minihelp.top) + 10;
1842+
}
1843+
18351844
void CShipEditorDlg::calc_cue_height()
18361845
{
1837-
CRect cue, help;
1846+
CRect cue;
18381847

18391848
GetDlgItem(IDC_CUE_FRAME)->GetWindowRect(cue);
1840-
cue_height = (cue.bottom - cue.top)+20;
1841-
if (Show_sexp_help){
1842-
GetDlgItem(IDC_HELP_BOX)->GetWindowRect(help);
1843-
cue_height += (help.bottom - help.top);
1844-
}
1845-
1846-
if (Hide_ship_cues) {
1847-
((CButton *) GetDlgItem(IDC_HIDE_CUES)) -> SetCheck(1);
1848-
OnHideCues();
1849-
}
1849+
cue_height = (cue.bottom - cue.top) + 10;
18501850
}
18511851

18521852
void CShipEditorDlg::show_hide_sexp_help()
18531853
{
1854-
CRect rect, help;
1855-
GetDlgItem(IDC_HELP_BOX)->GetWindowRect(help);
1856-
float box_size = (float)(help.bottom - help.top);
1857-
1858-
if (Show_sexp_help){
1859-
cue_height += (int)box_size;
1860-
} else {
1861-
cue_height -= (int)box_size;
1862-
}
1854+
CRect rect;
18631855

1864-
if (((CButton *) GetDlgItem(IDC_HIDE_CUES)) -> GetCheck()){
1856+
if (((CButton *) GetDlgItem(IDC_HIDE_CUES)) -> GetCheck())
18651857
return;
1866-
}
18671858

18681859
GetWindowRect(rect);
18691860

1870-
if (Show_sexp_help){
1871-
rect.bottom += (LONG)box_size;
1872-
} else {
1873-
rect.bottom -= (LONG)box_size;
1874-
}
1861+
if (Show_sexp_help)
1862+
rect.bottom += help_height;
1863+
else
1864+
rect.bottom -= help_height;
18751865

18761866
MoveWindow(rect);
18771867
}
18781868

1869+
void CShipEditorDlg::show_hide_cues()
1870+
{
1871+
((CButton*)GetDlgItem(IDC_HIDE_CUES))->SetCheck(Hide_ship_cues ? TRUE : FALSE);
1872+
OnHideCues();
1873+
}
1874+
18791875
void CShipEditorDlg::OnHideCues()
18801876
{
18811877
CRect rect;
18821878

18831879
GetWindowRect(rect);
1880+
18841881
if (((CButton *) GetDlgItem(IDC_HIDE_CUES)) -> GetCheck()) {
18851882
rect.bottom -= cue_height;
1886-
Hide_ship_cues = 1;
1883+
if (Show_sexp_help)
1884+
rect.bottom -= help_height;
18871885

1886+
Hide_ship_cues = 1;
18881887
} else {
18891888
rect.bottom += cue_height;
1889+
if (Show_sexp_help)
1890+
rect.bottom += help_height;
1891+
18901892
Hide_ship_cues = 0;
18911893
}
18921894

fred2/shipeditordlg.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class CShipEditorDlg : public CDialog
4747
int initialized;
4848
int multi_edit;
4949
int always_on_top;
50+
int help_height;
5051
int cue_height;
5152
int mission_type; // indicates if single player(1) or multiplayer(0)
5253
CView* m_pSEView;
@@ -65,8 +66,10 @@ class CShipEditorDlg : public CDialog
6566
int p_enable; // used to enable(1)/disable(0) controls based on if a player ship
6667

6768
int tristate_set(int val, int cur_state);
68-
void show_hide_sexp_help();
69+
void calc_help_height();
6970
void calc_cue_height();
71+
void show_hide_sexp_help();
72+
void show_hide_cues();
7073
int verify();
7174
void OnInitMenu(CMenu *m);
7275
void OnOK();

fred2/wing_editor.cpp

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,53 +1117,63 @@ void wing_editor::OnSelchangedDepartureTree(NMHDR* pNMHDR, LRESULT* pResult)
11171117
*pResult = 0;
11181118
}
11191119

1120+
void wing_editor::calc_help_height()
1121+
{
1122+
CRect minihelp, help;
1123+
1124+
GetDlgItem(IDC_MINI_HELP_BOX)->GetWindowRect(minihelp);
1125+
GetDlgItem(IDC_HELP_BOX)->GetWindowRect(help);
1126+
help_height = (help.bottom - minihelp.top) + 10;
1127+
}
1128+
11201129
void wing_editor::calc_cue_height()
11211130
{
11221131
CRect cue;
11231132

11241133
GetDlgItem(IDC_CUE_FRAME)->GetWindowRect(cue);
1125-
cue_height = cue.bottom - cue.top + 10;
1126-
if (Show_sexp_help)
1127-
cue_height += SEXP_HELP_BOX_SIZE;
1128-
1129-
if (Hide_wing_cues) {
1130-
((CButton *) GetDlgItem(IDC_HIDE_CUES)) -> SetCheck(1);
1131-
OnHideCues();
1132-
}
1134+
cue_height = (cue.bottom - cue.top) + 10;
11331135
}
11341136

11351137
void wing_editor::show_hide_sexp_help()
11361138
{
11371139
CRect rect;
11381140

1139-
if (Show_sexp_help)
1140-
cue_height += SEXP_HELP_BOX_SIZE;
1141-
else
1142-
cue_height -= SEXP_HELP_BOX_SIZE;
1143-
11441141
if (((CButton *) GetDlgItem(IDC_HIDE_CUES)) -> GetCheck())
11451142
return;
11461143

11471144
GetWindowRect(rect);
1145+
11481146
if (Show_sexp_help)
1149-
rect.bottom += SEXP_HELP_BOX_SIZE;
1147+
rect.bottom += help_height;
11501148
else
1151-
rect.bottom -= SEXP_HELP_BOX_SIZE;
1149+
rect.bottom -= help_height;
11521150

11531151
MoveWindow(rect);
11541152
}
11551153

1156-
void wing_editor::OnHideCues()
1154+
void wing_editor::show_hide_cues()
1155+
{
1156+
((CButton*)GetDlgItem(IDC_HIDE_CUES))->SetCheck(Hide_wing_cues ? TRUE : FALSE);
1157+
OnHideCues();
1158+
}
1159+
1160+
void wing_editor::OnHideCues()
11571161
{
11581162
CRect rect;
11591163

11601164
GetWindowRect(rect);
1165+
11611166
if (((CButton *) GetDlgItem(IDC_HIDE_CUES)) -> GetCheck()) {
11621167
rect.bottom -= cue_height;
1163-
Hide_wing_cues = 1;
1168+
if (Show_sexp_help)
1169+
rect.bottom -= help_height;
11641170

1171+
Hide_wing_cues = 1;
11651172
} else {
11661173
rect.bottom += cue_height;
1174+
if (Show_sexp_help)
1175+
rect.bottom += help_height;
1176+
11671177
Hide_wing_cues = 0;
11681178
}
11691179

fred2/wing_editor.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@ class wing_editor : public CDialog
1818
{
1919
// Construction
2020
public:
21+
int help_height;
2122
int cue_height;
2223
int bypass_errors;
2324
int modified;
2425
int select_sexp_node;
2526

2627
void initialize_data_safe(int full_update);
2728
void update_data_safe();
28-
void show_hide_sexp_help();
29+
void calc_help_height();
2930
void calc_cue_height();
31+
void show_hide_sexp_help();
32+
void show_hide_cues();
3033
int verify();
3134
wing_editor(CWnd* pParent = NULL); // standard constructor
3235
BOOL Create();

0 commit comments

Comments
 (0)