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
23 changes: 23 additions & 0 deletions code/mission/missionparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5803,11 +5803,34 @@ void parse_waypoint_list(mission *pm)
required_string("$Name:");
stuff_string(name_buf, F_NAME, NAME_LENGTH);

bool no_draw_lines = false;
if (optional_string("+No Draw Lines:"))
stuff_boolean(&no_draw_lines);

bool has_custom_color = false;
int cr = 255, cg = 255, cb = 255;
if (optional_string("+Color:")) {
has_custom_color = true;
stuff_int(&cr);
stuff_int(&cg);
stuff_int(&cb);
}

SCP_vector<vec3d> vec_list;
required_string("$List:");
stuff_vec3d_list(vec_list);

waypoint_add_list(name_buf, vec_list);

// Apply display properties to the list just added
if (no_draw_lines || has_custom_color) {
waypoint_list* wl = find_matching_waypoint_list(name_buf);
if (wl) {
wl->set_no_draw_lines(no_draw_lines);
if (has_custom_color)
wl->set_color(cr, cg, cb);
}
}
}

void parse_waypoints_and_jumpnodes(mission *pm)
Expand Down
21 changes: 21 additions & 0 deletions code/missioneditor/missionsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4816,6 +4816,27 @@ int Fred_mission_save::save_waypoints()
parse_comments(first_wpt_list ? 1 : 2);
fout(" %s", ii.get_name());

if (save_config.save_format != MissionFormat::RETAIL) {

int nol_in_file = optional_string_fred("+No Draw Lines:", "$List:");
if (nol_in_file)
parse_comments();
if (nol_in_file || ii.get_no_draw_lines()) {
if (!nol_in_file)
fout("\n+No Draw Lines:");
fout(" %s", ii.get_no_draw_lines() ? "true" : "false");
}

if (ii.get_has_custom_color()) {
if (optional_string_fred("+Color:", "$List:")) {
parse_comments();
} else {
fout("\n+Color:");
}
fout(" %d %d %d", ii.get_color_r(), ii.get_color_g(), ii.get_color_b());
}
}

required_string_fred("$List:");
parse_comments();
fout(" (\t\t;! %d points in list\n", ii.get_waypoints().size());
Expand Down
49 changes: 49 additions & 0 deletions code/object/waypoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,19 @@ void waypoint::set_pos(const vec3d *pos)
waypoint_list::waypoint_list()
{
this->m_name[0] = '\0';
this->m_no_draw_lines = false;
this->m_has_custom_color = false;
this->m_color_r = this->m_color_g = this->m_color_b = 255;
}

waypoint_list::waypoint_list(const char *name)
{
Assert(name != NULL);
Assert(find_matching_waypoint_list(name) == NULL);
strcpy_s(this->m_name, name);
this->m_no_draw_lines = false;
this->m_has_custom_color = false;
this->m_color_r = this->m_color_g = this->m_color_b = 255;
}

waypoint_list::~waypoint_list()
Expand Down Expand Up @@ -137,6 +143,49 @@ void waypoint_list::set_name(const char *name)
this->m_name[len] = '\0';
}

void waypoint_list::set_no_draw_lines(bool val)
{
m_no_draw_lines = val;
}

void waypoint_list::set_color(int r, int g, int b)
{
m_color_r = r;
m_color_g = g;
m_color_b = b;
m_has_custom_color = true;
}

void waypoint_list::clear_color()
{
m_has_custom_color = false;
}

bool waypoint_list::get_no_draw_lines() const
{
return m_no_draw_lines;
}

bool waypoint_list::get_has_custom_color() const
{
return m_has_custom_color;
}

int waypoint_list::get_color_r() const
{
return m_color_r;
}

int waypoint_list::get_color_g() const
{
return m_color_g;
}

int waypoint_list::get_color_b() const
{
return m_color_b;
}

//********************FUNCTIONS********************
void waypoint_level_close()
{
Expand Down
13 changes: 13 additions & 0 deletions code/object/waypoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,23 @@ class waypoint_list

// mutators
void set_name(const char *name);
void set_no_draw_lines(bool val);
void set_color(int r, int g, int b);
void clear_color();

// display property accessors
bool get_no_draw_lines() const;
bool get_has_custom_color() const;
int get_color_r() const;
int get_color_g() const;
int get_color_b() const;

private:
char m_name[NAME_LENGTH];
SCP_vector<waypoint> m_waypoints;
bool m_no_draw_lines;
bool m_has_custom_color;
int m_color_r, m_color_g, m_color_b;
};

