-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtension.cpp
165 lines (114 loc) · 3.42 KB
/
Extension.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#include "Common.h"
///
/// EXTENSION CONSTRUCTOR/DESTRUCTOR
///
Extension::Extension(LPRDATA _rdPtr, LPEDATA edPtr, fpcob cobPtr)
: rdPtr(_rdPtr), rhPtr(_rdPtr->rHo.hoAdRunHeader), Runtime(_rdPtr)
{
/*
Link all your action/condition/expression functions to their IDs to match the
IDs in the JSON here
*/
LinkCondition(0, IsUnicode);
LinkExpression(0, GetASCIIStringFromUnicodeString);
LinkExpression(1, GetUnicodeStringFromASCIIString);
LinkExpression(2, GetASCIIStringFromUnicodeMemory);
LinkExpression(3, GetUnicodeStringFromASCIIMemory);
LinkExpression(4, GetASCIIMemoryFromUnicodeString);
LinkExpression(5, GetUnicodeMemoryFromASCIIString);
LinkExpression(6, GetASCIIMemoryFromUnicodeMemory);
LinkExpression(7, GetUnicodeMemoryFromASCIIMemory);
/*
This is where you'd do anything you'd do in CreateRunObject in the original SDK
It's the only place you'll get access to edPtr at runtime, so you should transfer
anything from edPtr to the extension class here.
*/
}
Extension::~Extension()
{
/*
This is where you'd do anything you'd do in DestroyRunObject in the original SDK.
(except calling destructors and other such atrocities, because that's automatic in Edif)
*/
}
short Extension::Handle()
{
/*
If your extension will draw to the MMF window you should first
check if anything about its display has changed :
if (rdPtr->roc.rcChanged)
return REFLAG_DISPLAY;
else
return 0;
You will also need to make sure you change this flag yourself
to 1 whenever you want to redraw your object
If your extension won't draw to the window, but it still needs
to do something every MMF loop use :
return 0;
If you don't need to do something every loop, use :
return REFLAG_ONESHOT;
This doesn't mean this function can never run again. If you want MMF
to handle your object again (causing this code to run) use this function:
Runtime.Rehandle();
At the end of the loop this code will run
*/
// Will not be called next loop
return REFLAG_ONESHOT;
}
short Extension::Display()
{
/*
If you return REFLAG_DISPLAY in Handle() this routine will run.
*/
// Ok
return 0;
}
short Extension::Pause()
{
// Ok
return 0;
}
short Extension::Continue()
{
// Ok
return 0;
}
bool Extension::Save(HANDLE File)
{
bool OK = false;
#ifndef VITALIZE
// Save the object's data here
OK = true;
#endif
return OK;
}
bool Extension::Load(HANDLE File)
{
bool OK = false;
#ifndef VITALIZE
// Load the object's data here
OK = true;
#endif
return OK;
}
// These are called if there's no function linked to an ID
void Extension::Action(int ID, LPRDATA rdPtr, long param1, long param2)
{
char t [50];
sprintf_s(t, 50, "Action not set up: ID %i.", ID);
MessageBoxA(NULL, t, "Darknet Object Error", MB_OK);
}
long Extension::Condition(int ID, LPRDATA rdPtr, long param1, long param2)
{
char t [50];
sprintf_s(t, 50, "Condition not set up: ID %i.", ID);
MessageBoxA(NULL, t, "Darknet Object Error", MB_OK);
return false;
}
long Extension::Expression(int ID, LPRDATA rdPtr, long param)
{
char t [50];
sprintf_s(t, 50, "Expression not set up: ID %i.", ID);
MessageBoxA(NULL, t, "Darknet Object Error", MB_OK);
return 0;
}