src/main_gui.cpp
branchNewGRF_ports
changeset 6871 5a9dc001e1ad
parent 6870 ca3fd1fbe311
child 6872 1c4a4a609f85
--- a/src/main_gui.cpp	Sat Oct 06 21:16:00 2007 +0000
+++ b/src/main_gui.cpp	Mon Dec 03 23:39:38 2007 +0000
@@ -19,6 +19,7 @@
 #include "viewport.h"
 #include "gfx.h"
 #include "player.h"
+#include "road.h"
 #include "command.h"
 #include "news.h"
 #include "town.h"
@@ -47,6 +48,7 @@
 #include "network/network_server.h"
 #include "network/network_gui.h"
 #include "industry.h"
+#include "transparency.h"
 
 static int _rename_id = 1;
 static int _rename_what = -1;
@@ -94,7 +96,7 @@
 		const Player *p = GetPlayer(_current_player);
 		Money money = min(p->player_money - p->current_loan, (Money)(atoi(str) / _currency->rate));
 
-		uint32 money_c = clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
+		uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
 
 		/* Give 'id' the money, and substract it from ourself */
 		DoCommandP(0, money_c, id, CcGiveMoney, CMD_GIVE_MONEY | CMD_MSG(STR_INSUFFICIENT_FUNDS));
@@ -117,20 +119,20 @@
  * @param placeproc Procedure which will be called when someone clicks on the map
  * @return true if the button is clicked, false if it's unclicked
  */
-bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, int mode, PlaceProc *placeproc)
+bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc)
 {
-	if (IsWindowWidgetDisabled(w, widget)) return false;
+	if (w->IsWidgetDisabled(widget)) return false;
 
 	SndPlayFx(SND_15_BEEP);
 	SetWindowDirty(w);
 
-	if (IsWindowWidgetLowered(w, widget)) {
+	if (w->IsWidgetLowered(widget)) {
 		ResetObjectToPlace();
 		return false;
 	}
 
 	SetObjectToPlace(cursor, PAL_NONE, mode, w->window_class, w->window_number);
-	LowerWindowWidget(w, widget);
+	w->LowerWidget(widget);
 	_place_proc = placeproc;
 	return true;
 }
@@ -156,22 +158,6 @@
 }
 
 
-/** Toggle all transparency options, except for signs */
-static void ToggleTransparency()
-{
-	static byte trans_opt = ~0;
-
-	if (GB(_transparent_opt, 1, 7) == 0) {
-		SB(_transparent_opt, 1, 7, GB(trans_opt, 1, 7));
-	} else {
-		trans_opt = _transparent_opt;
-		SB(_transparent_opt, 1, 7, 0);
-	}
-
-	MarkWholeScreenDirty();
-}
-
-
 static void MenuClickSettings(int index)
 {
 	switch (index) {
@@ -181,14 +167,17 @@
 		case 3: ShowNewGRFSettings(!_networking, true, true, &_grfconfig);   return;
 		case 4: ShowTransparencyToolbar(); break;
 
-		case  6: TOGGLEBIT(_display_opt, DO_SHOW_TOWN_NAMES);    break;
-		case  7: TOGGLEBIT(_display_opt, DO_SHOW_STATION_NAMES); break;
-		case  8: TOGGLEBIT(_display_opt, DO_SHOW_SIGNS);         break;
-		case  9: TOGGLEBIT(_display_opt, DO_WAYPOINTS);          break;
-		case 10: TOGGLEBIT(_display_opt, DO_FULL_ANIMATION);     break;
-		case 11: TOGGLEBIT(_display_opt, DO_FULL_DETAIL);        break;
-		case 12: ToggleTransparency(); break;
-		case 13: TOGGLEBIT(_transparent_opt, TO_SIGNS); break;
+		case  6: ToggleBit(_display_opt, DO_SHOW_TOWN_NAMES);    break;
+		case  7: ToggleBit(_display_opt, DO_SHOW_STATION_NAMES); break;
+		case  8: ToggleBit(_display_opt, DO_SHOW_SIGNS);         break;
+		case  9: ToggleBit(_display_opt, DO_WAYPOINTS);          break;
+		case 10: ToggleBit(_display_opt, DO_FULL_ANIMATION);     break;
+		case 11: ToggleBit(_display_opt, DO_FULL_DETAIL);        break;
+		case 12:
+			ToggleTransparency(TO_TREES);
+			ToggleTransparency(TO_HOUSES);
+			break;
+		case 13: ToggleTransparency(TO_SIGNS);                   break;
 	}
 	MarkWholeScreenDirty();
 }
