Changeset - r8082:9d654f9b59ea
[Not reviewed]
master
0 14 0
rubidium - 16 years ago 2007-12-16 10:54:08
rubidium@openttd.org
(svn r11643) -Codechange: conform with the coding style for the WP macro uses.
14 files changed with 155 insertions and 155 deletions:
0 comments (0 inline, 0 general)
src/autoreplace_gui.cpp
Show inline comments
 
@@ -237,13 +237,13 @@ static void ReplaceVehicleWndProc(Window
 

	
 
		case WE_PAINT: {
 
			if (WP(w, replaceveh_d).update_left || WP(w, replaceveh_d).update_right) GenerateLists(w);
 

	
 
			Player *p = GetPlayer(_local_player);
 
			EngineID selected_id[2];
 
			const GroupID selected_group = WP(w,replaceveh_d).sel_group;
 
			const GroupID selected_group = WP(w, replaceveh_d).sel_group;
 

	
 
			selected_id[0] = WP(w, replaceveh_d).sel_engine[0];
 
			selected_id[1] = WP(w, replaceveh_d).sel_engine[1];
 

	
 
			/* Disable the "Start Replacing" button if:
 
			 *    Either list is empty
src/depot_gui.cpp
Show inline comments
 
@@ -168,13 +168,13 @@ static void DrawVehicleInDepot(Window *w
 
	byte diff_x = 0, diff_y = 0;
 

	
 
	int sprite_y = y + w->resize.step_height - GetVehicleListHeight(v->type);
 

	
 
	switch (v->type) {
 
		case VEH_TRAIN:
 
			DrawTrainImage(v, x + 21, sprite_y, w->hscroll.cap + 4, w->hscroll.pos, WP(w,depot_d).sel);
 
			DrawTrainImage(v, x + 21, sprite_y, w->hscroll.cap + 4, w->hscroll.pos, WP(w, depot_d).sel);
 

	
 
			/* Number of wagons relative to a standard length wagon (rounded up) */
 
			SetDParam(0, (v->u.rail.cached_total_length + 7) / 8);
 
			DrawStringRightAligned(w->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, TC_FROMSTRING); // Draw the counter
 
			break;
 

	
 
@@ -270,13 +270,13 @@ static void DrawDepotWindow(Window *w)
 

	
 
	/* draw the train wagons, that do not have an engine in front */
 
	for (; num < maxval; num++, y += 14) {
 
		const Vehicle *v = WP(w, depot_d).wagon_list[num - WP(w, depot_d).engine_count];
 
		const Vehicle *u;
 

	
 
		DrawTrainImage(v, x + 50, y, w->hscroll.cap - 29, 0, WP(w,depot_d).sel);
 
		DrawTrainImage(v, x + 50, y, w->hscroll.cap - 29, 0, WP(w, depot_d).sel);
 
		DrawString(x, y + 2, STR_8816, TC_FROMSTRING);
 

	
 
		/*Draw the train counter */
 
		i = 0;
 
		u = v;
 
		do i++; while ((u = u->Next()) != NULL); // Determine length of train
 
@@ -426,13 +426,13 @@ static void DepotClick(Window *w, int x,
 
			return;
 

	
 
		case MODE_DRAG_VEHICLE: { // start dragging of vehicle
 
			VehicleID sel = WP(w, depot_d).sel;
 

	
 
			if (WP(w, depot_d).type == VEH_TRAIN && sel != INVALID_VEHICLE) {
 
				WP(w,depot_d).sel = INVALID_VEHICLE;
 
				WP(w, depot_d).sel = INVALID_VEHICLE;
 
				TrainDepotMoveVehicle(v, sel, gdvp.head);
 
			} else if (v != NULL) {
 
				int image = v->GetImage(DIR_W);
 

	
 
				WP(w, depot_d).sel = v->index;
 
				SetWindowDirty(w);
src/main_gui.cpp
Show inline comments
 
@@ -465,29 +465,29 @@ static void MenuWndProc(Window *w, Windo
 
			dis >>= 1;
 
		}
 
	} break;
 

	
 
	case WE_DESTROY: {
 
			Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0);
 
			v->RaiseWidget(WP(w,menu_d).main_button);
 
			v->RaiseWidget(WP(w, menu_d).main_button);
 
			SetWindowDirty(v);
 
			return;
 
		}
 

	
 
	case WE_POPUPMENU_SELECT: {
 
		int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
 
		int action_id;
 

	
 

	
 
		if (index < 0) {
 
			Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0);
 
			if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button)
 
				index = WP(w,menu_d).sel_index;
 
			if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button)
 
				index = WP(w, menu_d).sel_index;
 
		}
 

	
 
		action_id = WP(w,menu_d).action_id;
 
		action_id = WP(w, menu_d).action_id;
 
		DeleteWindow(w);
 

	
 
		if (index >= 0) {
 
			assert((uint)index <= lengthof(_menu_clicked_procs));
 
			_menu_clicked_procs[action_id](index);
 
		}
 
@@ -495,15 +495,15 @@ static void MenuWndProc(Window *w, Windo
 
		break;
 
		}
 

	
 
	case WE_POPUPMENU_OVER: {
 
		int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
 

	
 
		if (index == -1 || index == WP(w,menu_d).sel_index) return;
 
		if (index == -1 || index == WP(w, menu_d).sel_index) return;
 

	
 
		WP(w,menu_d).sel_index = index;
 
		WP(w, menu_d).sel_index = index;
 
		SetWindowDirty(w);
 
		return;
 
		}
 
	}
 
}
 

	
 
