34 remove UI (#35)Unverified
* removed ftxui * run help command when nothing provided --------- Co-authored-by: Adrian Duraj <adrian.duraj@onmail.com>
e7d18a4 parent: 89d42b6 modified
app/CMakeLists.txt +0 -19 | @@ -5,37 +5,21 @@ project(fluffy LANGUAGES CXX VERSION 1.0.0) | ||
| 5 | 5 | |
| 6 | 6 | include(FetchContent) |
| 7 | 7 | |
| 8 | -set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE) | |
| 9 | -FetchContent_Declare(ftxui | |
| 10 | - GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui | |
| 11 | - GIT_TAG v5.0.0 | |
| 12 | -) | |
| 13 | -FetchContent_MakeAvailable(ftxui) | |
| 14 | -if(NOT ftxui_POPULATED) | |
| 15 | - FetchContent_Populate(ftxui) | |
| 16 | - add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL) | |
| 17 | -endif() | |
| 18 | - | |
| 19 | - | |
| 20 | 8 | FetchContent_Declare(googletest |
| 21 | 9 | GIT_REPOSITORY https://github.com/google/googletest |
| 22 | 10 | GIT_TAG v1.14.0 |
| 23 | 11 | ) |
| 24 | 12 | FetchContent_MakeAvailable(googletest) |
| 25 | 13 | |
| 26 | - | |
| 27 | 14 | #find_program(CLANG_TIDY NAMES "clang-tidy" REQUIRED) |
| 28 | 15 | #set(CLANG_TIDY_COMMAND "${CLANG_TIDY}" "-checks=-*,modernize-*") |
| 29 | 16 | |
| 30 | - | |
| 31 | 17 | find_package(SQLite3 REQUIRED) |
| 32 | 18 | |
| 33 | 19 | include_directories(${CMAKE_SOURCE_DIR}/include) |
| 34 | 20 | enable_testing() |
| 35 | 21 | add_executable(fluffy src/main.cpp src/fluffyApplication.cpp) |
| 36 | 22 | |
| 37 | - | |
| 38 | - | |
| 39 | 23 | add_executable( |
| 40 | 24 | tests |
| 41 | 25 | tests/gameTest.cpp |
| @@ -46,9 +30,6 @@ target_link_libraries( | ||
| 46 | 30 | ) |
| 47 | 31 | |
| 48 | 32 | target_link_libraries(fluffy |
| 49 | - PRIVATE ftxui::screen | |
| 50 | - PRIVATE ftxui::dom | |
| 51 | - PRIVATE ftxui::component | |
| 52 | 33 | PRIVATE SQLite::SQLite3 |
| 53 | 34 | ) |
| 54 | 35 | #set_target_properties(fluffy PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}") |
| @@ -5,37 +5,21 @@ project(fluffy LANGUAGES CXX VERSION 1.0.0) | |||
| 5 | 5 | ||
| 6 | include(FetchContent) | 6 | include(FetchContent) |
| 7 | 7 | ||
| 8 | -set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE) | ||
| 9 | -FetchContent_Declare(ftxui | ||
| 10 | - GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui | ||
| 11 | - GIT_TAG v5.0.0 | ||
| 12 | -) | ||
| 13 | -FetchContent_MakeAvailable(ftxui) | ||
| 14 | -if(NOT ftxui_POPULATED) | ||
| 15 | - FetchContent_Populate(ftxui) | ||
| 16 | - add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL) | ||
| 17 | -endif() | ||
| 18 | - | ||
| 19 | - | ||
| 20 | FetchContent_Declare(googletest | 8 | FetchContent_Declare(googletest |
| 21 | GIT_REPOSITORY https://github.com/google/googletest | 9 | GIT_REPOSITORY https://github.com/google/googletest |
| 22 | GIT_TAG v1.14.0 | 10 | GIT_TAG v1.14.0 |
| 23 | ) | 11 | ) |
| 24 | FetchContent_MakeAvailable(googletest) | 12 | FetchContent_MakeAvailable(googletest) |
| 25 | 13 | ||
| 26 | - | ||
| 27 | #find_program(CLANG_TIDY NAMES "clang-tidy" REQUIRED) | 14 | #find_program(CLANG_TIDY NAMES "clang-tidy" REQUIRED) |
| 28 | #set(CLANG_TIDY_COMMAND "${CLANG_TIDY}" "-checks=-*,modernize-*") | 15 | #set(CLANG_TIDY_COMMAND "${CLANG_TIDY}" "-checks=-*,modernize-*") |
| 29 | 16 | ||
| 30 | - | ||
| 31 | find_package(SQLite3 REQUIRED) | 17 | find_package(SQLite3 REQUIRED) |
| 32 | 18 | ||
| 33 | include_directories(${CMAKE_SOURCE_DIR}/include) | 19 | include_directories(${CMAKE_SOURCE_DIR}/include) |
| 34 | enable_testing() | 20 | enable_testing() |
| 35 | add_executable(fluffy src/main.cpp src/fluffyApplication.cpp) | 21 | add_executable(fluffy src/main.cpp src/fluffyApplication.cpp) |
| 36 | 22 | ||
| 37 | - | ||
| 38 | - | ||
| 39 | add_executable( | 23 | add_executable( |
| 40 | tests | 24 | tests |
| 41 | tests/gameTest.cpp | 25 | tests/gameTest.cpp |
| @@ -46,9 +30,6 @@ target_link_libraries( | |||
| 46 | ) | 30 | ) |
| 47 | 31 | ||
| 48 | target_link_libraries(fluffy | 32 | target_link_libraries(fluffy |
| 49 | - PRIVATE ftxui::screen | ||
| 50 | - PRIVATE ftxui::dom | ||
| 51 | - PRIVATE ftxui::component | ||
| 52 | PRIVATE SQLite::SQLite3 | 33 | PRIVATE SQLite::SQLite3 |
| 53 | ) | 34 | ) |
| 54 | #set_target_properties(fluffy PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}") | 35 | #set_target_properties(fluffy PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}") |
modified
app/include/fluffyApplication.hpp +0 -15 | @@ -1,14 +1,5 @@ | ||
| 1 | 1 | #pragma once |
| 2 | 2 | |
| 3 | - | |
| 4 | -#include <ftxui/component/component.hpp> | |
| 5 | -#include <ftxui/component/component_base.hpp> | |
| 6 | -#include <ftxui/component/component_options.hpp> | |
| 7 | -#include <ftxui/component/screen_interactive.hpp> | |
| 8 | -#include <ftxui/dom/elements.hpp> | |
| 9 | -#include <ftxui/screen/screen.hpp> | |
| 10 | -#include <ftxui/screen/string.hpp> | |
| 11 | - | |
| 12 | 3 | #include <cstdlib> |
| 13 | 4 | #include <filesystem> |
| 14 | 5 | #include <iostream> |
| @@ -24,8 +15,6 @@ | ||
| 24 | 15 | #include <database.hpp> |
| 25 | 16 | #include <output.hpp> |
| 26 | 17 | |
| 27 | -using namespace ftxui; | |
| 28 | - | |
| 29 | 18 | class FluffyApplication { |
| 30 | 19 | public: |
| 31 | 20 | FluffyApplication(int argc, char const *argv[]); |
| @@ -43,10 +32,6 @@ private: | ||
| 43 | 32 | |
| 44 | 33 | auto handleCommand(const std::string& command, const std::vector<std::string>& arguments, Database& database) -> void; |
| 45 | 34 | |
| 46 | - auto style() -> ButtonOption; | |
| 47 | - | |
| 48 | - auto runConsoleApp() -> void; | |
| 49 | - | |
| 50 | 35 | auto handleFlags(std::vector<std::string> flags) -> void; |
| 51 | 36 | |
| 52 | 37 | auto getExecutablePath() -> std::filesystem::path; |
| @@ -1,14 +1,5 @@ | |||
| 1 | #pragma once | 1 | #pragma once |
| 2 | 2 | ||
| 3 | - | ||
| 4 | -#include <ftxui/component/component.hpp> | ||
| 5 | -#include <ftxui/component/component_base.hpp> | ||
| 6 | -#include <ftxui/component/component_options.hpp> | ||
| 7 | -#include <ftxui/component/screen_interactive.hpp> | ||
| 8 | -#include <ftxui/dom/elements.hpp> | ||
| 9 | -#include <ftxui/screen/screen.hpp> | ||
| 10 | -#include <ftxui/screen/string.hpp> | ||
| 11 | - | ||
| 12 | #include <cstdlib> | 3 | #include <cstdlib> |
| 13 | #include <filesystem> | 4 | #include <filesystem> |
| 14 | #include <iostream> | 5 | #include <iostream> |
| @@ -24,8 +15,6 @@ | |||
| 24 | #include <database.hpp> | 15 | #include <database.hpp> |
| 25 | #include <output.hpp> | 16 | #include <output.hpp> |
| 26 | 17 | ||
| 27 | -using namespace ftxui; | ||
| 28 | - | ||
| 29 | class FluffyApplication { | 18 | class FluffyApplication { |
| 30 | public: | 19 | public: |
| 31 | FluffyApplication(int argc, char const *argv[]); | 20 | FluffyApplication(int argc, char const *argv[]); |
| @@ -43,10 +32,6 @@ private: | |||
| 43 | 32 | ||
| 44 | auto handleCommand(const std::string& command, const std::vector<std::string>& arguments, Database& database) -> void; | 33 | auto handleCommand(const std::string& command, const std::vector<std::string>& arguments, Database& database) -> void; |
| 45 | 34 | ||
| 46 | - auto style() -> ButtonOption; | ||
| 47 | - | ||
| 48 | - auto runConsoleApp() -> void; | ||
| 49 | - | ||
| 50 | auto handleFlags(std::vector<std::string> flags) -> void; | 35 | auto handleFlags(std::vector<std::string> flags) -> void; |
| 51 | 36 | ||
| 52 | auto getExecutablePath() -> std::filesystem::path; | 37 | auto getExecutablePath() -> std::filesystem::path; |
modified
app/src/fluffyApplication.cpp +1 -50 | @@ -70,55 +70,6 @@ auto FluffyApplication::handleCommand(const std::string& command, const std::vec | ||
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | -auto FluffyApplication::style() -> ButtonOption { | |
| 74 | - auto option = ButtonOption::Border(); | |
| 75 | - option.transform = [](const EntryState &s) { | |
| 76 | - auto element = text(s.label); | |
| 77 | - if (s.focused) { | |
| 78 | - element |= bold; | |
| 79 | - } | |
| 80 | - return element | size(HEIGHT, LESS_THAN, 10); | |
| 81 | - }; | |
| 82 | - return option; | |
| 83 | -} | |
| 84 | - | |
| 85 | -auto FluffyApplication::runConsoleApp() -> void { | |
| 86 | - system("clear"); | |
| 87 | - | |
| 88 | - std::vector<std::string> localGames = {}; | |
| 89 | - for (auto &game : games) { | |
| 90 | - localGames.emplace_back(game.getName()); | |
| 91 | - } | |
| 92 | - localGames.emplace_back("Exit"); | |
| 93 | - | |
| 94 | - auto gamesContainer{Container::Vertical({})}; | |
| 95 | - for (auto &game : games) { | |
| 96 | - gamesContainer->Add(Button( | |
| 97 | - game.getName(), [&] { runGame(game.getName()); }, style())); | |
| 98 | - } | |
| 99 | - | |
| 100 | - auto menu_screen = ScreenInteractive::TerminalOutput(); | |
| 101 | - | |
| 102 | - auto quitButton = Button("Exit", menu_screen.ExitLoopClosure(), style()); | |
| 103 | - gamesContainer->Add(quitButton); | |
| 104 | - | |
| 105 | - int menuOptionSelected{0}; | |
| 106 | - auto appContainer = | |
| 107 | - Container::Tab({gamesContainer}, &menuOptionSelected); | |
| 108 | - | |
| 109 | - auto container = Container::Horizontal({ | |
| 110 | - appContainer, | |
| 111 | - }); | |
| 112 | - auto renderer = Renderer(container, [&] { | |
| 113 | - return vbox({ | |
| 114 | - center(text("Fluffy " + version)), | |
| 115 | - appContainer->Render(), | |
| 116 | - }) | | |
| 117 | - border | size(WIDTH, LESS_THAN, 120); | |
| 118 | - }); | |
| 119 | - menu_screen.Loop(renderer); | |
| 120 | - | |
| 121 | -} | |
| 122 | 73 | |
| 123 | 74 | auto FluffyApplication::handleFlags(std::vector<std::string> flags) -> void { |
| 124 | 75 | for (const auto& flag : flags) { |
| @@ -176,6 +127,6 @@ FluffyApplication::FluffyApplication(int argc, char const *argv[]) { | ||
| 176 | 127 | if (command != "") handleCommand(command, arguments, database); |
| 177 | 128 | } |
| 178 | 129 | else { |
| 179 | - runConsoleApp(); | |
| 130 | + handleCommand("--help", {}, database); | |
| 180 | 131 | } |
| 181 | 132 | } |
| @@ -70,55 +70,6 @@ auto FluffyApplication::handleCommand(const std::string& command, const std::vec | |||
| 70 | } | 70 | } |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | -auto FluffyApplication::style() -> ButtonOption { | ||
| 74 | - auto option = ButtonOption::Border(); | ||
| 75 | - option.transform = [](const EntryState &s) { | ||
| 76 | - auto element = text(s.label); | ||
| 77 | - if (s.focused) { | ||
| 78 | - element |= bold; | ||
| 79 | - } | ||
| 80 | - return element | size(HEIGHT, LESS_THAN, 10); | ||
| 81 | - }; | ||
| 82 | - return option; | ||
| 83 | -} | ||
| 84 | - | ||
| 85 | -auto FluffyApplication::runConsoleApp() -> void { | ||
| 86 | - system("clear"); | ||
| 87 | - | ||
| 88 | - std::vector<std::string> localGames = {}; | ||
| 89 | - for (auto &game : games) { | ||
| 90 | - localGames.emplace_back(game.getName()); | ||
| 91 | - } | ||
| 92 | - localGames.emplace_back("Exit"); | ||
| 93 | - | ||
| 94 | - auto gamesContainer{Container::Vertical({})}; | ||
| 95 | - for (auto &game : games) { | ||
| 96 | - gamesContainer->Add(Button( | ||
| 97 | - game.getName(), [&] { runGame(game.getName()); }, style())); | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - auto menu_screen = ScreenInteractive::TerminalOutput(); | ||
| 101 | - | ||
| 102 | - auto quitButton = Button("Exit", menu_screen.ExitLoopClosure(), style()); | ||
| 103 | - gamesContainer->Add(quitButton); | ||
| 104 | - | ||
| 105 | - int menuOptionSelected{0}; | ||
| 106 | - auto appContainer = | ||
| 107 | - Container::Tab({gamesContainer}, &menuOptionSelected); | ||
| 108 | - | ||
| 109 | - auto container = Container::Horizontal({ | ||
| 110 | - appContainer, | ||
| 111 | - }); | ||
| 112 | - auto renderer = Renderer(container, [&] { | ||
| 113 | - return vbox({ | ||
| 114 | - center(text("Fluffy " + version)), | ||
| 115 | - appContainer->Render(), | ||
| 116 | - }) | | ||
| 117 | - border | size(WIDTH, LESS_THAN, 120); | ||
| 118 | - }); | ||
| 119 | - menu_screen.Loop(renderer); | ||
| 120 | - | ||
| 121 | -} | ||
| 122 | 73 | ||
| 123 | auto FluffyApplication::handleFlags(std::vector<std::string> flags) -> void { | 74 | auto FluffyApplication::handleFlags(std::vector<std::string> flags) -> void { |
| 124 | for (const auto& flag : flags) { | 75 | for (const auto& flag : flags) { |
| @@ -176,6 +127,6 @@ FluffyApplication::FluffyApplication(int argc, char const *argv[]) { | |||
| 176 | if (command != "") handleCommand(command, arguments, database); | 127 | if (command != "") handleCommand(command, arguments, database); |
| 177 | } | 128 | } |
| 178 | else { | 129 | else { |
| 179 | - runConsoleApp(); | 130 | + handleCommand("--help", {}, database); |
| 180 | } | 131 | } |
| 181 | } | 132 | } |