Changeset - r9094:b8b4d5f9a3d8
[Not reviewed]
master
0 9 0
peter1138 - 16 years ago 2008-05-05 11:36:43
peter1138@openttd.org
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
9 files changed with 79 insertions and 24 deletions:
0 comments (0 inline, 0 general)
src/depot_gui.cpp
Show inline comments
 
@@ -810,25 +810,31 @@ static void DepotWndProc(Window *w, Wind
 
						static const CursorID clone_icons[] = {
 
							SPR_CURSOR_CLONE_TRAIN, SPR_CURSOR_CLONE_ROADVEH,
 
							SPR_CURSOR_CLONE_SHIP, SPR_CURSOR_CLONE_AIRPLANE
 
						};
 

	
 
						_place_clicked_vehicle = NULL;
 
						SetObjectToPlaceWnd(clone_icons[WP(w, depot_d).type], PAL_NONE, VHM_RECT, w);
 
					} else {
 
						ResetObjectToPlace();
 
					}
 
						break;
 

	
 
				case DEPOT_WIDGET_LOCATION: ScrollMainWindowToTile(w->window_number); break;
 
				case DEPOT_WIDGET_LOCATION:
 
					if (_ctrl_pressed) {
 
						ShowExtraViewPortWindow(w->window_number);
 
					} else {
 
						ScrollMainWindowToTile(w->window_number);
 
					}
 
					break;
 

	
 
				case DEPOT_WIDGET_STOP_ALL:
 
				case DEPOT_WIDGET_START_ALL:
 
					DoCommandP(w->window_number, 0, WP(w, depot_d).type | (e->we.click.widget == DEPOT_WIDGET_START_ALL ? (1 << 5) : 0), NULL, CMD_MASS_START_STOP);
 
					break;
 

	
 
				case DEPOT_WIDGET_SELL_ALL:
 
					/* Only open the confimation window if there are anything to sell */
 
					if (WP(w, depot_d).engine_count != 0 || WP(w, depot_d).wagon_count != 0) {
 
						static const StringID confirm_captions[] = {
 
							STR_8800_TRAIN_DEPOT,
 
							STR_9003_ROAD_VEHICLE_DEPOT,
src/gui.h
Show inline comments
 
@@ -83,25 +83,25 @@ void ShowTimetableWindow(const Vehicle *
 
void PlaceLandBlockInfo();
 
void ShowAboutWindow();
 
void ShowBuildTreesToolbar();
 
void ShowBuildTreesScenToolbar();
 
void ShowTownDirectory();
 
void ShowIndustryDirectory();
 
void ShowSubsidiesList();
 

	
 
void ShowEstimatedCostOrIncome(Money cost, int x, int y);
 
void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y);
 

	
 
void ShowSmallMap();
 
void ShowExtraViewPortWindow();
 
void ShowExtraViewPortWindow(TileIndex tile = INVALID_TILE);
 
void SetVScrollCount(Window *w, int num);
 
void SetVScroll2Count(Window *w, int num);
 
void SetHScrollCount(Window *w, int num);
 

	
 
void BuildFileList();
 
void SetFiosType(const byte fiostype);
 

	
 
/* FIOS_TYPE_FILE, FIOS_TYPE_OLDFILE etc. different colours */
 
extern const TextColour _fios_colors[];
 

	
 
/* bridge_gui.cpp */
 
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte bridge_type);
src/industry_gui.cpp
Show inline comments
 
@@ -559,25 +559,29 @@ static void IndustryViewWndProc(Window *
 
					WP(w, indview_d).clicked_line = line + 1;
 
					WP(w, indview_d).clicked_button = (x < 15 ? 1 : 2);
 
				} else if (IsInsideMM(x, 34, 160)) {
 
					/* clicked the text */
 
					WP(w, indview_d).editbox_line = line;
 
					SetDParam(0, i->production_rate[line] * 8);
 
					ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_GAME_PRODUCTION, 10, 100, w, CS_ALPHANUMERAL);
 
				}
 
			}
 
		} break;
 
		case IVW_GOTO:
 
			i = GetIndustry(w->window_number);
 
			ScrollMainWindowToTile(i->xy + TileDiffXY(1, 1));
 
			if (_ctrl_pressed) {
 
				ShowExtraViewPortWindow(i->xy + TileDiffXY(1, 1));
 
			} else {
 
				ScrollMainWindowToTile(i->xy + TileDiffXY(1, 1));
 
			}
 
		} break;
 

	
 
		}
 
		break;
 
	case WE_TIMEOUT:
 
		WP(w, indview_d).clicked_line = 0;
 
		WP(w, indview_d).clicked_button = 0;
 
		SetWindowDirty(w);
 
		break;
 

	
 
	case WE_ON_EDIT_TEXT:
 
		if (e->we.edittext.str[0] != '\0') {
 
@@ -844,25 +848,29 @@ static void IndustryDirectoryWndProc(Win
 
				_industry_sort_order = _industry_sort_order == 6 ? 7 : 6;
 
				_industry_sort_dirty = true;
 
				SetWindowDirty(w);
 
			} break;
 

	
 
			case IDW_INDUSRTY_LIST: {
 
				int y = (e->we.click.pt.y - 28) / 10;
 
				uint16 p;
 

	
 
				if (!IsInsideMM(y, 0, w->vscroll.cap)) return;
 
				p = y + w->vscroll.pos;
 
				if (p < _num_industry_sort) {
 
					ScrollMainWindowToTile(_industry_sort[p]->xy);
 
					if (_ctrl_pressed) {
 
						ShowExtraViewPortWindow(_industry_sort[p]->xy);
 
					} else {
 
						ScrollMainWindowToTile(_industry_sort[p]->xy);
 
					}
 
				}
 
			} break;
 
		}
 
		break;
 

	
 
	case WE_4:
 
		SetWindowDirty(w);
 
		break;
 

	
 
	case WE_RESIZE:
 
		w->vscroll.cap += e->we.sizing.diff.y / 10;
 
		break;
