Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "skse/PluginAPI.h"
- #include "skse/skse_version.h"
- #include "skse/ScaleformCallbacks.h"
- #include "skse/ScaleformMovie.h"
- #include "skse/ScaleformExtendedData.h"
- #include "skse/GameRTTI.h"
- #include "skse/GameReferences.h"
- #include "skse/GameObjects.h"
- #include "skse/GlobalLocks.h"
- #include <shlobj.h>
- IDebugLog gLog;
- PluginHandle g_pluginHandle = kPluginHandle_Invalid;
- SKSEScaleformInterface * g_scaleform = NULL;
- /**** scaleform functions ****/
- class SKSEScaleform_RequestBaseArmorRating : public GFxFunctionHandler
- {
- public:
- virtual void Invoke(Args * args)
- {
- if (!g_loadGameLock.TryEnter())
- return;
- UInt32 formidArg = 0;
- TESForm * formArg = NULL;
- if (args->numArgs >= 1) {
- formidArg = (UInt32)args->args[0].GetNumber();
- if (formidArg > 0)
- formArg = LookupFormByID(formidArg);
- }
- args->result->SetNull();
- if ((args->result != NULL) && formArg) {
- TESObjectARMO * pArmor = DYNAMIC_CAST(formArg, TESForm, TESObjectARMO);
- if (pArmor){
- args->result->SetNumber(pArmor->armorValTimes100 / 100);
- }
- }
- g_loadGameLock.Leave();
- }
- };
- bool RegisterScaleform(GFxMovieView * view, GFxValue * root)
- {
- RegisterFunction <SKSEScaleform_RequestBaseArmorRating>(root, view, "RequestBaseArmorRating");
- return true;
- }
- extern "C"
- {
- bool SKSEPlugin_Query(const SKSEInterface * skse, PluginInfo * info)
- {
- gLog.OpenRelative(CSIDL_MYDOCUMENTS, "\\My Games\\Skyrim\\SKSE\\base_armor_plugin.log");
- // populate info structure
- info->infoVersion = PluginInfo::kInfoVersion;
- info->name = "base armor plugin";
- info->version = 1;
- // store plugin handle so we can identify ourselves later
- g_pluginHandle = skse->GetPluginHandle();
- if(skse->isEditor)
- {
- _MESSAGE("loaded in editor, marking as incompatible");
- return false;
- }
- else if(skse->runtimeVersion != RUNTIME_VERSION_1_9_32_0)
- {
- _MESSAGE("unsupported runtime version %08X", skse->runtimeVersion);
- return false;
- }
- // get the scaleform interface and query its version
- g_scaleform = (SKSEScaleformInterface *)skse->QueryInterface(kInterface_Scaleform);
- if(!g_scaleform)
- {
- _MESSAGE("couldn't get scaleform interface");
- return false;
- }
- if(g_scaleform->interfaceVersion < SKSEScaleformInterface::kInterfaceVersion)
- {
- _MESSAGE("scaleform interface too old (%d expected %d)", g_scaleform->interfaceVersion, SKSEScaleformInterface::kInterfaceVersion);
- return false;
- }
- // ### do not do anything else in this callback
- // ### only fill out PluginInfo and return true/false
- // supported runtime version
- return true;
- }
- bool SKSEPlugin_Load(const SKSEInterface * skse)
- {
- _MESSAGE("load");
- // register scaleform callbacks
- g_scaleform->Register("base_armor", RegisterScaleform);
- return true;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement