void OnlineService::init() { //printf("online init\n"); fflush(stdout); SC_InitData_Init(&scoreloop_init_data); scoreloop_init_data.runLoopType = SC_RUN_LOOP_TYPE_CUSTOM; const char *scoreloop_language = strcmp(flags.language, "french") == 0 ? "fr" : strcmp(flags.language, "german") == 0 ? "de" : "en"; SC_Error_t newClientErrCode = SC_Client_New(&scoreloop_client, &scoreloop_init_data, scoreloop_gameid, scoreloop_game_secret, scoreloop_game_version, scoreloop_game_currency, scoreloop_language); if (!newClientErrCode == SC_OK) { //printf("online SC_Client_New failed with code %i\n", newClientErrCode); fflush(stdout); return; // handle error } SC_Error_t newUIClientErrCode = SCUI_Client_New(&scoreloop_ui_client, scoreloop_client); if (!newUIClientErrCode == SC_OK) { //printf("online SCUI_Client_New failed with code %i\n", newUIClientErrCode); return; // handle error } SCUI_Client_SetViewEventCallback(scoreloop_ui_client, OnViewEvent, this); }
void ScoreLoopThread::run() { qDebug() << "ScoreLoopThread run() started"; AppData_t app; SC_InitData_t initData; SC_Error_t rc; char versionBuffer[0x100]; /* Thats 256 bytes */ qDebug() << "Starting Scoreloop Sample..."; /* Initialize the BPS event system */ bps_initialize(); bps_set_verbosity(0); /* Set to 1 or 2 for more output if you like */ memset(&app, 0, sizeof(AppData_t)); /* Initialize the Scoreloop platform dependent SC_InitData_t structure to default values. */ SC_InitData_Init(&initData); /* What version of the Scoreloop library do we use? */ if (SC_GetVersionInfo(&initData, versionBuffer, sizeof(versionBuffer))) { qDebug() << "Version-Info: " << versionBuffer; } /* Now, create the Scoreloop Client with the initialized SC_InitData_t structure * as well as the game-id and game-secret as found on the developer portal. */ rc = SC_Client_New(&app.client, &initData, SCORELOOP_GAME_ID, SCORELOOP_GAME_SECRET, SCORELOOP_GAME_VERSION, SCORELOOP_GAME_CURRENCY, SCORELOOP_GAME_LANGUAGE); if (rc != SC_OK) { HandleError(&app, rc); } else { //InformUser(&app, "Note", "Scoreloop Sample started..."); /* Request the user here just for demonstration purposes */ RequestUser(&app); } while (!m_quit) { /* Get next BPS event */ bps_event_t *event; bps_get_event(&event, -1); /* Scoreloop event handling */ if (bps_event_get_domain(event) == SC_GetBPSEventDomain(&initData)) { SC_HandleBPSEvent(&initData, event); } else if (bps_event_get_domain(event) == dialog_get_domain()) { dialog_destroy(dialog_event_get_dialog_instance(event)); app.dialog = 0; } /* Add more BPS event handling here... */ } /* Cleanup the Scoreloop client */ SC_Client_Release(app.client); /* Shutdown BPS */ bps_shutdown(); qDebug() << "SensorsThread run() finished."; }