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

Method dumpActionMap

Engine/source/sim/actionMap.cpp:229–450  ·  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", 1024 );
249 iostrm->write( dStrlen( lineBuffer ), lineBuffer );
250 }
251
252 dSprintf(lineBuffer, 1024, "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;
273 if (rNode.flags & Node::BindCmd)
274 command = "bindCmd";
275 else if (rNode.flags & Node::Held)
276 command = "held";
277 else
278 command = "bind";
279
280 dSprintf(lineBuffer, 1024, "%s.%s(%s, \"%s%s\"",
281 getName(),
282 command,
283 devbuffer,
284 pModifierString, objectbuffer);
285
286 if (rNode.flags & (Node::HasScale|Node::HasDeadZone|Node::Ranged|Node::Inverted)) {

Callers 1

actionMap.cppFile · 0.80

Calls 12

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

Tested by

no test coverage detected