@@ -535,16 +535,16 @@ static int GetPlayerIndexFromMenu(int in
 

	
 
static void UpdatePlayerMenuHeight(Window *w)
 
{
 
	byte num = ActivePlayerCount();
 

	
 
	/* Increase one to fit in PlayerList in the menu when in network */
 
	if (_networking && WP(w,menu_d).main_button == 9) num++;
 
	if (_networking && WP(w, menu_d).main_button == 9) num++;
 

	
 
	if (WP(w,menu_d).item_count != num) {
 
		WP(w,menu_d).item_count = num;
 
	if (WP(w, menu_d).item_count != num) {
 
		WP(w, menu_d).item_count = num;
 
		SetWindowDirty(w);
 
		num = num * 10 + 2;
 
		w->height = num;
 
		w->widget[0].bottom = w->widget[0].top + num - 1;
 
		SetWindowDirty(w);
 
	}
 
@@ -562,17 +562,17 @@ static void PlayerMenuWndProc(Window *w,
 

	
 
		UpdatePlayerMenuHeight(w);
 
		DrawWindowWidgets(w);
 

	
 
		x = 1;
 
		y = 1;
 
		sel = WP(w,menu_d).sel_index;
 
		chk = WP(w,menu_d).checked_items; // let this mean gray items.
 
		sel = WP(w, menu_d).sel_index;
 
		chk = WP(w, menu_d).checked_items; // let this mean gray items.
 

	
 
		/* 9 = playerlist */
 
		if (_networking && WP(w,menu_d).main_button == 9) {
 
		if (_networking && WP(w, menu_d).main_button == 9) {
 
			if (sel == 0) {
 
				GfxFillRect(x, y, x + 238, y + 9, 0);
 
			}
 
			DrawString(x + 19, y, STR_NETWORK_CLIENT_LIST, TC_FROMSTRING);
 
			y += 10;
 
			sel--;
 
@@ -600,33 +600,33 @@ static void PlayerMenuWndProc(Window *w,
 

	
 
		break;
 
		}
 

	
 
	case WE_DESTROY: {
 
		Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0);
 
		v->RaiseWidget(WP(w,menu_d).main_button);
 
		v->RaiseWidget(WP(w, menu_d).main_button);
 
		SetWindowDirty(v);
 
		return;
 
		}
 

	
 
	case WE_POPUPMENU_SELECT: {
 
		int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
 
		int action_id = WP(w,menu_d).action_id;
 
		int action_id = WP(w, menu_d).action_id;
 

	
 
		/* We have a new entry at the top of the list of menu 9 when networking
 
		 *  so keep that in count */
 
		if (_networking && WP(w,menu_d).main_button == 9) {
 
		if (_networking && WP(w, menu_d).main_button == 9) {
 
			if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
 
		} else {
 
			index = GetPlayerIndexFromMenu(index);
 
		}
 

	
 
		if (index < 0) {
 
			Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0);
 
			if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button)
 
				index = WP(w,menu_d).sel_index;
 
			if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button)
 
				index = WP(w, menu_d).sel_index;
 
		}
 

	
 
		DeleteWindow(w);
 

	
 
		if (index >= 0) {
 
			assert(index >= 0 && index < 30);
 
@@ -638,21 +638,21 @@ static void PlayerMenuWndProc(Window *w,
 
		int index;
 
		UpdatePlayerMenuHeight(w);
 
		index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
 

	
 
		/* We have a new entry at the top of the list of menu 9 when networking
 
		 * so keep that in count */
 
		if (_networking && WP(w,menu_d).main_button == 9) {
 
		if (_networking && WP(w, menu_d).main_button == 9) {
 
			if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
 
		} else {
 
			index = GetPlayerIndexFromMenu(index);
 
		}
 

	
 
		if (index == -1 || index == WP(w,menu_d).sel_index) return;
 
		if (index == -1 || index == WP(w, menu_d).sel_index) return;
 

	
 
		WP(w,menu_d).sel_index = index;
 
		WP(w, menu_d).sel_index = index;
 
		SetWindowDirty(w);
 
		return;
 
		}
 
	}
 
}
 

	
 
@@ -719,19 +719,19 @@ static Window *PopupMainToolbMenu(Window
 
	x = w->left + Clamp(x, 0, w->width - width); // or alternatively '_screen.width - width'
 

	
 
	w = AllocateWindow(x, 22, width, item_count * 10 + 2, MenuWndProc, WC_TOOLBAR_MENU, _menu_widgets);
 
	w->widget[0].bottom = item_count * 10 + 1;
 
	w->flags4 &= ~WF_WHITE_BORDER_MASK;
 

	
 
	WP(w,menu_d).item_count = item_count;
 
	WP(w,menu_d).sel_index = 0;
 
	WP(w,menu_d).main_button = GB(parent_button, 0, 8);
 
	WP(w,menu_d).action_id = (GB(parent_button, 8, 8) != 0) ? GB(parent_button, 8, 8) : parent_button;
 
	WP(w,menu_d).string_id = base_string;
 
	WP(w,menu_d).checked_items = 0;
 
	WP(w,menu_d).disabled_items = disabled_mask;
 
	WP(w, menu_d).item_count = item_count;
 
	WP(w, menu_d).sel_index = 0;
 
	WP(w, menu_d).main_button = GB(parent_button, 0, 8);
 
	WP(w, menu_d).action_id = (GB(parent_button, 8, 8) != 0) ? GB(parent_button, 8, 8) : parent_button;
 
	WP(w, menu_d).string_id = base_string;
 
	WP(w, menu_d).checked_items = 0;
 
	WP(w, menu_d).disabled_items = disabled_mask;
 

	
 
	_popup_menu_active = true;
 

	
 
	SndPlayFx(SND_15_BEEP);
 
	return w;
 
}
 
@@ -743,26 +743,26 @@ static Window *PopupMainPlayerToolbMenu(
 
	w->LowerWidget(main_button);
 
	w->InvalidateWidget(main_button);
 

	
 
	DeleteWindowById(WC_TOOLBAR_MENU, 0);
 
	w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
 
	w->flags4 &= ~WF_WHITE_BORDER_MASK;
 
	WP(w,menu_d).item_count = 0;
 
	WP(w,menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
 
	WP(w, menu_d).item_count = 0;
 
	WP(w, menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
 
	if (_networking && main_button == 9) {
 
		if (_local_player != PLAYER_SPECTATOR) {
 
			WP(w,menu_d).sel_index++;
 
			WP(w, menu_d).sel_index++;
 
		} else {
 
			/* Select client list by default for spectators */
 
			WP(w,menu_d).sel_index = 0;
 
			WP(w, menu_d).sel_index = 0;
 
		}
 
	}
 
	WP(w,menu_d).action_id = main_button;
 
	WP(w,menu_d).main_button = main_button;
 
	WP(w,menu_d).checked_items = gray;
 
	WP(w,menu_d).disabled_items = 0;
 
	WP(w, menu_d).action_id = main_button;
 
	WP(w, menu_d).main_button = main_button;
 
	WP(w, menu_d).checked_items = gray;
 
	WP(w, menu_d).disabled_items = 0;
 
	_popup_menu_active = true;
 
	SndPlayFx(SND_15_BEEP);
 
	return w;
 
}
 

	
 
static void ToolbarSaveClick(Window *w)
 
@@ -873,25 +873,25 @@ bool DoZoomInOutWindow(int how, Window *
 
		case ZOOM_IN:
 
			if (vp->zoom == ZOOM_LVL_MIN) return false;
 
			vp->zoom = (ZoomLevel)((byte)vp->zoom - 1);
 
			vp->virtual_width >>= 1;
 
			vp->virtual_height >>= 1;
 

	
 
			WP(w,vp_d).scrollpos_x += vp->virtual_width >> 1;
 
			WP(w,vp_d).scrollpos_y += vp->virtual_height >> 1;
 
			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;
 
			WP(w, vp_d).scrollpos_x += vp->virtual_width >> 1;
 
			WP(w, vp_d).scrollpos_y += vp->virtual_height >> 1;
 
			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;
 
			break;
 
		case ZOOM_OUT:
 
			if (vp->zoom == ZOOM_LVL_MAX) return false;
 
			vp->zoom = (ZoomLevel)((byte)vp->zoom + 1);
 

	
 
			WP(w,vp_d).scrollpos_x -= vp->virtual_width >> 1;
 
			WP(w,vp_d).scrollpos_y -= vp->virtual_height >> 1;
 
			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;
 
			WP(w, vp_d).scrollpos_x -= vp->virtual_width >> 1;
 
			WP(w, vp_d).scrollpos_y -= vp->virtual_height >> 1;
 
			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;
 

	
 
			vp->virtual_width <<= 1;
 
			vp->virtual_height <<= 1;
 
			break;
 
	}
 
	if (vp != NULL) { // the vp can be null when how == ZOOM_NONE
 
@@ -976,13 +976,13 @@ static void ToolbarOptionsClick(Window *
 
	if (HasBit(_display_opt, DO_SHOW_SIGNS))         SetBit(x,  8);
 
	if (HasBit(_display_opt, DO_WAYPOINTS))          SetBit(x,  9);
 
	if (HasBit(_display_opt, DO_FULL_ANIMATION))     SetBit(x, 10);
 
	if (HasBit(_display_opt, DO_FULL_DETAIL))        SetBit(x, 11);
 
	if (IsTransparencySet(TO_HOUSES) && IsTransparencySet(TO_TREES)) SetBit(x, 12);
 
	if (IsTransparencySet(TO_SIGNS))                     SetBit(x, 13);
 
	WP(w,menu_d).checked_items = x;
 
	WP(w, menu_d).checked_items = x;
 
}
 

	
 

	
 
static void ToolbarScenSaveOrLoad(Window *w)
 
{
 
	PopupMainToolbMenu(w, 3, STR_0292_SAVE_SCENARIO, 6, 0);
 
@@ -2082,16 +2082,16 @@ static void StatusBarWndProc(Window *w, 
 
		if (w->message.msg) { // true when saving is active
 
			DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_SAVING_GAME, TC_FROMSTRING);
 
		} else if (_do_autosave) {
 
			DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_032F_AUTOSAVE, TC_FROMSTRING);
 
		} else if (_pause_game) {
 
			DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_0319_PAUSED, TC_FROMSTRING);
 
		} else if (WP(w,def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) {
 
		} else if (WP(w, def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) {
 
			/* Draw the scrolling news text */
 
			if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w,def_d).data_1, w->widget[1].right - w->widget[1].left - 2)) {
 
				WP(w,def_d).data_1 = -1280;
 
			if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w, def_d).data_1, w->widget[1].right - w->widget[1].left - 2)) {
 
				WP(w, def_d).data_1 = -1280;
 
				if (p != NULL) {
 
					/* This is the default text */
 
					SetDParam(0, p->index);
 
					DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING);
 
				}
 
			}
 
@@ -2399,13 +2399,13 @@ void ShowVitalWindows()
 
	if (_game_mode == GM_EDITOR) return;
 

	
 
	_main_status_desc.top = _screen.height - 12;
 
	w = AllocateWindowDesc(&_main_status_desc);
 
	CLRBITS(w->flags4, WF_WHITE_BORDER_MASK);
 

	
 
	WP(w,def_d).data_1 = -1280;
 
	WP(w, def_d).data_1 = -1280;
 
}
 

	
 
void GameSizeChanged()
 
{
 
	_cur_resolution[0] = _screen.width;
 
	_cur_resolution[1] = _screen.height;
src/misc_gui.cpp
Show inline comments
 
@@ -340,14 +340,14 @@ static void BuildTreesWndProc(Window *w,
 
	case WE_PAINT: {
 
		int x,y;
 
		int i, count;
 

	
 
		DrawWindowWidgets(w);
 

	
 
		WP(w,tree_d).base = i = _tree_base_by_landscape[_opt.landscape];
 
		WP(w,tree_d).count = count = _tree_count_by_landscape[_opt.landscape];
 
		WP(w, tree_d).base = i = _tree_base_by_landscape[_opt.landscape];
 
		WP(w, tree_d).count = count = _tree_count_by_landscape[_opt.landscape];
 

	
 
		x = 18;
 
		y = 54;
 
		do {
 
			DrawSprite(_tree_sprites[i].sprite, _tree_sprites[i].pal, x, y);
 
			x += 35;
 
@@ -366,16 +366,16 @@ static void BuildTreesWndProc(Window *w,
 
			ResetObjectToPlace();
 
			break;
 

	
 
		case 3: case 4: case 5: case 6:
 
		case 7: case 8: case 9: case 10:
 
		case 11:case 12: case 13: case 14:
 
			if (wid - 3 >= WP(w,tree_d).count) break;
 
			if (wid - 3 >= WP(w, tree_d).count) break;
 

	
 
			if (HandlePlacePushButton(w, wid, SPR_CURSOR_TREE, VHM_RECT, NULL))
 
				_tree_to_plant = WP(w,tree_d).base + wid - 3;
 
				_tree_to_plant = WP(w, tree_d).base + wid - 3;
 
			break;
 

	
 
		case 15: // tree of random type.
 
			if (HandlePlacePushButton(w, 15, SPR_CURSOR_TREE, VHM_RECT, NULL))
 
				_tree_to_plant = -1;
 
			break;
 
@@ -1853,13 +1853,13 @@ static const Widget _cheat_widgets[] = {
 
};
 

	
 
static void CheatsWndProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
 
	case WE_PAINT: {
 
		int clk = WP(w,def_d).data_1;
 
		int clk = WP(w, def_d).data_1;
 
		int x, y;
 
		int i;
 

	
 
		DrawWindowWidgets(w);
 

	
 
		DrawStringMultiCenter(200, 25, STR_CHEATS_WARNING, w->width - 50);
 
@@ -1932,13 +1932,13 @@ static void CheatsWndProc(Window *w, Win
 
			oldvalue = value = (int32)ReadValue(ce->variable, ce->type);
 

	
 
			*ce->been_used = true;
 

	
 
			switch (ce->type) {
 
			case SLE_BOOL:
 
				if (ce->flags & CE_CLICK) WP(w,def_d).data_1 = btn * 2 + 1;
 
				if (ce->flags & CE_CLICK) WP(w, def_d).data_1 = btn * 2 + 1;
 
				value ^= 1;
 
				if (ce->proc != NULL) ce->proc(value, 0);
 
				break;
 
			default: {
 
				/* Add a dynamic step-size to the scroller. In a maximum of
 
				 * 50-steps you should be able to get from min to max */
 
@@ -1950,13 +1950,13 @@ static void CheatsWndProc(Window *w, Win
 
				value = Clamp(value, ce->min, ce->max);
 

	
 
				/* take whatever the function returns */
 
				value = ce->proc(value, (x >= 30) ? 1 : -1);
 

	
 
				if (value != oldvalue) {
 
					WP(w,def_d).data_1 = btn * 2 + 1 + ((x >= 30) ? 1 : 0);
 
					WP(w, def_d).data_1 = btn * 2 + 1 + ((x >= 30) ? 1 : 0);
 
				}
 
			} break;
 
			}
 

	
 
			if (value != oldvalue) {
 
				WriteValue(ce->variable, ce->type, (int64)value);
 
@@ -1966,13 +1966,13 @@ static void CheatsWndProc(Window *w, Win
 
			w->flags4 |= 5 << WF_TIMEOUT_SHL;
 

	
 
			SetWindowDirty(w);
 
		}
 
		break;
 
	case WE_TIMEOUT:
 
		WP(w,def_d).data_1 = 0;
 
		WP(w, def_d).data_1 = 0;
 
		SetWindowDirty(w);
 
		break;
 
	}
 
}
 

	
 
static const WindowDesc _cheats_desc = {
src/network/network_gui.cpp
Show inline comments
 
@@ -1400,16 +1400,16 @@ static Window *PopupClientList(Window *w
 
	// Allocate the popup
 
	w = AllocateWindow(x, y, 150, h + 1, ClientListPopupWndProc, WC_TOOLBAR_MENU, _client_list_popup_widgets);
 
	w->widget[0].bottom = w->widget[0].top + h;
 
	w->widget[0].right = w->widget[0].left + 150;
 

	
 
	w->flags4 &= ~WF_WHITE_BORDER_MASK;
 
	WP(w,menu_d).item_count = 0;
 
	WP(w, menu_d).item_count = 0;
 
	// Save our client
 
	WP(w,menu_d).main_button = client_no;
 
	WP(w,menu_d).sel_index = 0;
 
	WP(w, menu_d).main_button = client_no;
 
	WP(w, menu_d).sel_index = 0;
 
	// We are a popup
 
	_popup_menu_active = true;
 

	
 
	return w;
 
}
 

	
 
@@ -1421,13 +1421,13 @@ static void ClientListPopupWndProc(Windo
 
	case WE_PAINT: {
 
		int i, y, sel;
 
		TextColour colour;
 
		DrawWindowWidgets(w);
 

	
 
		// Draw the actions
 
		sel = WP(w,menu_d).sel_index;
 
		sel = WP(w, menu_d).sel_index;
 
		y = 1;
 
		for (i = 0; i < MAX_CLIENTLIST_ACTION; i++, y += CLNWND_ROWSIZE) {
 
			if (_clientlist_action[i][0] == '\0') continue;
 
			if (_clientlist_proc[i] == NULL) continue;
 

	
 
			if (sel-- == 0) { // Selected item, highlight it
 
@@ -1443,24 +1443,24 @@ static void ClientListPopupWndProc(Windo
 

	
 
	case WE_POPUPMENU_SELECT: {
 
		// We selected an action
 
		int index = (e->we.popupmenu.pt.y - w->top) / CLNWND_ROWSIZE;
 

	
 
		if (index >= 0 && e->we.popupmenu.pt.y >= w->top)
 
			HandleClientListPopupClick(index, WP(w,menu_d).main_button);
 
			HandleClientListPopupClick(index, WP(w, menu_d).main_button);
 

	
 
		DeleteWindowById(WC_TOOLBAR_MENU, 0);
 
	} break;
 

	
 
	case WE_POPUPMENU_OVER: {
 
		// Our mouse hoovers over an action? Select it!
 
		int index = (e->we.popupmenu.pt.y - w->top) / CLNWND_ROWSIZE;
 

	
 
		if (index == -1 || index == WP(w,menu_d).sel_index) return;
 
		if (index == -1 || index == WP(w, menu_d).sel_index) return;
 

	
 
		WP(w,menu_d).sel_index = index;
 
		WP(w, menu_d).sel_index = index;
 
		SetWindowDirty(w);
 
	} break;
 

	
 
	}
 
}
 

	
src/openttd.cpp
Show inline comments
 
@@ -1052,14 +1052,14 @@ static void DoAutosave()
 
static void ScrollMainViewport(int x, int y)
 
{
 
	if (_game_mode != GM_MENU) {
 
		Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
 
		assert(w);
 

	
 
		WP(w,vp_d).dest_scrollpos_x += ScaleByZoom(x, w->viewport->zoom);
 
		WP(w,vp_d).dest_scrollpos_y += ScaleByZoom(y, w->viewport->zoom);
 
		WP(w, vp_d).dest_scrollpos_x += ScaleByZoom(x, w->viewport->zoom);
 
		WP(w, vp_d).dest_scrollpos_y += ScaleByZoom(y, w->viewport->zoom);
 
	}
 
}
 
/**
 
 * Describes all the different arrow key combinations the game allows
 
 * when it is in scrolling mode.
 
 * The real arrow keys are bitwise numbered as
src/order_gui.cpp
Show inline comments
 
@@ -55,13 +55,13 @@ enum OrderWindowWidgets {
 
 * @return the memorised order if it is a vaild one
 
 *  else return the number of orders
 
 */
 
static int OrderGetSel(const Window *w)
 
{
 
	const Vehicle *v = GetVehicle(w->window_number);
 
	int num = WP(w,order_d).sel;
 
	int num = WP(w, order_d).sel;
 

	
 
	return (num >= 0 && num < v->num_orders) ? num : v->num_orders;
 
}
 

	
 
/**
 
 * Calculate the selected order.
 
@@ -239,24 +239,24 @@ static void DrawOrdersWindow(Window *w)
 
					break;
 

	
 
				default: break;
 
			}
 

	
 
			SetDParam(0, i + 1);
 
			DrawString(2, y, str, (i == WP(w,order_d).sel) ? TC_WHITE : TC_BLACK);
 
			DrawString(2, y, str, (i == WP(w, order_d).sel) ? TC_WHITE : TC_BLACK);
 

	
 
			y += 10;
 
		}
 

	
 
		i++;
 
		order = order->next;
 
	}
 

	
 
	if (i - w->vscroll.pos < w->vscroll.cap) {
 
		str = shared_orders ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS;
 
		DrawString(2, y, str, (i == WP(w,order_d).sel) ? TC_WHITE : TC_BLACK);
 
		DrawString(2, y, str, (i == WP(w, order_d).sel) ? TC_WHITE : TC_BLACK);
 
	}
 
}
 

	
 
static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
 
{
 
	Order order;
 
@@ -364,13 +364,13 @@ static bool HandleOrderVehClick(const Ve
 
	// v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet
 
	// obviously if you press CTRL on a non-empty orders vehicle you know what you are doing
 
	if (v->num_orders != 0 && _ctrl_pressed == 0) return false;
 

	
 
	if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? CO_SHARE : CO_COPY, NULL,
 
		_ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) {
 
		WP(w,order_d).sel = -1;
 
		WP(w, order_d).sel = -1;
 
		ResetObjectToPlace();
 
	}
 

	
 
	return true;
 
}
 

	
 
@@ -384,13 +384,13 @@ static void OrdersPlaceObj(const Vehicle
 
	if (u != NULL && HandleOrderVehClick(v, u, w)) return;
 

	
 
	cmd = GetOrderCmdFromTile(v, tile);
 
	if (!cmd.IsValid()) return;
 

	
 
	if (DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), PackOrder(&cmd), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) {
 
		if (WP(w,order_d).sel != -1) WP(w,order_d).sel++;
 
		if (WP(w, order_d).sel != -1) WP(w,order_d).sel++;
 
		ResetObjectToPlace();
 
	}
 
}
 

	
 
/**
 
 * Handle the click on the goto button.
 
@@ -491,15 +491,15 @@ static void OrderClick_Delete(Window *w,
 
 * @param v current vehicle
 
 */
 
static void OrderClick_Refit(Window *w, const Vehicle *v)
 
{
 
	if (_ctrl_pressed) {
 
		/* Cancel refitting */
 
		DoCommandP(v->tile, v->index, (WP(w,order_d).sel << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, NULL, CMD_ORDER_REFIT);
 
		DoCommandP(v->tile, v->index, (WP(w, order_d).sel << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, NULL, CMD_ORDER_REFIT);
 
	} else {
 
		ShowVehicleRefitWindow(v, WP(w,order_d).sel);
 
		ShowVehicleRefitWindow(v, WP(w, order_d).sel);
 
	}
 
}
 

	
 
typedef void OnButtonVehClick(Window *w, const Vehicle *v);
 

	
 
/**
 
@@ -563,13 +563,13 @@ static void OrdersWndProc(Window *w, Win
 

	
 
			int sel = GetOrderFromOrderWndPt(w, e->we.click.pt.y, v);
 

	
 
			if (sel == INVALID_ORDER) {
 
				/* This was a click on an empty part of the orders window, so
 
				 * deselect the currently selected order. */
 
				WP(w,order_d).sel = -1;
 
				WP(w, order_d).sel = -1;
 
				SetWindowDirty(w);
 
				return;
 
			}
 

	
 
			if (_ctrl_pressed && sel < v->num_orders) {
 
				const Order *ord = GetVehicleOrder(v, sel);
 
@@ -582,18 +582,18 @@ static void OrdersWndProc(Window *w, Win
 
					default:               xy = 0; break;
 
				}
 

	
 
				if (xy != 0) ScrollMainWindowToTile(xy);
 
				return;
 
			} else {
 
				if (sel == WP(w,order_d).sel) {
 
				if (sel == WP(w, order_d).sel) {
 
					/* Deselect clicked order */
 
					WP(w,order_d).sel = -1;
 
					WP(w, order_d).sel = -1;
 
				} else {
 
					/* Select clicked order */
 
					WP(w,order_d).sel = sel;
 
					WP(w, order_d).sel = sel;
 

	
 
					if (v->owner == _local_player) {
 
						/* Activate drag and drop */
 
						SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, VHM_DRAG, w);
 
					}
 
				}
 
@@ -867,9 +867,9 @@ void ShowOrdersWindow(const Vehicle *v)
 
	}
 

	
 
	if (w != NULL) {
 
		w->caption_color = v->owner;
 
		w->vscroll.cap = 6;
 
		w->resize.step_height = 10;
 
		WP(w,order_d).sel = -1;
 
		WP(w, order_d).sel = -1;
 
	}
 
}
src/settings_gui.cpp
Show inline comments
 
@@ -807,13 +807,13 @@ static void PatchesSelectionWndProc(Wind
 
		}
 
		w->LowerWidget(4);
 
	} break;
 

	
 
	case WE_PAINT: {
 
		int x, y;
 
		const PatchPage *page = &_patches_page[WP(w,def_d).data_1];
 
		const PatchPage *page = &_patches_page[WP(w, def_d).data_1];
 
		uint i;
 

	
 
		/* Set up selected category */
 
		DrawWindowWidgets(w);
 

	
 
		x = 5;
 
@@ -840,13 +840,13 @@ static void PatchesSelectionWndProc(Wind
 
			} else {
 
				int32 value;
 

	
 
				value = (int32)ReadValue(var, sd->save.conv);
 

	
 
				/* Draw [<][>] boxes for settings of an integer-type */
 
				DrawArrowButtons(x, y, 3, WP(w,def_d).data_2 - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max));
 
				DrawArrowButtons(x, y, 3, WP(w, def_d).data_2 - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max));
 

	
 
				disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED);
 
				if (disabled) {
 
					SetDParam(0, STR_CONFIG_PATCHES_DISABLED);
 
				} else {
 
					if (sdb->flags & SGF_CURRENCY) {
 
@@ -865,13 +865,13 @@ static void PatchesSelectionWndProc(Wind
 
		break;
 
	}
 

	
 
	case WE_CLICK:
 
		switch (e->we.click.widget) {
 
		case 3: {
 
			const PatchPage *page = &_patches_page[WP(w,def_d).data_1];
 
			const PatchPage *page = &_patches_page[WP(w, def_d).data_1];
 
			const SettingDesc *sd;
 
			void *var;
 
			int32 value;
 
			int x, y;
 
			byte btn;
 

	
 
@@ -924,13 +924,13 @@ static void PatchesSelectionWndProc(Wind
 
						value -= step;
 
						if (value < sdb->min) value = (sdb->flags & SGF_0ISDISABLED) ? 0 : sdb->min;
 
					}
 

	
 
					/* Set up scroller timeout for numeric values */
 
					if (value != oldvalue && !(sd->desc.flags & SGF_MULTISTRING)) {
 
						WP(w,def_d).data_2 = btn * 2 + 1 + ((x >= 10) ? 1 : 0);
 
						WP(w, def_d).data_2 = btn * 2 + 1 + ((x >= 10) ? 1 : 0);
 
						w->flags4 |= 5 << WF_TIMEOUT_SHL;
 
						_left_button_clicked = false;
 
					}
 
				} break;
 
				default: NOT_REACHED();
 
				}
 
@@ -942,13 +942,13 @@ static void PatchesSelectionWndProc(Wind
 
			} else {
 
				/* only open editbox for types that its sensible for */
 
				if (sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) {
 
					/* Show the correct currency-translated value */
 
					if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate;
 

	
 
					WP(w,def_d).data_3 = btn;
 
					WP(w, def_d).data_3 = btn;
 
					SetDParam(0, value);
 
					ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, w, CS_NUMERAL);
 
				}
 
			}
 

	
 
			break;
 
@@ -961,19 +961,19 @@ static void PatchesSelectionWndProc(Wind
 
			SetWindowDirty(w);
 
			break;
 
		}
 
		break;
 

	
 
	case WE_TIMEOUT:
 
		WP(w,def_d).data_2 = 0;
 
		WP(w, def_d).data_2 = 0;
 
		SetWindowDirty(w);
 
		break;
 

	
 
	case WE_ON_EDIT_TEXT: {
 
		if (e->we.edittext.str != NULL) {
 
			const PatchEntry *pe = &_patches_page[WP(w,def_d).data_1].entries[WP(w,def_d).data_3];
 
			const PatchEntry *pe = &_patches_page[WP(w, def_d).data_1].entries[WP(w,def_d).data_3];
 
			const SettingDesc *sd = pe->setting;
 
			int32 value = atoi(e->we.edittext.str);
 

	
 
			/* Save the correct currency-translated value */
 
			if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate;
 

	
 
@@ -1049,13 +1049,13 @@ static char _str_separator[2];
 
static void CustCurrencyWndProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
 
		case WE_PAINT: {
 
			int x;
 
			int y = 20;
 
			int clk = WP(w,def_d).data_1;
 
			int clk = WP(w, def_d).data_1;
 
			DrawWindowWidgets(w);
 

	
 
			// exchange rate
 
			DrawArrowButtons(10, y, 3, GB(clk, 0, 2), true, true);
 
			SetDParam(0, 1);
 
			SetDParam(1, 1);
 
@@ -1102,59 +1102,59 @@ static void CustCurrencyWndProc(Window *
 

	
 
			switch (line) {
 
				case 0: // rate
 
					if (IsInsideMM(x, 10, 30)) { // clicked buttons
 
						if (x < 20) {
 
							if (_custom_currency.rate > 1) _custom_currency.rate--;
 
							WP(w,def_d).data_1 = 1 << (line * 2 + 0);
 
							WP(w, def_d).data_1 = 1 << (line * 2 + 0);
 
						} else {
 
							if (_custom_currency.rate < 5000) _custom_currency.rate++;
 
							WP(w,def_d).data_1 = 1 << (line * 2 + 1);
 
							WP(w, def_d).data_1 = 1 << (line * 2 + 1);
 
						}
 
					} else { // enter text
 
						SetDParam(0, _custom_currency.rate);
 
						str = STR_CONFIG_PATCHES_INT32;
 
						len = 4;
 
						afilter = CS_NUMERAL;
 
					}
 
					break;
 

	
 
				case 1: // separator
 
					if (IsInsideMM(x, 10, 30)) { // clicked button
 
						WP(w,def_d).data_1 = 1 << (line * 2 + 1);
 
						WP(w, def_d).data_1 = 1 << (line * 2 + 1);
 
					}
 
					str = BindCString(_str_separator);
 
					len = 1;
 
					break;
 

	
 
				case 2: // prefix
 
					if (IsInsideMM(x, 10, 30)) { // clicked button
 
						WP(w,def_d).data_1 = 1 << (line * 2 + 1);
 
						WP(w, def_d).data_1 = 1 << (line * 2 + 1);
 
					}
 
					str = BindCString(_custom_currency.prefix);
 
					len = 12;
 
					break;
 

	
 
				case 3: // suffix
 
					if (IsInsideMM(x, 10, 30)) { // clicked button
 
						WP(w,def_d).data_1 = 1 << (line * 2 + 1);
 
						WP(w, def_d).data_1 = 1 << (line * 2 + 1);
 
					}
 
					str = BindCString(_custom_currency.suffix);
 
					len = 12;
 
					break;
 

	
 
				case 4: // to euro
 
					if (IsInsideMM(x, 10, 30)) { // clicked buttons
 
						if (x < 20) {
 
							_custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ?
 
								CF_NOEURO : _custom_currency.to_euro - 1;
 
							WP(w,def_d).data_1 = 1 << (line * 2 + 0);
 
							WP(w, def_d).data_1 = 1 << (line * 2 + 0);
 
						} else {
 
							_custom_currency.to_euro =
 
								Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR);
 
							WP(w,def_d).data_1 = 1 << (line * 2 + 1);
 
							WP(w, def_d).data_1 = 1 << (line * 2 + 1);
 
						}
 
					} else { // enter text
 
						SetDParam(0, _custom_currency.to_euro);
 
						str = STR_CONFIG_PATCHES_INT32;
 
						len = 4;
 
						afilter = CS_NUMERAL;
 
@@ -1172,13 +1172,13 @@ static void CustCurrencyWndProc(Window *
 
			break;
 
		}
 

	
 
		case WE_ON_EDIT_TEXT: {
 
				const char *b = e->we.edittext.str;
 

	
 
				switch (WP(w,def_d).data_2) {
 
				switch (WP(w, def_d).data_2) {
 
					case 0: /* Exchange rate */
 
						_custom_currency.rate = Clamp(atoi(b), 1, 5000);
 
						break;
 

	
 
					case 1: /* Thousands seperator */
 
						_custom_currency.separator = (b[0] == '\0') ? ' ' : b[0];
 
@@ -1203,13 +1203,13 @@ static void CustCurrencyWndProc(Window *
 
				}
 
			MarkWholeScreenDirty();
 
			break;
 
		}
 

	
 
		case WE_TIMEOUT:
 
			WP(w,def_d).data_1 = 0;
 
			WP(w, def_d).data_1 = 0;
 
			SetWindowDirty(w);
 
			break;
 

	
 
		case WE_DESTROY:
 
			DeleteWindowById(WC_QUERY_STRING, 0);
 
			MarkWholeScreenDirty();
src/smallmap_gui.cpp
Show inline comments
 
@@ -609,16 +609,16 @@ static void DrawSmallMap(DrawPixelInfo *
 
				_owner_colors[p->index] =
 
					_colour_gradient[p->player_color][5] * 0x01010101;
 
			}
 
		}
 
	}
 

	
 
	tile_x = WP(w,smallmap_d).scroll_x / TILE_SIZE;
 
	tile_y = WP(w,smallmap_d).scroll_y / TILE_SIZE;
 
	tile_x = WP(w, smallmap_d).scroll_x / TILE_SIZE;
 
	tile_y = WP(w, smallmap_d).scroll_y / TILE_SIZE;
 

	
 
	dx = dpi->left + WP(w,smallmap_d).subscroll;
 
	dx = dpi->left + WP(w, smallmap_d).subscroll;
 
	tile_x -= dx / 4;
 
	tile_y += dx / 4;
 
	dx &= 3;
 

	
 
	dy = dpi->top;
 
	tile_x += dy / 2;
 
@@ -686,27 +686,27 @@ skip_column:
 

	
 
		FOR_ALL_VEHICLES(v) {
 
			if (v->type != VEH_SPECIAL &&
 
					(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) {
 
				/* Remap into flat coordinates. */
 
				Point pt = RemapCoords(
 
					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
 
					v->y_pos / TILE_SIZE - WP(w,smallmap_d).scroll_y / TILE_SIZE, //    dtto
 
					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
 
					v->y_pos / TILE_SIZE - WP(w, smallmap_d).scroll_y / TILE_SIZE, //    dtto
 
					0);
 
				x = pt.x;
 
				y = pt.y;
 

	
 
				/* Check if y is out of bounds? */
 
				y -= dpi->top;
 
				if (!IsInsideMM(y, 0, dpi->height)) continue;
 

	
 
				/* Default is to draw both pixels. */
 
				skip = false;
 

	
 
				/* Offset X coordinate */
 
				x -= WP(w,smallmap_d).subscroll + 3 + dpi->left;
 
				x -= WP(w, smallmap_d).subscroll + 3 + dpi->left;
 

	
 
				if (x < 0) {
 
					/* if x+1 is 0, that means we're on the very left edge,
 
					 *  and should thus only draw a single pixel */
 
					if (++x != 0) continue;
 
					skip = true;
 
@@ -732,13 +732,13 @@ skip_column:
 
		FOR_ALL_TOWNS(t) {
 
			/* Remap the town coordinate */
 
			Point pt = RemapCoords(
 
				(int)(TileX(t->xy) * TILE_SIZE - WP(w, smallmap_d).scroll_x) / TILE_SIZE,
 
				(int)(TileY(t->xy) * TILE_SIZE - WP(w, smallmap_d).scroll_y) / TILE_SIZE,
 
				0);
 
			x = pt.x - WP(w,smallmap_d).subscroll + 3 - (t->sign.width_2 >> 1);
 
			x = pt.x - WP(w, smallmap_d).subscroll + 3 - (t->sign.width_2 >> 1);
 
			y = pt.y;
 

	
 
			/* Check if the town sign is within bounds */
 
			if (x + t->sign.width_2 > dpi->left &&
 
					x < dpi->left + dpi->width &&
 
					y + 6 > dpi->top &&
 
@@ -763,14 +763,14 @@ skip_column:
 
		y = vp->virtual_top - pt.y;
 
		x2 = (x + vp->virtual_width) / TILE_SIZE;
 
		y2 = (y + vp->virtual_height) / TILE_SIZE;
 
		x /= TILE_SIZE;
 
		y /= TILE_SIZE;
 

	
 
		x -= WP(w,smallmap_d).subscroll;
 
		x2 -= WP(w,smallmap_d).subscroll;
 
		x -= WP(w, smallmap_d).subscroll;
 
		x2 -= WP(w, smallmap_d).subscroll;
 

	
 
		DrawVertMapIndicator(x, y, x, y2);
 
		DrawVertMapIndicator(x2, y, x2, y2);
 

	
 
		DrawHorizMapIndicator(x, y, x2, y);
 
		DrawHorizMapIndicator(x, y2, x2, y2);
 
@@ -875,13 +875,13 @@ static void SmallMapWindowProc(Window *w
 
					 * button here, it gets reclicked during the next inputloop, which
 
					 * would make it look like the mouse is being dragged, while it is
 
					 * actually being (virtually) clicked every inputloop.
 
					 */
 
					_left_button_clicked = false;
 

	
 
					pt = RemapCoords(WP(w,smallmap_d).scroll_x, WP(w,smallmap_d).scroll_y, 0);
 
					pt = RemapCoords(WP(w, smallmap_d).scroll_x, WP(w,smallmap_d).scroll_y, 0);
 
					WP(w2, vp_d).dest_scrollpos_x = pt.x + ((_cursor.pos.x - w->left + 2) << 4) - (w2->viewport->virtual_width >> 1);
 
					WP(w2, vp_d).dest_scrollpos_y = pt.y + ((_cursor.pos.y - w->top - 16) << 4) - (w2->viewport->virtual_height >> 1);
 

	
 
					SetWindowDirty(w);
 
				} break;
 

	
src/timetable_gui.cpp
Show inline comments
 
@@ -45,13 +45,13 @@ static inline void SetTimetableParams(in
 
	}
 
}
 

	
 
static void DrawTimetableWindow(Window *w)
 
{
 
	const Vehicle *v = GetVehicle(w->window_number);
 
	int selected = WP(w,order_d).sel;
 
	int selected = WP(w, order_d).sel;
 

	
 
	SetVScrollCount(w, v->num_orders * 2);
 

	
 
	if (v->owner == _local_player) {
 
		if (selected == -1) {
 
			w->DisableWidget(6);
 
@@ -218,23 +218,23 @@ static void TimetableWndProc(Window *w, 
 
			const Vehicle *v = GetVehicle(w->window_number);
 

	
 
			switch (we->we.click.widget) {
 
				case 3: { /* Main panel. */
 
					int selected = GetOrderFromTimetableWndPt(w, we->we.click.pt.y, v);
 

	
 
					if (selected == INVALID_ORDER || selected == WP(w,order_d).sel) {
 
					if (selected == INVALID_ORDER || selected == WP(w, order_d).sel) {
 
						/* Deselect clicked order */
 
						WP(w,order_d).sel = -1;
 
						WP(w, order_d).sel = -1;
 
					} else {
 
						/* Select clicked order */
 
						WP(w,order_d).sel = selected;
 
						WP(w, order_d).sel = selected;
 
					}
 
				} break;
 

	
 
				case 6: { /* "Wait For" button. */
 
					int selected = WP(w,order_d).sel;
 
					int selected = WP(w, order_d).sel;
 
					VehicleOrderID real = (selected + 1) / 2;
 

	
 
					if (real >= v->num_orders) real = 0;
 

	
 
					const Order *order = GetVehicleOrder(v, real);
 
					StringID current = STR_EMPTY;
 
@@ -250,13 +250,13 @@ static void TimetableWndProc(Window *w, 
 
					}
 

	
 
					ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, 150, w, CS_NUMERAL);
 
				} break;
 

	
 
				case 7: { /* Clear waiting time button. */
 
					uint32 p1 = PackTimetableArgs(v, WP(w,order_d).sel);
 
					uint32 p1 = PackTimetableArgs(v, WP(w, order_d).sel);
 
					DoCommandP(0, p1, 0, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
 
				} break;
 

	
 
				case 8: /* Reset the vehicle's late counter. */
 
					DoCommandP(0, v->index, 0, NULL, CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
 
					break;
 
@@ -269,13 +269,13 @@ static void TimetableWndProc(Window *w, 
 
			SetWindowDirty(w);
 
		} break;
 

	
 
		case WE_ON_EDIT_TEXT: {
 
			const Vehicle *v = GetVehicle(w->window_number);
 

	
 
			uint32 p1 = PackTimetableArgs(v, WP(w,order_d).sel);
 
			uint32 p1 = PackTimetableArgs(v, WP(w, order_d).sel);
 

	
 
			uint64 time = StrEmpty(we->we.edittext.str) ? 0 : strtoul(we->we.edittext.str, NULL, 10);
 
			if (!_patches.timetable_in_ticks) time *= DAY_TICKS;
 

	
 
			uint32 p2 = minu(time, MAX_UVALUE(uint16));
 

	
 
@@ -324,9 +324,9 @@ void ShowTimetableWindow(const Vehicle *
 
	Window *w = AllocateWindowDescFront(&_timetable_desc, v->index);
 

	
 
	if (w != NULL) {
 
		w->caption_color = v->owner;
 
		w->vscroll.cap = 8;
 
		w->resize.step_height = 10;
 
		WP(w,order_d).sel = -1;
 
		WP(w, order_d).sel = -1;
 
	}
 
}
src/town_gui.cpp
Show inline comments
 
@@ -137,14 +137,14 @@ static void TownAuthorityWndProc(Window 
 
		const Town *t = GetTown(w->window_number);
 
		int numact;
 
		uint buttons = GetMaskOfTownActions(&numact, _local_player, t);
 

	
 
		SetVScrollCount(w, numact + 1);
 

	
 
		if (WP(w,def_d).data_1 != -1 && !HasBit(buttons, WP(w,def_d).data_1))
 
			WP(w,def_d).data_1 = -1;
 
		if (WP(w, def_d).data_1 != -1 && !HasBit(buttons, WP(w,def_d).data_1))
 
			WP(w, def_d).data_1 = -1;
 

	
 
		w->SetWidgetDisabledState(6, WP(w, def_d).data_1 == -1);
 

	
 
		{
 
			int y;
 
			const Player *p;
 
@@ -203,13 +203,13 @@ static void TownAuthorityWndProc(Window 
 
					y += 10;
 
				}
 
			}
 
		}
 

	
 
		{
 
			int i = WP(w,def_d).data_1;
 
			int i = WP(w, def_d).data_1;
 

	
 
			if (i != -1) {
 
				SetDParam(1, (_price.build_industry >> 8) * _town_action_costs[i]);
 
				SetDParam(0, STR_2046_SMALL_ADVERTISING_CAMPAIGN + i);
 
				DrawStringMultiLine(2, 159, STR_204D_INITIATE_A_SMALL_LOCAL + i, 313);
 
			}
 
@@ -225,21 +225,21 @@ static void TownAuthorityWndProc(Window 
 
			int y = (e->we.click.pt.y - 0x6B) / 10;
 

	
 
			if (!IsInsideMM(y, 0, 5)) return;
 

	
 
			y = GetNthSetBit(GetMaskOfTownActions(NULL, _local_player, t), y + w->vscroll.pos - 1);
 
			if (y >= 0) {
 
				WP(w,def_d).data_1 = y;
 
				WP(w, def_d).data_1 = y;
 
				SetWindowDirty(w);
 
			}
 
			/* Fall through to clicking in case we are double-clicked */
 
			if (e->event != WE_DOUBLE_CLICK || y < 0) break;
 
		}
 

	
 
		case TWA_EXECUTE: {
 
			DoCommandP(GetTown(w->window_number)->xy, w->window_number, WP(w,def_d).data_1, NULL, CMD_DO_TOWN_ACTION | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
 
			DoCommandP(GetTown(w->window_number)->xy, w->window_number, WP(w, def_d).data_1, NULL, CMD_DO_TOWN_ACTION | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
 
			break;
 
		}
 
		}
 
		break;
 

	
 
	case WE_4:
 
@@ -259,13 +259,13 @@ static const WindowDesc _town_authority_
 
static void ShowTownAuthorityWindow(uint town)
 
{
 
	Window *w = AllocateWindowDescFront(&_town_authority_desc, town);
 

	
 
	if (w != NULL) {
 
		w->vscroll.cap = 5;
 
		WP(w,def_d).data_1 = -1;
 
		WP(w, def_d).data_1 = -1;
 
	}
 
}
 

	
 
static void TownViewWndProc(Window *w, WindowEvent *e)
 
{
 
	Town *t = GetTown(w->window_number);
src/viewport.cpp
Show inline comments
 
@@ -1677,13 +1677,13 @@ static inline void ClampViewportToMap(co
 

	
 
void UpdateViewportPosition(Window *w)
 
{
 
	const ViewPort *vp = w->viewport;
 

	
 
	if (WP(w, vp_d).follow_vehicle != INVALID_VEHICLE) {
 
		const Vehicle* veh = GetVehicle(WP(w,vp_d).follow_vehicle);
 
		const Vehicle* veh = GetVehicle(WP(w, vp_d).follow_vehicle);
 
		Point pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos);
 

	
 
		SetViewportPosition(w, pt.x, pt.y);
 
	} else {
 
		/* Ensure the destination location is within the map */
 
		ClampViewportToMap(vp, WP(w, vp_d).dest_scrollpos_x, WP(w, vp_d).dest_scrollpos_y);
src/widget.cpp
Show inline comments
 
@@ -500,18 +500,18 @@ static int GetDropdownItem(const Window 
 
	y = _cursor.pos.y - w->top - 2 + w->vscroll.pos * 10;
 

	
 
	if (y < 0)
 
		return - 1;
 

	
 
	item = y / 10;
 
	if (item >= WP(w,dropdown_d).num_items || (HasBit(WP(w,dropdown_d).disabled_state, item) && !HasBit(WP(w,dropdown_d).hidden_state, item)) || WP(w,dropdown_d).items[item] == 0)
 
	if (item >= WP(w, dropdown_d).num_items || (HasBit(WP(w,dropdown_d).disabled_state, item) && !HasBit(WP(w,dropdown_d).hidden_state, item)) || WP(w,dropdown_d).items[item] == 0)
 
		return - 1;
 

	
 
	/* Skip hidden items -- +1 for each hidden item before the clicked item. */
 
	for (counter = 0; item >= counter; ++counter)
 
		if (HasBit(WP(w,dropdown_d).hidden_state, counter)) item++;
 
		if (HasBit(WP(w, dropdown_d).hidden_state, counter)) item++;
 

	
 
	return item;
 
}
 

	
 
static void DropdownMenuWndProc(Window *w, WindowEvent *e)
 
{
 
@@ -524,25 +524,25 @@ static void DropdownMenuWndProc(Window *
 

	
 
			DrawWindowWidgets(w);
 

	
 
			x = 1;
 
			y = 2 - w->vscroll.pos * 10;
 

	
 
			sel    = WP(w,dropdown_d).selected_index;
 
			sel    = WP(w, dropdown_d).selected_index;
 
			width  = w->widget[0].right - 3;
 
			height = w->widget[0].bottom - 3;
 

	
 
			for (i = 0; WP(w,dropdown_d).items[i] != INVALID_STRING_ID; i++, sel--) {
 
				if (HasBit(WP(w,dropdown_d).hidden_state, i)) continue;
 
			for (i = 0; WP(w, dropdown_d).items[i] != INVALID_STRING_ID; i++, sel--) {
 
				if (HasBit(WP(w, dropdown_d).hidden_state, i)) continue;
 

	
 
				if (y >= 0 && y <= height) {
 
					if (WP(w,dropdown_d).items[i] != STR_NULL) {
 
					if (WP(w, dropdown_d).items[i] != STR_NULL) {
 
						if (sel == 0) GfxFillRect(x + 1, y, x + width, y + 9, 0);
 
						DrawStringTruncated(x + 2, y, WP(w,dropdown_d).items[i], sel == 0 ? TC_WHITE : TC_BLACK, x + width);
 
						DrawStringTruncated(x + 2, y, WP(w, dropdown_d).items[i], sel == 0 ? TC_WHITE : TC_BLACK, x + width);
 

	
 
						if (HasBit(WP(w,dropdown_d).disabled_state, i)) {
 
						if (HasBit(WP(w, dropdown_d).disabled_state, i)) {
 
							GfxFillRect(x, y, x + width, y + 9,
 
								(1 << PALETTE_MODIFIER_GREYOUT) | _colour_gradient[_dropdown_menu_widgets[0].color][5]
 
							);
 
						}
 
					} else {
 
						int c1 = _colour_gradient[_dropdown_menu_widgets[0].color][3];
 
@@ -557,56 +557,56 @@ static void DropdownMenuWndProc(Window *
 
		} break;
 

	
 
		case WE_CLICK: {
 
			if (e->we.click.widget != 0) break;
 
			item = GetDropdownItem(w);
 
			if (item >= 0) {
 
				WP(w,dropdown_d).click_delay = 4;
 
				WP(w,dropdown_d).selected_index = item;
 
				WP(w, dropdown_d).click_delay = 4;
 
				WP(w, dropdown_d).selected_index = item;
 
				SetWindowDirty(w);
 
			}
 
		} break;
 

	
 
		case WE_MOUSELOOP: {
 
			Window *w2 = FindWindowById(WP(w,dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num);
 
			Window *w2 = FindWindowById(WP(w, dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num);
 
			if (w2 == NULL) {
 
				DeleteWindow(w);
 
				return;
 
			}
 

	
 
			if (WP(w,dropdown_d).click_delay != 0 && --WP(w,dropdown_d).click_delay == 0) {
 
			if (WP(w, dropdown_d).click_delay != 0 && --WP(w,dropdown_d).click_delay == 0) {
 
				WindowEvent e;
 
				e.event = WE_DROPDOWN_SELECT;
 
				e.we.dropdown.button = WP(w,dropdown_d).parent_button;
 
				e.we.dropdown.index  = WP(w,dropdown_d).selected_index;
 
				e.we.dropdown.button = WP(w, dropdown_d).parent_button;
 
				e.we.dropdown.index  = WP(w, dropdown_d).selected_index;
 
				w2->wndproc(w2, &e);
 
				DeleteWindow(w);
 
				return;
 
			}
 

	
 
			if (WP(w,dropdown_d).drag_mode) {
 
			if (WP(w, dropdown_d).drag_mode) {
 
				item = GetDropdownItem(w);
 

	
 
				if (!_left_button_clicked) {
 
					WP(w,dropdown_d).drag_mode = false;
 
					WP(w, dropdown_d).drag_mode = false;
 
					if (item < 0) return;
 
					WP(w,dropdown_d).click_delay = 2;
 
					WP(w, dropdown_d).click_delay = 2;
 
				} else {
 
					if (item < 0) return;
 
				}
 

	
 
				WP(w,dropdown_d).selected_index = item;
 
				WP(w, dropdown_d).selected_index = item;
 
				SetWindowDirty(w);
 
			}
 
		} break;
 

	
 
		case WE_DESTROY: {
 
			Window *w2 = FindWindowById(WP(w,dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num);
 
			Window *w2 = FindWindowById(WP(w, dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num);
 
			if (w2 != NULL) {
 
				w2->RaiseWidget(WP(w,dropdown_d).parent_button);
 
				w2->InvalidateWidget(WP(w,dropdown_d).parent_button);
 
				w2->RaiseWidget(WP(w, dropdown_d).parent_button);
 
				w2->InvalidateWidget(WP(w, dropdown_d).parent_button);
 
			}
 
		} break;
 
	}
 
}
 

	
 
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask)
 
@@ -693,25 +693,25 @@ void ShowDropDownMenu(Window *w, const S
 
		w2->vscroll.count = i;
 
	}
 

	
 
	w2->desc_flags = WDF_DEF_WIDGET;
 
	w2->flags4 &= ~WF_WHITE_BORDER_MASK;
 

	
 
	WP(w2,dropdown_d).disabled_state = disabled_mask;
 
	WP(w2,dropdown_d).hidden_state = hidden_mask;
 
	WP(w2, dropdown_d).disabled_state = disabled_mask;
 
	WP(w2, dropdown_d).hidden_state = hidden_mask;
 

	
 
	WP(w2,dropdown_d).parent_wnd_class = w->window_class;
 
	WP(w2,dropdown_d).parent_wnd_num = w->window_number;
 
	WP(w2,dropdown_d).parent_button = button;
 
	WP(w2, dropdown_d).parent_wnd_class = w->window_class;
 
	WP(w2, dropdown_d).parent_wnd_num = w->window_number;
 
	WP(w2, dropdown_d).parent_button = button;
 

	
 
	WP(w2,dropdown_d).num_items = i;
 
	WP(w2,dropdown_d).selected_index = selected;
 
	WP(w2,dropdown_d).items = strings;
 
	WP(w2, dropdown_d).num_items = i;
 
	WP(w2, dropdown_d).selected_index = selected;
 
	WP(w2, dropdown_d).items = strings;
 

	
 
	WP(w2,dropdown_d).click_delay = 0;
 
	WP(w2,dropdown_d).drag_mode = true;
 
	WP(w2, dropdown_d).click_delay = 0;
 
	WP(w2, dropdown_d).drag_mode = true;
 
}
 

	
 

	
 
static void ResizeWidgets(Window *w, byte a, byte b)
 
{
 
	int16 offset = w->widget[a].left;
src/window.h
Show inline comments
 
@@ -234,13 +234,13 @@ struct Textbuf {
 
	uint16 length, width;       ///< the current size of the string. Width specifies screensize in pixels, length is in bytes
 
	bool caret;                 ///< is the caret ("_") visible or not
 
	uint16 caretpos;            ///< the current position of the caret in the buffer, in bytes
 
	uint16 caretxoffs;          ///< the current position of the caret in pixels
 
};
 

	
 
#define WP(ptr,str) (*(str*)(ptr)->custom)
 
#define WP(ptr, str) (*(str*)(ptr)->custom)
 
/* You cannot 100% reliably calculate the biggest custom struct as
 
 * the number of pointers in it and alignment will have a huge impact.
 
 * 96 is the largest window-size for 64-bit machines currently */
 
#define WINDOW_CUSTOM_SIZE 96
 

	
 
struct Scrollbar {
0 comments (0 inline, 0 general)