diff --git a/source/code/BlockGameSdl.hpp b/source/code/BlockGameSdl.hpp index 7ef6ff9..f93c3da 100644 --- a/source/code/BlockGameSdl.hpp +++ b/source/code/BlockGameSdl.hpp @@ -21,6 +21,8 @@ https://blockattack.net =========================================================================== */ +#pragma once + #include "BlockGame.hpp" #include "global.hpp" #include "sago/SagoTextField.hpp" diff --git a/source/code/puzzle_editor/PuzzleEditorState.cpp b/source/code/puzzle_editor/PuzzleEditorState.cpp index 0778712..1eaf298 100644 --- a/source/code/puzzle_editor/PuzzleEditorState.cpp +++ b/source/code/puzzle_editor/PuzzleEditorState.cpp @@ -40,6 +40,8 @@ void PuzzleEditorState::ProcessInput(const SDL_Event& event, bool& processed) { void PuzzleEditorState::Init() { this->selected_file = ""; this->puzzle_files = sago::GetFileList("puzzles"); + game = std::make_shared(globalData.xsize-450,100,&globalData.spriteHolder->GetDataHolder()); + game->name = "Player 1"; } void PuzzleEditorState::SelectFile(const std::string& file) { @@ -49,6 +51,10 @@ void PuzzleEditorState::SelectFile(const std::string& file) { } void PuzzleEditorState::Draw(SDL_Renderer* target) { + DrawBackground(target); + if (game) { + game->DoPaintJob(); + } ImGui::Begin("File list", nullptr, ImGuiWindowFlags_NoCollapse); for (const auto& file : this->puzzle_files) { if (ImGui::Selectable(file.c_str(), this->selected_file == file)) { @@ -61,7 +67,8 @@ void PuzzleEditorState::Draw(SDL_Renderer* target) { ImGui::Begin("Puzzles in file"); int puzzle_count = PuzzleGetNumberOfPuzzles(); for (int i = 0; i < puzzle_count; ++i) { - if (ImGui::Selectable(std::to_string(i).c_str(), false)) { + if (ImGui::Selectable(std::to_string(i).c_str(), this->selected_puzzle == i)) { + this->selected_puzzle = i; } } ImGui::End(); diff --git a/source/code/puzzle_editor/PuzzleEditorState.hpp b/source/code/puzzle_editor/PuzzleEditorState.hpp index 9dbe0d4..df2ef39 100644 --- a/source/code/puzzle_editor/PuzzleEditorState.hpp +++ b/source/code/puzzle_editor/PuzzleEditorState.hpp @@ -24,7 +24,9 @@ https://blockattack.net #pragma once +#include "../global.hpp" #include "../sago/GameStateInterface.hpp" +#include "../BlockGameSdl.hpp" #include #include @@ -46,6 +48,8 @@ private: void SelectFile(const std::string& file); bool isActive = true; + int selected_puzzle = -1; std::string selected_file; std::vector puzzle_files; + std::shared_ptr game; };