Skip to content

Commit

Permalink
Make auto-offset on line split optional
Browse files Browse the repository at this point in the history
Closes #511
  • Loading branch information
sirjuddington committed Sep 21, 2016
1 parent 6e3a939 commit 6bc88ef
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/Dialogs/Preferences/MapEditorPrefsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)


/*******************************************************************
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand All @@ -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();
}
1 change: 1 addition & 0 deletions src/Dialogs/Preferences/MapEditorPrefsPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 13 additions & 4 deletions src/MapEditor/SLADEMap/SLADEMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
#define IDEQ(x) (((x) != 0) && ((x) == id))


/*******************************************************************
* VARIABLES
*******************************************************************/
CVAR(Bool, map_split_auto_offset, true, CVAR_SAVE)


/*******************************************************************
* SLADEMAP CLASS FUNCTIONS
*******************************************************************/
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 6bc88ef

Please sign in to comment.