MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / dumpActionMap

Method dumpActionMap

Engine/source/sim/actionMap.cpp:229–420  ·  view source on GitHub ↗

--------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

227
228//--------------------------------------------------------------------------
229void ActionMap::dumpActionMap(const char* fileName, const bool append) const
230{
231 if (fileName != NULL) {
232 // Dump the deletion, and creation script commands, followed by all the binds
233 // to a script.
234
235 FileStream *iostrm;
236 if((iostrm = FileStream::createAndOpen( fileName, append ? Torque::FS::File::WriteAppend : Torque::FS::File::Write )) == NULL)
237 {
238 Con::errorf( "Unable to open file '%s' for writing.", fileName );
239 return;
240 }
241
242 char lineBuffer[1024];
243 if ( append )
244 iostrm->setPosition( iostrm->getStreamSize() );
245 else
246 {
247 // IMPORTANT -- do NOT change the following line, it identifies the file as an input map file
248 dStrcpy( lineBuffer, "// Torque Input Map File\n" );
249 iostrm->write( dStrlen( lineBuffer ), lineBuffer );
250 }
251
252 dSprintf(lineBuffer, 1023, "if (isObject(%s)) %s.delete();\n"
253 "new ActionMap(%s);\n", getName(), getName(), getName());
254 iostrm->write(dStrlen(lineBuffer), lineBuffer);
255
256 // Dump all the binds to the console...
257 for (S32 i = 0; i < mDeviceMaps.size(); i++) {
258 const DeviceMap* pDevMap = mDeviceMaps[i];
259
260 char devbuffer[32];
261 getDeviceName(pDevMap->deviceType, pDevMap->deviceInst, devbuffer);
262
263 for (S32 j = 0; j < pDevMap->nodeMap.size(); j++) {
264 const Node& rNode = pDevMap->nodeMap[j];
265
266 const char* pModifierString = getModifierString(rNode.modifiers);
267
268 char objectbuffer[64];
269 if (getKeyString(rNode.action, objectbuffer) == false)
270 continue;
271
272 const char* command = (rNode.flags & Node::BindCmd) ? "bindCmd" : "bind";
273
274 dSprintf(lineBuffer, 1023, "%s.%s(%s, \"%s%s\"",
275 getName(),
276 command,
277 devbuffer,
278 pModifierString, objectbuffer);
279
280 if (rNode.flags & (Node::HasScale|Node::HasDeadZone|Node::Ranged|Node::Inverted)) {
281 char buff[10];
282 U32 curr = 0;
283 buff[curr++] = ',';
284 buff[curr++] = ' ';
285 if (rNode.flags & Node::HasScale)
286 buff[curr++] = 'S';

Callers 1

actionMap.cppFile · 0.80

Calls 12

errorfFunction · 0.85
dStrcpyFunction · 0.85
dSprintfFunction · 0.85
dStrcatFunction · 0.85
expandEscapeFunction · 0.85
printfFunction · 0.85
dStrlenFunction · 0.50
getNameFunction · 0.50
setPositionMethod · 0.45
getStreamSizeMethod · 0.45
writeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected