void identity_reset(void) { die1_num = 0; die2_num = 0; /* 50 seems to give a good upper limit */ if (identity_area != NULL) calculate_optimum_size(identity_area, 50); }
void identity_reset(void) { gint i; for (i = 0; i < 2; i++) { die_num[i] = 0; }; /* 50 seems to give a good upper limit */ if (identity_area != NULL) calculate_optimum_size(identity_area, 50); }
static void calculate_optimum_size(GtkWidget * area, gint size) { const GameParams *game_params = get_game_params(); GdkPoint points[MAX_POINTS]; Polygon poly; gint new_size; gint fixedwidth; /* Size of fixed part (digits + spacing) */ gint variablewidth; /* Size of variable part (polygons) */ if (game_params == NULL) return; guimap_scale_with_radius(&bogus_map, size); if (bogus_map.hex_radius <= MIN_HEX_RADIUS) return; fixedwidth = 0; variablewidth = 0; poly.points = points; if (game_params->num_build_type[BUILD_ROAD] > 0) { poly.num_points = MAX_POINTS; guimap_road_polygon(&bogus_map, NULL, &poly); calculate_width(area, &poly, stock_num_roads(), &fixedwidth, &variablewidth); } if (game_params->num_build_type[BUILD_SHIP] > 0) { poly.num_points = MAX_POINTS; guimap_ship_polygon(&bogus_map, NULL, &poly); calculate_width(area, &poly, stock_num_ships(), &fixedwidth, &variablewidth); } if (game_params->num_build_type[BUILD_BRIDGE] > 0) { poly.num_points = MAX_POINTS; guimap_bridge_polygon(&bogus_map, NULL, &poly); calculate_width(area, &poly, stock_num_bridges(), &fixedwidth, &variablewidth); } if (game_params->num_build_type[BUILD_SETTLEMENT] > 0) { poly.num_points = MAX_POINTS; guimap_settlement_polygon(&bogus_map, NULL, &poly); calculate_width(area, &poly, stock_num_settlements(), &fixedwidth, &variablewidth); } if (game_params->num_build_type[BUILD_CITY] > 0) { poly.num_points = MAX_POINTS; guimap_city_polygon(&bogus_map, NULL, &poly); calculate_width(area, &poly, stock_num_cities(), &fixedwidth, &variablewidth); } if (game_params->num_build_type[BUILD_CITY_WALL] > 0) { poly.num_points = MAX_POINTS; guimap_city_wall_polygon(&bogus_map, NULL, &poly); calculate_width(area, &poly, stock_num_city_walls(), &fixedwidth, &variablewidth); } new_size = bogus_map.hex_radius * (area->allocation.width - 75 - fixedwidth) / variablewidth; if (new_size < bogus_map.hex_radius) { calculate_optimum_size(area, new_size); } }
static void identity_resize_cb(GtkWidget * area, G_GNUC_UNUSED GtkAllocation * allocation, G_GNUC_UNUSED gpointer user_data) { calculate_optimum_size(area, 50); }