src/news_gui.cpp
Show inline comments
 
@@ -197,26 +197,33 @@ static void NewsWindowProc(Window *w, Wi
 
					DeleteWindow(w);
 
					ni->duration = 0;
 
					_forced_news = INVALID_NEWS;
 
					break;
 
				}
 

	
 
				case 0: {
 
					NewsItem *ni = WP(w, news_d).ni;
 
					if (ni->flags & NF_VEHICLE) {
 
						Vehicle *v = GetVehicle(ni->data_a);
 
						ScrollMainWindowTo(v->x_pos, v->y_pos);
 
					} else if (ni->flags & NF_TILE) {
 
						if (!ScrollMainWindowToTile(ni->data_a) && ni->data_b != 0) {
 
							ScrollMainWindowToTile(ni->data_b);
 
						if (_ctrl_pressed) {
 
							ShowExtraViewPortWindow(ni->data_a);
 
							if (ni->data_b != 0) {
 
								ShowExtraViewPortWindow(ni->data_b);
 
							}
 
						} else {
 
							if (!ScrollMainWindowToTile(ni->data_a) && ni->data_b != 0) {
 
								ScrollMainWindowToTile(ni->data_b);
 
							}
 
						}
 
					}
 
					break;
 
				}
 
			}
 
			break;
 

	
 
		case WE_KEYPRESS:
 
			if (e->we.keypress.keycode == WKC_SPACE) {
 
				/* Don't continue. */
 
				e->we.keypress.cont = false;
 
				DeleteWindow(w);
src/player_gui.cpp
Show inline comments
 
@@ -1261,25 +1261,29 @@ static void PlayerCompanyWndProc(Window 
 
				}
 

	
 
				case PCW_WIDGET_BUILD_VIEW_HQ: {
 
					TileIndex tile = GetPlayer((PlayerID)w->window_number)->location_of_house;
 
					if (tile == 0) {
 
						if ((byte)w->window_number != _local_player)
 
							return;
 
						SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, w);
 
						SetTileSelectSize(2, 2);
 
						w->LowerWidget(PCW_WIDGET_BUILD_VIEW_HQ);
 
						w->InvalidateWidget(PCW_WIDGET_BUILD_VIEW_HQ);
 
					} else {
 
						ScrollMainWindowToTile(tile);
 
						if (_ctrl_pressed) {
 
							ShowExtraViewPortWindow(tile);
 
						} else {
 
							ScrollMainWindowToTile(tile);
 
						}
 
					}
 
					break;
 
				}
 

	
 
				case PCW_WIDGET_RELOCATE_HQ:
 
					SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, VHM_RECT, w);
 
					SetTileSelectSize(2, 2);
 
					w->LowerWidget(PCW_WIDGET_RELOCATE_HQ);
 
					w->InvalidateWidget(PCW_WIDGET_RELOCATE_HQ);
 
					break;
 

	
 
				case PCW_WIDGET_BUY_SHARE:
