-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGameSystemExtended.h
77 lines (66 loc) · 2.55 KB
/
GameSystemExtended.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
#ifndef GAMESYSTEMEXTENDED_H_INCLUDED
#define GAMESYSTEMEXTENDED_H_INCLUDED
#include "../../isEngine/system/function/GameSystem.h"
#include "../../isEngine/ext_lib/TinyFileDialogs/TinyDialogBox.h"
////////////////////////////////////////////////////////////
/// \brief Class derived from GameSystem to manage the
/// different engine components
///
/// Allows to manage the saving / loading of game and
/// configuration data, manipulate the data of the virtual
/// Game Pad and act on the different scenes of the game
////////////////////////////////////////////////////////////
namespace is
{
class GameSystemExtended : public GameSystem
{
public:
GameSystemExtended(sf::RenderWindow &window);
/// Initialize the data link to the game engine
void initSystemData();
/// Save config data
void saveConfig(std::string const &fileName)
{
FILE *file = NULL;
file = fopen(fileName.c_str(), "wb");
if (file != NULL)
{
fwrite(&m_enableSound, sizeof(bool), 1, file);
fwrite(&m_enableLoadTex, sizeof(bool), 1, file);
fwrite(&m_enableAutoSave, sizeof(bool), 1, file);
fwrite(&m_gameLanguage, sizeof(int), 1, file);
fwrite(&m_firstLaunch, sizeof(bool), 1, file);
fclose(file);
}
}
/// Load config data
void loadConfig(std::string const &fileName)
{
FILE *file = NULL;
file = fopen(fileName.c_str(), "rb");
if (file != NULL)
{
fread(&m_enableSound, sizeof(bool), 1, file);
fread(&m_enableLoadTex, sizeof(bool), 1, file);
fread(&m_enableAutoSave, sizeof(bool), 1, file);
fread(&m_gameLanguage, sizeof(int), 1, file);
fread(&m_firstLaunch, sizeof(bool), 1, file);
fclose(file);
}
}
/// default filter patterns
tinyString TINY_FILTER_PATTERNS[2] = {
#if !defined(SFML_SYSTEM_LINUX) && !defined(IS_ENGINE_LINUX)
L"*.sav", L"*.save"
#else
"*.sav", "*.save"
#endif
};
/// Allows to choose the scene that will be launched
is::DisplayOption m_launchOption = is::GameConfig::LAUNCH_OPTION; // Represents the first scene to be launched
bool m_enableLoadTex;
bool m_enableAutoSave;
std::string m_filePath;
};
}
#endif // GAMESYSTEMEXTENDED_H_INCLUDED