Represents a Mod ingame.
Class Mod
#include <Geode/loader/Mod.hpp>
Examples0
Public static methods1
template<class = void>staticgeode::Mod*get()
Get the Mod of the current mod being developed
Public member functions72
geode::Modoperator=()
std::stringgetID()const
std::stringgetName()const
std::vector<std::string>getDevelopers()const
std::optional<std::string>getDescription()const
std::optional<std::string>getDetails()const
std::filesystem::pathgetPackagePath()const
geode::VersionInfogetVersion()const
boolisEnabled()const
boolisOrWillBeEnabled()const
boolisInternal()const
boolneedsEarlyLoad()const
geode::ModMetadatagetMetadata()const
std::filesystem::pathgetTempDir()const
std::filesystem::pathgetBinaryPath()const
Get the path to the mod’s platform binary (.dll on Windows, .dylib on Mac & iOS, .so on Android)
std::filesystem::pathgetResourcesDir()const
Get the path to the mod’s runtime resources directory (contains all of its resources)
matjson::ValuegetDependencySettingsFor(std::string_viewdependencyID)const
Get the dependency settings for a specific dependency via its ID. For example, if this mod depends on Custom Keybinds, it can specify the keybinds it wants to add in mod.json
under dependencies."geode.custom-keybinds".settings.keybinds
voidsetMetadata(geode::ModMetadataconst&metadata)
std::vector<geode::Mod*>getDependants()const
geode::Mod::CheckUpdatesTaskcheckUpdates()const
Check if this Mod has updates available on the mods index. If you’re using this for automatic update checking, use openInfoPopup
from the ui/GeodeUI.hpp
header to open the Mod’s page to let the user install the update
geode::Result<>saveData()
geode::Result<>loadData()
std::filesystem::pathgetSaveDir()const
Get the mod’s save directory path
std::filesystem::pathgetConfigDir(boolcreate)const
Get the mod’s config directory path
std::filesystem::pathgetPersistentDir(boolcreate)const
Get the mod’s persistent directory path This directory is not deleted even when Geode/mod is uninstalled
boolhasSettings()const
Returns true if this mod has any settings
std::vector<std::string>getSettingKeys()const
Get a list of all this mod’s setting keys (in the order they were declared in mod.json
)
boolhasSetting()const
std::shared_ptr<geode::Setting>getSetting()const
Get the definition of a setting, or null if the setting was not found, or if it’s a custom setting that has not yet been registered using Mod::registerCustomSettingType
key
geode::Result<>registerCustomSettingType(std::string_viewtype,geode::SettingGeneratorgenerator)
Register a custom setting type. See the setting docs for more
type
generator
std::stringgetLaunchArgumentName(std::string_viewname)const
Returns a prefixed launch argument name. See Mod::getLaunchArgument
for details about mod-specific launch arguments.
std::vector<std::string>getLaunchArgumentNames()const
Returns the names of the available mod-specific launch arguments.
boolhasLaunchArgument(std::string_viewname)const
Equivalent to a prefixed Loader::hasLaunchArgument
call. See Mod::getLaunchArgument
for details about mod-specific launch arguments.
name
std::optional<std::string>getLaunchArgument(std::string_viewname)const
Get a mod-specific launch argument. This is equivalent to Loader::getLaunchArgument
with the argument name prefixed by the mod ID. For example, a launch argument named mod-arg
for the mod author.test
would be specified with --geode:author.test.mod-arg=value
.
name
boolgetLaunchFlag(std::string_viewname)const
Equivalent to a prefixed Loader::getLaunchFlag
call. See Mod::getLaunchArgument
for details about mod-specific launch arguments.
name
template<class T>std::optional<T>parseLaunchArgument(std::string_viewname)const
Equivalent to a prefixed Loader::parseLaunchArgument
call. See Mod::getLaunchArgument
for details about mod-specific launch arguments.
name
matjson::Value&getSaveContainer()
matjson::Value&getSavedSettingsData()
template<class T>TgetSettingValue()const
Get the value of a setting. To use this for custom settings, first specialize the SettingTypeForValueType
class, and then make sure your custom setting type has a getValue
function which returns the value
template<class T>TsetSettingValue(,const Tconst&value)
boolhasSavedValue()
template<class T>TgetSavedValue()
template<class T>TgetSavedValue(,const Tconst&defaultValue)
template<class T>TsetSavedValue(,const Tconst&value)
Set the value of an automatically saved variable. When the game is closed, the value is automatically saved under the key
key
value
template<class DetourType>geode::Result<geode::Hook*>hook(void*address,DetourTypedetour,std::stringconst&displayName,tulip::hook::TulipConventionconvention,tulip::hook::HookMetadataconst&hookMetadata)
Create a hook at an address. Call the original function by calling the original function – no trampoline needed
address
detour
displayName
convention
hookMetadata
geode::Result<geode::Hook*>hook(void*address,void*detour,std::stringconst&displayName,tulip::hook::HandlerMetadataconst&handlerMetadata,tulip::hook::HookMetadataconst&hookMetadata)
geode::Result<geode::Hook*>claimHook()
Claims an existing hook object, marking this mod as its owner. If the hook has “auto enable” set, this will enable the hook.
geode::Result<>disownHook(geode::Hook*hook)
Disowns a hook which this mod owns, making this mod no longer its owner. If the hook has “auto enable” set, this will disable the hook.
std::vector<geode::Hook*>getHooks()const
Get all hooks owned by this Mod
geode::Result<geode::Patch*>patch(void*address,)
Write a patch at an address
address
data
geode::Result<geode::Patch*>claimPatch()
Claims an existing patch object, marking this mod as its owner. If the patch has “auto enable” set, this will enable the patch.
geode::Result<>disownPatch(geode::Patch*patch)
Disowns a patch which this mod owns, making this mod no longer its owner. If the patch has “auto enable” set, this will disable the patch.
std::vector<geode::Patch*>getPatches()const
Get all patches owned by this Mod
geode::Result<>enable()
Enable this mod
geode::Result<>disable()
Disable this mod
geode::Result<>uninstall(booldeleteSaveData)
Delete the mod’s .geode package.
deleteSaveData
boolisUninstalled()const
geode::ModRequestedActiongetRequestedAction()const
booldepends()const
Check whether or not this Mod depends on another mod
boolhasUnresolvedDependencies()const
Check whether all the required dependencies for this mod have been loaded or not
boolhasUnresolvedIncompatibilities()const
Check whether none of the incompatibilities with this mod are loaded
std::string_viewexpandSpriteName(std::string_viewname)
geode::ModJsongetRuntimeInfo()const
Get info about the mod as JSON
ℹ For IPC
boolisLoggingEnabled()const
std::optional<geode::LoadProblem>targetsOutdatedVersion()const
If this mod is built for an outdated GD or Geode version, returns the LoadProblem
describing the situation. Otherwise nullopt
if the mod is made for the correct version of the game and Geode
boolhasLoadProblems()const
ℹ Make sure to also call `targetsOutdatedVersion` if you want to make sure the mod is actually loadable