Skip to content

Commit 279f3b2

Browse files
committed
Add Change Side to Convert
1 parent 09952f5 commit 279f3b2

File tree

6 files changed

+35
-0
lines changed

6 files changed

+35
-0
lines changed

src/Editor/Action.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ void Action::perform(Type action) {
213213
gEditing->changeHoldsToRolls();
214214
CASE(CHANGE_BETWEEN_PLAYER_NUMBERS)
215215
gEditing->changePlayerNumber();
216+
CASE(CHANGE_SIDE)
217+
gEditing->changeSide();
216218

217219
CASE(MIRROR_NOTES_VERTICALLY)
218220
gEditing->mirrorNotes(Editing::MIRROR_V);

src/Editor/Action.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ enum Type {
115115
CHANGE_HOLDS_TO_MINES,
116116
CHANGE_BETWEEN_HOLDS_AND_ROLLS,
117117
CHANGE_BETWEEN_PLAYER_NUMBERS,
118+
CHANGE_SIDE,
118119

119120
MIRROR_NOTES_VERTICALLY,
120121
MIRROR_NOTES_HORIZONTALLY,

src/Editor/Editing.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,35 @@ struct EditingImpl : public Editing {
542542
gNotes->modify(edit, false, desc);
543543
}
544544

545+
void changeNoteSide() {
546+
Style* style = gStyle->get();
547+
548+
if (!style) {
549+
HudNote("No style is currently active.");
550+
return;
551+
}
552+
553+
if (style->numCols != 8) {
554+
HudNote("Switch side is only available in a double style.");
555+
return;
556+
}
557+
558+
NoteEdit edit;
559+
gSelection->getSelectedNotes(edit.add);
560+
for (auto& n : edit.add) {
561+
if (n.col <= 3) {
562+
n.col += 4;
563+
} else {
564+
n.col -= 4;
565+
}
566+
}
567+
568+
static const NotesMan::EditDescription desc = {
569+
"Switched side for %1 note.", "Switched side for %1 notes."};
570+
gEditing->deleteSelection();
571+
gNotes->modify(edit, true, &desc);
572+
}
573+
545574
template <typename T>
546575
static T readFromBuffer(Vector<uint8_t>& buffer, int& pos) {
547576
if (pos + sizeof(T) <= buffer.size()) {

src/Editor/Editing.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct Editing : public InputHandler {
3939
virtual void changeHoldsToType(NoteType type) = 0;
4040
virtual void changeHoldsToRolls() = 0;
4141
virtual void changePlayerNumber() = 0;
42+
virtual void changeSide() = 0;
4243

4344
virtual void mirrorNotes(MirrorType type) = 0;
4445
virtual void scaleNotes(int numerator, int denominator) = 0;

src/Editor/Menubar.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ struct MenuBarImpl : public Menubar {
190190
add(hNoteConvert, CHANGE_HOLDS_TO_MINES, L"Holds \x2192 Mines");
191191
sep(hNoteConvert);
192192
add(hNoteConvert, CHANGE_BETWEEN_PLAYER_NUMBERS, L"Switch Player");
193+
add(hNoteConvert, CHANGE_SIDE, L"Switch Sides");
193194

194195
// Notes > Mirror menu.
195196
Item* hNoteMirror = newMenu();

src/Editor/Shortcuts.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ static ActionEntry actionMap[] = {
241241
E(CHANGE_HOLDS_TO_MINES)
242242
E(CHANGE_BETWEEN_HOLDS_AND_ROLLS)
243243
E(CHANGE_BETWEEN_PLAYER_NUMBERS)
244+
E(CHANGE_SIDE)
244245

245246
E(MIRROR_NOTES_VERTICALLY)
246247
E(MIRROR_NOTES_HORIZONTALLY)

0 commit comments

Comments
 (0)