Exemple #1
0
void vs_input_tick(scene *scene) {
    vs_local *local = scene->userdata;
    ctrl_event *p1=NULL, *i;
    game_player *player1 = game_state_get_player(scene->gs, 0);
    controller_poll(player1->ctrl, &p1);
    i = p1;
    if (i) {
        do {
            if(i->type == EVENT_TYPE_ACTION) {
                if (i->event_data.action == ACT_ESC) {
                    if(dialog_is_visible(&local->too_pathetic_dialog)) {
                        dialog_event(&local->too_pathetic_dialog, i->event_data.action);
                    } else if(dialog_is_visible(&local->quit_dialog)) {
                        dialog_event(&local->quit_dialog, i->event_data.action);
                    } else if(vs_is_singleplayer(scene) && player1->sp_wins != 0) {
                        // there's an active singleplayer campaign, confirm quitting
                        dialog_show(&local->quit_dialog, 1);
                    } else {
                        game_state_set_next(scene->gs, SCENE_MELEE);
                    }
                } else {
                    vs_handle_action(scene, i->event_data.action);
                }
            } else if (i->type == EVENT_TYPE_CLOSE) {
                game_state_set_next(scene->gs, SCENE_MENU);
            }
        } while((i = i->next));
    }
    controller_free_chain(p1);
}
Exemple #2
0
void SystemToast(const char *text) {
	dialog_instance_t dialog = 0;
	dialog_create_toast(&dialog);
	dialog_set_toast_message_text(dialog, text);
	dialog_set_toast_position(dialog, DIALOG_POSITION_TOP_CENTER);
	dialog_show(dialog);
}
Exemple #3
0
	void show_loading(){
		if( loading_dialog ) {
			return;
		}
	
		if( dialog_create_alert(&loading_dialog) != BPS_SUCCESS ){
			return;
		}

		if( dialog_set_background_alpha(loading_dialog, 0.2) != BPS_SUCCESS ){
			return;
		}

		if( dialog_set_alert_message_text(loading_dialog, "..." ) != BPS_SUCCESS ){
			return;
		}

		if( dialog_set_position(loading_dialog, DIALOG_POSITION_MIDDLE_CENTER ) != BPS_SUCCESS ){
			return;
		}
		
		if (dialog_show(loading_dialog) != BPS_SUCCESS) {
			dialog_destroy(loading_dialog);
			loading_dialog = 0;
		}
	
	}
