Last active
August 29, 2015 14:04
-
-
Save himika/248400fba4ffada3e75f to your computer and use it in GitHub Desktop.
SKSETaskInterfaceの使用例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <skse.h> | |
#include <skse/PluginAPI.h> | |
#include <skse/GameThreads.h> | |
#include <shlobj.h> | |
IDebugLog gLog; | |
PluginHandle g_pluginHandle = kPluginHandle_Invalid; | |
SKSEScaleformInterface * g_scaleform = NULL; | |
SKSESerializationInterface * g_serialization = NULL; | |
SKSETaskInterface * g_task = NULL; | |
class SKSETaskXXXXXX : public TaskDelegate | |
{ | |
public: | |
virtual void Run(); | |
virtual void Dispose(); | |
}; | |
void SKSETaskXXXXXX::Run() | |
{ | |
// ここに重たい処理を書く | |
} | |
void SKSETaskXXXXXX::Dispose() | |
{ | |
// 最後にオブジェクトを破棄するとき呼ばれる。 | |
// ここで後始末をする。 | |
} | |
extern "C" | |
{ | |
bool SKSEPlugin_Query(const SKSEInterface * skse, PluginInfo * info) | |
{ | |
gLog.OpenRelative(CSIDL_MYDOCUMENTS, "\\My Games\\Skyrim\\SKSE\\skse_task_interface_test.log"); | |
// populate info structure | |
info->infoVersion = PluginInfo::kInfoVersion; | |
info->name = "skse_task_interface_test"; | |
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; | |
} | |
// スケールフォーム・インタフェースを取得して、バージョンを確認 | |
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; | |
} | |
// シリアライゼーション・インタフェースを取得して、バージョンを確認 | |
// get the serialization interface and query its version | |
g_serialization = (SKSESerializationInterface *)skse->QueryInterface(kInterface_Serialization); | |
if(!g_serialization) | |
{ | |
_MESSAGE("couldn't get serialization interface"); | |
return false; | |
} | |
if(g_serialization->version < SKSESerializationInterface::kVersion) | |
{ | |
_MESSAGE("serialization interface too old (%d expected %d)", g_serialization->version, SKSESerializationInterface::kVersion); | |
return false; | |
} | |
// タスク・インタフェースを取得して、バージョンを確認 | |
g_task = (SKSETaskInterface *)skse->QueryInterface(kInterface_Task); | |
if(!g_task) | |
{ | |
_MESSAGE("couldn't get task interface"); | |
return false; | |
} | |
if(g_task->interfaceVersion < SKSETaskInterface::kInterfaceVersion) | |
{ | |
_MESSAGE("task interface too old (%d expected %d)", g_task->interfaceVersion, SKSESerializationInterface::kInterfaceVersion); | |
return false; | |
} | |
// supported runtime version | |
return true; | |
} | |
bool SKSEPlugin_Load(const SKSEInterface * skse) | |
{ | |
_MESSAGE("load"); | |
// こんな感じで使う。 | |
static SKSETaskXXXXXX myTask; | |
g_task->AddTask(&myTask); | |
return true; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment