-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
156 lines (141 loc) · 4.16 KB
/
Main.cpp
File metadata and controls
156 lines (141 loc) · 4.16 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
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
// ============================================================================
//
// This file contains the actions, conditions and expressions your object uses
//
// ============================================================================
#include "common.h"
// ============================================================================
//
// FUNCTIONS
//
// ============================================================================
void RefreshList (LPRDATA rdPtr, bool GEvent = false)
{
// Obtain object list
LPRH rhPtr = rdPtr -> rHo.hoAdRunHeader;
LPOBL oblPtr = (LPOBL)rhPtr->rhObjectList;
// Clear current list
rdPtr -> FixedVector.clear();
// Loop through object list and add to vector list
for (int i = 0; i < rhPtr->rhNObjects; oblPtr++, i++)
{
LPRO roPtr = (LPRO)(oblPtr->oblOffset);
if (roPtr == NULL) continue;
rdPtr -> FixedVector.push_back((roPtr->roHo.hoCreationId << 16) + roPtr->roHo.hoNumber);
if (GEvent) //If iterating action, generate an event.
{
rdPtr -> FValue = (roPtr->roHo.hoCreationId << 16) + roPtr->roHo.hoNumber;
rdPtr -> rRd-> GenerateEvent(0);
}
}
}
// ============================================================================
//
// CONDITIONS
//
// ============================================================================
CONDITION(
/* ID */ 0,
/* Name */ _T("%o: On iterated value"),
/* Flags */ 0,
/* Params */ (0)
) {
// This is called by GEvent being true in RefreshList.
// Just return true.
return true;
}
// ============================================================================
//
// ACTIONS
//
// ============================================================================
ACTION(
/* ID */ 0,
/* Name */ _T("Iterate fixed value list"),
/* Flags */ 0,
/* Params */ (0)
) {
//Refresh the list, and generate an event for each fixed value
RefreshList(rdPtr, true);
}
// ============================================================================
//
// EXPRESSIONS
//
// ============================================================================
EXPRESSION(
/* ID */ 0,
/* Name */ _T("LastFixedValue("),
/* Flags */ 0,
/* Params */ (0)
) {
// Deprecated expression: Notify user
MessageBox(NULL, _T("Sorry to interrupt your programming, but you have\nan old \"LastFixedValue\" expression in FixedValueList which needs replacing.\nClick the FixedValueList icon in your event editor to see all the events\nZlibStream is in."), _T("Darkwire Software - Old Expression Notice"), MB_OK);
return 0;
}
EXPRESSION(
/* ID */ 1,
/* Name */ _T("LastIteratedValue("),
/* Flags */ 0,
/* Params */ (0)
) {
return rdPtr -> FValue;
}
EXPRESSION(
/* ID */ 2,
/* Name */ _T("GetFixedFromIndex("),
/* Flags */ 0,
/* Params */ (1, EXPPARAM_NUMBER, _T("Index"))
) {
int p1 = ExParam(TYPE_INT);
RefreshList(rdPtr);
if (p1 >= 0 && p1 < rdPtr -> FixedVector.size()) //Remember vectors are 0-based.
return rdPtr -> FixedVector[p1];
else
{
rdPtr -> LastError = _T("GetFixedFromIndex failed: index out of range.");
return 0;
}
}
EXPRESSION(
/* ID */ 3,
/* Name */ _T("GetList$("),
/* Flags */ EXPFLAG_STRING,
/* Params */ (1, EXPPARAM_STRING, _T("Delimiter"))
) {
tchar * p1 = (tchar *) ExParam(TYPE_STRING);
if (p1 = _T(""))
{
rdPtr -> LastError = _T("Blank delimiter given.");
ReturnStringSafe(_T("0"));
}
stringstream ss;
string temp, temp2;
RefreshList(rdPtr);
for (int i = 0; i < rdPtr -> FixedVector.size(); i++)
{
//Add to stringstream
ss << rdPtr -> FixedVector[i] << p1;
}
// Set temp to the stream
temp = ss.str(); ss.flush();
// This removes the ending delimiter. For example, "F1|F2|" goes to "F1|F2".
// 0 is the offset of the first character to read: here it is 0, read from start.
temp2 = temp.substr(0, temp.length()-(_tcslen(p1)*sizeof(tchar))); temp = "";
#ifndef UNICODE
ReturnStringSafe(temp2.c_str());
#else
//Cast to Unicode
wchar_t * temp3;
MultiByteToWideChar(mV->mvGetAppCodePage(mV, mV->mvEditApp), NULL, temp2.c_str(), NULL, temp3,NULL);
ReturnStringSafe(temp3);
#endif
}
EXPRESSION(
/* ID */ 4,
/* Name */ _T("LastError$("),
/* Flags */ EXPFLAG_STRING,
/* Params */ (0)
) {
ReturnStringSafe(rdPtr -> LastError);
}