Ejemplo n.º 1
0
void frontend_roadbuilding(gint num_roads)
{
	gui_prompt_show(road_building_message(num_roads));
	if (get_gui_state() == frontend_state_roadbuilding)
		return;
	set_gui_state(frontend_state_roadbuilding);
}
Ejemplo n.º 2
0
static void frontend_mode_setup(GuiEvent event)
{
	switch (event) {
	case GUI_UPDATE:
		frontend_gui_check(GUI_UNDO, can_undo());
		frontend_gui_check(GUI_ROAD, setup_can_build_road());
		frontend_gui_check(GUI_BRIDGE, setup_can_build_bridge());
		frontend_gui_check(GUI_SHIP, setup_can_build_ship());
		frontend_gui_check(GUI_SETTLEMENT,
				   setup_can_build_settlement());
		frontend_gui_check(GUI_FINISH, setup_can_finish());
		guimap_single_click_set_functions(check_road_setup,
						  build_road_cb,
						  check_ship_setup,
						  build_ship_cb,
						  check_bridge_setup,
						  build_bridge_cb,
						  check_settlement_setup,
						  build_settlement_cb,
						  NULL, NULL, NULL,
						  NULL, NULL, NULL, NULL);
		break;
	case GUI_UNDO:
		/* The user has pressed the "Undo" button.  Send a
		 * command to the server to attempt the undo.  The
		 * server will respond telling us whether the undo was
		 * successful or not.
		 */
		cb_undo();
		return;
	case GUI_ROAD:
		gui_cursor_set(ROAD_CURSOR,
			       check_road_setup, build_road_cb, NULL,
			       NULL);
		return;
	case GUI_SHIP:
		gui_cursor_set(SHIP_CURSOR,
			       check_ship_setup, build_ship_cb, NULL,
			       NULL);
		return;
	case GUI_BRIDGE:
		gui_cursor_set(BRIDGE_CURSOR,
			       check_bridge_setup, build_bridge_cb, NULL,
			       NULL);
		return;
	case GUI_SETTLEMENT:
		gui_cursor_set(SETTLEMENT_CURSOR,
			       check_settlement_setup,
			       build_settlement_cb, NULL, NULL);
		return;
	case GUI_FINISH:
		cb_end_turn();
		gui_cursor_none();	/* Finish single click build */
		set_gui_state(frontend_state_idle);
		return;
	default:
		break;
	}
}
Ejemplo n.º 3
0
void frontend_gold_done(void)
{
	gold_choose_end();
	if (previous_state != dummy_state) {
		set_gui_state(previous_state);
		previous_state = dummy_state;
	}
}
Ejemplo n.º 4
0
void frontend_robber_done(void)
{
	robber_busy = FALSE;
	if (previous_state != dummy_state) {
		set_gui_state(previous_state);
		previous_state = dummy_state;
	}
	gui_prompt_hide();
}
Ejemplo n.º 5
0
void frontend_discard_add(gint player_num, gint discard_num)
{
	if (player_num == my_player_num())
		g_assert(callback_mode == MODE_DISCARD);
	discard_player_must(player_num, discard_num);
	if (player_num == my_player_num())
		set_gui_state(frontend_state_discard);
	frontend_gui_update();
}
Ejemplo n.º 6
0
void frontend_discard_done(void)
{
	discard_busy = FALSE;
	discard_end();
	if (previous_state != dummy_state) {
		set_gui_state(previous_state);
		previous_state = dummy_state;
	}
}
Ejemplo n.º 7
0
void frontend_discard_remove(gint player_num)
{
	if (discard_busy) {
		discard_player_did(player_num);
		if (player_num == my_player_num())
			set_gui_state(frontend_state_idle);
	}
	frontend_gui_update();
}
Ejemplo n.º 8
0
void frontend_setup(G_GNUC_UNUSED unsigned num_settlements,
		    G_GNUC_UNUSED unsigned num_roads)
{
	if (get_gui_state() == frontend_mode_setup) {
		frontend_gui_update();
		return;
	}
	set_gui_state(frontend_mode_setup);
	play_sound(SOUND_TURN);
}
Ejemplo n.º 9
0
Archivo: main.c Proyecto: bobbens/cwiid
void menuDisconnect_activate(void)
{
	if (cwiid_close(wiimote)) {
		message(GTK_MESSAGE_ERROR, "Error on disconnect", GTK_WINDOW(winMain));
	}
	wiimote = NULL;
	status("No connection");
	clear_widgets();
	set_gui_state();
}
Ejemplo n.º 10
0
void frontend_gold(void)
{
	if (get_gui_state() != frontend_state_gold) {
		gold_choose_begin();
		g_assert(previous_state == dummy_state);
		previous_state = get_gui_state();
		set_gui_state(frontend_state_gold);
		gui_cursor_none();	/* Clear possible cursor */
	}
}
Ejemplo n.º 11
0
Archivo: main.c Proyecto: bobbens/cwiid
void chkAcc_toggled(void)
{
	if (wiimote) {
		set_report_mode();
	}
	if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkAcc))) {
		clear_acc_widgets();
	}
	set_gui_state();
}
Ejemplo n.º 12
0
void frontend_game_over(gint player, gint points)
{
	gui_cursor_none();	/* Clear possible (robber) cursor */
	if (robber_busy) {
		robber_busy = FALSE;
		gui_prompt_hide();
	}
	gameover_create_dlg(player, points);
	set_gui_state(frontend_state_idle);
}
Ejemplo n.º 13
0
Archivo: main.c Proyecto: bobbens/cwiid
void chkIR_toggled(void)
{
	if (wiimote) {
		set_report_mode();
	}
	if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkIR))) {
		clear_ir_data();
	}
	set_gui_state();
}
Ejemplo n.º 14
0
void frontend_quote(gint player_num, gint * they_supply,
		    gint * they_receive)
{
	if (get_gui_state() == frontend_state_quote) {
		quote_begin_again(player_num, they_supply, they_receive);
	} else {
		quote_begin(player_num, they_supply, they_receive);
		set_gui_state(frontend_state_quote);
	}
	frontend_gui_update();
}
Ejemplo n.º 15
0
void frontend_discard(void)
{
	/* set state to idle until we must discard (or discard ends) */
	if (!discard_busy) {
		discard_busy = TRUE;
		discard_begin();
		g_assert(previous_state == dummy_state);
		previous_state = get_gui_state();
		set_gui_state(frontend_state_idle);
		gui_cursor_none();	/* Clear possible cursor */
	}
}
Ejemplo n.º 16
0
Archivo: main.c Proyecto: bobbens/cwiid
void chkExt_toggled(void)
{
	if (wiimote) {
		set_report_mode();
	}
	if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkExt))) {
		clear_nunchuk_widgets();
		clear_classic_widgets();
		clear_motionplus_widgets();
	}
	set_gui_state();
}
Ejemplo n.º 17
0
void frontend_turn(void)
{
	/* if it already is our turn, just update the gui (maybe something
	 * happened), but don't beep */
	if (get_gui_state() == frontend_state_turn
	    || get_gui_state() == frontend_state_trade
	    || get_gui_state() == frontend_state_robber) {
		/* this is in the if, because it gets called from set_gui_state
		 * anyway. */
		frontend_gui_update();
		return;
	}
	set_gui_state(frontend_state_turn);
	play_sound(SOUND_TURN);
}
Ejemplo n.º 18
0
/* monopoly */
static void frontend_state_monopoly(GuiEvent event)
{
	switch (event) {
	case GUI_UPDATE:
		frontend_gui_check(GUI_MONOPOLY, TRUE);
		break;
	case GUI_MONOPOLY:
		cb_choose_monopoly(monopoly_type());
		monopoly_destroy_dlg();
		set_gui_state(frontend_state_turn);
		return;
	default:
		break;
	}
}
Ejemplo n.º 19
0
void frontend_robber(void)
{
	if (!robber_busy) {
		/* Do this only once.  */
		robber_busy = TRUE;
		g_assert(previous_state == dummy_state);
		previous_state = get_gui_state();
	}
	/* These things are redone at undo.  */
	set_gui_state(frontend_state_robber);
	gui_cursor_set(ROBBER_CURSOR, check_move_robber_or_pirate,
		       place_robber_or_pirate_cb, NULL, NULL);
	gui_prompt_show(_("Place the robber."));
	frontend_gui_update();
}
Ejemplo n.º 20
0
/* trade */
static void frontend_state_trade(GuiEvent event)
{
	static gboolean trading = FALSE;
	const QuoteInfo *quote;
	switch (event) {
	case GUI_UPDATE:
		frontend_gui_check(GUI_TRADE_CALL, can_call_for_quotes());
		frontend_gui_check(GUI_TRADE_ACCEPT,
				   trade_valid_selection());
		frontend_gui_check(GUI_TRADE_FINISH, TRUE);
		frontend_gui_check(GUI_TRADE, TRUE);
		gui_cursor_none();	/* Finish single click build */
		break;
	case GUI_TRADE_CALL:
		trading = TRUE;
		trade_new_trade();
		cb_domestic(trade_we_supply(), trade_we_receive());
		return;
	case GUI_TRADE_ACCEPT:
		quote = trade_current_quote();
		g_assert(quote != NULL);
		if (quote->is_domestic) {
			trade_perform_domestic(my_player_num(),
					       quote->var.d.player_num,
					       quote->var.d.quote_num,
					       quote->var.d.supply,
					       quote->var.d.receive);
		} else {
			trade_perform_maritime(quote->var.m.ratio,
					       quote->var.m.supply,
					       quote->var.m.receive);
		}
		return;
	case GUI_TRADE_FINISH:
	case GUI_TRADE:
		/* stop trading.  Only let the network know about it if it
		 * knew we were trading in the first place. */
		if (trading)
			cb_end_trade();
		trading = FALSE;
		trade_finish();
		set_gui_state(frontend_state_turn);
		return;
	default:
		break;
	}
}
Ejemplo n.º 21
0
/* road building */
static void frontend_state_roadbuilding(GuiEvent event)
{
	switch (event) {
	case GUI_UPDATE:
		frontend_gui_check(GUI_UNDO, can_undo());
		frontend_gui_check(GUI_ROAD,
				   road_building_can_build_road());
		frontend_gui_check(GUI_SHIP,
				   road_building_can_build_ship());
		frontend_gui_check(GUI_BRIDGE,
				   road_building_can_build_bridge());
		frontend_gui_check(GUI_FINISH, road_building_can_finish());
		guimap_single_click_set_functions(check_road,
						  build_road_cb,
						  check_ship,
						  build_ship_cb,
						  check_bridge,
						  build_bridge_cb,
						  NULL, NULL, NULL,
						  NULL, NULL, NULL,
						  NULL, NULL, NULL);
		break;
	case GUI_UNDO:
		cb_undo();
		return;
	case GUI_ROAD:
		gui_cursor_set(ROAD_CURSOR, check_road, build_road_cb,
			       NULL, NULL);
		return;
	case GUI_SHIP:
		gui_cursor_set(SHIP_CURSOR, check_ship, build_ship_cb,
			       NULL, NULL);
		return;
	case GUI_BRIDGE:
		gui_cursor_set(BRIDGE_CURSOR, check_bridge,
			       build_bridge_cb, NULL, NULL);
		return;
	case GUI_FINISH:
		cb_end_turn();
		gui_cursor_none();	/* Finish single click build */
		set_gui_state(frontend_state_turn);
		gui_prompt_hide();
		return;
	default:
		break;
	}
}
Ejemplo n.º 22
0
/* year of plenty */
static void frontend_state_plenty(GuiEvent event)
{
	gint plenty[NO_RESOURCE];
	switch (event) {
	case GUI_UPDATE:
		frontend_gui_check(GUI_PLENTY, plenty_can_activate());
		break;
	case GUI_PLENTY:
		plenty_resources(plenty);
		cb_choose_plenty(plenty);
		plenty_destroy_dlg();
		set_gui_state(frontend_state_turn);
		return;
	default:
		break;
	}
}
Ejemplo n.º 23
0
Archivo: main.c Proyecto: bobbens/cwiid
void menuConnect_activate(void)
{
	char reset_bdaddr = 0;

	if (bacmp(&bdaddr, BDADDR_ANY) == 0) {
		reset_bdaddr = 1;
	}
	message(GTK_MESSAGE_INFO,
	        "Put Wiimote in discoverable mode (press 1+2) and press OK",
	         GTK_WINDOW(winMain));
	if ((wiimote = cwiid_open(&bdaddr, CWIID_FLAG_MESG_IFC)) == NULL) {
		message(GTK_MESSAGE_ERROR, "Unable to connect", GTK_WINDOW(winMain));
		status("No connection");
	}
	else if (cwiid_set_mesg_callback(wiimote, &cwiid_callback)) {
		message(GTK_MESSAGE_ERROR, "Error setting callback",
		        GTK_WINDOW(winMain));
		if (cwiid_close(wiimote)) {
			message(GTK_MESSAGE_ERROR, "Error on disconnect",
			        GTK_WINDOW(winMain));
		}
		wiimote = NULL;
		status("No connection");
	}
	else {
		status("Connected");
		if (cwiid_get_acc_cal(wiimote, CWIID_EXT_NONE, &wm_cal)) {
			message(GTK_MESSAGE_ERROR, "Unable to retrieve accelerometer "
			        "calibration", GTK_WINDOW(winMain));
		}
		set_gui_state();
		set_report_mode();
		cwiid_enable(wiimote, CWIID_FLAG_MOTIONPLUS);
		cwiid_request_status(wiimote);
	}

	if (reset_bdaddr) {
		bdaddr = *BDADDR_ANY;
	}
}
Ejemplo n.º 24
0
Archivo: main.c Proyecto: bobbens/cwiid
int main (int argc, char *argv[])
{
	int c;
	char *str_addr;

	gtk_set_locale ();
	gtk_init (&argc, &argv);

	if (!g_thread_supported()) {
		g_thread_init(NULL);
	}
	gdk_threads_init();
	gdk_threads_enter();

	/* cwiid_set_err(err); */

	/* Parse Options */
	while ((c = getopt(argc, argv, OPTSTRING)) != -1) {
		switch (c) {
		case 'h':
			printf(USAGE, argv[0]);
			return 0;
			break;
		case '?':
			return -1;
			break;
		default:
			printf("unknown command-line option: -%c\n", c);
			break;
		}
	}

	/* BDADDR */
	if (optind < argc) {
		if (str2ba(argv[optind], &bdaddr)) {
			printf("invalid bdaddr\n");
			bdaddr = *BDADDR_ANY;
		}
		optind++;
		if (optind < argc) {
			printf("invalid command-line\n");
			printf(USAGE, argv[0]);
			return -1;
		}
	}
	else if ((str_addr = getenv(WIIMOTE_BDADDR)) != NULL) {
		if (str2ba(str_addr, &bdaddr)) {
			printf("invalid address in %s\n", WIIMOTE_BDADDR);
			bdaddr = *BDADDR_ANY;
		}
	}
	else {
		bdaddr = *BDADDR_ANY;
	}		

	/* Create the window */
	winMain = create_winMain();
	winRW = create_winRW();

	/* Lookup Widgets */
	menuConnect = lookup_widget(winMain, "menuConnect");
	menuDisconnect = lookup_widget(winMain, "menuDisconnect");
	menuQuit = lookup_widget(winMain, "menuQuit");
	menuRW = lookup_widget(winMain, "menuRW");
	menuAbout = lookup_widget(winMain, "menuAbout");
	chkAcc = lookup_widget(winMain, "chkAcc");
	chkIR = lookup_widget(winMain, "chkIR");
	chkExt = lookup_widget(winMain, "chkExt");
	chkLED1 = lookup_widget(winMain, "chkLED1");
	chkLED2 = lookup_widget(winMain, "chkLED2");
	chkLED3 = lookup_widget(winMain, "chkLED3");
	chkLED4 = lookup_widget(winMain, "chkLED4");
	chkRumble = lookup_widget(winMain, "chkRumble");
	evUp = lookup_widget(winMain, "evUp");
	evDown = lookup_widget(winMain, "evDown");
	evLeft = lookup_widget(winMain, "evLeft");
	evRight = lookup_widget(winMain, "evRight");
	evA = lookup_widget(winMain, "evA");
	evB = lookup_widget(winMain, "evB");
	evMinus = lookup_widget(winMain, "evMinus");
	evPlus = lookup_widget(winMain, "evPlus");
	evHome = lookup_widget(winMain, "evHome");
	ev1 = lookup_widget(winMain, "ev1");
	ev2 = lookup_widget(winMain, "ev2");
	lblUp = lookup_widget(winMain, "lblUp");
	lblDown = lookup_widget(winMain, "lblDown");
	lblLeft = lookup_widget(winMain, "lblLeft");
	lblRight = lookup_widget(winMain, "lblRight");
	lblA = lookup_widget(winMain, "lblA");
	lblB = lookup_widget(winMain, "lblB");
	lblMinus = lookup_widget(winMain, "lblMinus");
	lblPlus = lookup_widget(winMain, "lblPlus");
	lblHome = lookup_widget(winMain, "lblHome");
	lbl1 = lookup_widget(winMain, "lbl1");
	lbl2 = lookup_widget(winMain, "lbl2");
	lblAccX = lookup_widget(winMain, "lblAccX");
	lblAccY = lookup_widget(winMain, "lblAccY");
	lblAccZ = lookup_widget(winMain, "lblAccZ");
	lblAccXVal = lookup_widget(winMain, "lblAccXVal");
	lblAccYVal = lookup_widget(winMain, "lblAccYVal");
	lblAccZVal = lookup_widget(winMain, "lblAccZVal");
	progAccX = lookup_widget(winMain, "progAccX");
	progAccY = lookup_widget(winMain, "progAccY");
	progAccZ = lookup_widget(winMain, "progAccZ");
	lblAcc = lookup_widget(winMain, "lblAcc");
	lblRoll = lookup_widget(winMain, "lblRoll");
	lblPitch = lookup_widget(winMain, "lblPitch");
	lblAccVal = lookup_widget(winMain, "lblAccVal");
	lblRollVal = lookup_widget(winMain, "lblRollVal");
	lblPitchVal = lookup_widget(winMain, "lblPitchVal");
	lblIR = lookup_widget(winMain, "lblIR");
	drawIR = lookup_widget(winMain, "drawIR");
	lblNC = lookup_widget(winMain, "lblNC");
	drawNCStick = lookup_widget(winMain, "drawNCStick");
	evNCC = lookup_widget(winMain, "evNCC");
	evNCZ = lookup_widget(winMain, "evNCZ");
	lblNCC = lookup_widget(winMain, "lblNCC");
	lblNCZ = lookup_widget(winMain, "lblNCZ");
	lblNCAccX = lookup_widget(winMain, "lblNCAccX");
	lblNCAccY = lookup_widget(winMain, "lblNCAccY");
	lblNCAccZ = lookup_widget(winMain, "lblNCAccZ");
	lblNCAccXVal = lookup_widget(winMain, "lblNCAccXVal");
	lblNCAccYVal = lookup_widget(winMain, "lblNCAccYVal");
	lblNCAccZVal = lookup_widget(winMain, "lblNCAccZVal");
	progNCAccX = lookup_widget(winMain, "progNCAccX");
	progNCAccY = lookup_widget(winMain, "progNCAccY");
	progNCAccZ = lookup_widget(winMain, "progNCAccZ");
	lblNCAcc = lookup_widget(winMain, "lblNCAcc");
	lblNCRoll = lookup_widget(winMain, "lblNCRoll");
	lblNCPitch = lookup_widget(winMain, "lblNCPitch");
	lblNCAccVal = lookup_widget(winMain, "lblNCAccVal");
	lblNCRollVal = lookup_widget(winMain, "lblNCRollVal");
	lblNCPitchVal = lookup_widget(winMain, "lblNCPitchVal");
	evCCUp = lookup_widget(winMain, "evCCUp");
	evCCDown = lookup_widget(winMain, "evCCDown");
	evCCLeft = lookup_widget(winMain, "evCCLeft");
	evCCRight = lookup_widget(winMain, "evCCRight");
	evCCMinus = lookup_widget(winMain, "evCCMinus");
	evCCPlus = lookup_widget(winMain, "evCCPlus");
	evCCHome = lookup_widget(winMain, "evCCHome");
	evCCA = lookup_widget(winMain, "evCCA");
	evCCB = lookup_widget(winMain, "evCCB");
	evCCX = lookup_widget(winMain, "evCCX");
	evCCY = lookup_widget(winMain, "evCCY");
	evCCZL = lookup_widget(winMain, "evCCZL");
	evCCZR = lookup_widget(winMain, "evCCZR");
	lblCCUp = lookup_widget(winMain, "lblCCUp");
	lblCCDown = lookup_widget(winMain, "lblCCDown");
	lblCCLeft = lookup_widget(winMain, "lblCCLeft");
	lblCCRight = lookup_widget(winMain, "lblCCRight");
	lblCCMinus = lookup_widget(winMain, "lblCCMinus");
	lblCCPlus = lookup_widget(winMain, "lblCCPlus");
	lblCCHome = lookup_widget(winMain, "lblCCHome");
	lblCCA = lookup_widget(winMain, "lblCCA");
	lblCCB = lookup_widget(winMain, "lblCCB");
	lblCCX = lookup_widget(winMain, "lblCCX");
	lblCCY = lookup_widget(winMain, "lblCCY");
	lblCCZL = lookup_widget(winMain, "lblCCZL");
	lblCCZR = lookup_widget(winMain, "lblCCZR");
	drawCCLStick = lookup_widget(winMain, "drawCCLStick");
	drawCCRStick = lookup_widget(winMain, "drawCCRStick");
	evCCL = lookup_widget(winMain, "evCCL");
	evCCR = lookup_widget(winMain, "evCCR");
	lblCCL = lookup_widget(winMain, "lblCCL");
	lblCCR = lookup_widget(winMain, "lblCCR");
	lblCCLVal = lookup_widget(winMain, "lblCCLVal");
	lblCCRVal = lookup_widget(winMain, "lblCCRVal");
	progCCL = lookup_widget(winMain, "progCCL");
	progCCR = lookup_widget(winMain, "progCCR");
	lblMPPhi = lookup_widget(winMain, "lblMPPhi");
	lblMPTheta = lookup_widget(winMain, "lblMPTheta");
	lblMPPsi = lookup_widget(winMain, "lblMPPsi");
	lblMPPhiVal = lookup_widget(winMain, "lblMPPhiVal");
	lblMPThetaVal = lookup_widget(winMain, "lblMPThetaVal");
	lblMPPsiVal = lookup_widget(winMain, "lblMPPsiVal");
	evMPPhiSlow = lookup_widget(winMain, "evMPPhiSlow");
	evMPThetaSlow = lookup_widget(winMain, "evMPThetaSlow");
	evMPPsiSlow = lookup_widget(winMain, "evMPPsiSlow");
	lblMPPhiSlow = lookup_widget(winMain, "lblMPPhiSlow");
	lblMPThetaSlow = lookup_widget(winMain, "lblMPThetaSlow");
	lblMPPsiSlow = lookup_widget(winMain, "lblMPPsiSlow");
	progMPPhi = lookup_widget(winMain, "progMPPhi");
	progMPTheta = lookup_widget(winMain, "progMPTheta");
	progMPPsi = lookup_widget(winMain, "progMPPsi");
	statConnection = lookup_widget(winMain, "statConnection");
	statBattery = lookup_widget(winMain, "statBattery");
	statExtension = lookup_widget(winMain, "statExtension");
	txtReadOffset = lookup_widget(winRW, "txtReadOffset");
	txtReadLen = lookup_widget(winRW, "txtReadLen");
	radReadEEPROM = lookup_widget(winRW, "radReadEEPROM");
	radReadReg = lookup_widget(winRW, "radReadReg");
	btnRead = lookup_widget(winRW, "btnRead");
	txtWriteOffset = lookup_widget(winRW, "txtWriteOffset");
	txtWriteData = lookup_widget(winRW, "txtWriteData");
	radWriteEEPROM = lookup_widget(winRW, "radWriteEEPROM");
	radWriteReg = lookup_widget(winRW, "radWriteReg");
	btnWrite = lookup_widget(winRW, "btnWrite");
	tvRW = lookup_widget(winRW, "tvRW");
	btnRWClose = lookup_widget(winRW, "btnRWClose");
	btnBeep = lookup_widget(winMain, "btnBeep");
	
	tbRW = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tvRW));

	/* Connect Callbacks */
	g_signal_connect(winMain, "delete_event", G_CALLBACK(winMain_delete_event),
	                 NULL);
	g_signal_connect(winRW, "delete_event", G_CALLBACK(winRW_delete_event),
	                 NULL);
	g_signal_connect(menuConnect, "activate", G_CALLBACK(menuConnect_activate),
	                 NULL);
	g_signal_connect(menuDisconnect, "activate",
	                 G_CALLBACK(menuDisconnect_activate), NULL);
	g_signal_connect(menuQuit, "activate", G_CALLBACK(menuQuit_activate),
	                 NULL);
	g_signal_connect(menuRW, "activate", G_CALLBACK(menuRW_activate), NULL);
	g_signal_connect(menuAbout, "activate", G_CALLBACK(menuAbout_activate),
	                 NULL);
	g_signal_connect(chkAcc, "toggled", G_CALLBACK(chkAcc_toggled), NULL);
	g_signal_connect(chkIR, "toggled", G_CALLBACK(chkIR_toggled), NULL);
	g_signal_connect(chkExt, "toggled", G_CALLBACK(chkExt_toggled), NULL);
	g_signal_connect(chkLED1, "toggled", G_CALLBACK(chkLED_toggled), NULL);
	g_signal_connect(chkLED2, "toggled", G_CALLBACK(chkLED_toggled), NULL);
	g_signal_connect(chkLED3, "toggled", G_CALLBACK(chkLED_toggled), NULL);
	g_signal_connect(chkLED4, "toggled", G_CALLBACK(chkLED_toggled), NULL);
	g_signal_connect(chkRumble, "toggled", G_CALLBACK(chkRumble_toggled),
	                 NULL);
	g_signal_connect(drawIR, "expose_event",
	                 G_CALLBACK(drawIR_expose_event), NULL);
	g_signal_connect(drawNCStick, "expose_event",
	                 G_CALLBACK(drawStick_expose_event), &nc_stick);
	g_signal_connect(drawCCLStick, "expose_event",
	                 G_CALLBACK(drawStick_expose_event), &cc_l_stick);
	g_signal_connect(drawCCRStick, "expose_event",
	                 G_CALLBACK(drawStick_expose_event), &cc_r_stick);
	g_signal_connect(btnRead, "clicked", G_CALLBACK(btnRead_clicked), NULL);
	g_signal_connect(btnWrite, "clicked", G_CALLBACK(btnWrite_clicked), NULL);
	g_signal_connect(btnRWClose, "clicked", G_CALLBACK(btnRWClose_clicked),
	                 NULL);
	g_signal_connect(btnBeep, "clicked", G_CALLBACK(btnBeep_clicked), NULL);

	/* Initialize */
	btn_on.red = 0; btn_on.blue = 0; btn_on.green = 0xFFFF;
	btn_off = gtk_widget_get_style(evUp)->bg[GTK_STATE_NORMAL];

	nc_stick.max = 0xFF;
	cc_l_stick.max = CWIID_CLASSIC_L_STICK_MAX;
	cc_r_stick.max = CWIID_CLASSIC_R_STICK_MAX;

	set_gui_state();
	clear_widgets();
	status("No connection");

	gtk_widget_show(winMain);

	gtk_main();
	gdk_threads_leave();
	return 0;
}
Ejemplo n.º 25
0
void frontend_quote_end(void)
{
	quote_finish();
	set_gui_state(frontend_state_idle);
}
Ejemplo n.º 26
0
/* turn */
static void frontend_state_turn(GuiEvent event)
{
	switch (event) {
	case GUI_UPDATE:
		frontend_gui_check(GUI_ROLL, !have_rolled_dice());
		frontend_gui_check(GUI_UNDO, can_undo());
		frontend_gui_check(GUI_ROAD, turn_can_build_road());
		frontend_gui_check(GUI_SHIP, turn_can_build_ship());
		frontend_gui_check(GUI_MOVE_SHIP, turn_can_move_ship());
		frontend_gui_check(GUI_BRIDGE, turn_can_build_bridge());
		frontend_gui_check(GUI_SETTLEMENT,
				   turn_can_build_settlement());
		frontend_gui_check(GUI_CITY, turn_can_build_city());
		frontend_gui_check(GUI_CITY_WALL,
				   turn_can_build_city_wall());
		frontend_gui_check(GUI_TRADE, turn_can_trade());
		frontend_gui_check(GUI_PLAY_DEVELOP,
				   can_play_develop(develop_current_idx
						    ()));
		frontend_gui_check(GUI_BUY_DEVELOP, can_buy_develop());
		frontend_gui_check(GUI_FINISH, have_rolled_dice());

		guimap_single_click_set_functions(check_road,
						  build_road_cb,
						  check_ship,
						  build_ship_cb,
						  check_bridge,
						  build_bridge_cb,
						  check_settlement,
						  build_settlement_cb,
						  check_city,
						  build_city_cb,
						  check_city_wall,
						  build_city_wall_cb,
						  check_ship_move,
						  move_ship_cb,
						  cancel_move_ship_cb);
		break;
	case GUI_ROLL:
		cb_roll();
		break;
	case GUI_UNDO:
		cb_undo();
		return;
	case GUI_ROAD:
		gui_cursor_set(ROAD_CURSOR, check_road, build_road_cb,
			       NULL, NULL);
		return;
	case GUI_SHIP:
		gui_cursor_set(SHIP_CURSOR, check_ship, build_ship_cb,
			       NULL, NULL);
		return;
	case GUI_MOVE_SHIP:
		gui_cursor_set(SHIP_CURSOR, check_ship_move, move_ship_cb,
			       NULL, NULL);
		return;
	case GUI_BRIDGE:
		gui_cursor_set(BRIDGE_CURSOR, check_bridge,
			       build_bridge_cb, NULL, NULL);
		return;
	case GUI_SETTLEMENT:
		gui_cursor_set(SETTLEMENT_CURSOR, check_settlement,
			       build_settlement_cb, NULL, NULL);
		return;
	case GUI_CITY:
		gui_cursor_set(CITY_CURSOR, check_city, build_city_cb,
			       NULL, NULL);
		return;
	case GUI_CITY_WALL:
		gui_cursor_set(CITY_WALL_CURSOR, check_city_wall,
			       build_city_wall_cb, NULL, NULL);
		return;
	case GUI_TRADE:
		trade_begin();
		set_gui_state(frontend_state_trade);
		return;
	case GUI_PLAY_DEVELOP:
		cb_play_develop(develop_current_idx());
		return;
	case GUI_BUY_DEVELOP:
		cb_buy_develop();
		return;
	case GUI_FINISH:
		cb_end_turn();
		gui_cursor_none();	/* Finish single click build */
		set_gui_state(frontend_state_idle);
		return;
	default:
		break;
	}
}
Ejemplo n.º 27
0
static void frontend_state_special_building_phase(GuiEvent event)
{
	switch (event) {
	case GUI_UPDATE:
		frontend_gui_check(GUI_ROLL, FALSE);
		frontend_gui_check(GUI_UNDO, FALSE);
		frontend_gui_check(GUI_ROAD, turn_can_build_road());
		frontend_gui_check(GUI_SHIP, turn_can_build_ship());
		frontend_gui_check(GUI_MOVE_SHIP, FALSE);
		frontend_gui_check(GUI_BRIDGE, turn_can_build_bridge());
		frontend_gui_check(GUI_SETTLEMENT,
				   turn_can_build_settlement());
		frontend_gui_check(GUI_CITY, turn_can_build_city());
		frontend_gui_check(GUI_CITY_WALL,
				   turn_can_build_city_wall());
		frontend_gui_check(GUI_TRADE, FALSE);
		frontend_gui_check(GUI_PLAY_DEVELOP, FALSE);
		frontend_gui_check(GUI_BUY_DEVELOP, FALSE);
		frontend_gui_check(GUI_FINISH, FALSE); // don't allow clicking finish during SBP

		guimap_single_click_set_functions(check_road,
						  build_road_cb,
						  check_ship,
						  build_ship_cb,
						  check_bridge,
						  build_bridge_cb,
						  check_settlement,
						  build_settlement_cb,
						  check_city,
						  build_city_cb,
						  check_city_wall,
						  build_city_wall_cb,
						  check_ship_move,
						  move_ship_cb,
						  cancel_move_ship_cb);
		break;
	case GUI_UNDO:
		cb_undo();
		return;
	case GUI_ROAD:
		gui_cursor_set(ROAD_CURSOR, check_road, build_road_cb,
			       NULL, NULL);
		return;
	case GUI_SHIP:
		gui_cursor_set(SHIP_CURSOR, check_ship, build_ship_cb,
			       NULL, NULL);
		return;
	case GUI_BRIDGE:
		gui_cursor_set(BRIDGE_CURSOR, check_bridge,
			       build_bridge_cb, NULL, NULL);
		return;
	case GUI_SETTLEMENT:
		gui_cursor_set(SETTLEMENT_CURSOR, check_settlement,
			       build_settlement_cb, NULL, NULL);
		return;
	case GUI_CITY:
		gui_cursor_set(CITY_CURSOR, check_city, build_city_cb,
			       NULL, NULL);
		return;
	case GUI_CITY_WALL:
		gui_cursor_set(CITY_WALL_CURSOR, check_city_wall,
			       build_city_wall_cb, NULL, NULL);
		return;
	case GUI_FINISH:
		cb_end_turn();
		gui_cursor_none();	/* Finish single click build */
		set_gui_state(frontend_state_idle);
		return;
	default:
		break;
	}
}
Ejemplo n.º 28
0
void frontend_special_building_phase(void)
{
	set_gui_state(frontend_state_special_building_phase);
}
Ejemplo n.º 29
0
void frontend_monopoly(void)
{
	monopoly_create_dlg();
	set_gui_state(frontend_state_monopoly);
}
Ejemplo n.º 30
0
void frontend_plenty(const gint * bank)
{
	plenty_create_dlg(bank);
	set_gui_state(frontend_state_plenty);
}