GameEngine.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. /**
  5. *
  6. * Interface for platform dependent game-engine
  7. *
  8. *
  9. */
  10. #ifndef __NOKIAGAME_ENGINE__
  11. #define __NOKIAGAME_ENGINE__
  12. #ifdef IAP
  13. #include "../epong_iap_impl/miniiapclientapi.h"
  14. #endif
  15. namespace GF {
  16. enum ENGINE_EVENT_TYPE {
  17. HAPTIC_FEEDBACK, // engine should privide haptic click
  18. VIRTUAL_KEYBOARD, // vkb show (flags=1) or hide(flags=0)
  19. EXIT // exit
  20. };
  21. class GameEngine {
  22. public:
  23. GameEngine();
  24. virtual ~GameEngine();
  25. /**
  26. * Exit game engine. Shuts down everything and returns to OS.
  27. */
  28. virtual void exit() {};
  29. /**
  30. * Start audio engine using given format. Audio engine starts calling game's pullAudio method.
  31. */
  32. virtual bool startAudio( int frequency, int channels );
  33. /**
  34. * Stop audio engine.
  35. */
  36. virtual void stopAudio();
  37. // TODO is this necessary, can't the sensors be always active when engine is enabled,
  38. // it does not use much power anyway?
  39. /**
  40. * Start sensors.
  41. */
  42. virtual bool startSensors();
  43. /**
  44. * Stop sensors.
  45. */
  46. virtual void stopSensors();
  47. /**
  48. * Display text-query dialog and return the user's input to requester
  49. * @param prompt optional prompt
  50. * @param target buffer to hold user input
  51. * @param targetLength max length of user input buffer
  52. * return false if no text was aquired.
  53. */
  54. virtual bool queryTextInput( const char *prompt, char *target, int targetLength ) { return false; }
  55. // Helpers
  56. // TODO rename to loadTexture
  57. virtual int loadGLTexture( const char *fileName );
  58. virtual void releaseTexture(int textureHandle);
  59. /**
  60. *
  61. * Load a file, read it to memory and return it's content and length.
  62. * The user is responsible for releasing the memory.
  63. *
  64. */
  65. virtual void* loadBinaryResource( const char *fileName, int &sizeTarget ) { return 0; }
  66. virtual void releaseBinaryResource( void *resource ) {}
  67. virtual void sendEvent(ENGINE_EVENT_TYPE type, int flags) = 0;
  68. virtual int openUrlInBrowser(const char *path8) { return 0; };
  69. // TODO should this be replaced with just setting proper working directory, like on Symbian?
  70. // InputPaths which start with "configdata:" are supposed to be adjusted to be
  71. // in a system-wide configuration place for this application.
  72. virtual const char *adjustPath(const char *inputPath, char *outputPath, int outputPathLength, bool *isOk = 0);
  73. // TODO lose this, replace with sendEvent if this is really necessary
  74. virtual void setUpdateAndPauseState(bool updatesDisabled, bool pauseResumeDisabled);
  75. #ifdef IAP
  76. // TODO IAP should probably be instantiated by PongApp, not passed from engine
  77. // gets (and if not existing, creates) "global" MiniIAPClient.
  78. virtual MiniIAPClientApi *getMiniIAPClient() = 0;
  79. #endif
  80. #ifdef MY_OS_MEEGO
  81. // TODO lose this, replace with GameApp:notifyEvent
  82. virtual bool isSwipeEnabled();
  83. #endif
  84. protected:
  85. };
  86. };
  87. #endif