src/smallmap_gui.cpp
author celestar
Wed, 13 Jun 2007 11:45:14 +0000
branchgamebalance
changeset 9911 0b8b245a2391
parent 9909 dce9a6923bb7
child 9912 1ac8aac92385
permissions -rw-r--r--
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
     3
/** @file smallmap_gui.cpp */
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1815
diff changeset
     6
#include "openttd.h"
4356
bc52a48e2590 (svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents: 4346
diff changeset
     7
#include "functions.h"
3234
986c30171e92 (svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents: 3184
diff changeset
     8
#include "bridge_map.h"
3144
426b825578f9 (svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents: 2989
diff changeset
     9
#include "clear_map.h"
3391
c3747f4b259b (svn r4199) - Codechange: Use industry map accessors to get industry graphics type.
peter1138
parents: 3338
diff changeset
    10
#include "industry_map.h"
3338
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3326
diff changeset
    11
#include "station_map.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 500
diff changeset
    12
#include "table/strings.h"
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
    13
#include "table/sprites.h"
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
    14
#include "landscape.h"
679
e959706a3e4d (svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents: 541
diff changeset
    15
#include "map.h"
1209
a1ac96655b79 (svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents: 1093
diff changeset
    16
#include "tile.h"
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
    17
#include "gui.h"
3144
426b825578f9 (svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents: 2989
diff changeset
    18
#include "tree_map.h"
3180
2123f8062a2d (svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents: 3144
diff changeset
    19
#include "tunnel_map.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    20
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
#include "gfx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    23
#include "player.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    24
#include "vehicle.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
#include "town.h"
337
66647f97e7c0 (svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents: 193
diff changeset
    26
#include "sound.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2062
diff changeset
    27
#include "variables.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
    29
static const Widget _smallmap_widgets[] = {
2725
5c632bc5be28 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2635
diff changeset
    30
{  WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
    31
{   WWT_CAPTION,  RESIZE_RIGHT,    13,    11,   433,     0,    13, STR_00B0_MAP,            STR_018C_WINDOW_TITLE_DRAG_THIS},
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
    32
{ WWT_STICKYBOX,     RESIZE_LR,    13,   434,   445,     0,    13, 0x0,                     STR_STICKY_BUTTON},
2907
65c92989a1f3 (svn r3462) - Fix: a one-off pixel alignment in the minimap window that "overflowed" its panel in the tropical climate (qball should be satisfied now)
Darkvater
parents: 2725
diff changeset
    33
{     WWT_PANEL,     RESIZE_RB,    13,     0,   445,    14,   257, 0x0,                     STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4938
diff changeset
    34
{     WWT_INSET,     RESIZE_RB,    13,     2,   443,    16,   255, 0x0,                     STR_NULL},
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
    35
{    WWT_IMGBTN,   RESIZE_LRTB,    13,   380,   401,   258,   279, SPR_IMG_SHOW_COUNTOURS,  STR_0191_SHOW_LAND_CONTOURS_ON_MAP},
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
    36
{    WWT_IMGBTN,   RESIZE_LRTB,    13,   402,   423,   258,   279, SPR_IMG_SHOW_VEHICLES,   STR_0192_SHOW_VEHICLES_ON_MAP},
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
    37
{    WWT_IMGBTN,   RESIZE_LRTB,    13,   424,   445,   258,   279, SPR_IMG_INDUSTRY,        STR_0193_SHOW_INDUSTRIES_ON_MAP},
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
    38
{    WWT_IMGBTN,   RESIZE_LRTB,    13,   380,   401,   280,   301, SPR_IMG_SHOW_ROUTES,     STR_0194_SHOW_TRANSPORT_ROUTES_ON},
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
    39
{    WWT_IMGBTN,   RESIZE_LRTB,    13,   402,   423,   280,   301, SPR_IMG_PLANTTREES,      STR_0195_SHOW_VEGETATION_ON_MAP},
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
    40
{    WWT_IMGBTN,   RESIZE_LRTB,    13,   424,   445,   280,   301, SPR_IMG_COMPANY_GENERAL, STR_0196_SHOW_LAND_OWNERS_ON_MAP},
4339
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
    41
{    WWT_IMGBTN,   RESIZE_LRTB,    13,   358,   379,   258,   279, SPR_IMG_SMALLMAP,        STR_SMALLMAP_CENTER},
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
    42
{    WWT_IMGBTN,   RESIZE_LRTB,    13,   358,   379,   280,   301, SPR_IMG_TOWN,            STR_0197_TOGGLE_TOWN_NAMES_ON_OFF},
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
    43
{     WWT_PANEL,    RESIZE_RTB,    13,     0,   357,   258,   301, 0x0,                     STR_NULL},
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
    44
{     WWT_PANEL,    RESIZE_RTB,    13,     0,   433,   302,   313, 0x0,                     STR_NULL},
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
    45
{ WWT_RESIZEBOX,   RESIZE_LRTB,    13,   434,   445,   302,   313, 0x0,                     STR_RESIZE_BUTTON},
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
    46
{  WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
static int _smallmap_type;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
static bool _smallmap_show_towns = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    52
/** Macro for ordinary entry of LegendAndColor */
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    53
#define MK(a,b) {a, b, false, false}
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    54
/** Macro for end of list marker in arrays of LegendAndColor */
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    55
#define MKEND() {0, STR_NULL, true, false}
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    56
/** Macro for break marker in arrays of LegendAndColor.
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    57
 * It will have valid data, though */
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    58
#define MS(a,b) {a, b, false, true}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    60
/** Structure for holding relevant data for legends in small map */
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    61
struct LegendAndColour {
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    62
	uint16 colour;     ///< color of the item on the map
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    63
	StringID legend;   ///< string corresponding to the colored item
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    64
	bool end;         ///< this is the end of the list
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    65
	bool col_break;   ///< perform a break and go one collumn further
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    66
};
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    67
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    68
/** Legend text giving the colours to look for on the minimap */
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    69
static const LegendAndColour _legend_land_contours[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    70
	MK(0x5A, STR_00F0_100M),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    71
	MK(0x5C, STR_00F1_200M),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    72
	MK(0x5E, STR_00F2_300M),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    73
	MK(0x1F, STR_00F3_400M),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    74
	MK(0x27, STR_00F4_500M),
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    75
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    76
	MS(0xD7, STR_00EB_ROADS),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    77
	MK(0x0A, STR_00EC_RAILROADS),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    78
	MK(0x98, STR_00ED_STATIONS_AIRPORTS_DOCKS),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    79
	MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    80
	MK(0x0F, STR_00EF_VEHICLES),
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
	MKEND()
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    84
static const LegendAndColour _legend_vehicles[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    85
	MK(0xB8, STR_00F5_TRAINS),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    86
	MK(0xBF, STR_00F6_ROAD_VEHICLES),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    87
	MK(0x98, STR_00F7_SHIPS),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    88
	MK(0x0F, STR_00F8_AIRCRAFT),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    89
	MS(0xD7, STR_00F9_TRANSPORT_ROUTES),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    90
	MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES),
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
	MKEND()
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
    94
static const LegendAndColour _legend_routes[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    95
	MK(0xD7, STR_00EB_ROADS),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    96
	MK(0x0A, STR_00EC_RAILROADS),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    97
	MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
    98
	MS(0x56, STR_011B_RAILROAD_STATION),
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   100
	MK(0xC2, STR_011C_TRUCK_LOADING_BAY),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   101
	MK(0xBF, STR_011D_BUS_STATION),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   102
	MK(0xB8, STR_011E_AIRPORT_HELIPORT),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   103
	MK(0x98, STR_011F_DOCK),
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
	MKEND()
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   107
static const LegendAndColour _legend_vegetation[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   108
	MK(0x52, STR_0120_ROUGH_LAND),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   109
	MK(0x54, STR_0121_GRASS_LAND),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   110
	MK(0x37, STR_0122_BARE_LAND),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   111
	MK(0x25, STR_0123_FIELDS),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   112
	MK(0x57, STR_0124_TREES),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   113
	MK(0xD0, STR_00FC_FOREST),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   114
	MS(0x0A, STR_0125_ROCKS),
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   116
	MK(0xC2, STR_012A_DESERT),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   117
	MK(0x98, STR_012B_SNOW),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   118
	MK(0xD7, STR_00F9_TRANSPORT_ROUTES),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   119
	MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES),
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
	MKEND()
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   123
static const LegendAndColour _legend_land_owners[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   124
	MK(0xCA, STR_0126_WATER),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   125
	MK(0x54, STR_0127_NO_OWNER),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   126
	MK(0xB4, STR_0128_TOWNS),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   127
	MK(0x20, STR_0129_INDUSTRIES),
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
	MKEND()
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
#undef MK
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
#undef MS
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
#undef MKEND
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
9911
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   134
/** Allow room for all industries, plus a terminator entry
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   135
 * This is required in order to have the indutry slots all filled up */
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   136
static LegendAndColour _legend_from_industries[NUM_INDUSTRYTYPES+1];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
9911
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   138
/**
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   139
 * Fills an array for the industries legends.
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   140
 */
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   141
void BuildIndustriesLegend()
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   142
{
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   143
	const IndustrySpec *indsp;
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   144
	uint j = 0;
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   145
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   146
	/* Add each name */
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   147
	for (IndustryType i = 0; i < NUM_INDUSTRYTYPES; i++) {
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   148
		indsp = GetIndustrySpec(i);
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   149
		if (HASBIT(indsp->climate_availability, _opt.landscape)) {
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   150
			_legend_from_industries[j].legend = indsp->name;
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   151
			_legend_from_industries[j].colour = indsp->map_colour;
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   152
			_legend_from_industries[j].col_break = (j % 6) == 0;  // break is performed on the 7th item
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   153
			_legend_from_industries[j].end = false;
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   154
			j++;
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   155
		}
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   156
	}
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   157
	/* Terminate the list */
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   158
	_legend_from_industries[j].end = true;
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   159
}
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   160
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   161
static const LegendAndColour * const _legend_table[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
	_legend_land_contours,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
	_legend_vehicles,
9911
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   164
	_legend_from_industries,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
	_legend_routes,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
	_legend_vegetation,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
	_legend_land_owners,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
2966
7f382cfeb93d (svn r3529) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help)
Darkvater
parents: 2955
diff changeset
   170
#if defined(OTTD_ALIGNMENT)
2062
00f7d339fdcb (svn r2571) Add explicit type Pixel for ... Pixels
tron
parents: 2049
diff changeset
   171
	static inline void WRITE_PIXELS(Pixel* d, uint32 val)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
	{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
#	if defined(TTD_BIG_ENDIAN)
2635
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2548
diff changeset
   174
		d[0] = GB(val, 24, 8);
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2548
diff changeset
   175
		d[1] = GB(val, 16, 8);
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2548
diff changeset
   176
		d[2] = GB(val,  8, 8);
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2548
diff changeset
   177
		d[3] = GB(val,  0, 8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
#	elif defined(TTD_LITTLE_ENDIAN)
2635
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2548
diff changeset
   179
		d[0] = GB(val,  0, 8);
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2548
diff changeset
   180
		d[1] = GB(val,  8, 8);
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2548
diff changeset
   181
		d[2] = GB(val, 16, 8);
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2548
diff changeset
   182
		d[3] = GB(val, 24, 8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
#	endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
/* need to use OR, otherwise we will overwrite the wrong pixels at the edges :( */
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4000
diff changeset
   187
	static inline void WRITE_PIXELS_OR(Pixel *d, uint32 val)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
	{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
#	if defined(TTD_BIG_ENDIAN)
2635
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2548
diff changeset
   190
		d[0] |= GB(val, 24, 8);
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2548
diff changeset
   191
		d[1] |= GB(val, 16, 8);
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2548
diff changeset
   192
		d[2] |= GB(val,  8, 8);
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2548
diff changeset
   193
		d[3] |= GB(val,  0, 8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
#	elif defined(TTD_LITTLE_ENDIAN)
2635
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2548
diff changeset
   195
		d[0] |= GB(val,  0, 8);
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2548
diff changeset
   196
		d[1] |= GB(val,  8, 8);
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2548
diff changeset
   197
		d[2] |= GB(val, 16, 8);
88b8b74c01ac (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2548
diff changeset
   198
		d[3] |= GB(val, 24, 8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
#	endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
#else
4549
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4481
diff changeset
   202
#	define WRITE_PIXELS(dst, val)   *(uint32*)(dst) = (val);
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4481
diff changeset
   203
#	define WRITE_PIXELS_OR(dst,val) *(uint32*)(dst) |= (val);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
2984
225bffc79071 (svn r3559) - CodeChange: simplify MKCOLOR(x) macro for smallmap_gui.c by adding a TO_LE32X() macro next to TO_BE32X(). The 'X' signifies them as macros and not-inline functions so they can be used in variable declarations.
Darkvater
parents: 2981
diff changeset
   206
#define MKCOLOR(x) TO_LE32X(x)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   208
/* Height encodings; 16 levels XXX - needs updating for more/finer heights! */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
static const uint32 _map_height_bits[16] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
	MKCOLOR(0x5A5A5A5A),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
	MKCOLOR(0x5A5B5A5B),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   212
	MKCOLOR(0x5B5B5B5B),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
	MKCOLOR(0x5B5C5B5C),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
	MKCOLOR(0x5C5C5C5C),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
	MKCOLOR(0x5C5D5C5D),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
	MKCOLOR(0x5D5D5D5D),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
	MKCOLOR(0x5D5E5D5E),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
	MKCOLOR(0x5E5E5E5E),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
	MKCOLOR(0x5E5F5E5F),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
	MKCOLOR(0x5F5F5F5F),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
	MKCOLOR(0x5F1F5F1F),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
	MKCOLOR(0x1F1F1F1F),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
	MKCOLOR(0x1F271F27),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
	MKCOLOR(0x27272727),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
	MKCOLOR(0x27272727),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6206
diff changeset
   228
struct AndOr {
1511
32b095e3da76 (svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents: 1350
diff changeset
   229
	uint32 mor;
32b095e3da76 (svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents: 1350
diff changeset
   230
	uint32 mand;
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6206
diff changeset
   231
};
1511
32b095e3da76 (svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents: 1350
diff changeset
   232
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4000
diff changeset
   233
static inline uint32 ApplyMask(uint32 colour, const AndOr *mask)
1511
32b095e3da76 (svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents: 1350
diff changeset
   234
{
32b095e3da76 (svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents: 1350
diff changeset
   235
	return (colour & mask->mand) | mask->mor;
32b095e3da76 (svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents: 1350
diff changeset
   236
}
32b095e3da76 (svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents: 1350
diff changeset
   237
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   238
1511
32b095e3da76 (svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents: 1350
diff changeset
   239
static const AndOr _smallmap_contours_andor[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   240
	{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   241
	{MKCOLOR(0x000A0A00), MKCOLOR(0xFF0000FF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   242
	{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   243
	{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   244
	{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   245
	{MKCOLOR(0x98989898), MKCOLOR(0x00000000)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   246
	{MKCOLOR(0xCACACACA), MKCOLOR(0x00000000)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   247
	{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   248
	{MKCOLOR(0xB5B5B5B5), MKCOLOR(0x00000000)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   249
	{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   250
	{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   251
	{MKCOLOR(0x000A0A00), MKCOLOR(0xFF0000FF)},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
1511
32b095e3da76 (svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents: 1350
diff changeset
   254
static const AndOr _smallmap_vehicles_andor[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   255
	{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   256
	{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   257
	{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   258
	{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   259
	{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   260
	{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   261
	{MKCOLOR(0xCACACACA), MKCOLOR(0x00000000)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   262
	{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   263
	{MKCOLOR(0xB5B5B5B5), MKCOLOR(0x00000000)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   264
	{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   265
	{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   266
	{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
1511
32b095e3da76 (svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents: 1350
diff changeset
   269
static const AndOr _smallmap_vegetation_andor[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   270
	{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   271
	{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   272
	{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   273
	{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   274
	{MKCOLOR(0x00575700), MKCOLOR(0xFF0000FF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   275
	{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   276
	{MKCOLOR(0xCACACACA), MKCOLOR(0x00000000)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   277
	{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   278
	{MKCOLOR(0xB5B5B5B5), MKCOLOR(0x00000000)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   279
	{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   280
	{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   281
	{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   284
typedef uint32 GetSmallMapPixels(TileIndex tile); // typedef callthrough function
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   285
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   286
/**
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   287
 * Draws one column of the small map in a certain mode onto the screen buffer. This
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   288
 * function looks exactly the same for all types
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   289
 *
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   290
 * @param dst Pointer to a part of the screen buffer to write to.
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   291
 * @param xc The X coordinate of the first tile in the column.
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   292
 * @param yc The Y coordinate of the first tile in the column
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   293
 * @param pitch Number of pixels to advance in the screen buffer each time a pixel is written.
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   294
 * @param reps Number of lines to draw
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   295
 * @param mask ?
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   296
 * @param proc Pointer to the colour function
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   297
 * @see GetSmallMapPixels(TileIndex)
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   298
 */
2062
00f7d339fdcb (svn r2571) Add explicit type Pixel for ... Pixels
tron
parents: 2049
diff changeset
   299
static void DrawSmallMapStuff(Pixel *dst, uint xc, uint yc, int pitch, int reps, uint32 mask, GetSmallMapPixels *proc)
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   300
{
2062
00f7d339fdcb (svn r2571) Add explicit type Pixel for ... Pixels
tron
parents: 2049
diff changeset
   301
	Pixel *dst_ptr_end = _screen.dst_ptr + _screen.width * _screen.height - _screen.width;
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   302
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   303
	do {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   304
		/* check if the tile (xc,yc) is within the map range */
1919
0ad642b26ff2 (svn r2425) - Fix (regression): wrong sprite for level-land cursor (thx Tron)
Darkvater
parents: 1918
diff changeset
   305
		if (xc < MapMaxX() && yc < MapMaxY()) {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   306
			/* check if the dst pointer points to a pixel inside the screen buffer */
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   307
			if (dst > _screen.dst_ptr && dst < dst_ptr_end)
1981
de031d2aed47 (svn r2487) Replace TILE_XY by TileXY/TileDiffXY
tron
parents: 1919
diff changeset
   308
				WRITE_PIXELS_OR(dst, proc(TileXY(xc, yc)) & mask);
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   309
		}
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   310
	/* switch to next tile in the column */
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   311
	} while (xc++, yc++, dst += pitch, --reps != 0);
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   312
}
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   313
1516
997a23b8b16c (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   314
997a23b8b16c (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   315
static inline TileType GetEffectiveTileType(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
{
1516
997a23b8b16c (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   317
	TileType t = GetTileType(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
	if (t == MP_TUNNELBRIDGE) {
3180
2123f8062a2d (svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents: 3144
diff changeset
   320
		TransportType tt;
2123f8062a2d (svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents: 3144
diff changeset
   321
3184
7405329343ce (svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents: 3180
diff changeset
   322
		if (IsTunnel(tile)) {
7405329343ce (svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents: 3180
diff changeset
   323
			tt = GetTunnelTransportType(tile);
7405329343ce (svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents: 3180
diff changeset
   324
		} else {
3234
986c30171e92 (svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents: 3184
diff changeset
   325
			tt = GetBridgeTransportType(tile);
3180
2123f8062a2d (svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents: 3144
diff changeset
   326
		}
2123f8062a2d (svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents: 3144
diff changeset
   327
		switch (tt) {
2123f8062a2d (svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents: 3144
diff changeset
   328
			case TRANSPORT_RAIL: t = MP_RAILWAY; break;
2123f8062a2d (svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents: 3144
diff changeset
   329
			case TRANSPORT_ROAD: t = MP_STREET;  break;
2123f8062a2d (svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents: 3144
diff changeset
   330
			default:             t = MP_WATER;   break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
	}
1516
997a23b8b16c (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   333
	return t;
997a23b8b16c (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   334
}
997a23b8b16c (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   335
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   336
/**
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   337
 * Return the color a tile would be displayed with in the small map in mode "Contour".
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   338
 * @param tile The tile of which we would like to get the color.
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   339
 * @return The color of tile in the small map in mode "Contour"
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   340
 */
1516
997a23b8b16c (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   341
static inline uint32 GetSmallMapContoursPixels(TileIndex tile)
997a23b8b16c (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   342
{
997a23b8b16c (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   343
	TileType t = GetEffectiveTileType(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
1511
32b095e3da76 (svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents: 1350
diff changeset
   345
	return
32b095e3da76 (svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents: 1350
diff changeset
   346
		ApplyMask(_map_height_bits[TileHeight(tile)], &_smallmap_contours_andor[t]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   348
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   349
/**
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   350
 * Return the color a tile would be displayed with in the small map in mode "Vehicles".
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   351
 *
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   352
 * @param tile The tile of which we would like to get the color.
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   353
 * @return The color of tile in the small map in mode "Vehicles"
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   354
 */
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   355
static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
{
1516
997a23b8b16c (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   357
	TileType t = GetEffectiveTileType(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
1511
32b095e3da76 (svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents: 1350
diff changeset
   359
	return ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   362
/**
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   363
 * Return the color a tile would be displayed with in the small map in mode "Industries".
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   364
 *
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   365
 * @param tile The tile of which we would like to get the color.
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   366
 * @return The color of tile in the small map in mode "Industries"
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   367
 */
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   368
static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   369
{
1516
997a23b8b16c (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   370
	TileType t = GetEffectiveTileType(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
	if (t == MP_INDUSTRY) {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   373
		return GetIndustrySpec(GetIndustryByTile(tile)->type)->map_colour * 0x01010101;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
	}
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   375
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   376
	return ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   378
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   379
/**
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   380
 * Return the color a tile would be displayed with in the small map in mode "Routes".
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   381
 *
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   382
 * @param tile The tile of which we would like to get the color.
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   383
 * @return The color of tile  in the small map in mode "Routes"
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   384
 */
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   385
static inline uint32 GetSmallMapRoutesPixels(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   386
{
1516
997a23b8b16c (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   387
	TileType t = GetEffectiveTileType(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
	uint32 bits;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   389
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   390
	if (t == MP_STATION) {
3338
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3326
diff changeset
   391
		switch (GetStationType(tile)) {
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3326
diff changeset
   392
			case STATION_RAIL:    bits = MKCOLOR(0x56565656); break;
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3326
diff changeset
   393
			case STATION_AIRPORT: bits = MKCOLOR(0xB8B8B8B8); break;
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3326
diff changeset
   394
			case STATION_TRUCK:   bits = MKCOLOR(0xC2C2C2C2); break;
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3326
diff changeset
   395
			case STATION_BUS:     bits = MKCOLOR(0xBFBFBFBF); break;
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3326
diff changeset
   396
			case STATION_DOCK:    bits = MKCOLOR(0x98989898); break;
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3326
diff changeset
   397
			default:              bits = MKCOLOR(0xFFFFFFFF); break;
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3326
diff changeset
   398
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
	} else {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   400
		/* ground color */
1511
32b095e3da76 (svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents: 1350
diff changeset
   401
		bits = ApplyMask(MKCOLOR(0x54545454), &_smallmap_contours_andor[t]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
	return bits;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
2955
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents: 2952
diff changeset
   407
static const uint32 _vegetation_clear_bits[] = {
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   408
	MKCOLOR(0x54545454), ///< full grass
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   409
	MKCOLOR(0x52525252), ///< rough land
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   410
	MKCOLOR(0x0A0A0A0A), ///< rocks
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   411
	MKCOLOR(0x25252525), ///< fields
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   412
	MKCOLOR(0x98989898), ///< snow
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   413
	MKCOLOR(0xC2C2C2C2), ///< desert
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   414
	MKCOLOR(0x54545454), ///< unused
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   415
	MKCOLOR(0x54545454), ///< unused
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   416
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   418
static inline uint32 GetSmallMapVegetationPixels(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   419
{
1516
997a23b8b16c (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   420
	TileType t = GetEffectiveTileType(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
	uint32 bits;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   423
	switch (t) {
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   424
		case MP_CLEAR:
3447
d136931464f7 (svn r4279) s/\<CL_/CLEAR_/
tron
parents: 3441
diff changeset
   425
			if (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) < 3) {
2955
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents: 2952
diff changeset
   426
				bits = MKCOLOR(0x37373737);
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents: 2952
diff changeset
   427
			} else {
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents: 2952
diff changeset
   428
				bits = _vegetation_clear_bits[GetClearGround(tile)];
27221592ebbc (svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents: 2952
diff changeset
   429
			}
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   430
			break;
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   431
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   432
		case MP_INDUSTRY:
3499
e95d6e5f66ae (svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents: 3447
diff changeset
   433
			bits = GetIndustryType(tile) == IT_FOREST ? MKCOLOR(0xD0D0D0D0) : MKCOLOR(0xB5B5B5B5);
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   434
			break;
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   435
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   436
		case MP_TREES:
3441
d1cef7047cd4 (svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents: 3421
diff changeset
   437
			if (GetTreeGround(tile) == TREE_GROUND_SNOW_DESERT) {
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9895
diff changeset
   438
				bits = (_opt.landscape == LT_ARCTIC) ? MKCOLOR(0x98575798) : MKCOLOR(0xC25757C2);
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2907
diff changeset
   439
			} else {
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   440
				bits = MKCOLOR(0x54575754);
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2907
diff changeset
   441
			}
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   442
			break;
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   443
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   444
		default:
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   445
			bits = ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]);
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   446
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   447
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   448
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
	return bits;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   450
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
4846
a6c472d934c0 (svn r6772) -Codechange: Do not abuse OWNER_SPECTATOR as the "owner" of the industry for
Darkvater
parents: 4727
diff changeset
   453
static uint32 _owner_colors[OWNER_END + 1];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   455
/**
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   456
 * Return the color a tile would be displayed with in the small map in mode "Owner".
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   457
 *
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   458
 * @param tile The tile of which we would like to get the color.
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   459
 * @return The color of tile in the small map in mode "Owner"
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   460
 */
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   461
static inline uint32 GetSmallMapOwnerPixels(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   462
{
2368
d5a31a409219 (svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents: 2332
diff changeset
   463
	Owner o;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   464
2368
d5a31a409219 (svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents: 2332
diff changeset
   465
	switch (GetTileType(tile)) {
4846
a6c472d934c0 (svn r6772) -Codechange: Do not abuse OWNER_SPECTATOR as the "owner" of the industry for
Darkvater
parents: 4727
diff changeset
   466
		case MP_INDUSTRY: o = OWNER_END;          break;
2368
d5a31a409219 (svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents: 2332
diff changeset
   467
		case MP_HOUSE:    o = OWNER_TOWN;         break;
d5a31a409219 (svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents: 2332
diff changeset
   468
		default:          o = GetTileOwner(tile); break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
2368
d5a31a409219 (svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents: 2332
diff changeset
   471
	return _owner_colors[o];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
static const uint32 _smallmap_mask_left[3] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   476
	MKCOLOR(0xFF000000),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
	MKCOLOR(0xFFFF0000),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   478
	MKCOLOR(0xFFFFFF00),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   481
static const uint32 _smallmap_mask_right[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   482
	MKCOLOR(0x000000FF),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   483
	MKCOLOR(0x0000FFFF),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   484
	MKCOLOR(0x00FFFFFF),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   485
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   486
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   487
/* each tile has 4 x pixels and 1 y pixel */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   488
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   489
static GetSmallMapPixels *_smallmap_draw_procs[] = {
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   490
	GetSmallMapContoursPixels,
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   491
	GetSmallMapVehiclesPixels,
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   492
	GetSmallMapIndustriesPixels,
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   493
	GetSmallMapRoutesPixels,
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   494
	GetSmallMapVegetationPixels,
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   495
	GetSmallMapOwnerPixels,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   496
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   497
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
static const byte _vehicle_type_colors[6] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   499
	184, 191, 152, 15, 215, 184
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   500
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   501
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   502
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   503
static void DrawVertMapIndicator(int x, int y, int x2, int y2)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   504
{
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2907
diff changeset
   505
	GfxFillRect(x, y,      x2, y + 3, 69);
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2907
diff changeset
   506
	GfxFillRect(x, y2 - 3, x2, y2,    69);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   507
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   508
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   509
static void DrawHorizMapIndicator(int x, int y, int x2, int y2)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
{
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2907
diff changeset
   511
	GfxFillRect(x,      y, x + 3, y2, 69);
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2907
diff changeset
   512
	GfxFillRect(x2 - 3, y, x2,    y2, 69);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   513
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   514
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   515
/**
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   516
 * Draws the small map.
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   517
 *
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   518
 * Basically, the small map is draw column of pixels by column of pixels. The pixels
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   519
 * are drawn directly into the screen buffer. The final map is drawn in multiple passes.
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   520
 * The passes are:
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   521
 * <ol><li>The colors of tiles in the different modes.</li>
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   522
 * <li>Town names (optional)</li></ol>
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   523
 *
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   524
 * @param dpi pointer to pixel to write onto
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   525
 * @param w pointer to Window struct
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   526
 * @param type type of map requested (vegetation, owners, routes, etc)
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   527
 * @param show_towns true if the town names should be displayed, false if not.
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   528
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_towns)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   530
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
	DrawPixelInfo *old_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   532
	int dx,dy, x, y, x2, y2;
2062
00f7d339fdcb (svn r2571) Add explicit type Pixel for ... Pixels
tron
parents: 2049
diff changeset
   533
	Pixel *ptr;
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   534
	int tile_x;
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   535
	int tile_y;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   536
	ViewPort *vp;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   537
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   538
	old_dpi = _cur_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   539
	_cur_dpi = dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   540
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
	/* clear it */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
	GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   543
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   544
	/* setup owner table */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
	if (type == 5) {
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4000
diff changeset
   546
		const Player *p;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   547
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
		/* fill with some special colors */
2368
d5a31a409219 (svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents: 2332
diff changeset
   549
		_owner_colors[OWNER_TOWN] = MKCOLOR(0xB4B4B4B4);
2332
fa9dc1350e22 (svn r2858) -Codechange: resolved some magic numbers (_Luca_)
truelight
parents: 2186
diff changeset
   550
		_owner_colors[OWNER_NONE] = MKCOLOR(0x54545454);
fa9dc1350e22 (svn r2858) -Codechange: resolved some magic numbers (_Luca_)
truelight
parents: 2186
diff changeset
   551
		_owner_colors[OWNER_WATER] = MKCOLOR(0xCACACACA);
4847
bd9e07155a34 (svn r6773) -eh...I had to test it didn't i, just forgot to save
Darkvater
parents: 4846
diff changeset
   552
		_owner_colors[OWNER_END]   = MKCOLOR(0x20202020); /* industry */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
		/* now fill with the player colors */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
		FOR_ALL_PLAYERS(p) {
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2907
diff changeset
   556
			if (p->is_active) {
1092
9adcd7820373 (svn r1593) Remove yet another alloca()
tron
parents: 1044
diff changeset
   557
				_owner_colors[p->index] =
4455
fed147abf037 (svn r6238) Use the colour stored in _colour_gradient[] instead of explicitly retrieving it with GetNonSprite()
tron
parents: 4435
diff changeset
   558
					_colour_gradient[p->player_color][5] * 0x01010101;
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2907
diff changeset
   559
			}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   560
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   561
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   562
3421
8ab76c47c72c (svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents: 3391
diff changeset
   563
	tile_x = WP(w,smallmap_d).scroll_x / TILE_SIZE;
8ab76c47c72c (svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents: 3391
diff changeset
   564
	tile_y = WP(w,smallmap_d).scroll_y / TILE_SIZE;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   565
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   566
	dx = dpi->left + WP(w,smallmap_d).subscroll;
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   567
	tile_x -= dx / 4;
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   568
	tile_y += dx / 4;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   569
	dx &= 3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   570
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   571
	dy = dpi->top;
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   572
	tile_x += dy / 2;
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   573
	tile_y += dy / 2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   574
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   575
	if (dy & 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   576
		tile_x++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   577
		dx += 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   578
		if (dx > 3) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   579
			dx -= 4;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   580
			tile_x--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   581
			tile_y++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   582
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   583
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   584
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   585
	ptr = dpi->dst_ptr - dx - 4;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   586
	x = - dx - 4;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   587
	y = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   588
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
   589
	for (;;) {
2989
99c95a3ebcaa (svn r3564) Several smaller changes:
tron
parents: 2984
diff changeset
   590
		uint32 mask = 0xFFFFFFFF;
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   591
		int reps;
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   592
		int t;
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   593
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   594
		/* distance from left edge */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   595
		if (x < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   596
			if (x < -3) goto skip_column;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   597
			/* mask to use at the left edge */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   598
			mask = _smallmap_mask_left[x + 3];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   599
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   601
		/* distance from right edge */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   602
		t = dpi->width - x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   603
		if (t < 4) {
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2907
diff changeset
   604
			if (t <= 0) break; /* exit loop */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   605
			/* mask to use at the right edge */
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   606
			mask &= _smallmap_mask_right[t - 1];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   607
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   608
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   609
		/* number of lines */
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   610
		reps = (dpi->height - y + 1) / 2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   611
		if (reps > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   612
//			assert(ptr >= dpi->dst_ptr);
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4000
diff changeset
   613
			DrawSmallMapStuff(ptr, tile_x, tile_y, dpi->pitch * 2, reps, mask, _smallmap_draw_procs[type]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   614
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   615
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   616
skip_column:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   617
		if (y == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   618
			tile_y++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   619
			y++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   620
			ptr += dpi->pitch;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   621
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   622
			tile_x--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   623
			y--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   624
			ptr -= dpi->pitch;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   625
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   626
		ptr += 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   627
		x += 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   628
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   629
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   630
	/* draw vehicles? */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   631
	if (type == 0 || type == 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   632
		Vehicle *v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   633
		bool skip;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   634
		byte color;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   635
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   636
		FOR_ALL_VEHICLES(v) {
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6206
diff changeset
   637
			if (v->type != VEH_SPECIAL &&
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   638
					(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   639
				/* Remap into flat coordinates. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   640
				Point pt = RemapCoords(
5096
144cdbb32045 (svn r7166) -Fix: [FS#402] MiniMap was misplacing vehicles sometimes (HMage)
KUDr
parents: 5070
diff changeset
   641
					v->x_pos / TILE_SIZE - WP(w,smallmap_d).scroll_x / TILE_SIZE, // divide each one separately because (a-b)/c != a/c-b/c in integer world
144cdbb32045 (svn r7166) -Fix: [FS#402] MiniMap was misplacing vehicles sometimes (HMage)
KUDr
parents: 5070
diff changeset
   642
					v->y_pos / TILE_SIZE - WP(w,smallmap_d).scroll_y / TILE_SIZE, //    dtto
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   643
					0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   644
				x = pt.x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   645
				y = pt.y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   646
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   647
				/* Check if y is out of bounds? */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   648
				y -= dpi->top;
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   649
				if (!IS_INT_INSIDE(y, 0, dpi->height)) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   650
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   651
				/* Default is to draw both pixels. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   652
				skip = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   653
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   654
				/* Offset X coordinate */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   655
				x -= WP(w,smallmap_d).subscroll + 3 + dpi->left;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   656
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   657
				if (x < 0) {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   658
					/* if x+1 is 0, that means we're on the very left edge,
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   659
					 *  and should thus only draw a single pixel */
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2907
diff changeset
   660
					if (++x != 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   661
					skip = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   662
				} else if (x >= dpi->width - 1) {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   663
					/* Check if we're at the very right edge, and if so draw only a single pixel */
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2907
diff changeset
   664
					if (x != dpi->width - 1) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   665
					skip = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   666
				}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   667
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   668
				/* Calculate pointer to pixel and the color */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   669
				ptr = dpi->dst_ptr + y * dpi->pitch + x;
6206
67358999d80d (svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents: 6144
diff changeset
   670
				color = (type == 1) ? _vehicle_type_colors[v->type] : 0xF;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   671
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   672
				/* And draw either one or two pixels depending on clipping */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   673
				ptr[0] = color;
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2907
diff changeset
   674
				if (!skip) ptr[1] = color;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   675
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   676
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   677
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   678
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   679
	if (show_towns) {
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   680
		const Town *t;
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   681
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   682
		FOR_ALL_TOWNS(t) {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   683
			/* Remap the town coordinate */
4346
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   684
			Point pt = RemapCoords(
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   685
				(int)(TileX(t->xy) * TILE_SIZE - WP(w, smallmap_d).scroll_x) / TILE_SIZE,
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   686
				(int)(TileY(t->xy) * TILE_SIZE - WP(w, smallmap_d).scroll_y) / TILE_SIZE,
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   687
				0);
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   688
			x = pt.x - WP(w,smallmap_d).subscroll + 3 - (t->sign.width_2 >> 1);
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   689
			y = pt.y;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   690
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   691
			/* Check if the town sign is within bounds */
4346
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   692
			if (x + t->sign.width_2 > dpi->left &&
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   693
					x < dpi->left + dpi->width &&
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   694
					y + 6 > dpi->top &&
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   695
					y < dpi->top + dpi->height) {
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   696
				/* And draw it. */
4346
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   697
				SetDParam(0, t->index);
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   698
				DrawString(x, y, STR_2056, 12);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   699
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   700
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   701
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   702
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   703
	/* Draw map indicators */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   704
	{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   705
		Point pt;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   706
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   707
		/* Find main viewport. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   708
		vp = FindWindowById(WC_MAIN_WINDOW,0)->viewport;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   709
1515
f466d02bd936 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   710
		pt = RemapCoords(WP(w, smallmap_d).scroll_x, WP(w, smallmap_d).scroll_y, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   711
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   712
		x = vp->virtual_left - pt.x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   713
		y = vp->virtual_top - pt.y;
3421
8ab76c47c72c (svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents: 3391
diff changeset
   714
		x2 = (x + vp->virtual_width) / TILE_SIZE;
8ab76c47c72c (svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents: 3391
diff changeset
   715
		y2 = (y + vp->virtual_height) / TILE_SIZE;
8ab76c47c72c (svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents: 3391
diff changeset
   716
		x /= TILE_SIZE;
8ab76c47c72c (svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents: 3391
diff changeset
   717
		y /= TILE_SIZE;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   718
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   719
		x -= WP(w,smallmap_d).subscroll;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   720
		x2 -= WP(w,smallmap_d).subscroll;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   721
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   722
		DrawVertMapIndicator(x, y, x, y2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   723
		DrawVertMapIndicator(x2, y, x2, y2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   724
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   725
		DrawHorizMapIndicator(x, y, x2, y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   726
		DrawHorizMapIndicator(x, y2, x2, y2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   727
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   728
	_cur_dpi = old_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   729
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   730
4339
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   731
void SmallMapCenterOnCurrentPos(Window *w)
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   732
{
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   733
	int x, y;
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   734
	ViewPort *vp;
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   735
	vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   736
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   737
	x  = ((vp->virtual_width  - (w->widget[4].right  - w->widget[4].left) * TILE_SIZE) / 2 + vp->virtual_left) / 4;
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   738
	y  = ((vp->virtual_height - (w->widget[4].bottom - w->widget[4].top ) * TILE_SIZE) / 2 + vp->virtual_top ) / 2 - TILE_SIZE * 2;
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   739
	WP(w, smallmap_d).scroll_x = (y - x) & ~0xF;
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   740
	WP(w, smallmap_d).scroll_y = (x + y) & ~0xF;
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   741
	SetWindowDirty(w);
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   742
}
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   743
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   744
static void SmallMapWindowProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   745
{
1918
68d78ef6833d (svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents: 1901
diff changeset
   746
	switch (e->event) {
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   747
		case WE_PAINT: {
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   748
			const LegendAndColour *tbl;
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   749
			int x, y, y_org;
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   750
			DrawPixelInfo new_dpi;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   751
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   752
			/* draw the window */
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   753
			SetDParam(0, STR_00E5_CONTOURS + _smallmap_type);
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   754
			DrawWindowWidgets(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   755
9911
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   756
			tbl = _legend_table[_smallmap_type];
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   757
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   758
			x = 4;
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   759
			y_org = w->height - 44 - 11;
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   760
			y = y_org;
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   761
			for (;;) {
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   762
				GfxFillRect(x,     y + 1, x + 8, y + 5, 0);
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   763
				GfxFillRect(x + 1, y + 2, x + 7, y + 4, tbl->colour);
9911
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   764
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   765
				if (_smallmap_type == 2) {
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   766
					/* Industry name must be formated, since it's not in tiny font in the specs.
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   767
					* So, draw with a parameter and use the STR_7065 string, which is tiny, black */
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   768
					SetDParam(0, tbl->legend);
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   769
					DrawString(x + 11, y, STR_7065, 0);
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   770
				} else {
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   771
					DrawString(x + 11, y, tbl->legend, 0);
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
   772
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   773
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   774
				tbl += 1;
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   775
				y += 6;
4339
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   776
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   777
				if (tbl->end) { // end of the list
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   778
					break;
9909
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   779
				} else if (tbl->col_break) {
dce9a6923bb7 (svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents: 9908
diff changeset
   780
					/*  break asked, continue at top, 123 pixels (one "row") to the right */
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   781
					x += 123;
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   782
					y = y_org;
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   783
				}
4339
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   784
			}
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   785
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   786
			if (!FillDrawPixelInfo(&new_dpi, 3, 17, w->width - 28 + 22, w->height - 64 - 11))
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   787
				return;
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   788
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   789
			DrawSmallMap(&new_dpi, w, _smallmap_type, _smallmap_show_towns);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   790
		} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   791
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   792
		case WE_CLICK:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   793
			switch (e->we.click.widget) {
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   794
				case 4: { // Map window
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   795
					Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0);
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   796
					Point pt;
5127
ed0ecbd3db0a (svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents: 5096
diff changeset
   797
ed0ecbd3db0a (svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents: 5096
diff changeset
   798
					/*
ed0ecbd3db0a (svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents: 5096
diff changeset
   799
					 * XXX: scrolling with the left mouse button is done by subsequently
ed0ecbd3db0a (svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents: 5096
diff changeset
   800
					 * clicking with the left mouse button; clicking once centers the
ed0ecbd3db0a (svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents: 5096
diff changeset
   801
					 * large map at the selected point. So by unclicking the left mouse
ed0ecbd3db0a (svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents: 5096
diff changeset
   802
					 * button here, it gets reclicked during the next inputloop, which
ed0ecbd3db0a (svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents: 5096
diff changeset
   803
					 * would make it look like the mouse is being dragged, while it is
ed0ecbd3db0a (svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents: 5096
diff changeset
   804
					 * actually being (virtually) clicked every inputloop.
ed0ecbd3db0a (svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents: 5096
diff changeset
   805
					 */
ed0ecbd3db0a (svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents: 5096
diff changeset
   806
					_left_button_clicked = false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   807
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   808
					pt = RemapCoords(WP(w,smallmap_d).scroll_x, WP(w,smallmap_d).scroll_y, 0);
5127
ed0ecbd3db0a (svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents: 5096
diff changeset
   809
					WP(w2, vp_d).scrollpos_x = pt.x + ((_cursor.pos.x - w->left + 2) << 4) - (w2->viewport->virtual_width >> 1);
ed0ecbd3db0a (svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents: 5096
diff changeset
   810
					WP(w2, vp_d).scrollpos_y = pt.y + ((_cursor.pos.y - w->top - 16) << 4) - (w2->viewport->virtual_height >> 1);
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   811
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   812
					SetWindowDirty(w);
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   813
				} break;
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   814
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   815
				case 5:  // Show land contours
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   816
				case 6:  // Show vehicles
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   817
				case 7:  // Show industries
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   818
				case 8:  // Show transport routes
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   819
				case 9:  // Show vegetation
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   820
				case 10: // Show land owners
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   821
					RaiseWindowWidget(w, _smallmap_type + 5);
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   822
					_smallmap_type = e->we.click.widget - 5;
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   823
					LowerWindowWidget(w, _smallmap_type + 5);
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   824
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   825
					SetWindowDirty(w);
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   826
					SndPlayFx(SND_15_BEEP);
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   827
					break;
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   828
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   829
				case 11: // Center the smallmap again
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   830
					SmallMapCenterOnCurrentPos(w);
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   831
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   832
					SetWindowDirty(w);
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   833
					SndPlayFx(SND_15_BEEP);
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   834
					break;
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   835
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   836
				case 12: // Toggle town names
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   837
					ToggleWidgetLoweredState(w, 12);
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   838
					_smallmap_show_towns = IsWindowWidgetLowered(w, 12);
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   839
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   840
					SetWindowDirty(w);
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   841
					SndPlayFx(SND_15_BEEP);
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   842
					break;
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   843
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   844
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   845
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   846
		case WE_RCLICK:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   847
			if (e->we.click.widget == 4) {
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   848
				if (_scrolling_viewport) return;
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   849
				_scrolling_viewport = true;
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   850
				_cursor.delta.x = 0;
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   851
				_cursor.delta.y = 0;
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   852
			}
4339
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   853
			break;
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   854
4435
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   855
		case WE_MOUSELOOP:
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   856
			/* update the window every now and then */
cde1d8fc5c8f (svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents: 4429
diff changeset
   857
			if ((++w->vscroll.pos & 0x1F) == 0) SetWindowDirty(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   858
			break;
4335
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   859
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   860
		case WE_SCROLL: {
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   861
			int x;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   862
			int y;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   863
			int sub;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   864
			int hx;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   865
			int hy;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   866
			int hvx;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   867
			int hvy;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   868
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   869
			_cursor.fix_at = true;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   870
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   871
			x = WP(w, smallmap_d).scroll_x;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   872
			y = WP(w, smallmap_d).scroll_y;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   873
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   874
			sub = WP(w, smallmap_d).subscroll + e->we.scroll.delta.x;
4335
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   875
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   876
			x -= (sub >> 2) << 4;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   877
			y += (sub >> 2) << 4;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   878
			sub &= 3;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   879
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   880
			x += (e->we.scroll.delta.y >> 1) << 4;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   881
			y += (e->we.scroll.delta.y >> 1) << 4;
4335
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   882
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   883
			if (e->we.scroll.delta.y & 1) {
4335
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   884
				x += TILE_SIZE;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   885
				sub += 2;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   886
				if (sub > 3) {
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   887
					sub -= 4;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   888
					x -= TILE_SIZE;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   889
					y += TILE_SIZE;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   890
				}
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   891
			}
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   892
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   893
			hx = (w->widget[4].right  - w->widget[4].left) / 2;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   894
			hy = (w->widget[4].bottom - w->widget[4].top ) / 2;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   895
			hvx = hx * -4 + hy * 8;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   896
			hvy = hx *  4 + hy * 8;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   897
			if (x < -hvx) {
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   898
				x = -hvx;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   899
				sub = 0;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   900
			}
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   901
			if (x > (int)MapMaxX() * TILE_SIZE - hvx) {
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   902
				x = MapMaxX() * TILE_SIZE - hvx;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   903
				sub = 0;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   904
			}
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   905
			if (y < -hvy) {
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   906
				y = -hvy;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   907
				sub = 0;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   908
			}
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   909
			if (y > (int)MapMaxY() * TILE_SIZE - hvy) {
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   910
				y = MapMaxY() * TILE_SIZE - hvy;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   911
				sub = 0;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   912
			}
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   913
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   914
			WP(w, smallmap_d).scroll_x = x;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   915
			WP(w, smallmap_d).scroll_y = y;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   916
			WP(w, smallmap_d).subscroll = sub;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   917
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   918
			SetWindowDirty(w);
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
   919
		} break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   920
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   921
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   922
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   923
static const WindowDesc _smallmap_desc = {
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5045
diff changeset
   924
	WDP_AUTO, WDP_AUTO, 446, 314,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5835
diff changeset
   925
	WC_SMALLMAP, WC_NONE,
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   926
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE,
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   927
	_smallmap_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   928
	SmallMapWindowProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   929
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   930
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6206
diff changeset
   931
void ShowSmallMap()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   932
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   933
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   934
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   935
	w = AllocateWindowDescFront(&_smallmap_desc, 0);
4339
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   936
	if (w == NULL) return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   937
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   938
	LowerWindowWidget(w, _smallmap_type + 5);
4727
ba5bae41b004 (svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents: 4719
diff changeset
   939
	SetWindowWidgetLoweredState(w, 12, _smallmap_show_towns);
4339
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   940
	w->resize.width = 350;
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   941
	w->resize.height = 250;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   942
4339
f5e99218131a (svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents: 4337
diff changeset
   943
	SmallMapCenterOnCurrentPos(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   944
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   945
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
   946
/* Extra ViewPort Window Stuff */
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   947
static const Widget _extra_view_port_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   948
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   949
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   287,     0,    13, STR_EXTRA_VIEW_PORT_TITLE,        STR_018C_WINDOW_TITLE_DRAG_THIS},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   950
{  WWT_STICKYBOX,     RESIZE_LR,    14,   288,   299,     0,    13, 0x0,                              STR_STICKY_BUTTON},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   951
{      WWT_PANEL,     RESIZE_RB,    14,     0,   299,    14,   233, 0x0,                              STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4938
diff changeset
   952
{      WWT_INSET,     RESIZE_RB,    14,     2,   297,    16,   231, 0x0,                              STR_NULL},
5036
78d76f4bc144 (svn r7078) -Codechange: Make the zoom in/out buttons of the extra viewport into proper push-buttons.
Darkvater
parents: 4939
diff changeset
   953
{ WWT_PUSHIMGBTN,     RESIZE_TB,    14,     0,    21,   234,   255, SPR_IMG_ZOOMIN,                   STR_017F_ZOOM_THE_VIEW_IN},
78d76f4bc144 (svn r7078) -Codechange: Make the zoom in/out buttons of the extra viewport into proper push-buttons.
Darkvater
parents: 4939
diff changeset
   954
{ WWT_PUSHIMGBTN,     RESIZE_TB,    14,    22,    43,   234,   255, SPR_IMG_ZOOMOUT,                  STR_0180_ZOOM_THE_VIEW_OUT},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   955
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,    44,   171,   234,   255, STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW, STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW_TT},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   956
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   172,   298,   234,   255, STR_EXTRA_VIEW_MOVE_VIEW_TO_MAIN, STR_EXTRA_VIEW_MOVE_VIEW_TO_MAIN_TT},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   957
{      WWT_PANEL,    RESIZE_RTB,    14,   299,   299,   234,   255, 0x0,                              STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   958
{      WWT_PANEL,    RESIZE_RTB,    14,     0,   287,   256,   267, 0x0,                              STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4339
diff changeset
   959
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   288,   299,   256,   267, 0x0,                              STR_RESIZE_BUTTON},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 154
diff changeset
   960
{   WIDGETS_END},
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
   961
};
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
   962
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
   963
static void ExtraViewPortWndProc(Window *w, WindowEvent *e)
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
   964
{
1815
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
   965
	switch (e->event) {
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
   966
	case WE_CREATE: /* Disable zoom in button */
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4634
diff changeset
   967
		DisableWindowWidget(w, 5);
1815
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
   968
		break;
4000
bab1ebc37da0 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3882
diff changeset
   969
1815
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
   970
	case WE_PAINT:
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
   971
		// set the number in the title bar
4000
bab1ebc37da0 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3882
diff changeset
   972
		SetDParam(0, w->window_number + 1);
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
   973
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
   974
		DrawWindowWidgets(w);
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
   975
		DrawWindowViewport(w);
1815
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
   976
		break;
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
   977
4000
bab1ebc37da0 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3882
diff changeset
   978
	case WE_CLICK:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
   979
		switch (e->we.click.widget) {
4000
bab1ebc37da0 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3882
diff changeset
   980
			case 5: DoZoomInOutWindow(ZOOM_IN,  w); break;
bab1ebc37da0 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3882
diff changeset
   981
			case 6: DoZoomInOutWindow(ZOOM_OUT, w); break;
bab1ebc37da0 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3882
diff changeset
   982
1815
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
   983
		case 7: { /* location button (move main view to same spot as this view) 'Paste Location' */
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
   984
			Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0);
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
   985
			int x = WP(w, vp_d).scrollpos_x; // Where is the main looking at
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
   986
			int y = WP(w, vp_d).scrollpos_y;
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
   987
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
   988
			/* set this view to same location. Based on the center, adjusting for zoom */
1815
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
   989
			WP(w2, vp_d).scrollpos_x =  x - (w2->viewport->virtual_width -  w->viewport->virtual_width) / 2;
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
   990
			WP(w2, vp_d).scrollpos_y =  y - (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
   991
		} break;
4000
bab1ebc37da0 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3882
diff changeset
   992
1815
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
   993
		case 8: { /* inverse location button (move this view to same spot as main view) 'Copy Location' */
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4000
diff changeset
   994
			const Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0);
2548
97ada3bd2702 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2368
diff changeset
   995
			int x = WP(w2, const vp_d).scrollpos_x;
97ada3bd2702 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2368
diff changeset
   996
			int y = WP(w2, const vp_d).scrollpos_y;
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
   997
1815
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
   998
			WP(w, vp_d).scrollpos_x =  x + (w2->viewport->virtual_width -  w->viewport->virtual_width) / 2;
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
   999
			WP(w, vp_d).scrollpos_y =  y + (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
  1000
		} break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1001
		}
4000
bab1ebc37da0 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3882
diff changeset
  1002
		break;
1815
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
  1003
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
  1004
	case WE_RESIZE:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
  1005
		w->viewport->width          += e->we.sizing.diff.x;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
  1006
		w->viewport->height         += e->we.sizing.diff.y;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
  1007
		w->viewport->virtual_width  += e->we.sizing.diff.x;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
  1008
		w->viewport->virtual_height += e->we.sizing.diff.y;
1815
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
  1009
		break;
4335
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
  1010
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
  1011
		case WE_SCROLL: {
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
  1012
			ViewPort *vp = IsPtInWindowViewport(w, _cursor.pos.x, _cursor.pos.y);
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
  1013
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
  1014
			if (vp == NULL) {
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
  1015
				_cursor.fix_at = false;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
  1016
				_scrolling_viewport = false;
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
  1017
			}
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
  1018
9911
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
  1019
			WP(w, vp_d).scrollpos_x += ScaleByZoom(e->we.scroll.delta.x, vp->zoom);
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
  1020
			WP(w, vp_d).scrollpos_y += ScaleByZoom(e->we.scroll.delta.y, vp->zoom);
4335
18bc63352a17 (svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents: 4171
diff changeset
  1021
		} break;
4337
f77887bd2634 (svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents: 4335
diff changeset
  1022
f77887bd2634 (svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents: 4335
diff changeset
  1023
		case WE_MOUSEWHEEL:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4549
diff changeset
  1024
			ZoomInOrOutToCursorWindow(e->we.wheel.wheel < 0, w);
4337
f77887bd2634 (svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents: 4335
diff changeset
  1025
			break;
5045
3e734e178dae (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5036
diff changeset
  1026
3e734e178dae (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5036
diff changeset
  1027
3e734e178dae (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5036
diff changeset
  1028
		case WE_MESSAGE:
3e734e178dae (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5036
diff changeset
  1029
			/* Only handle zoom message if intended for us (msg ZOOM_IN/ZOOM_OUT) */
3e734e178dae (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5036
diff changeset
  1030
			if (e->we.message.wparam != w->window_number) break;
3e734e178dae (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5036
diff changeset
  1031
			HandleZoomMessage(w, w->viewport, 5, 6);
3e734e178dae (svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents: 5036
diff changeset
  1032
			break;
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
  1033
	}
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
  1034
}
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
  1035
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
  1036
static const WindowDesc _extra_view_port_desc = {
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 5045
diff changeset
  1037
	WDP_AUTO, WDP_AUTO, 300, 268,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5835
diff changeset
  1038
	WC_EXTRA_VIEW_PORT, WC_NONE,
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
  1039
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
  1040
	_extra_view_port_widgets,
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
  1041
	ExtraViewPortWndProc
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
  1042
};
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
  1043
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6206
diff changeset
  1044
void ShowExtraViewPortWindow()
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
  1045
{
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
  1046
	Window *w, *v;
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
  1047
	int i = 0;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1048
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
  1049
	/* find next free window number for extra viewport */
2989
99c95a3ebcaa (svn r3564) Several smaller changes:
tron
parents: 2984
diff changeset
  1050
	while (FindWindowById(WC_EXTRA_VIEW_PORT, i) != NULL) i++;
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
  1051
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
  1052
	w = AllocateWindowDescFront(&_extra_view_port_desc, i);
2989
99c95a3ebcaa (svn r3564) Several smaller changes:
tron
parents: 2984
diff changeset
  1053
	if (w != NULL) {
867
581154a08a78 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
  1054
		int x, y;
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
  1055
		/* the main window with the main view */
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1056
		v = FindWindowById(WC_MAIN_WINDOW, 0);
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
  1057
		/* New viewport start ats (zero,zero) */
9911
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9909
diff changeset
  1058
		AssignWindowViewport(w, 3, 17, 294, 214, 0 , ZOOM_LVL_VIEWPORT);
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
  1059
9908
0fa543611bbe (svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents: 9906
diff changeset
  1060
		/* center on same place as main window (zoom is maximum, no adjustment needed) */
1815
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
  1061
		x = WP(v, vp_d).scrollpos_x;
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
  1062
		y = WP(v, vp_d).scrollpos_y;
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
  1063
		WP(w, vp_d).scrollpos_x = x + (v->viewport->virtual_width  - (294)) / 2;
cfc1399ea8c9 (svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents: 1516
diff changeset
  1064
		WP(w, vp_d).scrollpos_y = y + (v->viewport->virtual_height - (214)) / 2;
152
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
  1065
	}
c3964b43943e (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents: 12
diff changeset
  1066
}