Skip to content

Commit acffb23

Browse files
committed
Add prop editor dialog in FRED
1 parent a3f54df commit acffb23

File tree

18 files changed

+442
-19
lines changed

18 files changed

+442
-19
lines changed

code/mission/missionparse.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,16 @@ parse_object_flag_description<Mission::Parse_Object_Flags> Parse_object_flag_des
405405

406406
const size_t Num_parse_object_flags = sizeof(Parse_object_flags) / sizeof(flag_def_list_new<Mission::Parse_Object_Flags>);
407407

408+
flag_def_list_new<Mission::Parse_Object_Flags> Parse_prop_flags[] = {
409+
{ "no_collide", Mission::Parse_Object_Flags::OF_No_collide, true, false },
410+
};
411+
412+
parse_object_flag_description<Mission::Parse_Object_Flags> Parse_prop_flag_descriptions[] = {
413+
{ Mission::Parse_Object_Flags::OF_No_collide, "Prop cannot be collided with."},
414+
};
415+
416+
const size_t Num_parse_prop_flags = sizeof(Parse_prop_flags) / sizeof(flag_def_list_new<Mission::Parse_Object_Flags>);
417+
408418
// These are only the flags that are saved to the mission file. See the MEF_ #defines.
409419
flag_def_list Mission_event_flags[] = {
410420
{ "interval & delay use msecs", MEF_USE_MSECS, 0 },
@@ -4954,6 +4964,17 @@ void parse_prop(mission* pm)
49544964
required_string("$Orientation:");
49554965
stuff_matrix(&prop.orientation);
49564966

4967+
// set flags
4968+
if (optional_string("+Flags:")) {
4969+
SCP_vector<SCP_string> unparsed;
4970+
parse_string_flag_list(prop.flags, Parse_prop_flags, Num_parse_prop_flags, &unparsed);
4971+
if (!unparsed.empty()) {
4972+
for (size_t k = 0; k < unparsed.size(); ++k) {
4973+
WarningEx(LOCATION, "Unknown flag in parse prop flags: %s", unparsed[k].c_str());
4974+
}
4975+
}
4976+
}
4977+
49574978
Parse_props.emplace_back(prop);
49584979
}
49594980

@@ -5065,7 +5086,15 @@ void post_process_props()
50655086
{
50665087
for (int i = 0; i < static_cast<int>(Parse_props.size()); i++) {
50675088
parsed_prop* propp = &Parse_props[i];
5068-
prop_create(&propp->orientation, &propp->position, propp->prop_info_index, propp->name);
5089+
int objnum = prop_create(&propp->orientation, &propp->position, propp->prop_info_index, propp->name);
5090+
5091+
if (objnum >= 0) {
5092+
auto& obj = Objects[objnum];
5093+
5094+
if (propp->flags[Mission::Parse_Object_Flags::OF_No_collide]) {
5095+
obj.flags.remove(Object::Object_Flags::Collides);
5096+
}
5097+
}
50695098
}
50705099
}
50715100

code/mission/missionparse.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ extern char *Object_flags[];
275275
extern flag_def_list_new<Mission::Parse_Object_Flags> Parse_object_flags[];
276276
extern parse_object_flag_description<Mission::Parse_Object_Flags> Parse_object_flag_descriptions[];
277277
extern const size_t Num_parse_object_flags;
278+
extern flag_def_list_new<Mission::Parse_Object_Flags> Parse_prop_flags[];
279+
extern parse_object_flag_description<Mission::Parse_Object_Flags> Parse_prop_flag_descriptions[];
280+
extern const size_t Num_parse_prop_flags;
278281
extern const char *Icon_names[];
279282
extern const char *Mission_event_log_flags[];
280283

