HoverRace  2.0
GamePeer.h
Go to the documentation of this file.
1 
2 // GamePeer.h
3 //
4 // Copyright (c) 2010, 2014-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 <luabind/luabind.hpp>
25 #include <luabind/object.hpp>
26 
27 #include "../../../engine/Script/Handlers.h"
28 #include "../../../engine/Script/Peer.h"
29 
30 namespace HoverRace {
31  namespace Client {
32  namespace HoverScript {
33  class ConfigPeer;
34  class SessionPeer;
35  }
36  class GameDirector;
37  class Rulebook;
38  class RulebookLibrary;
39  }
40  namespace Display {
41  class Display;
42  }
43  namespace Script {
44  class Core;
45  }
46 }
47 
48 namespace HoverRace {
49 namespace Client {
50 namespace HoverScript {
51 
56 class GamePeer : public Script::Peer
57 {
59 
60 public:
62  RulebookLibrary &rulebookLibrary);
63  virtual ~GamePeer() { }
64 
65 public:
66  static void Register(Script::Core &scripting);
67 
68 public:
69  void SetDisplay(Display::Display *display) { this->display = display; }
70 
71 public:
72  void OnInit();
73  void OnShutdown();
74  void OnSessionStart(std::shared_ptr<SessionPeer> sessionPeer);
75  void OnSessionEnd(std::shared_ptr<SessionPeer> sessionPeer);
76 
77 protected:
78  void VerifyInitialized() const;
79 
80 public:
81  ConfigPeer *LGetConfig();
82 
83  void LAddLocalPlayer();
84  void LAddLocalPlayer_N(const std::string &name);
85 
86  void LAnnounce(const std::string &label);
87  void LAnnounce_T(const std::string &label, const std::string &text);
88 
89  bool LIsInitialized();
90 
91  void LOnInit(const luabind::object &fn);
92  void LOnInit_N(const std::string &name, const luabind::object &fn);
93 
94  void LOnShutdown(const luabind::object &fn);
95  void LOnShutdown_N(const std::string &name, const luabind::object &fn);
96 
97  void LOnSessionBegin(const luabind::object &fn);
98  void LOnSessionBegin_N(const std::string &name, const luabind::object &fn);
99 
100  void LOnSessionEnd(const luabind::object &fn);
101  void LOnSessionEnd_N(const std::string &name, const luabind::object &fn);
102 
103  void LScreenshot();
104 
105  void LStartMenuMenu();
106 
107  void LStartPractice(const std::string &track);
108  void LStartPractice_O(const std::string &track,
109  const luabind::object &opts);
110  void LStartPractice_RO(const std::string &track,
111  const std::string &rulebookName, const luabind::object &opts);
112 
113  void LShutdown();
114 
115  bool LToggleHud();
116 
117 private:
126 };
127 
128 } // namespace HoverScript
129 } // namespace Client
130 } // namespace HoverRace
Scripting peer for system-level control of the game.
Definition: GamePeer.h:56
Interface for game client shells.
Definition: GameDirector.h:57
GameDirector & director
Definition: GamePeer.h:118
Script::Handlers onShutdown
Definition: GamePeer.h:123
Tracks event handlers registered in scripts.
Definition: Handlers.h:47
GameDirector & director
Definition: TestLabScene.cpp:160
bool initialized
Definition: GamePeer.h:121
Base class for display managers.
Definition: Display.h:73
Scripting peer for access to the game configuration.
Definition: ConfigPeer.h:43
Base class for script peers.
Definition: Peer.h:47
The collection of all registered rulebooks.
Definition: RulebookLibrary.h:40
virtual ~GamePeer()
Definition: GamePeer.h:63
void SetDisplay(Display::Display *display)
Definition: GamePeer.h:69
Script::Handlers onSessionEnd
Definition: GamePeer.h:125
Script::Handlers onInit
Definition: GamePeer.h:122
Definition: Announcement.h:24
Script::Handlers onSessionStart
Definition: GamePeer.h:124
Display::Display * display
Definition: GamePeer.h:120
RulebookLibrary & rulebookLibrary
Definition: GamePeer.h:119
A script environment.
Definition: Core.h:66