git repos / blockattack-game

commit 520e8c44

Poul Sander · 2025-06-29 18:16
520e8c4479c425519a3cbff3aee16b4b61b28dee patch · browse files
parent af6d5a44baf6f0efa1de8f7991ebc312ebfcbc21

Make it possible to adjust the number of puzzles up and down

Changed files

M source/code/puzzle_editor/PuzzleEditorState.cpp before
M source/code/puzzlehandler.cpp before
M source/code/puzzlehandler.hpp before
diff --git a/source/code/puzzle_editor/PuzzleEditorState.cpp b/source/code/puzzle_editor/PuzzleEditorState.cpp index 42b8200..db6ff40 100644 --- a/source/code/puzzle_editor/PuzzleEditorState.cpp +++ b/source/code/puzzle_editor/PuzzleEditorState.cpp
@@ -291,6 +291,14 @@ void PuzzleEditorState::Draw(SDL_Renderer* target) {
}
ImGui::Separator();
ImGui::LabelText("moves allowed", "%i", PuzzleNumberOfMovesAllowed(this->selected_puzzle));
+ if (ImGui::Button("+1 move")) {
+ PuzzleNumberOfMovesAllowedSet(this->selected_puzzle, PuzzleNumberOfMovesAllowed(this->selected_puzzle)+1);
+ SavePuzzleStages();
+ }
+ if (ImGui::Button("-1 move")) {
+ PuzzleNumberOfMovesAllowedSet(this->selected_puzzle, PuzzleNumberOfMovesAllowed(this->selected_puzzle)-1);
+ SavePuzzleStages();
+ }
ImGui::Separator();
if (read_only) {
ImGui::LabelText("Read Only", "");
diff --git a/source/code/puzzlehandler.cpp b/source/code/puzzlehandler.cpp index afabe66..9e8abeb 100644 --- a/source/code/puzzlehandler.cpp +++ b/source/code/puzzlehandler.cpp
@@ -49,6 +49,13 @@ int PuzzleNumberOfMovesAllowed(size_t level) {
return nrOfMovesAllowed.at(level);
}
+void PuzzleNumberOfMovesAllowedSet(size_t level, int numbler_of_moves) {
+ if (level >= nrOfMovesAllowed.size()) {
+ return;
+ }
+ nrOfMovesAllowed[level] = numbler_of_moves;
+}
+
int PuzzleGetBrick(size_t level, int x, int y) {
if (level >= maxNrOfPuzzleStages || x >= 6 || y >= 12 || x < 0 || y < 0) {
return -1;
diff --git a/source/code/puzzlehandler.hpp b/source/code/puzzlehandler.hpp index 707b7f4..0f46cea 100644 --- a/source/code/puzzlehandler.hpp +++ b/source/code/puzzlehandler.hpp
@@ -28,6 +28,7 @@ http://www.blockattack.net
#include <string>
int PuzzleNumberOfMovesAllowed(size_t level);
+void PuzzleNumberOfMovesAllowedSet(size_t level, int numbler_of_moves);
int PuzzleGetBrick(size_t level, int x, int y);
void PuzzleSetBrick(size_t level, int x, int y, int brick); // used only for editor
bool PuzzleIsCleared(size_t level);