Beispiel #1
0
/*
 * meh_screen_popup_destroy_data destroys the additional data
 * of the popup screen.
 */
void meh_screen_popup_destroy_data(Screen* screen) {
	PopupData* data = meh_screen_popup_get_data(screen);
	meh_widget_rect_destroy(data->hover_widget);
	meh_widget_text_destroy(data->title_widget);
	meh_widget_text_destroy(data->favorite_widget);
	meh_widget_text_destroy(data->random_widget);
	meh_widget_rect_destroy(data->selection_widget);
	screen->data = NULL;
}
Beispiel #2
0
/*
 * meh_main_popup_destroy_data destroys the additional data
 * of the popup screen.
 */
void meh_main_popup_destroy_data(Screen* screen) {
	MainPopupData* data = meh_main_popup_get_data(screen);
	meh_widget_rect_destroy(data->hover_widget);
	meh_widget_text_destroy(data->title_widget);

	meh_widget_text_destroy(data->random_widget);
	meh_widget_text_destroy(data->close_widget);
	meh_widget_text_destroy(data->shutdown_widget);

	meh_widget_rect_destroy(data->selection_widget);

	screen->data = NULL;
}
Beispiel #3
0
void meh_screen_mapping_destroy_data(Screen* screen) {
	g_assert(screen != NULL);

	MappingData* data = meh_screen_mapping_get_data(screen);

	meh_widget_text_destroy(data->title);

	if (data->device_configuring != NULL) {
		meh_widget_text_destroy(data->device_configuring);
	}

	if (data->action != NULL) {
		meh_widget_text_destroy(data->action);
	}

	screen->data = NULL;
}
Beispiel #4
0
/*
 * meh_simple_popup_destroy_data destroys the additional data
 * of the popup screen.
 */
void meh_simple_popup_destroy_data(Screen* screen) {
	SimplePopupData* data = meh_simple_popup_get_data(screen);
	meh_widget_rect_destroy(data->hover_widget);
	meh_widget_text_destroy(data->title_widget);
	meh_widget_rect_destroy(data->selection_widget);

	/* free the actions objects */
	for (unsigned int i = 0; i < g_queue_get_length(data->actions); i++) {
		SimplePopupAction* action = g_queue_peek_nth(data->actions, i);
		meh_widget_text_destroy(action->widget);
		g_free(action->label);
		g_free(action);
	}
	g_queue_free(data->actions);
	g_free(data);

	screen->data = NULL;
}
Beispiel #5
0
void meh_exec_selection_destroy(Screen* screen) {
	g_assert(screen != NULL);

	ExecutableListData* data = meh_exec_list_get_data(screen);

	/* Selection */
	meh_widget_rect_destroy(data->selection_widget);

	/* Executables */
	for (unsigned int i = 0; i < g_queue_get_length(data->executable_widgets); i++) {
		meh_widget_text_destroy( g_queue_peek_nth( data->executable_widgets, i) );
	}
	g_queue_free(data->executable_widgets);
}
Beispiel #6
0
/*
 * meh_screen_mapping_button_pressed is called when we received a button pressed
 * message.
 */
