Skip to content

Commit ad44249

Browse files
authored
Qtfred generic fixes (#7403)
1 parent 681e9b7 commit ad44249

16 files changed

Lines changed: 65 additions & 53 deletions

qtfred/src/mission/FredRenderer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,8 @@ void FredRenderer::render_one_model_htl(object* objp,
797797
render_info.set_debug_flags(debug_flags);
798798
render_info.set_replacement_textures(model_get_instance(Ships[z].model_instance_num)->texture_replace);
799799
render_info.set_flags(flags);
800+
if (Ship_info[Ships[z].ship_info_index].uses_team_colors)
801+
render_info.set_team_color(Ships[z].team_name, Ships[z].secondary_team_name, Ships[z].team_change_timestamp, Ships[z].team_change_time);
800802
model_render_immediate(&render_info, Ship_info[Ships[z].ship_info_index].model_num, Ships[z].model_instance_num, &objp->orient, &objp->pos);
801803
}
802804

@@ -952,9 +954,14 @@ void FredRenderer::render_frame(int cur_object_index,
952954

953955
g3_set_view_matrix(&_viewport->eye_pos, &_viewport->eye_orient, 0.5f);
954956

957+
// Force max star detail so the editor always shows the full Num_stars count
958+
// regardless of the player's graphics quality setting (Detail.num_stars can be 0).
959+
int saved_detail_stars = Detail.num_stars;
960+
Detail.num_stars = MAX_DETAIL_VALUE;
955961
enable_htl();
956962
stars_draw(view().Show_stars, view().Show_stars, view().Show_stars, 0, 0);
957963
disable_htl();
964+
Detail.num_stars = saved_detail_stars;
958965

959966
if (view().Show_horizon) {
960967
gr_set_color(128, 128, 64);

qtfred/src/mission/dialogs/BackgroundEditorDialogModel.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,15 @@ void BackgroundEditorDialogModel::reject()
4848
void BackgroundEditorDialogModel::refreshBackgroundPreview()
4949
{
5050
stars_load_background(Cur_background); // rebuild instances from Backgrounds[]
51-
stars_set_background_model(The_mission.skybox_model, nullptr, The_mission.skybox_flags); // rebuild skybox
51+
52+
// The mission stores the base model name (no extension); the save code adds .pof when writing.
53+
// model_load needs the .pof extension to find the file, so append it if missing.
54+
SCP_string skybox_model = The_mission.skybox_model;
55+
if (!skybox_model.empty() && skybox_model.find('.') == SCP_string::npos)
56+
skybox_model += ".pof";
57+
58+
stars_set_background_model(skybox_model.c_str(), nullptr, The_mission.skybox_flags); // rebuild skybox
5259
stars_set_background_orientation(&The_mission.skybox_orientation);
53-
// TODO make this actually show the stars in the background
5460
_editor->missionChanged();
5561
}
5662

qtfred/src/mission/dialogs/MissionSpecDialogModel.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -422,18 +422,17 @@ bool MissionSpecDialogModel::getMissionFlag(Mission::Mission_Flags flag) const {
422422
}
423423

424424
const SCP_vector<std::pair<SCP_string, bool>>& MissionSpecDialogModel::getMissionFlagsList() {
425-
if (_m_flag_data.empty()) {
426-
for (size_t i = 0; i < Num_parse_mission_flags; ++i) {
427-
auto flagDef = Parse_mission_flags[i];
428-
429-
// Skip flags that have checkboxes elsewhere than the flag list or are inactive
430-
if (flagDef.is_special || !flagDef.in_use) {
431-
continue;
432-
}
425+
_m_flag_data.clear();
426+
for (size_t i = 0; i < Num_parse_mission_flags; ++i) {
427+
auto flagDef = Parse_mission_flags[i];
433428

434-
bool checked = _m_flags[flagDef.def];
435-
_m_flag_data.emplace_back(flagDef.name, checked);
429+
// Skip flags that have checkboxes elsewhere than the flag list or are inactive
430+
if (flagDef.is_special || !flagDef.in_use) {
431+
continue;
436432
}
433+
434+
bool checked = _m_flags[flagDef.def];
435+
_m_flag_data.emplace_back(flagDef.name, checked);
437436
}
438437
return _m_flag_data;
439438
}

qtfred/src/mission/dialogs/ShipEditor/ShipEditorDialogModel.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,9 @@ std::vector<std::pair<SCP_string, bool>> ShipEditorDialogModel::getArrivalPaths(
545545
auto m_path_mask = Ships[single_ship].arrival_path_mask;
546546

547547
for (int i = 0; i < m_num_paths; i++) {
548-
SCP_string name("Path ");
549-
name += i2ch(i + 1);
548+
int path_id = m_model->ship_bay->path_indexes[i];
549+
const char* raw_name = m_model->paths[path_id].name;
550+
SCP_string name = (raw_name && raw_name[0]) ? SCP_string{raw_name} : SCP_string{"<unnamed path>"};
550551
bool allowed;
551552
if (m_path_mask == 0) {
552553
allowed = true;
@@ -570,8 +571,9 @@ std::vector<std::pair<SCP_string, bool>> ShipEditorDialogModel::getDeparturePath
570571
auto m_path_mask = Ships[single_ship].departure_path_mask;
571572

572573
for (int i = 0; i < m_num_paths; i++) {
573-
SCP_string name("Path ");
574-
name += i2ch(i + 1);
574+
int path_id = m_model->ship_bay->path_indexes[i];
575+
const char* raw_name = m_model->paths[path_id].name;
576+
SCP_string name = (raw_name && raw_name[0]) ? SCP_string{raw_name} : SCP_string{"<unnamed path>"};
575577
bool allowed;
576578
if (m_path_mask == 0) {
577579
allowed = true;

qtfred/src/mission/dialogs/ShipEditor/ShipInitialStatusDialogModel.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,9 @@ void ShipInitialStatusDialogModel::initializeData(bool multi)
274274
}
275275
}
276276

277-
if (objp != nullptr) {
278-
if (objp->type == OBJ_SHIP || objp->type == OBJ_START) {
279-
ship* shipp = &Ships[objp->instance];
280-
281-
if (Ship_info[shipp->ship_info_index].uses_team_colors) {
282-
m_use_teams = true;
283-
}
284-
}
277+
if (Ship_info[Ships[m_ship].ship_info_index].uses_team_colors) {
278+
m_use_teams = true;
279+
m_team_color_setting = Ships[m_ship].team_name;
285280
}
286281
change_subsys(0);
287282

@@ -609,6 +604,7 @@ bool ShipInitialStatusDialogModel::apply()
609604
handle_inconsistent_flag(shipp->flags, Ship::Ship_Flags::Secondaries_locked, m_secondaries_locked);
610605
handle_inconsistent_flag(shipp->flags, Ship::Ship_Flags::Lock_all_turrets_initially, m_turrets_locked);
611606
handle_inconsistent_flag(shipp->flags, Ship::Ship_Flags::Afterburner_locked, m_afterburner_locked);
607+
shipp->team_name = m_team_color_setting;
612608
}
613609

614610
objp = GET_NEXT(objp);
@@ -630,8 +626,8 @@ bool ShipInitialStatusDialogModel::apply()
630626
handle_inconsistent_flag(Ships[m_ship].flags, Ship::Ship_Flags::Secondaries_locked, m_secondaries_locked);
631627
handle_inconsistent_flag(Ships[m_ship].flags, Ship::Ship_Flags::Lock_all_turrets_initially, m_turrets_locked);
632628
handle_inconsistent_flag(Ships[m_ship].flags, Ship::Ship_Flags::Afterburner_locked, m_afterburner_locked);
629+
Ships[m_ship].team_name = m_team_color_setting;
633630
}
634-
Ships[m_ship].team_name = m_team_color_setting;
635631
update_docking_info();
636632
_editor->missionChanged();
637633
return true;

qtfred/src/mission/dialogs/WingEditorDialogModel.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,8 @@ void WingEditorDialogModel::setArrivalType(ArrivalLocation newArrivalType)
771771
auto* w = getCurrentWing();
772772
modify(w->arrival_location, newArrivalType);
773773

774-
// If the new arrival type is a dock bay, clear warp in parameters
774+
// If the new arrival type is a dock bay, reset warp-in params to ship class defaults
775+
// (dock bay arrivals don't use warp effects; -1 would crash the save code)
775776
// else, clear arrival paths
776777
if (newArrivalType == ArrivalLocation::FROM_DOCK_BAY) {
777778
for (auto& ship : Ships) {
@@ -780,7 +781,7 @@ void WingEditorDialogModel::setArrivalType(ArrivalLocation newArrivalType)
780781
if (ship.wingnum != _currentWingIndex)
781782
continue;
782783

783-
ship.warpin_params_index = -1;
784+
ship.warpin_params_index = Ship_info[ship.ship_info_index].warpin_params_index;
784785
}
785786
} else {
786787
modify(w->arrival_path_mask, 0);
@@ -1104,7 +1105,8 @@ void WingEditorDialogModel::setDepartureType(DepartureLocation newDepartureType)
11041105
auto* w = getCurrentWing();
11051106
modify(w->departure_location, newDepartureType);
11061107

1107-
// If the new departure type is a dock bay,clear warp out parameters
1108+
// If the new departure type is a dock bay, reset warp-out params to ship class defaults
1109+
// (dock bay departures don't use warp effects; -1 would crash the save code)
11081110
// else, clear departure paths
11091111
if (newDepartureType == DepartureLocation::TO_DOCK_BAY) {
11101112
for (auto& ship : Ships) {
@@ -1113,7 +1115,7 @@ void WingEditorDialogModel::setDepartureType(DepartureLocation newDepartureType)
11131115
if (ship.wingnum != _currentWingIndex)
11141116
continue;
11151117

1116-
ship.warpout_params_index = -1;
1118+
ship.warpout_params_index = Ship_info[ship.ship_info_index].warpout_params_index;
11171119
}
11181120
} else {
11191121
modify(w->departure_path_mask, 0);

qtfred/src/ui/FredView.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,6 +2269,7 @@ void FredView::onPropClassSelected(int prop_class) {
22692269
void FredView::on_actionAsteroid_Field_triggered(bool) {
22702270
auto asteroidFieldEditor = new dialogs::AsteroidEditorDialog(this, _viewport);
22712271
asteroidFieldEditor->setAttribute(Qt::WA_DeleteOnClose);
2272+
connect(asteroidFieldEditor, &QDialog::finished, this, [this]() { fred->updateAllViewports(); });
22722273
asteroidFieldEditor->show();
22732274
}
22742275
void FredView::on_actionVolumetric_Nebula_triggered(bool)

qtfred/src/ui/dialogs/BackgroundEditorDialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ void BackgroundEditorDialog::on_noCullCheckBox_toggled(bool checked)
919919
_model->setSkyboxNoCull(checked);
920920
}
921921

922-
void BackgroundEditorDialog::on_noGlowmapsCheckBox_toggled(bool checked)
922+
void BackgroundEditorDialog::on_noGlowMapsCheckBox_toggled(bool checked)
923923
{
924924
_model->setSkyboxNoGlowmaps(checked);
925925
}

qtfred/src/ui/dialogs/BackgroundEditorDialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private slots:
9292
void on_forceClampCheckBox_toggled(bool checked);
9393
void on_noZBufferCheckBox_toggled(bool checked);
9494
void on_noCullCheckBox_toggled(bool checked);
95-
void on_noGlowmapsCheckBox_toggled(bool checked);
95+
void on_noGlowMapsCheckBox_toggled(bool checked);
9696

9797
// Misc
9898
void on_numStarsSlider_valueChanged(int value);

qtfred/src/ui/dialogs/MissionSpecDialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void MissionSpecDialog::updateFlags()
145145
toWidget.reserve(static_cast<int>(flags.size()));
146146
for (const auto& p : flags) {
147147
QString name = QString::fromUtf8(p.first.c_str());
148-
toWidget.append({name, p.second});
148+
toWidget.append({name, p.second ? Qt::Checked : Qt::Unchecked});
149149
}
150150

151151
ui->flagList->setFlags(toWidget);

0 commit comments

Comments
 (0)