Esempio n. 1
0
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;
}
Esempio n. 2
0
void ExampleInit()
{
#define NUM_MESSAGES 30
#define MESSAGE_LEN 80

    InitMessages(NUM_MESSAGES, MESSAGE_LEN);
    AppendMessageColour(GREEN, "Checking for extension");
    
    SetButtonScale(GetButtonScale()-1);
    g_MessageBox = NewButton("MessageBox");
    if (s3eNOpenFeintAvailable())
	{
		g_NOFInitialize = NewButton("OF Initialize");
		g_NOFShutdown = NewButton("OF Shutdown");
		g_NOFLaunchDashboard = NewButton("OF LaunchDashboard");
		g_NOFTestButton1 = NewButton("OF Test 1");
		g_NOFTestButton2 = NewButton("OF Test 2");
		

		// Register for callbacks
		AppendMessageColour(BLUE, "*************");
		AppendMessage("");
		AppendMessage("");
		AppendMessage("");
		AppendMessage("");
		AppendMessage("");
		AppendMessage("");
		AppendMessage("");
		AppendMessage("");
		AppendMessage("");
		AppendMessage("");
		AppendMessage("");
		AppendMessage("");		
		AppendMessage("");
		AppendMessage("");
		AppendMessageColour(GREEN, "Registering for callback");
		
		s3eNOpenFeintRegister(S3E_NOPENFEINT_CALLBACK_PLAYER_LOGGEDIN, &playerLoggedIn, NULL);
		s3eNOpenFeintRegister(S3E_NOPENFEINT_CALLBACK_DASHBOARD_DID_APPEAR, &dashBoardAppeared, NULL);
		s3eNOpenFeintRegister(S3E_NOPENFEINT_CALLBACK_DID_DOWNLOAD_ALL_CHALLENGE_DEFINITIONS,
							  &didDownloadAllChallengeDefinitions,
							  NULL);
		s3eNOpenFeintRegister(S3E_NOPENFEINT_CALLBACK_DID_FAIL_DOWNLOAD_CHALLENGE_DEFINITIONS,
							  &didFailDownloadChallengeDefinitions,
							  NULL);
		s3eNOpenFeintRegister(S3E_NOPENFEINT_CALLBACK_USER_LAUNCHED_CHALLENGE,
							  &userLaunchedChallenge,
							  NULL);
    
    s3eNOpenFeintRegister(S3E_NOPENFEINT_CALLBACK_IS_OPENFEINT_NOTIFICATION_ALLOWED,
                          &isOpenFeintNotificationAllowed,
                          NULL);
    
	}
    else
    {
        AppendMessageColour(RED,"Could not load s3eNOpenFeint extension");
      return;
    }
  
  if(s3eFacebookAvailable())
  {
    s3eFBInit("193667878484");
  }
  else
    AppendMessageColour(RED,"Could not load s3eFacebook extension");
//  if (!s3eIOSNotificationsAvailable())
//  {
//    AppendMessageColour(RED,"Extension Not Available");
//    return;
//  }
//  else {
//      // Register IOS Notification
//      //     s3eDeviceRegister(S3E_DEVICE_PUSH_NOTIFICATION, RemotePushNotificationRecieved, 0);
//           s3eIOSNotificationsRegister(S3E_IOSNOTIFICATIONS_REMOTE, RemotePushNotificationRecieved, NULL);
//
//      // s3eIOSNotificationsGetLaunchNotification();
//  }
//	g_is3eNGAvailable = NewButton("IsNGAvailable");
}
Esempio n. 3
0
//Example Main
void ExampleInit()
{
    InitMessages(10,60);

    g_ButtonLogEvent = NewButton("Log Event");
    g_ButtonLogTimedEvent = NewButton("Log Timed Event");
    g_ButtonEndTimedEvent = NewButton("End Timed Event");
    g_ButtonLogError = NewButton("Log Error");
    g_ButtonUserInfo = NewButton("Set User Info");
    g_ButtonUserLocation = NewButton("Log User Location");
    g_ButtonToggleSendOnClose = NewButton("Disable send session report on close");
    g_ButtonToggleSendOnPause = NewButton("Disable send session report on pause");

    g_ButtonSetDefaultMessage = NewButton("Set Default Banner Message");
    g_ButtonToggleAdBanner = NewButton("Toggle Ad Banner");
    g_ButtonShowOfferWall = NewButton("Display Offer Wall");

    g_ButtonLogEvent->m_Enabled = false;
    g_ButtonLogTimedEvent->m_Enabled = false;
    g_ButtonEndTimedEvent->m_Enabled = false;
    g_ButtonLogError->m_Enabled = false;
    g_ButtonUserInfo->m_Enabled = false;
    g_ButtonUserLocation->m_Enabled = false;
    g_ButtonToggleSendOnClose->m_Enabled = false;
    g_ButtonToggleSendOnPause->m_Enabled = false;

    g_ButtonSetDefaultMessage->m_Enabled = false;
    g_ButtonToggleAdBanner->m_Enabled = false;
    g_ButtonShowOfferWall->m_Enabled = false;

    if (!s3eFlurryAvailable())
    {
        AppendMessageColour(RED,"Extension Not Available");
        return;
    }

    // Enable AppCircle
    // We need to call this *before* calling s3eFlurryStart
    s3eFlurryAppCircleEnable();

    //iOS Applicaton Key
    if(s3eDeviceGetInt (S3E_DEVICE_OS) == S3E_OS_ID_IPHONE)
        s3eFlurryStart("DNWX7I7XZYYL9V1QAZFC");
    //Android Applicaton Key
    else if(s3eDeviceGetInt (S3E_DEVICE_OS) == S3E_OS_ID_ANDROID)
        s3eFlurryStart("HD4EZJ147ELQAT9H43KM");


    g_ButtonLogEvent->m_Enabled = true;
    g_ButtonLogTimedEvent->m_Enabled = true;
    g_ButtonEndTimedEvent->m_Enabled = true;
    g_ButtonLogError->m_Enabled = true;
    g_ButtonUserInfo->m_Enabled = true;
    g_ButtonUserLocation->m_Enabled = true;
    g_ButtonToggleSendOnClose->m_Enabled = true;
    g_ButtonToggleSendOnPause->m_Enabled = true;

    g_ButtonSetDefaultMessage->m_Enabled = true;
    g_ButtonToggleAdBanner->m_Enabled = true;
    g_ButtonShowOfferWall->m_Enabled = true;

    s3eLocationStart();
}
Esempio n. 4
0
static int32 isOpenFeintNotificationAllowed(void *systemData, void *userData) 
{
	AppendMessageColour(RED,"isOpenFeintNotificationAllowed called");
	return 0;
}
Esempio n. 5
0
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;
}