HoverRace  2.0
GameScene.h
Go to the documentation of this file.
1 
2 // GameScene.h
3 //
4 // Copyright (c) 2010, 2013-2016 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 #include "../../engine/Display/HudCell.h"
25 #include "../../engine/Util/Config.h"
26 
27 #include "Observer.h"
28 #include "GameDirector.h"
29 #include "Rules.h"
30 
31 #include "UiScene.h"
32 
33 namespace HoverRace {
34  namespace Client {
35  namespace HoverScript {
36  class MetaPlayer;
37  class MetaSession;
38  class SessionPeer;
39  class SysEnv;
40  }
41  class ClientSession;
42  class LoadingScene;
43  }
44  namespace Control {
45  class InputEventController;
46  }
47  namespace Display {
48  class Display;
49  class Hud;
50  }
51  namespace Player {
52  class Player;
53  }
54  namespace Script {
55  class Core;
56  }
57  namespace Util {
58  class Loader;
59  }
60 }
61 
62 namespace HoverRace {
63 namespace Client {
64 
69 class GameScene : public UiScene
70 {
71  using SUPER = UiScene;
72 
73 protected:
74  struct Viewport {
75  Viewport(Display::Display &display,
76  std::shared_ptr<Player::Player> player,
77  Observer *observer, Display::Hud *hud);
78 
79  Viewport(const Viewport &o) = delete;
80  Viewport(Viewport &&viewport) noexcept = default;
81 
82  Viewport &operator=(const Viewport &o) = delete;
83  Viewport &operator=(Viewport &&viewport) noexcept = default;
84 
85  void SetCell(Display::HudCell cell);
86 
87  std::shared_ptr<Player::Player> player;
88  std::unique_ptr<Observer> observer;
89  std::shared_ptr<Display::Hud> hud;
90  };
91 
92 public:
93  GameScene(const std::string &name,
95  Script::Core &scripting, std::shared_ptr<Rules> rules,
96  std::shared_ptr<Util::Loader> loader);
97  virtual ~GameScene();
98 
99 public:
100  std::ostream &OutputDebugText(std::ostream &oss) const override;
101 
102 private:
103  void Cleanup();
104 
105  void ScheduleLoad(std::shared_ptr<Util::Loader> loader);
106 
107 public:
108  bool IsMouseCursorEnabled() const override { return false; }
109 
110 protected:
111  virtual void OnFinishedLoading();
112 
113 protected:
114  void SetHudVisible(bool visible);
115  void SetMuted(bool muted);
116 
117 public:
118  void Advance(Util::OS::timestamp_t tick) override;
119  void Layout() override;
120  void PrepareRender() override;
121  void Render() override;
122 
123 private:
124  void LayoutViewports();
125 
126 private:
127  void OnRaceFinish();
128 
129 protected:
133  std::shared_ptr<Rules> rules;
134 
135 private:
137  bool muted;
138 
139 protected:
140  std::vector<Viewport> viewports;
142 
143 private:
144  boost::signals2::scoped_connection finishedLoadingConn;
145 
146  std::shared_ptr<HoverScript::MetaSession> metaSession;
147 };
148 
149 } // namespace Client
150 } // namespace HoverRace
std::shared_ptr< Player::Player > player
Definition: GameScene.h:87
Base for scenes that render and interact with tracks.
Definition: GameScene.h:69
Interface for game client shells.
Definition: GameDirector.h:57
Display::Display & display
Definition: GameScene.h:130
Base class for UI-centric scenes.
Definition: UiScene.h:42
std::unique_ptr< Observer > observer
Definition: GameScene.h:88
GameDirector & director
Definition: TestLabScene.cpp:160
boost::signals2::scoped_connection finishedLoadingConn
Definition: GameScene.h:144
std::shared_ptr< Rules > rules
Definition: GameScene.h:133
ClientSession * session
Definition: GameScene.h:141
Definition: GameScene.h:74
The container for the heads-up display.
Definition: Hud.h:63
bool muted
Definition: GameScene.h:137
Base class for display managers.
Definition: Display.h:73
Definition: Observer.h:41
bool finishedLoading
Definition: GameScene.h:136
std::vector< Viewport > viewports
Definition: GameScene.h:140
Script::Core & scripting
Definition: GameScene.h:132
std::shared_ptr< Display::Hud > hud
Definition: GameScene.h:89
bool IsMouseCursorEnabled() const override
Determine if the mouse cursor is enabled for this scene.
Definition: GameScene.h:108
GameDirector & director
Definition: GameScene.h:131
Definition: ClientSession.h:58
Definition: Announcement.h:24
HudCell
Split-screen HUD grid locations.
Definition: HudCell.h:28
std::shared_ptr< HoverScript::MetaSession > metaSession
Definition: GameScene.h:146
MR_Int64 timestamp_t
Definition: OS.h:55
A script environment.
Definition: Core.h:66