mirror of
https://github.com/DarkStore-3DS/Universal-Core.git
synced 2026-07-04 16:59:04 +00:00
Move screen stuff into screen.cpp.
This commit is contained in:
@@ -84,30 +84,6 @@ namespace Graphics {
|
|||||||
* @param layer The layer to draw to
|
* @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);
|
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> screen);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Goes a screen back
|
|
||||||
*/
|
|
||||||
void screenBack();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -29,12 +29,39 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <nds.h>
|
#include <nds.h>
|
||||||
|
#include <stack>
|
||||||
|
|
||||||
class Screen {
|
class Screen {
|
||||||
public:
|
public:
|
||||||
|
static std::stack<std::unique_ptr<Screen>> screens;
|
||||||
|
|
||||||
virtual ~Screen() {}
|
virtual ~Screen() {}
|
||||||
virtual void Logic(u32 hDown, u32 hHeld, touchPosition touch) = 0;
|
virtual void Logic(u32 hDown, u32 hHeld, touchPosition touch) = 0;
|
||||||
virtual void Draw() const = 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> screen);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Goes a screen back
|
||||||
|
*/
|
||||||
|
static void back();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -29,11 +29,9 @@
|
|||||||
#include "tonccpy.h"
|
#include "tonccpy.h"
|
||||||
|
|
||||||
#include <nds.h>
|
#include <nds.h>
|
||||||
#include <stack>
|
|
||||||
|
|
||||||
int Graphics::bg3Main, Graphics::bg2Main, Graphics::bg3Sub, Graphics::bg2Sub;
|
int Graphics::bg3Main, Graphics::bg2Main, Graphics::bg3Sub, Graphics::bg2Sub;
|
||||||
bool Graphics::wideScreen = false;
|
bool Graphics::wideScreen = false;
|
||||||
static std::stack<std::unique_ptr<Screen>> screens;
|
|
||||||
|
|
||||||
void Graphics::init(void) {
|
void Graphics::init(void) {
|
||||||
// Initialize video mode
|
// Initialize video mode
|
||||||
@@ -91,20 +89,3 @@ void Graphics::drawRectangle(int x, int y, int w, int h, u8 color1, u8 color2, b
|
|||||||
toncset(dst + ((y + i) * 256 + x), ((i % 2) ? color1 : color2), w);
|
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> screen) { screens.push(std::move(screen)); }
|
|
||||||
|
|
||||||
void Graphics::screenBack() {
|
|
||||||
if(screens.size() > 0)
|
|
||||||
screens.pop();
|
|
||||||
}
|
|
||||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* 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<std::unique_ptr<Screen>> 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) { Screen::screens.push(std::move(screen)); }
|
||||||
|
|
||||||
|
void Screen::back() {
|
||||||
|
if(Screen::screens.size() > 0)
|
||||||
|
Screen::screens.pop();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user