Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InexorCefApp.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <list>
4 #include <string> // for string
5 
6 #include "SDL_events.h" // for SDL_Event
7 #include "include/cef_app.h" // for CefApp
8 #include "include/cef_base.h" // for CefRefPtr, IMP...
9 #include "include/cef_browser_process_handler.h" // for CefBrowserProc...
10 #include "inexor/ui/context/InexorContextManager.hpp" // for InexorContextM...
11 #include "inexor/ui/input/InexorKeyboardManager.hpp" // for InexorKeyboard...
12 #include "inexor/ui/input/InexorMouseManager.hpp" // for InexorMouseMan...
13 #include "inexor/ui/layer/InexorAppLayer.hpp" // for InexorAppLayer
14 #include "inexor/ui/layer/InexorConsoleLayer.hpp" // for InexorConsoleL...
15 #include "inexor/ui/layer/InexorHudLayer.hpp" // for InexorHudLayer
16 #include "inexor/ui/layer/InexorLayerManager.hpp" // for InexorLayerMan...
17 
18 class CefBrowser;
19 class CefFrame;
20 class CefV8Context;
21 
22 namespace inexor {
23 namespace ui {
24 
25 class InexorCefApp : public CefApp,
26  public CefBrowserProcessHandler
27 {
28 
29  public:
30  InexorCefApp(std::string instance_id, std::string host, std::string port, int width, int height);
31 
32  void Destroy();
33 
34  // Getters for handlers
35  CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override { return this; }
36  CefRefPtr<context::InexorContextManager> GetContextManager() { return context_manager; }
37  CefRefPtr<input::InexorMouseManager> GetMouseManager() { return mouse_manager; }
38  CefRefPtr<input::InexorKeyboardManager> GetKeyboardManager() { return keyboard_manager; }
39  CefRefPtr<layer::InexorLayerManager> GetLayerManager() { return layer_manager; }
40  CefRefPtr<layer::InexorHudLayer> GetHudLayer() { return hud_layer; }
41  CefRefPtr<layer::InexorConsoleLayer> GetConsoleLayer() { return console_layer; }
42  CefRefPtr<layer::InexorAppLayer> GetAppLayer() { return app_layer; }
43 
44  // Rendering / Window Management
45  void SetScreenSize(int width, int height);
46 
47  // CefBrowserProcessHandler
48  void OnContextInitialized() override;
49  // void OnBeforeChildProcessLaunch(CefRefPtr app, CefRefPtr command_line) {}
50  // void OnRenderProcessThreadCreated(CefRefPtr app, CefRefPtr extra_info) {}
51 
52  // CefRenderProcessHandler
53  void OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context);
54 
60  bool HandleSdlEvent(SDL_Event &e);
61 
62  private:
63  CefRefPtr<context::InexorContextManager> context_manager;
64  CefRefPtr<input::InexorMouseManager> mouse_manager;
65  CefRefPtr<input::InexorKeyboardManager> keyboard_manager;
66  CefRefPtr<layer::InexorLayerManager> layer_manager;
67  CefRefPtr<layer::InexorHudLayer> hud_layer;
68  CefRefPtr<layer::InexorConsoleLayer> console_layer;
69  CefRefPtr<layer::InexorAppLayer> app_layer;
70 
71  void InitHudLayer(std::string instance_id, std::string host, std::string port);
72  void InitConsoleLayer(std::string instance_id, std::string host, std::string port);
73  void InitAppLayer(std::string instance_id, std::string host, std::string port);
74 
76 };
77 extern CefRefPtr<InexorCefApp> cef_app;
78 
79 }
80 }
CefRefPtr< layer::InexorConsoleLayer > console_layer
Definition: InexorCefApp.hpp:68
GLenum GLsizei GLsizei height
Definition: glexts.hpp:291
CefRefPtr< input::InexorKeyboardManager > GetKeyboardManager()
Definition: InexorCefApp.hpp:38
void OnContextInitialized() override
Definition: InexorCefApp.cpp:82
void Destroy()
Definition: InexorCefApp.cpp:72
GLenum GLsizei width
Definition: glexts.hpp:291
bool HandleSdlEvent(SDL_Event &e)
Handle SDL events for CEF.
Definition: InexorCefApp.cpp:95
CefRefPtr< CefBrowserProcessHandler > GetBrowserProcessHandler() override
Definition: InexorCefApp.hpp:35
CefRefPtr< layer::InexorLayerManager > layer_manager
Definition: InexorCefApp.hpp:66
CefRefPtr< input::InexorKeyboardManager > keyboard_manager
Definition: InexorCefApp.hpp:65
void OnContextCreated(CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, CefRefPtr< CefV8Context > context)
Definition: InexorCefApp.cpp:88
CefRefPtr< layer::InexorAppLayer > GetAppLayer()
Definition: InexorCefApp.hpp:42
void InitHudLayer(std::string instance_id, std::string host, std::string port)
Definition: InexorCefApp.cpp:39
CefRefPtr< layer::InexorAppLayer > app_layer
Definition: InexorCefApp.hpp:69
CefRefPtr< layer::InexorLayerManager > GetLayerManager()
Definition: InexorCefApp.hpp:39
void InitAppLayer(std::string instance_id, std::string host, std::string port)
Definition: InexorCefApp.cpp:61
void SetScreenSize(int width, int height)
Definition: InexorCefApp.cpp:77
CefRefPtr< input::InexorMouseManager > GetMouseManager()
Definition: InexorCefApp.hpp:37
CefRefPtr< layer::InexorHudLayer > hud_layer
Definition: InexorCefApp.hpp:67
char string[MAXSTRLEN]
cube-strings (char arrays of fixed size).
Definition: cube_types.hpp:18
InexorCefApp(std::string instance_id, std::string host, std::string port, int width, int height)
Definition: InexorCefApp.cpp:17
CefRefPtr< context::InexorContextManager > GetContextManager()
Definition: InexorCefApp.hpp:36
void InitConsoleLayer(std::string instance_id, std::string host, std::string port)
Definition: InexorCefApp.cpp:50
CefRefPtr< input::InexorMouseManager > mouse_manager
Definition: InexorCefApp.hpp:64
CefRefPtr< layer::InexorConsoleLayer > GetConsoleLayer()
Definition: InexorCefApp.hpp:41
Definition: InexorCefApp.hpp:25
CefRefPtr< context::InexorContextManager > context_manager
Definition: InexorCefApp.hpp:63
CefRefPtr< InexorCefApp > cef_app
Definition: CefSubsystem.cpp:26
IMPLEMENT_REFCOUNTING(InexorCefApp)
CefRefPtr< layer::InexorHudLayer > GetHudLayer()
Definition: InexorCefApp.hpp:40