Skip to content

Commit

Permalink
C4HudBarDef::Gfx: Capitalize public members and remove unnecessary co…
Browse files Browse the repository at this point in the history
…nstructors and operator== implementation
  • Loading branch information
Fulgen301 committed Sep 25, 2024
1 parent 7e2a01d commit 3c7bd67
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 31 deletions.
34 changes: 11 additions & 23 deletions src/C4HudBars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,24 +270,12 @@ namespace
}
}

C4HudBarsDef::Gfx::Gfx(std::string key, std::string file, const std::int32_t amount, const std::int32_t scale) noexcept
: key{std::move(key)},
file{std::move(file)},
amount{amount},
scale{scale}
{}

bool C4HudBarsDef::Gfx::operator==(const Gfx &rhs) const noexcept
{
return key == rhs.key && file == rhs.file && amount == rhs.amount && scale == rhs.scale;
}

void C4HudBarsDef::Gfx::CompileFunc(StdCompiler *const comp)
{
comp->Value(mkNamingAdapt(key, "Key"));
comp->Value(mkNamingAdapt(file, "File"));
comp->Value(mkNamingAdapt(amount, "Amount"));
comp->Value(mkNamingAdapt(scale, "Scale"));
comp->Value(mkNamingAdapt(Key, "Key"));
comp->Value(mkNamingAdapt(File, "File"));
comp->Value(mkNamingAdapt(Amount, "Amount"));
comp->Value(mkNamingAdapt(Scale, "Scale"));
}

C4HudBarsDef::C4HudBarsDef(Gfxs &&gfxs, Bars &&bars) : gfxs{std::move(gfxs)}, bars{std::move(bars)}
Expand Down Expand Up @@ -321,7 +309,7 @@ std::size_t C4HudBarsDef::GetHash() const noexcept
std::size_t result{0};
for (const auto &gfx : gfxs)
{
HashCombineArguments(result, gfx.second.key, gfx.second.file, gfx.second.amount, gfx.second.scale);
HashCombineArguments(result, gfx.second.Key, gfx.second.File, gfx.second.Amount, gfx.second.Scale);
}

for (const auto &bardef : bars)
Expand Down Expand Up @@ -391,9 +379,9 @@ std::shared_ptr<C4FacetExID> C4HudBarsUniquifier::GetFacet(const std::function<v

if (const auto it = gfxs.find(gfx); it != gfxs.end())
{
amount = it->second.amount;
scale = it->second.scale;
file = it->second.file;
amount = it->second.Amount;
scale = it->second.Scale;
file = it->second.File;
}
else
{
Expand Down Expand Up @@ -645,7 +633,7 @@ void C4HudBarsUniquifier::ProcessHudBar(std::int32_t &valueIndex, const C4HudBar
bar.max = _max;
bar.visible = _visible;
bar.advance = advance;
auto scale = graphics.at(file.getData()).scale;
auto scale = graphics.at(file.getData()).Scale;
bar.scale = static_cast<float>(scale) / 100.0f;
bars.push_back(bar);
}
Expand Down Expand Up @@ -674,7 +662,7 @@ void C4HudBarsAdapt::CompileFunc(StdCompiler *const comp)
std::vector<C4HudBarsDef::Gfx> temp;
comp->Value(mkNamingAdapt(mkSTLContainerAdapt(temp), "Gfx", std::vector<C4HudBarsDef::Gfx>{}));
for (const auto &gfx : temp)
gfxs_.emplace(gfx.key, gfx);
gfxs_.emplace(gfx.Key, gfx);

C4HudBarsDef::Bars bars_;
comp->Value(mkNamingAdapt(mkSTLContainerAdapt(bars_), "Def", C4HudBarsDef::Bars{}));
Expand All @@ -691,7 +679,7 @@ void C4HudBarsAdapt::CompileFunc(StdCompiler *const comp)
bars = Game.HudBars.DefaultBars();
return;
}
bar.scale = static_cast<float>(def->gfxs.at(bar.gfx).scale) / 100.0f;
bar.scale = static_cast<float>(def->gfxs.at(bar.gfx).Scale) / 100.0f;
}

const auto instance = Game.HudBars.RegisterAndCreateInstance(std::move(def));
Expand Down
13 changes: 5 additions & 8 deletions src/C4HudBars.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,12 @@ class C4HudBarsDef
public:
struct Gfx
{
std::string key;
std::string file;
std::int32_t amount{0};
std::int32_t scale{0};
std::string Key;
std::string File;
std::int32_t Amount{0};
std::int32_t Scale{0};

Gfx() noexcept = default;
Gfx(std::string key, std::string file, std::int32_t amount, std::int32_t scale) noexcept;

bool operator==(const Gfx &rhs) const noexcept;
constexpr bool operator==(const Gfx &rhs) const noexcept = default;

void CompileFunc(StdCompiler *comp);
};
Expand Down

0 comments on commit 3c7bd67

Please sign in to comment.