daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * This file is part of the s3eAdWhirl Marmalade extension
  3.  *
  4.  * Copyright (C) 2001-2011 Agop Shirinian
  5.  *
  6.  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  7.  * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  8.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  9.  * PARTICULAR PURPOSE.
  10.  */
  11.  
  12. #include "ExamplesMain.h"
  13.  
  14. #include "s3eAdWhirl.h"
  15.  
  16. static const char* g_LastMessage = NULL;
  17.  
  18. static Button* g_ButtonShow = NULL;
  19. static Button* g_ButtonHide = NULL;
  20. static Button* g_ButtonRefresh = NULL;
  21.  
  22. static bool g_AdShowing = true;
  23.  
  24. int32 adLoad(void* system, void* user)
  25. {
  26.     g_LastMessage = "`x666666Ad loaded";
  27.     return 0;
  28. }
  29.  
  30. int32 adFail(void* system, void* user)
  31. {
  32.     g_LastMessage = "`x666666Ad failed";
  33.     return 0;
  34. }
  35.  
  36. int32 adFullscreenBegin(void* system, void* user)
  37. {
  38.     g_LastMessage = "`x666666Fullscreen ad began";
  39.     return 0;
  40. }
  41.  
  42. int32 adFullscreenEnd(void* system, void* user)
  43. {
  44.     g_LastMessage = "`x666666Fullscreen ad ended";
  45.     return 0;
  46. }
  47.  
  48. void ExampleInit()
  49. {
  50.     g_ButtonShow = NewButton("Show Banner");
  51.     g_ButtonHide = NewButton("Hide Banner");
  52.     g_ButtonRefresh = NewButton("Refresh Banner");
  53.  
  54.     // initialise s3eAdWhirl
  55.     s3eDeviceOSID osid = (s3eDeviceOSID)s3eDeviceGetInt(S3E_DEVICE_OS);
  56.     if (osid == S3E_OS_ID_IPHONE)
  57.     {
  58.         // this ID is specifically made for testing s3eAdWhirl
  59.         // make sure you change this ID to your iPhone app AdWhirl ID when building your own app
  60.         s3eAdWhirlStart("c9791d39bd5b4157b2d3f7912d345c52");
  61.     }
  62.     else if (osid == S3E_OS_ID_ANDROID)
  63.     {
  64.         // this ID is specifically made for testing s3eAdWhirl
  65.         // make sure you change this ID to your Android app AdWhirl ID when building your own app
  66.         s3eAdWhirlStart("c705a7e8711b4aafb845d18d390976b0");
  67.     }
  68.     else
  69.     {
  70.     }
  71.  
  72.     s3eAdWhirlRegister(S3E_ADWHIRL_CALLBACK_AD_LOAD, &adLoad, NULL);
  73.     s3eAdWhirlRegister(S3E_ADWHIRL_CALLBACK_AD_FAIL, &adFail, NULL);
  74.     s3eAdWhirlRegister(S3E_ADWHIRL_CALLBACK_FULLSCREEN_BEGIN, &adFullscreenBegin, NULL);
  75.     s3eAdWhirlRegister(S3E_ADWHIRL_CALLBACK_FULLSCREEN_END, &adFullscreenEnd, NULL);
  76. }
  77.  
  78. void ExampleTerm()
  79. {
  80. }
  81.  
  82. bool ExampleUpdate()
  83. {
  84.     if (!s3eAdWhirlAvailable())
  85.         return true;
  86.  
  87.     g_ButtonShow->m_Enabled = !g_AdShowing;
  88.     g_ButtonHide->m_Enabled = g_AdShowing;
  89.  
  90.     Button* pressed = GetSelectedButton();
  91.     if (pressed == g_ButtonHide)
  92.     {
  93.         s3eAdWhirlHide();
  94.         g_AdShowing = false;
  95.     }
  96.     else if (pressed == g_ButtonShow)
  97.     {
  98.         s3eAdWhirlShow();
  99.         g_AdShowing = true;
  100.     }
  101.     else if (pressed == g_ButtonRefresh)
  102.     {
  103.         s3eAdWhirlRequestFreshAd();
  104.     }
  105.  
  106.     return true;
  107. }
  108.  
  109. void ExampleRender()
  110. {
  111.     if (!s3eAdWhirlAvailable())
  112.     {
  113.         s3eDebugPrint(50, 100, "`xff0000s3eAdWhirl extension not found.", 1);
  114.         return;
  115.     }
  116.  
  117.     int lineHeight = s3eDebugGetInt(S3E_DEBUG_FONT_HEIGHT);
  118.     lineHeight = lineHeight * 2; // add some padding to the text height
  119.  
  120.     int y = GetYBelowButtons();
  121.  
  122.     s3eDebugPrintf(10, y, true, "`x666666Hello AdWhirl");
  123.     y += lineHeight;
  124.  
  125.     if (g_AdShowing)
  126.     {
  127.         s3eDebugPrintf(10, y, true, "`x666666Ad is visible");
  128.         y += lineHeight;
  129.     }
  130.     else
  131.     {
  132.         s3eDebugPrintf(10, y, true, "`x666666Ad is hidden");
  133.         y += lineHeight;
  134.     }
  135.  
  136.     if (g_LastMessage != NULL)
  137.     {
  138.         s3eDebugPrintf(10, y, true, g_LastMessage);
  139.         y += lineHeight;
  140.     }
  141. }
RAW Paste Data
Top