mirror of
https://github.com/Team-Neptune/DeepSea-Updater.git
synced 2024-11-23 12:29:52 +00:00
Added render methods and scene changing.
This commit is contained in:
parent
24a6d82f60
commit
87b8770096
@ -20,3 +20,5 @@
|
||||
Scene::Scene() {}
|
||||
|
||||
Scene::~Scene() {}
|
||||
|
||||
void Scene::render(SDL_Rect rect, double dTime) {}
|
||||
|
@ -17,10 +17,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Scene {
|
||||
public:
|
||||
Scene();
|
||||
~Scene();
|
||||
virtual ~Scene();
|
||||
|
||||
virtual void render(SDL_Rect rect, double dTime);
|
||||
};
|
||||
|
@ -48,9 +48,29 @@ SceneDirector::SceneDirector() {
|
||||
|
||||
_now = SDL_GetPerformanceCounter();
|
||||
_last = 0;
|
||||
_allDoneScene = NULL;
|
||||
_appUpdateScene = NULL;
|
||||
_downloadingAppScene = NULL;
|
||||
_downloadingPackageScene = NULL;
|
||||
_packageSelectScene = NULL;
|
||||
}
|
||||
|
||||
SceneDirector::~SceneDirector() {
|
||||
if (_allDoneScene != NULL)
|
||||
delete _allDoneScene;
|
||||
|
||||
if (_appUpdateScene != NULL)
|
||||
delete _appUpdateScene;
|
||||
|
||||
if (_downloadingAppScene != NULL)
|
||||
delete _downloadingAppScene;
|
||||
|
||||
if (_downloadingPackageScene != NULL)
|
||||
delete _downloadingPackageScene;
|
||||
|
||||
if (_packageSelectScene != NULL)
|
||||
delete _packageSelectScene;
|
||||
|
||||
if (SceneDirector::renderer != NULL)
|
||||
SDL_DestroyRenderer(SceneDirector::renderer);
|
||||
|
||||
@ -73,29 +93,94 @@ bool SceneDirector::direct() {
|
||||
|
||||
hidScanInput();
|
||||
u32 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_A)
|
||||
return false;
|
||||
|
||||
// TODO: Handle touch controls
|
||||
|
||||
AssetManager::setRenderColor(AssetManager::background);
|
||||
SDL_RenderClear(SceneDirector::renderer);
|
||||
|
||||
// Unload previous scenes
|
||||
switch(SceneDirector::currentScene) {
|
||||
case SCENE_APP_UPDATE:
|
||||
break;
|
||||
|
||||
case SCENE_DOWNLOADING_APP:
|
||||
break;
|
||||
|
||||
case SCENE_PACKAGE_SELECT:
|
||||
break;
|
||||
|
||||
case SCENE_DOWNLOADING_PACKAGE:
|
||||
if (_appUpdateScene != NULL) {
|
||||
delete _appUpdateScene;
|
||||
_appUpdateScene = NULL;
|
||||
}
|
||||
|
||||
if (_downloadingAppScene != NULL) {
|
||||
delete _downloadingAppScene;
|
||||
_downloadingAppScene = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case SCENE_ALL_DONE:
|
||||
if (_appUpdateScene != NULL) {
|
||||
delete _appUpdateScene;
|
||||
_appUpdateScene = NULL;
|
||||
}
|
||||
|
||||
if (_downloadingAppScene != NULL) {
|
||||
delete _downloadingAppScene;
|
||||
_downloadingAppScene = NULL;
|
||||
}
|
||||
|
||||
if (_packageSelectScene != NULL) {
|
||||
delete _packageSelectScene;
|
||||
_packageSelectScene = NULL;
|
||||
}
|
||||
|
||||
if (_downloadingPackageScene != NULL) {
|
||||
delete _downloadingPackageScene;
|
||||
_downloadingPackageScene = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Do Nothing */
|
||||
break;
|
||||
}
|
||||
|
||||
// Load new scenes
|
||||
switch(SceneDirector::currentScene) {
|
||||
case SCENE_APP_UPDATE:
|
||||
if (_appUpdateScene == NULL)
|
||||
_appUpdateScene = new AppUpdateScene();
|
||||
|
||||
_currentScene = _appUpdateScene;
|
||||
break;
|
||||
|
||||
case SCENE_DOWNLOADING_APP:
|
||||
if (_downloadingAppScene == NULL)
|
||||
_downloadingAppScene = new DownloadingAppScene();
|
||||
|
||||
_currentScene = _downloadingAppScene;
|
||||
break;
|
||||
|
||||
case SCENE_PACKAGE_SELECT:
|
||||
if (_packageSelectScene == NULL)
|
||||
_packageSelectScene = new PackageSelectScene();
|
||||
|
||||
_currentScene = _packageSelectScene;
|
||||
break;
|
||||
|
||||
case SCENE_DOWNLOADING_PACKAGE:
|
||||
if (_downloadingPackageScene == NULL)
|
||||
_downloadingPackageScene = new DownloadingPackageScene();
|
||||
|
||||
_currentScene = _downloadingPackageScene;
|
||||
break;
|
||||
|
||||
case SCENE_ALL_DONE:
|
||||
if (_allDoneScene == NULL)
|
||||
_allDoneScene = new AllDoneScene();
|
||||
|
||||
_currentScene = _allDoneScene;
|
||||
break;
|
||||
}
|
||||
|
||||
_currentScene->render({ 0, 0, 1280, 720 }, dTime);
|
||||
|
||||
SDL_RenderPresent(SceneDirector::renderer);
|
||||
|
||||
return !SceneDirector::exitApp;
|
||||
|
@ -19,8 +19,13 @@
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "AssetManager.hpp"
|
||||
#include "views/HeaderView.hpp"
|
||||
#include "views/FooterView.hpp"
|
||||
#include "Scene.hpp"
|
||||
|
||||
#include "scenes/AllDoneScene.hpp"
|
||||
#include "scenes/AppUpdateScene.hpp"
|
||||
#include "scenes/DownloadingAppScene.hpp"
|
||||
#include "scenes/DownloadingPackageScene.hpp"
|
||||
#include "scenes/PackageSelectScene.hpp"
|
||||
|
||||
typedef enum {
|
||||
SCENE_APP_UPDATE,
|
||||
@ -47,4 +52,11 @@ class SceneDirector {
|
||||
private:
|
||||
Uint64 _now;
|
||||
Uint64 _last;
|
||||
|
||||
Scene * _currentScene;
|
||||
AllDoneScene * _allDoneScene;
|
||||
AppUpdateScene * _appUpdateScene;
|
||||
DownloadingAppScene * _downloadingAppScene;
|
||||
DownloadingPackageScene * _downloadingPackageScene;
|
||||
PackageSelectScene * _packageSelectScene;
|
||||
};
|
@ -20,3 +20,7 @@
|
||||
AllDoneScene::AllDoneScene() {}
|
||||
|
||||
AllDoneScene::~AllDoneScene() {}
|
||||
|
||||
void AllDoneScene::render(SDL_Rect rect, double dTime) {
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ class AllDoneScene : public Scene {
|
||||
public:
|
||||
AllDoneScene();
|
||||
~AllDoneScene();
|
||||
|
||||
void render(SDL_Rect rect, double dTime);
|
||||
|
||||
private:
|
||||
};
|
||||
|
@ -20,3 +20,7 @@
|
||||
AppUpdateScene::AppUpdateScene() {}
|
||||
|
||||
AppUpdateScene::~AppUpdateScene() {}
|
||||
|
||||
void AppUpdateScene::render(SDL_Rect rect, double dTime) {
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ class AppUpdateScene : public Scene {
|
||||
public:
|
||||
AppUpdateScene();
|
||||
~AppUpdateScene();
|
||||
|
||||
void render(SDL_Rect rect, double dTime);
|
||||
|
||||
private:
|
||||
};
|
||||
|
@ -20,3 +20,7 @@
|
||||
DownloadingAppScene::DownloadingAppScene() {}
|
||||
|
||||
DownloadingAppScene::~DownloadingAppScene() {}
|
||||
|
||||
void DownloadingAppScene::render(SDL_Rect rect, double dTime) {
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ class DownloadingAppScene : public Scene {
|
||||
public:
|
||||
DownloadingAppScene();
|
||||
~DownloadingAppScene();
|
||||
|
||||
void render(SDL_Rect rect, double dTime);
|
||||
|
||||
private:
|
||||
};
|
||||
|
@ -20,3 +20,7 @@
|
||||
DownloadingPackageScene::DownloadingPackageScene() {}
|
||||
|
||||
DownloadingPackageScene::~DownloadingPackageScene() {}
|
||||
|
||||
void DownloadingPackageScene::render(SDL_Rect rect, double dTime) {
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ class DownloadingPackageScene : public Scene {
|
||||
public:
|
||||
DownloadingPackageScene();
|
||||
~DownloadingPackageScene();
|
||||
|
||||
void render(SDL_Rect rect, double dTime);
|
||||
|
||||
private:
|
||||
};
|
||||
|
@ -20,3 +20,7 @@
|
||||
PackageSelectScene::PackageSelectScene() {}
|
||||
|
||||
PackageSelectScene::~PackageSelectScene() {}
|
||||
|
||||
void PackageSelectScene::render(SDL_Rect rect, double dTime) {
|
||||
|
||||
}
|
||||
|
@ -24,5 +24,7 @@ class PackageSelectScene : public Scene {
|
||||
PackageSelectScene();
|
||||
~PackageSelectScene();
|
||||
|
||||
void render(SDL_Rect rect, double dTime);
|
||||
|
||||
private:
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user