Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * This file is part of the s3eAdWhirl Marmalade extension
- *
- * Copyright (C) 2001-2011 Agop Shirinian
- *
- * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
- * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
- * PARTICULAR PURPOSE.
- */
- #include "ExamplesMain.h"
- #include "s3eAdWhirl.h"
- static const char* g_LastMessage = NULL;
- static Button* g_ButtonShow = NULL;
- static Button* g_ButtonHide = NULL;
- static Button* g_ButtonRefresh = NULL;
- static bool g_AdShowing = true;
- int32 adLoad(void* system, void* user)
- {
- g_LastMessage = "`x666666Ad loaded";
- return 0;
- }
- int32 adFail(void* system, void* user)
- {
- g_LastMessage = "`x666666Ad failed";
- return 0;
- }
- int32 adFullscreenBegin(void* system, void* user)
- {
- g_LastMessage = "`x666666Fullscreen ad began";
- return 0;
- }
- int32 adFullscreenEnd(void* system, void* user)
- {
- g_LastMessage = "`x666666Fullscreen ad ended";
- return 0;
- }
- void ExampleInit()
- {
- g_ButtonShow = NewButton("Show Banner");
- g_ButtonHide = NewButton("Hide Banner");
- g_ButtonRefresh = NewButton("Refresh Banner");
- // initialise s3eAdWhirl
- s3eDeviceOSID osid = (s3eDeviceOSID)s3eDeviceGetInt(S3E_DEVICE_OS);
- if (osid == S3E_OS_ID_IPHONE)
- {
- // this ID is specifically made for testing s3eAdWhirl
- // make sure you change this ID to your iPhone app AdWhirl ID when building your own app
- s3eAdWhirlStart("c9791d39bd5b4157b2d3f7912d345c52");
- }
- else if (osid == S3E_OS_ID_ANDROID)
- {
- // this ID is specifically made for testing s3eAdWhirl
- // make sure you change this ID to your Android app AdWhirl ID when building your own app
- s3eAdWhirlStart("c705a7e8711b4aafb845d18d390976b0");
- }
- else
- {
- }
- s3eAdWhirlRegister(S3E_ADWHIRL_CALLBACK_AD_LOAD, &adLoad, NULL);
- s3eAdWhirlRegister(S3E_ADWHIRL_CALLBACK_AD_FAIL, &adFail, NULL);
- s3eAdWhirlRegister(S3E_ADWHIRL_CALLBACK_FULLSCREEN_BEGIN, &adFullscreenBegin, NULL);
- s3eAdWhirlRegister(S3E_ADWHIRL_CALLBACK_FULLSCREEN_END, &adFullscreenEnd, NULL);
- }
- void ExampleTerm()
- {
- }
- bool ExampleUpdate()
- {
- if (!s3eAdWhirlAvailable())
- return true;
- g_ButtonShow->m_Enabled = !g_AdShowing;
- g_ButtonHide->m_Enabled = g_AdShowing;
- Button* pressed = GetSelectedButton();
- if (pressed == g_ButtonHide)
- {
- s3eAdWhirlHide();
- g_AdShowing = false;
- }
- else if (pressed == g_ButtonShow)
- {
- s3eAdWhirlShow();
- g_AdShowing = true;
- }
- else if (pressed == g_ButtonRefresh)
- {
- s3eAdWhirlRequestFreshAd();
- }
- return true;
- }
- void ExampleRender()
- {
- if (!s3eAdWhirlAvailable())
- {
- s3eDebugPrint(50, 100, "`xff0000s3eAdWhirl extension not found.", 1);
- return;
- }
- int lineHeight = s3eDebugGetInt(S3E_DEBUG_FONT_HEIGHT);
- lineHeight = lineHeight * 2; // add some padding to the text height
- int y = GetYBelowButtons();
- s3eDebugPrintf(10, y, true, "`x666666Hello AdWhirl");
- y += lineHeight;
- if (g_AdShowing)
- {
- s3eDebugPrintf(10, y, true, "`x666666Ad is visible");
- y += lineHeight;
- }
- else
- {
- s3eDebugPrintf(10, y, true, "`x666666Ad is hidden");
- y += lineHeight;
- }
- if (g_LastMessage != NULL)
- {
- s3eDebugPrintf(10, y, true, g_LastMessage);
- y += lineHeight;
- }
- }
Add Comment
Please, Sign In to add comment