+++ /dev/null
-#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);
-}
-
-}
+++ /dev/null
-#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
#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>
+++ /dev/null
-#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);
- }
-}
-
-}
+++ /dev/null
-#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
+++ /dev/null
-#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);
-}
-
-}
+++ /dev/null
-#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
#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"
--- /dev/null
+#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
--- /dev/null
+#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
--- /dev/null
+#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
--- /dev/null
+#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);
+}
+
+}
#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"
#ifndef BLANK_STANDALONE_PRELOADSTATE_HPP_
#define BLANK_STANDALONE_PRELOADSTATE_HPP_
-#include "../app/ProgressState.hpp"
+#include "../shared/ProgressState.hpp"
#include <cstddef>
#ifndef BLANK_STANDALONE_UNLOADSTATE_HPP_
#define BLANK_STANDALONE_UNLOADSTATE_HPP_
-#include "../app/ProgressState.hpp"
+#include "../shared/ProgressState.hpp"
#include <cstddef>
#include <list>