diff --git a/include/graphics.hpp b/include/graphics.hpp index 42d1334..ab9a185 100644 --- a/include/graphics.hpp +++ b/include/graphics.hpp @@ -84,30 +84,6 @@ namespace Graphics { * @param layer The layer to draw to */ void drawRectangle(int x, int y, int w, int h, u8 color1, u8 color2, bool top, bool layer); - - /** - * @brief Draws the setted screen - */ - void drawScreen(); - - /** - * @brief The current screen logic - * @param hDown The keysDown variable - * @param hHeld The keysHeld variable - * @param touch The TouchPosition variable - */ - void screenLogic(u32 hDown, u32 hHeld, touchPosition touch); - - /** - * @brief Set a specific Screen with the Screen class - * @param screen The screen which to set - */ - void setScreen(std::unique_ptr screen); - - /** - * @brief Goes a screen back - */ - void screenBack(); } #endif \ No newline at end of file diff --git a/include/screen.hpp b/include/screen.hpp index e60e085..97c0178 100644 --- a/include/screen.hpp +++ b/include/screen.hpp @@ -29,12 +29,39 @@ #include #include +#include class Screen { public: + static std::stack> screens; + virtual ~Screen() {} virtual void Logic(u32 hDown, u32 hHeld, touchPosition touch) = 0; virtual void Draw() const = 0; + + /** + * @brief Draws the setted screen + */ + static void doDraw(); + + /** + * @brief The current screen logic + * @param hDown The keysDown variable + * @param hHeld The keysHeld variable + * @param touch The TouchPosition variable + */ + static void doLogic(u32 hDown, u32 hHeld, touchPosition touch); + + /** + * @brief Set a specific Screen with the Screen class + * @param screen The screen which to set + */ + static void set(std::unique_ptr screen); + + /** + * @brief Goes a screen back + */ + static void back(); }; #endif \ No newline at end of file diff --git a/source/graphics.cpp b/source/graphics.cpp index e65e532..9f9757f 100644 --- a/source/graphics.cpp +++ b/source/graphics.cpp @@ -29,11 +29,9 @@ #include "tonccpy.h" #include -#include int Graphics::bg3Main, Graphics::bg2Main, Graphics::bg3Sub, Graphics::bg2Sub; bool Graphics::wideScreen = false; -static std::stack> screens; void Graphics::init(void) { // Initialize video mode @@ -90,21 +88,4 @@ void Graphics::drawRectangle(int x, int y, int w, int h, u8 color1, u8 color2, b for(int i = 0; i < h; i++) { toncset(dst + ((y + i) * 256 + x), ((i % 2) ? color1 : color2), w); } -} - -void Graphics::drawScreen() { - if(!screens.empty()) - screens.top()->Draw(); -} - -void Graphics::screenLogic(u32 hDown, u32 hHeld, touchPosition touch) { - if(!screens.empty()) - screens.top()->Logic(hDown, hHeld, touch); -} - -void Graphics::setScreen(std::unique_ptr screen) { screens.push(std::move(screen)); } - -void Graphics::screenBack() { - if(screens.size() > 0) - screens.pop(); } \ No newline at end of file diff --git a/source/screen.cpp b/source/screen.cpp new file mode 100644 index 0000000..95ab1d0 --- /dev/null +++ b/source/screen.cpp @@ -0,0 +1,46 @@ +/* + * This file is part of Universal-Core + * Copyright (C) 2021 Universal-Team + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Additional Terms 7.b and 7.c of GPLv3 apply to this file: + * * Requiring preservation of specified reasonable legal notices or + * author attributions in that material or in the Appropriate Legal + * Notices displayed by works containing it. + * * Prohibiting misrepresentation of the origin of that material, + * or requiring that modified versions of such material be marked in + * reasonable ways as different from the original version. + */ + +#include "screen.hpp" + +std::stack> Screen::screens; + +void Screen::doDraw() { + if(!Screen::screens.empty()) + Screen::screens.top()->Draw(); +} + +void Screen::doLogic(u32 hDown, u32 hHeld, touchPosition touch) { + if(!Screen::screens.empty()) + Screen::screens.top()->Logic(hDown, hHeld, touch); +} + +void Screen::set(std::unique_ptr screen) { Screen::screens.push(std::move(screen)); } + +void Screen::back() { + if(Screen::screens.size() > 0) + Screen::screens.pop(); +} \ No newline at end of file