From 7e97510f31e8d28ff989e1bfbfcf1ba2c4fba4f1 Mon Sep 17 00:00:00 2001 From: NaiJi Date: Thu, 12 Aug 2021 22:10:52 +0300 Subject: [PATCH] Add editor state --- src/application.cpp | 5 ++- src/gui/editor.cpp | 61 +++++++++++++++++++++++++++++++++++++ src/gui/editor.h | 35 +++++++++++++++++++++ src/gui/mainmenu.h | 2 +- src/tools/bpmcalculator.cpp | 7 +++++ src/tools/musicsfml.cpp | 2 +- 6 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 src/gui/editor.cpp create mode 100644 src/gui/editor.h diff --git a/src/application.cpp b/src/application.cpp index a6a067b..1a1e75f 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -6,6 +6,7 @@ #include "gui/mainmenu.h" #include "gui/gamestate.h" +#include "gui/editor.h" #include "tools/musicsfml.h" @@ -22,12 +23,14 @@ Application::Application() : _game_window.setMouseCursorGrabbed(false); _game_window.setVerticalSyncEnabled(true); - MainMenu::Callbacks callbacks = {[&](){ emplaceState(GUIState::Tag::GAME); }}; + MainMenu::Callbacks callbacks = {[&](){ emplaceState(GUIState::Tag::EDITOR); }}; const auto main_menu = std::make_shared(_game_window, std::move(callbacks)); const auto game_state = std::make_shared(_game_window, _game, GameState::Callbacks()); + const auto editor = std::make_shared(_game_window, Editor::Callbacks(), std::make_unique()); _states[GUIState::Tag::MAIN_MENU] = main_menu; _states[GUIState::Tag::GAME] = game_state; + _states[GUIState::Tag::EDITOR] = editor; _state_stack.emplace_back(_states.at(GUIState::Tag::MAIN_MENU)); } diff --git a/src/gui/editor.cpp b/src/gui/editor.cpp new file mode 100644 index 0000000..8b71126 --- /dev/null +++ b/src/gui/editor.cpp @@ -0,0 +1,61 @@ +#include "editor.h" +#include "widgets/button.h" +#include "widgets/group.h" +#include "tools/bpmcalculator.h" + +#include + +Editor::Editor(sf::RenderWindow& game_window, Callbacks&& callbacks, std::unique_ptr&& music) : + _buttons(std::make_shared()), + _game_window(game_window), + _music(std::move(music)), + _bpm_calculator(std::make_unique(_music)) +{ + (void)callbacks; + const float window_width = game_window.getSize().x; + const float window_height = game_window.getSize().y; + + _music->openFromFile("Uta-test.flac"); + _music->setVolume(20); + + std::shared_ptr