Etterna 0.74.4
Loading...
Searching...
No Matches
ProfileManager.h
1#ifndef ProfileManager_H
2#define ProfileManager_H
3
4#include "Etterna/Models/Misc/Difficulty.h"
5#include "Etterna/Models/Misc/GameConstantsAndTypes.h"
6#include "Etterna/Models/Misc/PlayerNumber.h"
7#include "Etterna/Models/Misc/Preference.h"
8#include "Etterna/Models/Misc/Profile.h"
9#include "arch/LoadingWindow/LoadingWindow.h"
10
11class Song;
12class Steps;
13class Style;
14struct HighScore;
15struct lua_State;
17{
18 public:
21
22 void Init(LoadingWindow* ld);
23
24 auto FixedProfiles() const
25 -> bool; // If true, profiles shouldn't be added/deleted
26
27 // local profiles
28 void UnloadAllLocalProfiles();
29 void RefreshLocalProfilesFromDisk();
30 void RefreshLocalProfilesFromDisk(LoadingWindow* ld);
31 auto GetLocalProfile(const std::string& sProfileID) const -> const Profile*;
32 auto GetLocalProfile(const std::string& sProfileID) -> Profile*
33 {
34 return const_cast<Profile*>(
35 static_cast<const ProfileManager*>(this)->GetLocalProfile(
36 sProfileID));
37 }
38 auto GetLocalProfileFromIndex(int iIndex) -> Profile*;
39 auto GetLocalProfileIDFromIndex(int iIndex) -> std::string;
40
41 auto CreateLocalProfile(const std::string& sName,
42 std::string& sProfileIDOut) -> bool;
43 void AddLocalProfileByID(
44 Profile* pProfile,
45 const std::string& sProfileID); // transfers ownership of pProfile
46 auto RenameLocalProfile(const std::string& sProfileID,
47 const std::string& sNewName) -> bool;
48 void GetLocalProfileIDs(std::vector<std::string>& vsProfileIDsOut) const;
49 void GetLocalProfileDisplayNames(
50 std::vector<std::string>& vsProfileDisplayNamesOut) const;
51 auto GetLocalProfileIndexFromID(const std::string& sProfileID) const -> int;
52 auto GetNumLocalProfiles() const -> int;
53
54 auto GetStatsPrefix() -> std::string { return m_stats_prefix; }
55 void SetStatsPrefix(std::string const& prefix);
56
57 auto LoadFirstAvailableProfile(PlayerNumber pn, bool bLoadEdits = true)
58 -> bool;
59 auto LoadLocalProfileFromMachine(PlayerNumber pn) -> bool;
60 auto SaveProfile(PlayerNumber pn) const -> bool;
61 auto SaveLocalProfile(const std::string& sProfileID) -> bool;
62 void UnloadProfile(PlayerNumber pn);
63
64 void MergeLocalProfiles(std::string const& from_id,
65 std::string const& to_id);
66 void MoveProfilePriority(int index, bool up);
67
68 // General data
69 void IncrementToastiesCount(PlayerNumber pn);
70 void AddStepTotals(PlayerNumber pn,
71 int iNumTapsAndHolds,
72 int iNumJumps,
73 int iNumHolds,
74 int iNumRolls,
75 int iNumMines,
76 int iNumHands,
77 int iNumLifts);
78
79 // return a profile even if !IsUsingProfile
80 auto GetProfile(PlayerNumber pn) const -> const Profile*;
81 auto GetProfile(PlayerNumber pn) -> Profile*
82 {
83 return const_cast<Profile*>(
84 static_cast<const ProfileManager*>(this)->GetProfile(pn));
85 }
86 auto GetProfile(ProfileSlot slot) const -> const Profile*;
87 auto GetProfile(ProfileSlot slot) -> Profile*
88 {
89 return const_cast<Profile*>(
90 static_cast<const ProfileManager*>(this)->GetProfile(slot));
91 }
92
93 auto GetProfileDir(ProfileSlot slot) const -> const std::string&;
94
95 auto GetPlayerName(PlayerNumber pn) const -> std::string;
96 auto LastLoadWasTamperedOrCorrupt(PlayerNumber pn) const -> bool;
97 auto LastLoadWasFromLastGood(PlayerNumber pn) const -> bool;
98
99 void IncrementStepsPlayCount(const Song* pSong,
100 const Steps* pSteps,
101 PlayerNumber pn);
102 // Lua
103 void PushSelf(lua_State* L);
104
105 static Preference1D<std::string> m_sDefaultLocalProfileID;
106
107 private:
108 auto LoadProfile(PlayerNumber pn, const std::string& sProfileDir)
109 -> ProfileLoadResult;
110
111 // Directory that contains the profile. Either on local machine or
112 // on a memory card.
113 std::string m_sProfileDir;
114
115 std::string m_stats_prefix;
116 Profile* dummy;
117 bool m_bLastLoadWasTamperedOrCorrupt; // true if Stats.xml was
118 // present, but failed to
119 // load (probably because
120 // of a signature
121 // failure)
122 bool m_bLastLoadWasFromLastGood; // if true, then
123 // m_bLastLoadWasTamperedOrCorrupt
124 // is also true
125 mutable bool m_bNeedToBackUpLastLoad; // if true, back up
126 // profile on next save
127 bool m_bNewProfile;
128};
129
130extern ProfileManager*
131 PROFILEMAN; // global and accessible from anywhere in our program
132
133#endif
Opens and displays the loading banner.
Definition LoadingWindow.h:9
Definition Preference.h:137
Definition ProfileManager.h:17
Player data that persists between sessions.
Definition Profile.h:130
Holds all music metadata and steps for one song.
Definition Song.h:65
Holds note information for a Song.
Definition Steps.h:42
Definition Style.h:22
The high score that is earned by a player.
Definition HighScore.h:18