Esempio n. 1
0
void settings_menu_push(state_stack* stack, void* udata) {
	(void) udata;
	state_desc mm = {
		GAME_SETTINGS_MENU, nullptr,
		nullptr, nullptr,
		&_event,
		nullptr,
		&_draw,
		&_destroy,
		nullptr, nullptr, false,
	};
	
	_settings_menu *data = (_settings_menu*) malloc(sizeof(_settings_menu));
	
	menu *pMenu = menu_init(100, 50);
	menu_add_entry(pMenu, "Controls");
	menu_add_entry(pMenu, "");
	menu_add_entry(pMenu, STR_ARROWBIG_LEFT " Save Settings");
	menu_add_entry(pMenu, STR_ARROWBIG_LEFT " Discard Changes");
	menu_auto_resize(pMenu);
	data->m_menu = pMenu;
	
	data->m_settings = settings_init();
	input_config_settings(data->m_settings, g_keybinds);
	screen_config_settings(data->m_settings, nullptr);
	settings_load(data->m_settings, settings_file_path);
	
	mm.m_pData = data;
	table_append(stack, &mm);
}
Esempio n. 2
0
void mod_rfbsl_init(void)
{
	menu_add_entry("RFBSL", NULL, NULL, NULL, NULL, NULL,
						&updown_press,
						&rfbsl_activate,
						&rfbsl_deactivate);
}
Esempio n. 3
0
void mod_tide_init(void)
{
	sys_messagebus_register(&minuteTick, SYS_MSG_RTC_MINUTE);
	menu_add_entry("TIDE", &buttonUp, &buttonDown, NULL, &longStarButton, NULL, NULL, &activate, &deactivate);
	tide = timeFromMinutes(90); /* fullTideTime); */
	minuteTick(); /* initla display setup */
}
void mod_stopwatch_init(void) {
	sSwatch_conf.state = SWATCH_MODE_OFF;
	clear_stopwatch();

	menu_add_entry(" STOP", &up_press, &down_press, &num_press, NULL,
			&num_long_pressed, NULL, &stopwatch_activated,
			&stopwatch_deactivated);
}
Esempio n. 5
0
//* ************************************************************************************************
/// @fn			mod_temperature_init(void)
/// @brief		Init the module. Sets default values, register menu entry.
/// @return		none
//* ************************************************************************************************
void mod_temperature_init(void)
{
    menu_add_entry(" TEMP",
                   NULL, NULL, NULL,
                   &temperature_edit,
                   NULL, NULL,
                   &temperature_activate,
                   &temperature_deactivate);
}
Esempio n. 6
0
// addChoice(choice_string)
// 	addChoice adds the given string to the menu of convrsation choices. Returns immediately.
int _lua_addchoice(lua_State *L) {
	_talk_state *st = (_talk_state*) lua_touserdata(L, lua_upvalueindex(1));
	if (st->m_iState == _STOPPED) {
		return luaL_error(L, "conversation is already stopped");
	}
	const char *txt = lua_tostring(L, 1);
	menu_add_entry(st->m_pChoices, txt);
	lua_remove(L, 1);
	return 0;
}
Esempio n. 7
0
void mod_clock_init()
{
	menu_add_entry("CLOCK", NULL, NULL,
			&num_pressed,
			&star_long_pressed,
			NULL, NULL,
			&clock_activated,
			&clock_deactivated);

}
Esempio n. 8
0
void mod_alarm_init()
{
	menu_add_entry("ALARM", NULL, NULL,
			&num_pressed,
			&star_long_pressed,
			NULL, NULL,
			&alarm_activated,
			&alarm_deactivated);

}
Esempio n. 9
0
void mod_intertechno_init()
{
    menu_add_entry("INTER",
                   &intertechno_up_pressed,
                   &intertechno_down_pressed,
                   &intertechno_num_pressed,
                   &intertechno_star_long_pressed,
                   NULL, NULL,
                   &intertechno_activated, &intertechno_deactivated);
}
Esempio n. 10
0
void _controls_push(state_stack* stack, void* udata) {
	(void) udata;
	state_desc mm = {
		GAME_SETTINGS_CONTROLS, nullptr,
		nullptr, nullptr,
		&_event_controls,
		nullptr,
		&_draw_controls,
		&_destroy_controls,
		nullptr, nullptr, false,
	};
	
	_controls_menu *data = (_controls_menu*) malloc(sizeof(_controls_menu));
	
	data->m_iWhichBinding = -1;
	
	menu *pCmdMenu = menu_init(200, 50);
	menu_add_entry(pCmdMenu, "Set Controls");
	menu_add_entry(pCmdMenu, "Restore Defaults");
	menu_add_entry(pCmdMenu, STR_ARROWBIG_LEFT " Back");
	menu_auto_resize(pCmdMenu);
	data->m_cmdMenu = pCmdMenu;
	
	menu *pBindMenu = menu_init(0, 0);
	pBindMenu->m_iCursorPos = -1;
	menu_add_entry(pBindMenu, STR_ARROW_UP "    ");
	menu_add_entry(pBindMenu, STR_ARROW_DOWN "    ");
	menu_add_entry(pBindMenu, STR_ARROW_LEFT "    ");
	menu_add_entry(pBindMenu, STR_ARROW_RIGHT "    ");
	menu_add_entry(pBindMenu, "OK   ");
	menu_auto_resize(pBindMenu);
	data->m_bindingsMenu = pBindMenu;
	
	pCmdMenu->m_iHeight = pBindMenu->m_iHeight;
	pBindMenu->m_iWidth *= 8;
	pBindMenu->m_iX = pCmdMenu->m_iX + pCmdMenu->m_iWidth + 6;
	pBindMenu->m_iY = pCmdMenu->m_iY;
	
	data->m_aControls[0] = _find_control_bind(IN_DIRUP);
	data->m_aControls[1] = _find_control_bind(IN_DIRDOWN);
	data->m_aControls[2] = _find_control_bind(IN_DIRLEFT);
	data->m_aControls[3] = _find_control_bind(IN_DIRRIGHT);
	data->m_aControls[4] = _find_control_bind(IN_OK);
	_update_bind_desc(data);
	
	data->m_capturingBindings = false;
	
	data->m_iJoyAxes = input_joystick_num_axes();
	data->m_bIgnoreAxes = (bool*) calloc(data->m_iJoyAxes, sizeof(bool));
	
	mm.m_pData = data;
	table_append(stack, &mm);
}
Esempio n. 11
0
void mod_d_day_init(void)
{
	menu_add_entry("D-DAY",
		&up_btn_pressed,
		NULL, NULL,
		&star_long_pressed,
		NULL, NULL,
		&d_day_activate, &d_day_deactivate);

	g_dday.year = CONFIG_MOD_D_DAY_YEAR;
	g_dday.month = CONFIG_MOD_D_DAY_MONTH;
	g_dday.day = CONFIG_MOD_D_DAY_DAY;
}
Esempio n. 12
0
void mod_accelerometer_init()
{

	//if this is called only one time after reboot there are some important things to initialise
	//Initialise sAccel struct?
	sAccel.data=0;
	sAccel.data_prev=0;
	// Set timeout counter
	sAccel.timeout = ACCEL_MEASUREMENT_TIMEOUT;
	/* Clear mode */
	sAccel.mode = ACCEL_MODE_OFF;

	menu_add_entry("ACC",&up_btn, &down_btn,
			&num_pressed,
			&star_long_pressed,
			NULL,NULL,
			&acc_activated,
			&acc_deactivated);

}
Esempio n. 13
0
/*
 * bootsources_menu - show a menu from an array of names
 */
