コード例 #1
0
ファイル: mapping.c プロジェクト: gale320/mehstation
Screen* meh_screen_mapping_new(App* app) {
	g_assert(app != NULL);

	Screen* screen = meh_screen_new(app->window);

	screen->name = g_strdup("Gamepad configuration screen");
	screen->messages_handler = &meh_screen_mapping_messages_handler;
	screen->destroy_data = &meh_screen_mapping_destroy_data;

	/*
	 * Custom data
	 */
	MappingData* data = g_new(MappingData, 1);

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

	data->title = meh_widget_text_new(app->big_font, "Press a key on the controller to configure", 50, 50, 1230, 50, white, FALSE);
	data->title->x = meh_transition_start(MEH_TRANSITION_LINEAR, -300, 50, 300);
	meh_screen_add_text_transitions(screen, data->title);
	data->device_configuring = NULL;
	data->action = NULL;

	data->step = MEH_MAPPING_STEP_IDENTIFY;

	screen->data = data;

	return screen;
}
コード例 #2
0
ファイル: simple_popup.c プロジェクト: duiz/mehstation
/*
 * meh_simple_popup_add_action adds an action to the popup.
 */
void meh_simple_popup_add_action(App* app, Screen* screen, gchar* label, void (*func) (struct App*, struct Screen*)) {
	g_assert(label != NULL);
	g_assert(func != NULL);


	SimplePopupData* data = meh_simple_popup_get_data(screen);
	SimplePopupAction* new_action = g_new(SimplePopupAction, 1);

	new_action->label = g_strdup(label);
	new_action->run = func;

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

	/* compute the position of this widget */
	new_action->widget = meh_widget_text_new(
			app->small_font,
			new_action->label,
			400,
			data->y+55 + (32*g_queue_get_length(data->actions)),
			data->width-20,
			30,
			white,
			TRUE);

	g_queue_push_tail(data->actions, new_action);
}
コード例 #3
0
ファイル: exec_selection.c プロジェクト: gale320/mehstation
void meh_exec_selection_prepare(App* app, Screen* screen) {
	g_assert(app != NULL);
	g_assert(screen != NULL);

	ExecutableListData* data = meh_exec_list_get_data(screen);

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

	/* Selection */
	data->selection_widget = meh_widget_rect_new(0, -100, 415, 28, white_transparent, TRUE);
	data->selection_widget->y = meh_transition_start(MEH_TRANSITION_CUBIC, -100, 130, 500);
	meh_screen_add_rect_transitions(screen, data->selection_widget);

	/* Executables */
	for (int i = 0; i < MEH_EXEC_LIST_SIZE; i++) {
		WidgetText* text = meh_widget_text_new(app->small_font, "", 55, 130+(i*32), 350, 30, white, FALSE);
		text->uppercase = TRUE; /* executables name in uppercase */
		g_queue_push_tail(data->executable_widgets, text);
	}
}
コード例 #4
0
ファイル: popup.c プロジェクト: MrTraan/mehstation
Screen* meh_screen_popup_new(App* app, Screen* src_screen, Executable* executable)  {
    g_assert(app != NULL);
    g_assert(src_screen != NULL);
    g_assert(executable != NULL);

    Screen* screen = meh_screen_new(app->window);

    screen->name = g_strdup("Popup screen");
    screen->messages_handler = &meh_screen_popup_messages_handler;
    screen->destroy_data = &meh_screen_popup_destroy_data;

    /*
     * Custom data
     */
    PopupData* data = g_new(PopupData, 1);

    data->src_screen = src_screen;
    data->executable = executable;
    data->action = 0;
    data->width = 400;
    data->height = 200;
    data->x = MEH_FAKE_WIDTH/2 - data->width/2;
    data->y = MEH_FAKE_HEIGHT/2 - data->height/2;
    data->quitting = FALSE;

    /* Popup background */

    SDL_Color white = { 255, 255, 255, 255 };
    SDL_Color black = { 0, 0, 0, 240 };
    SDL_Color gray = { 15, 15, 15, 120 };
    SDL_Color light_gray = { 90, 90, 90, 220 };
    SDL_Color very_light_gray = { 40, 40, 40, 220 };

    data->background_widget = meh_widget_rect_new(data->x, data->y, data->width, data->height, very_light_gray, TRUE);
    data->background_widget->y = meh_transition_start(MEH_TRANSITION_LINEAR, -data->height, data->background_widget->y.value, 150);
    meh_screen_add_rect_transitions(screen, data->background_widget);
    screen->data = data;

    black.a = 150;
    data->hover_widget = meh_widget_rect_new(0, 0, MEH_FAKE_WIDTH, MEH_FAKE_HEIGHT, black, TRUE);

    /* Title */
    data->title_widget = meh_widget_text_new(app->small_bold_font, "OPTIONS", data->x+10, data->y+5, data->width-10, 40, white, TRUE);
    data->title_bg_widget = meh_widget_rect_new(data->x, data->y, data->width, 45, gray, TRUE);

    data->selection_widget = meh_widget_rect_new(
                                 data->x+5,
                                 data->y+54,
                                 data->width-10,
                                 30,
                                 light_gray,
                                 TRUE);


    /* Add/Remove to favorite */
    data->favorite_widget = meh_widget_text_new(
                                app->small_font,
                                executable->favorite == 1 ? "Remove from favorite" : "Add to favorite",
                                data->x+20,
                                data->y+55,
                                data->width-20,
                                30,
                                white,
                                TRUE);

    screen->data = data;

    return screen;
}
コード例 #5
0
ファイル: popup.c プロジェクト: gale320/mehstation
Screen* meh_screen_popup_new(App* app, Screen* src_screen, Platform* platform, Executable* executable)  {
	g_assert(app != NULL);
	g_assert(src_screen != NULL);
	g_assert(executable != NULL);

	Screen* screen = meh_screen_new(app->window);

	screen->name = g_strdup("Popup screen");
	screen->messages_handler = &meh_screen_popup_messages_handler;
	screen->destroy_data = &meh_screen_popup_destroy_data;

	/*
	 * Custom data
	 */
	PopupData* data = g_new(PopupData, 1);

	data->src_screen = src_screen;
	data->executable = executable;
	data->platform = platform;
	data->action = 0;
	data->width = 400;
	data->height = 200;
	data->x = MEH_FAKE_WIDTH/2 - data->width/2;
	data->y = MEH_FAKE_HEIGHT/2 - data->height/2;

	/* Popup background */

	SDL_Color white = { 255, 255, 255, 255 };
	SDL_Color black = { 0, 0, 0, 240 };
	SDL_Color light_gray = { 40, 40, 40, 220 };

	screen->data = data;

	black.a = 210;
	data->hover_widget = meh_widget_rect_new(0, 0, MEH_FAKE_WIDTH, MEH_FAKE_HEIGHT, black, TRUE); 

	/* Title */
	data->title_widget = meh_widget_text_new(app->small_bold_font, "OPTIONS", -300, data->y+5, data->width-10, 40, white, TRUE);
	data->title_widget->x = meh_transition_start(MEH_TRANSITION_CUBIC, -300, 300, 350);
	meh_screen_add_text_transitions(screen, data->title_widget);

	data->selection_widget = meh_widget_rect_new(
			0,
			data->y+54,
			MEH_FAKE_WIDTH,
			30,
			light_gray,
			TRUE);

	/* Add/Remove to favorite */
	data->favorite_widget = meh_widget_text_new(
			app->small_font,
			executable->favorite == 1 ? "Remove from favorite" : "Add to favorite",
			400,
			data->y+55,
			data->width-20,
			30,
			white,
			TRUE);

	/* Run random */
	data->random_widget = meh_widget_text_new(
			app->small_font,
			"Run random executable of this platform",
			400,
			data->y+87,
			data->width-20,
			30,
			white,
			TRUE);

	screen->data = data;

	return screen;
}
コード例 #6
0
ファイル: main_popup.c プロジェクト: gale320/mehstation
Screen* meh_main_popup_new(App* app, Screen* src_screen)  {
	g_assert(app != NULL);
	g_assert(src_screen != NULL);

	Screen* screen = meh_screen_new(app->window);

	screen->name = g_strdup("Main popup screen");
	screen->messages_handler = &meh_main_popup_messages_handler;
	screen->destroy_data = &meh_main_popup_destroy_data;

	/*
	 * Custom data
	 */
	MainPopupData* data = g_new(MainPopupData, 1);

	data->src_screen = src_screen;
	data->action = 0;
	data->width = 400;
	data->height = 200;
	data->x = MEH_FAKE_WIDTH/2 - data->width/2;
	data->y = MEH_FAKE_HEIGHT/2 - data->height/2;

	/* Popup background */

	SDL_Color white = { 255, 255, 255, 255 };
	SDL_Color black = { 0, 0, 0, 240 };
	SDL_Color light_gray = { 40, 40, 40, 220 };

	screen->data = data;

	black.a = 210;
	data->hover_widget = meh_widget_rect_new(0, 0, MEH_FAKE_WIDTH, MEH_FAKE_HEIGHT, black, TRUE); 

	/* Title */
	data->title_widget = meh_widget_text_new(app->small_bold_font, "COMMANDS", data->x+10, data->y+5, data->width-10, 40, white, TRUE);
	data->title_widget->x = meh_transition_start(MEH_TRANSITION_CUBIC, -300, 300, 350);
	meh_screen_add_text_transitions(screen, data->title_widget);

	data->selection_widget = meh_widget_rect_new(
			0,
			data->y+54,
			MEH_FAKE_WIDTH,
			30,
			light_gray,
			TRUE);

	data->title_widget->x = meh_transition_start(MEH_TRANSITION_CUBIC, -300, 300, 350);
	meh_screen_add_text_transitions(screen, data->title_widget);


	/* Run random executable */
	data->random_widget = meh_widget_text_new(
			app->small_font,
			"Run random executable",
			400,
			data->y+55,
			data->width-20,
			30,
			white,
			TRUE);

	/* Close mehstation */
	data->close_widget = meh_widget_text_new(
			app->small_font,
			"Close mehstation",
			400,
			data->y+87,
			data->width-20,
			30,
			white,
			TRUE);

	/* Shutdown */
	data->shutdown_widget = meh_widget_text_new(
			app->small_font,
			"Shutdown",
			400,
			data->y+119,
			data->width-20,
			30,
			white,
			TRUE);
	screen->data = data;

	return screen;
}
コード例 #7
0
ファイル: mapping.c プロジェクト: gale320/mehstation
/*
 * 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++;
}