/* * The following function checks which buttons where pressed and changes * between mono and sterio sound playback - by registering/unregistering * AudioCallback() as the S3E_CHANNEL_GEN_AUDIO_STEREO function - or * cycles through left/right/both stereo channels. */ bool ExampleUpdate() { //you must update sound manager soundManager->update(); Button* pressed = GetSelectedButton(); if(pressed == bPlaySmall) { char buf[50]; sprintf(buf, "%i", rand()); soundManager->play(buf, "test3.ogg"); } else if(pressed == bPlay1) { soundManager->play("test1", "test1.ogg"); } else if(pressed == bPlay2) { soundManager->play("test2", "test2.ogg"); } else if(pressed == bStop1) { soundManager->stop("test1"); } else if(pressed == bStop2) { soundManager->stop("test2"); } return true; }
bool ExampleUpdate() { Button* pressed = GetSelectedButton(); if (pressed == g_ButtonHidebarSticky) { s3eAndroidFullscreenOn(); } if (pressed == g_ButtonHideBarNonSticky) { s3eAndroidFullscreenOn(S3E_TRUE, S3E_FALSE); } if (pressed == g_ButtonHideBarNonImmersive) { s3eAndroidFullscreenOn(S3E_FALSE); } if (pressed == g_ButtonShow) { s3eAndroidFullscreenOff(); } if (pressed == g_ButtonShowBars) { s3eAndroidFullscreenOff(S3E_TRUE); } if (pressed == g_ButtonCheck) { s3eDialogAlertInfo alert; alert.m_Title = "Android Fullscreen Support"; if (s3eAndroidFullscreenAvailable()) { if (s3eAndroidFullscreenIsImmersiveSupported()) alert.m_Message = "fully supported"; else alert.m_Message = "only non-immersive mode is supported"; } else alert.m_Message = "not supported at all"; s3eDialogAlertBox(&alert); // Tip: try showing the s3eDialog when in fullscreen mode... // a good example of a situation where you would need to manually // re-call s3eAndroidFullscreenOn()! } return true; }
bool ExampleUpdate() { g_ShowAdButton->m_Enabled = !Presage::AdInFligt() && Presage::IsAvailable(); Button* pressed = GetSelectedButton(); if (pressed == g_ShowAdButton&& Presage::IsAvailable()) { if (Presage::AdInFligt()) { IwTrace(PRESAGE, ("Ad already in flight")); } else { Presage::adToServe(AdNotFound, AdFound, AdClosed, AdError, AdDisplayed, NULL); } } return true; }
bool ExampleUpdate() { Button* pressed = GetSelectedButton(); if (pressed && pressed == g_MessageBox) s3eNewMessageBox("Title", "Hello world"); else if (pressed && pressed == g_NOFInitialize) { s3eNOFSettingVal *settings = (s3eNOFSettingVal*)s3eMalloc(sizeof(s3eNOFSettingVal) * 7); // Fill settings // UIOrientation value strncpy(settings[0].m_varName, "OpenFeintSettingDashboardOrientation", S3E_NOPENFEINT_SETTINGS_STRING_MAX); settings[0].m_intVal = s3eNOFUIInterfaceOrientationPortrait; // Shortdisplay name strncpy(settings[1].m_varName, "OpenFeintSettingShortDisplayName", S3E_NOPENFEINT_SETTINGS_STRING_MAX); strncpy(settings[1].m_stringVal, "FunkyRacers", S3E_NOPENFEINT_STRING_MAX); // Push Notification Setting strncpy(settings[2].m_varName, "OpenFeintSettingEnablePushNotifications", S3E_NOPENFEINT_SETTINGS_STRING_MAX); settings[2].m_intVal = 1; // TRUE/YES // Sandbox Notification Mode strncpy(settings[3].m_varName, "OpenFeintSettingUseSandboxPushNotificationServer", S3E_NOPENFEINT_SETTINGS_STRING_MAX); settings[3].m_intVal = 1; // Disable User generated content strncpy(settings[4].m_varName, "OpenFeintSettingDisableUserGeneratedContent", S3E_NOPENFEINT_SETTINGS_STRING_MAX); settings[4].m_intVal = 0; // Disable ask for approval in debug mode strncpy(settings[5].m_varName, "OpenFeintSettingAlwaysAskForApprovalInDebug", S3E_NOPENFEINT_SETTINGS_STRING_MAX); settings[5].m_intVal = 0; // Add GameId in settings as well as Android needs it strncpy(settings[1].m_varName, "GameID", S3E_NOPENFEINT_SETTINGS_STRING_MAX); strncpy(settings[1].m_stringVal, "330603", S3E_NOPENFEINT_STRING_MAX); s3eNOFArray array; array.m_count = 7; array.m_items = settings; s3eNOFinitializeWithProductKey("TD5741bq5dsEWStKk3rdMA", "HgjtDJBBRW8sBfASq9Iv6hDAfchXAHMYJvNU5gQ0", "RacingGame", &array); s3eFree(settings); AppendMessageColour(GREEN, "Called s3eNOFinitializeWithProductKey"); //g_doRender1 = false; // Lets try to give the API the token // const char* deviceToken = s3eIOSNotificationsGetRemoteNotificationToken(); // char tmp[40]; // const char *tmp1 = deviceToken; // memset(tmp,'\0', sizeof(tmp)); // // // need to get rid of spaces in middle // int i =0; // while(*tmp1) // { // if(*tmp1!=' ') // { // // not a space. we can copy // tmp[i] = *tmp1; // i++; // } // tmp1++; // } // // if (deviceToken) { // AppendMessageColour(BLUE,"Device token is %s",tmp); // s3eNOFapplicationDidRegisterForRemoteNotificationsWithDeviceToke(tmp); // } } else if (pressed && pressed == g_NOFShutdown) { s3eNOFshutdown(); AppendMessageColour(GREEN, "Called s3eNOFshutdown"); } else if (pressed && pressed == g_NOFLaunchDashboard) { // s3eNOFlaunchDashboard(); s3eNOFlaunchDashboard(); AppendMessageColour(GREEN, "Called s3eNOFlaunchDashboardWithListLeaderboardsPage"); } else if (pressed && pressed == g_NOFTestButton1) { /*const unsigned int max_achievements = 20; // whatever we think is max we need void* data = s3eMalloc(sizeof(s3eNOFAchievement) * max_achievements); if (data == NULL) { AppendMessageColour(RED, ("Couldn't allocate data")); return false; } s3eNOFArray achArray; achArray.m_items = data; achArray.m_count = max_achievements; s3eNOFachievements(&achArray); // AppendMessage("Size of achievement %d and double %d", // sizeof(s3eNOFAchievement), // sizeof(double)); for (uint i=0; i < achArray.m_count && i < max_achievements; i++) { // s3eNOFAchievement* ach = &((s3eNOFAchievement*)achArray.m_items[i]); // AppendMessage("Ach at %p", &((s3eNOFAchievement*)achArray.m_items)[i]); AppendMessage("Acheivement title %s", ((s3eNOFAchievement*)achArray.m_items)[i].title); } s3eFree(data);*/ //AppendMessage("Updating achievement 1205572"); // s3eNOFupdateAcheivementProgressionComplete("1205572", "77", true); // last param is ignored for android s3eNOFlaunchDashboardWithListLeaderboardsPage(); } else if (pressed && pressed == g_NOFTestButton2) { //s3eNOFdisplayAndSendChallenge(&g_nofChallengeDefinitions[1]); /* s3eNOFchallengeCompleteWithResult(kNOFChallengeResultRecipientLost, persistentChallengeId); AppendMessageColour(GREEN, "Called s3eNOFchallengeCompleteWithResult"); s3eNOFChallengeData chalData; const char *dd = "SCORE=5"; chalData.data = (void*)dd; chalData.length = strlen(dd); s3eNOFchallengeDisplayCompletionWithData(&chalData, "Challenge Lost", persistentChallengeId); AppendMessageColour(GREEN, "Called s3eNOFchallengeDisplayCompletionWithData"); */ /* s3eNOFAchievement *ach = (s3eNOFAchievement*)s3eMalloc(sizeof(s3eNOFAchievement)); AppendMessageColour(GREEN,"Calling s3eNOFachievement"); s3eNOFachievement(ach, "1117662"); AppendMessage("Achievement title %s", ach->title); // AppendMessage("Achievement description %s", ach->description); s3eFree(ach); */ //AppendMessage("Unlocking achievement 1117662"); // s3eNOFachievementUnlock("1117662"); // AppendMessage("User approved %d", s3eNOFhasUserApprovedFeint()); // AppendMessage("User is Online %d", s3eNOFisOnline()); // s3eNOFsubmitHighScore("844216", "50", "Beaten by Android", NULL); s3eNOFlaunchDashboardWithHighscorePage("844216"); } return true; }
bool ExampleUpdate() { Button* pressed = GetSelectedButton(); if (!pressed) { return true; } if (pressed == g_ButtonLogEvent) { char EventName[MAX_CHAR_SIZE]; // Event Name: Key used to recognise event strcpy(EventName, s3eOSReadStringUTF8("Enter Event Name:", 0)); s3eFlurryLogEvent(EventName, false); AppendMessageColour(GREEN, "Non Timed Event Logged"); } else if (pressed == g_ButtonLogTimedEvent) { char EventName[MAX_CHAR_SIZE]; // Event Name: Key used to recognise event strcpy(EventName, s3eOSReadStringUTF8("Enter Event Name:", 0)); s3eFlurryLogEvent(EventName, true); AppendMessageColour(GREEN, "Timed Event Logged"); } else if (pressed == g_ButtonEndTimedEvent) { char EventName[MAX_CHAR_SIZE]; // Event Name: Key used to recognise event strcpy(EventName, s3eOSReadStringUTF8("Enter Event Name:", 0)); s3eFlurryEndTimedEvent(EventName); } else if (pressed == g_ButtonLogError) { char Error[MAX_CHAR_SIZE]; char Message[MAX_CHAR_SIZE]; // Error ID: ID you can use to recognise this error strcpy(Error, s3eOSReadStringUTF8("Enter Error ID:", 0)); // Error Message: Message describing the error strcpy(Message, s3eOSReadStringUTF8("Error Message:", 0)); s3eFlurryLogError(Error, Message); } else if (pressed == g_ButtonUserInfo) { char userID[MAX_CHAR_SIZE]; // User ID: Set an ID that can be used to recognise this user strcpy(userID, s3eOSReadStringUTF8("Enter User ID:", 0)); s3eFlurrySetUserID(userID); char userAge[MAX_CHAR_SIZE]; // User Age: Set the user's age strcpy(userAge, s3eOSReadStringUTF8("Enter User Age:", S3E_OSREADSTRING_FLAG_NUMBER)); uint8 age = atoi(userAge); s3eFlurrySetUserAge(age); char userGender[MAX_CHAR_SIZE]; // User Gender: Set the user's gender strcpy(userGender, s3eOSReadStringUTF8("Enter User Gender\n\"M\" or \"F\"", 0)); if(!strcmp(userGender,"m") || !strcmp(userGender,"M")) { s3eFlurrySetUserGender(S3E_FLURRY_MALE); AppendMessageColour(GREEN, "Logged User Gender: Male"); } else if(!strcmp(userGender,"f") || !strcmp(userGender,"F")) { s3eFlurrySetUserGender(S3E_FLURRY_FEMALE); AppendMessageColour(GREEN, "Logged User Gender: Female"); } else AppendMessageColour(RED, "Gender given not valid"); AppendMessageColour(GREEN, "Logged User age: %i", age); AppendMessageColour(GREEN, "Logged User ID: %s", userID); } else if (pressed == g_ButtonUserLocation) { //g_Error = s3eLocationGet(&g_Location); if(g_Error == S3E_RESULT_ERROR) AppendMessageColour(RED, "Could not determine location"); else { // s3eFlurrySetLocation(&g_Location); AppendMessageColour(GREEN, "Logged user location"); } } else if (pressed == g_ButtonToggleSendOnClose) { bSendSessionReportOnClose = !bSendSessionReportOnClose; s3eFlurrySetSessionReportOnClose(bSendSessionReportOnClose); if(bSendSessionReportOnClose) { AppendMessageColour(GREEN, "Session report send on close: Enabled"); g_ButtonToggleSendOnClose->m_Name = (char*)"Disable send session report on close"; } else { AppendMessageColour(GREEN, "Session report send on close: Disabled"); g_ButtonToggleSendOnClose->m_Name = (char*)"Enable send session report on close"; } } else if (pressed == g_ButtonToggleSendOnPause) { bSendSessionReportOnPause = !bSendSessionReportOnPause; s3eFlurrySetSessionReportOnPause(bSendSessionReportOnPause); if(bSendSessionReportOnPause) { AppendMessageColour(GREEN, "Session report send on pause: Enabled"); g_ButtonToggleSendOnPause->m_Name = (char*)"Disable send session report on pause"; } else { AppendMessageColour(GREEN, "Session report send on pause: Disabled"); g_ButtonToggleSendOnPause->m_Name = (char*)"Enable send session report on pause"; } } else if (pressed == g_ButtonSetDefaultMessage) { char message[MAX_CHAR_SIZE]; // User Gender: Set the user's gender strcpy(message, s3eOSReadStringUTF8("Enter a default message to be shown in the event no banner is available",0)); s3eFlurrySetDefaultText(message); } else if (pressed == g_ButtonToggleAdBanner) { bShowBanner = !bShowBanner; s3eFlurryShowAdBanner(bShowBanner); if(bShowBanner) AppendMessageColour(GREEN, "Ad Banner: Enabled"); else AppendMessageColour(GREEN, "Ad Banner: Disabled"); } else if (pressed == g_ButtonShowOfferWall) { s3eFlurryShowOfferWall(); } return true; }