Splash screen loads and displays correctly
This commit is contained in:
@@ -137,6 +137,10 @@ void SceneManager::Proc() {
|
||||
|
||||
void SceneManager::Quit() {
|
||||
//clean up the services
|
||||
netUtil->Close();
|
||||
surfaceMgr->FreeAll();
|
||||
|
||||
//delete the services
|
||||
configUtil = ServiceLocator<ConfigUtility>::Set(nullptr);
|
||||
surfaceMgr = ServiceLocator<SurfaceManager>::Set(nullptr);
|
||||
netUtil = ServiceLocator<UDPNetworkUtility>::Set(nullptr);
|
||||
|
||||
+33
-37
@@ -12,9 +12,11 @@ SplashScreen::SplashScreen() {
|
||||
#ifdef DEBUG
|
||||
cout << "entering SplashScreen" << endl;
|
||||
#endif
|
||||
logo.SetSurface(surfaceMgr->Load("splash-logo", configUtil->String("logos") + "/krstudios.bmp"));
|
||||
}
|
||||
|
||||
SplashScreen::~SplashScreen() {
|
||||
surfaceMgr->Free("splash-logo");
|
||||
#ifdef DEBUG
|
||||
cout << "leaving SplashScreen" << endl;
|
||||
#endif
|
||||
@@ -24,46 +26,40 @@ SplashScreen::~SplashScreen() {
|
||||
//Frame loop
|
||||
//-------------------------
|
||||
|
||||
void SplashScreen::FrameStart() {
|
||||
//
|
||||
void SplashScreen::RunFrame(double delta) {
|
||||
HandleEvents();
|
||||
if (!loaded) {
|
||||
//never repeat this
|
||||
loaded = true;
|
||||
|
||||
//quick draw
|
||||
RenderFrame();
|
||||
|
||||
LoadResources();
|
||||
}
|
||||
|
||||
void SplashScreen::Update(double delta) {
|
||||
//
|
||||
}
|
||||
|
||||
void SplashScreen::FrameEnd() {
|
||||
//
|
||||
}
|
||||
|
||||
void SplashScreen::Render(SDL_Surface* const screen) {
|
||||
//
|
||||
}
|
||||
|
||||
//-------------------------
|
||||
//Event handlers
|
||||
//-------------------------
|
||||
|
||||
void SplashScreen::MouseMotion(SDL_MouseMotionEvent const& motion) {
|
||||
//
|
||||
}
|
||||
|
||||
void SplashScreen::MouseButtonDown(SDL_MouseButtonEvent const& button) {
|
||||
//
|
||||
}
|
||||
|
||||
void SplashScreen::MouseButtonUp(SDL_MouseButtonEvent const& button) {
|
||||
//
|
||||
}
|
||||
|
||||
void SplashScreen::KeyDown(SDL_KeyboardEvent const& key) {
|
||||
switch(key.keysym.sym) {
|
||||
case SDLK_ESCAPE:
|
||||
QuitEvent();
|
||||
break;
|
||||
if (Clock::now() - start > std::chrono::duration<int>(1)) {
|
||||
SetNextScene(SceneList::MAINMENU);
|
||||
}
|
||||
}
|
||||
|
||||
void SplashScreen::KeyUp(SDL_KeyboardEvent const& key) {
|
||||
//
|
||||
void SplashScreen::RenderFrame() {
|
||||
SDL_FillRect(GetScreen(), 0, 0);
|
||||
int x = (GetScreen()->w - logo.GetClipW()) / 2;
|
||||
int y = (GetScreen()->h - logo.GetClipH()) / 2;
|
||||
logo.DrawTo(GetScreen(), x, y);
|
||||
SDL_Flip(GetScreen());
|
||||
}
|
||||
|
||||
void SplashScreen::LoadResources() {
|
||||
//standard
|
||||
surfaceMgr->Load("font", configUtil->String("fonts") + "/pokemon_dark_font.bmp");
|
||||
surfaceMgr->Load("button", configUtil->String("interface") + "/button.bmp");
|
||||
|
||||
//debugging
|
||||
surfaceMgr->Load("elliot", configUtil->String("sprites") + "/elliot2.bmp");
|
||||
surfaceMgr->Load("coa", configUtil->String("sprites") + "/coa2.bmp");
|
||||
surfaceMgr->Load("flower", configUtil->String("sprites") + "/aniflower.bmp");
|
||||
surfaceMgr->Load("terrain", configUtil->String("tilesets") + "/terrain.bmp");
|
||||
//TODO
|
||||
}
|
||||
|
||||
+16
-10
@@ -2,6 +2,14 @@
|
||||
#define SPLASHSCREEN_HPP_
|
||||
|
||||
#include "base_scene.hpp"
|
||||
#include "service_locator.hpp"
|
||||
#include "defines.hpp"
|
||||
|
||||
#include "config_utility.hpp"
|
||||
#include "surface_manager.hpp"
|
||||
#include "image.hpp"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
class SplashScreen : public BaseScene {
|
||||
public:
|
||||
@@ -11,17 +19,15 @@ public:
|
||||
|
||||
protected:
|
||||
/* Frame loop */
|
||||
void FrameStart();
|
||||
void Update(double delta);
|
||||
void FrameEnd();
|
||||
void Render(SDL_Surface* const);
|
||||
void RunFrame(double delta);
|
||||
void RenderFrame();
|
||||
void LoadResources();
|
||||
|
||||
/* Event handlers */
|
||||
void MouseMotion(SDL_MouseMotionEvent const&);
|
||||
void MouseButtonDown(SDL_MouseButtonEvent const&);
|
||||
void MouseButtonUp(SDL_MouseButtonEvent const&);
|
||||
void KeyDown(SDL_KeyboardEvent const&);
|
||||
void KeyUp(SDL_KeyboardEvent const&);
|
||||
bool loaded = false;
|
||||
ConfigUtility* configUtil = ServiceLocator<ConfigUtility>::Get();
|
||||
SurfaceManager* surfaceMgr = ServiceLocator<SurfaceManager>::Get();
|
||||
Image logo;
|
||||
Clock::time_point start = Clock::now();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user