Giter VIP home page Giter VIP logo

middle-earth-mod-loader's Introduction

Middle Earth Mod Loader

image

Consider donating if you enjoy my work:

ko-fi

Details

A DLL loader for Shadow of War with a small and simple plugin API to allow for easily adding in-game menus and logging capabilities to plugins.

Requirements

Requires the latest Microsoft Visual C++ Redistributables found here.

Installation

First, navigate to your game's installation folder located at "...\steamapps\common\ShadowOfWar\x64" and rename the bink2w64.dll file to bink2w64_.dll, so basically add an underscore to the name.

Download the mod loader archive from the Releases section here and place the contents of the archive (download 7zip to open the archive if you have no archiving application) into the "x64" folder where the "ShadowOfWar.exe" is, in your game's installation folder.

Create a "plugins" folder in the same directory, that is where the plugins you want to load need to go to.

After installation, you should have a new "bink2w64.dll" file, a "modloader" folder and a "plugins" folder.

Known Issues

Changing any of the settings in the Options menu of the game leads to a crash while the mod menu is loaded. Simply disabling the hook didn't fix it and I don't really have the time or the will anymore to debug and fix it.

As long as you have your UI, Sound and Graphics settings set up the way you want them to, this shouldn't really pose much of an issue. If you want to change them, just swap the names of the DLL files, change the options you want and then swap them back again.

For Users

Simply download any mods you want and install them according to their instructions. All options for mods (if they have any) and for the mod loader itself can be modified in-game.

The default hotkey to open the Mod Configuration Menu is F10.

The default hotkey to open the Log Menu is Tilde (`).

For Modders

You can find a sample project you can clone including the mod loader API here. It demonstrates how to add a plugin and register a mod menu and a custom menu for it. Also comes with some skeleton code where you can add your own functionality.

If you just want to grab the header file to include in a project you can grab it from under the releases section here.

Using the plugin API is not a strict requirement, as it includes some legacy compatibility for any plugins that were made with the old version.

Using the API

There are 4 functions to interface with the mod loader, each is prototyped in the modloaderapi.h header file. They are as follows:

#define MODLOADERAPI extern "C" void __declspec(dllexport)

MODLOADERAPI OnRegisterLogAPI(ModLoader::LogAPI*) // first function, called when the logging API is registered for the plugin
MODLOADERAPI OnRegisterMenuAPI(ModLoader::MenuAPI*) // second function, called when the menu API is registered for the plugin
MODLOADERAPI OnPluginLoad(ModLoader::PluginAPI*) // third function, called when the plugin is fully loaded
MODLOADERAPI OnPluginUnload() // called when the plugin is unloaded, like when it gets disabled in-game

By default ImGui is a dependency if using the API, but it can be disabled by defining the "MODLOADER_NO_MENU" key before including modloaderapi.h like such:

#define MODLOADER_NO_MENU
#include <modloaderapi.h>

If this key is defined, then the MenuAPI class is also not available for use.

From then on you can do whatever you like and use the objects passed through the arguments to call any of the functions from the header file. They are all commented and fairly straightforward, so you should be able to understand what they all mean.

You can register some basic information about your mod via the PluginAPI* object in OnPluginLoad as follows:

api->RegisterPlugin("Display Name", "Log Name", { 1/*major version*/, 0/*minor version*/, 0/*patch version*/ }, "Plugin description goes here.");

Even plugins that don't use ImGui or register menus are visible in the mod configuration menu in a separate category so you can see they are loaded.

If you don't register your plugin (or leave certain fields empty) then the display and log name will simply be the file name, the version will be 1.0.0 and the description will be a basic description saying the menu entry is for X mod and whether it comes with options or not.

You can also initialize the log and the menu API singletons through the LogAPI* and MenuAPI* objects by calling

ModLoader::LogAPI::Init(api);

and

ModLoader::MenuAPI::Init(api);

Once they are initialized you can invoke them anywhere inside your code by grabbing the singleton instances of each in the following way:

ModLoader::LogAPI::GetSingleton()->Log("I am a log entry. This statement is %s.", true ? "true" : "false");

void ShowSettings() {
// I do stuff to display settings in-game.
}

void Defaults() {
// I reset all the mod's settings to their defaults.
}

void Save() {
// I save the mod's settings to file.
}

ModLoader::MenuAPI::GetSingleton()->RegisterMenuEntry(ShowSettings, Defaults, Save, "Settings Tab Name"); 

Any ImGui directives inside the ShowSettings function will begin rendering from the following highlighted area: image

You can register multiple menu entries in the mod configuration menu, which will all become individual tabs inside your plugin's menu entry. You can leave the fourth argument of RegisterMenuEntry empty, in which case the tab names will be Settings, Extra Settings, Extra Settings 2 and so on by default.

Not using the API

You can avoid using the API and including the header file by simply including the following function in your code:

extern "C" void __declspec(dllexport) OnLoad() {}

It will be called just like the others but without any of the functionality that the others bring.

Credits

Dear ImGui

SimpleIni

MinHook

Astoria Font

Inconsolata Font

middle-earth-mod-loader's People

Contributors

reaperanon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

middle-earth-mod-loader's Issues

Can't open the menu or log menu at all

Pressing F10 or Tilde(`) doesn't do anything in game.

The mods are loaded, I can tell because they are taking effect clearly.

I've checked the logs and the logs are being written as well, so it seems just the GUI is not working for some reason.

I have the VC Redistributables from the readme.

my /x64/plugins folder has 5 .dlls and a config folder

The three configs (FOV Extender, Myrian Multiplier, Uruk Intel) are all empty.

in /x64/modloader , the Mod Loader ini is empty.

The imgui ini:

[Window][Mod Configuration Menu]
Pos=496,77
Size=1286,921
Collapsed=0

[Window][Log]
Pos=0,580
Size=869,499
Collapsed=0

[Window][Set Font Scale]
Pos=801,497
Size=317,86
Collapsed=0

[Window][Notice]
Pos=860,500
Size=200,80
Collapsed=0

[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0

Game crashes upon game start

I followed all of the instructions to properly install the mod loader along with my desired plugins. When I go to start a new game with the mods. It crashes without fail and doesn't give me a message as to why.

Renderer failed to initialize

The game starts and when i get to the menu screen i press F10 to bring up the menu and it minimizes the tab so i have to click on it in the bar to get it back and the mod menu is open but when i close it thats when i get an error saying something like "Failed to initialize renderer. IDXGISwapChain::ResizeBuffer Failed" and then the game closes out

It also has this on it 0x887A0001

Flagged as a trojan ("Wacatac")

What in this file could make Opera GX & Windows Defender flag it as a trojan? It seems clean but I just want to be safe. Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.