-
Notifications
You must be signed in to change notification settings - Fork 0
/
load.h
80 lines (63 loc) · 2.33 KB
/
load.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
#pragma once
#include <storage/storage.h>
#include "common.h"
#define ASSETS_LEVELS_COUNT 9
#define MAX_LEVELS_PER_SET 100
extern char* assetLevels[];
typedef struct {
uint16_t moves;
bool spoiled;
} LevelScore;
typedef struct {
FuriString* id;
FuriString* title;
FuriString* author;
FuriString* description;
FuriString* url;
uint8_t maxLevel;
LevelScore scores[MAX_LEVELS_PER_SET];
uint8_t pars[MAX_LEVELS_PER_SET];
} LevelSet;
typedef struct {
FuriString* solution;
FuriString* board;
FuriString* title;
unsigned int gamePar;
} LevelData;
typedef struct {
FuriString** ids;
int count;
} LevelList;
//-----------------------------------------------------------------------------
LevelSet* alloc_level_set();
void free_level_set(LevelSet* ls);
LevelData* alloc_level_data();
void free_level_data(LevelData* ld);
void init_level_list(LevelList* ls, int capacity);
void free_level_list(LevelList* ls);
//-----------------------------------------------------------------------------
bool ensure_paths(Storage* storage);
bool level_set_id_to_path(Storage* storage, FuriString* levelSetId, size_t maxSize, char* path);
//-----------------------------------------------------------------------------
bool load_level_set(
Storage* storage,
FuriString* levelSetId,
LevelSet* levelSet,
FuriString* errorMsg);
bool load_last_level(FuriString* lastLevelSetId, uint8_t* levelNo);
bool save_last_level(FuriString* lastLevelSetId, uint8_t levelNo);
bool load_set_scores(Storage* storage, FuriString* levelSetId, LevelScore* scores);
bool save_set_scores(FuriString* levelSetId, LevelScore* scores);
void delete_progress(LevelScore* scores);
//-----------------------------------------------------------------------------
int load_level_row(uint8_t* pb, const char* psz, const char* pszMax);
bool parse_level_notation(const char* pszLevel, PlayGround* level);
bool load_level(
Storage* storage,
FuriString* levelSetId,
int level,
LevelData* levelData,
FuriString* errorMsg);
//-----------------------------------------------------------------------------
void list_extra_levels(Storage* storage, LevelList* levelList);
void mark_set_invalid(Storage* storage, FuriString* levelSetId, FuriString* errorMsg);