//********************GLOBALS********************
Expand Down
26 changes: 18 additions & 8 deletions qtfred/src/mission/FredRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,9 +968,16 @@ void FredRenderer::render_one_model_htl(object* objp,
g = 127;
b = 0;
} else if (objp->type == OBJ_WAYPOINT) {
r = 96;
g = 0;
b = 112;
waypoint_list* wpt_list = find_waypoint_list_with_instance(objp->instance);
if (wpt_list && wpt_list->get_has_custom_color()) {
r = wpt_list->get_color_r();
g = wpt_list->get_color_g();
b = wpt_list->get_color_b();
} else {
r = 96;
g = 0;
b = 112;
}
} else if (objp->type == OBJ_POINT) {
if (objp->instance != BRIEFING_LOOKAT_POINT_ID) {
///! \fixme Briefing stuff!
Expand Down Expand Up @@ -1004,11 +1011,14 @@ void FredRenderer::render_one_model_htl(object* objp,
}

if (objp->type == OBJ_WAYPOINT) {
for (auto objIdx : rendering_order) {
o2 = &Objects[objIdx];
if (o2->type == OBJ_WAYPOINT) {
if ((o2->instance == objp->instance - 1) || (o2->instance == objp->instance + 1)) {
g3_draw_htl_line(&o2->pos, &objp->pos);
waypoint_list* wpt_list = find_waypoint_list_with_instance(objp->instance);
if (!wpt_list || !wpt_list->get_no_draw_lines()) {
for (auto objIdx : rendering_order) {
o2 = &Objects[objIdx];
if (o2->type == OBJ_WAYPOINT) {
if ((o2->instance == objp->instance - 1) || (o2->instance == objp->instance + 1)) {
g3_draw_htl_line(&o2->pos, &objp->pos);
}
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions qtfred/src/mission/dialogs/WaypointEditorDialogModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ bool WaypointEditorDialogModel::apply()
}
}

// apply display properties
_editor->cur_waypoint_list->set_no_draw_lines(_noDrawLines);
if (_hasCustomColor)
_editor->cur_waypoint_list->set_color((ubyte)_colorR, (ubyte)_colorG, (ubyte)_colorB);
else
_editor->cur_waypoint_list->clear_color();

_editor->missionChanged();

return true;
}

Expand All @@ -61,8 +70,16 @@ void WaypointEditorDialogModel::initializeData()

if (_editor->cur_waypoint_list != nullptr) {
_currentName = _editor->cur_waypoint_list->get_name();
_noDrawLines = _editor->cur_waypoint_list->get_no_draw_lines();
_hasCustomColor = _editor->cur_waypoint_list->get_has_custom_color();
_colorR = _editor->cur_waypoint_list->get_color_r();
_colorG = _editor->cur_waypoint_list->get_color_g();
_colorB = _editor->cur_waypoint_list->get_color_b();
} else {
_currentName = "";
_noDrawLines = false;
_hasCustomColor = false;
_colorR = _colorG = _colorB = 255;
_enabled = false;
}

Expand Down Expand Up @@ -223,4 +240,17 @@ const SCP_vector<std::pair<SCP_string, int>>& WaypointEditorDialogModel::getWayp
return _waypointPathList;
}

bool WaypointEditorDialogModel::getNoDrawLines() const { return _noDrawLines; }
void WaypointEditorDialogModel::setNoDrawLines(bool val) { modify(_noDrawLines, val); }

bool WaypointEditorDialogModel::getHasCustomColor() const { return _hasCustomColor; }
void WaypointEditorDialogModel::setHasCustomColor(bool val) { modify(_hasCustomColor, val); }

int WaypointEditorDialogModel::getColorR() const { return _colorR; }
int WaypointEditorDialogModel::getColorG() const { return _colorG; }
int WaypointEditorDialogModel::getColorB() const { return _colorB; }
void WaypointEditorDialogModel::setColorR(int r) { modify(_colorR, r); }
void WaypointEditorDialogModel::setColorG(int g) { modify(_colorG, g); }
void WaypointEditorDialogModel::setColorB(int b) { modify(_colorB, b); }

} // namespace fso::fred::dialogs
16 changes: 15 additions & 1 deletion qtfred/src/mission/dialogs/WaypointEditorDialogModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@ class WaypointEditorDialogModel: public AbstractDialogModel {
void setCurrentName(const SCP_string& name);
int getCurrentlySelectedPath() const;
void setCurrentlySelectedPath(int elementId);


bool getNoDrawLines() const;
void setNoDrawLines(bool val);
bool getHasCustomColor() const;
void setHasCustomColor(bool val);
int getColorR() const;
int getColorG() const;
int getColorB() const;
void setColorR(int r);
void setColorG(int g);
void setColorB(int b);

bool isEnabled() const;
const SCP_vector<std::pair<SCP_string, int>>& getWaypointPathList() const;

Expand All @@ -40,6 +51,9 @@ private slots:
bool _enabled = false;
SCP_vector<std::pair<SCP_string, int>> _waypointPathList;
bool _bypass_errors = false;
bool _noDrawLines = false;
bool _hasCustomColor = false;
int _colorR = 255, _colorG = 255, _colorB = 255;
};

} // namespace fso::fred::dialogs
64 changes: 63 additions & 1 deletion qtfred/src/ui/dialogs/WaypointEditorDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ void WaypointEditorDialog::initializeUi()
util::SignalBlockers blockers(this);

updateWaypointListComboBox();
ui->nameEdit->setEnabled(_model->isEnabled());
bool enabled = _model->isEnabled();
ui->nameEdit->setEnabled(enabled);
ui->noDrawLinesCheck->setEnabled(enabled);
ui->customColorCheck->setEnabled(enabled);
}

void WaypointEditorDialog::updateWaypointListComboBox()
Expand All @@ -55,6 +58,28 @@ void WaypointEditorDialog::updateUi()
util::SignalBlockers blockers(this);
ui->nameEdit->setText(QString::fromStdString(_model->getCurrentName()));
ui->pathSelection->setCurrentIndex(ui->pathSelection->findData(_model->getCurrentlySelectedPath()));

ui->noDrawLinesCheck->setChecked(_model->getNoDrawLines());
ui->customColorCheck->setChecked(_model->getHasCustomColor());
ui->colorRSpinBox->setValue(_model->getColorR());
ui->colorGSpinBox->setValue(_model->getColorG());
ui->colorBSpinBox->setValue(_model->getColorB());

bool colorEnabled = _model->isEnabled() && _model->getHasCustomColor();
ui->colorRSpinBox->setEnabled(colorEnabled);
ui->colorGSpinBox->setEnabled(colorEnabled);
ui->colorBSpinBox->setEnabled(colorEnabled);

updateColorSwatch();
}

void WaypointEditorDialog::updateColorSwatch()
{
ui->colorSwatch->setStyleSheet(QString("background: rgb(%1,%2,%3);"
"border: 1px solid #444; border-radius: 3px;")
.arg(_model->getColorR())
.arg(_model->getColorG())
.arg(_model->getColorB()));
}

void WaypointEditorDialog::on_pathSelection_currentIndexChanged(int index)
Expand Down Expand Up @@ -86,4 +111,41 @@ void WaypointEditorDialog::on_nameEdit_editingFinished()
}
}

