示例#1
0
/**
 *  Called when our plugin is first loaded in the system, during the execution of
 * DLLInit() - prior to initializing the GameDLL.
 **/
bool CMetaModPy::Load(PluginId id, ISmmAPI* ismm, char* error, size_t maxlen, bool late)
{
    char *directoryBuffer = new char[MAXIMUM_PATH_LENGTH];
    PyObject *loaderModule;

    PLUGIN_SAVEVARS();

    /* Make sure we build on MM:S 1.4 */
#if defined METAMOD_PLAPI_VERSION
    GET_V_IFACE_ANY(GetServerFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
#else
    GET_V_IFACE_ANY(serverFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
#endif

    // Set up our Python environment
    setenv("PYTHONNOUSERSITE", "1", 1);

    g_SMAPI->PathFormat(directoryBuffer, MAXIMUM_PATH_LENGTH, "%s/%s", g_SMAPI->GetBaseDir(), "addons/metamodpy");
    setenv("PYTHONHOME", directoryBuffer, 1);

    g_SMAPI->PathFormat(directoryBuffer, MAXIMUM_PATH_LENGTH, "%s/%s", directoryBuffer, "plugins");
    setenv("PYTHONPATH", directoryBuffer, 1);

    // We don't need this any more.
    delete directoryBuffer;

    // Create our initialize the Python subsystem
    g_pythonManager = new CPythonManager();

    InitializeHooks();

    return true;
}
示例#2
0
ChromiumCDMAdapter::ChromiumCDMAdapter(nsTArray<Pair<nsCString, nsCString>>&& aHostPathPairs)
{
#ifdef XP_WIN
  InitializeHooks();
#endif
  PopulateHostFiles(std::move(aHostPathPairs));
}
示例#3
0
void MQ2NavigationPlugin::Plugin_Initialize()
{
	if (m_initialized)
		return;

	HookStatus status = InitializeHooks();
	if (status != HookStatus::Success)
	{
		m_retryHooks = (status == HookStatus::MissingDevice);
		return;
	}

	mq2nav::LoadSettings();

	InitializeRenderer();

	AddModule<KeybindHandler>();
	AddModule<NavMeshLoader>();
	AddModule<ModelLoader>();
	AddModule<NavMeshRenderer>();
	AddModule<UiController>();

	for (const auto& m : m_modules)
	{
		m.second->Initialize();
	}

	// get the keybind handler and connect it to our keypress handler
	auto keybindHandler = Get<KeybindHandler>();
	m_keypressConn = keybindHandler->OnMovementKeyPressed.Connect(
		[this]() { OnMovementKeyPressed(); });

	// initialize mesh loader's settings
	auto meshLoader = Get<NavMeshLoader>();
	meshLoader->SetAutoReload(mq2nav::GetSettings().autoreload);

	m_initialized = true;

	Plugin_SetGameState(gGameState);

	AddCommand("/navigate", NavigateCommand);
	AddMQ2Data("Navigation", NavigateData);

	auto ui = Get<UiController>();
	m_updateTabConn = ui->OnTabUpdate.Connect([=](TabPage page) { OnUpdateTab(page); });
}