-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.cpp
More file actions
60 lines (48 loc) · 1.57 KB
/
Copy pathconfig.cpp
File metadata and controls
60 lines (48 loc) · 1.57 KB
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
#include "config.h"
#include "crossplatform.h"
#include <fstream>
SConfig SyobonGlobalConfig;
void SaveConfig()
{
const char * psave_dir = GetSavePath();
if(psave_dir)
{
char filepath[256] = {0};
snprintf(filepath, sizeof(filepath), "%s/save.txt", GetSavePath());
std::ofstream file(filepath);
for(auto &LevelFinished : SyobonGlobalConfig.LevelsFinished)
{
file << "LEVEL_FINISHED " << (int)LevelFinished.Game << " " << LevelFinished.World << " " << LevelFinished.Level << std::endl;
file << "FULLSCREEN " << (int)SyobonKZIsFullscreen() << std::endl;
}
file.close();
}
}
void LoadConfig()
{
SyobonGlobalConfig.LevelsFinished.clear();
const char * psave_dir = GetSavePath();
if(psave_dir)
{
char filepath[256] = {0};
snprintf(filepath, sizeof(filepath), "%s/save.txt", psave_dir);
std::ifstream file(filepath);
std::string line;
while(std::getline(file, line))
{
if(strstr(line.c_str(), "LEVEL_FINISHED"))
{
SSyobonGameLevel temp;
int game;
sscanf(line.c_str(), "LEVEL_FINISHED %d %d %d", &game, &temp.World, &temp.Level);
temp.Game = (ESyobonActionGame)game;
SyobonGlobalConfig.LevelsFinished.insert(temp);
}
if(strstr(line.c_str(), "FULLSCREEN"))
{
sscanf(line.c_str(), "FULLSCREEN %d", &SyobonGlobalConfig.Fullscreen);
}
}
file.close();
}
}