code/prop/prop.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ void prop_init()
154154
{
155155

156156
// first parse the default table
157-
parse_prop_table("props.tbl");
157+
if (cf_exists_full("props.tbl", CF_TYPE_TABLES)) {
158+
parse_prop_table("props.tbl");
159+
}
158160

159161
// parse any modular tables
160162
parse_modular_table("*-prp.tbm", parse_prop_table);
@@ -196,7 +198,7 @@ int prop_create(matrix* orient, vec3d* pos, int prop_type, const char* name)
196198
char base_name[NAME_LENGTH];
197199
char suffix[NAME_LENGTH];
198200
strcpy_s(base_name, Prop_info[prop_type].name);
199-
sprintf(suffix, NOX(" %d"), Props.size());
201+
sprintf(suffix, NOX(" %d"), static_cast<int>(Props.size()));
200202

201203
// start building name
202204
strcpy_s(propp->prop_name, base_name);

code/prop/prop.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "globalincs/pstypes.h"
44

5+
#include "mission/mission_flags.h"
56
#include "object/object.h"
67
#include "prop/prop_flags.h"
78
#include "ship/ship.h"
@@ -29,14 +30,15 @@ typedef struct prop {
2930
float alpha_mult;
3031
// glow points
3132
std::deque<bool> glow_point_bank_active;
32-
flagset<Prop::Prop_Flags> flags; // Render flags
33+
flagset<Prop::Prop_Flags> flags;
3334
} prop;
3435

3536
typedef struct parsed_prop {
3637
char name[NAME_LENGTH];
3738
int prop_info_index;
3839
matrix orientation;
3940
vec3d position;
41+
flagset<Mission::Parse_Object_Flags> flags;
4042
} parsed_prop;
4143

4244
// Global prop info array

fred2/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ set(FRED2_SOURCES
103103
playerstarteditor.h
104104
prefsdlg.cpp
105105
prefsdlg.h
106+
propdlg.cpp
107+
propdlg.h
106108
reinforcementeditordlg.cpp
107109
reinforcementeditordlg.h
108110
resource.h

fred2/fred.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ int Show_cpu = 0;
116116

117117
CWnd* Prev_window;
118118
CShipEditorDlg Ship_editor_dialog;
119+
prop_dlg Prop_editor_dialog;
119120
wing_editor Wing_editor_dialog;
120121
waypoint_path_dlg Waypoint_editor_dialog;
121122
jumpnode_dlg Jumpnode_editor_dialog;
@@ -125,6 +126,7 @@ briefing_editor_dlg* Briefing_dialog = NULL;
125126

126127
window_data Main_wnd_data;
127128
window_data Ship_wnd_data;
129+
window_data Prop_wnd_data;
128130
window_data Wing_wnd_data;
129131
window_data Object_wnd_data;
130132
window_data Mission_goals_wnd_data;
@@ -249,6 +251,7 @@ BOOL CFREDApp::InitInstance() {
249251

250252
read_window("Main window", &Main_wnd_data);
251253
read_window("Ship window", &Ship_wnd_data);
254+
read_window("Prop window", &Prop_wnd_data);
252255
read_window("Wing window", &Wing_wnd_data);
253256
read_window("Waypoint window", &Waypoint_wnd_data);
254257
read_window("Jumpnode window", &Jumpnode_wnd_data);
@@ -391,6 +394,7 @@ BOOL CFREDApp::OnIdle(LONG lCount) {
391394
if (!app_init) {
392395
app_init = 1;
393396
theApp.init_window(&Ship_wnd_data, &Ship_editor_dialog, 0, 1);
397+
theApp.init_window(&Prop_wnd_data, &Prop_editor_dialog, 0, 1);
394398
theApp.init_window(&Wing_wnd_data, &Wing_editor_dialog, 0, 1);
395399
theApp.init_window(&MusPlayer_wnd_data, &Music_player_dialog, 0, 1);
396400
theApp.init_window(&Waypoint_wnd_data, &Waypoint_editor_dialog, 0, 1);
@@ -427,6 +431,11 @@ BOOL CFREDApp::OnIdle(LONG lCount) {
427431
Update_wing = 0;
428432
}
429433

434+
if (Update_prop) {
435+
Prop_editor_dialog.initialize_data(1);
436+
Update_prop = 0;
437+
}
438+
430439
Prev_window = CFREDView::GetActiveWindow();
431440

432441
// Find the root window of the active window
@@ -546,10 +555,12 @@ void CFREDApp::write_ini_file(int degree) {
546555
record_window_data(&MusPlayer_wnd_data, &Music_player_dialog);
547556
record_window_data(&Wing_wnd_data, &Wing_editor_dialog);
548557
record_window_data(&Ship_wnd_data, &Ship_editor_dialog);
558+
record_window_data(&Prop_wnd_data, &Prop_editor_dialog);
549559
record_window_data(&Main_wnd_data, Fred_main_wnd);
550560

551561
write_window("Main window", &Main_wnd_data);
552562
write_window("Ship window", &Ship_wnd_data);
563+
write_window("Prop window", &Prop_wnd_data);
553564
write_window("Wing window", &Wing_wnd_data);
554565
write_window("Waypoint window", &Waypoint_wnd_data);
555566
write_window("Jumpnode window", &Jumpnode_wnd_data);

fred2/fred.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "BriefingEditorDlg.h"
2020
#include "resource.h"
2121
#include "ShipEditorDlg.h"
22+
#include "propdlg.h"
2223
#include "WaypointPathDlg.h"
2324
#include "JumpNodeDlg.h"
2425
#include "wing_editor.h"
@@ -180,6 +181,7 @@ extern HCURSOR h_cursor_rotate; //!< Cursor resource (icon) used for rotational
180181

181182
extern CWnd* Prev_window; //!< The currently active window
182183
extern CShipEditorDlg Ship_editor_dialog; //!< The ship editor instance
184+
extern prop_dlg Prop_editor_dialog; //!< The prop editor instance
183185
extern wing_editor Wing_editor_dialog; //!< The wing editor instance
184186
extern waypoint_path_dlg Waypoint_editor_dialog; //!< The waypoint editor instance
185187
extern jumpnode_dlg Jumpnode_editor_dialog; //!< The jumpnode editor instance
@@ -191,6 +193,7 @@ extern CFREDApp theApp; //!< The application instance
191193

192194
extern window_data Main_wnd_data;
193195
extern window_data Ship_wnd_data;
196+
extern window_data Prop_wnd_data;
194197
extern window_data Wing_wnd_data;
195198
extern window_data Object_wnd_data;
196199
extern window_data Mission_goals_wnd_data;

fred2/fred.rc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,14 @@ BEGIN
545545
END
546546
END
547547

548+
IDR_PROP_EDIT_MENU MENU
549+
BEGIN
550+
POPUP "&Select Prop"
551+
BEGIN
552+
MENUITEM "PlaceHolder", ID_SELECTSHIP_PLACEHOLDER
553+
END
554+
END
555+
548556
IDR_PLAYER_EDIT_MENU MENU
549557
BEGIN
550558
POPUP "Select Team"
@@ -622,6 +630,7 @@ BEGIN
622630
"F", ID_EDITORS_FICTION, VIRTKEY, SHIFT, NOINVERT
623631
"G", ID_EDITORS_GOALS, VIRTKEY, SHIFT, NOINVERT
624632
"G", ID_VIEW_GRID, VIRTKEY, SHIFT, ALT, NOINVERT
633+
"P", ID_EDITORS_PROPS, VIRTKEY, SHIFT, CONTROL, NOINVERT
625634
"H", ID_ERROR_CHECKER, VIRTKEY, SHIFT, NOINVERT
626635
"H", ID_SELECT_LIST, VIRTKEY, NOINVERT
627636
"H", ID_SHOW_HORIZON, VIRTKEY, SHIFT, ALT, NOINVERT
@@ -1089,6 +1098,20 @@ BEGIN
10891098
EDITTEXT IDC_HELP_BOX,7,421,308,78,ES_MULTILINE | ES_READONLY,WS_EX_TRANSPARENT
10901099
END
10911100

1101+
IDD_PROP_EDITOR DIALOGEX 0, 0, 300, 200
1102+
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
1103+
CAPTION "Prop Editor"
1104+
FONT 8, "MS Sans Serif", 0, 0, 0x0
1105+
BEGIN
1106+
LTEXT "Name",IDC_STATIC,7,12,24,8
1107+
EDITTEXT IDC_PROP_NAME,32,10,90,14,ES_AUTOHSCROLL
1108+
PUSHBUTTON "Prev",IDC_PROP_PREV,130,10,20,14
1109+
PUSHBUTTON "Next",IDC_PROP_NEXT,155,10,20,14
1110+
LTEXT "Flags",IDC_STATIC,7,35,30,8
1111+
LISTBOX IDC_PROP_FLAGS,7,45,220,60,LBS_MULTIPLESEL | LBS_NOTIFY | WS_VSCROLL | WS_BORDER
1112+
END
1113+
1114+
10921115
IDD_WEAPON_EDITOR DIALOGEX 0, 0, 564, 79
10931116
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
10941117
CAPTION "Weapon Editor"
@@ -2624,6 +2647,13 @@ BEGIN
26242647
TOPMARGIN, 7
26252648
END
26262649

2650+
IDD_PROP_EDITOR, DIALOG
2651+
BEGIN
2652+
LEFTMARGIN, 7
2653+
RIGHTMARGIN, 315
2654+
TOPMARGIN, 7
2655+
END
2656+
26272657
IDD_WEAPON_EDITOR, DIALOG
26282658
BEGIN
26292659
LEFTMARGIN, 7
@@ -3274,6 +3304,11 @@ BEGIN
32743304
0
32753305
END
32763306

3307+
IDD_PROP_EDITOR AFX_DIALOG_LAYOUT
3308+
BEGIN
3309+
0
3310+
END
3311+
32773312
IDD_WING_EDITOR AFX_DIALOG_LAYOUT
32783313
BEGIN
32793314
0

fred2/fredview.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "ai/ai.h"
3232
#include "ai/aigoals.h"
3333
#include "ship/ship.h" // for ship names
34+
#include "prop/prop.h" // for prop names
3435
#include "MissionGoalsDlg.h"
3536
#include "MissionCutscenesDlg.h"
3637
#include "wing.h"
@@ -149,6 +150,7 @@ BEGIN_MESSAGE_MAP(CFREDView, CView)
149150
ON_UPDATE_COMMAND_UI(ID_SHOW_WAYPOINTS, OnUpdateViewWaypoints)
150151
ON_WM_LBUTTONDOWN()
151152
ON_COMMAND(ID_EDITORS_SHIPS, OnEditorsShips)
153+
ON_COMMAND(ID_EDITORS_PROPS, OnEditorsProps)
152154
ON_WM_KEYDOWN()
153155
ON_WM_KEYUP()
154156
ON_WM_SETFOCUS()
@@ -1195,6 +1197,18 @@ void CFREDView::OnEditorsShips()
11951197
Ship_editor_dialog.ShowWindow(SW_RESTORE);
11961198
}
11971199

1200+
void CFREDView::OnEditorsProps()
1201+
{
1202+
Assert(Prop_editor_dialog.GetSafeHwnd());
1203+
1204+
if (!theApp.init_window(&Prop_wnd_data, &Prop_editor_dialog, 0))
1205+
return;
1206+
1207+
Prop_editor_dialog.SetWindowPos(&wndTop, 0, 0, 0, 0,
1208+
SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
1209+
Prop_editor_dialog.ShowWindow(SW_RESTORE);
1210+
}
1211+
11981212
void CFREDView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT lParam)
11991213
{
12001214
uint lKeyData;
@@ -1460,10 +1474,14 @@ void CFREDView::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
14601474
else {
14611475
CString str;
14621476

1463-
if ((Objects[objnum].type == OBJ_START) || (Objects[objnum].type == OBJ_SHIP))
1477+
if ((Objects[objnum].type == OBJ_START) || (Objects[objnum].type == OBJ_SHIP)) {
14641478
str.Format("Edit %s", Ships[Objects[objnum].instance].ship_name);
14651479

1466-
else if (Objects[objnum].type == OBJ_JUMP_NODE) {
1480+
} else if (Objects[objnum].type == OBJ_PROP) {
1481+
id = ID_EDITORS_PROPS;
1482+
str.Format("Edit %s", Props[Objects[objnum].instance].prop_name);
1483+
1484+
} else if (Objects[objnum].type == OBJ_JUMP_NODE) {
14671485
auto jnp = jumpnode_get_by_objnum(objnum);
14681486
Assert(jnp != nullptr);
14691487

@@ -2001,6 +2019,10 @@ void CFREDView::OnLButtonDblClk(UINT nFlags, CPoint point)
20012019
OnEditorsShips();
20022020
break;
20032021

2022+
case OBJ_PROP:
2023+
OnEditorsProps();
2024+
break;
2025+
20042026
case OBJ_WAYPOINT:
20052027
OnEditorsWaypoint();
20062028
break;

fred2/fredview.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class CFREDView : public CView
105105
afx_msg void OnUpdateViewWaypoints(CCmdUI* pCmdUI);
106106
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
107107
afx_msg void OnEditorsShips();
108+
afx_msg void OnEditorsProps();
108109
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
109110
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
110111
afx_msg void OnSetFocus(CWnd* pOldWnd);

0 commit comments

Comments
 (0)