void WaypointEditorDialog::on_noDrawLinesCheck_toggled(bool checked)
{
_model->setNoDrawLines(checked);
_model->apply();
}

void WaypointEditorDialog::on_customColorCheck_toggled(bool checked)
{
_model->setHasCustomColor(checked);
ui->colorRSpinBox->setEnabled(checked);
ui->colorGSpinBox->setEnabled(checked);
ui->colorBSpinBox->setEnabled(checked);
updateColorSwatch();
_model->apply();
}

void WaypointEditorDialog::on_colorRSpinBox_valueChanged(int value)
{
_model->setColorR(value);
updateColorSwatch();
_model->apply();
}

void WaypointEditorDialog::on_colorGSpinBox_valueChanged(int value)
{
_model->setColorG(value);
updateColorSwatch();
_model->apply();
}

void WaypointEditorDialog::on_colorBSpinBox_valueChanged(int value)
{
_model->setColorB(value);
updateColorSwatch();
_model->apply();
}

} // namespace fso::fred::dialogs
8 changes: 7 additions & 1 deletion qtfred/src/ui/dialogs/WaypointEditorDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class WaypointEditorDialog : public QDialog {
private slots:
void on_pathSelection_currentIndexChanged(int index);
void on_nameEdit_editingFinished();
void on_noDrawLinesCheck_toggled(bool checked);
void on_customColorCheck_toggled(bool checked);
void on_colorRSpinBox_valueChanged(int value);
void on_colorGSpinBox_valueChanged(int value);
void on_colorBSpinBox_valueChanged(int value);

private: // NOLINT(readability-redundant-access-specifiers)
EditorViewport* _viewport;
Expand All @@ -26,7 +31,8 @@ private slots:

void initializeUi();
void updateWaypointListComboBox();
void updateUi();
void updateUi();
void updateColorSwatch();
};

} // namespace fso::fred::dialogs
Expand Down
Loading
Loading