diff --git a/source/code/puzzle_editor/PuzzleEditorState.cpp b/source/code/puzzle_editor/PuzzleEditorState.cpp index db6ff40..f58f48b 100644 --- a/source/code/puzzle_editor/PuzzleEditorState.cpp +++ b/source/code/puzzle_editor/PuzzleEditorState.cpp @@ -254,7 +254,6 @@ void PuzzleEditorState::Draw(SDL_Renderer* target) { } } - ImGui::End(); ImGui::Begin("Puzzles in file"); int puzzle_count = PuzzleGetNumberOfPuzzles(); @@ -263,6 +262,12 @@ void PuzzleEditorState::Draw(SDL_Renderer* target) { this->selected_puzzle = i; } } + if (ImGui::Button("Add puzzle")) { + EditorAddPuzzle(this->selected_puzzle); + } + if (ImGui::Button("Remove puzzle")) { + EditorRemovePuzzle(this->selected_puzzle); + } ImGui::End(); ImGui::Begin("Palette"); @@ -280,7 +285,7 @@ void PuzzleEditorState::Draw(SDL_Renderer* target) { if (ImGui::Selectable("Move Up", this->selected_action == selection_move_up)) { this->selected_action = selection_move_up; } - if (ImGui::Selectable("Move down", this->selected_action == selection_move_down)) { + /*if (ImGui::Selectable("Move down", this->selected_action == selection_move_down)) { this->selected_action = selection_move_down; } if (ImGui::Selectable("Move left", this->selected_action == selection_move_left)) { @@ -288,7 +293,7 @@ void PuzzleEditorState::Draw(SDL_Renderer* target) { } if (ImGui::Selectable("Move right", this->selected_action == selection_move_right)) { this->selected_action = selection_move_right; - } + }*/ ImGui::Separator(); ImGui::LabelText("moves allowed", "%i", PuzzleNumberOfMovesAllowed(this->selected_puzzle)); if (ImGui::Button("+1 move")) { diff --git a/source/code/puzzlehandler.cpp b/source/code/puzzlehandler.cpp index 9e8abeb..f05ce4a 100644 --- a/source/code/puzzlehandler.cpp +++ b/source/code/puzzlehandler.cpp @@ -165,4 +165,26 @@ int SavePuzzleStages() { } sago::WriteFileContent(((std::string)("puzzles/"+puzzleName)).c_str(), fileContent); return 0; +} + +void EditorRemovePuzzle(size_t level) { + if (level >= nrOfPuzzles) { + return; + } + //Shift all puzzles up. + memmove(puzzleLevels[level], puzzleLevels[level+1], sizeof(puzzleLevels[0])*(nrOfPuzzles-level-1)); + nrOfPuzzles--; +} + +void EditorAddPuzzle(size_t level) { + if (nrOfPuzzles >= 50) { + return; + } + memmove( puzzleLevels[level+1], puzzleLevels[level], sizeof(puzzleLevels[0])*(50-level-1) ); + nrOfPuzzles++; + for (size_t i = 0; i < 6; i++) { + for (size_t j =0; j < 12; j++) { + puzzleLevels[level][i][j] = -1; + } + } } \ No newline at end of file diff --git a/source/code/puzzlehandler.hpp b/source/code/puzzlehandler.hpp index 0f46cea..2e2b10d 100644 --- a/source/code/puzzlehandler.hpp +++ b/source/code/puzzlehandler.hpp @@ -39,5 +39,8 @@ void PuzzleSetClear(size_t level); const std::string& PuzzleGetName(); void PuzzleSetName(const std::string& name); +void EditorRemovePuzzle(size_t level); +void EditorAddPuzzle(size_t level); + #endif /* PUZZLEHANDLER_HPP */