void meh_screen_mapping_button_pressed(App* app, Screen* screen, int pressed_button, int sdl_key, gchar*  guid) {
	MappingData* data = meh_screen_mapping_get_data(screen);
	g_assert(data != NULL);

	SDL_Color white = { 255, 255, 255, 255 };

	Gamepad* gamepad = meh_input_manager_gamepad_by_guid(app->input_manager, guid);
	const char* name = "keyboard";
	if (gamepad != NULL) {
		name = gamepad->name;
	}

	switch (data->step) {
		case MEH_MAPPING_STEP_IDENTIFY:
			meh_widget_text_destroy(data->title);
			data->title = meh_widget_text_new(app->big_font, "Configuring:", 50, 50, 1230, 50, white, FALSE);
			data->device_configuring = meh_widget_text_new(app->big_font, name, 300, 50, 1030, 50, white, FALSE);
			data->action = meh_widget_text_new(app->big_font, "Press the key for up", 200, 150, 1030, 50, white, FALSE);
			data->action->x = meh_transition_start(MEH_TRANSITION_LINEAR, MEH_FAKE_WIDTH+200, 200, 200);
			meh_screen_add_text_transitions(screen, data->action);
			break;
		case MEH_MAPPING_STEP_UP:
			meh_widget_text_destroy(data->action);
			data->action = meh_widget_text_new(app->big_font, "Press the key for down", 200, 150, 1030, 50, white, FALSE);
			data->action->x = meh_transition_start(MEH_TRANSITION_LINEAR, MEH_FAKE_WIDTH+200, 200, 200);
			meh_screen_add_text_transitions(screen, data->action);

			data->up = sdl_key;
			break;
		case MEH_MAPPING_STEP_DOWN:
			meh_widget_text_destroy(data->action);
			data->action = meh_widget_text_new(app->big_font, "Press the key for left", 200, 150, 1030, 50, white, FALSE);
			data->action->x = meh_transition_start(MEH_TRANSITION_LINEAR, MEH_FAKE_WIDTH+200, 200, 200);
			meh_screen_add_text_transitions(screen, data->action);
			data->down = sdl_key;
			break;
		case MEH_MAPPING_STEP_LEFT:
			meh_widget_text_destroy(data->action);
			data->action = meh_widget_text_new(app->big_font, "Press the key for right", 200, 150, 1030, 50, white, FALSE);
			data->action->x = meh_transition_start(MEH_TRANSITION_LINEAR, MEH_FAKE_WIDTH+200, 200, 200);
			meh_screen_add_text_transitions(screen, data->action);
			data->left = sdl_key;
			break;
		case MEH_MAPPING_STEP_RIGHT:
			meh_widget_text_destroy(data->action);
			data->action = meh_widget_text_new(app->big_font, "Press the key for A button", 200, 150, 1030, 50, white, FALSE);
			data->action->x = meh_transition_start(MEH_TRANSITION_LINEAR, MEH_FAKE_WIDTH+200, 200, 200);
			meh_screen_add_text_transitions(screen, data->action);
			data->right = sdl_key;
			break;
		case MEH_MAPPING_STEP_A:
			meh_widget_text_destroy(data->action);
			data->action = meh_widget_text_new(app->big_font, "Press the key for B button", 200, 150, 1030, 50, white, FALSE);
			data->action->x = meh_transition_start(MEH_TRANSITION_LINEAR, MEH_FAKE_WIDTH+200, 200, 200);
			meh_screen_add_text_transitions(screen, data->action);
			data->a = sdl_key;
			break;
		case MEH_MAPPING_STEP_B:
			meh_widget_text_destroy(data->action);
			data->action = meh_widget_text_new(app->big_font, "Press the key for L button", 200, 150, 1030, 50, white, FALSE);
			data->action->x = meh_transition_start(MEH_TRANSITION_LINEAR, MEH_FAKE_WIDTH+200, 200, 200);
			meh_screen_add_text_transitions(screen, data->action);
			data->b = sdl_key;
			break;
		case MEH_MAPPING_STEP_L:
			meh_widget_text_destroy(data->action);
			data->action = meh_widget_text_new(app->big_font, "Press the key for R button", 200, 150, 1030, 50, white, FALSE);
			data->action->x = meh_transition_start(MEH_TRANSITION_LINEAR, MEH_FAKE_WIDTH+200, 200, 200);
			meh_screen_add_text_transitions(screen, data->action);
			data->l = sdl_key;
			break;
		case MEH_MAPPING_STEP_R:
			meh_widget_text_destroy(data->action);
			data->action = meh_widget_text_new(app->big_font, "Press the key for START button", 200, 150, 1030, 50, white, FALSE);
			data->action->x = meh_transition_start(MEH_TRANSITION_LINEAR, MEH_FAKE_WIDTH+200, 200, 200);
			meh_screen_add_text_transitions(screen, data->action);
			data->r = sdl_key;
			break;
		case MEH_MAPPING_STEP_START:
			meh_widget_text_destroy(data->action);
			data->action = meh_widget_text_new(app->big_font, "Press the key for SELECT button", 200, 150, 1030, 50, white, FALSE);
			data->action->x = meh_transition_start(MEH_TRANSITION_LINEAR, MEH_FAKE_WIDTH+200, 200, 200);
			meh_screen_add_text_transitions(screen, data->action);
			data->start = sdl_key;
			break;
		case MEH_MAPPING_STEP_SELECT:
			meh_widget_text_destroy(data->action);
			data->action = meh_widget_text_new(app->big_font, "All done", 200, 150, 1030, 50, white, FALSE);
			data->action->x = meh_transition_start(MEH_TRANSITION_LINEAR, MEH_FAKE_WIDTH+200, 200, 200);
			meh_screen_add_text_transitions(screen, data->action);
			data->select = sdl_key;
			break;
		case MEH_MAPPING_STEP_END:
			meh_screen_mapping_next_screen(app, screen);

			break;
	}

	meh_input_manager_reset_buttons_state(app->input_manager);

	data->step++;
}