Skip to content

Commit 0902903

Browse files
authored
Qtfred unify flag lists (#7384)
* convert wing flags to the flags widget * set tooltips on flags using flag descriptions * add missing descriptions * clang
1 parent b1cefad commit 0902903

25 files changed

Lines changed: 347 additions & 37 deletions

code/ai/ai.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ typedef struct ai_flag_description {
4242
extern ai_flag_name Ai_flag_names[];
4343
extern ai_flag_description Ai_flag_descriptions[];
4444
extern const int Num_ai_flag_names;
45+
extern const size_t Num_ai_flag_descriptions;
4546

4647
// dock_orient_and_approach() modes.
4748
#define DOA_APPROACH 1 // Approach the current point on the path (aip->path_cur)

code/ai/aicode.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,11 @@ ai_flag_description Ai_flag_descriptions[] = {
223223
{AI::AI_Flags::No_dynamic, "Will stop allowing the AI to pursue dynamic goals (eg: chasing ships it was not ordered to)."},
224224
{AI::AI_Flags::Free_afterburner_use, "Will allow AI to use afterburners when attacking a big ship, flying to a target position, guarding a ship, and flying in formation."},
225225
{AI::AI_Flags::Waypoints_no_formation, "Ship will not form up with its wingmates while running waypoints with them." },
226+
{AI::AI_Flags::Kamikaze, "Ship will attack big ships by colliding with them and exploding."},
226227
};
227228

228229
extern const int Num_ai_flag_names = sizeof(Ai_flag_names) / sizeof(ai_flag_name);
230+
extern const size_t Num_ai_flag_descriptions = sizeof(Ai_flag_descriptions) / sizeof(ai_flag_description);
229231

230232
const char *Skill_level_names(int level, int translate)
231233
{

code/mission/missionparse.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ parse_object_flag_description<Mission::Mission_Flags> Parse_mission_flag_descrip
434434
};
435435

436436
const size_t Num_parse_mission_flags = sizeof(Parse_mission_flags) / sizeof(flag_def_list_new<Mission::Mission_Flags>);
437+
const size_t Num_parse_mission_flag_descriptions = sizeof(Parse_mission_flag_descriptions) / sizeof(parse_object_flag_description<Mission::Mission_Flags>);
437438

438439
flag_def_list_new<Mission::Parse_Object_Flags> Parse_object_flags[] = {
439440
{ "cargo-known", Mission::Parse_Object_Flags::SF_Cargo_known, true, false },
@@ -601,6 +602,7 @@ parse_object_flag_description<Ship::Wing_Flags> Parse_wing_flag_descriptions[] =
601602
{ Ship::Wing_Flags::Same_departure_warp_when_docked, "Docked ship use the same warp effect size upon departure as if they were not docked instead of the enlarged aggregate size." }};
602603

603604
const size_t Num_parse_wing_flags = sizeof(Parse_wing_flags) / sizeof(flag_def_list_new<Ship::Wing_Flags>);
605+
const size_t Num_parse_wing_flag_descriptions = sizeof(Parse_wing_flag_descriptions) / sizeof(parse_object_flag_description<Ship::Wing_Flags>);
604606

605607
flag_def_list_new<Mission::Parse_Object_Flags> Parse_prop_flags[] = {
606608
{ "no_collide", Mission::Parse_Object_Flags::OF_No_collide, true, false },
@@ -611,6 +613,7 @@ parse_object_flag_description<Mission::Parse_Object_Flags> Parse_prop_flag_descr
611613
};
612614

613615
const size_t Num_parse_prop_flags = sizeof(Parse_prop_flags) / sizeof(flag_def_list_new<Mission::Parse_Object_Flags>);
616+
const size_t Num_parse_prop_flag_descriptions = sizeof(Parse_prop_flag_descriptions) / sizeof(parse_object_flag_description<Mission::Parse_Object_Flags>);
614617

615618
// These are only the flags that are saved to the mission file. See the MEF_ #defines.
616619
flag_def_list Mission_event_flags[] = {

code/mission/missionparse.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ extern const char *Reinforcement_type_names[];
313313
extern flag_def_list_new<Mission::Mission_Flags> Parse_mission_flags[];
314314
extern parse_object_flag_description<Mission::Mission_Flags> Parse_mission_flag_descriptions[];
315315
extern const size_t Num_parse_mission_flags;
316+
extern const size_t Num_parse_mission_flag_descriptions;
316317
extern char *Object_flags[];
317318
extern flag_def_list_new<Ship::Ship_Flags> Parse_ship_flags[];
318319
extern const size_t Num_Parse_ship_flags;
@@ -326,9 +327,11 @@ extern const size_t Num_parse_object_flags;
326327
extern flag_def_list_new<Ship::Wing_Flags> Parse_wing_flags[];
327328
extern parse_object_flag_description<Ship::Wing_Flags> Parse_wing_flag_descriptions[];
328329
extern const size_t Num_parse_wing_flags;
330+
extern const size_t Num_parse_wing_flag_descriptions;
329331
extern flag_def_list_new<Mission::Parse_Object_Flags> Parse_prop_flags[];
330332
extern parse_object_flag_description<Mission::Parse_Object_Flags> Parse_prop_flag_descriptions[];
331333
extern const size_t Num_parse_prop_flags;
334+
extern const size_t Num_parse_prop_flag_descriptions;
332335
extern const char *Icon_names[];
333336
extern const char *Mission_event_log_flags[];
334337

code/object/object.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,12 @@ obj_flag_description Object_flag_descriptions[] = {
176176
{ Object::Object_Flags::Dont_change_orientation, "Will not let an object change orientation. Upon destruction it will still do the death roll and explosion."},
177177
{ Object::Object_Flags::Collides, "This object will collide with other objects."},
178178
{ Object::Object_Flags::Attackable_if_no_collide, "Allows the AI to attack this object, even if no-collide is set. (Normally an object that does not collide is also not attacked.)"},
179+
{ Object::Object_Flags::Player_ship, "Ship is a player ship."},
180+
{ Object::Object_Flags::Special_warpin, "Ship uses the special Knossos warp-in animation."},
179181
};
180182

181183
extern const int Num_object_flag_names = sizeof(Object_flag_names) / sizeof(obj_flag_name);
184+
extern const size_t Num_object_flag_descriptions = sizeof(Object_flag_descriptions) / sizeof(obj_flag_description);
182185

183186
#ifdef OBJECT_CHECK
184187
checkobject::checkobject()

code/object/object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ typedef struct obj_flag_description {
120120
extern obj_flag_name Object_flag_names[];
121121
extern obj_flag_description Object_flag_descriptions[];
122122
extern const int Num_object_flag_names;
123+
extern const size_t Num_object_flag_descriptions;
123124

124125
struct dock_instance;
125126
class model_draw_list;

code/ship/ship.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,9 +709,20 @@ ship_flag_description Ship_flag_descriptions[] = {
709709
{ Ship_Flags::Maneuver_despite_engines, "Ship can maneuver even if its engines are disabled or disrupted" },
710710
{ Ship_Flags::No_scanned_cargo, "Ship cargo will never be revealed and will instead only show scanned or not scanned. Only available if using New Scanning Behavior in game_settings.tbl."},
711711
{ Ship_Flags::EMP_doesnt_scramble_messages, "EMP does not affect whether messages appear scrambled when sent from or received by this ship." },
712+
{ Ship_Flags::Ignore_count, "Ignore this ship when counting ship types for goals."},
713+
{ Ship_Flags::Reinforcement, "This ship is a reinforcement ship."},
714+
{ Ship_Flags::Escort, "This ship is an escort ship."},
715+
{ Ship_Flags::No_arrival_music, "Don't play arrival music when ship arrives."},
716+
{ Ship_Flags::Red_alert_store_status, "Ship status should be stored/restored if red alert mission."},
717+
{ Ship_Flags::Navpoint_carry, "This ship autopilots with the player."},
718+
{ Ship_Flags::Affected_by_gravity, "Deprecated. Does nothing."},
719+
{ Ship_Flags::Navpoint_needslink, "This ship requires linking for autopilot."},
720+
{ Ship_Flags::Set_class_dynamically, "This ship should have its class assigned rather than simply read from the mission file."},
721+
{ Ship_Flags::Kill_before_mission, "Ship is destroyed before the mission begins. Use with the Destroyed seconds setting."},
712722
};
713723

714724
extern const size_t Num_ship_flag_names = sizeof(Ship_flag_names) / sizeof(ship_flag_name);
725+
extern const size_t Num_ship_flag_descriptions = sizeof(Ship_flag_descriptions) / sizeof(ship_flag_description);
715726

716727
// Ditto for wings
717728
wing_flag_name Wing_flag_names[] = {
@@ -737,6 +748,7 @@ wing_flag_description Wing_flag_descriptions[] = {
737748
};
738749

739750
extern const size_t Num_wing_flag_names = sizeof(Wing_flag_names) / sizeof(wing_flag_name);
751+
extern const size_t Num_wing_flag_descriptions = sizeof(Wing_flag_descriptions) / sizeof(wing_flag_description);
740752

741753
static int Laser_energy_out_snd_timer; // timer so we play out of laser sound effect periodically
742754
static int Missile_out_snd_timer; // timer so we play out of laser sound effect periodically

code/ship/ship.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ typedef struct ship_flag_description {
470470
extern ship_flag_name Ship_flag_names[];
471471
extern ship_flag_description Ship_flag_descriptions[];
472472
extern const size_t Num_ship_flag_names;
473+
extern const size_t Num_ship_flag_descriptions;
473474

474475
typedef struct wing_flag_name {
475476
Ship::Wing_Flags flag;
@@ -484,6 +485,7 @@ typedef struct wing_flag_description {
484485
extern wing_flag_name Wing_flag_names[];
485486
extern wing_flag_description Wing_flag_descriptions[];
486487
extern const size_t Num_wing_flag_names;
488+
extern const size_t Num_wing_flag_descriptions;
487489

488490
#define DEFAULT_SHIP_PRIMITIVE_SENSOR_RANGE 10000 // Goober5000
489491

qtfred/source_groups.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ add_file_folder("Source/UI/Dialogs"
216216
src/ui/dialogs/WaypointPathGeneratorDialog.h
217217
src/ui/dialogs/WingEditorDialog.cpp
218218
src/ui/dialogs/WingEditorDialog.h
219+
src/ui/dialogs/WingFlagsDialog.cpp
220+
src/ui/dialogs/WingFlagsDialog.h
219221
)
220222
add_file_folder("Source/UI/Dialogs/BriefingEditor"
221223
src/ui/dialogs/BriefingEditor/CameraCoordinatesDialog.cpp
@@ -369,6 +371,7 @@ add_file_folder("UI"
369371
ui/ShipWeaponsDialog.ui
370372
ui/VariableDialog.ui
371373
ui/WingEditorDialog.ui
374+
ui/WingFlagsDialog.ui
372375
ui/SaveAsTemplateDialog.ui
373376
ui/SceneBrowserPanel.ui
374377
ui/TemplateBrowserDialog.ui

qtfred/src/mission/dialogs/MissionSpecDialogModel.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,25 @@ const SCP_vector<std::pair<SCP_string, bool>>& MissionSpecDialogModel::getMissio
432432
return _m_flag_data;
433433
}
434434

435+
SCP_vector<std::pair<SCP_string, SCP_string>> MissionSpecDialogModel::getMissionFlagDescriptions()
436+
{
437+
const size_t num_descs = Num_parse_mission_flag_descriptions;
438+
SCP_vector<std::pair<SCP_string, SCP_string>> descriptions;
439+
descriptions.reserve(Num_parse_mission_flags);
440+
for (size_t i = 0; i < Num_parse_mission_flags; ++i) {
441+
const auto& flagDef = Parse_mission_flags[i];
442+
if (flagDef.is_special || !flagDef.in_use)
443+
continue;
444+
for (size_t j = 0; j < num_descs; ++j) {
445+
if (Parse_mission_flag_descriptions[j].def == flagDef.def) {
446+
descriptions.emplace_back(flagDef.name, Parse_mission_flag_descriptions[j].flag_desc);
447+
break;
448+
}
449+
}
450+
}
451+
return descriptions;
452+
}
453+
435454
void MissionSpecDialogModel::setMissionFullWar(bool enabled) {
436455
if (_m_full_war != enabled) {
437456
_m_full_war = enabled;

0 commit comments

Comments
 (0)