Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions code/missioneditor/missionsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3152,6 +3152,19 @@ int Fred_mission_save::save_mission_info()
fso_comment_pop();
}

if (The_mission.gravity.xyz.y != 0.0f) {
fso_comment_push(";;FSO 23.0.0;;");
if (optional_string_fred("$Gravity Acceleration:")) {
parse_comments(2);
fout(" %f", -The_mission.gravity.xyz.y);
} else {
fout_version("\n\n$Gravity Acceleration: %f", -The_mission.gravity.xyz.y);
}
fso_comment_pop();
} else {
bypass_comment(";;FSO 23.0.0;; $Gravity Acceleration:");
}

return err;
}

Expand Down Expand Up @@ -3935,6 +3948,8 @@ int Fred_mission_save::save_objects()
fout(" \"no_collide\"");
if (shipp->flags[Ship::Ship_Flags::No_disabled_self_destruct])
fout(" \"no-disabled-self-destruct\"");
if (shipp->flags[Ship::Ship_Flags::Hide_mission_log])
fout(" \"hide-in-mission-log\"");
if (shipp->flags[Ship::Ship_Flags::Same_arrival_warp_when_docked])
fout(" \"same-arrival-warp-when-docked\"");
if (shipp->flags[Ship::Ship_Flags::Same_departure_warp_when_docked])
Expand Down
4 changes: 4 additions & 0 deletions fred2/missioncutscenesdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ int CMissionCutscenesDlg::onRootDeleted(int formula_node)
m_cutscenes.erase(m_cutscenes.begin() + i);
m_sig.erase(m_sig.begin() + i);

// if a row is left the tree selects it next and sets this again; if none is, the fields must not stay live
cur_cutscene = -1;
update_cur_cutscene();

return formula_node;
}
void CMissionCutscenesDlg::onRootInserted(int old_formula, int new_formula) { insert_handler(old_formula, new_formula); }
Expand Down
4 changes: 4 additions & 0 deletions fred2/missiongoalsdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ int CMissionGoalsDlg::onRootDeleted(int formula_node)
m_goals.erase(m_goals.begin() + i);
m_sig.erase(m_sig.begin() + i);

// if a row is left the tree selects it next and sets this again; if none is, the fields must not stay live
cur_goal = -1;
update_cur_goal();

return formula_node;
}
void CMissionGoalsDlg::onRootInserted(int old_formula, int new_formula) { insert_handler(old_formula, new_formula); }
Expand Down
2 changes: 2 additions & 0 deletions qtfred/src/mission/dialogs/MissionCutscenesDialogModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ void MissionCutscenesDialogModel::deleteCutscene(int node)
Assertion(i < m_cutscenes.size(), "Invalid cutscene index!");
m_cutscenes.erase(m_cutscenes.begin() + i);
m_sig.erase(m_sig.begin() + i);
// the index now names whichever cutscene moved into this slot, so none is current until one is selected
cur_cutscene = -1;

set_modified();
modelChanged();
Expand Down
2 changes: 1 addition & 1 deletion qtfred/src/mission/dialogs/MissionEventsDialogModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void MissionEventsDialogModel::initializeEvents()

