summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/aircraft_cmd.cpp1
-rw-r--r--src/aircraft_gui.cpp2
-rw-r--r--src/airport_gui.cpp3
-rw-r--r--src/autoreplace_gui.cpp1
-rw-r--r--src/bridge_gui.cpp3
-rw-r--r--src/build_vehicle_gui.cpp1
-rw-r--r--src/clear_cmd.cpp2
-rw-r--r--src/console.cpp1
-rw-r--r--src/depot_gui.cpp3
-rw-r--r--src/dock_gui.cpp3
-rw-r--r--src/economy.cpp1
-rw-r--r--src/elrail.cpp2
-rw-r--r--src/engine_gui.cpp2
-rw-r--r--src/genworld_gui.cpp1
-rw-r--r--src/graph_gui.cpp1
-rw-r--r--src/group_gui.cpp3
-rw-r--r--src/gui.h7
-rw-r--r--src/industry_gui.cpp3
-rw-r--r--src/intro_gui.cpp1
-rw-r--r--src/main_gui.cpp2
-rw-r--r--src/misc.cpp4
-rw-r--r--src/misc_gui.cpp3
-rw-r--r--src/music_gui.cpp2
-rw-r--r--src/network/network_gui.cpp1
-rw-r--r--src/newgrf_gui.cpp1
-rw-r--r--src/news_gui.cpp2
-rw-r--r--src/openttd.cpp3
-rw-r--r--src/order_gui.cpp3
-rw-r--r--src/player_gui.cpp3
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/rail_gui.cpp3
-rw-r--r--src/road_cmd.cpp2
-rw-r--r--src/road_gui.cpp3
-rw-r--r--src/roadveh_cmd.cpp1
-rw-r--r--src/roadveh_gui.cpp3
-rw-r--r--src/settings_gui.cpp1
-rw-r--r--src/ship_cmd.cpp1
-rw-r--r--src/ship_gui.cpp3
-rw-r--r--src/signs_gui.cpp2
-rw-r--r--src/smallmap_gui.cpp3
-rw-r--r--src/sound.cpp1
-rw-r--r--src/station_gui.cpp2
-rw-r--r--src/subsidy_gui.cpp2
-rw-r--r--src/table/autorail.h34
-rw-r--r--src/terraform_gui.cpp3
-rw-r--r--src/timetable_gui.cpp1
-rw-r--r--src/town_cmd.cpp2
-rw-r--r--src/town_gui.cpp3
-rw-r--r--src/train_cmd.cpp1
-rw-r--r--src/train_gui.cpp2
-rw-r--r--src/transparency_gui.cpp1
-rw-r--r--src/tunnelbridge_cmd.cpp2
-rw-r--r--src/unmovable_cmd.cpp2
-rw-r--r--src/vehicle.cpp3
-rw-r--r--src/vehicle_gui.cpp3
-rw-r--r--src/viewport.cpp76
-rw-r--r--src/viewport_func.h80
-rw-r--r--src/viewport_type.h (renamed from src/viewport.h)84
-rw-r--r--src/water_cmd.cpp2
-rw-r--r--src/widget.cpp2
-rw-r--r--src/window.cpp3
-rw-r--r--src/window_gui.h2
62 files changed, 224 insertions, 176 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index f9c0f9502..6f81f27d5 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -36,6 +36,7 @@
#include "variables.h"
#include "autoreplace_func.h"
#include "autoreplace_gui.h"
+#include "gfx_func.h"
void Aircraft::UpdateDeltaXY(Direction direction)
{
diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp
index a831821a7..fe73681bf 100644
--- a/src/aircraft_gui.cpp
+++ b/src/aircraft_gui.cpp
@@ -10,13 +10,13 @@
#include "table/strings.h"
#include "gui.h"
#include "engine.h"
-#include "viewport.h"
#include "player.h"
#include "depot.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "strings_func.h"
#include "vehicle_func.h"
+#include "gfx_func.h"
/**
* Draw the details for the given vehicle at the position (x,y)
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index 19b1e1b58..fd258aa77 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -10,7 +10,6 @@
#include "gui.h"
#include "station_gui.h"
#include "terraform_gui.h"
-#include "viewport.h"
#include "command_func.h"
#include "station.h"
#include "airport.h"
@@ -18,6 +17,8 @@
#include "sound_func.h"
#include "window_func.h"
#include "variables.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
static byte _selected_airport_type;
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index 128bfe5cf..0a68db43e 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -18,6 +18,7 @@
#include "window_func.h"
#include "vehicle_func.h"
#include "autoreplace_func.h"
+#include "gfx_func.h"
static RailType _railtype_selected_in_replace_gui;
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
index d6a0dbbcd..5706ab3ba 100644
--- a/src/bridge_gui.cpp
+++ b/src/bridge_gui.cpp
@@ -7,7 +7,6 @@
#include "table/strings.h"
#include "gui.h"
#include "window_gui.h"
-#include "viewport.h"
#include "command_func.h"
#include "economy_func.h"
#include "variables.h"
@@ -16,6 +15,8 @@
#include "window_func.h"
#include "sound_func.h"
#include "map_func.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
static struct BridgeData {
uint8 last_size;
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index 4580799e1..3faa86d63 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -30,6 +30,7 @@
#include "date_func.h"
#include "vehicle_func.h"
#include "settings_type.h"
+#include "gfx_func.h"
struct buildvehicle_d {
VehicleType vehicle_type;
diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp
index d7c7e7e49..af8d66b16 100644
--- a/src/clear_cmd.cpp
+++ b/src/clear_cmd.cpp
@@ -7,7 +7,6 @@
#include "clear_map.h"
#include "table/strings.h"
#include "player.h"
-#include "viewport.h"
#include "command_func.h"
#include "bridge.h"
#include "landscape.h"
@@ -21,6 +20,7 @@
#include "functions.h"
#include "economy_func.h"
#include "table/clear_land.h"
+#include "viewport_func.h"
static CommandCost ClearTile_Clear(TileIndex tile, byte flags)
{
diff --git a/src/console.cpp b/src/console.cpp
index 2713744d2..a31a30717 100644
--- a/src/console.cpp
+++ b/src/console.cpp
@@ -19,6 +19,7 @@
#include "core/alloc_func.hpp"
#include "window_func.h"
#include "string_func.h"
+#include "gfx_func.h"
#define ICON_BUFFER 79
#define ICON_HISTORY_SIZE 20
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index ef11bf7b1..00c10be34 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -12,7 +12,8 @@
#include "table/sprites.h"
#include "gui.h"
#include "textbuf_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
#include "command_func.h"
#include "depot.h"
#include "vehicle_gui.h"
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index 59c13cbf2..f7115232b 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -12,13 +12,14 @@
#include "terraform_gui.h"
#include "window_gui.h"
#include "station_gui.h"
-#include "viewport.h"
#include "command_func.h"
#include "variables.h"
#include "water.h"
#include "window_func.h"
#include "vehicle_func.h"
#include "sound_func.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
static void ShowBuildDockStationPicker();
static void ShowBuildDocksDepotPicker();
diff --git a/src/economy.cpp b/src/economy.cpp
index 8e6a7e2d1..99191e111 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -43,6 +43,7 @@
#include "track_type.h"
#include "track_func.h"
#include "rail_map.h"
+#include "gfx_func.h"
/**
* Multiply two integer values and shift the results to right.
diff --git a/src/elrail.cpp b/src/elrail.cpp
index 4961d065e..6b1197998 100644
--- a/src/elrail.cpp
+++ b/src/elrail.cpp
@@ -48,7 +48,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "station_map.h"
-#include "viewport.h"
+#include "viewport_func.h"
#include "variables.h" /* ... same here */
#include "landscape.h"
#include "rail_type.h"
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index 1c6db10de..8924da6ed 100644
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -8,7 +8,7 @@
#include "table/sprites.h"
#include "gui.h"
#include "window_gui.h"
-#include "viewport.h"
+#include "gfx_func.h"
#include "engine.h"
#include "command_func.h"
#include "economy_func.h"
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 54f776540..1b34fc451 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -26,6 +26,7 @@
#include "sound_func.h"
#include "fios.h"
#include "string_func.h"
+#include "gfx_func.h"
/**
* In what 'mode' the GenerateLandscapeWindowProc is.
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index eb94a8325..995e3a63f 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -16,6 +16,7 @@
#include "core/alloc_func.hpp"
#include "window_func.h"
#include "date_func.h"
+#include "gfx_func.h"
/* Bitmasks of player and cargo indices that shouldn't be drawn. */
static uint _legend_excluded_players;
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index 9d7bcedf0..975841028 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -15,7 +15,6 @@
#include "depot.h"
#include "train.h"
#include "group.h"
-#include "viewport.h"
#include "debug.h"
#include "strings_func.h"
#include "core/alloc_func.hpp"
@@ -23,6 +22,8 @@
#include "vehicle_func.h"
#include "autoreplace_gui.h"
#include "string_func.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
struct Sorting {
diff --git a/src/gui.h b/src/gui.h
index 48d15e20e..8ff80c1dc 100644
--- a/src/gui.h
+++ b/src/gui.h
@@ -49,13 +49,6 @@ void ShowBuildAirToolbar();
void ShowGenerateLandscape();
void ShowHeightmapLoad();
-typedef void PlaceProc(TileIndex tile);
-void PlaceProc_DemolishArea(TileIndex tile);
-void PlaceProc_LevelLand(TileIndex tile);
-void PlaceProc_BuyLand(TileIndex tile);
-bool GUIPlaceProcDragXY(const WindowEvent *e);
-VARDEF PlaceProc *_place_proc;
-
/** Drag and drop selection process, or, what to do with an area of land when
* you've selected it. */
enum {
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index a6eeb2e38..9dd623d93 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -11,7 +11,8 @@
#include "window_gui.h"
#include "textbuf_gui.h"
#include "command_func.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
#include "industry.h"
#include "town.h"
#include "variables.h"
diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp
index dd5b61261..696b93760 100644
--- a/src/intro_gui.cpp
+++ b/src/intro_gui.cpp
@@ -19,6 +19,7 @@
#include "strings_func.h"
#include "window_func.h"
#include "fios.h"
+#include "gfx_func.h"
static const Widget _select_game_widgets[] = {
{ WWT_CAPTION, RESIZE_NONE, 13, 0, 335, 0, 13, STR_0307_OPENTTD, STR_NULL},
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 18d8662da..17a426043 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -13,7 +13,7 @@
#include "window_gui.h"
#include "window_func.h"
#include "textbuf_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
#include "player.h"
#include "command_func.h"
#include "news.h"
diff --git a/src/misc.cpp b/src/misc.cpp
index 6d52a47c1..853d41b76 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -18,7 +18,7 @@
#include "newgrf_house.h"
#include "cargotype.h"
#include "group.h"
-#include "viewport.h"
+#include "viewport_func.h"
#include "economy_func.h"
#include "zoom_func.h"
#include "functions.h"
@@ -27,6 +27,8 @@
#include "vehicle_func.h"
#include "texteff.hpp"
#include "string_func.h"
+#include "gfx_func.h"
+
char _name_array[512][32];
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 164e9157d..f403f0674 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -18,7 +18,8 @@
#include "window_gui.h"
#include "station_gui.h"
#include "textbuf_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
#include "station.h"
#include "command_func.h"
#include "player.h"
diff --git a/src/music_gui.cpp b/src/music_gui.cpp
index ba7ef6d2b..4b187e171 100644
--- a/src/music_gui.cpp
+++ b/src/music_gui.cpp
@@ -14,6 +14,8 @@
#include "strings_func.h"
#include "window_func.h"
#include "sound_func.h"
+#include "gfx_func.h"
+#include "core/math_func.hpp"
static byte _music_wnd_cursong;
static bool _song_is_active;
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index a15718057..20c5e8ca4 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -26,6 +26,7 @@
#include "../window_func.h"
#include "../core/alloc_func.hpp"
#include "../string_func.h"
+#include "../gfx_func.h"
#define BGC 5
#define BTC 15
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index e835eed6a..4978b1d54 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -16,6 +16,7 @@
#include "window_func.h"
#include "core/alloc_func.hpp"
#include "string_func.h"
+#include "gfx_func.h"
/** Parse an integerlist string and set each found value
* @param p the string to be parsed. Each element in the list is seperated by a
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index cd6611859..8a5811a77 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -7,7 +7,7 @@
#include "table/strings.h"
#include "gui.h"
#include "window_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
#include "news.h"
#include "variables.h"
#include "transparency.h"
diff --git a/src/openttd.cpp b/src/openttd.cpp
index f116264c0..ab8e81c2a 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -20,7 +20,8 @@
#include "station_map.h"
#include "town_map.h"
#include "tunnel_map.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
#include "window_func.h"
#include "window_gui.h"
#include "player.h"
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index 5ecb80259..208aa48e2 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -13,7 +13,8 @@
#include "station.h"
#include "town.h"
#include "command_func.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
#include "depot.h"
#include "waypoint.h"
#include "train.h"
diff --git a/src/player_gui.cpp b/src/player_gui.cpp
index dfa1ae2fe..22c9f4e28 100644
--- a/src/player_gui.cpp
+++ b/src/player_gui.cpp
@@ -9,7 +9,8 @@
#include "gui.h"
#include "window_gui.h"
#include "textbuf_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
#include "player.h"
#include "command_func.h"
#include "network/network.h"
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 9fc6ddad5..9b75dd386 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -16,7 +16,7 @@
#include "landscape.h"
#include "town_map.h"
#include "tunnel_map.h"
-#include "viewport.h"
+#include "viewport_func.h"
#include "command_func.h"
#include "pathfind.h"
#include "engine.h"
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index ed364ff5a..53a823ed1 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -12,7 +12,8 @@
#include "window_gui.h"
#include "station_gui.h"
#include "terraform_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
#include "command_func.h"
#include "station.h"
#include "waypoint.h"
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 3a27577ad..e7c62400d 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -16,7 +16,7 @@
#include "tile_cmd.h"
#include "landscape.h"
#include "town_map.h"
-#include "viewport.h"
+#include "viewport_func.h"
#include "command_func.h"
#include "player.h"
#include "town.h"
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 2486ed577..276b05281 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -10,7 +10,8 @@
#include "window_gui.h"
#include "station_gui.h"
#include "terraform_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
#include "command_func.h"
#include "variables.h"
#include "road_type.h"
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 49f83f974..82ea00394 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -40,6 +40,7 @@
#include "sound_func.h"
#include "variables.h"
#include "autoreplace_gui.h"
+#include "gfx_func.h"
static const uint16 _roadveh_images[63] = {
diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp
index 85baa684c..87cfcee5f 100644
--- a/src/roadveh_gui.cpp
+++ b/src/roadveh_gui.cpp
@@ -10,7 +10,8 @@
#include "table/strings.h"
#include "gui.h"
#include "window_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
#include "command_func.h"
#include "depot.h"
#include "vehicle_gui.h"
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 3109bd61d..28d1105ce 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -25,6 +25,7 @@
#include "vehicle_base.h"
#include "core/alloc_func.hpp"
#include "string_func.h"
+#include "gfx_func.h"
static uint32 _difficulty_click_a;
static uint32 _difficulty_click_b;
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 8d5e5081f..45d3fd8dc 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -36,6 +36,7 @@
#include "sound_func.h"
#include "variables.h"
#include "autoreplace_gui.h"
+#include "gfx_func.h"
static const uint16 _ship_sprites[] = {0x0E5D, 0x0E55, 0x0E65, 0x0E6D};
diff --git a/src/ship_gui.cpp b/src/ship_gui.cpp
index 69fda84b8..8d950c5ee 100644
--- a/src/ship_gui.cpp
+++ b/src/ship_gui.cpp
@@ -10,7 +10,8 @@
#include "table/sprites.h"
#include "gui.h"
#include "window_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
#include "depot.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index f806ac50f..87c1b860b 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -18,6 +18,8 @@
#include "core/alloc_func.hpp"
#include "window_func.h"
#include "map_func.h"
+#include "gfx_func.h"
+#include "viewport_func.h"
static const Sign **_sign_sort;
static uint _num_sign_sort;
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 8d1273bb5..ce583c9d5 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -16,7 +16,8 @@
#include "window_gui.h"
#include "tree_map.h"
#include "tunnel_map.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
#include "player.h"
#include "town.h"
#include "variables.h"
diff --git a/src/sound.cpp b/src/sound.cpp
index c2047c05e..02e65f46b 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -7,7 +7,6 @@
#include "landscape.h"
#include "mixer.h"
#include "sound_func.h"
-#include "viewport.h"
#include "fileio.h"
#include "newgrf_sound.h"
#include "fios.h"
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index cf19c1969..1648adb00 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -23,6 +23,8 @@
#include "strings_func.h"
#include "core/alloc_func.hpp"
#include "window_func.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
typedef int CDECL StationSortListingTypeFunction(const void*, const void*);
diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp
index 2b638a602..f88d288dd 100644
--- a/src/subsidy_gui.cpp
+++ b/src/subsidy_gui.cpp
@@ -15,6 +15,8 @@
#include "window_gui.h"
#include "strings_func.h"
#include "date_func.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
static void HandleSubsidyClick(int y)
{
diff --git a/src/table/autorail.h b/src/table/autorail.h
index 3d47e33e3..f80b500c8 100644
--- a/src/table/autorail.h
+++ b/src/table/autorail.h
@@ -52,21 +52,21 @@ static const int _AutorailTilehSprite[][6] = {
// maps each pixel of a tile (16x16) to a selection type
// (0,0) is the top corner, (16,16) the bottom corner
-static const byte _AutorailPiece[][16] = {
- { 2, 2, 2, 2, 2, 2, 0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T_DIR_HL },
+ { HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL },
+ { HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_VL, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL, HT_DIR_HL }
};
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp
index f074d64eb..24106090f 100644
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -11,7 +11,8 @@
#include "player.h"
#include "gui.h"
#include "window_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
#include "command_func.h"
#include "signs.h"
#include "variables.h"
diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp
index 9c70168b4..2c666033f 100644
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -16,6 +16,7 @@
#include "strings_func.h"
#include "vehicle_base.h"
#include "string_func.h"
+#include "gfx_func.h"
static int GetOrderFromTimetableWndPt(Window *w, int y, const Vehicle *v)
{
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 3336f7936..bf74d116f 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -13,7 +13,7 @@
#include "landscape.h"
#include "town_map.h"
#include "tunnel_map.h"
-#include "viewport.h"
+#include "viewport_func.h"
#include "town.h"
#include "command_func.h"
#include "industry.h"
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index 3c3db9c67..e0091cb26 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -8,7 +8,8 @@
#include "table/sprites.h"
#include "table/strings.h"
#include "town.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
#include "gui.h"
#include "window_gui.h"
#include "textbuf_gui.h"
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 36b452372..1c0253485 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -45,6 +45,7 @@
#include "sound_func.h"
#include "variables.h"
#include "autoreplace_gui.h"
+#include "gfx_func.h"
static bool TrainCheckIfLineEnds(Vehicle *v);
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index 4005bb072..2054c3e4c 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -9,7 +9,7 @@
#include "table/strings.h"
#include "gui.h"
#include "window_gui.h"
-#include "viewport.h"
+#include "gfx_func.h"
#include "command_func.h"
#include "vehicle_gui.h"
#include "depot.h"
diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp
index fe232e3ff..063c007fc 100644
--- a/src/transparency_gui.cpp
+++ b/src/transparency_gui.cpp
@@ -6,7 +6,6 @@
#include "table/strings.h"
#include "gui.h"
#include "window_gui.h"
-#include "viewport.h"
#include "variables.h"
#include "transparency.h"
#include "sound_func.h"
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index b04e1f729..fb23260e1 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -16,7 +16,7 @@
#include "landscape.h"
#include "tunnel_map.h"
#include "unmovable_map.h"
-#include "viewport.h"
+#include "viewport_func.h"
#include "command_func.h"
#include "player.h"
#include "town.h"
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index d11020421..a50c05ace 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -9,7 +9,7 @@
#include "tile_cmd.h"
#include "landscape.h"
#include "command_func.h"
-#include "viewport.h"
+#include "viewport_func.h"
#include "player.h"
#include "gui.h"
#include "station.h"
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 259cd6bba..bb29f7211 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -13,7 +13,8 @@
#include "tile_cmd.h"
#include "landscape.h"
#include "timetable.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
#include "news.h"
#include "command_func.h"
#include "saveload.h"
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 9e372b793..3df4fb6c7 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -16,7 +16,8 @@
#include "command_func.h"
#include "variables.h"
#include "vehicle_gui.h"
-#include "viewport.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
#include "train.h"
#include "newgrf_callbacks.h"
#include "newgrf_engine.h"
diff --git a/src/viewport.cpp b/src/viewport.cpp
index aa5cacae5..c07b2b36a 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -11,7 +11,7 @@
#include "table/sprites.h"
#include "table/strings.h"
#include "landscape.h"
-#include "viewport.h"
+#include "viewport_func.h"
#include "station.h"
#include "town.h"
#include "signs.h"
@@ -28,6 +28,8 @@
#define VIEWPORT_DRAW_MEM (65536 * 2)
+PlaceProc *_place_proc;
+Point _tile_fract_coords;
ZoomLevel _saved_scrollpos_zoom;
/**
@@ -865,23 +867,22 @@ static bool IsPartOfAutoLine(int px, int py)
px -= _thd.selstart.x;
py -= _thd.selstart.y;
- switch (_thd.drawstyle) {
- case HT_LINE | HT_DIR_X: return py == 0; // x direction
- case HT_LINE | HT_DIR_Y: return px == 0; // y direction
- case HT_LINE | HT_DIR_HU: return px == -py || px == -py - 16; // horizontal upper
- case HT_LINE | HT_DIR_HL: return px == -py || px == -py + 16; // horizontal lower
- case HT_LINE | HT_DIR_VL: return px == py || px == py + 16; // vertival left
- case HT_LINE | HT_DIR_VR: return px == py || px == py - 16; // vertical right
- default:
- NOT_REACHED();
- }
+ if ((_thd.drawstyle & ~HT_DIR_MASK) != HT_LINE) return false;
- /* useless, but avoids compiler warning this way */
- return 0;
+ switch (_thd.drawstyle & HT_DIR_MASK) {
+ case HT_DIR_X: return py == 0; // x direction
+ case HT_DIR_Y: return px == 0; // y direction
+ case HT_DIR_HU: return px == -py || px == -py - 16; // horizontal upper
+ case HT_DIR_HL: return px == -py || px == -py + 16; // horizontal lower
+ case HT_DIR_VL: return px == py || px == py + 16; // vertival left
+ case HT_DIR_VR: return px == py || px == py - 16; // vertical right
+ default:
+ NOT_REACHED();
+ }
}
// [direction][side]
-static const int _AutorailType[6][2] = {
+static const HighLightStyle _autorail_type[6][2] = {
{ HT_DIR_X, HT_DIR_X },
{ HT_DIR_Y, HT_DIR_Y },
{ HT_DIR_HU, HT_DIR_HL },
@@ -969,7 +970,7 @@ static void DrawTileSelection(const TileInfo *ti)
/* autorail highlight piece under cursor */
uint type = _thd.drawstyle & 0xF;
assert(type <= 5);
- DrawAutorailSelection(ti, _AutorailType[type][0]);
+ DrawAutorailSelection(ti, _autorail_type[type][0]);
} else if (IsPartOfAutoLine(ti->x, ti->y)) {
/* autorail highlighting long line */
int dir = _thd.drawstyle & ~0xF0;
@@ -982,7 +983,7 @@ static void DrawTileSelection(const TileInfo *ti)
side = Delta(Delta(TileX(start), TileX(ti->tile)), Delta(TileY(start), TileY(ti->tile)));
}
- DrawAutorailSelection(ti, _AutorailType[dir][side]);
+ DrawAutorailSelection(ti, _autorail_type[dir][side]);
}
return;
}
@@ -2229,9 +2230,9 @@ void SetTileSelectBigSize(int ox, int oy, int sx, int sy)
}
/** returns the best autorail highlight type from map coordinates */
-static byte GetAutorailHT(int x, int y)
+static HighLightStyle GetAutorailHT(int x, int y)
{
- return HT_RAIL | _AutorailPiece[x & 0xF][y & 0xF];
+ return HT_RAIL | _autorail_piece[x & 0xF][y & 0xF];
}
/**
@@ -2376,7 +2377,7 @@ static void VpStartPreSizing()
/** returns information about the 2x1 piece to be build.
* The lower bits (0-3) are the track type. */
-static byte Check2x1AutoRail(int mode)
+static HighLightStyle Check2x1AutoRail(int mode)
{
int fxpy = _tile_fract_coords.x + _tile_fract_coords.y;
int sxpy = (_thd.selend.x & 0xF) + (_thd.selend.y & 0xF);
@@ -2384,28 +2385,27 @@ static byte Check2x1AutoRail(int mode)
int sxmy = (_thd.selend.x & 0xF) - (_thd.selend.y & 0xF);
switch (mode) {
- case 0: // end piece is lower right
- if (fxpy >= 20 && sxpy <= 12) { /*SwapSelection(); DoRailroadTrack(0); */return 3; }
- if (fxmy < -3 && sxmy > 3) {/* DoRailroadTrack(0); */return 5; }
- return 1;
+ default: NOT_REACHED();
+ case 0: // end piece is lower right
+ if (fxpy >= 20 && sxpy <= 12) { /*SwapSelection(); DoRailroadTrack(0); */return HT_DIR_HL; }
+ if (fxmy < -3 && sxmy > 3) {/* DoRailroadTrack(0); */return HT_DIR_VR; }
+ return HT_DIR_Y;
- case 1:
- if (fxmy > 3 && sxmy < -3) { /*SwapSelection(); DoRailroadTrack(0); */return 4; }
- if (fxpy <= 12 && sxpy >= 20) { /*DoRailroadTrack(0); */return 2; }
- return 1;
+ case 1:
+ if (fxmy > 3 && sxmy < -3) { /*SwapSelection(); DoRailroadTrack(0); */return HT_DIR_VL; }
+ if (fxpy <= 12 && sxpy >= 20) { /*DoRailroadTrack(0); */return HT_DIR_HU; }
+ return HT_DIR_Y;
- case 2:
- if (fxmy > 3 && sxmy < -3) { /*DoRailroadTrack(3);*/ return 4; }
- if (fxpy >= 20 && sxpy <= 12) { /*SwapSelection(); DoRailroadTrack(0); */return 3; }
- return 0;
+ case 2:
+ if (fxmy > 3 && sxmy < -3) { /*DoRailroadTrack(3);*/ return HT_DIR_VL; }
+ if (fxpy >= 20 && sxpy <= 12) { /*SwapSelection(); DoRailroadTrack(0); */return HT_DIR_HL; }
+ return HT_DIR_X;
- case 3:
- if (fxmy < -3 && sxmy > 3) { /*SwapSelection(); DoRailroadTrack(3);*/ return 5; }
- if (fxpy <= 12 && sxpy >= 20) { /*DoRailroadTrack(0); */return 2; }
- return 0;
+ case 3:
+ if (fxmy < -3 && sxmy > 3) { /*SwapSelection(); DoRailroadTrack(3);*/ return HT_DIR_VR; }
+ if (fxpy <= 12 && sxpy >= 20) { /*DoRailroadTrack(0); */return HT_DIR_HU; }
+ return HT_DIR_X;
}
-
- return 0; // avoids compiler warnings
}
/** Check if the direction of start and end tile should be swapped based on
@@ -2749,7 +2749,7 @@ calc_heightdiff_single_direction:;
/* If dragging an area (eg dynamite tool) and it is actually a single
* row/column, change the type to 'line' to get proper calculation for height */
- style = _thd.next_drawstyle;
+ style = (HighLightStyle)_thd.next_drawstyle;
if (style & HT_RECT) {
if (dx == 1) {
style = HT_LINE | HT_DIR_Y;
diff --git a/src/viewport_func.h b/src/viewport_func.h
new file mode 100644
index 000000000..9a8d69125
--- /dev/null
+++ b/src/viewport_func.h
@@ -0,0 +1,80 @@
+/* $Id$ */
+
+/** @file viewport_func.h Functions related to (drawing on) viewports. */
+
+#ifndef VIEWPORT_FUNC_H
+#define VIEWPORT_FUNC_H
+
+#include "viewport_type.h"
+#include "vehicle_type.h"
+
+void SetSelectionRed(bool);
+
+void InitViewports();
+void DeleteWindowViewport(Window *w);
+void AssignWindowViewport(Window *w, int x, int y, int width, int height, uint32 follow_flags, ZoomLevel zoom);
+ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
+Point GetTileBelowCursor();
+void UpdateViewportPosition(Window *w);
+
+bool DoZoomInOutWindow(int how, Window *w);
+void ZoomInOrOutToCursorWindow(bool in, Window * w);
+Point GetTileZoomCenterWindow(bool in, Window * w);
+void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out);
+
+static inline void MaxZoomInOut(int how, Window *w)
+{
+ while (DoZoomInOutWindow(how, w)) {};
+}
+
+void OffsetGroundSprite(int x, int y);
+
+void DrawGroundSprite(SpriteID image, SpriteID pal, const SubSprite *sub = NULL);
+void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z, const SubSprite *sub = NULL);
+void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, int dz, int z, bool transparent = false, int bb_offset_x = 0, int bb_offset_y = 0, int bb_offset_z = 0, const SubSprite *sub = NULL);
+void *AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2);
+void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y, bool transparent = false, const SubSprite *sub = NULL);
+
+
+void StartSpriteCombine();
+void EndSpriteCombine();
+
+void HandleViewportClicked(const ViewPort *vp, int x, int y);
+void PlaceObject();
+void SetRedErrorSquare(TileIndex tile);
+void SetTileSelectSize(int w, int h);
+void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
+
+Vehicle *CheckMouseOverVehicle();
+
+void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method);
+void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, byte process);
+void VpSetPresizeRange(uint from, uint to);
+void VpSetPlaceSizingLimit(int limit);
+
+typedef void PlaceProc(TileIndex tile);
+void PlaceProc_DemolishArea(TileIndex tile);
+void PlaceProc_LevelLand(TileIndex tile);
+void PlaceProc_BuyLand(TileIndex tile);
+bool GUIPlaceProcDragXY(const WindowEvent *e);
+
+/* common button handler */
+bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc);
+
+void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom);
+
+void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode, Window *w);
+void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num);
+
+void ResetObjectToPlace();
+
+bool ScrollWindowTo(int x, int y, Window *w, bool instant = false);
+
+bool ScrollMainWindowToTile(TileIndex tile, bool instant = false);
+bool ScrollMainWindowTo(int x, int y, bool instant = false);
+
+extern PlaceProc *_place_proc;
+extern Point _tile_fract_coords;
+extern TileHighlightData _thd;
+
+#endif /* VIEWPORT_FUNC_H */
diff --git a/src/viewport.h b/src/viewport_type.h
index 11c8f992e..4d9f7c75a 100644
--- a/src/viewport.h
+++ b/src/viewport_type.h
@@ -1,15 +1,13 @@
/* $Id$ */
-/** @file viewport.h */
+/** @file viewport_type.h Types related to viewports. */
-#ifndef VIEWPORT_H
-#define VIEWPORT_H
+#ifndef VIEWPORT_TYPE_H
+#define VIEWPORT_TYPE_H
#include "zoom_type.h"
#include "window_type.h"
-#include "vehicle_type.h"
-#include "gfx_func.h"
-#include "gui.h"
+#include "tile_type.h"
struct ViewPort {
int left,top; // screen coordinates for the viewport
@@ -21,33 +19,12 @@ struct ViewPort {
ZoomLevel zoom;
};
-void SetSelectionRed(bool);
-
-/* viewport.cpp */
-void InitViewports();
-void DeleteWindowViewport(Window *w);
-void AssignWindowViewport(Window *w, int x, int y,
- int width, int height, uint32 follow_flags, ZoomLevel zoom);
-ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
-Point GetTileBelowCursor();
-void UpdateViewportPosition(Window *w);
-
enum {
ZOOM_IN = 0,
ZOOM_OUT = 1,
ZOOM_NONE = 2, // hack, used to update the button status
};
-bool DoZoomInOutWindow(int how, Window *w);
-void ZoomInOrOutToCursorWindow(bool in, Window * w);
-Point GetTileZoomCenterWindow(bool in, Window * w);
-void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out);
-
-static inline void MaxZoomInOut(int how, Window *w)
-{
- while (DoZoomInOutWindow(how, w)) {};
-}
-
/**
* Some values for constructing bounding boxes (BB). The Z positions under bridges are:
* z=0..5 Everything that can be built under low bridges.
@@ -59,26 +36,6 @@ enum {
BB_Z_SEPARATOR = 7, ///< Separates the bridge/tunnel from the things under/above it.
};
-void OffsetGroundSprite(int x, int y);
-
-void DrawGroundSprite(SpriteID image, SpriteID pal, const SubSprite *sub = NULL);
-void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z, const SubSprite *sub = NULL);
-void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, int dz, int z, bool transparent = false, int bb_offset_x = 0, int bb_offset_y = 0, int bb_offset_z = 0, const SubSprite *sub = NULL);
-void *AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2);
-void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y, bool transparent = false, const SubSprite *sub = NULL);
-
-
-void StartSpriteCombine();
-void EndSpriteCombine();
-
-void HandleViewportClicked(const ViewPort *vp, int x, int y);
-void PlaceObject();
-void SetRedErrorSquare(TileIndex tile);
-void SetTileSelectSize(int w, int h);
-void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
-
-Vehicle *CheckMouseOverVehicle();
-
/** Viewport place method (type of highlighted area and placed objects) */
enum ViewportPlaceMethod {
VPM_X_OR_Y = 0, ///< drag in X or Y direction
@@ -100,14 +57,8 @@ enum ViewportHighlightMode {
VHM_RAIL = 5, ///< rail pieces
};
-void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method);
-void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, byte process);
-void VpSetPresizeRange(uint from, uint to);
-void VpSetPlaceSizingLimit(int limit);
-
/* highlighting draw styles */
-typedef byte HighLightStyle;
-enum HighLightStyles {
+enum HighLightStyle {
HT_NONE = 0x00,
HT_RECT = 0x80,
HT_POINT = 0x40,
@@ -127,6 +78,8 @@ enum HighLightStyles {
HT_DIR_VR = 5, ///< vertical right
HT_DIR_MASK = 0x7 ///< masks the drag-direction
};
+DECLARE_ENUM_AS_BIT_SET(HighLightStyle);
+
struct TileHighlightData {
Point size;
@@ -158,25 +111,4 @@ struct TileHighlightData {
TileIndex redsq;
};
-
-/* common button handler */
-bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, ViewportHighlightMode mode, PlaceProc *placeproc);
-
-VARDEF Point _tile_fract_coords;
-
-extern TileHighlightData _thd;
-
-
-void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom);
-
-void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode, Window *w);
-void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num);
-
-void ResetObjectToPlace();
-
-bool ScrollWindowTo(int x, int y, Window *w, bool instant = false);
-
-bool ScrollMainWindowToTile(TileIndex tile, bool instant = false);
-bool ScrollMainWindowTo(int x, int y, bool instant = false);
-
-#endif /* VIEWPORT_H */
+#endif /* VIEWPORT_TYPE_H */
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 07ab11e26..bc11323e2 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -12,7 +12,7 @@
#include "table/strings.h"
#include "tile_cmd.h"
#include "landscape.h"
-#include "viewport.h"
+#include "viewport_func.h"
#include "command_func.h"
#include "town.h"
#include "news.h"
diff --git a/src/widget.cpp b/src/widget.cpp
index 6e3db2595..3e3dd2357 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -7,7 +7,7 @@
#include "player.h"
#include "table/sprites.h"
#include "table/strings.h"
-#include "viewport.h"
+#include "gfx_func.h"
#include "window_gui.h"
#include "window_func.h"
diff --git a/src/window.cpp b/src/window.cpp
index c85faa5a6..9d1b8f57d 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -7,8 +7,9 @@
#include "openttd.h"
#include "debug.h"
#include "player.h"
-#include "viewport.h"
+#include "gfx_func.h"
#include "console.h"
+#include "viewport_func.h"
#include "variables.h"
#include "table/sprites.h"
#include "genworld.h"
diff --git a/src/window_gui.h b/src/window_gui.h
index e4d0367ca..cb1ffa02d 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -7,7 +7,7 @@
#include "core/bitmath_func.hpp"
#include "vehicle_type.h"
-#include "viewport.h"
+#include "viewport_type.h"
/**
* The maximum number of windows that can be opened.