Advertisement.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /******************************************************************************
  2. Use 'AdMob' or 'Chartboost' to display ads in your application (for Android and iOS).
  3. Usage of 'Chartboost' requires specifying following elements in the Application properties:
  4. -Chartboost App ID
  5. -Chartboost App Signature
  6. /******************************************************************************/
  7. struct AdMobClass
  8. {
  9. #if EE_PRIVATE
  10. // !! these enums must be equal to "EsenthelActivity.java" !!
  11. #endif
  12. enum BANNER_TYPE : Byte
  13. { // Size | Description | Availability
  14. BANNER , // 320x50 , Standard Banner , Phones and Tablets
  15. MEDIUM_RECTANGLE, // 300x250, IAB Medium Rectangle, Tablets
  16. FULL_BANNER , // 468x60 , IAB Full-Size Banner, Tablets
  17. LEADERBOARD , // 728x90 , IAB Leaderboard , Tablets
  18. SMART_BANNER , // Varies , Smart Banner , Phones and Tablets, https://firebase.google.com/docs/admob/android/banner#smart_banners
  19. #if EE_PRIVATE
  20. INTERSTITIAL , // Fullscreen, Interstitial , Phones and Tablets, https://firebase.google.com/docs/admob/android/interstitial
  21. #endif
  22. };
  23. enum STATE : Byte
  24. {
  25. NONE , // ad was not yet requested by the user
  26. LOADING, // ad is currently being loaded
  27. DONE , // ad is available
  28. ERROR , // ad failed to load
  29. };
  30. AdMobClass& testMode(Bool on=true); // 'on'=if enable test mode, which means that you will receive test ads instead of real ones, and won't risk being banned from AdMob for accidental clicking on them
  31. // banner ad
  32. STATE bannerState ( )C {return _banner_state;} // get state of banner ad
  33. AdMobClass& bannerDel ( ); // delete a banner ad
  34. AdMobClass& bannerCreate (C Str8 &unit_id, BANNER_TYPE type=BANNER); // create a banner ad, 'type'=type of the banner, 'unit_id'=ID of the ad (obtained when creating a new ad on the AdMob https://apps.admob.com/ website)
  35. AdMobClass& bannerShow ( ); // show the banner ad, if the ad is not yet loaded, then it will be automatically shown once it gets loaded
  36. AdMobClass& bannerHide ( ); // hide the banner ad
  37. AdMobClass& bannerVisible(Bool visible ); // set banner ad visibility
  38. AdMobClass& bannerPos (Int x, Int y ); // set banner ad position, x=-1..1 (-1=left, 0=center, 1=right), y=-1..1 (-1=bottom, 0=center, 1=top), default=(0, 1)
  39. C VecI2 & bannerPos ()C {return _banner_pos ;} // get banner ad position, x=-1..1 (-1=left, 0=center, 1=right), y=-1..1 (-1=bottom, 0=center, 1=top), default=(0, 1)
  40. C VecI2 & bannerSizePx ()C {return _banner_size;} // get banner ad size in pixels, this becomes valid once banner has finished loading (DONE state)
  41. // fullscreen ad (aka interstitial ad)
  42. STATE fsState ( )C {return _fs_state;} // get state of fullscreen ad
  43. AdMobClass& fsDel ( ); // delete a fullscreen ad
  44. AdMobClass& fsCreate(C Str8 &unit_id); // create a fullscreen ad, 'unit_id'=ID of the ad (obtained when creating a new ad on the AdMob https://apps.admob.com/ website)
  45. AdMobClass& fsShow ( ); // show the fullscreen ad, if the ad is not yet loaded, then it will be automatically shown once it gets loaded
  46. #if EE_PRIVATE
  47. AdMobClass& fsHide ( ); // hide the fullscreen ad
  48. AdMobClass& fsVisible(Bool visible); // set fullscreen ad visibility
  49. #endif
  50. #if !EE_PRIVATE
  51. private:
  52. #endif
  53. STATE _banner_state, _fs_state;
  54. VecI2 _banner_pos, _banner_size;
  55. ~AdMobClass();
  56. AdMobClass();
  57. }extern
  58. AdMob;
  59. /******************************************************************************/
  60. struct ChartboostClass
  61. {
  62. #if EE_PRIVATE
  63. // !! these enums must be equal to "EsenthelActivity.java" !!
  64. #endif
  65. enum RESULT
  66. {
  67. INTERSTITIAL_LOADED , // called when an interstitial has been loaded from the Chartboost API servers and cached locally
  68. INTERSTITIAL_LOAD_FAIL, // called when an interstitial has attempted to load from the Chartboost API servers but failed
  69. INTERSTITIAL_DISPLAYED, // called when an interstitial has been displayed on the screen
  70. INTERSTITIAL_CLOSED , // called when an interstitial has been closed
  71. INTERSTITIAL_CLICKED , // called when an interstitial has been clicked
  72. REWARDED_VIDEO_LOADED , // called when a rewarded video has been loaded from the Chartboost API servers and cached locally
  73. REWARDED_VIDEO_LOAD_FAIL, // called when a rewarded video has attempted to load from the Chartboost API servers but failed
  74. REWARDED_VIDEO_DISPLAYED, // called when a rewarded video has been displayed on the screen
  75. REWARDED_VIDEO_CLOSED , // called when a rewarded video has been closed
  76. REWARDED_VIDEO_COMPLETED, // called when a rewarded video has been viewed completely and user is eligible for reward
  77. REWARDED_VIDEO_CLICKED , // called when a rewarded video has been clicked
  78. };
  79. void (*callback)(RESULT result); // pointer to a custom function that will be called with processed events, 'result'=message received at the moment
  80. Bool visible()C; // check if there are any ads currently visible on the screen
  81. ChartboostClass& interstitialLoad ();
  82. ChartboostClass& interstitialShow ();
  83. Bool interstitialAvailable()C;
  84. ChartboostClass& rewardedVideoLoad ();
  85. ChartboostClass& rewardedVideoShow ();
  86. Bool rewardedVideoAvailable()C;
  87. #if !EE_PRIVATE
  88. private:
  89. #endif
  90. ~ChartboostClass();
  91. ChartboostClass();
  92. }extern
  93. Chartboost;
  94. /******************************************************************************/