Horrible C++ template nightmares (fix clang-tidy warning about int conversions with ranges)

This commit is contained in:
PJB3005
2026-05-29 05:47:12 +02:00
parent 8c713d4535
commit c83cc3b971
3 changed files with 7 additions and 3 deletions
+2
View File
@@ -129,4 +129,6 @@ private:
void initOverlayFiles();
};
using ModIndex = std::ranges::range_difference_t<decltype(std::declval<ModLoader>().mods())>;
} // namespace dusk
+2 -2
View File
@@ -59,7 +59,7 @@ ModsWindow::ModsWindow() {
return;
}
for (size_t i = 0; i < mods.size(); ++i) {
for (ModIndex i = 0; i < mods.size(); ++i) {
mSnapshot.push_back({mods[i].active, mods[i].load_failed});
add_tab(mods[i].metadata.name, [this, i](Rml::Element* content) {
@@ -95,7 +95,7 @@ void ModsWindow::update() {
bool dirty = mods.size() != mSnapshot.size();
if (!dirty) {
for (size_t i = 0; i < mods.size(); ++i) {
for (ModIndex i = 0; i < mods.size(); ++i) {
if (mods[i].active != mSnapshot[i].active ||
mods[i].load_failed != mSnapshot[i].load_failed)
{
+3 -1
View File
@@ -4,6 +4,8 @@
#include <vector>
#include "dusk/mod_loader.hpp"
namespace dusk::ui {
class ModsWindow : public Window {
@@ -17,7 +19,7 @@ private:
bool load_failed;
};
std::vector<ModSnapshot> mSnapshot;
int mActiveModIndex = 0;
ModIndex mActiveModIndex = 0;
};
} // namespace dusk::ui