src/smallmap_gui.cpp
branchnoai
changeset 10294 7798ae816af8
parent 10249 58810805030e
child 10455 22c441f5adf9
equal deleted inserted replaced
10292:7856e972f8aa 10294:7798ae816af8
   680 		Vehicle *v;
   680 		Vehicle *v;
   681 		bool skip;
   681 		bool skip;
   682 		byte color;
   682 		byte color;
   683 
   683 
   684 		FOR_ALL_VEHICLES(v) {
   684 		FOR_ALL_VEHICLES(v) {
   685 			if (v->type != VEH_SPECIAL &&
   685 			if (v->type != VEH_EFFECT &&
   686 					(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) {
   686 					(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) {
   687 				/* Remap into flat coordinates. */
   687 				/* Remap into flat coordinates. */
   688 				Point pt = RemapCoords(
   688 				Point pt = RemapCoords(
   689 					v->x_pos / TILE_SIZE - WP(w, smallmap_d).scroll_x / TILE_SIZE, // divide each one separately because (a-b)/c != a/c-b/c in integer world
   689 					v->x_pos / TILE_SIZE - WP(w, smallmap_d).scroll_x / TILE_SIZE, // divide each one separately because (a-b)/c != a/c-b/c in integer world
   690 					v->y_pos / TILE_SIZE - WP(w, smallmap_d).scroll_y / TILE_SIZE, //    dtto
   690 					v->y_pos / TILE_SIZE - WP(w, smallmap_d).scroll_y / TILE_SIZE, //    dtto
  1106 };
  1106 };
  1107 
  1107 
  1108 static void ExtraViewPortWndProc(Window *w, WindowEvent *e)
  1108 static void ExtraViewPortWndProc(Window *w, WindowEvent *e)
  1109 {
  1109 {
  1110 	switch (e->event) {
  1110 	switch (e->event) {
  1111 	case WE_CREATE: /* Disable zoom in button */
  1111 	case WE_CREATE: // Disable zoom in button
  1112 		/* New viewport start at (zero,zero) */
  1112 		/* New viewport start at (zero,zero) */
  1113 		AssignWindowViewport(w, 3, 17, w->widget[4].right - w->widget[4].left - 1, w->widget[4].bottom - w->widget[4].top - 1, 0, ZOOM_LVL_VIEWPORT);
  1113 		InitializeWindowViewport(w, 3, 17, w->widget[4].right - w->widget[4].left - 1, w->widget[4].bottom - w->widget[4].top - 1, 0, ZOOM_LVL_VIEWPORT);
  1114 
  1114 
  1115 		w->DisableWidget(5);
  1115 		w->DisableWidget(5);
  1116 		break;
  1116 		break;
  1117 
  1117 
  1118 	case WE_PAINT:
  1118 	case WE_PAINT:
  1119 		// set the number in the title bar
  1119 		/* set the number in the title bar */
  1120 		SetDParam(0, w->window_number + 1);
  1120 		SetDParam(0, w->window_number + 1);
  1121 
  1121 
  1122 		DrawWindowWidgets(w);
  1122 		DrawWindowWidgets(w);
  1123 		DrawWindowViewport(w);
  1123 		DrawWindowViewport(w);
  1124 		break;
  1124 		break;
  1126 	case WE_CLICK:
  1126 	case WE_CLICK:
  1127 		switch (e->we.click.widget) {
  1127 		switch (e->we.click.widget) {
  1128 			case 5: DoZoomInOutWindow(ZOOM_IN,  w); break;
  1128 			case 5: DoZoomInOutWindow(ZOOM_IN,  w); break;
  1129 			case 6: DoZoomInOutWindow(ZOOM_OUT, w); break;
  1129 			case 6: DoZoomInOutWindow(ZOOM_OUT, w); break;
  1130 
  1130 
  1131 		case 7: { /* location button (move main view to same spot as this view) 'Paste Location' */
  1131 		case 7: { // location button (move main view to same spot as this view) 'Paste Location'
  1132 			Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0);
  1132 			Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0);
  1133 			int x = WP(w, vp_d).scrollpos_x; // Where is the main looking at
  1133 			int x = WP(w, vp_d).scrollpos_x; // Where is the main looking at
  1134 			int y = WP(w, vp_d).scrollpos_y;
  1134 			int y = WP(w, vp_d).scrollpos_y;
  1135 
  1135 
  1136 			/* set this view to same location. Based on the center, adjusting for zoom */
  1136 			/* set this view to same location. Based on the center, adjusting for zoom */
  1137 			WP(w2, vp_d).dest_scrollpos_x =  x - (w2->viewport->virtual_width -  w->viewport->virtual_width) / 2;
  1137 			WP(w2, vp_d).dest_scrollpos_x =  x - (w2->viewport->virtual_width -  w->viewport->virtual_width) / 2;
  1138 			WP(w2, vp_d).dest_scrollpos_y =  y - (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
  1138 			WP(w2, vp_d).dest_scrollpos_y =  y - (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
  1139 		} break;
  1139 		} break;
  1140 
  1140 
  1141 		case 8: { /* inverse location button (move this view to same spot as main view) 'Copy Location' */
  1141 		case 8: { // inverse location button (move this view to same spot as main view) 'Copy Location'
  1142 			const Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0);
  1142 			const Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0);
  1143 			int x = WP(w2, const vp_d).scrollpos_x;
  1143 			int x = WP(w2, const vp_d).scrollpos_x;
  1144 			int y = WP(w2, const vp_d).scrollpos_y;
  1144 			int y = WP(w2, const vp_d).scrollpos_y;
  1145 
  1145 
  1146 			WP(w, vp_d).dest_scrollpos_x =  x + (w2->viewport->virtual_width -  w->viewport->virtual_width) / 2;
  1146 			WP(w, vp_d).dest_scrollpos_x =  x + (w2->viewport->virtual_width -  w->viewport->virtual_width) / 2;