src/smallmap_gui.cpp
Show inline comments
 
@@ -1182,35 +1182,40 @@ static void ExtraViewPortWndProc(Window 
 
			break;
 
	}
 
}
 

	
 
static const WindowDesc _extra_view_port_desc = {
 
	WDP_AUTO, WDP_AUTO, 300, 68, 300, 268,
 
	WC_EXTRA_VIEW_PORT, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
 
	_extra_view_port_widgets,
 
	ExtraViewPortWndProc
 
};
 

	
 
void ShowExtraViewPortWindow()
 
void ShowExtraViewPortWindow(TileIndex tile)
 
{
 
	Window *w, *v;
 
	int i = 0;
 

	
 
	/* find next free window number for extra viewport */
 
	while (FindWindowById(WC_EXTRA_VIEW_PORT, i) != NULL) i++;
 

	
 
	w = AllocateWindowDescFront(&_extra_view_port_desc, i);
 
	Window *w = AllocateWindowDescFront(&_extra_view_port_desc, i);
 
	if (w != NULL) {
 
		int x, y;
 
		/* the main window with the main view */
 
		v = FindWindowById(WC_MAIN_WINDOW, 0);
 
		Point pt;
 

	
 
		if (tile == INVALID_TILE) {
 
			/* the main window with the main view */
 
			const Window *v = FindWindowById(WC_MAIN_WINDOW, 0);
 

	
 
		/* center on same place as main window (zoom is maximum, no adjustment needed) */
 
		x = WP(v, vp_d).scrollpos_x;
 
		y = WP(v, vp_d).scrollpos_y;
 
		WP(w, vp_d).scrollpos_x = x + (v->viewport->virtual_width  - (w->widget[4].right - w->widget[4].left) - 1) / 2;
 
		WP(w, vp_d).scrollpos_y = y + (v->viewport->virtual_height - (w->widget[4].bottom - w->widget[4].top) - 1) / 2;
 
			/* center on same place as main window (zoom is maximum, no adjustment needed) */
 
			pt.x = WP(v, vp_d).scrollpos_x + v->viewport->virtual_height / 2;
 
			pt.y = WP(v, vp_d).scrollpos_y + v->viewport->virtual_height / 2;
 
		} else {
 
			pt = RemapCoords(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, TileHeight(tile));
 
		}
 

	
 
		WP(w, vp_d).scrollpos_x = pt.x - ((w->widget[4].right - w->widget[4].left) - 1) / 2;
 
		WP(w, vp_d).scrollpos_y = pt.y - ((w->widget[4].bottom - w->widget[4].top) - 1) / 2;
 
		WP(w, vp_d).dest_scrollpos_x = WP(w, vp_d).scrollpos_x;
 
		WP(w, vp_d).dest_scrollpos_y = WP(w, vp_d).scrollpos_y;
 
	}
 
}
src/station_gui.cpp
Show inline comments
 
