-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCGame.h
97 lines (78 loc) · 2.14 KB
/
CGame.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright (C) 2009 - 2021 Marc Vester (XaserLE)
// Copyright (C) 2009 - 2021 Settlers Freaks <sf-team at siedler25.org>
//
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include "CIO/CFont.h"
#include "SdlSurface.h"
#include <Point.h>
#include <memory>
#include <vector>
class CWindow;
class CMap;
class CMenu;
class CGame
{
friend class CDebug;
public:
Extent GameResolution;
bool fullscreen;
bool Running;
bool showLoadScreen;
SdlSurface Surf_Display;
SdlTexture displayTexture_;
SdlRenderer renderer_;
SdlWindow window_;
private:
#ifdef _ADMINMODE
// some debugging variables
unsigned long int FrameCounter = 0;
#endif
// milliseconds for SDL_Delay()
Uint32 msWait = 0;
Uint32 framesPassedSinceLastFps = 0;
Uint32 lastFpsTick = 0;
CFont lastFps;
Uint32 lastFrameTime = 0;
// structure for mouse cursor
struct
{
Position pos = {0, 0};
bool clicked = false;
struct
{
bool left = false;
bool right = false;
} button;
} Cursor;
// Object for Menu Screens
std::vector<std::unique_ptr<CMenu>> Menus;
// Object for Windows
std::vector<std::unique_ptr<CWindow>> Windows;
// Object for Callbacks
std::vector<void (*)(int)> Callbacks;
// Object for the Map
std::unique_ptr<CMap> MapObj;
void SetAppIcon();
public:
CGame(Extent GameResolution_, bool fullscreen_);
~CGame();
int Execute();
bool Init();
bool ReCreateWindow();
void EventHandling(SDL_Event* Event);
void GameLoop();
void Render();
void RenderPresent() const;
CMenu* RegisterMenu(std::unique_ptr<CMenu> Menu);
bool UnregisterMenu(CMenu* Menu);
CWindow* RegisterWindow(std::unique_ptr<CWindow> Window);
bool UnregisterWindow(CWindow* Window);
void RegisterCallback(void (*callback)(int));
bool UnregisterCallback(void (*callback)(int));
void setMapObj(std::unique_ptr<CMap> MapObj);
CMap* getMapObj();
void delMapObj();
SDL_Surface* getDisplaySurface() const { return Surf_Display.get(); };
auto getRes() const { return GameResolution; }
};