Rise
The Vieneo Province
Loading...
Searching...
No Matches
GameClass.h
Go to the documentation of this file.
1#pragma once
2
3#define DIRECTINPUT_VERSION 0x0800
4
5//#define _TOUCHFILES // be careful this will slow down the PatchScan process now! ONLY WORKS WITH DEBUG BUILD
6
7#include "gui.h"
8#include "Sound.h"
9#include "Graphics.h"
10#include "Bus.h"
11#include "Logger.h"
12#include "Displays/Displays.h"
13#include "Modules/Module.h"
15#include "Config/config.h"
16#include "GameState.h"
17#include "DiscordIntegration.h"
18#include <memory>
19
20// TeamSpeak
21//#include <public_definitions.h>
22
23#define designedWidthC 1680.0f
24#define designedHeightC 1050.0f
25
26class Viewscreen;
27
29{
30public:
31 char name[32];
33 char status = 0; // 0=created, 1=lost, 2=reset, 3=released
34 // could track type
35 // could track state
36 Resource(const char* prmName, Rendering::ResourcePool prmPool)
37 {
38 strcpy_s(name, 32, prmName);
39 pool = prmPool;
40 }
41};
42
44{
45 void InitializeGame();
47
48 // probably change the type to some object that has a string name
49 // status enum (created, lost, reset, dropped)
50 std::vector<Resource> trackedResources;
51
52 float lastDeviceChange = 2.0f; // for WM_DEVICECHANGE
55 HDEVNOTIFY dev_notify = nullptr;
56 bool maximized = false;
57
58public:
59 GameClass();
60 ~GameClass();
61 void Close();
62 void KillScannerData() const;
63 void RequestScannerData() const;
64 static void TouchFile(const WCHAR* str);
65 void RepairVehicle() const;
66 void RequestClose() const;
67 void ToggleFullScreen(bool goFullScreen);
68
69 //Default callback functions from DXUT
70 //need to be static since we can't use instantiated class members as callbacks, we can pass ourselves in the pUserContext tho
71 static HRESULT CALLBACK OnCreateDevice(Rendering::RenderDevice* pd3dDevice, const Rendering::SurfaceDescription* pBackBufferSurfaceDesc, void* pUserContext);
72 static HRESULT CALLBACK OnResetDevice(Rendering::RenderDevice* pd3dDevice, const Rendering::SurfaceDescription* pBackBufferSurfaceDesc, void* pUserContext);
73 static void CALLBACK OnFrameMove(double fTime, float fElapsedTime, void* pUserContext);
74 static void CALLBACK OnFrameRender(Rendering::RenderDevice* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext);
75 static LRESULT CALLBACK MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing, void* pUserContext);
76 static void CALLBACK KeyboardProc(UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext);
77 static void CALLBACK OnLostDevice(void* pUserContext);
78 static void CALLBACK OnDestroyDevice(void* pUserContext);
80
81 void LoadTexture(Rendering::RenderTexture** resource, const std::string& pointerName, const WCHAR* file, Rendering::ImageFormat format = Rendering::ImageFormat::BGRA8);
82 void ChangeGear(char newGear, bool isInit = false) const;
83
84 void FlightDirectorOn() const;
85 void AutopilotDisconnect() const;
86 bool TurnOffTVM() const;
87 bool TurnOffDOR(bool preserveGuidance = false) const;
88 void LostScannerTarget(const char* msg) const;
89 void LostVerticalTarget(const char* msg) const;
90 void UseOrDisuseInventoryItemType(int itemtype, int itemsubtype, int itemId, int vehicleId) const;
91 void GetProgramVersion(int& major, int& minor, int& build, int& revision) const;
92 static float GetCpuSpeedMhz();
93
95 void UpdateTrackedResource(const char* name, int status); // 0=created, 1=lost, 2=reset, 3=released
96
97 HRESULT InitDirectInput(HWND hDlg) const;
98
99 //public vars
102
103 std::unique_ptr<Networking> networking;
104 std::unique_ptr<Sound> sound;
105 std::unique_ptr<Graphics> graphics;
106 std::unique_ptr<HMI> GUI;
107 std::unique_ptr<Viewscreen> viewscreen;
108 std::unique_ptr<Bus> bus;
109 std::unique_ptr<Logger> logger;
110 std::unique_ptr<Displays> displays;
111 std::unique_ptr<DiscordIntegration> discord;
112
113 std::vector<std::unique_ptr<Module>> modules;
115
117
119 short loadstage = 0;
120
121 short stage = 0, instage = 0;
122
123 // Device-dependent preparation stays in the loading window. Window promotion
124 // happens once, after a game frame presents; recovery preserves its placement.
128 unsigned char beginScene = 0;
129
130 float displayscale = 0, dpiscale = 0;
132
133 bool showKeymapOverlay = false;
134 bool timeLapse = false;
135
136};
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
GameState
Definition GameState.h:4
@ STATUS_SPLASH
Definition GameState.h:5
unsigned char beginScene
Definition GameClass.h:128
float lastDeviceChange
Definition GameClass.h:52
float FrameElapsedTime
Definition GameClass.h:116
HRESULT InitializeGameHud()
short instage
Definition GameClass.h:121
GameState displaystage
Definition GameClass.h:118
void LoadTexture(Rendering::RenderTexture **resource, const std::string &pointerName, const WCHAR *file, Rendering::ImageFormat format=Rendering::ImageFormat::BGRA8)
std::unique_ptr< Bus > bus
Definition GameClass.h:108
static HRESULT CALLBACK OnResetDevice(Rendering::RenderDevice *pd3dDevice, const Rendering::SurfaceDescription *pBackBufferSurfaceDesc, void *pUserContext)
bool lastDeviceChangedSound
Definition GameClass.h:53
Config config
Definition GameClass.h:100
void LostScannerTarget(const char *msg) const
void RequestScannerData() const
static void CALLBACK OnDestroyDevice(void *pUserContext)
void UnregisterDeviceNotifications()
Definition GameClass.cpp:92
void GetProgramVersion(int &major, int &minor, int &build, int &revision) const
std::unique_ptr< HMI > GUI
Definition GameClass.h:106
HRESULT InitDirectInput(HWND hDlg) const
float dpiscale
Definition GameClass.h:130
void UseOrDisuseInventoryItemType(int itemtype, int itemsubtype, int itemId, int vehicleId) const
bool loadingLabelsReady
Definition GameClass.h:125
std::unique_ptr< Sound > sound
Definition GameClass.h:104
static void CALLBACK KeyboardProc(UINT nChar, bool bKeyDown, bool bAltDown, void *pUserContext)
void LostVerticalTarget(const char *msg) const
bool TurnOffTVM() const
std::unique_ptr< Networking > networking
Definition GameClass.h:103
void AddTrackedResource(const char *name, Rendering::ResourcePool pool=Rendering::ResourcePool::Managed)
short stage
Definition GameClass.h:121
bool vphelp[vphelpC]
Definition GameClass.h:101
void UpdateTrackedResource(const char *name, int status)
void Close()
void RequestClose() const
static void CALLBACK OnLostDevice(void *pUserContext)
bool gameWindowShown
Definition GameClass.h:125
std::vector< Resource > trackedResources
Definition GameClass.h:50
void FlightDirectorOn() const
std::unique_ptr< Displays > displays
Definition GameClass.h:110
bool showKeymapOverlay
Definition GameClass.h:133
static void CALLBACK OnFrameMove(double fTime, float fElapsedTime, void *pUserContext)
static float GetCpuSpeedMhz()
HDEVNOTIFY dev_notify
Definition GameClass.h:55
static void CALLBACK OnFrameRender(Rendering::RenderDevice *pd3dDevice, double fTime, float fElapsedTime, void *pUserContext)
bool loadingReadyToContinue
Definition GameClass.h:126
bool timeLapse
Definition GameClass.h:134
std::vector< std::unique_ptr< Module > > modules
Definition GameClass.h:113
void RepairVehicle() const
static void TouchFile(const WCHAR *str)
HRESULT OnFramePresented()
std::unique_ptr< DiscordIntegration > discord
Definition GameClass.h:111
void InitializeGame()
ModuleScheduler moduleScheduler
Definition GameClass.h:114
void KillScannerData() const
short loadstage
Definition GameClass.h:119
static LRESULT CALLBACK MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool *pbNoFurtherProcessing, void *pUserContext)
bool lastDeviceChangedInput
Definition GameClass.h:54
std::unique_ptr< Viewscreen > viewscreen
Definition GameClass.h:107
bool TurnOffDOR(bool preserveGuidance=false) const
float displayscale
Definition GameClass.h:130
void ChangeGear(char newGear, bool isInit=false) const
bool gameGraphicsReady
Definition GameClass.h:125
std::unique_ptr< Graphics > graphics
Definition GameClass.h:105
float displayWidth
Definition GameClass.h:131
std::unique_ptr< Logger > logger
Definition GameClass.h:109
static HRESULT CALLBACK OnCreateDevice(Rendering::RenderDevice *pd3dDevice, const Rendering::SurfaceDescription *pBackBufferSurfaceDesc, void *pUserContext)
float displayHeight
Definition GameClass.h:131
void ToggleFullScreen(bool goFullScreen)
void AutopilotDisconnect() const
bool maximized
Definition GameClass.h:56
Resource(const char *prmName, Rendering::ResourcePool prmPool)
Definition GameClass.h:36
char status
Definition GameClass.h:33
char name[32]
Definition GameClass.h:31
Rendering::ResourcePool pool
Definition GameClass.h:32
#define vphelpC
Definition globals.h:74