From 2bd8adaf69720452d8790178acfc67c8fd8b4179 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Sun, 27 Oct 2013 22:00:09 +1100 Subject: [PATCH] Added an empty navigation shell to the client --- client/lobby_menu.cpp | 26 +++++++++++++++++----- client/lobby_menu.hpp | 9 ++++++++ client/main_menu.cpp | 48 +++++++++++++++++++++++++++++++++++----- client/main_menu.hpp | 11 +++++++++ client/options_menu.cpp | 28 ++++++++++++++++++----- client/options_menu.hpp | 9 ++++++++ client/splash_screen.cpp | 45 +++++-------------------------------- client/splash_screen.hpp | 15 ++++++------- 8 files changed, 129 insertions(+), 62 deletions(-) diff --git a/client/lobby_menu.cpp b/client/lobby_menu.cpp index 6bb7805..f337d52 100644 --- a/client/lobby_menu.cpp +++ b/client/lobby_menu.cpp @@ -26,7 +26,21 @@ //------------------------- LobbyMenu::LobbyMenu() { - // + //setup the utility objects + image.LoadSurface("rsc\\graphics\\interface\\button_menu.bmp"); + image.SetClipH(image.GetClipH()/3); + font.LoadSurface("rsc\\graphics\\fonts\\pk_white_8.bmp"); + + //pass the utility objects + backButton.SetImage(&image); + backButton.SetFont(&font); + + //set the button positions + backButton.SetX(50); + backButton.SetY(50 + image.GetClipH() * 0); + + //set the button texts + backButton.SetText("Back"); } LobbyMenu::~LobbyMenu() { @@ -50,7 +64,7 @@ void LobbyMenu::FrameEnd() { } void LobbyMenu::Render(SDL_Surface* const screen) { - // + backButton.DrawTo(screen); } //------------------------- @@ -58,15 +72,17 @@ void LobbyMenu::Render(SDL_Surface* const screen) { //------------------------- void LobbyMenu::MouseMotion(SDL_MouseMotionEvent const& motion) { - // + backButton.MouseMotion(motion); } void LobbyMenu::MouseButtonDown(SDL_MouseButtonEvent const& button) { - // + backButton.MouseButtonDown(button); } void LobbyMenu::MouseButtonUp(SDL_MouseButtonEvent const& button) { - // + if (backButton.MouseButtonUp(button) == Button::State::HOVER) { + SetNextScene(SceneList::MAINMENU); + } } void LobbyMenu::KeyDown(SDL_KeyboardEvent const& key) { diff --git a/client/lobby_menu.hpp b/client/lobby_menu.hpp index bc3393c..a32a0f0 100644 --- a/client/lobby_menu.hpp +++ b/client/lobby_menu.hpp @@ -24,6 +24,10 @@ #include "base_scene.hpp" +#include "image.hpp" +#include "raster_font.hpp" +#include "button.hpp" + class LobbyMenu : public BaseScene { public: //Public access members @@ -43,6 +47,11 @@ protected: void MouseButtonUp(SDL_MouseButtonEvent const&); void KeyDown(SDL_KeyboardEvent const&); void KeyUp(SDL_KeyboardEvent const&); + + //members + Image image; + RasterFont font; + Button backButton; }; #endif diff --git a/client/main_menu.cpp b/client/main_menu.cpp index ebf0dea..f60a01d 100644 --- a/client/main_menu.cpp +++ b/client/main_menu.cpp @@ -26,7 +26,31 @@ //------------------------- MainMenu::MainMenu() { - // + //setup the utility objects + image.LoadSurface("rsc\\graphics\\interface\\button_menu.bmp"); + image.SetClipH(image.GetClipH()/3); + font.LoadSurface("rsc\\graphics\\fonts\\pk_white_8.bmp"); + + //pass the utility objects + startButton.SetImage(&image); + startButton.SetFont(&font); + optionsButton.SetImage(&image); + optionsButton.SetFont(&font); + quitButton.SetImage(&image); + quitButton.SetFont(&font); + + //set the button positions + startButton.SetX(50); + startButton.SetY(50 + image.GetClipH() * 0); + optionsButton.SetX(50); + optionsButton.SetY(50 + image.GetClipH() * 1); + quitButton.SetX(50); + quitButton.SetY(50 + image.GetClipH() * 2); + + //set the button texts + startButton.SetText("Start"); + optionsButton.SetText("Options"); + quitButton.SetText("Quit"); } MainMenu::~MainMenu() { @@ -50,7 +74,9 @@ void MainMenu::FrameEnd() { } void MainMenu::Render(SDL_Surface* const screen) { - // + startButton.DrawTo(screen); + optionsButton.DrawTo(screen); + quitButton.DrawTo(screen); } //------------------------- @@ -58,15 +84,27 @@ void MainMenu::Render(SDL_Surface* const screen) { //------------------------- void MainMenu::MouseMotion(SDL_MouseMotionEvent const& motion) { - // + startButton.MouseMotion(motion); + optionsButton.MouseMotion(motion); + quitButton.MouseMotion(motion); } void MainMenu::MouseButtonDown(SDL_MouseButtonEvent const& button) { - // + startButton.MouseButtonDown(button); + optionsButton.MouseButtonDown(button); + quitButton.MouseButtonDown(button); } void MainMenu::MouseButtonUp(SDL_MouseButtonEvent const& button) { - // + if (startButton.MouseButtonUp(button) == Button::State::HOVER) { + SetNextScene(SceneList::LOBBYMENU); + } + if (optionsButton.MouseButtonUp(button) == Button::State::HOVER) { + SetNextScene(SceneList::OPTIONSMENU); + } + if (quitButton.MouseButtonUp(button) == Button::State::HOVER) { + QuitEvent(); + } } void MainMenu::KeyDown(SDL_KeyboardEvent const& key) { diff --git a/client/main_menu.hpp b/client/main_menu.hpp index 02db7b1..dc6e44e 100644 --- a/client/main_menu.hpp +++ b/client/main_menu.hpp @@ -24,6 +24,10 @@ #include "base_scene.hpp" +#include "image.hpp" +#include "raster_font.hpp" +#include "button.hpp" + class MainMenu : public BaseScene { public: //Public access members @@ -43,6 +47,13 @@ protected: void MouseButtonUp(SDL_MouseButtonEvent const&); void KeyDown(SDL_KeyboardEvent const&); void KeyUp(SDL_KeyboardEvent const&); + + //members + Image image; + RasterFont font; + Button startButton; + Button optionsButton; + Button quitButton; }; #endif diff --git a/client/options_menu.cpp b/client/options_menu.cpp index c41a954..472fcc9 100644 --- a/client/options_menu.cpp +++ b/client/options_menu.cpp @@ -26,7 +26,21 @@ //------------------------- OptionsMenu::OptionsMenu() { - // + //setup the utility objects + image.LoadSurface("rsc\\graphics\\interface\\button_menu.bmp"); + image.SetClipH(image.GetClipH()/3); + font.LoadSurface("rsc\\graphics\\fonts\\pk_white_8.bmp"); + + //pass the utility objects + backButton.SetImage(&image); + backButton.SetFont(&font); + + //set the button positions + backButton.SetX(50); + backButton.SetY(50 + image.GetClipH() * 0); + + //set the button texts + backButton.SetText("Back"); } OptionsMenu::~OptionsMenu() { @@ -50,7 +64,9 @@ void OptionsMenu::FrameEnd() { } void OptionsMenu::Render(SDL_Surface* const screen) { - // + backButton.DrawTo(screen); + + font.DrawStringTo("Oh, were you looking for the options screen?", screen, 50, 30); } //------------------------- @@ -58,15 +74,17 @@ void OptionsMenu::Render(SDL_Surface* const screen) { //------------------------- void OptionsMenu::MouseMotion(SDL_MouseMotionEvent const& motion) { - // + backButton.MouseMotion(motion); } void OptionsMenu::MouseButtonDown(SDL_MouseButtonEvent const& button) { - // + backButton.MouseButtonDown(button); } void OptionsMenu::MouseButtonUp(SDL_MouseButtonEvent const& button) { - // + if (backButton.MouseButtonUp(button) == Button::State::HOVER) { + SetNextScene(SceneList::MAINMENU); + } } void OptionsMenu::KeyDown(SDL_KeyboardEvent const& key) { diff --git a/client/options_menu.hpp b/client/options_menu.hpp index 39fba41..e0593b0 100644 --- a/client/options_menu.hpp +++ b/client/options_menu.hpp @@ -24,6 +24,10 @@ #include "base_scene.hpp" +#include "image.hpp" +#include "raster_font.hpp" +#include "button.hpp" + class OptionsMenu : public BaseScene { public: //Public access members @@ -43,6 +47,11 @@ protected: void MouseButtonUp(SDL_MouseButtonEvent const&); void KeyDown(SDL_KeyboardEvent const&); void KeyUp(SDL_KeyboardEvent const&); + + //members + Image image; + RasterFont font; + Button backButton; }; #endif diff --git a/client/splash_screen.cpp b/client/splash_screen.cpp index 97c64d0..87dee19 100644 --- a/client/splash_screen.cpp +++ b/client/splash_screen.cpp @@ -26,7 +26,8 @@ //------------------------- SplashScreen::SplashScreen() { - // + logo.LoadSurface("rsc\\graphics\\logos\\krstudios.bmp"); + startTick = std::chrono::steady_clock::now(); } SplashScreen::~SplashScreen() { @@ -37,46 +38,12 @@ SplashScreen::~SplashScreen() { //Frame loop //------------------------- -void SplashScreen::FrameStart() { - // -} - 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 (std::chrono::steady_clock::now() - startTick > std::chrono::duration(1)) { + SetNextScene(SceneList::MAINMENU); } } -void SplashScreen::KeyUp(SDL_KeyboardEvent const& key) { - // +void SplashScreen::Render(SDL_Surface* const screen) { + logo.DrawTo(screen, (screen->w - logo.GetClipW()) / 2, (screen->h - logo.GetClipH()) / 2); } diff --git a/client/splash_screen.hpp b/client/splash_screen.hpp index f5ce0c8..29c9a88 100644 --- a/client/splash_screen.hpp +++ b/client/splash_screen.hpp @@ -24,6 +24,10 @@ #include "base_scene.hpp" +#include "image.hpp" + +#include + class SplashScreen : public BaseScene { public: //Public access members @@ -32,17 +36,12 @@ public: protected: //Frame loop - void FrameStart(); void Update(double delta); - void FrameEnd(); void Render(SDL_Surface* const); - //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&); + //members + std::chrono::steady_clock::time_point startTick; + Image logo; }; #endif