From 64d691bacc11cfca3b5c948dffb4eeb29aa8746e Mon Sep 17 00:00:00 2001 From: rubidium Date: Wed, 9 Jan 2008 09:45:45 +0000 Subject: [PATCH] (svn r11787) -Codechange: more header rewrites. This time related to viewport.h. --- src/aircraft_cmd.cpp | 1 + src/aircraft_gui.cpp | 2 +- src/airport_gui.cpp | 3 +- src/autoreplace_gui.cpp | 1 + src/bridge_gui.cpp | 3 +- src/build_vehicle_gui.cpp | 1 + src/clear_cmd.cpp | 2 +- src/console.cpp | 1 + src/depot_gui.cpp | 3 +- src/dock_gui.cpp | 3 +- src/economy.cpp | 1 + src/elrail.cpp | 2 +- src/engine_gui.cpp | 2 +- src/genworld_gui.cpp | 1 + src/graph_gui.cpp | 1 + src/group_gui.cpp | 3 +- src/gui.h | 7 --- src/industry_gui.cpp | 3 +- src/intro_gui.cpp | 1 + src/main_gui.cpp | 2 +- src/misc.cpp | 4 +- src/misc_gui.cpp | 3 +- src/music_gui.cpp | 2 + src/network/network_gui.cpp | 1 + src/newgrf_gui.cpp | 1 + src/news_gui.cpp | 2 +- src/openttd.cpp | 3 +- src/order_gui.cpp | 3 +- src/player_gui.cpp | 3 +- src/rail_cmd.cpp | 2 +- src/rail_gui.cpp | 3 +- src/road_cmd.cpp | 2 +- src/road_gui.cpp | 3 +- src/roadveh_cmd.cpp | 1 + src/roadveh_gui.cpp | 3 +- src/settings_gui.cpp | 1 + src/ship_cmd.cpp | 1 + src/ship_gui.cpp | 3 +- src/signs_gui.cpp | 2 + src/smallmap_gui.cpp | 3 +- src/sound.cpp | 1 - src/station_gui.cpp | 2 + src/subsidy_gui.cpp | 2 + src/table/autorail.h | 34 ++++++------ src/terraform_gui.cpp | 3 +- src/timetable_gui.cpp | 1 + src/town_cmd.cpp | 2 +- src/town_gui.cpp | 3 +- src/train_cmd.cpp | 1 + src/train_gui.cpp | 2 +- src/transparency_gui.cpp | 1 - src/tunnelbridge_cmd.cpp | 2 +- src/unmovable_cmd.cpp | 2 +- src/vehicle.cpp | 3 +- src/vehicle_gui.cpp | 3 +- src/viewport.cpp | 76 +++++++++++++------------- src/viewport_func.h | 80 +++++++++++++++++++++++++++ src/{viewport.h => viewport_type.h} | 84 +++-------------------------- src/water_cmd.cpp | 2 +- src/widget.cpp | 2 +- src/window.cpp | 3 +- src/window_gui.h | 2 +- 62 files changed, 224 insertions(+), 176 deletions(-) create mode 100644 src/viewport_func.h rename src/{viewport.h => viewport_type.h} (54%) diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index f9c0f95020..6f81f27d54 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 a831821a73..fe73681bfb 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 19b1e1b580..fd258aa777 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 128bfe5cf7..0a68db43ed 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 d6a0dbbcdd..5706ab3bac 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 4580799e17..3faa86d632 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 d7c7e7e494..af8d66b160 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 2713744d2b..a31a30717b 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 ef11bf7b1c..00c10be34b 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 59c13cbf2c..f7115232b2 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 8e6a7e2d17..99191e111d 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 4961d065ef..6b11979983 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 1c6db10ded..8924da6edd 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 54f7765405..1b34fc4518 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 eb94a8325f..995e3a63f1 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 9d7bcedf00..9758410280 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 48d15e20ec..8ff80c1dc3 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 a6eeb2e38f..9dd623d93c 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 dd5b612616..696b93760e 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 18d8662dae..17a426043a 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 6d52a47c17..853d41b769 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 164e9157d1..f403f06743 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 ba7ef6d2b2..4b187e1718 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 a157180571..20c5e8ca4d 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 e835eed6a5..4978b1d540 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 cd6611859b..8a5811a771 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 f116264c01..ab8e81c2aa 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 5ecb802599..208aa48e2f 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 dfa1ae2fe7..22c9f4e281 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 9fc6ddad5b..9b75dd3869 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 ed364ff5a1..53a823ed13 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 3a27577ad4..e7c62400dd 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 2486ed577d..276b052812 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 49f83f974a..82ea00394e 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 85baa684cb..87cfcee5ff 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 3109bd61dc..28d1105cea 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 8d5e5081f9..45d3fd8dc3 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 69fda84b87..8d950c5ee1 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 f806ac50ff..87c1b860bd 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 8d1273bb50..ce583c9d54 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 c2047c05ea..02e65f46bd 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 cf19c19693..1648adb005 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 2b638a602b..f88d288dde 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 3d47e33e35..f80b500c8b 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, 0, 0, 0, 5, 5, 5, 5, 5, 5 }, - { 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5 }, - { 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5 }, - { 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5 }, - { 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5 }, - { 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5 }, - { 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1 }, - { 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 }, - { 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1 }, - { 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, - { 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3 }, - { 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3 }, - { 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3 }, - { 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3 }, - { 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3 }, - { 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3 } +static const HighLightStyle _autorail_piece[][16] = { + { HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR }, + { HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR }, + { HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR }, + { HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR }, + { HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR }, + { HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_HU, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR, HT_DIR_VR }, + { HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y }, + { HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_X, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y }, + { HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_X, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y }, + { HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_X, HT_DIR_X, HT_DIR_X, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y, HT_DIR_Y }, + { 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 }, + { 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 }, + { 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 f074d64ebf..24106090f8 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 9c70168b4a..2c666033f0 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 3336f7936a..bf74d116ff 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 3c3db9c679..e0091cb268 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 36b452372a..1c0253485c 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 4005bb0722..2054c3e4c2 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 fe232e3ff0..063c007fcd 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 b04e1f7292..fb23260e10 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 d11020421e..a50c05ace1 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 259cd6bbab..bb29f7211e 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 9e372b793f..3df4fb6c7e 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 aa5cacae5e..c07b2b36af 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 0000000000..9a8d69125a --- /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 similarity index 54% rename from src/viewport.h rename to src/viewport_type.h index 11c8f992e3..4d9f7c75a9 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 07ab11e263..bc11323e24 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 6e3db25951..3e3dd2357c 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 c85faa5a65..9d1b8f57de 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 e4d0367ca1..cb1ffa02da 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.