void SystemToast(const char *text) {
#ifdef BLACKBERRY10
	dialog_instance_t dialog = 0;
	dialog_create_toast(&dialog);
	dialog_set_toast_message_text(dialog, text);
	dialog_set_toast_position(dialog, DIALOG_POSITION_TOP_CENTER);
	dialog_show(dialog);
#else
	puts(text);
#endif
}
void ScoreLoopThread::DisplayDialog(AppData_t *app, const char* title, const char* message) {
	/* Close a former dialog - if any */
	if (app->dialog) {
		dialog_destroy(app->dialog);
		app->dialog = 0;
	}

	/* Open a new alert dialog here - you would probably want to do something more elaborate */
	dialog_create_alert(&app->dialog);
	dialog_set_title_text(app->dialog, title);
	dialog_set_alert_message_text(app->dialog, message);
	dialog_add_button(app->dialog, DIALOG_OK_LABEL, true, NULL, true);
	dialog_show(app->dialog);
}
void show_alert()
{

    if (dialog_create_alert(&alert_dialog) != BPS_SUCCESS) {
        fprintf(stderr, "Failed to create alert dialog.");
        return;
    }
    dialog_set_size(alert_dialog,DIALOG_SIZE_FULL);

	if (dialog_set_alert_message_text(alert_dialog,
			"Download our brand new application Compass: \n\nThis is the first magnetic compass written natively for the BlackBerry® PlayBook. It does not use GPS (no movement necessary to get a correct direction), instead the Magnetometer is used.Keep the PlayBook out of range of any metallic object, as this can interfere with the compass!\nTry it!\nFeatures:\n\n- Real magnetic compass (no GPS and/or movement needed)\n- Stunning graphics\n- Swipe down for easy to understand calibration") != BPS_SUCCESS) {
		fprintf(stderr, "Failed to set alert dialog message text.");
		dialog_destroy(alert_dialog);
		alert_dialog = 0;
		return;
	}


    /*
     * Use a button label of our own. Don't attach a context to the button.
     */
    if (dialog_add_button(alert_dialog, "Cancel", true, 0, true) != BPS_SUCCESS) {
        fprintf(stderr, "Failed to add button to alert dialog.");
        dialog_destroy(alert_dialog);
        alert_dialog = 0;
        return;
    }
    if (dialog_add_button(alert_dialog, "mappau.com", true, 0, true) != BPS_SUCCESS) {
        fprintf(stderr, "Failed to add button to alert dialog.");
        dialog_destroy(alert_dialog);
        alert_dialog = 0;
        return;
    }

    if (dialog_add_button(alert_dialog, "Download", true, 0, true) != BPS_SUCCESS) {
        fprintf(stderr, "Failed to add button to alert dialog.");
        dialog_destroy(alert_dialog);
        alert_dialog = 0;
        return;
    }

    if (dialog_show(alert_dialog) != BPS_SUCCESS) {
        fprintf(stderr, "Failed to show alert dialog.");
        dialog_destroy(alert_dialog);
        alert_dialog = 0;
        return;
    }
}
void
create_dialog()
{
    if (main_dialog) {
        return;
    }

    dialog_create_alert(&main_dialog);
    dialog_set_alert_message_text(main_dialog, "\n");
    dialog_set_group_id(main_dialog, get_window_group_id());
    dialog_set_cancel_required(main_dialog, true);

    dialog_add_button(main_dialog, "Query", true, "query", true);
    dialog_add_button(main_dialog, "Vol Up", true, "double", true);
    dialog_add_button(main_dialog, "Vol Down", true, "half", true);
    dialog_add_button(main_dialog, "Toggle Mute", true, "toggle", true);

    dialog_show(main_dialog);
}
Exemple #8
0
int vs_create(scene *scene) {
    // Init local data
    vs_local *local = malloc(sizeof(vs_local));
    scene_set_userdata(scene, local);
    game_player *player1 = game_state_get_player(scene->gs, 0);
    game_player *player2 = game_state_get_player(scene->gs, 1);

    snprintf(local->vs_str, 128, "%s VS. %s", lang_get(20+player1->pilot_id), lang_get(20+player2->pilot_id));

    animation *ani;

    palette *mpal = video_get_base_palette();
    palette_set_player_color(mpal, 0, player1->colors[2], 0);
    palette_set_player_color(mpal, 0, player1->colors[1], 1);
    palette_set_player_color(mpal, 0, player1->colors[0], 2);
    palette_set_player_color(mpal, 1, player2->colors[2], 0);
    palette_set_player_color(mpal, 1, player2->colors[1], 1);
    palette_set_player_color(mpal, 1, player2->colors[0], 2);
    video_force_pal_refresh();

    // HAR
    ani = &bk_get_info(&scene->bk_data, 5)->ani;
    object_create(&local->player1_har, scene->gs, vec2i_create(160,0), vec2f_create(0, 0));
    object_set_animation(&local->player1_har, ani);
    object_select_sprite(&local->player1_har, player1->har_id);

    object_create(&local->player2_har, scene->gs, vec2i_create(160,0), vec2f_create(0, 0));
    object_set_animation(&local->player2_har, ani);
    object_select_sprite(&local->player2_har, player2->har_id);
    object_set_direction(&local->player2_har, OBJECT_FACE_LEFT);
    object_set_pal_offset(&local->player2_har, 48);

    // PLAYER
    ani = &bk_get_info(&scene->bk_data, 4)->ani;
    object_create(&local->player1_portrait, scene->gs, vec2i_create(-10,150), vec2f_create(0, 0));
    object_set_animation(&local->player1_portrait, ani);
    object_select_sprite(&local->player1_portrait, player1->pilot_id);

    object_create(&local->player2_portrait, scene->gs, vec2i_create(330,150), vec2f_create(0, 0));
    object_set_animation(&local->player2_portrait, ani);
    object_select_sprite(&local->player2_portrait, player2->pilot_id);
    object_set_direction(&local->player2_portrait, OBJECT_FACE_LEFT);

    // clone the left side of the background image
    // Note! We are touching the scene-wide background surface!
    surface_sub(&scene->bk_data.background, // DST Surface
                &scene->bk_data.background, // SRC Surface
                160, 0, // DST
                0, 0, // SRC
                160, 200, // Size
                SUB_METHOD_MIRROR); // Flip the right side horizontally

    if (player2->selectable) {
        // player1 gets to choose, start at arena 0
        local->arena = 0;
    } else {
        // pick a random arena for 1 player mode
        local->arena = rand_int(5); // srand was done in melee
    }

    // Arena
    if(player2->selectable) {
        ani = &bk_get_info(&scene->bk_data, 3)->ani;
        object_create(&local->arena_select, scene->gs, vec2i_create(59,155), vec2f_create(0, 0));
        object_set_animation(&local->arena_select, ani);
        object_select_sprite(&local->arena_select, local->arena);
    }


    // SCIENTIST
    int scientistpos = rand_int(4);
    vec2i scientistcoord = spawn_position(scientistpos, 1);
    if (scientistpos % 2) {
        scientistcoord.x += 50;
    } else {
        scientistcoord.x -= 50;
    }
    object *o_scientist = malloc(sizeof(object));
    ani = &bk_get_info(&scene->bk_data, 8)->ani;
    object_create(o_scientist, scene->gs, scientistcoord, vec2f_create(0, 0));
    object_set_animation(o_scientist, ani);
    object_select_sprite(o_scientist, 0);
    object_set_direction(o_scientist, scientistpos % 2 ? OBJECT_FACE_LEFT : OBJECT_FACE_RIGHT);
    game_state_add_object(scene->gs, o_scientist, RENDER_LAYER_MIDDLE, 0, 0);

    // WELDER
    int welderpos = rand_int(6);
    // welder can't be on the same gantry or the same *side* as the scientist
    // he also can't be on the same 'level'
    // but he has 10 possible starting positions
    while ((welderpos % 2)  == (scientistpos % 2) || (scientistpos < 2 && welderpos < 2) || (scientistpos > 1 && welderpos > 1 && welderpos < 4)) {
        welderpos = rand_int(6);
    }
    object *o_welder = malloc(sizeof(object));
    ani = &bk_get_info(&scene->bk_data, 7)->ani;
    object_create(o_welder, scene->gs, spawn_position(welderpos, 0), vec2f_create(0, 0));
    object_set_animation(o_welder, ani);
    object_select_sprite(o_welder, 0);
    object_set_spawn_cb(o_welder, cb_vs_spawn_object, (void*)scene);
    object_set_destroy_cb(o_welder, cb_vs_destroy_object, (void*)scene);
    object_set_direction(o_welder, welderpos % 2 ? OBJECT_FACE_LEFT : OBJECT_FACE_RIGHT);
    game_state_add_object(scene->gs, o_welder, RENDER_LAYER_MIDDLE, 0, 0);

    // GANTRIES
    object *o_gantry_a = malloc(sizeof(object));
    ani = &bk_get_info(&scene->bk_data, 11)->ani;
    object_create(o_gantry_a, scene->gs, vec2i_create(0,0), vec2f_create(0, 0));
    object_set_animation(o_gantry_a, ani);
    object_select_sprite(o_gantry_a, 0);
    game_state_add_object(scene->gs, o_gantry_a, RENDER_LAYER_TOP, 0, 0);

    object *o_gantry_b = malloc(sizeof(object));
    object_create(o_gantry_b, scene->gs, vec2i_create(320,0), vec2f_create(0, 0));
    object_set_animation(o_gantry_b, ani);
    object_select_sprite(o_gantry_b, 0);
    object_set_direction(o_gantry_b, OBJECT_FACE_LEFT);
    game_state_add_object(scene->gs, o_gantry_b, RENDER_LAYER_TOP, 0, 0);

    // Background tex
    menu_background2_create(&local->arena_select_bg, 211, 50);

    // Quit Dialog
    dialog_create(&local->quit_dialog, DIALOG_STYLE_YES_NO, "ARE YOU SURE YOU WANT TO QUIT THIS GAME?", 72, 60);
    local->quit_dialog.userdata = scene;
    local->quit_dialog.clicked = vs_quit_dialog_clicked;

    // Too Pathetic Dialog
    char insult[512];
    snprintf(insult, 512, lang_get(748), "Veteran", "Major Kreissack");
    dialog_create(&local->too_pathetic_dialog, DIALOG_STYLE_OK, insult, 72, 60);
    local->too_pathetic_dialog.userdata = scene;
    local->too_pathetic_dialog.clicked = vs_too_pathetic_dialog_clicked;

    if (player2->pilot_id == 10 && settings_get()->gameplay.difficulty < 2) {
        // kriessack, but not on Veteran or higher
        dialog_show(&local->too_pathetic_dialog, 1);
    }

    // Callbacks
    scene_set_render_cb(scene, vs_render);
    scene_set_render_overlay_cb(scene, vs_render_overlay);
    scene_set_input_poll_cb(scene, vs_input_tick);
    scene_set_dynamic_tick_cb(scene, vs_dynamic_tick);
    scene_set_static_tick_cb(scene, vs_static_tick);
    scene_set_free_cb(scene, vs_free);

    // Pick renderer
    video_select_renderer(VIDEO_RENDERER_HW);

    return 0;
}
bool QQnxFileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
{
    Q_UNUSED(flags);
    qFileDialogHelperDebug() << Q_FUNC_INFO;

    QQnxBpsEventFilter *eventFilter = m_integration->bpsEventFilter();
    // We *really* need the bps event filter ;)
    if (!eventFilter)
        return false;

    // Native dialogs can only handle application modal use cases so far
    if (modality != Qt::ApplicationModal)
        return false;

    // Tear down any existing dialog and start again as dialog mode may have changed
    if (m_dialog) {
        dialog_destroy(m_dialog);
        m_dialog = 0;
    }

    // Create dialog
    const QSharedPointer<QFileDialogOptions> &opts = options();
    if (opts->acceptMode() == QFileDialogOptions::AcceptOpen) {
        if (dialog_create_filebrowse(&m_dialog) != BPS_SUCCESS) {
            qWarning("dialog_create_filebrowse failed");
            return false;
        }

        // Select one or many files?
        bool multiSelect = (opts->fileMode() == QFileDialogOptions::ExistingFiles);
        dialog_set_filebrowse_multiselect(m_dialog, multiSelect);

        // Set the actual list of extensions
        if (!opts->nameFilters().isEmpty()) {
            qFileDialogHelperDebug() << "nameFilters =" << opts->nameFilters();
            setNameFilter(opts->nameFilters().first());
        } else {
            QString defaultNameFilter = QStringLiteral("*.*");
            setNameFilter(defaultNameFilter);
        }
    } else {
        if (dialog_create_filesave(&m_dialog) != BPS_SUCCESS) {
            qWarning("dialog_create_filesave failed");
            return false;
        }

        // Maybe pre-select a filename
        if (!opts->initiallySelectedFiles().isEmpty()) {
            QString fileName = opts->initiallySelectedFiles().first().toLocalFile();
            dialog_set_filesave_filename(m_dialog, QFile::encodeName(fileName).constData());
        }

        // Add OK and Cancel buttons. We add the buttons in the order "CANCEL" followed by "OK
        // such that they have indices matching the buttons on the file open dialog which
        // is automatically populated with buttons.
        if (dialog_add_button(m_dialog, tr("CANCEL").toLocal8Bit().constData(), true, 0, true) != BPS_SUCCESS) {
            qWarning("dialog_add_button failed");
            return false;
        }

        if (dialog_add_button(m_dialog, tr("OK").toLocal8Bit().constData(), true, 0, true) != BPS_SUCCESS) {
            qWarning("dialog_add_button failed");
            return false;
        }
    }

    // Cache the accept mode so we know which functions to use to get the results back
    m_acceptMode = opts->acceptMode();

    // Set the libscreen window group and common properties

    QQnxScreen *nativeScreen = parent ? static_cast<QQnxScreen *>(parent->screen()->handle()) :
                                        m_integration->primaryDisplay();
    Q_ASSERT(nativeScreen);
    dialog_set_group_id(m_dialog, nativeScreen->windowGroupName());
    dialog_set_title_text(m_dialog, opts->windowTitle().toLocal8Bit().constData());

    // Register ourselves for dialog domain events from bps
    eventFilter->registerForDialogEvents(this);

    // Show the dialog
    dialog_show(m_dialog);

    return true;
}
Exemple #10
0
void newsroom_input_tick(scene *scene) {
    newsroom_local *local = scene_get_userdata(scene);

    game_player *player1 = game_state_get_player(scene->gs, 0);
    ctrl_event *p1=NULL, *i;
    controller_poll(player1->ctrl, &p1);
    i = p1;
    if (i) {
        do {
            if(i->type == EVENT_TYPE_ACTION) {
                if(dialog_is_visible(&local->continue_dialog)) {
                    dialog_event(&local->continue_dialog, i->event_data.action);
                } else if (
                        i->event_data.action == ACT_ESC ||
                        i->event_data.action == ACT_KICK ||
                        i->event_data.action == ACT_PUNCH) {
                    local->screen++;
                    newsroom_fixup_str(local);
                    if(local->screen >= 2) {
                        if (local->won) {
                            // pick a new player
                            game_player *p1 = game_state_get_player(scene->gs, 0);
                            game_player *p2 = game_state_get_player(scene->gs, 1);
                            DEBUG("wins are %d", p1->sp_wins);
                            if (p1->sp_wins == (4094 ^ (2 << p1->pilot_id)))  {
                                // won the game
                                game_state_set_next(scene->gs, SCENE_END);
                            } else {
                                if (p1->sp_wins == (2046 ^ (2 << p1->pilot_id))) {
                                    // everyone but kriessack
                                    p2->pilot_id = 10;
                                    p2->har_id = HAR_NOVA;
                                } else {
                                    // pick an opponent we have not yet beaten
                                    while(1) {
                                        int i = rand_int(10);
                                        if ((2 << i) & p1->sp_wins || i == p1->pilot_id) {
                                            continue;
                                        }
                                        p2->pilot_id = i;
                                        p2->har_id = rand_int(10);
                                        break;
                                    }
                                }
                                pilot p;
                                pilot_get_info(&p, p2->pilot_id);
                                p2->colors[0] = p.colors[0];
                                p2->colors[1] = p.colors[1];
                                p2->colors[2] = p.colors[2];

                                // make a new AI controller
                                controller *ctrl = malloc(sizeof(controller));
                                controller_init(ctrl);
                                ai_controller_create(ctrl, settings_get()->gameplay.difficulty);
                                game_player_set_ctrl(p2, ctrl);
                                game_state_set_next(scene->gs, SCENE_VS);
                            }
                        } else {
                            dialog_show(&local->continue_dialog, 1);
                        }
                    }
                }
            }
        } while((i = i->next));
    }
    controller_free_chain(p1);
}
Exemple #11
0
int dialog_select_game(char * isofilename, char *isoDir, int *videoPlugin, int *disableSound){
	char path[MAXPATHLEN];
	int i, rc;

	rc = snprintf(path, MAXPATHLEN, "%s", isoDir);
	if ((rc == -1) || (rc >= MAXPATHLEN)) {
		return -1;
	}

	dialog_instance_t dialog = 0;
	bps_event_t *event;
	dialog_create_popuplist(&dialog);

	DIR *dirp;
	struct dirent* direntp;
	int count=0, domain=0;
	const char ** list = 0;
	const char * label;

	dirp = opendir(isoDir);
	if( dirp != NULL ) {
		for(;;) {
			direntp = readdir( dirp );
			if( direntp == NULL ) break;
			printf( "%s\n", direntp->d_name );
			count++;
		}
		rewinddir(dirp);

		if(count==2){
			printf("No ISO's found!");
		}

		list = (const char**)malloc(count*sizeof(char*));
		count = 0;

		for(;;){
			direntp = readdir( dirp );
			if( direntp == NULL ) break;
			list[count] = (char*)direntp->d_name;
			count++;
		}

		int j = 0, m;
		int disabled[count];

		//If a cue exists, disable the bin for easier readability
		for(i=0; i<count;i++){

			if( strcmp(list[i], ".") == 0 || strcmp(list[i], "..") == 0 ){
				disabled[j++] = i;
				continue;
			}

			//Check if current index is a valid rom, .n64, .v64, .z64
			if( strncasecmp(list[i]+strlen(list[i])-4, ".n64", 4) != 0 &&
				strncasecmp(list[i]+strlen(list[i])-4, ".v64", 4) != 0 &&
				strncasecmp(list[i]+strlen(list[i])-4, ".z64", 4) != 0)
			{
				disabled[j++] = i;
				continue;
			}
		}

		int k = 0;
		char * compact[count-j+6];
		compact[k++] = "Video Plugin";
		compact[k++] = "Video Rice";
		compact[k++] = "GLES2N64";
		compact[k++] = "Audio Plugin";
		compact[k++] = "Disable Sound";
		compact[k++] = "Roms";

		//For each index
		for(i=0;i<count;i++){
			//search disabled for a match
			for(m=0;m<j;m++){
				if(i==disabled[m]){
					//If we do find that i is disabled don't copy
					break;
				}
			}
			if(m==j){
				compact[k++] = list[i];
			}
		}

		//Sort compact list
		qsort( compact+6, k-6, sizeof(char *), compare );
		int indice[] = {0,3,5};
		dialog_set_popuplist_items(dialog, compact, k);
		dialog_set_popuplist_separator_indices(dialog, (int*)&indice, 3);
		indice[0] = 1;
		dialog_set_popuplist_selected_indices(dialog, (int*)&indice, 1);

		char* cancel_button_context = "Canceled";
		char* okay_button_context = "Okay";
		dialog_add_button(dialog, DIALOG_CANCEL_LABEL, true, cancel_button_context, true);
		dialog_add_button(dialog, DIALOG_OK_LABEL, true, okay_button_context, true);
		dialog_set_popuplist_multiselect(dialog, true);
		dialog_show(dialog);

		while(1){
			bps_get_event(&event, -1);

			if (event) {
				domain = bps_event_get_domain(event);
				if (domain == dialog_get_domain()) {
					int *response = NULL;
					int num = 0;
					int videoOption = 0;
					label = dialog_event_get_selected_label(event);

					if(strcmp(label, DIALOG_OK_LABEL) == 0){
						dialog_event_get_popuplist_selected_indices(event, (int**)&response, &num);
						if(num > 0){
							for(i=0;i<num;i++){
								if(	(response[i] == 1) ||
									(response[i] == 2) )
								{
									videoOption +=1;
								}
							}
							if(videoOption != 1){
								printf("Must pick only 1 video Plugin...\n");fflush(stdout);
								return -1;
							}
						}

						int vid = 0, sound = 0, rom = 0;
						switch(num){
						case 0:
						case 1:
							printf("Must pick at least a video plugin and rom...\n");
							return -1;
							break;
						case 2:
							if(response[1] == 4 || response[0] == 4){
								printf("Must pick a Rom...\n");
								return -1;
							}
							*disableSound = 0;
							if(response[0] == 2 || response[1] == 2){
								*videoPlugin = VIDEO_PLUGIN_GLES2N64;
							} else {
								*videoPlugin = VIDEO_PLUGIN_RICE;
							}
							if(response[0] == 2 || response[0] == 1){
								strcpy(isofilename, compact[response[1]]);
							}else {
								strcpy(isofilename, compact[response[0]]);
							}
							break;
						case 3:
							for(i=0;i<num;i++){
								if(response[i] == 1){
									vid = 1;
									*videoPlugin = VIDEO_PLUGIN_RICE;
								} else if (response[i] == 2){
									vid = 1;
									*videoPlugin = VIDEO_PLUGIN_GLES2N64;
								} else if (response[i] == 4){
									sound = 1;
								} else if( response[i] > 5){
									rom = 1;
									strcpy(isofilename, compact[response[i]]);
								}
							}
							if(vid != 1 || sound != 1 || rom != 1){
								printf("Must pick a rom...");fflush(stdout);
								return -1;
							}
							*disableSound = 1;
							break;
						}
						bps_free(response);
					} else {
						printf("User has canceled ISO dialog.");
						free(list);
						closedir(dirp);
						return -1;
					}
					break;
				}
			}
		}

		free(list);
		closedir(dirp);
	}

	if (strlen(path) + strlen(isofilename) + 1 < MAXPATHLEN) {
		strcat(path, isofilename);
		strcpy(isofilename, path);
	} else
		isofilename[0] = 0;
	return 0;
}