@@ -363,7 +352,7 @@
 	if (_cursor.sprite == SPR_CURSOR_SIGN) {
 		ResetObjectToPlace();
 	} else {
-		SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, 1, WC_MAIN_TOOLBAR, 0);
+		SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, VHM_RECT, WC_MAIN_TOOLBAR, 0);
 		_place_proc = PlaceProc_Sign;
 	}
 }
@@ -465,10 +454,10 @@
 		y = 1;
 
 		for (; count != 0; count--, string++, sel--) {
-			byte color = HASBIT(dis, 0) ? 14 : (sel == 0) ? 12 : 16;
+			TextColour color = HasBit(dis, 0) ? TC_GREY : (sel == 0) ? TC_WHITE : TC_BLACK;
 			if (sel == 0) GfxFillRect(x, y, x + w->width - 3, y + 9, 0);
 
-			if (HASBIT(chk, 0)) DrawString(x + 2, y, STR_CHECKMARK, color);
+			if (HasBit(chk, 0)) DrawString(x + 2, y, STR_CHECKMARK, color);
 			DrawString(x + 2, y, string, color);
 
 			y += 10;
@@ -479,7 +468,7 @@
 
 	case WE_DESTROY: {
 			Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0);
-			RaiseWindowWidget(v, WP(w,menu_d).main_button);
+			v->RaiseWidget(WP(w,menu_d).main_button);
 			SetWindowDirty(v);
 			return;
 		}
@@ -566,7 +555,8 @@
 	switch (e->event) {
 	case WE_PAINT: {
 		int x,y;
-		byte sel, color;
+		byte sel;
+		TextColour color;
 		Player *p;
 		uint16 chk;
 
@@ -583,7 +573,7 @@
 			if (sel == 0) {
 				GfxFillRect(x, y, x + 238, y + 9, 0);
 			}
-			DrawString(x + 19, y, STR_NETWORK_CLIENT_LIST, 0x0);
+			DrawString(x + 19, y, STR_NETWORK_CLIENT_LIST, TC_FROMSTRING);
 			y += 10;
 			sel--;
 		}
@@ -599,8 +589,8 @@
 				SetDParam(0, p->index);
 				SetDParam(1, p->index);
 
-				color = (p->index == sel) ? 0xC : 0x10;
-				if (chk&1) color = 14;
+				color = (p->index == sel) ? TC_WHITE : TC_BLACK;
+				if (chk&1) color = TC_GREY;
 				DrawString(x + 19, y, STR_7021, color);
 
 				y += 10;
@@ -613,7 +603,7 @@
 
 	case WE_DESTROY: {
 		Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0);
-		RaiseWindowWidget(v, WP(w,menu_d).main_button);
+		v->RaiseWidget(WP(w,menu_d).main_button);
 		SetWindowDirty(v);
 		return;
 		}
@@ -715,7 +705,7 @@
 	int x = w->widget[GB(parent_button, 0, 8)].left;
 
 	assert(disabled_mask == 0 || item_count <= 8);
-	LowerWindowWidget(w, parent_button);
+	w->LowerWidget(parent_button);
 	InvalidateWidget(w, parent_button);
 
 	DeleteWindowById(WC_TOOLBAR_MENU, 0);