static void bootsources_menu(char *entries[], int num_entries)
{
	struct blspec *blspec = NULL;
	struct blspec_entry *entry, *entry_default;
	struct menu_entry *back_entry;

	if (!IS_ENABLED(CONFIG_MENU)) {
		printf("no menu support available\n");
		return;
	}

	blspec = bootentries_collect(entries, num_entries);
	if (blspec)
		return;

	entry_default = blspec_entry_default(blspec);

	blspec_for_each_entry(blspec, entry) {
		entry->me.action = bootsource_action;
		menu_add_entry(blspec->menu, &entry->me);
		if (entry == entry_default)
			menu_set_selected_entry(blspec->menu, &entry->me);
	}
Esempio n. 14
0
void mod_altitude_init(void)
{
#if defined CONFIG_PRESSURE_BUILD_BOSCH_PS || defined CONFIG_PRESSURE_BUILD_VTI_PS
    
	menu_add_entry(" ALTI", &up_callback, &down_callback,
		&submenu_callback, &edit_mode_callback, &calib_callback, NULL,
		&altitude_activate, &altitude_deactivate);
	
	reset_altitude_measurement();
	
// Set lower and upper limits for offset correction
	if(useMetric){
		// Limits for set_value function
		limit_low = -100;
		limit_high = 4000;
	}else{
// Limits for set_value function
		limit_low = -500;
		limit_high = 9999;
	}
	
#endif
}
Esempio n. 15
0
void mod_battery_init(void)
{
	menu_add_entry(" BATT", NULL, NULL, NULL, NULL, NULL, NULL,
		&battery_activate, &battery_deactivate);
}
Esempio n. 16
0
void mod_music_init(void)
{
	menu_add_entry("MUSIC", NULL, NULL, &num_press, NULL, NULL, NULL,
						&music_activate,
						&music_deactivate);
}
Esempio n. 17
0
static GtkWidget *create_menubar(GFunc *quit_proc) {
	GtkWidget *menubar;
	GtkWidget *menu,*menu_item;
	GtkWidget *menu_entry_play, *menu_entry_pause, *menu_entry_conn, *menu_entry_disconn;
/* 	GtkActionGroup *group;
	GtkUIManager *ui_manager; */

	menubar = gtk_menu_bar_new();

	/* action group whatever *
	group = gtk_action_group_new("MainActionGroup");
	gtk_action_group_add_actions(group,entries,NUM_ENTRIES,NULL);
	* UI Manager *
	ui_manager = gtk_ui_manager_new();
	gtk_ui_manager_insert_action_group(ui_manager, group, 0);
	* adjust path !!! *
	gtk_ui_manager_add_ui_from_file(ui_manager, "menu.ui", NULL);
	menubar = gtk_ui_manager_get_widget(ui_manager, "/MenuBar"); */

	/* item: Playlist */
	menu_item = gtk_menu_item_new_with_mnemonic ("_Playlist");
	gtk_container_add(GTK_CONTAINER(menubar), menu_item);

	/* create menubox for the item */
	menu = gtk_menu_new ();
  	gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);

	/* action: add url */
	menu_add_entry(GTK_CONTAINER(menu), "_Add Media Resource Locator", G_CALLBACK(gui_add_mrl_win), NULL);
	/* action: delete */
	menu_add_entry(GTK_CONTAINER(menu), "_Delete Songs", G_CALLBACK(pl_del_songs), NULL);
	/* action: get current song lyrics */
	// menu_add_entry(GTK_CONTAINER(menu), "_Get lyrics", G_CALLBACK(pl_get_current_song_lyrics), NULL);

	/* menu_entry = gtk_menu_item_new_with_mnemonic("Media _Browser");
	gtk_container_add(GTK_CONTAINER(menu), menu_entry);
	g_signal_connect(G_OBJECT(menu_entry), "activate",
					 G_CALLBACK(media_browser_window_show), NULL);
	g_signal_connect(G_OBJECT(menu_entry), "activate",
					 G_CALLBACK(media_database_read), NULL); */

	/* action: separator */
	menu_add_separator(GTK_CONTAINER(menu));
	/* action: reload playlist */
	menu_add_entry(GTK_CONTAINER(menu), "_Reload playlist", G_CALLBACK(playlist_update_tree_cb), NULL);

	/* action reload media browser */
	menu_add_entry(GTK_CONTAINER(menu), "Reload _Media Browser", G_CALLBACK(mb_reread_cb), NULL);

	/* action: separator */
	menu_add_separator(GTK_CONTAINER(menu));

	/* action: properties dialog */
	menu_add_entry(GTK_CONTAINER(menu), "_Properties", G_CALLBACK(mpd_new_properties_window_cb), (gpointer)MpdWin.win);

	/* action: quit */
#ifdef CLOSE
	menu_add_entry(GTK_CONTAINER(menu), "_Close", G_CALLBACK(quit_proc), MpdWin.win);
#else
	menu_add_entry(GTK_CONTAINER(menu), "_Quit", G_CALLBACK(quit_proc), MpdWin.win);
#endif

	/* item: MPD */
	menu_item = gtk_menu_item_new_with_mnemonic ("_MPD");
	gtk_container_add(GTK_CONTAINER(menubar), menu_item);

	/* create menubox for the item */
	menu = gtk_menu_new ();
  	gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);

	/* action: connect/disconnect */
	menu_entry_disconn = menu_add_entry_stock_icon(GTK_CONTAINER(menu), "_Disconnect", GTK_STOCK_DISCONNECT, G_CALLBACK(mpd_disconnect_cb), NULL);
	menu_entry_conn = menu_add_entry_stock_icon(GTK_CONTAINER(menu), "_Connect", GTK_STOCK_CONNECT, G_CALLBACK(mpd_connect_cb), NULL);

	/* separator */
	menu_add_separator(GTK_CONTAINER(menu));

	/* action: Previous */
	menu_add_entry_stock_icon(GTK_CONTAINER(menu), "P_revious", GTK_STOCK_MEDIA_PREVIOUS, G_CALLBACK(action), ACTION_TYPE_TO_GPOINTER(ACTION_PREVIOUS));

	/* action: Play */
	menu_entry_play = menu_add_entry_stock_icon(GTK_CONTAINER(menu), "_Play", GTK_STOCK_MEDIA_PLAY, G_CALLBACK(action), ACTION_TYPE_TO_GPOINTER(ACTION_PLAY_PAUSE));

	/* action: Pause */
	menu_entry_pause = menu_add_entry_stock_icon(GTK_CONTAINER(menu), "_Pause", GTK_STOCK_MEDIA_PAUSE, G_CALLBACK(action), ACTION_TYPE_TO_GPOINTER(ACTION_PLAY_PAUSE));


	/* action: Stop */
	menu_add_entry_stock_icon(GTK_CONTAINER(menu), "_Stop", GTK_STOCK_MEDIA_STOP, G_CALLBACK(action), ACTION_TYPE_TO_GPOINTER(ACTION_STOP));

	/* action: Next */
	menu_add_entry_stock_icon(GTK_CONTAINER(menu), "_Next", GTK_STOCK_MEDIA_NEXT, G_CALLBACK(action), ACTION_TYPE_TO_GPOINTER(ACTION_NEXT));

	/* action: separator */
	menu_add_separator(GTK_CONTAINER(menu));

	/* action: Update DB */
	menu_add_entry(GTK_CONTAINER(menu), "_Update DB", G_CALLBACK(action), ACTION_TYPE_TO_GPOINTER(ACTION_UPDATE_DB));

	/* action: Shuffle Playlist */
	menu_add_entry(GTK_CONTAINER(menu), "R_andom", G_CALLBACK(action), ACTION_TYPE_TO_GPOINTER(ACTION_RANDOM));

	/* action: Repeat */
	menu_add_entry(GTK_CONTAINER(menu), "R_epeat", G_CALLBACK(action), ACTION_TYPE_TO_GPOINTER(ACTION_REPEAT));

	/* action: Xfade */
	menu_add_entry(GTK_CONTAINER(menu), "_Xfade", G_CALLBACK(action), ACTION_TYPE_TO_GPOINTER(ACTION_XFADE));

	/* item: Help */
	menu_item = gtk_menu_item_new_with_mnemonic ("_Help");
	gtk_container_add(GTK_CONTAINER(menubar), menu_item);

	/* create menubox for the item */
	menu = gtk_menu_new ();
  	gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);

	/* action: log window */
