Skip to content

Commit

Permalink
Improved config loading of unrecognized buffs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Friendly0Fire committed Jul 31, 2022
1 parent aa0f87d commit 54c2aa7
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 42 deletions.
2 changes: 2 additions & 0 deletions GW2Clarity.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=HRESULT/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Binary file modified GW2Clarity/assets/atlas.dds
Binary file not shown.
45 changes: 23 additions & 22 deletions GW2Clarity/assets/atlas.inc
Original file line number Diff line number Diff line change
Expand Up @@ -223,25 +223,26 @@
{ "unbroken_lines", { 0.8784722, 0.8159722, 0.9340278, 0.8715278 } },
{ "unflinching_fortitude", { 0.9409722, 0.8159722, 0.9965278, 0.8715278 } },
{ "unhindered_combatant", { 0.0034722222, 0.8784722, 0.059027776, 0.9322917 } },
{ "unleashed", { 0.065972224, 0.8784722, 0.121527776, 0.9340278 } },
{ "unseen_burden", { 0.12847222, 0.8784722, 0.18402778, 0.9340278 } },
{ "unstable_blood_magic", { 0.19097222, 0.8784722, 0.24652778, 0.9340278 } },
{ "versatile_(archetype)", { 0.2534722, 0.8784722, 0.3090278, 0.9340278 } },
{ "vigor", { 0.3159722, 0.8784722, 0.3715278, 0.9340278 } },
{ "violent_currents", { 0.3784722, 0.8784722, 0.4340278, 0.9340278 } },
{ "virtue_of_courage_(dragonhunter)", { 0.4409722, 0.8784722, 0.4965278, 0.9340278 } },
{ "virtue_of_courage", { 0.5034722, 0.8784722, 0.5590278, 0.9357639 } },
{ "virtue_of_justice_(dragonhunter)", { 0.5659722, 0.8784722, 0.6215278, 0.9340278 } },
{ "virtue_of_justice", { 0.6284722, 0.8784722, 0.6840278, 0.9340278 } },
{ "virtue_of_resolve_(dragonhunter)", { 0.6909722, 0.8784722, 0.7465278, 0.9340278 } },
{ "virtue_of_resolve", { 0.7534722, 0.8784722, 0.8090278, 0.9322917 } },
{ "volatile_poison", { 0.8159722, 0.8784722, 0.8715278, 0.9340278 } },
{ "vulnerability", { 0.8784722, 0.8784722, 0.9340278, 0.9340278 } },
{ "vulture_stance", { 0.9409722, 0.8784722, 0.9965278, 0.9340278 } },
{ "waterlogged", { 0.0034722222, 0.9409722, 0.059027776, 0.9965278 } },
{ "weakening_strikes", { 0.065972224, 0.9409722, 0.121527776, 0.9965278 } },
{ "weakness", { 0.12847222, 0.9409722, 0.18402778, 0.9965278 } },
{ "winter's_blessing", { 0.19097222, 0.9409722, 0.24652778, 0.9965278 } },
{ "xera's_fury", { 0.2534722, 0.9409722, 0.3090278, 0.9965278 } },
{ "zealot's_flame", { 0.3159722, 0.9409722, 0.3715278, 0.9982639 } },
{ "zealous_benediction", { 0.3784722, 0.9409722, 0.4340278, 0.9965278 } },
{ "unknown", { 0.065972224, 0.8784722, 0.121527776, 0.9340278 } },
{ "unleashed", { 0.12847222, 0.8784722, 0.18402778, 0.9340278 } },
{ "unseen_burden", { 0.19097222, 0.8784722, 0.24652778, 0.9340278 } },
{ "unstable_blood_magic", { 0.2534722, 0.8784722, 0.3090278, 0.9340278 } },
{ "versatile_(archetype)", { 0.3159722, 0.8784722, 0.3715278, 0.9340278 } },
{ "vigor", { 0.3784722, 0.8784722, 0.4340278, 0.9340278 } },
{ "violent_currents", { 0.4409722, 0.8784722, 0.4965278, 0.9340278 } },
{ "virtue_of_courage_(dragonhunter)", { 0.5034722, 0.8784722, 0.5590278, 0.9340278 } },
{ "virtue_of_courage", { 0.5659722, 0.8784722, 0.6215278, 0.9357639 } },
{ "virtue_of_justice_(dragonhunter)", { 0.6284722, 0.8784722, 0.6840278, 0.9340278 } },
{ "virtue_of_justice", { 0.6909722, 0.8784722, 0.7465278, 0.9340278 } },
{ "virtue_of_resolve_(dragonhunter)", { 0.7534722, 0.8784722, 0.8090278, 0.9340278 } },
{ "virtue_of_resolve", { 0.8159722, 0.8784722, 0.8715278, 0.9322917 } },
{ "volatile_poison", { 0.8784722, 0.8784722, 0.9340278, 0.9340278 } },
{ "vulnerability", { 0.9409722, 0.8784722, 0.9965278, 0.9340278 } },
{ "vulture_stance", { 0.0034722222, 0.9409722, 0.059027776, 0.9965278 } },
{ "waterlogged", { 0.065972224, 0.9409722, 0.121527776, 0.9965278 } },
{ "weakening_strikes", { 0.12847222, 0.9409722, 0.18402778, 0.9965278 } },
{ "weakness", { 0.19097222, 0.9409722, 0.24652778, 0.9965278 } },
{ "winter's_blessing", { 0.2534722, 0.9409722, 0.3090278, 0.9965278 } },
{ "xera's_fury", { 0.3159722, 0.9409722, 0.3715278, 0.9965278 } },
{ "zealot's_flame", { 0.3784722, 0.9409722, 0.4340278, 0.9982639 } },
{ "zealous_benediction", { 0.4409722, 0.9409722, 0.4965278, 0.9965278 } },
Binary file added GW2Clarity/assets/atlas/unknown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion GW2Clarity/common
Submodule common updated 2 files
+15 −2 include/Common.h
+10 −1 src/BaseCore.cpp
4 changes: 1 addition & 3 deletions GW2Clarity/include/Grids.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ class Grids : public SettingsMenu::Implementer
void DrawItems(const Sets::Set* set, bool shouldIgnoreSet);