@@ -726,7 +716,7 @@
 	 * we clicked on and w->left the toolbar window itself. So meaning that
 	 * the default position is aligned with the left side of the clicked button */
 	width = max(GetStringListMaxWidth(base_string, item_count) + 6, 140);
-	x = w->left + clamp(x, 0, w->width - width); // or alternatively '_screen.width - width'
+	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;
@@ -750,7 +740,7 @@
 {
 	int x = w->widget[main_button].left + w->left;
 
-	LowerWindowWidget(w, main_button);
+	w->LowerWidget(main_button);
 	InvalidateWidget(w, main_button);
 
 	DeleteWindowById(WC_TOOLBAR_MENU, 0);
@@ -832,7 +822,7 @@
 	int dis = -1;
 
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_TRAIN && IsFrontEngine(v)) CLRBIT(dis, v->owner);
+		if (v->type == VEH_TRAIN && IsFrontEngine(v)) ClrBit(dis, v->owner);
 	}
 	PopupMainPlayerToolbMenu(w, 13, dis);
 }
@@ -843,7 +833,7 @@
 	int dis = -1;
 
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_ROAD && IsRoadVehFront(v)) CLRBIT(dis, v->owner);
+		if (v->type == VEH_ROAD && IsRoadVehFront(v)) ClrBit(dis, v->owner);
 	}
 	PopupMainPlayerToolbMenu(w, 14, dis);
 }
@@ -854,7 +844,7 @@
 	int dis = -1;
 
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_SHIP) CLRBIT(dis, v->owner);
+		if (v->type == VEH_SHIP) ClrBit(dis, v->owner);
 	}
 	PopupMainPlayerToolbMenu(w, 15, dis);
 }
@@ -865,7 +855,7 @@
 	int dis = -1;
 
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_AIRCRAFT) CLRBIT(dis, v->owner);
+		if (v->type == VEH_AIRCRAFT) ClrBit(dis, v->owner);
 	}
 	PopupMainPlayerToolbMenu(w, 16, dis);
 }
@@ -941,7 +931,7 @@
 {
 	const Player *p = GetPlayer(_local_player);
 	/* The standard road button is *always* available */
-	Window *w2 = PopupMainToolbMenu(w, 20, STR_180A_ROAD_CONSTRUCTION, 2, ~(p->avail_roadtypes | 1));
+	Window *w2 = PopupMainToolbMenu(w, 20, STR_180A_ROAD_CONSTRUCTION, 2, ~(p->avail_roadtypes | ROADTYPES_ROAD));
 	WP(w2, menu_d).sel_index = _last_built_roadtype;
 }
 
@@ -981,14 +971,14 @@
 
 	w = PopupMainToolbMenu(w, 2, STR_02C3_GAME_OPTIONS, 14, 0);
 
-	if (HASBIT(_display_opt, DO_SHOW_TOWN_NAMES))    SETBIT(x,  6);
-	if (HASBIT(_display_opt, DO_SHOW_STATION_NAMES)) SETBIT(x,  7);
-	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 (GB(_transparent_opt, 1, 7) != 0)      SETBIT(x, 12);
-	if (HASBIT(_transparent_opt, TO_SIGNS))   SETBIT(x, 13);
+	if (HasBit(_display_opt, DO_SHOW_TOWN_NAMES))    SetBit(x,  6);
+	if (HasBit(_display_opt, DO_SHOW_STATION_NAMES)) SetBit(x,  7);
+	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;
 }
 
@@ -1005,7 +995,7 @@
 		HandleButtonClick(w, 6);
 		SetWindowDirty(w);
 
-		_patches_newgame.starting_year = clamp(_patches_newgame.starting_year - 1, MIN_YEAR, MAX_YEAR);
+		_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year - 1, MIN_YEAR, MAX_YEAR);
 		SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
 	}
 	_left_button_clicked = false;
@@ -1018,7 +1008,7 @@
 		HandleButtonClick(w, 7);
 		SetWindowDirty(w);
 
