defaultGame.cc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "game/defaultGame.h"
  23. #include "platform/types.h"
  24. #include "platform/Tickable.h"
  25. #include "platform/platform.h"
  26. #include "platform/platformVideo.h"
  27. #include "platform/platformInput.h"
  28. #include "platform/platformAudio.h"
  29. #include "platform/event.h"
  30. #include "game/gameInterface.h"
  31. #include "collection/vector.h"
  32. #include "math/mMath.h"
  33. #include "graphics/dgl.h"
  34. #include "graphics/gBitmap.h"
  35. #include "io/resource/resourceManager.h"
  36. #include "io/fileStream.h"
  37. #include "graphics/TextureManager.h"
  38. #include "console/console.h"
  39. #include "sim/simBase.h"
  40. #include "gui/guiCanvas.h"
  41. #include "input/actionMap.h"
  42. #include "network/connectionProtocol.h"
  43. #include "io/bitStream.h"
  44. #include "network/telnetConsole.h"
  45. #include "debug/telnetDebugger.h"
  46. #include "console/consoleTypes.h"
  47. #include "math/mathTypes.h"
  48. #include "graphics/TextureManager.h"
  49. #include "io/resource/resourceManager.h"
  50. #include "platform/platformVideo.h"
  51. #include "network/netStringTable.h"
  52. #include "memory/frameAllocator.h"
  53. #include "game/version.h"
  54. #include "debug/profiler.h"
  55. #include "network/serverQuery.h"
  56. #include "game/defaultGame.h"
  57. #include "platform/nativeDialogs/msgBox.h"
  58. #include "platform/nativeDialogs/fileDialog.h"
  59. #include "memory/safeDelete.h"
  60. #include <stdio.h>
  61. #ifndef _NETWORK_PROCESS_LIST_H_
  62. #include "network/networkProcessList.h"
  63. #endif
  64. #ifndef _REMOTE_DEBUGGER_BRIDGE_H_
  65. #include "debug/remote/RemoteDebuggerBridge.h"
  66. #endif
  67. #ifndef _MODULE_MANAGER_H
  68. #include "module/moduleManager.h"
  69. #endif
  70. #ifndef _ASSET_MANAGER_H_
  71. #include "assets/assetManager.h"
  72. #endif
  73. #ifndef _PARTICLE_SYSTEM_H_
  74. #include "2d/core/particleSystem.h"
  75. #endif
  76. #ifdef TORQUE_OS_IOS
  77. #include "platformiOS/iOSProfiler.h"
  78. #endif
  79. // Script binding.
  80. #include "platform/platform_ScriptBinding.h"
  81. //-----------------------------------------------------------------------------
  82. DefaultGame GameObject;
  83. DemoNetInterface GameNetInterface;
  84. NetworkProcessList gServerProcessList(true);
  85. StringTableEntry gMasterAddress;
  86. static F32 gTimeScale = 1.0;
  87. static U32 gTimeAdvance = 0;
  88. static U32 gFrameSkip = 0;
  89. static U32 gFrameCount = 0;
  90. // Reset frames stats.
  91. static F32 framePeriod = 0.0f;
  92. static F32 frameTotalTime = 0.0f;
  93. static F32 frameTotalLastTime = 0.0f;
  94. static U32 frameTotalCount = 0;
  95. //-----------------------------------------------------------------------------
  96. bool initializeLibraries()
  97. {
  98. PlatformAssert::create();
  99. _StringTable::create();
  100. Con::init();
  101. Sim::init();
  102. if(!Net::init())
  103. {
  104. printf("Network Error : Unable to initialize the network... aborting.");
  105. return false;
  106. }
  107. gMasterAddress = StringTable->EmptyString;
  108. Con::addVariable( "MasterServerAddress", TypeString, &gMasterAddress );
  109. // Create the stock colors.
  110. StockColor::create();
  111. #ifdef TORQUE_OS_IOS
  112. //3MB default is way too big for iPhone!!!
  113. #ifdef TORQUE_SHIPPING
  114. FrameAllocator::init(256 * 1024); //256KB for now... but let's test and see!
  115. #else
  116. FrameAllocator::init(512 * 1024); //512KB for now... but let's test and see!
  117. #endif //TORQUE_SHIPPING
  118. #else
  119. FrameAllocator::init(3 << 20); // 3 meg frame allocator buffer
  120. #endif //TORQUE_OS_IOS
  121. TextureManager::create();
  122. ResManager::create();
  123. // Register known file types here
  124. ResourceManager->registerExtension(".jpg", constructBitmapJPEG);
  125. ResourceManager->registerExtension(".jpeg", constructBitmapJPEG);
  126. ResourceManager->registerExtension(".png", constructBitmapPNG);
  127. ResourceManager->registerExtension(".uft", constructNewFont);
  128. #ifdef TORQUE_OS_IOS
  129. ResourceManager->registerExtension(".pvr", constructBitmapPVR);
  130. #endif
  131. Platform::initConsole();
  132. NetStringTable::create();
  133. TelnetConsole::create();
  134. TelnetDebugger::create();
  135. Processor::init();
  136. Math::init();
  137. Platform::init(); // platform specific initialization
  138. // Initialize the particle system.
  139. ParticleSystem::Init();
  140. #if defined(TORQUE_OS_IOS) && defined(_USE_STORE_KIT)
  141. storeInit();
  142. #endif // TORQUE_OS_IOS && _USE_STORE_KIT
  143. return true;
  144. }
  145. //--------------------------------------------------------------------------
  146. void shutdownLibraries()
  147. {
  148. // Purge any resources on the timeout list...
  149. if (ResourceManager)
  150. ResourceManager->purge();
  151. TelnetDebugger::destroy();
  152. TelnetConsole::destroy();
  153. Sim::shutdown();
  154. Platform::shutdown();
  155. NetStringTable::destroy();
  156. Con::shutdown();
  157. ResManager::destroy();
  158. TextureManager::destroy();
  159. // Destroy the stock colors.
  160. StockColor::destroy();
  161. _StringTable::destroy();
  162. // asserts should be destroyed LAST
  163. FrameAllocator::destroy();
  164. PlatformAssert::destroy();
  165. Net::shutdown();
  166. // Destroy the particle system.
  167. ParticleSystem::destroy();
  168. #ifdef _USE_STORE_KIT
  169. storeCleanup();
  170. #endif // _USE_STORE_KIT
  171. }
  172. //--------------------------------------------------------------------------
  173. bool initializeGame(int argc, const char **argv)
  174. {
  175. Con::addVariable("timeScale", TypeF32, &gTimeScale);
  176. Con::addVariable("timeAdvance", TypeS32, &gTimeAdvance);
  177. Con::addVariable("frameSkip", TypeS32, &gFrameSkip);
  178. initMessageBoxVars();
  179. // Register the module manager.
  180. ModuleDatabase.registerObject( "ModuleDatabase" );
  181. // Register the asset database.
  182. AssetDatabase.registerObject( "AssetDatabase" );
  183. // Register the asset database as a module listener.
  184. ModuleDatabase.addListener( &AssetDatabase );
  185. ActionMap* globalMap = new ActionMap;
  186. globalMap->registerObject("GlobalActionMap");
  187. Sim::getActiveActionMapSet()->pushObject(globalMap);
  188. // Let the remote debugger process the command-line.
  189. RemoteDebuggerBridge::processCommandLine( argc, argv );
  190. if(argc > 2 && dStricmp(argv[1], "-project") == 0)
  191. {
  192. char playerPath[1024];
  193. Platform::makeFullPathName(argv[2], playerPath, sizeof(playerPath));
  194. Platform::setCurrentDirectory(playerPath);
  195. argv += 2;
  196. argc -= 2;
  197. }
  198. // Scan executable location and all sub-directories.
  199. ResourceManager->setWriteablePath(Platform::getCurrentDirectory());
  200. ResourceManager->addPath( Platform::getCurrentDirectory() );
  201. FileStream scriptFileStream;
  202. Stream* scriptStream;
  203. const char* defaultScriptName = "main.cs";
  204. bool useDefaultScript = true;
  205. // Check if any command-line parameters were passed (the first is just the app name).
  206. if (argc > 1)
  207. {
  208. // If so, check if the first parameter is a file to open.
  209. if ( (scriptFileStream.open(argv[1], FileStream::Read)) && dStrncmp(argv[1], "", 1) )
  210. {
  211. // If it opens, we assume it is the script to run.
  212. useDefaultScript = false;
  213. scriptStream = &scriptFileStream;
  214. }
  215. }
  216. if (useDefaultScript)
  217. {
  218. bool success = false;
  219. success = scriptFileStream.open(defaultScriptName, FileStream::Read);
  220. if( !success )
  221. {
  222. char msg[1024];
  223. dSprintf(msg, sizeof(msg), "Failed to open \"%s\".", defaultScriptName);
  224. printf(" Error : %s", msg);
  225. return false;
  226. }
  227. scriptStream = &scriptFileStream;
  228. }
  229. // Create a script buffer.
  230. const U32 size = scriptStream->getStreamSize();
  231. char* pScriptBuffer = new char[size + 1];
  232. // Read script.
  233. scriptStream->read(size, pScriptBuffer);
  234. scriptFileStream.close();
  235. pScriptBuffer[size] = 0;
  236. char buffer[1024], *ptr;
  237. Platform::makeFullPathName(useDefaultScript ? defaultScriptName : argv[1], buffer, sizeof(buffer), Platform::getCurrentDirectory());
  238. ptr = dStrrchr( buffer, '/' );
  239. if ( ptr )
  240. *ptr = 0;
  241. Platform::setMainDotCsDir(buffer);
  242. Platform::setCurrentDirectory(buffer);
  243. const S32 errorHash = Con::getIntVariable("$ScriptErrorHash");
  244. Con::evaluate(pScriptBuffer, false, useDefaultScript ? defaultScriptName : argv[1]);
  245. delete[] pScriptBuffer;
  246. // Did an error occur?
  247. if ( errorHash != Con::getIntVariable("$ScriptErrorHash") )
  248. {
  249. printf( "Quitting as an error occurred parsing the root script '%s'.", useDefaultScript ? defaultScriptName : argv[1] );
  250. return false;
  251. }
  252. return true;
  253. }
  254. //--------------------------------------------------------------------------
  255. void shutdownGame()
  256. {
  257. // Perform pre-exit callback.
  258. if( Con::isFunction("onPreExit") )
  259. Con::executef(1, "onPreExit");
  260. //exec the script onExit() function
  261. Con::executef(1, "onExit");
  262. // Unregister the module database.
  263. ModuleDatabase.unregisterObject();
  264. // Unregister the asset database.
  265. AssetDatabase.unregisterObject();
  266. }
  267. //--------------------------------------------------------------------------
  268. bool DefaultGame::mainInitialize(int argc, const char **argv)
  269. {
  270. if(!initializeLibraries())
  271. return false;
  272. // Set up the command line args for the console scripts...
  273. Con::setIntVariable("$GameProject::argc", argc);
  274. U32 i;
  275. for (i = 0; i < (U32)argc; i++)
  276. Con::setVariable(avar("$GameProject::argv%d", i), argv[i]);
  277. if (initializeGame(argc, argv) == false)
  278. {
  279. //Using printf cos Con:: is not around here.
  280. printf("\nApplication failed to start! Make sure your resources are in the correct place.");
  281. shutdownGame();
  282. shutdownLibraries();
  283. return false;
  284. }
  285. // Start processing ticks.
  286. setProcessTicks( true );
  287. #ifdef TORQUE_OS_IOS
  288. // Torque 2D does not have true, GameKit networking support.
  289. // The old socket network code is untested, undocumented and likely broken.
  290. // This will eventually be replaced with GameKit.
  291. // For now, it is confusing to even have a checkbox in the editor that no one uses or understands.
  292. // If you are one of the few that uses this, just replace the false; with the commented line. -MP 1.5
  293. //-Mat this is a bit of a hack, but if we don't want the network, we shut it off now.
  294. // We can't do it until we've run the entry script, otherwise the script variable will not have ben loaded
  295. bool usesNet = false; //dAtob( Con::getVariable( "$pref::iOS::UseNetwork" ) );
  296. if( !usesNet ) {
  297. Net::shutdown();
  298. }
  299. #ifdef TORQUE_OS_IOS_PROFILE
  300. iPhoneProfilerProfilerInit();
  301. #endif
  302. #endif
  303. return true;
  304. }
  305. //--------------------------------------------------------------------------
  306. void DefaultGame::processTick( void )
  307. {
  308. Con::setVariable( "Sim::Time", avar("%4.1f", (F32)Platform::getVirtualMilliseconds() / 1000.0f ) );
  309. // Update the frame variables periodically.
  310. static F32 lastFrameUpdate = frameTotalTime;
  311. if ( (frameTotalTime - lastFrameUpdate) > 0.25f )
  312. {
  313. Con::setVariable( "fps::framePeriod", avar("%4.1f", 1.0f / framePeriod) );
  314. Con::setVariable( "fps::frameCount", avar("%u", frameTotalCount) );
  315. lastFrameUpdate = frameTotalTime;
  316. }
  317. }
  318. //--------------------------------------------------------------------------
  319. void DefaultGame::advanceTime( F32 timeDelta )
  320. {
  321. // Update total frame time.
  322. frameTotalTime += timeDelta;
  323. // Update frame total count.
  324. frameTotalCount++;
  325. // Have we already processed a single frame?
  326. if ( frameTotalCount > 1 )
  327. {
  328. // Yes, so set the time-bias to use.
  329. const F32 timeBias = 0.01f;
  330. // Calculate the current frame period.
  331. framePeriod = framePeriod * ( 1.0f - timeBias ) + ( frameTotalTime - frameTotalLastTime ) * timeBias;
  332. }
  333. // Update last total frame time.
  334. frameTotalLastTime = frameTotalTime;
  335. }
  336. //--------------------------------------------------------------------------
  337. void DefaultGame::mainLoop( void )
  338. {
  339. #ifdef TORQUE_OS_IOS_PROFILE
  340. iPhoneProfilerStart("MAIN_LOOP");
  341. #endif
  342. PROFILE_START(MainLoop);
  343. #ifdef TORQUE_ALLOW_JOURNALING
  344. PROFILE_START(JournalMain);
  345. Game->journalProcess();
  346. PROFILE_END();
  347. #endif // TORQUE_ALLOW_JOURNALING
  348. PROFILE_START(NetProcessMain);
  349. Net::process(); // read in all events
  350. PROFILE_END();
  351. PROFILE_START(PlatformProcessMain);
  352. Platform::process(); // keys, etc.
  353. PROFILE_END();
  354. PROFILE_START(TelconsoleProcessMain);
  355. TelConsole->process();
  356. PROFILE_END();
  357. PROFILE_START(TelDebuggerProcessMain);
  358. TelDebugger->process();
  359. PROFILE_END();
  360. PROFILE_START(TimeManagerProcessMain);
  361. TimeManager::process(); // guaranteed to produce an event
  362. PROFILE_END();
  363. PROFILE_START(GameProcessEvents);
  364. Game->processEvents(); // process all non-sim posted events.
  365. PROFILE_END();
  366. PROFILE_END();
  367. #ifdef TORQUE_OS_IOS_PROFILE
  368. iPhoneProfilerEnd("MAIN_LOOP");
  369. if(iPhoneProfilerGetCount() >= 60){
  370. iPhoneProfilerPrintAllResults();
  371. iPhoneProfilerProfilerInit();
  372. }
  373. #endif
  374. }
  375. //-----------------------------------------------------------------------------
  376. void DefaultGame::mainShutdown( void )
  377. {
  378. // Stop processing ticks.
  379. setProcessTicks( false );
  380. shutdownGame();
  381. shutdownLibraries();
  382. if( Game->requiresRestart() )
  383. Platform::restartInstance();
  384. }
  385. //--------------------------------------------------------------------------
  386. void DefaultGame::gameReactivate( void )
  387. {
  388. if ( !Input::isEnabled() )
  389. Input::enable();
  390. if ( !Input::isActive() )
  391. Input::reactivate();
  392. TextureManager::mDGLRender = true;
  393. if ( Canvas )
  394. Canvas->resetUpdateRegions();
  395. }
  396. //--------------------------------------------------------------------------
  397. void DefaultGame::gameDeactivate( const bool noRender )
  398. {
  399. if ( Input::isActive() )
  400. Input::deactivate();
  401. if ( Input::isEnabled() )
  402. Input::disable();
  403. if ( noRender )
  404. TextureManager::mDGLRender = false;
  405. }
  406. //--------------------------------------------------------------------------
  407. void DefaultGame::textureKill()
  408. {
  409. TextureManager::killManager();
  410. }
  411. //--------------------------------------------------------------------------
  412. void DefaultGame::textureResurrect()
  413. {
  414. TextureManager::resurrectManager();
  415. }
  416. //--------------------------------------------------------------------------
  417. void DefaultGame::refreshWindow()
  418. {
  419. if(Canvas)
  420. Canvas->resetUpdateRegions();
  421. }
  422. //--------------------------------------------------------------------------
  423. void DefaultGame::processQuitEvent()
  424. {
  425. setRunning(false);
  426. }
  427. //--------------------------------------------------------------------------
  428. void DefaultGame::processTimeEvent(TimeEvent *event)
  429. {
  430. PROFILE_START(ProcessTimeEvent);
  431. U32 elapsedTime = event->elapsedTime;
  432. if(elapsedTime > 1024)
  433. {
  434. elapsedTime = 0;
  435. }
  436. if(gTimeAdvance)
  437. {
  438. elapsedTime = gTimeAdvance;
  439. }
  440. else if ( mNotEqual( gTimeScale, 1.0f ) )
  441. {
  442. elapsedTime = (U32) (elapsedTime * gTimeScale);
  443. }
  444. {
  445. elapsedTime = elapsedTime;
  446. }
  447. Platform::advanceTime(elapsedTime);
  448. bool tickPass;
  449. PROFILE_START(ServerProcess);
  450. #ifdef TORQUE_OS_IOS_PROFILE
  451. iPhoneProfilerStart("SERVER_PROC");
  452. #endif
  453. tickPass = gServerProcessList.advanceTime(elapsedTime);
  454. #ifdef TORQUE_OS_IOS_PROFILE
  455. iPhoneProfilerEnd("SERVER_PROC");
  456. #endif
  457. PROFILE_END();
  458. PROFILE_START(ServerNetProcess);
  459. // only send packets if a tick happened
  460. if(tickPass)
  461. GNet->processServer();
  462. PROFILE_END();
  463. PROFILE_START(SimAdvanceTime);
  464. #ifdef TORQUE_OS_IOS_PROFILE
  465. iPhoneProfilerStart("SIM_TIME");
  466. #endif
  467. Sim::advanceTime(elapsedTime);
  468. #ifdef TORQUE_OS_IOS_PROFILE
  469. iPhoneProfilerEnd("SIM_TIME");
  470. #endif
  471. PROFILE_END();
  472. PROFILE_START(ClientProcess);
  473. #ifdef TORQUE_OS_IOS_PROFILE
  474. iPhoneProfilerStart("CLIENT_PROC");
  475. #endif
  476. PROFILE_START(TickableAdvanceTime);
  477. Tickable::advanceTime(elapsedTime);
  478. PROFILE_END();
  479. // This is based on PW's stuff
  480. #ifndef NO_AUDIO_SUPPORT
  481. // Milliseconds between audio updates.
  482. const U32 AudioUpdatePeriod = 125;
  483. // alxUpdate is somewhat expensive and does not need to be updated constantly,
  484. // though it does need to be updated in real time
  485. static U32 lastAudioUpdate = 0;
  486. U32 realTime = Platform::getRealMilliseconds();
  487. if((realTime - lastAudioUpdate) >= AudioUpdatePeriod)
  488. {
  489. alxUpdate();
  490. lastAudioUpdate = realTime;
  491. }
  492. #endif
  493. #ifdef TORQUE_OS_IOS_PROFILE
  494. iPhoneProfilerEnd("CLIENT_PROC");
  495. #endif
  496. PROFILE_END();
  497. PROFILE_START(ClientNetProcess);
  498. GNet->processClient();
  499. PROFILE_END();
  500. if(Canvas && TextureManager::mDGLRender)
  501. {
  502. #ifdef TORQUE_OS_IOS_PROFILE
  503. iPhoneProfilerStart("GL_RENDER");
  504. #endif
  505. bool preRenderOnly = false;
  506. if(gFrameSkip && gFrameCount % gFrameSkip)
  507. preRenderOnly = true;
  508. PROFILE_START(RenderFrame);
  509. Canvas->renderFrame(preRenderOnly);
  510. PROFILE_END();
  511. gFrameCount++;
  512. #ifdef TORQUE_OS_IOS_PROFILE
  513. iPhoneProfilerEnd("GL_RENDER");
  514. #endif
  515. }
  516. GNet->checkTimeouts();
  517. #ifdef TORQUE_ALLOW_MUSICPLAYER
  518. updateVolume();
  519. #endif
  520. PROFILE_END();
  521. }
  522. //--------------------------------------------------------------------------
  523. void DefaultGame::processInputEvent(InputEvent *event)
  524. {
  525. PROFILE_START(ProcessInputEvent);
  526. // [neo, 5/24/2007 - #2986]
  527. // Swapped around the order of call for global action map and canvas input
  528. // handling to give canvas first go as GlobalActionMap will eat any input
  529. // events meant for firstResponders only and as a "general" trap should really
  530. // should only be called if any "local" traps did not take it, e.g. left/right
  531. // in a text edit control should not be forwarded if the text edit has focus, etc.
  532. // Any new issues regarding input should most probably start looking here first!
  533. if(!(Canvas && Canvas->processInputEvent(event)))
  534. {
  535. if(!ActionMap::handleEventGlobal(event))
  536. {
  537. // Other input consumers here...
  538. ActionMap::handleEvent(event);
  539. }
  540. }
  541. PROFILE_END();
  542. }
  543. //-----------------------------------------------------------------------------
  544. void DefaultGame::processMouseMoveEvent(MouseMoveEvent * mEvent)
  545. {
  546. if (Canvas)
  547. Canvas->processMouseMoveEvent(mEvent);
  548. }
  549. //--------------------------------------------------------------------------
  550. void DefaultGame::processScreenTouchEvent(ScreenTouchEvent * mEvent)
  551. {
  552. if (Canvas)
  553. Canvas->processScreenTouchEvent(mEvent);
  554. }
  555. //--------------------------------------------------------------------------
  556. void DefaultGame::processConsoleEvent(ConsoleEvent *event)
  557. {
  558. char *argv[2];
  559. argv[0] = (char*)"eval";
  560. argv[1] = event->data;
  561. Sim::postCurrentEvent(Sim::getRootGroup(), new SimConsoleEvent(2, const_cast<const char**>(argv), false));
  562. }
  563. //--------------------------------------------------------------------------
  564. void DefaultGame::processPacketReceiveEvent(PacketReceiveEvent * prEvent)
  565. {
  566. GNet->processPacketReceiveEvent(prEvent);
  567. }