// we must check for the case of the repeat count being 0. This would happen if the repeat
// count is not specified in a mission
if (m_events[i].repeat_count <= 0) {
if (m_events[i].repeat_count == 0) {
m_events[i].repeat_count = 1;
}
}
Expand Down
2 changes: 2 additions & 0 deletions qtfred/src/mission/dialogs/MissionGoalsDialogModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ void MissionGoalsDialogModel::deleteGoal(int node) {
Assert(i < m_goals.size());
m_goals.erase(m_goals.begin() + i);
m_sig.erase(m_sig.begin() + i);
// the index now names whichever goal moved into this slot, so no goal is current until one is selected
cur_goal = -1;

set_modified();
modelChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ ShipSpecialStatsDialogModel::ShipSpecialStatsDialogModel(QObject* parent, Editor
void ShipSpecialStatsDialogModel::initializeData()
{
object* objp;
_numSelectedShips = 0;
_selectedShips.resize(MAX_SHIPS);
_selectedShips.clear();

objp = GET_FIRST(&obj_used_list);
while (objp != END_OF_LIST(&obj_used_list)) {
if ((objp->type == OBJ_START) || (objp->type == OBJ_SHIP)) {
if (objp->flags[Object::Object_Flags::Marked]) {
_selectedShips[_numSelectedShips] = objp->instance;
_numSelectedShips++;
_selectedShips.push_back(objp->instance);
}
}
objp = GET_NEXT(objp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class ShipSpecialStatsDialogModel : public AbstractDialogModel {
void initializeData();

int _ship;
int _numSelectedShips;
SCP_vector<int> _selectedShips;

bool _specialExp;
Expand Down
1 change: 1 addition & 0 deletions qtfred/src/mission/dialogs/TeamLoadoutDialogModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ void TeamLoadoutDialogModel::initializeData()

// now merge in the data from Team_data
const auto& teamData = Team_data[i];
team.skipValidation = teamData.do_not_validate;

// first the ships
for (const auto &sc : teamData.ship_choices) {
Expand Down
7 changes: 6 additions & 1 deletion qtfred/src/ui/dialogs/MissionCutscenesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ void MissionCutscenesDialog::on_cutsceneFilename_textChanged(const QString& text
_model->setCurrentCutsceneFilename(text.toUtf8().constData());

auto item = ui->cutsceneEventTree->currentItem();
if (item == nullptr) {
return;
}
while (item->parent() != nullptr) {
item = item->parent();
}
Expand All @@ -219,9 +222,11 @@ void MissionCutscenesDialog::on_cutsceneEventTree_selectedRootChanged(int formul
for (size_t i = 0; i < cutscenes.size(); ++i) {
if (cutscenes[i].formula == formula) {
_model->setCurrentCutscene(static_cast<int>(i));
break;
return;
}
}
// the tree reports no row after a delete; without this the fields would keep editing another cutscene
_model->setCurrentCutscene(-1);
}

void MissionCutscenesDialog::on_cutsceneEventTree_rootNodeDeleted(int node)
Expand Down
7 changes: 7 additions & 0 deletions qtfred/src/ui/dialogs/MissionEventsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,8 @@ void MissionEventsDialog::initWaveFilenames() {
void MissionEventsDialog::initPersonas() {
auto list = _model->getPersonaList();

// filling the list selects its first entry, which must not be stored as the current message's persona
QSignalBlocker blocker(ui->personaCombo);
ui->personaCombo->clear();

for (auto&& [name, id] : _model->getPersonaList()) {
Expand All @@ -532,6 +534,8 @@ void MissionEventsDialog::initPersonas() {
void MissionEventsDialog::initMessageTeams() {
auto list = _model->getTeamList();

// as with the personas: filling the list must not store its first entry as the current message's team
QSignalBlocker blocker(ui->messageTeamCombo);
ui->messageTeamCombo->clear();

for (const auto& team : list) {
Expand All @@ -553,6 +557,9 @@ void MissionEventsDialog::initEventTeams()

void MissionEventsDialog::updateMessageUi()
{
// filling the fields from the model is not an edit, so the edit handlers must not run
util::SignalBlockers blockers(this);

bool enable = true;

if (!_model->messageIsValid()) {
Expand Down
17 changes: 11 additions & 6 deletions qtfred/src/ui/dialogs/MissionGoalsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void MissionGoalsDialog::updateUi()
ui->goalDescription->setText(QString::fromUtf8(goal.message.c_str()));
ui->goalTypeCombo->setCurrentIndex(goal.type & GOAL_TYPE_MASK);
ui->objectiveInvalidCheck->setChecked((goal.type & INVALID_GOAL) != 0);
ui->noCompletionMusicCheck->setChecked((goal.type & MGF_NO_MUSIC) != 0);
ui->noCompletionMusicCheck->setChecked((goal.flags & MGF_NO_MUSIC) != 0);
ui->goalScore->setValue(goal.score);
ui->goalTeamCombo->setCurrentIndex(goal.team);

Expand Down Expand Up @@ -187,6 +187,9 @@ void MissionGoalsDialog::on_goalName_textChanged(const QString& text)
_model->setCurrentGoalName(text.toUtf8().constData());

auto item = ui->goalEventTree->currentItem();
if (item == nullptr) {
return;
}
while (item->parent() != nullptr) {
item = item->parent();
}
Expand Down Expand Up @@ -214,17 +217,17 @@ void MissionGoalsDialog::on_goalTeamCombo_currentIndexChanged(int team)
}
}

void MissionGoalsDialog::on_objectiveInvalidCheck_stateChanged(bool checked)
void MissionGoalsDialog::on_objectiveInvalidCheck_stateChanged(int state)
{
if (_model->isCurrentGoalValid()) {
_model->setCurrentGoalInvalid(checked);
_model->setCurrentGoalInvalid(state == Qt::Checked);
}
}

void MissionGoalsDialog::on_noCompletionMusicCheck_stateChanged(bool checked)
void MissionGoalsDialog::on_noCompletionMusicCheck_stateChanged(int state)
{
if (_model->isCurrentGoalValid()) {
_model->setCurrentGoalNoMusic(checked);
_model->setCurrentGoalNoMusic(state == Qt::Checked);
}
}

Expand All @@ -239,9 +242,11 @@ void MissionGoalsDialog::on_goalEventTree_selectedRootChanged(int formula)
for (size_t i = 0; i < goals.size(); ++i) {
if (goals[i].formula == formula) {
_model->setCurrentGoal(static_cast<int>(i));
break;
return;
}
}
// the tree reports no row after a delete; without this the fields would keep editing another goal
_model->setCurrentGoal(-1);
}

void MissionGoalsDialog::on_goalEventTree_rootNodeDeleted(int node)
Expand Down
4 changes: 2 additions & 2 deletions qtfred/src/ui/dialogs/MissionGoalsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ private slots:
void on_goalDescription_textChanged(const QString& text);
void on_goalScore_valueChanged(int value);
void on_goalTeamCombo_currentIndexChanged(int team);
void on_objectiveInvalidCheck_stateChanged(bool checked);
void on_noCompletionMusicCheck_stateChanged(bool checked);
void on_objectiveInvalidCheck_stateChanged(int state);
void on_noCompletionMusicCheck_stateChanged(int state);
void on_newObjectiveBtn_clicked();

void on_goalEventTree_selectedRootChanged(int formula);
Expand Down
Loading