//	menu_add_entry(GTK_CONTAINER(menu), "_Log window", G_CALLBACK(open_log_window), NULL);

	/* action: separator */
	menu_add_separator(GTK_CONTAINER(menu));

	/* action: About */
	menu_add_entry(GTK_CONTAINER(menu), "_About", G_CALLBACK(open_about_dialog), NULL);


	gtk_widget_show_all(menubar);

	menu_entries = NULL;
	menu_entries = g_list_append(menu_entries, menu_entry_play);
	menu_entries = g_list_append(menu_entries, menu_entry_pause);
	menu_entries = g_list_append(menu_entries, menu_entry_conn);
	menu_entries = g_list_append(menu_entries, menu_entry_disconn);

	return menubar;
}
Esempio n. 18
0
File: ui.c Progetto: kradhub/pspdc
static int
ui_piloting_settings_menu (UI * ui, Drone * drone)
{
	Menu *menu;
	MenuSwitchEntry *hull_switch;
	MenuSwitchEntry *outdoor_flight_switch;
	MenuScaleEntry *altitude_limit_scale;
	MenuScaleEntry *vertical_limit_scale;
	MenuScaleEntry *rotation_limit_scale;
	MenuScaleEntry *tilt_limit_scale;
	SDL_Rect position;
	SDL_Surface *frame;
	SDL_Rect menu_frame;
	MenuState ret;

	menu = menu_new (ui->font, MENU_CANCEL_ON_START | MENU_BACK_ON_CIRCLE);

	/* hull presence selection */
	hull_switch = menu_switch_entry_new (PILOTING_SETTINGS_MENU_HULL,
			"Hull set");
	menu_switch_entry_set_values_labels (hull_switch, "no", "yes");
	menu_switch_entry_set_active (hull_switch, drone->hull);
	menu_switch_entry_set_toggled_callback (hull_switch,
			on_hull_switch_toggle, drone);

	/* outdoor flight */
	outdoor_flight_switch =
		menu_switch_entry_new (PILOTING_SETTINGS_MENU_OUTDOOR_FLIGHT,
				"outdoor flight");
	menu_switch_entry_set_values_labels (outdoor_flight_switch, "no", "yes");
	menu_switch_entry_set_active (outdoor_flight_switch, drone->outdoor);
	menu_switch_entry_set_toggled_callback (outdoor_flight_switch,
			on_outdoor_flight_switch_toggle, drone);

	/* altitude limit settings */
	altitude_limit_scale =
		menu_scale_entry_new (PILOTING_SETTINGS_MENU_ALTITUDE_LIMIT,
				"altitude limit (m)", drone->altitude_limit.min,
				drone->altitude_limit.max);
	menu_scale_entry_set_value (altitude_limit_scale,
			drone->altitude_limit.current);

	/* vertical speed limit settings */
	vertical_limit_scale =
		menu_scale_entry_new (PILOTING_SETTINGS_MENU_VERTICAL_SPEED_LIMIT,
				"vertical speed limit (m/s)",
				drone->vertical_speed_limit.min,
				drone->vertical_speed_limit.max);
	menu_scale_entry_set_value (vertical_limit_scale,
			drone->vertical_speed_limit.current);

	/* rotation speed limit settings */
	rotation_limit_scale =
		menu_scale_entry_new (PILOTING_SETTINGS_MENU_ROTATION_SPEED_LIMIT,
				"rotation speed limit (deg/s)",
				drone->rotation_speed_limit.min,
				drone->rotation_speed_limit.max);
	menu_scale_entry_set_value (rotation_limit_scale,
			drone->rotation_speed_limit.current);

	/* rotation speed limit settings */
	tilt_limit_scale =
		menu_scale_entry_new (PILOTING_SETTINGS_MENU_TILT_LIMIT,
				"tilt limit (deg)",
				drone->tilt_limit.min,
				drone->tilt_limit.max);
	menu_scale_entry_set_value (tilt_limit_scale,
			drone->tilt_limit.current);

	menu_add_entry (menu, (MenuEntry *) hull_switch);
	menu_add_entry (menu, (MenuEntry *) outdoor_flight_switch);
	menu_add_entry (menu, (MenuEntry *) altitude_limit_scale);
	menu_add_entry (menu, (MenuEntry *) vertical_limit_scale);
	menu_add_entry (menu, (MenuEntry *) rotation_limit_scale);
	menu_add_entry (menu, (MenuEntry *) tilt_limit_scale);

	/* center position in screen */
	position.x = (ui->screen->w - menu_get_width(menu)) / 2;
	position.y = (ui->screen->h - menu_get_height(menu)) / 2;

	/* to fill a rectangle in background to delimitate menu */
	menu_frame.x = position.x - 5;
	menu_frame.y = position.y - 5;
	menu_frame.w = menu_get_width (menu) + 10;
	menu_frame.h = menu_get_height (menu) + 10;
	frame = SDL_CreateRGBSurface (SDL_HWSURFACE | SDL_SRCCOLORKEY | SDL_SRCALPHA,
			menu_frame.w, menu_frame.h, 32, 0, 0, 0, 0);
	SDL_FillRect (frame, NULL, SDL_MapRGB (frame->format, 0, 0, 0));
	SDL_SetAlpha (frame, SDL_SRCALPHA, 200);

	while (running) {
		/*redraw flight ui */
		ui_flight_update(ui, drone);

		ret = menu_update (menu);
		switch (ret) {
			case MENU_STATE_VISIBLE:
				/* sync option with drone */
				menu_switch_entry_set_active (hull_switch,
						drone->hull);
				menu_switch_entry_set_active (outdoor_flight_switch,
						drone->outdoor);

				SDL_BlitSurface (frame, NULL, ui->screen,
						&menu_frame);
				menu_render_to (menu, ui->screen, &position);
				sceDisplayWaitVblankStart ();
				SDL_Flip (ui->screen);
				break;

			case MENU_STATE_CLOSE:
			case MENU_STATE_CANCELLED:
			default:
				goto done;
				break;

		}
	}

done:
	/* send new scale entries value to drone, not done in callback
	 * to avoid flooding drone and because it can't work well in our side
	 * due to local update and callback for drones for previously sent
	 * values. */
	drone_altitude_limit_set (drone,
			menu_scale_entry_get_value (altitude_limit_scale));
	drone_vertical_speed_limit_set (drone,
			menu_scale_entry_get_value (vertical_limit_scale));
	drone_rotation_speed_limit_set (drone,
			menu_scale_entry_get_value (rotation_limit_scale));
	drone_max_tilt_set (drone,
			menu_scale_entry_get_value (tilt_limit_scale));

	menu_free (menu);
	return ret;
}
Esempio n. 19
0
File: ui.c Progetto: kradhub/pspdc
static int
ui_controls_settings_menu (UI * ui, Drone * drone)
{
	Menu *menu;
	MenuScaleEntry *yaw_scale;
	MenuScaleEntry *pitch_scale;
	MenuScaleEntry *roll_scale;
	MenuScaleEntry *gaz_scale;
	MenuComboBoxEntry *select_binding;
	SDL_Rect position;
	SDL_Surface *frame;
	SDL_Rect menu_frame;
	MenuState ret;

	menu = menu_new (ui->font, MENU_CANCEL_ON_START | MENU_BACK_ON_CIRCLE);

	yaw_scale = menu_scale_entry_new (CONTROLS_SETTINGS_YAW, "yaw", 0, 100);
	menu_scale_entry_set_value (yaw_scale, ui->setting_yaw);

	pitch_scale = menu_scale_entry_new (CONTROLS_SETTINGS_PITCH, "pitch", 0,
			100);
	menu_scale_entry_set_value (pitch_scale, ui->setting_pitch);

	roll_scale = menu_scale_entry_new (CONTROLS_SETTINGS_ROLL, "roll", 0,
			100);
	menu_scale_entry_set_value (roll_scale, ui->setting_roll);

	gaz_scale = menu_scale_entry_new (CONTROLS_SETTINGS_GAZ, "gaz", 0, 100);
	menu_scale_entry_set_value (gaz_scale, ui->setting_gaz);

	select_binding =
		menu_combo_box_entry_new (CONTROLS_SETTINGS_SELECT_BINDING,
				"select binding");
	menu_combo_box_entry_append (select_binding, SELECT_BIND_TAKE_PICTURE,
			"take picture");
	menu_combo_box_entry_append (select_binding, SELECT_BIND_FLIP_FRONT,
			"front flip");
	menu_combo_box_entry_append (select_binding, SELECT_BIND_FLIP_BACK,
			"back flip");
	menu_combo_box_entry_append (select_binding, SELECT_BIND_FLIP_LEFT,
			"left flip");
	menu_combo_box_entry_append (select_binding, SELECT_BIND_FLIP_RIGHT,
			"right flip");
	menu_combo_box_entry_set_value (select_binding,
			ui->setting_select_binding);

	menu_add_entry (menu, (MenuEntry *) yaw_scale);
	menu_add_entry (menu, (MenuEntry *) pitch_scale);
	menu_add_entry (menu, (MenuEntry *) roll_scale);
	menu_add_entry (menu, (MenuEntry *) gaz_scale);
	menu_add_entry (menu, (MenuEntry *) select_binding);

	/* center position in screen */
	position.x = (ui->screen->w - menu_get_width (menu)) / 2;
	position.y = (ui->screen->h - menu_get_height (menu)) / 2;

	/* to fill a rectangle in background to delimitate menu */
	menu_frame.x = position.x - 5;
	menu_frame.y = position.y - 5;
	menu_frame.w = menu_get_width (menu) + 10;
	menu_frame.h = menu_get_height (menu) + 10;
	frame = SDL_CreateRGBSurface (SDL_HWSURFACE | SDL_SRCCOLORKEY | SDL_SRCALPHA,
			menu_frame.w, menu_frame.h, 32, 0, 0, 0, 0);
	SDL_FillRect (frame, NULL, SDL_MapRGB (frame->format, 0, 0, 0));
	SDL_SetAlpha (frame, SDL_SRCALPHA, 200);

	while (running) {
		/*redraw flight ui */
		ui_flight_update(ui, drone);

		ret = menu_update (menu);
		switch (ret) {
			case MENU_STATE_VISIBLE:
				SDL_BlitSurface (frame, NULL, ui->screen,
						&menu_frame);
				menu_render_to (menu, ui->screen, &position);
				sceDisplayWaitVblankStart ();
				SDL_Flip (ui->screen);
				break;

			case MENU_STATE_CLOSE:
			case MENU_STATE_CANCELLED:
			default:
				goto done;
				break;

		}
	}

done:
	/* store value to ui */
	ui->setting_yaw = menu_scale_entry_get_value (yaw_scale);
	ui->setting_pitch = menu_scale_entry_get_value (pitch_scale);
	ui->setting_roll = menu_scale_entry_get_value (roll_scale);
	ui->setting_gaz = menu_scale_entry_get_value (gaz_scale);
	ui->setting_select_binding =
		menu_combo_box_entry_get_value (select_binding);

	menu_free (menu);
	return ret;
}
Esempio n. 20
0
File: ui.c Progetto: kradhub/pspdc
static int
ui_drone_info_menu (UI * ui, Drone * drone)
{
	Menu *menu;
	MenuLabelEntry *drone_sw;
	MenuLabelEntry *drone_hw;
	MenuLabelEntry *arcommand_version;
	char tmp[128] = { 0, };
	SDL_Rect position;
	SDL_Surface *frame;
	SDL_Rect menu_frame;
	MenuState ret;

	menu = menu_new (ui->font, MENU_CANCEL_ON_START | MENU_BACK_ON_CIRCLE);

	snprintf (tmp, 127, "Drone HW: %s", drone->hardware_version);
	drone_hw = menu_label_entry_new (DRONE_INFO_MENU_DRONE_HW, tmp);

	snprintf (tmp, 127, "Drone SW: %s", drone->software_version);
	drone_sw = menu_label_entry_new (DRONE_INFO_MENU_DRONE_HW, tmp);

	snprintf (tmp, 127, "Protocol version: %s", drone->arcommand_version);
	arcommand_version =
		menu_label_entry_new (DRONE_INFO_MENU_ARCOMMAND_VERSION, tmp);

	menu_add_entry (menu, (MenuEntry *) drone_hw);
	menu_add_entry (menu, (MenuEntry *) drone_sw);
	menu_add_entry (menu, (MenuEntry *) arcommand_version);

	/* center position in screen */
	position.x = (ui->screen->w - menu_get_width (menu)) / 2;
	position.y = (ui->screen->h - menu_get_height (menu)) / 2;

	/* to fill a rectangle in background to delimitate menu */
	menu_frame.x = position.x - 5;
	menu_frame.y = position.y - 5;
	menu_frame.w = menu_get_width (menu) + 10;
	menu_frame.h = menu_get_height (menu) + 10;
	frame = SDL_CreateRGBSurface (SDL_HWSURFACE | SDL_SRCCOLORKEY | SDL_SRCALPHA,
			menu_frame.w, menu_frame.h, 32, 0, 0, 0, 0);
	SDL_FillRect (frame, NULL, SDL_MapRGB (frame->format, 0, 0, 0));
	SDL_SetAlpha (frame, SDL_SRCALPHA, 200);

	while (running) {
		/*redraw flight ui */
		ui_flight_update(ui, drone);

		ret = menu_update (menu);
		switch (ret) {
			case MENU_STATE_VISIBLE:
				SDL_BlitSurface (frame, NULL, ui->screen,
						&menu_frame);
				menu_render_to (menu, ui->screen, &position);
				sceDisplayWaitVblankStart ();
				SDL_Flip (ui->screen);
				break;

			case MENU_STATE_CANCELLED:
			case MENU_STATE_CLOSE:
			default:
				goto done;
				break;
		}
	}

done:
	menu_free (menu);
	return ret;
}
Esempio n. 21
0
File: ui.c Progetto: kradhub/pspdc
int
ui_main_menu_run (UI * ui)
{
	Menu *main_menu;
	MenuButtonEntry *connect_button;
	MenuButtonEntry *exit_button;
	SDL_Surface *screen = ui->screen;
	SDL_Surface *title;
	TTF_Font *font = ui->font;
	SDL_Rect position;
	SDL_Rect title_position;
	SDL_Surface *frame;
	SDL_Rect menu_frame;
	int selected_id = -1;

	/* make title and center it at screen top */
	title = ui_render_text (ui, &color_black, "PSP Drone Control");
	title_position.x = (screen->w - title->w) / 2;
	title_position.y = 20;

	main_menu = menu_new (font, 0);
	connect_button = menu_button_entry_new (MAIN_MENU_CONNECT,
			"Connect to drone");
	exit_button = menu_button_entry_new (MAIN_MENU_EXIT, "Exit");

	menu_add_entry (main_menu, (MenuEntry *) connect_button);
	menu_add_entry (main_menu, (MenuEntry *) exit_button);

	/* center position in screen */
	position.x = (screen->w - menu_get_width (main_menu)) / 2;
	position.y = (screen->h - menu_get_height (main_menu)) / 2;

	/* delimitate menu with a black rectangle */
	menu_frame.x = position.x - 5;
	menu_frame.y = position.y - 5;
	menu_frame.w = menu_get_width (main_menu) + 10;
	menu_frame.h = menu_get_height (main_menu) + 10;
	frame = SDL_CreateRGBSurface (SDL_HWSURFACE | SDL_SRCCOLORKEY | SDL_SRCALPHA,
			menu_frame.w, menu_frame.h, 32, 0, 0, 0, 0);
	SDL_FillRect (frame, NULL, SDL_MapRGB (frame->format, 0, 0, 0));
	SDL_SetAlpha (frame, SDL_SRCALPHA, 200);

	while (running) {
		switch (menu_update (main_menu)) {
			case MENU_STATE_CLOSE:
				selected_id = menu_get_selected_id (main_menu);
				goto done;
				break;
			default:
				/* update screen */
				SDL_FillRect (ui->screen, NULL,
						SDL_MapRGB (ui->screen->format, 28, 142, 207));
				SDL_BlitSurface (title, NULL, screen, &title_position);
				SDL_BlitSurface (frame, NULL, screen, &menu_frame);
				menu_render_to (main_menu, screen, &position);
				sceDisplayWaitVblankStart ();
				SDL_Flip (screen);
				break;
		}
	}

done:
	SDL_FreeSurface (frame);
	menu_free (main_menu);
	return selected_id;
}
Esempio n. 22
0
File: ui.c Progetto: kradhub/pspdc
static int
ui_flight_main_menu (UI * ui, Drone * drone)
{
	Menu *menu;
	MenuButtonEntry *quit;
	MenuButtonEntry *flat_trim;
	MenuButtonEntry *piloting_settings;
	MenuButtonEntry *controls_settings;
	MenuButtonEntry *drone_info;
	SDL_Rect position;
	SDL_Surface *frame;
	SDL_Rect menu_frame;
	int selected_id = -1;
	MenuState submenu_state;

	menu = menu_new (ui->font, MENU_CANCEL_ON_START | MENU_BACK_ON_CIRCLE);

	quit = menu_button_entry_new (FLIGHT_MAIN_MENU_QUIT,
			"Return to main menu");
	flat_trim = menu_button_entry_new (FLIGHT_MAIN_MENU_FLAT_TRIM,
			"Do flat trim");
	piloting_settings = menu_button_entry_new (
			FLIGHT_MAIN_MENU_PILOTING_SETTINGS,
			"Piloting settings");
	controls_settings =
		menu_button_entry_new (FLIGHT_MAIN_MENU_CONTROLS_SETTINGS,
			"Controls settings");
	drone_info = menu_button_entry_new (FLIGHT_MAIN_MENU_DRONE_INFO,
			"Drone information");

	menu_add_entry (menu, (MenuEntry *) flat_trim);
	menu_add_entry (menu, (MenuEntry *) piloting_settings);
	menu_add_entry (menu, (MenuEntry *) controls_settings);
	menu_add_entry (menu, (MenuEntry *) drone_info);
	menu_add_entry (menu, (MenuEntry *) quit);

	/* center position in screen */
	position.x = (ui->screen->w - menu_get_width (menu)) / 2;
	position.y = (ui->screen->h - menu_get_height (menu)) / 2;

	/* to fill a rectangle in background to delimitate menu */
	menu_frame.x = position.x - 5;
	menu_frame.y = position.y - 5;
	menu_frame.w = menu_get_width (menu) + 10;
	menu_frame.h = menu_get_height (menu) + 10;
	frame = SDL_CreateRGBSurface (SDL_HWSURFACE | SDL_SRCCOLORKEY | SDL_SRCALPHA,
			menu_frame.w, menu_frame.h, 32, 0, 0, 0, 0);
	SDL_FillRect (frame, NULL, SDL_MapRGB (frame->format, 0, 0, 0));
	SDL_SetAlpha (frame, SDL_SRCALPHA, 200);

mm_display:
	while (running) {
		MenuCloseResult res;

		selected_id = -1;
		/*redraw flight ui */
		ui_flight_update(ui, drone);

		switch (menu_update (menu)) {
			case MENU_STATE_CLOSE:
				selected_id = menu_get_selected_id (menu);
				res = menu_get_close_result (menu);

				if (res == MENU_CLOSE_RESULT_BACK)
					selected_id = -1;
				goto done;
				break;

			case MENU_STATE_VISIBLE:
				SDL_BlitSurface (frame, NULL, ui->screen,
						&menu_frame);
				menu_render_to (menu, ui->screen, &position);
				sceDisplayWaitVblankStart ();
				SDL_Flip (ui->screen);
				break;

			case MENU_STATE_CANCELLED:
			default:
				goto done;
		}
	}

done:
	switch (selected_id) {
		case FLIGHT_MAIN_MENU_FLAT_TRIM:
			drone_flat_trim (drone);
			submenu_state = MENU_STATE_CLOSE;
			break;

		case FLIGHT_MAIN_MENU_PILOTING_SETTINGS:
			submenu_state = ui_piloting_settings_menu (ui, drone);
			break;

		case FLIGHT_MAIN_MENU_CONTROLS_SETTINGS:
			submenu_state = ui_controls_settings_menu (ui, drone);
			break;

		case FLIGHT_MAIN_MENU_DRONE_INFO:
			submenu_state = ui_drone_info_menu (ui, drone);
			break;

		default:
			submenu_state = MENU_STATE_CANCELLED;
			break;
	}

	if (submenu_state == MENU_STATE_CLOSE)
		goto mm_display;

	menu_free (menu);
	return selected_id;
}