-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.cpp
81 lines (59 loc) · 1.92 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "F4SE_common/F4SE_version.h"
#include "Scaleform.h"
#include <shlobj.h>
#include <memory>
#include <string>
#define PLUGIN_VERSION MAKE_EXE_VERSION(1, 0, 2)
#define PLUGIN_NAME "HUDPlusPlus"
IDebugLog gLog;
PluginHandle g_pluginHandle = kPluginHandle_Invalid;
F4SEScaleformInterface * g_scaleform = nullptr;
F4SEMessagingInterface * g_messaging = nullptr;
extern "C"
{
bool F4SEPlugin_Query(const F4SEInterface * f4se, PluginInfo * info)
{
std::unique_ptr<char[]> sPath(new char[MAX_PATH]);
sprintf_s(sPath.get(), MAX_PATH, "%s%s.log", "\\My Games\\Fallout4\\F4SE\\", PLUGIN_NAME);
gLog.OpenRelative(CSIDL_MYDOCUMENTS, sPath.get());
_MESSAGE("%s: %08X", PLUGIN_NAME, PLUGIN_VERSION);
info->infoVersion = PluginInfo::kInfoVersion;
info->name = PLUGIN_NAME;
info->version = PLUGIN_VERSION;
g_pluginHandle = f4se->GetPluginHandle();
if (f4se->runtimeVersion != RUNTIME_VERSION_1_10_26)
{
MessageBoxA(nullptr, "UNSUPPORTED GAME VERSION. REQUIRED VERSION IS: V1.10.26", PLUGIN_NAME, MB_OK);
return false;
}
if (f4se->isEditor)
{
_FATALERROR("loaded in editor, marking as incompatible");
return false;
}
g_scaleform = (F4SEScaleformInterface *)f4se->QueryInterface(kInterface_Scaleform);
if (!g_scaleform)
{
_FATALERROR("couldn't get scaleform interface");
return false;
}
g_messaging = (F4SEMessagingInterface *)f4se->QueryInterface(kInterface_Messaging);
if (!g_messaging)
{
_FATALERROR("couldn't get messaging interface");
return false;
}
return true;
}
bool F4SEPlugin_Load(const F4SEInterface * f4se)
{
constexpr char* configFile = ".\\Data\\F4SE\\Plugins\\HUDPlusPlus.ini";
constexpr char* settingsSection = "Settings";
InitHooks();
if (g_scaleform)
g_scaleform->Register("HUDPlusPlus", ScaleformCallback);
if (g_messaging != nullptr)
g_messaging->RegisterListener(g_pluginHandle, "F4SE", MessageCallback);
return true;
}
};