@@ -413,25 +413,30 @@ static void PlayerStationsWndProc(Window
 
				case SLW_LIST: {
 
					uint32 id_v = (e->we.click.pt.y - 41) / 10;
 

	
 
					if (id_v >= w->vscroll.cap) return; // click out of bounds
 

	
 
					id_v += w->vscroll.pos;
 

	
 
					if (id_v >= sl->list_length) return; // click out of list bound
 

	
 
					const Station *st = sl->sort_list[id_v];
 
					/* do not check HasStationInUse - it is slow and may be invalid */
 
					assert(st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy()));
 
					ScrollMainWindowToTile(st->xy);
 

	
 
					if (_ctrl_pressed) {
 
						ShowExtraViewPortWindow(st->xy);
 
					} else {
 
						ScrollMainWindowToTile(st->xy);
 
					}
 
					break;
 
				}
 

	
 
				case SLW_TRAIN:
 
				case SLW_TRUCK:
 
				case SLW_BUS:
 
				case SLW_AIRPLANE:
 
				case SLW_SHIP:
 
					if (_ctrl_pressed) {
 
						ToggleBit(facilities, e->we.click.widget - SLW_TRAIN);
 
						w->ToggleWidgetLoweredState(e->we.click.widget);
 
					} else {
 
@@ -927,25 +932,29 @@ static void StationViewWndProc(Window *w
 
	switch (e->event) {
 
		case WE_PAINT:
 
			DrawStationViewWindow(w);
 
			break;
 

	
 
		case WE_CLICK:
 
			switch (e->we.click.widget) {
 
				case SVW_WAITING:
 
					HandleCargoWaitingClick(w, (e->we.click.pt.y - w->widget[SVW_WAITING].top) / 10 + w->vscroll.pos);
 
					break;
 

	
 
				case SVW_LOCATION:
 
					ScrollMainWindowToTile(GetStation(w->window_number)->xy);
 
					if (_ctrl_pressed) {
 
						ShowExtraViewPortWindow(GetStation(w->window_number)->xy);
 
					} else {
 
						ScrollMainWindowToTile(GetStation(w->window_number)->xy);
 
					}
 
					break;
 

	
 
				case SVW_RATINGS:
 
					SetWindowDirty(w);
 

	
 
					if (w->widget[SVW_RATINGS].data == STR_3032_RATINGS) {
 
						/* Switch to ratings view */
 
						w->widget[SVW_RATINGS].data = STR_3033_ACCEPTS;
 
						w->widget[SVW_RATINGS].tooltips = STR_3056_SHOW_LIST_OF_ACCEPTED_CARGO;
 
						ResizeWindowForWidget(w, SVW_ACCEPTLIST, 0, 100);
 
					} else {
 
						/* Switch to accepts view */
src/subsidy_gui.cpp
Show inline comments
 
@@ -6,24 +6,25 @@
 
#include "openttd.h"
 
#include "station_base.h"
 
#include "industry.h"
 
#include "town.h"
 
#include "economy_func.h"
 
#include "variables.h"
 
#include "cargotype.h"
 
#include "window_gui.h"
 
#include "strings_func.h"
 
#include "date_func.h"
 
#include "viewport_func.h"
 
#include "gfx_func.h"
 
#include "gui.h"
 

	
 
#include "table/strings.h"
 

	
 
static void HandleSubsidyClick(int y)
 
{
 
	const Subsidy *s;
 
	uint num;
 
	int offs;
 
	TileIndex xy;
 

	
 
	if (y < 0) return;
 

	
 
@@ -57,35 +58,42 @@ handle_click:
 
	TownEffect te = GetCargo(s->cargo_type)->town_effect;
 

	
 
	/* determine from coordinate for subsidy and try to scroll to it */
 
	offs = s->from;
 
	if (s->age >= 12) {
 
		xy = GetStation(offs)->xy;
 
	} else if (te == TE_PASSENGERS || te == TE_MAIL) {
 
		xy = GetTown(offs)->xy;
 
	} else {
 
		xy = GetIndustry(offs)->xy;
 
	}
 

	
 
	if (!ScrollMainWindowToTile(xy)) {
 
	if (_ctrl_pressed || !ScrollMainWindowToTile(xy)) {
 
		if (_ctrl_pressed) ShowExtraViewPortWindow(xy);
 

	
 
		/* otherwise determine to coordinate for subsidy and scroll to it */
 
		offs = s->to;
 
		if (s->age >= 12) {
 
			xy = GetStation(offs)->xy;
 
		} else if (te == TE_PASSENGERS || te == TE_MAIL || te == TE_GOODS || te == TE_FOOD) {
 
			xy = GetTown(offs)->xy;
 
		} else {
 
			xy = GetIndustry(offs)->xy;
 
		}
 
		ScrollMainWindowToTile(xy);
 

	
 
		if (_ctrl_pressed) {
 
			ShowExtraViewPortWindow(xy);
 
		} else {
 
			ScrollMainWindowToTile(xy);
 
		}
 
	}
 
}
 

	
 
static void DrawSubsidiesWindow(const Window *w)
 
{
 
	YearMonthDay ymd;
 
	const Subsidy *s;
 
	uint num;
 
	int x;
 
	int y;
 

	
 
	DrawWindowWidgets(w);
src/town_gui.cpp
Show inline comments
 
@@ -324,25 +324,29 @@ static void TownViewWndProc(Window *w, W
 
			DrawString(2, 117, STR_200D_PASSENGERS_LAST_MONTH_MAX, TC_FROMSTRING);
 

	
 
			SetDParam(0, t->act_mail);
 
			SetDParam(1, t->max_mail);
 
			DrawString(2, 127, STR_200E_MAIL_LAST_MONTH_MAX, TC_FROMSTRING);
 

	
 
			DrawWindowViewport(w);
 
			break;
 

	
 
		case WE_CLICK:
 
			switch (e->we.click.widget) {
 
				case TVW_CENTERVIEW: /* scroll to location */
 
					ScrollMainWindowToTile(t->xy);
 
					if (_ctrl_pressed) {
 
						ShowExtraViewPortWindow(t->xy);
 
					} else {
 
						ScrollMainWindowToTile(t->xy);
 
					}
 
					break;
 

	
 
				case TVW_SHOWAUTORITY: /* town authority */
 
					ShowTownAuthorityWindow(w->window_number);
 
					break;
 

	
 
				case TVW_CHANGENAME: /* rename */
 
					SetDParam(0, w->window_number);
 
					ShowQueryString(STR_TOWN, STR_2007_RENAME_TOWN, 31, 130, w, CS_ALPHANUMERAL);
 
					break;
 

	
 
				case TVW_EXPAND: /* expand town - only available on Scenario editor */
 
@@ -532,25 +536,29 @@ static void TownDirectoryWndProc(Window 
 
					const Town* t;
 

	
 
					uint16 id_v = (e->we.click.pt.y - 28) / 10;
 

	
 
					if (id_v >= w->vscroll.cap) return; // click out of bounds
 

	
 
					id_v += w->vscroll.pos;
 

	
 
					if (id_v >= _num_town_sort) return; // click out of town bounds
 

	
 
					t = _town_sort[id_v];
 
					assert(t->xy);
 
					ScrollMainWindowToTile(t->xy);
 
					if (_ctrl_pressed) {
 
						ShowExtraViewPortWindow(t->xy);
 
					} else {
 
						ScrollMainWindowToTile(t->xy);
 
					}
 
				} break;
 
			}
 
			break;
 

	
 
		case WE_4:
 
			SetWindowDirty(w);
 
			break;
 

	
 
		case WE_RESIZE:
 
			w->vscroll.cap += e->we.sizing.diff.y / 10;
 
			break;
 
	}
0 comments (0 inline, 0 general)