forked from SilverIce/JContainers
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from ryobg/devel
skse:form_from_file for VR and ESL support
- Loading branch information
Showing
8 changed files
with
206 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
image: Visual Studio 2019 | ||
version: '4.2.10.{build}' | ||
version: '4.2.11.{build}' | ||
platform: x64 | ||
branches: | ||
only: | ||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#include "SkyrimVRESLAPI.h" | ||
// Interface code based on https://github.com/adamhynek/higgs | ||
|
||
#ifdef JC_SKSE_VR | ||
// Stores the API after it has already been fetched | ||
SkyrimVRESLPluginAPI::ISkyrimVRESLInterface001* g_SkyrimVRESLInterface = nullptr; | ||
|
||
// Fetches the interface to use from SkyrimVRESL | ||
SkyrimVRESLPluginAPI::ISkyrimVRESLInterface001* SkyrimVRESLPluginAPI::GetSkyrimVRESLInterface001(const PluginHandle& pluginHandle, SKSEMessagingInterface* messagingInterface) | ||
{ | ||
// If the interface has already been fetched, rturn the same object | ||
if (g_SkyrimVRESLInterface) { | ||
return g_SkyrimVRESLInterface; | ||
} | ||
|
||
// Dispatch a message to get the plugin interface from SkyrimVRESL | ||
SkyrimVRESLMessage message; | ||
messagingInterface->Dispatch(pluginHandle, SkyrimVRESLMessage::kMessage_GetInterface, (void*)&message, sizeof(SkyrimVRESLMessage*), SkyrimVRESLPluginName); | ||
if (!message.GetApiFunction) { | ||
return nullptr; | ||
} | ||
|
||
// Fetch the API for this version of the SkyrimVRESL interface | ||
g_SkyrimVRESLInterface = static_cast<ISkyrimVRESLInterface001*>(message.GetApiFunction(1)); | ||
return g_SkyrimVRESLInterface; | ||
} | ||
|
||
const ModInfo* SkyrimVRESLPluginAPI::LookupAllLoadedModByName(const char* modName) | ||
{ | ||
DataHandler* dataHandler = DataHandler::GetSingleton(); | ||
if (dataHandler) | ||
{ | ||
if (!g_SkyrimVRESLInterface) | ||
{ | ||
return dataHandler->LookupLoadedModByName(modName); | ||
} | ||
else | ||
{ | ||
const ModInfo* modInfo = dataHandler->LookupLoadedModByName(modName); | ||
if (modInfo == nullptr) | ||
{ | ||
modInfo = SkyrimVRESLPluginAPI::LookupLoadedLightModByName(modName); | ||
} | ||
return modInfo; | ||
} | ||
} | ||
return nullptr; | ||
} | ||
|
||
const ModInfo* SkyrimVRESLPluginAPI::LookupLoadedLightModByName(const char* modName) | ||
{ | ||
if (!g_SkyrimVRESLInterface) | ||
{ | ||
DataHandler* dataHandler = DataHandler::GetSingleton(); | ||
if (dataHandler) | ||
{ | ||
return dataHandler->LookupLoadedModByName(modName); | ||
} | ||
else | ||
{ | ||
return nullptr; | ||
} | ||
} | ||
else | ||
{ | ||
const SkyrimVRESLPluginAPI::TESFileCollection* fileCollection = g_SkyrimVRESLInterface->GetCompiledFileCollection(); | ||
if (fileCollection != nullptr) | ||
{ | ||
for (int i = 0; i < fileCollection->smallFiles.count; i++) | ||
{ | ||
ModInfo* smallFile = nullptr; | ||
fileCollection->smallFiles.GetNthItem(i, smallFile); | ||
if (smallFile != nullptr) | ||
{ | ||
int modNameLength = strlen(modName); | ||
if (modNameLength == strlen(smallFile->name) && _strnicmp(smallFile->name, modName, modNameLength) == 0) | ||
{ | ||
return smallFile; | ||
} | ||
} | ||
} | ||
} | ||
return nullptr; | ||
} | ||
} | ||
#endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#pragma once | ||
#include "skse64/GameReferences.h" | ||
#include "skse64/PluginAPI.h" | ||
#include <skse64/GameData.h> | ||
// Interface code based on https://github.com/adamhynek/higgs | ||
|
||
#ifdef JC_SKSE_VR | ||
namespace SkyrimVRESLPluginAPI | ||
{ | ||
constexpr const auto SkyrimVRESLPluginName = "SkyrimVRESL"; | ||
// A message used to fetch SkyrimVRESL's interface | ||
struct SkyrimVRESLMessage | ||
{ | ||
enum : uint32_t | ||
{ | ||
kMessage_GetInterface = 0xeacb2bef | ||
}; // Randomly generated | ||
void* (*GetApiFunction)(unsigned int revisionNumber) = nullptr; | ||
}; | ||
|
||
struct TESFileCollection | ||
{ | ||
public: | ||
// members | ||
tArray<ModInfo*> files; // 00 | ||
tArray<ModInfo*> smallFiles; // 18 | ||
}; | ||
STATIC_ASSERT(sizeof(TESFileCollection) == 0x30); | ||
|
||
// Returns an ISkyrimVRESLInterface001 object compatible with the API shown below | ||
// This should only be called after SKSE sends kMessage_PostLoad to your plugin | ||
struct ISkyrimVRESLInterface001; | ||
ISkyrimVRESLInterface001* GetSkyrimVRESLInterface001(const PluginHandle& pluginHandle, SKSEMessagingInterface* messagingInterface); | ||
|
||
// This object provides access to SkyrimVRESL's mod support API | ||
struct ISkyrimVRESLInterface001 | ||
{ | ||
// Gets the SkyrimVRESL build number | ||
virtual unsigned int GetBuildNumber() = 0; | ||
|
||
/// @brief Get the SSE compatible TESFileCollection for SkyrimVR. | ||
/// This should be called after kDataLoaded to ensure it's been populated. | ||
/// @return Pointer to TESFileCollection CompiledFileCollection. | ||
const virtual TESFileCollection* GetCompiledFileCollection() = 0; | ||
}; | ||
|
||
// Converts the lower bits of a FormID to a full FormID depending on plugin type | ||
static inline UInt32 GetFullFormID(const ModInfo* modInfo, UInt32 formLower) | ||
{ | ||
// Use modIndex of 0xFE as check for light plugin to determine proper form ID composition | ||
return (modInfo->modIndex != 0xFE) ? UInt32(modInfo->modIndex) << 24 | (formLower & 0xFFFFFF) : 0xFE000000 | (UInt32(modInfo->lightIndex) << 12) | (formLower & 0xFFF); | ||
} | ||
|
||
const ModInfo* LookupAllLoadedModByName(const char* modName); | ||
const ModInfo* LookupLoadedLightModByName(const char* modName); | ||
} // namespace SkyrimVRESLPluginAPI | ||
extern SkyrimVRESLPluginAPI::ISkyrimVRESLInterface001* g_SkyrimVRESLInterface; | ||
#endif |
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
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
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