src/viewport.cpp
branchNewGRF_ports
changeset 10991 d8811e327d12
parent 10731 67db0d431d5e
child 10994 cd9968b6f96b
equal deleted inserted replaced
10731:67db0d431d5e 10991:d8811e327d12
  1043 				if (bottom > t->sign.top &&
  1043 				if (bottom > t->sign.top &&
  1044 						top    < t->sign.top + 12 &&
  1044 						top    < t->sign.top + 12 &&
  1045 						right  > t->sign.left &&
  1045 						right  > t->sign.left &&
  1046 						left   < t->sign.left + t->sign.width_1) {
  1046 						left   < t->sign.left + t->sign.width_1) {
  1047 					AddStringToDraw(t->sign.left + 1, t->sign.top + 1,
  1047 					AddStringToDraw(t->sign.left + 1, t->sign.top + 1,
  1048 						_settings.gui.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL,
  1048 						_settings_client.gui.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL,
  1049 						t->index, t->population);
  1049 						t->index, t->population);
  1050 				}
  1050 				}
  1051 			}
  1051 			}
  1052 			break;
  1052 			break;
  1053 
  1053 
  1059 				if (bottom > t->sign.top &&
  1059 				if (bottom > t->sign.top &&
  1060 						top    < t->sign.top + 24 &&
  1060 						top    < t->sign.top + 24 &&
  1061 						right  > t->sign.left &&
  1061 						right  > t->sign.left &&
  1062 						left   < t->sign.left + t->sign.width_1 * 2) {
  1062 						left   < t->sign.left + t->sign.width_1 * 2) {
  1063 					AddStringToDraw(t->sign.left + 1, t->sign.top + 1,
  1063 					AddStringToDraw(t->sign.left + 1, t->sign.top + 1,
  1064 						_settings.gui.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL,
  1064 						_settings_client.gui.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL,
  1065 						t->index, t->population);
  1065 						t->index, t->population);
  1066 				}
  1066 				}
  1067 			}
  1067 			}
  1068 			break;
  1068 			break;
  1069 
  1069 
  1614 
  1614 
  1615 		int delta_x = w->viewport->dest_scrollpos_x - w->viewport->scrollpos_x;
  1615 		int delta_x = w->viewport->dest_scrollpos_x - w->viewport->scrollpos_x;
  1616 		int delta_y = w->viewport->dest_scrollpos_y - w->viewport->scrollpos_y;
  1616 		int delta_y = w->viewport->dest_scrollpos_y - w->viewport->scrollpos_y;
  1617 
  1617 
  1618 		if (delta_x != 0 || delta_y != 0) {
  1618 		if (delta_x != 0 || delta_y != 0) {
  1619 			if (_settings.gui.smooth_scroll) {
  1619 			if (_settings_client.gui.smooth_scroll) {
  1620 				int max_scroll = ScaleByMapSize1D(512);
  1620 				int max_scroll = ScaleByMapSize1D(512);
  1621 				/* Not at our desired positon yet... */
  1621 				/* Not at our desired positon yet... */
  1622 				w->viewport->scrollpos_x += Clamp(delta_x / 4, -max_scroll, max_scroll);
  1622 				w->viewport->scrollpos_x += Clamp(delta_x / 4, -max_scroll, max_scroll);
  1623 				w->viewport->scrollpos_y += Clamp(delta_y / 4, -max_scroll, max_scroll);
  1623 				w->viewport->scrollpos_y += Clamp(delta_y / 4, -max_scroll, max_scroll);
  1624 			} else {
  1624 			} else {
  2533 				} //return px == py || px == py + 16;
  2533 				} //return px == py || px == py + 16;
  2534 			}
  2534 			}
  2535 		}
  2535 		}
  2536 	}
  2536 	}
  2537 
  2537 
  2538 	if (_settings.gui.measure_tooltip) {
  2538 	if (_settings_client.gui.measure_tooltip) {
  2539 		TileIndex t0 = TileVirtXY(thd->selstart.x, thd->selstart.y);
  2539 		TileIndex t0 = TileVirtXY(thd->selstart.x, thd->selstart.y);
  2540 		TileIndex t1 = TileVirtXY(x, y);
  2540 		TileIndex t1 = TileVirtXY(x, y);
  2541 		uint distance = DistanceManhattan(t0, t1) + 1;
  2541 		uint distance = DistanceManhattan(t0, t1) + 1;
  2542 		byte index = 0;
  2542 		byte index = 0;
  2543 		uint64 params[2];
  2543 		uint64 params[2];
  2613 		case VPM_FIX_Y: /* drag in X direction */
  2613 		case VPM_FIX_Y: /* drag in X direction */
  2614 			y = sy;
  2614 			y = sy;
  2615 			style = HT_DIR_X;
  2615 			style = HT_DIR_X;
  2616 
  2616 
  2617 calc_heightdiff_single_direction:;
  2617 calc_heightdiff_single_direction:;
  2618 			if (_settings.gui.measure_tooltip) {
  2618 			if (_settings_client.gui.measure_tooltip) {
  2619 				TileIndex t0 = TileVirtXY(sx, sy);
  2619 				TileIndex t0 = TileVirtXY(sx, sy);
  2620 				TileIndex t1 = TileVirtXY(x, y);
  2620 				TileIndex t1 = TileVirtXY(x, y);
  2621 				uint distance = DistanceManhattan(t0, t1) + 1;
  2621 				uint distance = DistanceManhattan(t0, t1) + 1;
  2622 				byte index = 0;
  2622 				byte index = 0;
  2623 				uint64 params[2];
  2623 				uint64 params[2];
  2641 			int limit = (_thd.sizelimit - 1) * TILE_SIZE;
  2641 			int limit = (_thd.sizelimit - 1) * TILE_SIZE;
  2642 			x = sx + Clamp(x - sx, -limit, limit);
  2642 			x = sx + Clamp(x - sx, -limit, limit);
  2643 			y = sy + Clamp(y - sy, -limit, limit);
  2643 			y = sy + Clamp(y - sy, -limit, limit);
  2644 			} /* Fallthrough */
  2644 			} /* Fallthrough */
  2645 		case VPM_X_AND_Y: { /* drag an X by Y area */
  2645 		case VPM_X_AND_Y: { /* drag an X by Y area */
  2646 			if (_settings.gui.measure_tooltip) {
  2646 			if (_settings_client.gui.measure_tooltip) {
  2647 				static const StringID measure_strings_area[] = {
  2647 				static const StringID measure_strings_area[] = {
  2648 					STR_NULL, STR_NULL, STR_MEASURE_AREA, STR_MEASURE_AREA_HEIGHTDIFF
  2648 					STR_NULL, STR_NULL, STR_MEASURE_AREA, STR_MEASURE_AREA_HEIGHTDIFF
  2649 				};
  2649 				};
  2650 
  2650 
  2651 				TileIndex t0 = TileVirtXY(sx, sy);
  2651 				TileIndex t0 = TileVirtXY(sx, sy);
  2781 {
  2781 {
  2782 	_thd.FSMportLayout = NULL;  // ensure irregular airport support disabled
  2782 	_thd.FSMportLayout = NULL;  // ensure irregular airport support disabled
  2783 	_thd.FSMportMask = NULL;
  2783 	_thd.FSMportMask = NULL;
  2784 	SetObjectToPlace(SPR_CURSOR_MOUSE, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
  2784 	SetObjectToPlace(SPR_CURSOR_MOUSE, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
  2785 }
  2785 }
       
  2786 
       
  2787 
       
  2788 void SaveViewportBeforeSaveGame()
       
  2789 {
       
  2790 	const Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
       
  2791 
       
  2792 	if (w != NULL) {
       
  2793 		_saved_scrollpos_x = w->viewport->scrollpos_x;
       
  2794 		_saved_scrollpos_y = w->viewport->scrollpos_y;
       
  2795 		_saved_scrollpos_zoom = w->viewport->zoom;
       
  2796 	}
       
  2797 }
       
  2798 
       
  2799 void ResetViewportAfterLoadGame()
       
  2800 {
       
  2801 	Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
       
  2802 
       
  2803 	w->viewport->scrollpos_x = _saved_scrollpos_x;
       
  2804 	w->viewport->scrollpos_y = _saved_scrollpos_y;
       
  2805 	w->viewport->dest_scrollpos_x = _saved_scrollpos_x;
       
  2806 	w->viewport->dest_scrollpos_y = _saved_scrollpos_y;
       
  2807 
       
  2808 	ViewPort *vp = w->viewport;
       
  2809 	vp->zoom = min(_saved_scrollpos_zoom, ZOOM_LVL_MAX);
       
  2810 	vp->virtual_width = ScaleByZoom(vp->width, vp->zoom);
       
  2811 	vp->virtual_height = ScaleByZoom(vp->height, vp->zoom);
       
  2812 
       
  2813 	DoZoomInOutWindow(ZOOM_NONE, w); // update button status
       
  2814 	MarkWholeScreenDirty();
       
  2815 }