-		_patches_newgame.starting_year = clamp(_patches_newgame.starting_year + 1, MIN_YEAR, MAX_YEAR);
+		_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + 1, MIN_YEAR, MAX_YEAR);
 		SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
 	}
 	_left_button_clicked = false;
@@ -1207,42 +1197,42 @@
  */
 static void EditorTerraformClick_Dynamite(Window *w)
 {
-	HandlePlacePushButton(w, 4, ANIMCURSOR_DEMOLISH, 1, PlaceProc_DemolishArea);
+	HandlePlacePushButton(w, 4, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea);
 }
 
 static void EditorTerraformClick_LowerBigLand(Window *w)
 {
-	HandlePlacePushButton(w, 5, ANIMCURSOR_LOWERLAND, 2, PlaceProc_LowerBigLand);
+	HandlePlacePushButton(w, 5, ANIMCURSOR_LOWERLAND, VHM_POINT, PlaceProc_LowerBigLand);
 }
 
 static void EditorTerraformClick_RaiseBigLand(Window *w)
 {
-	HandlePlacePushButton(w, 6, ANIMCURSOR_RAISELAND, 2, PlaceProc_RaiseBigLand);
+	HandlePlacePushButton(w, 6, ANIMCURSOR_RAISELAND, VHM_POINT, PlaceProc_RaiseBigLand);
 }
 
 static void EditorTerraformClick_LevelLand(Window *w)
 {
-	HandlePlacePushButton(w, 7, SPR_CURSOR_LEVEL_LAND, 2, PlaceProc_LevelLand);
+	HandlePlacePushButton(w, 7, SPR_CURSOR_LEVEL_LAND, VHM_POINT, PlaceProc_LevelLand);
 }
 
 static void EditorTerraformClick_WaterArea(Window *w)
 {
-	HandlePlacePushButton(w, 8, SPR_CURSOR_CANAL, 1, PlaceProc_WaterArea);
+	HandlePlacePushButton(w, 8, SPR_CURSOR_CANAL, VHM_RECT, PlaceProc_WaterArea);
 }
 
 static void EditorTerraformClick_RockyArea(Window *w)
 {
-	HandlePlacePushButton(w, 9, SPR_CURSOR_ROCKY_AREA, 1, PlaceProc_RockyArea);
+	HandlePlacePushButton(w, 9, SPR_CURSOR_ROCKY_AREA, VHM_RECT, PlaceProc_RockyArea);
 }
 
 static void EditorTerraformClick_DesertLightHouse(Window *w)
 {
-	HandlePlacePushButton(w, 10, SPR_CURSOR_LIGHTHOUSE, 1, (_opt.landscape == LT_TROPIC) ? PlaceProc_DesertArea : PlaceProc_LightHouse);
+	HandlePlacePushButton(w, 10, SPR_CURSOR_LIGHTHOUSE, VHM_RECT, (_opt.landscape == LT_TROPIC) ? PlaceProc_DesertArea : PlaceProc_LightHouse);
 }
 
 static void EditorTerraformClick_Transmitter(Window *w)
 {
-	HandlePlacePushButton(w, 11, SPR_CURSOR_TRANSMITTER, 1, PlaceProc_Transmitter);
+	HandlePlacePushButton(w, 11, SPR_CURSOR_TRANSMITTER, VHM_RECT, PlaceProc_Transmitter);
 }
 
 static const uint16 _editor_terraform_keycodes[] = {
@@ -1319,7 +1309,7 @@
 			} while (--n);
 		}
 
-		if (IsWindowWidgetLowered(w, 5) || IsWindowWidgetLowered(w, 6)) // change area-size if raise/lower corner is selected
+		if (w->IsWidgetLowered(5) || w->IsWidgetLowered(6)) // change area-size if raise/lower corner is selected
 			SetTileSelectSize(_terraform_size, _terraform_size);
 
 		break;
@@ -1346,7 +1336,7 @@
 			HandleButtonClick(w, e->we.click.widget);
 			size += _terraform_size;
 
