mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-05-29 08:12:52 -04:00
clear single achievement and fix achievement tab moving around
This commit is contained in:
@@ -40,6 +40,7 @@ public:
|
||||
void save();
|
||||
void tick();
|
||||
void clearAll();
|
||||
void clearOne(const char* key);
|
||||
|
||||
std::vector<Achievement> getAchievements() const;
|
||||
bool hasPendingUnlock() const { return !m_pendingUnlocks.empty(); }
|
||||
|
||||
@@ -426,6 +426,18 @@ void AchievementSystem::clearAll() {
|
||||
save();
|
||||
}
|
||||
|
||||
void AchievementSystem::clearOne(const char* key) {
|
||||
for (auto& e : m_entries) {
|
||||
if (std::string(e.achievement.key) == key) {
|
||||
e.achievement.progress = 0;
|
||||
e.achievement.unlocked = false;
|
||||
e.extra = {};
|
||||
break;
|
||||
}
|
||||
}
|
||||
save();
|
||||
}
|
||||
|
||||
void AchievementSystem::processEntry(Entry& e) {
|
||||
if (e.achievement.unlocked) {
|
||||
return;
|
||||
|
||||
@@ -131,7 +131,7 @@ void ImGuiAchievements::draw(bool& open) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const std::string tabLabel = fmt::format("{} ({}/{})", catInfo.label, catUnlocked, catTotal);
|
||||
const std::string tabLabel = fmt::format("{} ({}/{})###{}", catInfo.label, catUnlocked, catTotal, catInfo.label);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, catInfo.color);
|
||||
const bool tabOpen = ImGui::BeginTabItem(tabLabel.c_str());
|
||||
@@ -152,6 +152,7 @@ void ImGuiAchievements::draw(bool& open) {
|
||||
continue;
|
||||
}
|
||||
ImGui::PushID(a.key);
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::PushStyleColor(
|
||||
ImGuiCol_Text,
|
||||
@@ -190,6 +191,21 @@ void ImGuiAchievements::draw(bool& open) {
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
ImGui::EndGroup();
|
||||
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Right)) {
|
||||
ImGui::OpenPopup("##ctx");
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopup("##ctx")) {
|
||||
ImGui::TextDisabled("%s", a.name);
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Clear Achievement")) {
|
||||
AchievementSystem::get().clearOne(a.key);
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user