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
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ void ShipInitialStatusDialogModel::initializeData(bool multi)
_afterburnerLocked = Qt::Unchecked;
}

if (Ship_info[Ships[_ship].ship_info_index].uses_team_colors) {
_useTeams = true;
_teamColorSetting = Ships[_ship].team_name;
}

if (_multiEdit) {
objp = GET_FIRST(&obj_used_list);
while (objp != END_OF_LIST(&obj_used_list)) {
Expand All @@ -198,6 +203,10 @@ void ShipInitialStatusDialogModel::initializeData(bool multi)
sflag = 1;
if (static_cast<int>(objp->hull_strength) != _hull)
hflag = 1;
if (Ships[get_ship_from_obj(objp)].ship_guardian_threshold != _guardianThreshold)
_guardianInconsistent = true;
if (_useTeams && Ships[get_ship_from_obj(objp)].team_name != _teamColorSetting)
_teamColorInconsistent = true;
if (objp->flags[Object::Object_Flags::No_shields]) {
if (_hasShields)
_hasShields = Qt::PartiallyChecked;
Expand Down Expand Up @@ -273,20 +282,16 @@ void ShipInitialStatusDialogModel::initializeData(bool multi)
}
}

if (Ship_info[Ships[_ship].ship_info_index].uses_team_colors) {
_useTeams = true;
_teamColorSetting = Ships[_ship].team_name;
}
changeSubsys(0);

if (vflag) {
_velocity = BLANKFIELD;
}
if (vflag) {
_velocity = BLANKFIELD;
if (sflag) {
_shields = BLANKFIELD;
}
if (vflag) {
_velocity = BLANKFIELD;
if (hflag) {
_hull = BLANKFIELD;
}
_modified = false;
modelChanged();
Expand All @@ -295,6 +300,10 @@ void ShipInitialStatusDialogModel::initializeData(bool multi)

void ShipInitialStatusDialogModel::updateDockingInfo()
{
if (!_dockpointArray || _numDockPoints <= 0) {
return;
}

int i;
object* objp = &Objects[Ships[_ship].objnum];
for (i = 0; i < _numDockPoints; i++) {
Expand Down Expand Up @@ -587,19 +596,21 @@ bool ShipInitialStatusDialogModel::apply()
while (objp != END_OF_LIST(&obj_used_list)) {
if (((objp->type == OBJ_SHIP) || (objp->type == OBJ_START)) &&
(objp->flags[Object::Object_Flags::Marked])) {
modify(objp->phys_info.speed, (float)_velocity);

modify(objp->shield_quadrant[0], (float)_shields);

modify(objp->hull_strength, (float)_hull);
if (_velocity != BLANKFIELD)
modify(objp->phys_info.speed, (float)_velocity);
if (_shields != BLANKFIELD)
modify(objp->shield_quadrant[0], (float)_shields);
if (_hull != BLANKFIELD)
modify(objp->hull_strength, (float)_hull);

if (_hasShields == Qt::Checked) {
objp->flags.remove(Object::Object_Flags::No_shields);
} else if (_hasShields == Qt::Unchecked) {
objp->flags.set(Object::Object_Flags::No_shields);
}
auto shipp = &Ships[get_ship_from_obj(objp)];
shipp->ship_guardian_threshold = _guardianThreshold;
if (!_guardianInconsistent)
shipp->ship_guardian_threshold = _guardianThreshold;
// We need to ensure that we handle the inconsistent "boolean" value correctly
handle_inconsistent_flag(shipp->flags, Ship::Ship_Flags::Force_shields_on, _forceShields);
handle_inconsistent_flag(shipp->flags, Ship::Ship_Flags::Ship_locked, _shipLocked);
Expand All @@ -608,7 +619,8 @@ bool ShipInitialStatusDialogModel::apply()
handle_inconsistent_flag(shipp->flags, Ship::Ship_Flags::Secondaries_locked, _secondariesLocked);
handle_inconsistent_flag(shipp->flags, Ship::Ship_Flags::Lock_all_turrets_initially, _turretsLocked);
handle_inconsistent_flag(shipp->flags, Ship::Ship_Flags::Afterburner_locked, _afterburnerLocked);
shipp->team_name = _teamColorSetting;
if (!_teamColorInconsistent)
shipp->team_name = _teamColorSetting;
}

objp = GET_NEXT(objp);
Expand All @@ -632,7 +644,9 @@ bool ShipInitialStatusDialogModel::apply()
handle_inconsistent_flag(Ships[_ship].flags, Ship::Ship_Flags::Afterburner_locked, _afterburnerLocked);
Ships[_ship].team_name = _teamColorSetting;
}
updateDockingInfo();
if (!_multiEdit) {
updateDockingInfo();
}
_editor->missionChanged();
return true;
}
Expand Down Expand Up @@ -796,6 +810,7 @@ SCP_string ShipInitialStatusDialogModel::getColor() const

void ShipInitialStatusDialogModel::setColor(const SCP_string& color)
{
_teamColorInconsistent = false;
modify(_teamColorSetting, color);
}

Expand Down Expand Up @@ -916,6 +931,7 @@ int ShipInitialStatusDialogModel::getGuardian() const

void ShipInitialStatusDialogModel::setGuardian(int guardian)
{
_guardianInconsistent = false;
modify(_guardianThreshold, guardian);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ class ShipInitialStatusDialogModel : public AbstractDialogModel {
int _afterburnerLocked;
SCP_string _teamColorSetting;
int _shipHasScannableSubsystems;
int _numDockPoints;
int _numDockPoints = 0;
std::unique_ptr<dockpoint_information[]> _dockpointArray;
bool _multiEdit;
bool _multiEdit = false;
bool _useTeams = false;
bool _moveShipsWhenUndocking = true;
bool _guardianInconsistent = false;
bool _teamColorInconsistent = false;
};

template <typename T>
Expand Down
12 changes: 12 additions & 0 deletions qtfred/src/ui/dialogs/ShipEditor/ShipInitialStatusDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <globalincs/linklist.h>
#include <mission/object.h>
#include <qobject.h>
#include <ui/util/SignalBlockers.h>

#include <QCloseEvent>
Expand Down Expand Up @@ -174,31 +175,42 @@ void ShipInitialStatusDialog::on_moveShipsCheckBox_toggled(bool value)
void ShipInitialStatusDialog::updateUi()
{
util::SignalBlockers blockers(this);

auto value = _model->getVelocity();
if (value != BLANKFIELD) {
ui->velocitySpinBox->setSpecialValueText(QString());
ui->velocitySpinBox->setValue(value);
} else {
ui->velocitySpinBox->setSpecialValueText("-");
ui->velocitySpinBox->setValue(ui->velocitySpinBox->minimum());
}

value = _model->getHull();
if (value != BLANKFIELD) {
ui->hullSpinBox->setSpecialValueText(QString());
ui->hullSpinBox->setValue(value);
} else {
ui->hullSpinBox->setSpecialValueText("-");
ui->hullSpinBox->setValue(ui->hullSpinBox->minimum());
}

value = _model->getHasShield();
ui->hasShieldCheckBox->setCheckState(Qt::CheckState(value));
if (_model->getHasShield()) {
ui->shieldHullSpinBox->setEnabled(true);
} else {
ui->shieldHullSpinBox->setEnabled(false);
}

value = _model->getShieldHull();
if (value != BLANKFIELD) {
ui->shieldHullSpinBox->setSpecialValueText(QString());
ui->shieldHullSpinBox->setValue(value);
} else {
ui->shieldHullSpinBox->setSpecialValueText("-");
ui->shieldHullSpinBox->setValue(ui->shieldHullSpinBox->minimum());
}

ui->guardianSpinBox->setValue(_model->getGuardian());
updateFlags();
updateDocks();
Expand Down
Loading