Skip to content
Archie_UwU edited this page Dec 27, 2023 · 2 revisions

What is this?

This is an addon to the Aurie Framework to allow other modules to easily save state into config files stored in %PROGRAMDIR%\mods\Configs. The module offers a comprehensive interface for config access.

The following example showcases reading from a config test_config.json, and activating debug mode depending on the state of the Debug Mode config entry.

EXPORTED AurieStatus ModuleInitialize(
	IN AurieModule* Module,
	IN const fs::path& ModulePath
)
{
	UNREFERENCED_PARAMETER(Module);
	UNREFERENCED_PARAMETER(ModulePath);

	AurieConfigInterface* config_interface = nullptr;
	AurieStatus last_status = AURIE_SUCCESS;

	last_status = ObGetInterface(
		"Aurie Config Manager",
		reinterpret_cast<AurieInterfaceBase*&>(config_interface)
	);

	if (!AurieSuccess(last_status))
		return last_status;

	AurieConfig my_config = nullptr;
	last_status = config_interface->OpenConfig(
		L"test_config.json",
		&my_config
	);

	if (!AurieSuccess(last_status))
		return last_status;

	bool debug_mode = false;
	last_status = config_interface->ReadBoolean(
		my_config,
		"Debug Mode",
		debug_mode
	);

	if (debug_mode)
	{
		ActivateDebugMode();
	}

	config_interface->CloseConfig(
		my_config
	);

	return AURIE_SUCCESS;
}

Clone this wiki locally