Etterna 0.74.4
Loading...
Searching...
No Matches
DBProfile.h
1#ifndef Profile_DB
2#define Profile_DB
3
4#include "GameConstantsAndTypes.h"
5#include "Etterna/Models/HighScore/HighScore.h"
6#include <SQLiteCpp/SQLiteCpp.h>
7
8class Profile;
9
10enum DBProfileMode
11{
12 WriteOnlyWebExport,
13 LocalWithReplayData,
14 LocalWithoutReplayData,
15 NUM_DBProfileMode,
16 DBProfileMode_Invalid,
17};
18
20{
21 public:
22 enum ProfileLoadResult LoadDBFromDir(const std::string& dir);
23 ProfileLoadResult LoadDBFromDir(const std::string& dir, Profile* profile);
24
25 ProfileLoadResult SaveDBToDir(const std::string& sDir,
26 const Profile* profile,
27 DBProfileMode mode) const;
28
29 static void MoveBackupToDir(const std::string& sFromDir,
30 const std::string& sToDir,
31 DBProfileMode mode);
32
33 void SetLoadingProfile(Profile* p) { loadingProfile = p; }
34
35 static auto WriteReplayData(const HighScore* hs) -> bool;
36
37 private:
38 Profile* loadingProfile{ nullptr };
39 static auto GetChartKeyID(SQLite::Database* db, const std::string& key) -> int;
40 static auto GetChartKeyByID(SQLite::Database* db, int id) -> std::string;
41 static auto FindOrCreateChartKey(SQLite::Database* db, const std::string& key)
42 -> int;
43 static auto FindOrCreateSong(SQLite::Database* db,
44 const std::string& pack,
45 const std::string& song) -> int;
46 static auto FindOrCreateChart(SQLite::Database* db,
47 const std::string& chartkey,
48 const std::string& pack,
49 const std::string& song,
50 Difficulty diff) -> int;
51 static auto GetScoreKeyID(SQLite::Database* db, const std::string& key) -> int;
52 static auto FindOrCreateScoreKey(SQLite::Database* db, const std::string& key)
53 -> int;
54
55 void LoadFavourites(SQLite::Database* db);
56 void LoadPlayLists(SQLite::Database* db);
57 static void LoadPlayerScores(SQLite::Database* db);
58 auto LoadGeneralData(SQLite::Database* db) -> bool;
59 void LoadPermaMirrors(SQLite::Database* db);
60 void LoadScoreGoals(SQLite::Database* db);
61
62 static void SaveFavourites(SQLite::Database* db, const Profile* profile);
63 static void SavePlayLists(SQLite::Database* db, const Profile* profile);
64 static void SavePlayerScores(SQLite::Database* db,
65 const Profile* profile,
66 DBProfileMode mode);
67 static void SaveGeneralData(SQLite::Database* db, const Profile* profile);
68 static void SavePermaMirrors(SQLite::Database* db, const Profile* profile);
69 static void SaveScoreGoals(SQLite::Database* db, const Profile* profile);
70};
71
72#endif
Definition DBProfile.h:20
Player data that persists between sessions.
Definition Profile.h:130
The high score that is earned by a player.
Definition HighScore.h:18