static inline constexpr glm::ivec2 GridDefaultSpacing{ 64, 64 };
static inline const Buff UnknownBuff{
0, "Unknown", glm::vec4{0.f, 0.f, 0.f, 0.f}
};
static inline const Buff UnknownBuff{ 0, "Unknown", 1 };

struct Threshold
{
Expand Down
53 changes: 37 additions & 16 deletions GW2Clarity/src/Grids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ void Grids::DrawItems(const Sets::Set* set, bool shouldIgnoreSet)
int count = 0;
if (editing)
count = editingItemFakeCount_;
else
else if (i.buff)
count = std::accumulate(i.additionalBuffs.begin(), i.additionalBuffs.end(), i.buff->GetStacks(activeBuffs_),
[&](int a, const Buff* b) { return a + b->GetStacks(activeBuffs_); });

Expand Down Expand Up @@ -951,7 +951,7 @@ void Grids::Load()
auto& cfg = JSONConfigurationFile::i();
cfg.Reload();

auto maybe_at = []<typename D>(const json& j, const char* n, const D& def, const std::variant<std::monostate, std::function<D(const json&)>>& cvt = {})
auto maybeAt = []<typename D>(const json& j, const char* n, const D& def, const std::variant<std::monostate, std::function<D(const json&)>>& cvt = {})
{
auto it = j.find(n);
if (it == j.end())
Expand All @@ -962,36 +962,57 @@ void Grids::Load()
return std::get<1>(cvt)(*it);
};

auto getivec2 = [](const json& j) { return glm::ivec2(j[0].get<int>(), j[1].get<int>()); };
auto getivec4 = [](const json& j) { return glm::ivec4(j[0].get<int>(), j[1].get<int>(), j[2].get<int>(), j[3].get<int>()); };
auto getImVec4 = [](const json& j) { return ImVec4(j[0].get<float>(), j[1].get<float>(), j[2].get<float>(), j[3].get<float>()); };
auto getivec2 = [](const json& j) { return glm::ivec2(j[0].get<int>(), j[1].get<int>()); };
auto getivec4 = [](const json& j) { return glm::ivec4(j[0].get<int>(), j[1].get<int>(), j[2].get<int>(), j[3].get<int>()); };
auto getImVec4 = [](const json& j) { return ImVec4(j[0].get<float>(), j[1].get<float>(), j[2].get<float>(), j[3].get<float>()); };
auto getBuff = [this](const json& j) -> const Buff*
{
int id = j;
auto it = buffsMap_.find(id);
if (it != buffsMap_.end())
return it->second;
else
return nullptr;
};

const auto& grids = cfg.json()["buff_grids"];
const auto& grids = cfg.json()["buff_grids"];
for (const auto& gIn : grids)
{
Grid g;
g.spacing = maybe_at(gIn, "spacing", glm::ivec2(32, 32), { getivec2 });
g.offset = maybe_at(gIn, "offset", glm::ivec2(), { getivec2 });
g.attached = maybe_at(gIn, "attached", false);
g.centralWeight = maybe_at(gIn, "central_weight", 0.f);
g.mouseClipMin = maybe_at(gIn, "mouse_clip_min", glm::ivec2{ std::numeric_limits<int>::max() }, { getivec2 });
g.mouseClipMax = maybe_at(gIn, "mouse_clip_max", glm::ivec2{ std::numeric_limits<int>::min() }, { getivec2 });
g.trackMouseWhileHeld = maybe_at(gIn, "track_mouse_while_held", true);
g.square = maybe_at(gIn, "square", true);
g.spacing = maybeAt(gIn, "spacing", glm::ivec2(32, 32), { getivec2 });
g.offset = maybeAt(gIn, "offset", glm::ivec2(), { getivec2 });
g.attached = maybeAt(gIn, "attached", false);
g.centralWeight = maybeAt(gIn, "central_weight", 0.f);
g.mouseClipMin = maybeAt(gIn, "mouse_clip_min", glm::ivec2{ std::numeric_limits<int>::max() }, { getivec2 });
g.mouseClipMax = maybeAt(gIn, "mouse_clip_max", glm::ivec2{ std::numeric_limits<int>::min() }, { getivec2 });
g.trackMouseWhileHeld = maybeAt(gIn, "track_mouse_while_held", true);
g.square = maybeAt(gIn, "square", true);
g.name = gIn["name"];

for (const auto& iIn : gIn["items"])
{
Item i;
i.pos = getivec2(iIn["pos"]);
i.buff = buffsMap_.at(iIn["buff_id"]);
i.buff = getBuff(iIn["buff_id"]);
i.thresholds.clear();

if (iIn.contains("additional_buff_ids"))
for (auto& bIn : iIn["additional_buff_ids"])
if (const Buff* b = buffsMap_.at(bIn); b)
if (const Buff* b = getBuff(bIn); b)
i.additionalBuffs.push_back(b);

if (!i.buff)
{
i.buff = &UnknownBuff;
LogWarn("Configuration has unknown buff: Grid '{}', location ({}, {}), buff ID '{}'.", g.name, i.pos.x, i.pos.y, static_cast<std::string>(iIn["buff_id"]));
}

if (!i.buff && !i.additionalBuffs.empty())
{
i.buff = i.additionalBuffs.back();
i.additionalBuffs.pop_back();
}

if (iIn.contains("thresholds"))
for (auto& tIn : iIn["thresholds"])
i.thresholds.emplace_back(tIn["threshold"], getImVec4(tIn["tint"]));
Expand Down
Binary file modified getbuffs.dll
Binary file not shown.

0 comments on commit 54c2aa7

Please sign in to comment.