From 6bc88efef11ecdf0c89edd5e7dcffebcc7fc815c Mon Sep 17 00:00:00 2001 From: Simon Judd Date: Wed, 21 Sep 2016 12:03:58 +0930 Subject: [PATCH] Make auto-offset on line split optional Closes #511 --- src/Dialogs/Preferences/MapEditorPrefsPanel.cpp | 7 +++++++ src/Dialogs/Preferences/MapEditorPrefsPanel.h | 1 + src/MapEditor/SLADEMap/SLADEMap.cpp | 17 +++++++++++++---- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/Dialogs/Preferences/MapEditorPrefsPanel.cpp b/src/Dialogs/Preferences/MapEditorPrefsPanel.cpp index 5d1199fc6..91d397885 100644 --- a/src/Dialogs/Preferences/MapEditorPrefsPanel.cpp +++ b/src/Dialogs/Preferences/MapEditorPrefsPanel.cpp @@ -48,6 +48,7 @@ EXTERN_CVAR(Bool, mobj_props_auto_apply) EXTERN_CVAR(Bool, map_remove_invalid_lines) EXTERN_CVAR(Int, max_map_backups) EXTERN_CVAR(Bool, map_merge_lines_on_delete_vertex) +EXTERN_CVAR(Bool, map_split_auto_offset) /******************************************************************* @@ -96,6 +97,10 @@ MapEditorPrefsPanel::MapEditorPrefsPanel(wxWindow* parent) : PrefsPanelBase(pare cb_merge_lines_vertex_delete = new wxCheckBox(this, -1, "Merge connected lines when deleting a vertex"); sizer->Add(cb_merge_lines_vertex_delete, 0, wxEXPAND|wxALL, 4); + // Auto offset on line split + cb_split_auto_offset = new wxCheckBox(this, -1, "Automatic x-offset on line split"); + sizer->Add(cb_split_auto_offset, 0, wxEXPAND|wxALL, 4); + // Maximum backups wxBoxSizer* hbox = new wxBoxSizer(wxHORIZONTAL); sizer->Add(hbox, 0, wxEXPAND|wxALL, 4); @@ -125,6 +130,7 @@ void MapEditorPrefsPanel::init() cb_props_auto_apply->SetValue(mobj_props_auto_apply); cb_remove_invalid_lines->SetValue(map_remove_invalid_lines); cb_merge_lines_vertex_delete->SetValue(map_merge_lines_on_delete_vertex); + cb_split_auto_offset->SetValue(map_split_auto_offset); text_max_backups->setNumber(max_map_backups); } @@ -140,5 +146,6 @@ void MapEditorPrefsPanel::applyPreferences() mobj_props_auto_apply = cb_props_auto_apply->GetValue(); map_remove_invalid_lines = cb_remove_invalid_lines->GetValue(); map_merge_lines_on_delete_vertex = cb_merge_lines_vertex_delete->GetValue(); + map_split_auto_offset = cb_split_auto_offset->GetValue(); max_map_backups = text_max_backups->getNumber(); } diff --git a/src/Dialogs/Preferences/MapEditorPrefsPanel.h b/src/Dialogs/Preferences/MapEditorPrefsPanel.h index 818f9544e..b5918f060 100644 --- a/src/Dialogs/Preferences/MapEditorPrefsPanel.h +++ b/src/Dialogs/Preferences/MapEditorPrefsPanel.h @@ -15,6 +15,7 @@ class MapEditorPrefsPanel : public PrefsPanelBase wxCheckBox* cb_props_auto_apply; wxCheckBox* cb_remove_invalid_lines; wxCheckBox* cb_merge_lines_vertex_delete; + wxCheckBox* cb_split_auto_offset; NumberTextCtrl* text_max_backups; public: diff --git a/src/MapEditor/SLADEMap/SLADEMap.cpp b/src/MapEditor/SLADEMap/SLADEMap.cpp index 4f7e46ab4..07077b48f 100644 --- a/src/MapEditor/SLADEMap/SLADEMap.cpp +++ b/src/MapEditor/SLADEMap/SLADEMap.cpp @@ -45,6 +45,12 @@ #define IDEQ(x) (((x) != 0) && ((x) == id)) +/******************************************************************* + * VARIABLES + *******************************************************************/ +CVAR(Bool, map_split_auto_offset, true, CVAR_SAVE) + + /******************************************************************* * SLADEMAP CLASS FUNCTIONS *******************************************************************/ @@ -4404,10 +4410,13 @@ MapLine* SLADEMap::splitLine(MapLine* l, MapVertex* v) lines.push_back(nl); // Update x-offsets - int xoff1 = l->intProperty("side1.offsetx"); - int xoff2 = l->intProperty("side2.offsetx"); - nl->setIntProperty("side1.offsetx", xoff1 + l->getLength()); - l->setIntProperty("side2.offsetx", xoff2 + nl->getLength()); + if (map_split_auto_offset) + { + int xoff1 = l->intProperty("side1.offsetx"); + int xoff2 = l->intProperty("side2.offsetx"); + nl->setIntProperty("side1.offsetx", xoff1 + l->getLength()); + l->setIntProperty("side2.offsetx", xoff2 + nl->getLength()); + } geometry_updated = theApp->runTimer();