Skip to content

Commit

Permalink
Reload Lua mods when enabling/disabling
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenCWills authored and AJenbo committed Jan 10, 2025
1 parent d7647d6 commit 3b841b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 8 additions & 0 deletions Source/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "engine/sound_defs.hpp"
#include "game_mode.hpp"
#include "hwcursor.hpp"
#include "lua/lua.hpp"
#include "options.h"
#include "platform/locale.hpp"
#include "qol/monhealthbar.h"
Expand Down Expand Up @@ -1836,6 +1837,13 @@ std::vector<ModOptions::ModEntry> &ModOptions::GetModEntries()
return newModEntries;
}

ModOptions::ModEntry::ModEntry(std::string_view name)
: name(name)
, enabled(this->name, OptionEntryFlags::None, this->name.c_str(), "", false)
{
enabled.SetValueChangedCallback(LuaReloadActiveMods);
}

namespace {
#ifdef DEVILUTIONX_RESAMPLER_SPEEX
constexpr char ResamplerSpeex[] = "Speex";
Expand Down
7 changes: 1 addition & 6 deletions Source/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -811,12 +811,7 @@ struct ModOptions : OptionCategoryBase {

private:
struct ModEntry {
ModEntry(std::string_view name)
: name(name)
, enabled(this->name, OptionEntryFlags::None, this->name.c_str(), "", false)
{
}

ModEntry(std::string_view name);
std::string name;
OptionEntryBoolean enabled;
};
Expand Down

0 comments on commit 3b841b5

Please sign in to comment.