Skip to content

Commit

Permalink
Post-PR cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
techiew committed Sep 7, 2022
1 parent f7b16e7 commit 5b991db
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion EldenRingModLoader/EldenRingModLoader.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</ModuleDefinitionFile>
</Link>
<PostBuildEvent>
<Command>COPY "C:\Users\Marius\Documents\Programming\Github repositories\EldenRingModLoader\EldenRingModLoader\x64\Release\dinput8.dll" "G:\SteamLibrary\steamapps\common\ELDEN RING\Game\"</Command>
<Command>COPY "C:\Programming\Github repositories\EldenRingModLoader\EldenRingModLoader\x64\Release\dinput8.dll" "G:\SteamLibrary\steamapps\common\ELDEN RING\Game\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
31 changes: 15 additions & 16 deletions EldenRingModLoader/ModLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ void ModLoader::LoadMods()

void ModLoader::ReadConfigFile()
{
INIFile config = INIFile("mod_loader_config.ini");

if (config.read(ini))
if (config.read(m_ini))
{
m_loadDelay = std::stoi(ini["modloader"].get("load_delay"));
m_showTerminal = std::stoi(ini["modloader"].get("show_terminal")) != 0;
m_loadDelay = std::stoi(m_ini["modloader"].get("load_delay"));
m_showTerminal = std::stoi(m_ini["modloader"].get("show_terminal")) != 0;
}
else
{
ini["modloader"]["load_delay"] = std::to_string(m_loadDelay);
ini["modloader"]["show_terminal"] = std::to_string(m_showTerminal);
config.write(ini, true);
m_ini["modloader"]["load_delay"] = std::to_string(m_loadDelay);
m_ini["modloader"]["show_terminal"] = std::to_string(m_showTerminal);
config.write(m_ini, true);
}

if (m_showTerminal)
Expand All @@ -36,9 +37,9 @@ std::vector<std::pair<int64_t, std::string>> ModLoader::FindModsAndReadLoadOrder
m_logger.Log("Finding mods...");

std::vector<std::pair<int64_t, std::string>> dllMods;
constexpr int automaticLoadOrder = -1;
fs::create_directories(m_modFolder);
m_logger.Log("Load Order:");
constexpr int automaticLoadOrder = -1;
fs::create_directories(m_modFolder);
m_logger.Log("Load Order:");

for (auto file : fs::recursive_directory_iterator(m_modFolder))
{
Expand All @@ -60,14 +61,12 @@ std::vector<std::pair<int64_t, std::string>> ModLoader::FindModsAndReadLoadOrder
stringStream >> loadOrder;
}

std::string load = ini["loadorder"].get(modName);
//Just in case someone adds ".dll" to their load order.
if (load == "") {
load = ini["loadorder"].get(modName + ".dll");
std::string overrideLoadOrder = m_ini["loadorder"].get(modName);
if (overrideLoadOrder == "") {
overrideLoadOrder = m_ini["loadorder"].get(modName + ".dll");
}
if (load != "") {
std::stringstream stringStream(load);
stringStream >> loadOrder;
if (overrideLoadOrder != "") {
loadOrder = std::stoi(overrideLoadOrder);
}

m_logger.Log(" %s = %d", modName.c_str(), loadOrder);
Expand Down
4 changes: 1 addition & 3 deletions EldenRingModLoader/ModLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ class ModLoader
std::string m_modFolder = ".\\mods";
DWORD m_loadDelay = 5000;
bool m_showTerminal = false;
INIStructure m_ini;

void ReadConfigFile();
std::vector<std::pair<int64_t, std::string>> FindModsAndReadLoadOrders();
void LoadDllMods();
void OpenTerminal();
void OnLoadingDone();
INIFile config = INIFile("mod_loader_config.ini");
INIStructure ini;

};
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ If you want to develop a DLL mod, I recommend checking out [ModUtils.h](https://
## Load ordering
To specify a load order for a mod, create a folder with the same name as your DLL inside the "mods" folder. Inside the folder create "load.txt" and enter the load order number, which must go from 0 and up. Mods will load in order from lowest to highest number with an interval of 1 second.

Alternatively, just add the dll name under the loadorder section of the ini
Alternatively, you can specify the load order in "mod_loader_config.ini" like so:
```
[loadorder]
ErdTools = 1
MyDllMod.dll = 1
```
(This overrides the load order specified in the "mods" folder).

Mods with a load order of 0 will be loaded instantly, even ignoring the load delay set inside "mod_loader_config.ini". I recommend not using 0 unless the mod is absolutely required to have an immediate effect, as race conditions may occur for some types of mods if they load too quickly.

Expand Down

0 comments on commit 5b991db

Please sign in to comment.