-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathActions.cpp
More file actions
154 lines (128 loc) · 4.21 KB
/
Actions.cpp
File metadata and controls
154 lines (128 loc) · 4.21 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
#include "Common.h"
void Extension::CreateAtPos(LPTSTR objName, eventParam* evtParam, int layer)
{
//Iterate OI list
objInfoList* list = rhPtr->rhOiList;
int num = rhPtr->rhNumberOi-1;
short creationOI = -1;
for(int i=0; i<num; i++)
{
objInfoList info = *(objInfoList*)(((char*)list) + i*oiListItemSize);
if (! _tcscmp((TCHAR*)&info.oilName, objName))
creationOI = info.oilOi;
}
//No object was found
if(creationOI == -1)
return;
//Create the event buffer (with plenty space):
int bufferSize = sizeof(event)+sizeof(eventParam)+sizeof(CreateDuplicateParam);
char* buffer = new char[bufferSize];
memset(buffer, 0, bufferSize);
//Put the layer number in to a proper range
if(layer >= rhPtr->rhFrame->m_nLayers)
layer = rhPtr->rhFrame->m_nLayers-1;
if(layer < -1)
layer = -1;
//The event that should be passed to the CreateObject routine
event* evt = (event*)&buffer[0];
evt->evtCode = MAKELONG(0,0);
//Resides at event+14
eventParam* creationParams = (eventParam*)((char*)&buffer[0]+ACT_SIZE);
//The object creation parameters
CreateDuplicateParam* cdp = (CreateDuplicateParam*)&creationParams->evp.evpW.evpW0;
cdp->cdpHFII = rhPtr->rhNumberOi;
cdp->cdpOi = creationOI;
cdp->cdpPos = *(PositionParam*)&evtParam->evp;
cdp->cdpPos.posLayer = layer;
//Call the routine
CallTables* tables = Runtime.GetCallTables();
CALLACTION_ROUTINE createObject = tables->pActions[2];
createObject(evt);
mvFree(SDK->mV, tables);
free(buffer);
}
void Extension::CreateAtPosXY(LPTSTR objName, int x, int y, int layer)
{
//Iterate OI list
objInfoList* list = rhPtr->rhOiList;
int num = rhPtr->rhNumberOi-1;
short creationOI = -1;
for(int i=0; i<num; i++)
{
objInfoList info = *(objInfoList*)(((char*)list) + i*oiListItemSize);
if (! _tcscmp((TCHAR*)&info.oilName, objName))
creationOI = info.oilOi;
}
//No object was found
if(creationOI == -1)
return;
//Create the event buffer (with plenty space):
int bufferSize = sizeof(event)+sizeof(eventParam)+sizeof(CreateDuplicateParam);
char* buffer = new char[bufferSize];
memset(buffer, 0, bufferSize);
//Put the layer number in to a proper range
if(layer >= rhPtr->rhFrame->m_nLayers)
layer = rhPtr->rhFrame->m_nLayers-1;
if(layer < -1)
layer = -1;
//The event that should be passed to the CreateObject routine
event* evt = (event*)&buffer[0];
evt->evtCode = MAKELONG(0,0);
//Resides at event+14
eventParam* creationParams = (eventParam*)((char*)&buffer[0]+ACT_SIZE);
//The object creation parameters
CreateDuplicateParam* cdp = (CreateDuplicateParam*)&creationParams->evp.evpW.evpW0;
cdp->cdpHFII = rhPtr->rhNumberOi;
cdp->cdpOi = creationOI;
cdp->cdpPos.posX = x;
cdp->cdpPos.posY = y;
cdp->cdpPos.posLayer = layer;
cdp->cdpPos.posOINUMParent = -1;
cdp->cdpPos.posFlags = 8;
//Call the routine
CallTables* tables = Runtime.GetCallTables();
CALLACTION_ROUTINE createObject = tables->pActions[2];
createObject(evt);
mvFree(SDK->mV, tables);
free(buffer);
}
void Extension::CreateBackdropAtPos(LPTSTR objName, long position, int type, int layer)
{
CreateBackdropAtPosXY(objName, HIWORD(position), LOWORD(position), type, layer);
}
void Extension::CreateBackdropAtPosXY(LPTSTR objName, int x, int y, int type, int layer)
{
LPOI* ois = rhPtr->rhApp->m_ois;
LPOBL oblPtr = (LPOBL)rhPtr->rhObjectList;
int additionalLayerSize = isHWA ? 8 : 0;
CRunFrame* frame = (CRunFrame*)rhPtr->rhFrame;
RunFrameLayer* layerPtr = frame->m_pLayers;
// Find backdrop
for(int i=0; i<frame->m_nLayers; ++i)
{
LPLO backdropPtr = (LPLO)(frame->m_los + layerPtr->nFirstLOIndex);
for( int j = 0; j<(int)layerPtr->nBkdLOs; ++j )
{
LPOI objOI = rhPtr->rhApp->m_ois[rhPtr->rhApp->m_oi_handle_to_index[backdropPtr->loOiHandle]];
if( _tcscmp(objOI->oiName,objName) == 0 )
{
LPBackdrop_OC test = (LPBackdrop_OC)objOI->oiOC;
cSurface imageSurface;
LockImageSurface (rhPtr->rhIdAppli, test->ocImage, imageSurface, LOCKIMAGE_READBLITONLY);
rhPtr->rh4.rh4Mv->mvAddBackdrop(
&imageSurface,
x,
y,
objOI->oiHdr.oiInkEffect,
objOI->oiHdr.oiInkEffectParam,
type,
layer
);
UnlockImageSurface(imageSurface);
return;
}
backdropPtr++;
}
layerPtr = (RunFrameLayer*)(((char*)layerPtr++)+additionalLayerSize);
}
}