-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
117 lines (101 loc) · 3.14 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include "F4SE/PluginAPI.h"
#include "F4SE/GameMenus.h"
#include "F4SE_common/F4SE_version.h"
#include "F4SE_common/Relocation.h"
#include "F4SE_common/SafeWrite.h"
#include <shlobj.h>
#include <memory>
#include <string>
#define PLUGIN_VERSION MAKE_EXE_VERSION(1, 0, 1)
#define PLUGIN_NAME "ClockWidget"
IDebugLog gLog;
PluginHandle g_pluginHandle = kPluginHandle_Invalid;
F4SEScaleformInterface * g_scaleform = nullptr;
#ifdef _DEBUG
class ScaleformWidget_WriteLog : public GFxFunctionHandler
{
public:
virtual void Invoke(Args * args)
{
ASSERT(args->numArgs >= 1);
ASSERT(args->args[0].GetType() == GFxValue::kType_String);
_MESSAGE(args->args[0].GetString());
}
};
#endif
#define InjectFlashFile(a) \
GFxValue loader; \
movieRoot->CreateObject(&loader, "flash.display.Loader"); \
GFxValue loadArgs[2]; \
movieRoot->CreateObject(&loadArgs[0], "flash.net.URLRequest", &GFxValue("ClockWidget.swf"), 1); \
loadArgs[1].SetNull(); \
movieRoot->Invoke((a), nullptr, &loader, 1); \
if (!loader.Invoke("load", nullptr, loadArgs, 2)){ \
_MESSAGE("Failed to inject clock widget..."); \
}
bool ScaleformCallback(GFxMovieView * view, GFxValue * value)
{
#ifdef _DEBUG
RegisterFunction<ScaleformWidget_WriteLog>(value, view->movieRoot, "log");
#endif
GFxMovieRoot * movieRoot = view->movieRoot;
if (movieRoot)
{
GFxValue loaderInfo;
if (movieRoot->GetVariable(&loaderInfo, "root.loaderInfo.url"))
{
std::string sResult = loaderInfo.GetString();
//_MESSAGE("%s", sResult.c_str());
if (sResult.find("LoadingMenu.swf") != std::string::npos)
{
InjectFlashFile("root.FilterHolder_mc.Menu_mc.addChild");
}
else if (sResult.find("FaderMenu.swf") != std::string::npos)
{
InjectFlashFile("root.Menu_mc.SpinnerIcon_mc.addChild");
}
else if (sResult.find("MainMenu.swf") != std::string::npos)
{
InjectFlashFile("root.Menu_mc.Spinner_mc.addChild");
}
}
}
return true;
}
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_9_4)
{
MessageBox(nullptr, "UNSUPPORTED GAME VERSION.THE REQUIRED VERSION IS: V1.10.20", 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;
}
return true;
}
bool F4SEPlugin_Load(const F4SEInterface * f4se)
{
if (g_scaleform)
g_scaleform->Register("ClockWidget", ScaleformCallback);
return true;
}
};