Merge pull request #310 from andiabrudan/duplicate_profiles
Add option to duplicate profile
This commit is contained in:
commit
342b1a1a3e
@ -173,6 +173,13 @@ namespace cheat
|
||||
config::RemoveProfile(profileName);
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Delete");
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::SmallButton("Dupe"))
|
||||
config::DuplicateProfile(profileName);
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Duplicate Profile");
|
||||
}
|
||||
|
||||
void CheatManagerBase::DrawProfileEntry(const std::string& profileName)
|
||||
|
@ -371,6 +371,27 @@ namespace config
|
||||
ProfileChanged();
|
||||
}
|
||||
|
||||
void DuplicateProfile(const std::string& profileName)
|
||||
{
|
||||
// Find a unique name for the new profile
|
||||
uint32_t counter = 0;
|
||||
std::ostringstream buffer;
|
||||
std::string newProfileName;
|
||||
do
|
||||
{
|
||||
buffer.str(std::string());
|
||||
buffer.clear();
|
||||
counter++;
|
||||
buffer << profileName << " (" << counter << ")";
|
||||
newProfileName = buffer.str();
|
||||
} while (s_Profiles->contains(newProfileName));
|
||||
|
||||
// nlohmann::json copy constructor will take care of duplicating
|
||||
(*s_Profiles)[newProfileName] = (*s_Profiles)[profileName];
|
||||
UpdateProfilesNames();
|
||||
Save();
|
||||
}
|
||||
|
||||
std::vector<std::string> const& GetProfiles()
|
||||
{
|
||||
return s_ProfilesNames;
|
||||
|
@ -63,6 +63,7 @@ namespace config
|
||||
void RemoveProfile(const std::string& profileName);
|
||||
void RenameProfile(const std::string& oldProfileName, const std::string& newProfileName);
|
||||
void ChangeProfile(const std::string& profileName);
|
||||
void DuplicateProfile(const std::string& profileName);
|
||||
std::vector<std::string> const& GetProfiles();
|
||||
std::string const& CurrentProfileName();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user