-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdllmain.cpp
More file actions
92 lines (60 loc) · 1.91 KB
/
dllmain.cpp
File metadata and controls
92 lines (60 loc) · 1.91 KB
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
/* definitions */
#include "pch.h"
#ifdef _WIN32
#define EXPORT extern "C" __declspec(dllexport)
#else
#define EXPORT extern "C"
#endif /* _WIN32 */
#define LOGFILENAME "MessageLogMaster.txt" /* ログファイルのファイル名 */
#define PLUGINLOGMESSAGE_NAME "LogMessageMaster" /* プラグインの名前 */
/* ログファイル関係のメッセージタイプ(自由に内部メッセージタイプを設定できる) */
#define MMDAGENT_EVENT_FILEOPEN "LOGMESSAGE_EVENT_FILEOPEN"
#define MMDAGENT_EVENT_FILECLOSE "LOGMESSAGE_EVENT_FILECLOSE"
/* headers */
#include "MMDAgent.h"
#include <fstream>
#include <ctime>
/* variables */
static bool enable;
static std::ofstream ofs;
static time_t t;
static tm* x;
EXPORT void extAppStart(MMDAgent* mmdagent)
{
if (mmdagent == nullptr) {
printf("Error: mmdagent instance is null.\n");
return;
}
enable = true;
const char* fileName = LOGFILENAME;
ofs.open(fileName, std::ios::out | std::ios::app);
if (!ofs) {
mmdagent->sendMessage(MMDAGENT_EVENT_FILEOPEN, "%s can not be opened!", fileName);
}
else {
mmdagent->sendMessage(MMDAGENT_EVENT_FILEOPEN, "%s can be opened", fileName);
t = time(0);
char buf[32];
ctime_s(buf, sizeof(buf), &t);
ofs << buf;
ofs << "[[Start]]" << std::endl;
}
}
EXPORT void extProcMessage(MMDAgent* mmdagent, const char* type, const char* args)
{
if (enable && type != nullptr) {
ofs << type << "|" << (args ? args : "null") << std::endl;
}
}
EXPORT void extAppEnd(MMDAgent* mmdagent)
{
ofs << "[[End]]" << std::endl;
ofs << std::endl;
ofs.close();
}
EXPORT void extUpdate(MMDAgent* mmdagent, double deltaFrame)
{
}
EXPORT void extRender(MMDAgent* mmdagent)
{
}