]> git.localhorst.tv Git - blank.git/commitdiff
moved common stated to shared dir
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 26 Oct 2015 13:22:49 +0000 (14:22 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 26 Oct 2015 13:35:40 +0000 (14:35 +0100)
15 files changed:
src/app/ChatState.cpp [deleted file]
src/app/ChatState.hpp [deleted file]
src/app/Environment.hpp
src/app/MessageState.cpp [deleted file]
src/app/MessageState.hpp [deleted file]
src/app/ProgressState.cpp [deleted file]
src/app/ProgressState.hpp [deleted file]
src/client/InteractiveState.hpp
src/shared/ChatState.hpp [new file with mode: 0644]
src/shared/MessageState.hpp [new file with mode: 0644]
src/shared/ProgressState.hpp [new file with mode: 0644]
src/shared/states.cpp [new file with mode: 0644]
src/standalone/MasterState.hpp
src/standalone/PreloadState.hpp
src/standalone/UnloadState.hpp

diff --git a/src/app/ChatState.cpp b/src/app/ChatState.cpp
deleted file mode 100644 (file)
index 1eb35be..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-#include "ChatState.hpp"
-
-#include "Environment.hpp"
-#include "../io/event.hpp"
-
-#include <iostream>
-
-
-namespace blank {
-
-ChatState::ChatState(Environment &env, State &parent, Responder &responder)
-: env(env)
-, parent(parent)
-, responder(responder)
-, input(env.assets.small_ui_font) {
-       input.Position(glm::vec3(25.0f, -25.0f, -1.0f), Gravity::SOUTH_WEST, Gravity::SOUTH_WEST);
-       input.Width(env.viewport.Width() - 50.0f);
-       input.Foreground(glm::vec4(1.0f));
-       input.Background(glm::vec4(0.5f));
-}
-
-void ChatState::OnResume() {
-       OnResize(env.viewport);
-       input.Clear();
-       input.Focus(env.viewport);
-}
-
-void ChatState::OnPause() {
-       input.Blur();
-}
-
-void ChatState::OnResize(Viewport &viewport) {
-       input.Width(viewport.Width() - 50.0f);
-}
-
-
-void ChatState::Handle(const SDL_Event &e) {
-       switch (e.type) {
-               case SDL_KEYDOWN:
-                       switch (e.key.keysym.sym) {
-                               case SDLK_ESCAPE:
-                                       Quit();
-                                       break;
-                               case SDLK_KP_ENTER:
-                               case SDLK_RETURN:
-                                       responder.OnLineSubmit(input.GetInput());
-                                       Quit();
-                                       break;
-
-                               case SDLK_BACKSPACE:
-                                       input.Backspace();
-                                       break;
-                               case SDLK_DELETE:
-                                       input.Delete();
-                                       break;
-
-                               case SDLK_LEFT:
-                                       input.MoveBackward();
-                                       break;
-                               case SDLK_RIGHT:
-                                       input.MoveForward();
-                                       break;
-
-                               case SDLK_HOME:
-                                       input.MoveBegin();
-                                       break;
-                               case SDLK_END:
-                                       input.MoveEnd();
-                                       break;
-
-                               default:
-                                       break;
-                       }
-                       break;
-
-               case SDL_QUIT:
-                       env.state.PopAll();
-                       break;
-
-               case SDL_TEXTINPUT:
-                       input.Handle(e.text);
-                       break;
-
-               case SDL_TEXTEDITING:
-                       std::cout << e << std::endl;
-                       input.Handle(e.edit);
-                       break;
-
-               default:
-                       break;
-       }
-}
-
-void ChatState::Quit() {
-       env.state.PopUntil(this);
-}
-
-void ChatState::Update(int dt) {
-       parent.Update(dt);
-}
-
-void ChatState::Render(Viewport &viewport) {
-       parent.Render(viewport);
-       input.Render(viewport);
-}
-
-}
diff --git a/src/app/ChatState.hpp b/src/app/ChatState.hpp
deleted file mode 100644 (file)
index 56f8538..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef BLANK_APP_CHATSTATE_HPP_
-#define BLANK_APP_CHATSTATE_HPP_
-
-#include "State.hpp"
-
-#include "../ui/TextInput.hpp"
-
-#include <string>
-
-
-namespace blank {
-
-class Environment;
-
-class ChatState
-: public State {
-
-public:
-       struct Responder {
-               virtual void OnLineSubmit(const std::string &) = 0;
-       };
-
-public:
-       ChatState(Environment &env, State &parent, Responder &);
-
-       void OnResume() override;
-       void OnPause() override;
-
-       void OnResize(Viewport &) override;
-
-       void Handle(const SDL_Event &) override;
-       void Update(int dt) override;
-       void Render(Viewport &) override;
-
-       void Quit();
-
-private:
-       Environment &env;
-       State &parent;
-       Responder &responder;
-
-       TextInput input;
-
-};
-
-}
-
-#endif
index 724db7072de75fa0aa3904ebd1f2c1332aa70ab9..7061000fa221ffe1f3da97ad7e42ff43d4a08fcf 100644 (file)
@@ -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 <string>
diff --git a/src/app/MessageState.cpp b/src/app/MessageState.cpp
deleted file mode 100644 (file)
index 53ed741..0000000
+++ /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/MessageState.hpp b/src/app/MessageState.hpp
deleted file mode 100644 (file)
index 29c8cb6..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef BLANK_APP_MESSAGESTATE_HPP_
-#define BLANK_APP_MESSAGESTATE_HPP_
-
-#include "State.hpp"
-
-#include "../ui/FixedText.hpp"
-
-
-namespace blank {
-
-class Environment;
-
-class MessageState
-: public State {
-
-public:
-       explicit MessageState(Environment &);
-
-       void SetMessage(const char *);
-       void ClearMessage();
-
-       void Handle(const SDL_Event &) override;
-       void Update(int dt) override;
-       void Render(Viewport &) override;
-
-private:
-       Environment &env;
-       FixedText message;
-       FixedText press_key;
-
-};
-
-}
-
-#endif
diff --git a/src/app/ProgressState.cpp b/src/app/ProgressState.cpp
deleted file mode 100644 (file)
index 30a60dc..0000000
+++ /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/app/ProgressState.hpp b/src/app/ProgressState.hpp
deleted file mode 100644 (file)
index b3295c2..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef BLANK_APP_PROGRESSSTATE_HPP_
-#define BLANK_APP_PROGRESSSTATE_HPP_
-
-#include "State.hpp"
-
-#include "../ui/Progress.hpp"
-
-
-namespace blank {
-
-class Environment;
-
-class ProgressState
-: public State {
-
-public:
-       ProgressState(Environment &env, const char *tpl);
-
-       void SetProgress(int value, int total);
-
-       void Handle(const SDL_Event &) override;
-       void Render(Viewport &) override;
-
-private:
-       Environment &env;
-       Progress progress;
-
-};
-
-}
-
-#endif
index ab6513813e49f01c3049dfa45f336ea758ff2268..d5fd4a1859fb3c8b188e7f03bed58023ceff0c49 100644 (file)
@@ -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/shared/ChatState.hpp b/src/shared/ChatState.hpp
new file mode 100644 (file)
index 0000000..7b8a993
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef BLANK_SHARED_CHATSTATE_HPP_
+#define BLANK_SHARED_CHATSTATE_HPP_
+
+#include "../app/State.hpp"
+
+#include "../ui/TextInput.hpp"
+
+#include <string>
+
+
+namespace blank {
+
+class Environment;
+
+class ChatState
+: public State {
+
+public:
+       struct Responder {
+               virtual void OnLineSubmit(const std::string &) = 0;
+       };
+
+public:
+       ChatState(Environment &env, State &parent, Responder &);
+
+       void OnResume() override;
+       void OnPause() override;
+
+       void OnResize(Viewport &) override;
+
+       void Handle(const SDL_Event &) override;
+       void Update(int dt) override;
+       void Render(Viewport &) override;
+
+       void Quit();
+
+private:
+       Environment &env;
+       State &parent;
+       Responder &responder;
+
+       TextInput input;
+
+};
+
+}
+
+#endif
diff --git a/src/shared/MessageState.hpp b/src/shared/MessageState.hpp
new file mode 100644 (file)
index 0000000..8595fe0
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef BLANK_SHARED_MESSAGESTATE_HPP_
+#define BLANK_SHARED_MESSAGESTATE_HPP_
+
+#include "../app/State.hpp"
+
+#include "../ui/FixedText.hpp"
+
+
+namespace blank {
+
+class Environment;
+
+class MessageState
+: public State {
+
+public:
+       explicit MessageState(Environment &);
+
+       void SetMessage(const char *);
+       void ClearMessage();
+
+       void Handle(const SDL_Event &) override;
+       void Update(int dt) override;
+       void Render(Viewport &) override;
+
+private:
+       Environment &env;
+       FixedText message;
+       FixedText press_key;
+
+};
+
+}
+
+#endif
diff --git a/src/shared/ProgressState.hpp b/src/shared/ProgressState.hpp
new file mode 100644 (file)
index 0000000..8bfea0e
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef BLANK_SHARED_PROGRESSSTATE_HPP_
+#define BLANK_SHARED_PROGRESSSTATE_HPP_
+
+#include "../app/State.hpp"
+
+#include "../ui/Progress.hpp"
+
+
+namespace blank {
+
+class Environment;
+
+class ProgressState
+: public State {
+
+public:
+       ProgressState(Environment &env, const char *tpl);
+
+       void SetProgress(int value, int total);
+
+       void Handle(const SDL_Event &) override;
+       void Render(Viewport &) override;
+
+private:
+       Environment &env;
+       Progress progress;
+
+};
+
+}
+
+#endif
diff --git a/src/shared/states.cpp b/src/shared/states.cpp
new file mode 100644 (file)
index 0000000..b9a48b0
--- /dev/null
@@ -0,0 +1,169 @@
+#include "ChatState.hpp"
+#include "MessageState.hpp"
+#include "ProgressState.hpp"
+
+#include "../app/Environment.hpp"
+#include "../io/event.hpp"
+
+#include <iostream>
+
+
+namespace blank {
+
+ChatState::ChatState(Environment &env, State &parent, Responder &responder)
+: env(env)
+, parent(parent)
+, responder(responder)
+, input(env.assets.small_ui_font) {
+       input.Position(glm::vec3(25.0f, -25.0f, -1.0f), Gravity::SOUTH_WEST, Gravity::SOUTH_WEST);
+       input.Width(env.viewport.Width() - 50.0f);
+       input.Foreground(glm::vec4(1.0f));
+       input.Background(glm::vec4(0.5f));
+}
+
+void ChatState::OnResume() {
+       OnResize(env.viewport);
+       input.Clear();
+       input.Focus(env.viewport);
+}
+
+void ChatState::OnPause() {
+       input.Blur();
+}
+
+void ChatState::OnResize(Viewport &viewport) {
+       input.Width(viewport.Width() - 50.0f);
+}
+
+
+void ChatState::Handle(const SDL_Event &e) {
+       switch (e.type) {
+               case SDL_KEYDOWN:
+                       switch (e.key.keysym.sym) {
+                               case SDLK_ESCAPE:
+                                       Quit();
+                                       break;
+                               case SDLK_KP_ENTER:
+                               case SDLK_RETURN:
+                                       responder.OnLineSubmit(input.GetInput());
+                                       Quit();
+                                       break;
+
+                               case SDLK_BACKSPACE:
+                                       input.Backspace();
+                                       break;
+                               case SDLK_DELETE:
+                                       input.Delete();
+                                       break;
+
+                               case SDLK_LEFT:
+                                       input.MoveBackward();
+                                       break;
+                               case SDLK_RIGHT:
+                                       input.MoveForward();
+                                       break;
+
+                               case SDLK_HOME:
+                                       input.MoveBegin();
+                                       break;
+                               case SDLK_END:
+                                       input.MoveEnd();
+                                       break;
+
+                               default:
+                                       break;
+                       }
+                       break;
+
+               case SDL_QUIT:
+                       env.state.PopAll();
+                       break;
+
+               case SDL_TEXTINPUT:
+                       input.Handle(e.text);
+                       break;
+
+               case SDL_TEXTEDITING:
+                       std::cout << e << std::endl;
+                       input.Handle(e.edit);
+                       break;
+
+               default:
+                       break;
+       }
+}
+
+void ChatState::Quit() {
+       env.state.PopUntil(this);
+}
+
+void ChatState::Update(int dt) {
+       parent.Update(dt);
+}
+
+void ChatState::Render(Viewport &viewport) {
+       parent.Render(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);
+}
+
+}
index 942cc132e94a585bd6bcc066245f738daefe5cf3..26fcf26742a62cb4e05ca49208b5a9df5bc9ec63 100644 (file)
@@ -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"
index 1e750d9c815293255a4010474003f8309d31fde9..2012d4b7ef963d7b6c53760bf11559f683088890 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef BLANK_STANDALONE_PRELOADSTATE_HPP_
 #define BLANK_STANDALONE_PRELOADSTATE_HPP_
 
-#include "../app/ProgressState.hpp"
+#include "../shared/ProgressState.hpp"
 
 #include <cstddef>
 
index 959fa94df5039afc8fb345bb7b978cc2d8fac8e6..7782ce2d1df3bde08eb9e0d78ec9f054fc8d1cb6 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef BLANK_STANDALONE_UNLOADSTATE_HPP_
 #define BLANK_STANDALONE_UNLOADSTATE_HPP_
 
-#include "../app/ProgressState.hpp"
+#include "../shared/ProgressState.hpp"
 
 #include <cstddef>
 #include <list>