-			if (!IS_INT_INSIDE(size, 1, 8 + 1)) return;
+			if (!IsInsideMM(size, 1, 8 + 1)) return;
 			_terraform_size = size;
 
 			SndPlayFx(SND_15_BEEP);
@@ -1369,8 +1359,8 @@
 	case WE_TIMEOUT: {
 		uint i;
 		for (i = 0; i < w->widget_count; i++) {
-			if (IsWindowWidgetLowered(w, i)) {
-				RaiseWindowWidget(w, i);
+			if (w->IsWidgetLowered(i)) {
+				w->RaiseWidget(i);
 				InvalidateWidget(w, i);
 			}
 			if (i == 3) i = 11;
@@ -1466,13 +1456,13 @@
 		break;
 
 	case WE_CREATE:
-		LowerWindowWidget(w, _scengen_town_size + 7);
+		w->LowerWidget(_scengen_town_size + 7);
 		break;
 
 	case WE_CLICK:
 		switch (e->we.click.widget) {
 		case 4: // new town
-			HandlePlacePushButton(w, 4, SPR_CURSOR_TOWN, 1, PlaceProc_Town);
+			HandlePlacePushButton(w, 4, SPR_CURSOR_TOWN, VHM_RECT, PlaceProc_Town);
 			break;
 		case 5: {// random town
 			Town *t;
@@ -1502,17 +1492,17 @@
 		}
 
 		case 7: case 8: case 9: case 10:
-			RaiseWindowWidget(w, _scengen_town_size + 7);
+			w->RaiseWidget(_scengen_town_size + 7);
 			_scengen_town_size = e->we.click.widget - 7;
-			LowerWindowWidget(w, _scengen_town_size + 7);
+			w->LowerWidget(_scengen_town_size + 7);
 			SetWindowDirty(w);
 			break;
 		}
 		break;
 
 	case WE_TIMEOUT:
-		RaiseWindowWidget(w, 5);
-		RaiseWindowWidget(w, 6);
+		w->RaiseWidget(5);
+		w->RaiseWidget(6);
 		SetWindowDirty(w);
 		break;
 	case WE_PLACE_OBJ:
@@ -1520,7 +1510,7 @@
 		break;
 	case WE_ABORT_PLACE_OBJ:
 		RaiseWindowButtons(w);
-		LowerWindowWidget(w, _scengen_town_size + 7);
+		w->LowerWidget(_scengen_town_size + 7);
 		SetWindowDirty(w);
 		break;
 	}
@@ -1618,18 +1608,18 @@
 		/* If spectator, disable all construction buttons
 		 * ie : Build road, rail, ships, airports and landscaping
 		 * Since enabled state is the default, just disable when needed */
-		SetWindowWidgetsDisabledState(w, _current_player == PLAYER_SPECTATOR, 19, 20, 21, 22, 23, WIDGET_LIST_END);
+		w->SetWidgetsDisabledState(_current_player == PLAYER_SPECTATOR, 19, 20, 21, 22, 23, WIDGET_LIST_END);
 		/* disable company list drop downs, if there are no companies */
-		SetWindowWidgetsDisabledState(w, ActivePlayerCount() == 0, 7, 8, 13, 14, 15, 16, WIDGET_LIST_END);
+		w->SetWidgetsDisabledState(ActivePlayerCount() == 0, 7, 8, 13, 14, 15, 16, WIDGET_LIST_END);
 
-		SetWindowWidgetDisabledState(w, 19, !CanBuildVehicleInfrastructure(VEH_TRAIN));
-		SetWindowWidgetDisabledState(w, 22, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
+		w->SetWidgetDisabledState(19, !CanBuildVehicleInfrastructure(VEH_TRAIN));
+		w->SetWidgetDisabledState(22, !CanBuildVehicleInfrastructure(VEH_AIRCRAFT));
 
 		DrawWindowWidgets(w);
 		break;
 
 	case WE_CLICK: {
-		if (_game_mode != GM_MENU && !IsWindowWidgetDisabled(w, e->we.click.widget))
+		if (_game_mode != GM_MENU && !w->IsWidgetDisabled(e->we.click.widget))
 			_toolbar_button_procs[e->we.click.widget](w);
 	} break;
 
@@ -1682,18 +1672,18 @@
 	} break;
 
 	case WE_ABORT_PLACE_OBJ: {
-		RaiseWindowWidget(w, 25);
+		w->RaiseWidget(25);
 		SetWindowDirty(w);
 	} break;
 
 	case WE_MOUSELOOP:
-		if (IsWindowWidgetLowered(w, 0) != !!_pause_game) {
-			ToggleWidgetLoweredState(w, 0);
+		if (w->IsWidgetLowered(0) != !!_pause_game) {
+			w->ToggleWidgetLoweredState(0);
 			InvalidateWidget(w, 0);
 		}
 
-		if (IsWindowWidgetLowered(w, 1) != !!_fast_forward) {
-			ToggleWidgetLoweredState(w, 1);
+		if (w->IsWidgetLowered(1) != !!_fast_forward) {
+			w->ToggleWidgetLoweredState(1);
 			InvalidateWidget(w, 1);
 		}
 		break;
@@ -1728,8 +1718,8 @@
 	case WE_TIMEOUT: {
 		uint i;
 		for (i = 2; i < w->widget_count; i++) {
-			if (IsWindowWidgetLowered(w, i)) {
-				RaiseWindowWidget(w, i);
+			if (w->IsWidgetLowered(i)) {
+				w->RaiseWidget(i);
 				InvalidateWidget(w, i);
 			}
 		}
@@ -1859,8 +1849,8 @@
 {
 	switch (e->event) {
 	case WE_PAINT:
-		SetWindowWidgetDisabledState(w, 6, _patches_newgame.starting_year <= MIN_YEAR);
-		SetWindowWidgetDisabledState(w, 7, _patches_newgame.starting_year >= MAX_YEAR);
+		w->SetWidgetDisabledState(6, _patches_newgame.starting_year <= MIN_YEAR);
+		w->SetWidgetDisabledState(7, _patches_newgame.starting_year >= MAX_YEAR);
 
 		/* Draw brown-red toolbar bg. */
 		GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2);
@@ -1869,12 +1859,12 @@
 		DrawWindowWidgets(w);
 
 		SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
-		DrawStringCenteredTruncated(w->widget[6].right, w->widget[7].left, 6, STR_00AF, 0);
+		DrawStringCenteredTruncated(w->widget[6].right, w->widget[7].left, 6, STR_00AF, TC_FROMSTRING);
 
 		/* We hide this panel when the toolbar space gets too small */
 		if (w->widget[4].left != w->widget[4].right) {
-			DrawStringCenteredTruncated(w->widget[4].left + 1, w->widget[4].right - 1,  1, STR_0221_OPENTTD, 0);
-			DrawStringCenteredTruncated(w->widget[4].left + 1, w->widget[4].right - 1, 11, STR_0222_SCENARIO_EDITOR, 0);
+			DrawStringCenteredTruncated(w->widget[4].left + 1, w->widget[4].right - 1,  1, STR_0221_OPENTTD, TC_FROMSTRING);
+			DrawStringCenteredTruncated(w->widget[4].left + 1, w->widget[4].right - 1, 11, STR_0222_SCENARIO_EDITOR, TC_FROMSTRING);
 		}
 
 		break;
@@ -1910,7 +1900,7 @@
 	} break;
 
 	case WE_ABORT_PLACE_OBJ: {
-		RaiseWindowWidget(w, 25);
+		w->RaiseWidget(25);
 		SetWindowDirty(w);
 	} break;
 
@@ -1981,13 +1971,13 @@
 	} break;
 
 	case WE_MOUSELOOP:
-		if (IsWindowWidgetLowered(w, 0) != !!_pause_game) {
-			ToggleWidgetLoweredState(w, 0);
+		if (w->IsWidgetLowered(0) != !!_pause_game) {
+			w->ToggleWidgetLoweredState(0);
 			SetWindowDirty(w);
 		}
 
-		if (IsWindowWidgetLowered(w, 1) != !!_fast_forward) {
-			ToggleWidgetLoweredState(w, 1);
+		if (w->IsWidgetLowered(1) != !!_fast_forward) {
+			w->ToggleWidgetLoweredState(1);
 			SetWindowDirty(w);
 		}
 		break;
@@ -2019,7 +2009,7 @@
 	int x;
 	char buffer[256];
 
-	if (ni->display_mode == 3) {
+	if (ni->display_mode == NM_CALLBACK) {
 		str = _get_news_string_callback[ni->callback](ni);
 	} else {
 		CopyInDParam(0, ni->params, lengthof(ni->params));
@@ -2049,7 +2039,7 @@
 	old_dpi = _cur_dpi;
 	_cur_dpi = &tmp_dpi;
 
-	x = DoDrawString(buffer, pos, 0, 13);
+	x = DoDrawString(buffer, pos, 0, TC_LIGHT_BLUE);
 	_cur_dpi = old_dpi;
 
 	return x > 0;
@@ -2064,22 +2054,22 @@
 		DrawWindowWidgets(w);
 		SetDParam(0, _date);
 		DrawStringCentered(
-			70, 1, (_pause_game || _patches.status_long_date) ? STR_00AF : STR_00AE, 0
+			70, 1, (_pause_game || _patches.status_long_date) ? STR_00AF : STR_00AE, TC_FROMSTRING
 		);
 
 		if (p != NULL) {
 			/* Draw player money */
 			SetDParam(0, p->player_money);
-			DrawStringCentered(w->widget[2].left + 70, 1, STR_0004, 0);
+			DrawStringCentered(w->widget[2].left + 70, 1, STR_0004, TC_FROMSTRING);
 		}
 
 		/* Draw status bar */
 		if (w->message.msg) { // true when saving is active
-			DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_SAVING_GAME, 0);
+			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, 0);
+			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, 0);
+			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) {
 			/* 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)) {
@@ -2087,14 +2077,14 @@
 				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, 0);
+					DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING);
 				}
 			}
 		} else {
 			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, 0);
+				DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING);
 			}
 		}
 
@@ -2258,8 +2248,9 @@
 			case '5' | WKC_CTRL:
 			case '6' | WKC_CTRL:
 			case '7' | WKC_CTRL:
+			case '8' | WKC_CTRL:
 				/* Transparency toggle hot keys */
-				TOGGLEBIT(_transparent_opt, e->we.keypress.keycode - ('1' | WKC_CTRL));
+				ToggleTransparency((TransparencyOption)(e->we.keypress.keycode - ('1' | WKC_CTRL)));
 				MarkWholeScreenDirty();
 				break;
 
@@ -2268,7 +2259,7 @@
 				break;
 
 			case 'X':
-				ToggleTransparency();
+				ResetRestoreAllTransparency();
 				break;
 
 #ifdef ENABLE_NETWORK
@@ -2383,8 +2374,8 @@
 
 	CLRBITS(w->flags4, WF_WHITE_BORDER_MASK);
 
-	SetWindowWidgetDisabledState(w, 0, _networking && !_network_server); // if not server, disable pause button
-	SetWindowWidgetDisabledState(w, 1, _networking); // if networking, disable fast-forward button
+	w->SetWidgetDisabledState(0, _networking && !_network_server); // if not server, disable pause button
+	w->SetWidgetDisabledState(1, _networking); // if networking, disable fast-forward button
 
 	/* 'w' is for sure a WC_MAIN_TOOLBAR */
 	PositionMainToolbar(w);
@@ -2417,3 +2408,4 @@
 
 
 
+