From 69e4d6c0a86a27f9b3f1297e46c55b36059a24b9 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Mon, 26 Oct 2015 14:22:49 +0100 Subject: [PATCH] moved common stated to shared dir --- src/app/Environment.hpp | 2 +- src/app/MessageState.cpp | 45 -------------- src/app/ProgressState.cpp | 29 --------- src/client/InteractiveState.hpp | 2 +- src/{app => shared}/ChatState.hpp | 6 +- src/{app => shared}/MessageState.hpp | 6 +- src/{app => shared}/ProgressState.hpp | 6 +- src/{app/ChatState.cpp => shared/states.cpp} | 64 +++++++++++++++++++- src/standalone/MasterState.hpp | 2 +- src/standalone/PreloadState.hpp | 2 +- src/standalone/UnloadState.hpp | 2 +- 11 files changed, 77 insertions(+), 89 deletions(-) delete mode 100644 src/app/MessageState.cpp delete mode 100644 src/app/ProgressState.cpp rename src/{app => shared}/ChatState.hpp (85%) rename src/{app => shared}/MessageState.hpp (79%) rename src/{app => shared}/ProgressState.hpp (76%) rename src/{app/ChatState.cpp => shared/states.cpp} (57%) diff --git a/src/app/Environment.hpp b/src/app/Environment.hpp index 724db70..7061000 100644 --- a/src/app/Environment.hpp +++ b/src/app/Environment.hpp @@ -3,11 +3,11 @@ #include "Assets.hpp" #include "FrameCounter.hpp" -#include "MessageState.hpp" #include "StateControl.hpp" #include "../audio/Audio.hpp" #include "../graphics/Viewport.hpp" #include "../rand/GaloisLFSR.hpp" +#include "../shared/MessageState.hpp" #include "../ui/Keymap.hpp" #include diff --git a/src/app/MessageState.cpp b/src/app/MessageState.cpp deleted file mode 100644 index 53ed741..0000000 --- a/src/app/MessageState.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "MessageState.hpp" - -#include "Environment.hpp" - - -namespace blank { - -MessageState::MessageState(Environment &env) -: env(env) { - message.Position(glm::vec3(0.0f), Gravity::CENTER); - message.Hide(); - press_key.Position(glm::vec3(0.0f, env.assets.large_ui_font.LineSkip(), 0.0f), Gravity::CENTER); - press_key.Set(env.assets.small_ui_font, "press any key to continue"); - press_key.Show(); -} - -void MessageState::SetMessage(const char *msg) { - message.Set(env.assets.large_ui_font, msg); - message.Show(); -} - -void MessageState::ClearMessage() { - message.Hide(); -} - -void MessageState::Handle(const SDL_Event &e) { - if (e.type == SDL_KEYDOWN) { - env.state.Pop(); - } -} - -void MessageState::Update(int dt) { - -} - -void MessageState::Render(Viewport &viewport) { - if (message.Visible()) { - message.Render(viewport); - } - if (press_key.Visible()) { - press_key.Render(viewport); - } -} - -} diff --git a/src/app/ProgressState.cpp b/src/app/ProgressState.cpp deleted file mode 100644 index 30a60dc..0000000 --- a/src/app/ProgressState.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "ProgressState.hpp" - -#include "../app/Environment.hpp" - - -namespace blank { - -ProgressState::ProgressState(Environment &env, const char *tpl) -: env(env) -, progress(env.assets.large_ui_font) { - progress.Position(glm::vec3(0.0f), Gravity::CENTER); - progress.Template(tpl); -} - -void ProgressState::SetProgress(int value, int total) { - progress.Update(value, total); -} - -void ProgressState::Handle(const SDL_Event &e) { - if (e.type == SDL_QUIT) { - env.state.PopAll(); - } -} - -void ProgressState::Render(Viewport &viewport) { - progress.Render(viewport); -} - -} diff --git a/src/client/InteractiveState.hpp b/src/client/InteractiveState.hpp index ab65138..d5fd4a1 100644 --- a/src/client/InteractiveState.hpp +++ b/src/client/InteractiveState.hpp @@ -6,12 +6,12 @@ #include "ChunkReceiver.hpp" #include "NetworkedInput.hpp" -#include "../app/ChatState.hpp" #include "../app/IntervalTimer.hpp" #include "../audio/SoundBank.hpp" #include "../graphics/SkyBox.hpp" #include "../io/WorldSave.hpp" #include "../net/Packet.hpp" +#include "../shared/ChatState.hpp" #include "../shared/WorldResources.hpp" #include "../ui/HUD.hpp" #include "../ui/InteractiveManipulator.hpp" diff --git a/src/app/ChatState.hpp b/src/shared/ChatState.hpp similarity index 85% rename from src/app/ChatState.hpp rename to src/shared/ChatState.hpp index 56f8538..7b8a993 100644 --- a/src/app/ChatState.hpp +++ b/src/shared/ChatState.hpp @@ -1,7 +1,7 @@ -#ifndef BLANK_APP_CHATSTATE_HPP_ -#define BLANK_APP_CHATSTATE_HPP_ +#ifndef BLANK_SHARED_CHATSTATE_HPP_ +#define BLANK_SHARED_CHATSTATE_HPP_ -#include "State.hpp" +#include "../app/State.hpp" #include "../ui/TextInput.hpp" diff --git a/src/app/MessageState.hpp b/src/shared/MessageState.hpp similarity index 79% rename from src/app/MessageState.hpp rename to src/shared/MessageState.hpp index 29c8cb6..8595fe0 100644 --- a/src/app/MessageState.hpp +++ b/src/shared/MessageState.hpp @@ -1,7 +1,7 @@ -#ifndef BLANK_APP_MESSAGESTATE_HPP_ -#define BLANK_APP_MESSAGESTATE_HPP_ +#ifndef BLANK_SHARED_MESSAGESTATE_HPP_ +#define BLANK_SHARED_MESSAGESTATE_HPP_ -#include "State.hpp" +#include "../app/State.hpp" #include "../ui/FixedText.hpp" diff --git a/src/app/ProgressState.hpp b/src/shared/ProgressState.hpp similarity index 76% rename from src/app/ProgressState.hpp rename to src/shared/ProgressState.hpp index b3295c2..8bfea0e 100644 --- a/src/app/ProgressState.hpp +++ b/src/shared/ProgressState.hpp @@ -1,7 +1,7 @@ -#ifndef BLANK_APP_PROGRESSSTATE_HPP_ -#define BLANK_APP_PROGRESSSTATE_HPP_ +#ifndef BLANK_SHARED_PROGRESSSTATE_HPP_ +#define BLANK_SHARED_PROGRESSSTATE_HPP_ -#include "State.hpp" +#include "../app/State.hpp" #include "../ui/Progress.hpp" diff --git a/src/app/ChatState.cpp b/src/shared/states.cpp similarity index 57% rename from src/app/ChatState.cpp rename to src/shared/states.cpp index 1eb35be..b9a48b0 100644 --- a/src/app/ChatState.cpp +++ b/src/shared/states.cpp @@ -1,6 +1,8 @@ #include "ChatState.hpp" +#include "MessageState.hpp" +#include "ProgressState.hpp" -#include "Environment.hpp" +#include "../app/Environment.hpp" #include "../io/event.hpp" #include @@ -104,4 +106,64 @@ void ChatState::Render(Viewport &viewport) { input.Render(viewport); } + +MessageState::MessageState(Environment &env) +: env(env) { + message.Position(glm::vec3(0.0f), Gravity::CENTER); + message.Hide(); + press_key.Position(glm::vec3(0.0f, env.assets.large_ui_font.LineSkip(), 0.0f), Gravity::CENTER); + press_key.Set(env.assets.small_ui_font, "press any key to continue"); + press_key.Show(); +} + +void MessageState::SetMessage(const char *msg) { + message.Set(env.assets.large_ui_font, msg); + message.Show(); +} + +void MessageState::ClearMessage() { + message.Hide(); +} + +void MessageState::Handle(const SDL_Event &e) { + if (e.type == SDL_KEYDOWN) { + env.state.Pop(); + } +} + +void MessageState::Update(int dt) { + +} + +void MessageState::Render(Viewport &viewport) { + if (message.Visible()) { + message.Render(viewport); + } + if (press_key.Visible()) { + press_key.Render(viewport); + } +} + + +ProgressState::ProgressState(Environment &env, const char *tpl) +: env(env) +, progress(env.assets.large_ui_font) { + progress.Position(glm::vec3(0.0f), Gravity::CENTER); + progress.Template(tpl); +} + +void ProgressState::SetProgress(int value, int total) { + progress.Update(value, total); +} + +void ProgressState::Handle(const SDL_Event &e) { + if (e.type == SDL_QUIT) { + env.state.PopAll(); + } +} + +void ProgressState::Render(Viewport &viewport) { + progress.Render(viewport); +} + } diff --git a/src/standalone/MasterState.hpp b/src/standalone/MasterState.hpp index 942cc13..26fcf26 100644 --- a/src/standalone/MasterState.hpp +++ b/src/standalone/MasterState.hpp @@ -7,9 +7,9 @@ #include "PreloadState.hpp" #include "UnloadState.hpp" #include "../ai/Spawner.hpp" -#include "../app/ChatState.hpp" #include "../audio/SoundBank.hpp" #include "../graphics/SkyBox.hpp" +#include "../shared/ChatState.hpp" #include "../shared/WorldResources.hpp" #include "../ui/DirectInput.hpp" #include "../ui/HUD.hpp" diff --git a/src/standalone/PreloadState.hpp b/src/standalone/PreloadState.hpp index 1e750d9..2012d4b 100644 --- a/src/standalone/PreloadState.hpp +++ b/src/standalone/PreloadState.hpp @@ -1,7 +1,7 @@ #ifndef BLANK_STANDALONE_PRELOADSTATE_HPP_ #define BLANK_STANDALONE_PRELOADSTATE_HPP_ -#include "../app/ProgressState.hpp" +#include "../shared/ProgressState.hpp" #include diff --git a/src/standalone/UnloadState.hpp b/src/standalone/UnloadState.hpp index 959fa94..7782ce2 100644 --- a/src/standalone/UnloadState.hpp +++ b/src/standalone/UnloadState.hpp @@ -1,7 +1,7 @@ #ifndef BLANK_STANDALONE_UNLOADSTATE_HPP_ #define BLANK_STANDALONE_UNLOADSTATE_HPP_ -#include "../app/ProgressState.hpp" +#include "../shared/ProgressState.hpp" #include #include -- 2.39.2