Esempio n. 1
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;
	}
}
Esempio n. 2
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;
	}
}
Esempio n. 3
0
void frontend_steal_building(void)
{
	MapElement hex;
	hex.hex = map_robber_hex(callbacks.get_map());

	gui_cursor_set(STEAL_BUILDING_CURSOR, can_building_be_robbed,
		       rob_building, NULL, &hex);
	gui_prompt_show(_("Select the building to steal from."));
}
Esempio n. 4
0
void frontend_steal_ship(void)
{
	MapElement hex;
	hex.hex = map_pirate_hex(callbacks.get_map());

	gui_cursor_set(STEAL_SHIP_CURSOR, can_edge_be_robbed, rob_edge,
		       NULL, &hex);
	gui_prompt_show(_("Select the ship to steal from."));
}
Esempio n. 5
0
void move_ship_cb(MapElement edge, G_GNUC_UNUSED MapElement extra)
{
	MapElement ship_from;
	ship_from.edge = edge.edge;
	callbacks.instructions(_("Select a new location for the ship."));
	gui_prompt_show(_("Select a new location for the ship."));
	gui_cursor_set(SHIP_CURSOR, can_ship_be_moved_to, do_move_ship_cb,
		       cancel_move_ship_cb, &ship_from);
}
Esempio n. 6
0
File: gfx.c Progetto: bentley/puNES
void gfx_cursor_set(void) {
#if defined (__WIN32__)
	gui_cursor_set();
#else
	if (input_zapper_is_connected((_port *) &port) == TRUE) {
		SDL_SetCursor(cursor.target);
	} else {
		SDL_SetCursor(cursor.org);
	}
#endif
}
Esempio n. 7
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();
}
Esempio n. 8
0
File: gfx.c Progetto: bentley/puNES
void gfx_cursor_init(void) {
#if defined (__WIN32__)
	gui_cursor_init();
	gui_cursor_set();
#else
	memset(&cursor, 0x00, sizeof(cursor));

	cursor.org = SDL_GetCursor();

	if ((cursor.target = init_system_cursor(target_32x32_xpm)) == NULL) {
	//if ((cursor = init_system_cursor(target_48x48_xpm)) == NULL) {
		cursor.target = cursor.org;
		printf("SDL_Init failed: %s\n", SDL_GetError());
	}

	gfx_cursor_set();
#endif
}
Esempio n. 9
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;
	}
}
Esempio n. 10
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;
	}
}