smallmap_gui.c
author bjarni
Wed, 27 Jul 2005 10:11:45 +0000
changeset 2206 4518d18a5f58
parent 2186 db48cf29b983
child 2332 73edb64097fb
permissions -rw-r--r--
(svn r2724) -Fix: [Autoreplace] made the pulldown menu read GetPlayer(_local_player)->avail_railtypes - this removes the need for updating this code if we add more railtypes and it also allows the menu to show maglev when monorail is not available
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1815
diff changeset
     4
#include "openttd.h"
2163
b17b313113a0 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2159
diff changeset
     5
#include "functions.h"
1349
15979a2e9001 (svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents: 1214
diff changeset
     6
#include "spritecache.h"
507
04b5403aaf6b (svn r815) Include strings.h only in the files which need it.
tron
parents: 500
diff changeset
     7
#include "table/strings.h"
1918
fb72133270ac (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
     8
#include "table/sprites.h"
679
04ca2cd69420 (svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents: 541
diff changeset
     9
#include "map.h"
1209
2e00193652b2 (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
    10
#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
    11
#include "gui.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "gfx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
#include "player.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
#include "vehicle.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
#include "town.h"
337
cbe0c766c947 (svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents: 193
diff changeset
    18
#include "sound.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2062
diff changeset
    19
#include "variables.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    20
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
    21
static const Widget _smallmap_widgets[] = {
1918
fb72133270ac (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
    22
{   WWT_TEXTBTN,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
fb72133270ac (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
    23
{   WWT_CAPTION,  RESIZE_RIGHT,    13,    11,   433,     0,    13, STR_00B0_MAP,            STR_018C_WINDOW_TITLE_DRAG_THIS},
fb72133270ac (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
    24
{ WWT_STICKYBOX,     RESIZE_LR,    13,   434,   445,     0,    13, 0x0,                     STR_STICKY_BUTTON},
fb72133270ac (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
    25
{    WWT_IMGBTN,     RESIZE_RB,    13,     0,   445,    14,   257, 0x0,                     STR_NULL},
fb72133270ac (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
    26
{         WWT_6,     RESIZE_RB,    13,     2,   443,    16,   255, 0x0,                     STR_NULL},
fb72133270ac (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
    27
{    WWT_IMGBTN,   RESIZE_LRTB,    13,   380,   401,   258,   279, SPR_IMG_SHOW_COUNTOURS,  STR_0191_SHOW_LAND_CONTOURS_ON_MAP},
fb72133270ac (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
    28
{    WWT_IMGBTN,   RESIZE_LRTB,    13,   402,   423,   258,   279, SPR_IMG_SHOW_VEHICLES,   STR_0192_SHOW_VEHICLES_ON_MAP},
fb72133270ac (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
    29
{    WWT_IMGBTN,   RESIZE_LRTB,    13,   424,   445,   258,   279, SPR_IMG_INDUSTRY,        STR_0193_SHOW_INDUSTRIES_ON_MAP},
fb72133270ac (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
    30
{    WWT_IMGBTN,   RESIZE_LRTB,    13,   380,   401,   280,   301, SPR_IMG_SHOW_ROUTES,     STR_0194_SHOW_TRANSPORT_ROUTES_ON},
fb72133270ac (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_IMGBTN,   RESIZE_LRTB,    13,   402,   423,   280,   301, SPR_IMG_PLANTTREES,      STR_0195_SHOW_VEGETATION_ON_MAP},
fb72133270ac (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_IMGBTN,   RESIZE_LRTB,    13,   424,   445,   280,   301, SPR_IMG_COMPANY_GENERAL, STR_0196_SHOW_LAND_OWNERS_ON_MAP},
fb72133270ac (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
    33
{    WWT_IMGBTN,   RESIZE_LRTB,    13,   358,   379,   258,   279, 0x0,                     STR_NULL},
fb72133270ac (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
    34
{    WWT_IMGBTN,   RESIZE_LRTB,    13,   358,   379,   280,   301, SPR_IMG_TOWN,            STR_0197_TOGGLE_TOWN_NAMES_ON_OFF},
fb72133270ac (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_RTB,    13,     0,   357,   258,   301, 0x0,                     STR_NULL},
fb72133270ac (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_PANEL,    RESIZE_RTB,    13,     0,   433,   302,   313, 0x0,                     STR_NULL},
fb72133270ac (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_RESIZEBOX,   RESIZE_LRTB,    13,   434,   445,   302,   313, 0x0,                     STR_RESIZE_BUTTON},
fb72133270ac (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
{  WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
static int _smallmap_type;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
static bool _smallmap_show_towns = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
1918
fb72133270ac (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
#define MK(a,b) a, b
fb72133270ac (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
#define MKEND() 0xFFFF
fb72133270ac (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
#define MS(a,b) (a | 0x100), b
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
1918
fb72133270ac (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
    48
/* Legend text giving the colours to look for on the minimap */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
static const uint16 _legend_land_contours[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
	MK(0x5A,STR_00F0_100M),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
	MK(0x5C,STR_00F1_200M),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
	MK(0x5E,STR_00F2_300M),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
	MK(0x1F,STR_00F3_400M),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
	MK(0x27,STR_00F4_500M),
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    55
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
	MS(0xD7,STR_00EB_ROADS),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
	MK(0x0A,STR_00EC_RAILROADS),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
	MK(0x98,STR_00ED_STATIONS_AIRPORTS_DOCKS),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
	MK(0xB5,STR_00EE_BUILDINGS_INDUSTRIES),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
	MK(0x0F,STR_00EF_VEHICLES),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
	MKEND()
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
static const uint16 _legend_vehicles[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
	MK(0xB8,STR_00F5_TRAINS),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
	MK(0xBF,STR_00F6_ROAD_VEHICLES),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
	MK(0x98,STR_00F7_SHIPS),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
	MK(0x0F,STR_00F8_AIRCRAFT),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
	MS(0xD7,STR_00F9_TRANSPORT_ROUTES),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
	MK(0xB5,STR_00EE_BUILDINGS_INDUSTRIES),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
	MKEND()
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
static const uint16 _legend_industries_normal[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
	MK(0xD7,STR_00FA_COAL_MINE),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
	MK(0xB8,STR_00FB_POWER_STATION),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
	MK(0x56,STR_00FC_FOREST),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
	MK(0xC2,STR_00FD_SAWMILL),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
	MK(0xBF,STR_00FE_OIL_REFINERY),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
	MK(0x0F,STR_0105_BANK),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
	MS(0x30,STR_00FF_FARM),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
	MK(0xAE,STR_0100_FACTORY),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
	MK(0x98,STR_0102_OIL_WELLS),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
	MK(0x37,STR_0103_IRON_ORE_MINE),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
	MK(0x0A,STR_0104_STEEL_MILL),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
	MKEND()
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
static const uint16 _legend_industries_hilly[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
	MK(0xD7,STR_00FA_COAL_MINE),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
	MK(0xB8,STR_00FB_POWER_STATION),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
	MK(0x56,STR_00FC_FOREST),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
	MK(0x0A,STR_0106_PAPER_MILL),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
	MK(0xBF,STR_00FE_OIL_REFINERY),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
	MK(0x37,STR_0108_FOOD_PROCESSING_PLANT),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
	MS(0x30,STR_00FF_FARM),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
	MK(0xAE,STR_0101_PRINTING_WORKS),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
	MK(0x98,STR_0102_OIL_WELLS),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
	MK(0xC2,STR_0107_GOLD_MINE),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
	MK(0x0F,STR_0105_BANK),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
	MKEND()
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
};
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
static const uint16 _legend_industries_desert[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
	MK(0xBF,STR_00FE_OIL_REFINERY),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
	MK(0x98,STR_0102_OIL_WELLS),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
	MK(0x0F,STR_0105_BANK),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
	MK(0xB8,STR_0109_DIAMOND_MINE),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
	MK(0x37,STR_0108_FOOD_PROCESSING_PLANT),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
	MK(0x0A,STR_010A_COPPER_ORE_MINE),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
	MK(0x30,STR_00FF_FARM),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
	MS(0x56,STR_010B_FRUIT_PLANTATION),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
	MK(0x27,STR_010C_RUBBER_PLANTATION),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
	MK(0x25,STR_010D_WATER_SUPPLY),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
	MK(0xD0,STR_010E_WATER_TOWER),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
	MK(0xAE,STR_0100_FACTORY),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
	MK(0xC2,STR_010F_LUMBER_MILL),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
	MKEND()
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
static const uint16 _legend_industries_candy[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
	MK(0x30,STR_0110_COTTON_CANDY_FOREST),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
	MK(0xAE,STR_0111_CANDY_FACTORY),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
	MK(0x27,STR_0112_BATTERY_FARM),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
	MK(0x37,STR_0113_COLA_WELLS),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
	MK(0xD0,STR_0114_TOY_SHOP),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
	MK(0x0A,STR_0115_TOY_FACTORY),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
	MS(0x25,STR_0116_PLASTIC_FOUNTAINS),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
	MK(0xB8,STR_0117_FIZZY_DRINK_FACTORY),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
	MK(0x98,STR_0118_BUBBLE_GENERATOR),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
	MK(0xC2,STR_0119_TOFFEE_QUARRY),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
	MK(0x0F,STR_011A_SUGAR_MINE),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
	MKEND()
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
static const uint16 _legend_routes[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
	MK(0xD7,STR_00EB_ROADS),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
	MK(0x0A,STR_00EC_RAILROADS),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
	MK(0xB5,STR_00EE_BUILDINGS_INDUSTRIES),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
	MS(0x56,STR_011B_RAILROAD_STATION),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
	MK(0xC2,STR_011C_TRUCK_LOADING_BAY),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
	MK(0xBF,STR_011D_BUS_STATION),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
	MK(0xB8,STR_011E_AIRPORT_HELIPORT),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
	MK(0x98,STR_011F_DOCK),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
	MKEND()
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
static const uint16 _legend_vegetation[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
	MK(0x52,STR_0120_ROUGH_LAND),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
	MK(0x54,STR_0121_GRASS_LAND),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
	MK(0x37,STR_0122_BARE_LAND),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
	MK(0x25,STR_0123_FIELDS),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
	MK(0x57,STR_0124_TREES),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
	MK(0xD0,STR_00FC_FOREST),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
	MS(0x0A,STR_0125_ROCKS),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
	MK(0xC2,STR_012A_DESERT),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
	MK(0x98,STR_012B_SNOW),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
	MK(0xD7,STR_00F9_TRANSPORT_ROUTES),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
	MK(0xB5,STR_00EE_BUILDINGS_INDUSTRIES),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
	MKEND()
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
};
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
static const uint16 _legend_land_owners[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
	MK(0xCA,STR_0126_WATER),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
	MK(0x54,STR_0127_NO_OWNER),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
	MK(0xB4,STR_0128_TOWNS),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
	MK(0x20,STR_0129_INDUSTRIES),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
	MKEND()
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
#undef MK
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
#undef MS
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
#undef MKEND
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
enum { IND_OFFS = 6 };
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
static const uint16 * const _legend_table[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
	_legend_land_contours,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
	_legend_vehicles,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
	NULL,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
	_legend_routes,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
	_legend_vegetation,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
	_legend_land_owners,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
	_legend_industries_normal,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
	_legend_industries_hilly,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
	_legend_industries_desert,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
	_legend_industries_candy,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   195
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
#if defined(TTD_ALIGNMENT_4)
2062
57db03be52ad (svn r2571) Add explicit type Pixel for ... Pixels
tron
parents: 2049
diff changeset
   197
	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
   198
	{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
#	if defined(TTD_BIG_ENDIAN)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
		d[0] = (byte)(val >> 24);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
		d[1] = (byte)(val >> 16);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
		d[2] = (byte)(val >> 8);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
		d[3] = (byte)(val >> 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
#	elif defined(TTD_LITTLE_ENDIAN)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
		d[0] = (byte)(val >> 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
		d[1] = (byte)(val >> 8);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
		d[2] = (byte)(val >> 16);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
		d[3] = (byte)(val >> 24);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
#	endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   212
/* need to use OR, otherwise we will overwrite the wrong pixels at the edges :( */
2062
57db03be52ad (svn r2571) Add explicit type Pixel for ... Pixels
tron
parents: 2049
diff changeset
   213
	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
   214
	{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
#	if defined(TTD_BIG_ENDIAN)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
		d[0] |= (byte)(val >> 24);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
		d[1] |= (byte)(val >> 16);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
		d[2] |= (byte)(val >> 8);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
		d[3] |= (byte)(val >> 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
#	elif defined(TTD_LITTLE_ENDIAN)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
		d[0] |= (byte)(val >> 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
		d[1] |= (byte)(val >> 8);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
		d[2] |= (byte)(val >> 16);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
		d[3] |= (byte)(val >> 24);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
#	endif
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
#else
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
#	define WRITE_PIXELS(dst, val)		*(uint32*)(dst) = (val);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
#	define WRITE_PIXELS_OR(dst,val)	*(uint32*)(dst) |= (val);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
#if defined(TTD_BIG_ENDIAN)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   233
#	define MKCOLOR(x) BSWAP32(x)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
#elif defined(TTD_LITTLE_ENDIAN)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
#	define MKCOLOR(x) (x)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
1918
fb72133270ac (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
/* 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
   239
static const uint32 _map_height_bits[16] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
	MKCOLOR(0x5A5A5A5A),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
	MKCOLOR(0x5A5B5A5B),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
	MKCOLOR(0x5B5B5B5B),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   243
	MKCOLOR(0x5B5C5B5C),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
	MKCOLOR(0x5C5C5C5C),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
	MKCOLOR(0x5C5D5C5D),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
	MKCOLOR(0x5D5D5D5D),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
	MKCOLOR(0x5D5E5D5E),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
	MKCOLOR(0x5E5E5E5E),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
	MKCOLOR(0x5E5F5E5F),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   250
	MKCOLOR(0x5F5F5F5F),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
	MKCOLOR(0x5F1F5F1F),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
	MKCOLOR(0x1F1F1F1F),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
	MKCOLOR(0x1F271F27),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
	MKCOLOR(0x27272727),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
	MKCOLOR(0x27272727),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
1511
5917a04566df (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
   258
typedef struct AndOr {
5917a04566df (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
   259
	uint32 mor;
5917a04566df (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
   260
	uint32 mand;
5917a04566df (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
   261
} AndOr;
5917a04566df (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
   262
5917a04566df (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
   263
static inline uint32 ApplyMask(uint32 colour, const AndOr* mask)
5917a04566df (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
   264
{
5917a04566df (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
   265
	return (colour & mask->mand) | mask->mor;
5917a04566df (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
   266
}
5917a04566df (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
   267
1918
fb72133270ac (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
   268
1511
5917a04566df (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_contours_andor[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
	{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
	{MKCOLOR(0x000A0A00),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
	{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
	{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   274
	{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
	{MKCOLOR(0x98989898),MKCOLOR(0x00000000)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
	{MKCOLOR(0xCACACACA),MKCOLOR(0x00000000)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
	{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
	{MKCOLOR(0xB5B5B5B5),MKCOLOR(0x00000000)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
	{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
	{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
	{MKCOLOR(0x000A0A00),MKCOLOR(0xFF0000FF)},
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
1511
5917a04566df (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
   284
static const AndOr _smallmap_vehicles_andor[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
	{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
	{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
	{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
	{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
	{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   290
	{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
	{MKCOLOR(0xCACACACA),MKCOLOR(0x00000000)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
	{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
	{MKCOLOR(0xB5B5B5B5),MKCOLOR(0x00000000)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
	{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
	{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
	{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
1511
5917a04566df (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
   299
static const AndOr _smallmap_vegetation_andor[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
	{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
	{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
	{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
	{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
	{MKCOLOR(0x00575700),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
	{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
	{MKCOLOR(0xCACACACA),MKCOLOR(0x00000000)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
	{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
	{MKCOLOR(0xB5B5B5B5),MKCOLOR(0x00000000)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
	{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
	{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
	{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
1918
fb72133270ac (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
   314
typedef uint32 GetSmallMapPixels(TileIndex tile); // typedef callthrough function
fb72133270ac (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
   315
fb72133270ac (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
   316
/**
fb72133270ac (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
   317
 * Draws one column of the small map in a certain mode onto the screen buffer. This
fb72133270ac (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
   318
 * function looks exactly the same for all types
fb72133270ac (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
   319
 *
fb72133270ac (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
   320
 * @param dst Pointer to a part of the screen buffer to write to.
fb72133270ac (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
   321
 * @param xc The X coordinate of the first tile in the column.
fb72133270ac (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
   322
 * @param yc The Y coordinate of the first tile in the column
fb72133270ac (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
   323
 * @param pitch Number of pixels to advance in the screen buffer each time a pixel is written.
fb72133270ac (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
   324
 * @param reps Number of lines to draw
fb72133270ac (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
   325
 * @param mask ?
fb72133270ac (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
   326
 * @param proc Pointer to the colour function
fb72133270ac (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
   327
 * @see GetSmallMapPixels(TileIndex)
fb72133270ac (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
   328
 */
2062
57db03be52ad (svn r2571) Add explicit type Pixel for ... Pixels
tron
parents: 2049
diff changeset
   329
static void DrawSmallMapStuff(Pixel *dst, uint xc, uint yc, int pitch, int reps, uint32 mask, GetSmallMapPixels *proc)
1918
fb72133270ac (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
   330
{
2062
57db03be52ad (svn r2571) Add explicit type Pixel for ... Pixels
tron
parents: 2049
diff changeset
   331
	Pixel *dst_ptr_end = _screen.dst_ptr + _screen.width * _screen.height - _screen.width;
1918
fb72133270ac (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
   332
fb72133270ac (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
   333
	do {
fb72133270ac (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
   334
		// check if the tile (xc,yc) is within the map range
1919
ca41cc314d40 (svn r2425) - Fix (regression): wrong sprite for level-land cursor (thx Tron)
Darkvater
parents: 1918
diff changeset
   335
		if (xc < MapMaxX() && yc < MapMaxY()) {
1918
fb72133270ac (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
			// check if the dst pointer points to a pixel inside the screen buffer
fb72133270ac (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
			if (dst > _screen.dst_ptr && dst < dst_ptr_end)
1981
3c9c682f1212 (svn r2487) Replace TILE_XY by TileXY/TileDiffXY
tron
parents: 1919
diff changeset
   338
				WRITE_PIXELS_OR(dst, proc(TileXY(xc, yc)) & mask);
1918
fb72133270ac (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
		}
fb72133270ac (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
	// switch to next tile in the column
fb72133270ac (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
   341
	} while (xc++, yc++, dst += pitch, --reps != 0);
fb72133270ac (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
   342
}
fb72133270ac (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
   343
1516
dc914162ad01 (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   344
dc914162ad01 (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   345
static inline TileType GetEffectiveTileType(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
{
1516
dc914162ad01 (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   347
	TileType t = GetTileType(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   348
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   349
	if (t == MP_TUNNELBRIDGE) {
2049
538e73c53f54 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1981
diff changeset
   350
		t = _m[tile].m5;
1516
dc914162ad01 (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   351
		if ((t & 0x80) == 0) t >>= 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
		if ((t & 6) == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
			t = MP_RAILWAY;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
		} else if ((t & 6) == 2) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
			t = MP_STREET;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
			t = MP_WATER;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
	}
1516
dc914162ad01 (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   360
	return t;
dc914162ad01 (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   361
}
dc914162ad01 (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   362
1918
fb72133270ac (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
/**
fb72133270ac (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
 * Return the color a tile would be displayed with in the small map in mode "Contour".
fb72133270ac (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.
fb72133270ac (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 "Contour"
fb72133270ac (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
 */
1516
dc914162ad01 (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   368
static inline uint32 GetSmallMapContoursPixels(TileIndex tile)
dc914162ad01 (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   369
{
dc914162ad01 (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
1511
5917a04566df (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
   372
	return
5917a04566df (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
   373
		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
   374
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
1918
fb72133270ac (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
/**
fb72133270ac (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
   377
 * Return the color a tile would be displayed with in the small map in mode "Vehicles".
fb72133270ac (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
   378
 *
fb72133270ac (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
 * @param t The tile of which we would like to get the color.
fb72133270ac (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 of tile in the small map in mode "Vehicles"
fb72133270ac (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
 */
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   382
static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
{
1516
dc914162ad01 (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   384
	TileType t = GetEffectiveTileType(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   385
1511
5917a04566df (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
   386
	return ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   387
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
1918
fb72133270ac (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
   389
/* Industry colours... a total of 175 gfx - XXX - increase if more industries */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   390
static const byte _industry_smallmap_colors[175] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
	215,215,215,215,215,215,215,184,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
	184,184,184,194,194,194,194,194,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
	 86, 86,191,191,191,191,191,191,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
	152,152,152,152,152,152,152,152,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
	152, 48, 48, 48, 48, 48, 48,174,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
	174,174,174,174,174,174,174, 10,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   397
	 10, 10, 10, 10, 10, 10, 10, 10,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
	 10, 10, 15, 15, 55, 55, 55, 55,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
	 10, 10, 10, 10, 10, 10, 10, 10,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
	194,194,194,194,194,194,194,194,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
	194,194,194,194,194,194,194,194,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
	194, 15, 15,184,184,184,184,184,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
	184,184,184,184, 55, 55, 55, 55,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
	 55, 55, 55, 55, 55, 55, 55, 55,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
	 55, 55, 55, 55, 86, 39, 37, 37,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
	208,174,174,174,174,194,194,194,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   407
	194, 48, 48,174,174,174,174, 39,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   408
	 39, 55,208,208,208,208, 10, 10,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   409
	 10, 10, 10, 10, 37, 37, 37, 37,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   410
	 37, 37, 37, 37,184,184,184,184,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
	152,152,152,152,194,194,194, 15,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
	 15, 15, 15, 15, 15, 15, 15,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
1918
fb72133270ac (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
/**
fb72133270ac (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
   416
 * Return the color a tile would be displayed with in the small map in mode "Industries".
fb72133270ac (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
   417
 *
fb72133270ac (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
   418
 * @param tile The tile of which we would like to get the color.
fb72133270ac (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
   419
 * @return The color of tile in the small map in mode "Industries"
fb72133270ac (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
   420
 */
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   421
static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
{
1516
dc914162ad01 (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   423
	TileType t = GetEffectiveTileType(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   425
	if (t == MP_INDUSTRY) {
2049
538e73c53f54 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1981
diff changeset
   426
		byte color = _industry_smallmap_colors[_m[tile].m5];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
		return color + (color << 8) + (color << 16) + (color << 24);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   428
	}
1918
fb72133270ac (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
   429
fb72133270ac (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
   430
	return ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   431
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
1918
fb72133270ac (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
   433
/**
fb72133270ac (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
   434
 * Return the color a tile would be displayed with in the small map in mode "Routes".
fb72133270ac (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
   435
 *
fb72133270ac (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
   436
 * @param t The tile of which we would like to get the color.
fb72133270ac (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
   437
 * @return The color of tile  in the small map in mode "Routes"
fb72133270ac (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
   438
 */
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   439
static inline uint32 GetSmallMapRoutesPixels(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   440
{
1516
dc914162ad01 (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   441
	TileType t = GetEffectiveTileType(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   442
	uint32 bits;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
	if (t == MP_STATION) {
2049
538e73c53f54 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1981
diff changeset
   445
		byte m5 = _m[tile].m5;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
		(bits = MKCOLOR(0x56565656), m5 < 8) ||			//   8 - railroad station (green)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   447
		(bits = MKCOLOR(0xB8B8B8B8), m5 < 0x43) ||	//  67 - airport (red)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   448
		(bits = MKCOLOR(0xC2C2C2C2), m5 < 0x47) ||	//  71 - truck loading bay (orange)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
		(bits = MKCOLOR(0xBFBFBFBF), m5 < 0x4B) ||	//  75 - bus station (yellow)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   450
		(bits = MKCOLOR(0x98989898), m5 < 0x53) ||	//  83 - docks (blue)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
		(bits = MKCOLOR(0xB8B8B8B8), m5 < 0x73) ||	// 115 - airport (red) (new airports)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
		(bits = MKCOLOR(0xFFFFFFFF), true);					// all others
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
		// ground color
1511
5917a04566df (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
   455
		bits = ApplyMask(MKCOLOR(0x54545454), &_smallmap_contours_andor[t]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   456
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   457
	return bits;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   458
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   459
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   460
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   461
static const uint32 _vegetation_clear_bits[4 + 7] = {
1918
fb72133270ac (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
   462
	MKCOLOR(0x37373737), ///< bare land
fb72133270ac (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
   463
	MKCOLOR(0x37373737), ///< 1/3 grass
fb72133270ac (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
   464
	MKCOLOR(0x37373737), ///< 2/3 grass
fb72133270ac (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
   465
	MKCOLOR(0x54545454), ///< full grass
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   466
1918
fb72133270ac (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
   467
	MKCOLOR(0x52525252), ///< rough land
fb72133270ac (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
   468
	MKCOLOR(0x0A0A0A0A), ///< rocks
fb72133270ac (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
   469
	MKCOLOR(0x25252525), ///< fields
fb72133270ac (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
   470
	MKCOLOR(0x98989898), ///< snow
fb72133270ac (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
   471
	MKCOLOR(0xC2C2C2C2), ///< desert
fb72133270ac (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
   472
	MKCOLOR(0x54545454), ///< unused
fb72133270ac (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
   473
	MKCOLOR(0x54545454), ///< unused
0
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
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   476
static inline uint32 GetSmallMapVegetationPixels(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
{
1516
dc914162ad01 (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   478
	TileType t = GetEffectiveTileType(tile);
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   479
	int i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
	uint32 bits;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   482
	switch (t) {
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   483
		case MP_CLEAR:
2049
538e73c53f54 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1981
diff changeset
   484
			i = (_m[tile].m5 & 0x1F) - 4;
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   485
			if (i >= 0) i >>= 2;
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   486
			bits = _vegetation_clear_bits[i + 4];
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   487
			break;
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   488
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   489
		case MP_INDUSTRY:
2049
538e73c53f54 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1981
diff changeset
   490
			bits = IS_BYTE_INSIDE(_m[tile].m5, 0x10, 0x12) ? MKCOLOR(0xD0D0D0D0) : MKCOLOR(0xB5B5B5B5);
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   491
			break;
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   492
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   493
		case MP_TREES:
2049
538e73c53f54 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1981
diff changeset
   494
			if ((_m[tile].m2 & 0x30) == 0x20)
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   495
				bits = (_opt.landscape == LT_HILLY) ? MKCOLOR(0x98575798) : MKCOLOR(0xC25757C2);
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   496
			else
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   497
				bits = MKCOLOR(0x54575754);
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   498
			break;
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   499
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   500
		default:
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   501
			bits = ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]);
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   502
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   503
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   504
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
	return bits;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   506
}
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
1092
e3b4a131db7c (svn r1593) Remove yet another alloca()
tron
parents: 1044
diff changeset
   509
static uint32 _owner_colors[256];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
1918
fb72133270ac (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
   511
/**
fb72133270ac (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
   512
 * Return the color a tile would be displayed with in the small map in mode "Owner".
fb72133270ac (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
   513
 *
fb72133270ac (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
   514
 * @param t The tile of which we would like to get the color.
fb72133270ac (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
 * @return The color of tile in the small map in mode "Owner"
fb72133270ac (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
 */
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   517
static inline uint32 GetSmallMapOwnerPixels(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
{
1516
dc914162ad01 (svn r2020) Reduce code duplication in the minimap code a bit
tron
parents: 1515
diff changeset
   519
	TileType t = GetTileType(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   520
1901
03bf9bf99319 (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents: 1891
diff changeset
   521
	if (t == MP_INDUSTRY) {
03bf9bf99319 (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents: 1891
diff changeset
   522
		t = 0xff;
03bf9bf99319 (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents: 1891
diff changeset
   523
	} else if (t == MP_HOUSE || IsTileOwner(tile, OWNER_TOWN)) {
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   524
		t = 0x80;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   525
	} else {
1901
03bf9bf99319 (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents: 1891
diff changeset
   526
		t = GetTileOwner(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   527
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   528
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
	return _owner_colors[t];
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   532
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   533
static const uint32 _smallmap_mask_left[3] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   534
	MKCOLOR(0xFF000000),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   535
	MKCOLOR(0xFFFF0000),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   536
	MKCOLOR(0xFFFFFF00),
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
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   539
static const uint32 _smallmap_mask_right[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   540
	MKCOLOR(0x000000FF),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
	MKCOLOR(0x0000FFFF),
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
	MKCOLOR(0x00FFFFFF),
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
/* 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
   546
1918
fb72133270ac (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
   547
static GetSmallMapPixels *_smallmap_draw_procs[] = {
fb72133270ac (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
   548
	GetSmallMapContoursPixels,
fb72133270ac (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
   549
	GetSmallMapVehiclesPixels,
fb72133270ac (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
   550
	GetSmallMapIndustriesPixels,
fb72133270ac (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
   551
	GetSmallMapRoutesPixels,
fb72133270ac (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
   552
	GetSmallMapVegetationPixels,
fb72133270ac (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
   553
	GetSmallMapOwnerPixels,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
static const byte _vehicle_type_colors[6] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   557
	184, 191, 152, 15, 215, 184
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   559
500
8e52f7797b48 (svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents: 337
diff changeset
   560
static inline uint32 dup_byte32(byte b) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   561
	return b + (b << 8) + (b << 16) + (b << 24);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   562
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   563
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   564
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
   565
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   566
	GfxFillRect(x, y, x2, y + 3, 69);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   567
	GfxFillRect(x, y2 - 3, x2, y2, 69);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   568
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   569
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   570
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
   571
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
	GfxFillRect(x, y, x + 3, y2, 69);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   573
	GfxFillRect(x2 - 3, y, x2, y2, 69);
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
1918
fb72133270ac (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
   576
/**
fb72133270ac (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
   577
 * Draws the small map.
fb72133270ac (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
   578
 *
fb72133270ac (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
   579
 * Basically, the small map is draw column of pixels by column of pixels. The pixels
fb72133270ac (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
   580
 * are drawn directly into the screen buffer. The final map is drawn in multiple passes.
fb72133270ac (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
   581
 * The passes are:
fb72133270ac (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
   582
 * <ol><li>The colors of tiles in the different modes.</li>
fb72133270ac (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
   583
 * <li>Town names (optional)</li>
fb72133270ac (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
   584
 *
fb72133270ac (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
   585
 * @param dpi pointer to pixel to write onto
fb72133270ac (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
   586
 * @param w pointer to Window struct
fb72133270ac (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
   587
 * @param type type of map requested (vegetation, owners, routes, etc)
fb72133270ac (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
   588
 * @param show_towns true if the town names should be displayed, false if not.
fb72133270ac (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
   589
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   590
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
   591
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   592
	DrawPixelInfo *old_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   593
	int dx,dy, x, y, x2, y2;
2062
57db03be52ad (svn r2571) Add explicit type Pixel for ... Pixels
tron
parents: 2049
diff changeset
   594
	Pixel *ptr;
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   595
	int tile_x;
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   596
	int tile_y;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   597
	ViewPort *vp;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   598
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   599
	old_dpi = _cur_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
	_cur_dpi = dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   601
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   602
	/* clear it */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   603
	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
   604
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   605
	/* setup owner table */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   606
	if (type == 5) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   607
		Player *p;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   608
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   609
		/* clear the town colors */
1092
e3b4a131db7c (svn r1593) Remove yet another alloca()
tron
parents: 1044
diff changeset
   610
		memset(&_owner_colors[128], 0xB4, 128 * sizeof(*_owner_colors));
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   611
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   612
		/* fill with some special colors */
1092
e3b4a131db7c (svn r1593) Remove yet another alloca()
tron
parents: 1044
diff changeset
   613
		_owner_colors[0x10] = MKCOLOR(0x54545454);
e3b4a131db7c (svn r1593) Remove yet another alloca()
tron
parents: 1044
diff changeset
   614
		_owner_colors[0x11] = MKCOLOR(0xCACACACA);
e3b4a131db7c (svn r1593) Remove yet another alloca()
tron
parents: 1044
diff changeset
   615
		_owner_colors[0xff] = MKCOLOR(0x20202020); /* industry */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   616
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   617
		/* now fill with the player colors */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   618
		FOR_ALL_PLAYERS(p) {
1092
e3b4a131db7c (svn r1593) Remove yet another alloca()
tron
parents: 1044
diff changeset
   619
			if (p->is_active)
e3b4a131db7c (svn r1593) Remove yet another alloca()
tron
parents: 1044
diff changeset
   620
				_owner_colors[p->index] =
1918
fb72133270ac (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
   621
					dup_byte32(GetNonSprite(775 + p->player_color)[0xCB]); // XXX - magic pixel
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   622
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   623
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   624
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   625
	tile_x = WP(w,smallmap_d).scroll_x / 16;
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   626
	tile_y = WP(w,smallmap_d).scroll_y / 16;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   627
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   628
	dx = dpi->left + WP(w,smallmap_d).subscroll;
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   629
	tile_x -= dx / 4;
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   630
	tile_y += dx / 4;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   631
	dx &= 3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   632
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   633
	dy = dpi->top;
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   634
	tile_x += dy / 2;
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   635
	tile_y += dy / 2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   636
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   637
	if (dy & 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   638
		tile_x++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   639
		dx += 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   640
		if (dx > 3) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   641
			dx -= 4;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   642
			tile_x--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   643
			tile_y++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   644
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   645
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   646
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   647
	ptr = dpi->dst_ptr - dx - 4;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   648
	x = - dx - 4;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   649
	y = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   650
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   651
	for(;;) {
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   652
		uint32 mask;
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   653
		int reps;
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   654
		int t;
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   655
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   656
		mask = 0xFFFFFFFF;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   657
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   658
		/* distance from left edge */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   659
		if (x < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   660
			if (x < -3) goto skip_column;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   661
			/* mask to use at the left edge */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   662
			mask = _smallmap_mask_left[x + 3];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   663
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   664
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   665
		/* distance from right edge */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   666
		t = dpi->width - x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   667
		if (t < 4) {
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   668
			if (t <= 0)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   669
				break; /* exit loop */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   670
			/* mask to use at the right edge */
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   671
			mask &= _smallmap_mask_right[t - 1];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   672
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   673
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   674
		/* number of lines */
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   675
		reps = (dpi->height - y + 1) / 2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   676
		if (reps > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   677
//			assert(ptr >= dpi->dst_ptr);
1918
fb72133270ac (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
   678
			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
   679
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   680
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   681
skip_column:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   682
		if (y == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   683
			tile_y++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   684
			y++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   685
			ptr += dpi->pitch;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   686
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   687
			tile_x--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   688
			y--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   689
			ptr -= dpi->pitch;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   690
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   691
		ptr += 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   692
		x += 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   693
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   694
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   695
	/* draw vehicles? */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   696
	if (type == 0 || type == 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   697
		Vehicle *v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   698
		bool skip;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   699
		byte color;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   700
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   701
		FOR_ALL_VEHICLES(v) {
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   702
			if (v->type != 0 && v->type != VEH_Special &&
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   703
					(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   704
				// Remap into flat coordinates.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   705
				Point pt = RemapCoords(
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   706
					(v->x_pos - WP(w,smallmap_d).scroll_x) / 16,
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   707
					(v->y_pos - WP(w,smallmap_d).scroll_y) / 16,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   708
					0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   709
				x = pt.x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   710
				y = pt.y;
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
				// Check if y is out of bounds?
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   713
				y -= dpi->top;
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   714
				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
   715
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   716
				// Default is to draw both pixels.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   717
				skip = false;
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
				// Offset X coordinate
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   720
				x -= WP(w,smallmap_d).subscroll + 3 + dpi->left;
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
				if (x < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   723
					// if x+1 is 0, that means we're on the very left edge,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   724
					//  and should thus only draw a single pixel
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   725
					if (++x != 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   726
						continue;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   727
					skip = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   728
				} else if (x >= dpi->width - 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   729
					// Check if we're at the very right edge, and if so draw only a single pixel
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   730
					if (x != dpi->width - 1)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   731
						continue;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   732
					skip = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   733
				}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   734
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   735
				// Calculate pointer to pixel and the color
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   736
				ptr = dpi->dst_ptr + y * dpi->pitch + x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   737
				color = (type == 1) ? _vehicle_type_colors[v->type-0x10] : 0xF;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   738
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   739
				// And draw either one or two pixels depending on clipping
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   740
				ptr[0] = color;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   741
				if (!skip)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   742
					ptr[1] = color;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   743
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   744
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   745
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   746
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   747
	if (show_towns) {
1918
fb72133270ac (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
   748
		const Town *t;
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   749
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   750
		FOR_ALL_TOWNS(t) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   751
			if (t->xy != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   752
				// Remap the town coordinate
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   753
				Point pt = RemapCoords(
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   754
					(int)(TileX(t->xy) * 16 - WP(w, smallmap_d).scroll_x) / 16,
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   755
					(int)(TileY(t->xy) * 16 - WP(w, smallmap_d).scroll_y) / 16,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   756
					0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   757
				x = pt.x - WP(w,smallmap_d).subscroll + 3 - (t->sign.width_2 >> 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   758
				y = pt.y;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   759
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   760
				// Check if the town sign is within bounds
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   761
				if (x + t->sign.width_2 > dpi->left &&
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   762
						x < dpi->left + dpi->width &&
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   763
						y + 6 > dpi->top &&
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   764
						y < dpi->top + dpi->height) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   765
					// And draw it.
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   766
					SetDParam(0, t->index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   767
					DrawString(x, y, STR_2056, 12);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   768
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   769
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   770
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   771
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   772
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   773
	// Draw map indicators
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   774
	{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   775
		Point pt;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   776
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   777
		// Find main viewport.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   778
		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
   779
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   780
		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
   781
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   782
		x = vp->virtual_left - pt.x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   783
		y = vp->virtual_top - pt.y;
1515
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   784
		x2 = (x + vp->virtual_width) / 16;
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   785
		y2 = (y + vp->virtual_height) / 16;
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   786
		x /= 16;
071fe1565cb8 (svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents: 1511
diff changeset
   787
		y /= 16;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   788
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   789
		x -= WP(w,smallmap_d).subscroll;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   790
		x2 -= WP(w,smallmap_d).subscroll;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   791
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   792
		DrawVertMapIndicator(x, y, x, y2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   793
		DrawVertMapIndicator(x2, y, x2, y2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   794
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   795
		DrawHorizMapIndicator(x, y, x2, y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   796
		DrawHorizMapIndicator(x, y2, x2, y2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   797
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   798
	_cur_dpi = old_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   799
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   800
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   801
static void SmallMapWindowProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   802
{
1918
fb72133270ac (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
   803
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   804
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   805
		const uint16 *tbl;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   806
		int x,y,y_org;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   807
		DrawPixelInfo new_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   808
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   809
		/* draw the window */
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   810
		SetDParam(0, STR_00E5_CONTOURS + _smallmap_type);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   811
		DrawWindowWidgets(w);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   812
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   813
		/* draw the legend */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   814
		tbl = _legend_table[(_smallmap_type != 2) ? _smallmap_type : (_opt.landscape + IND_OFFS)];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   815
		x = 4;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   816
		y_org = w->height - 43 - 11;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   817
		y = y_org;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   818
		while (true) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   819
			GfxFillRect(x, y+1, x+8, y + 5, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   820
			GfxFillRect(x+1, y+2, x+7, y + 4, (byte)tbl[0]);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   821
			DrawString(x+11, y, tbl[1], 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   822
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   823
			tbl += 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   824
			y += 6;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   825
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   826
			if (tbl[0] == 0xFFFF) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   827
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   828
			} else if (tbl[0] & 0x100) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   829
				x += 123;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   830
				y = y_org;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   831
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   832
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   833
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   834
		if (!FillDrawPixelInfo(&new_dpi, NULL, 3, 17, w->width - 28 + 22, w->height - 64 - 11))
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   835
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   836
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   837
		DrawSmallMap(&new_dpi, w, _smallmap_type, _smallmap_show_towns);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   838
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   839
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   840
	case WE_CLICK:
1918
fb72133270ac (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
   841
		switch (e->click.widget) {
fb72133270ac (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
   842
		case 4: {/* Main wnd */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   843
			Window *w2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   844
			Point pt;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   845
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   846
			_left_button_clicked = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   847
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   848
			w2 = FindWindowById(WC_MAIN_WINDOW, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   849
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   850
			pt = RemapCoords(WP(w,smallmap_d).scroll_x, WP(w,smallmap_d).scroll_y, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   851
			WP(w2,vp_d).scrollpos_x = pt.x + ((_cursor.pos.x - w->left + 2) << 4) - (w2->viewport->virtual_width >> 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   852
			WP(w2,vp_d).scrollpos_y = pt.y + ((_cursor.pos.y - w->top - 16) << 4) - (w2->viewport->virtual_height >> 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   853
		} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   854
1918
fb72133270ac (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
   855
		case 5: /* Show land contours */
fb72133270ac (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
   856
		case 6: /* Show vehicles */
fb72133270ac (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
   857
		case 7: /* Show industries */
fb72133270ac (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
   858
		case 8: /* Show transport routes */
fb72133270ac (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
   859
		case 9: /* Show vegetation */
fb72133270ac (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
   860
		case 10: /* Show land owners */
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   861
			w->click_state &= ~(1<<5|1<<6|1<<7|1<<8|1<<9|1<<10);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   862
			w->click_state |= 1 << e->click.widget;
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   863
			_smallmap_type = e->click.widget - 5;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   864
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   865
			SetWindowDirty(w);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
   866
			SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   867
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   868
758
423ae0bcba07 (svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents: 682
diff changeset
   869
		case 12: /* toggle town names */
423ae0bcba07 (svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents: 682
diff changeset
   870
			w->click_state ^= (1 << 12);
423ae0bcba07 (svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents: 682
diff changeset
   871
			_smallmap_show_towns = (w->click_state >> 12) & 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   872
			SetWindowDirty(w);
541
625227bb2a3d (svn r925) Use sound enums
tron
parents: 534
diff changeset
   873
			SndPlayFx(SND_15_BEEP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   874
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   875
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   876
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   877
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   878
	case WE_RCLICK:
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   879
		if (e->click.widget == 4) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   880
			if (_scrolling_viewport)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   881
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   882
			_scrolling_viewport = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   883
			_cursor.delta.x = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   884
			_cursor.delta.y = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   885
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   886
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   887
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   888
	case WE_MOUSELOOP:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   889
		/* update the window every now and then */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   890
		if ((++w->vscroll.pos & 0x1F) == 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   891
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   892
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   893
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   894
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   895
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   896
static const WindowDesc _smallmap_desc = {
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   897
	-1,-1, 446, 314,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   898
	WC_SMALLMAP,0,
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   899
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE,
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   900
	_smallmap_widgets,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   901
	SmallMapWindowProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   902
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   903
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1092
diff changeset
   904
void ShowSmallMap(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   905
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   906
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   907
	ViewPort *vp;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   908
	int x,y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   909
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   910
	w = AllocateWindowDescFront(&_smallmap_desc, 0);
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   911
	if (w) {
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   912
		w->click_state = ((1<<5) << _smallmap_type) | (_smallmap_show_towns << 12);
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   913
		w->resize.width = 350;
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   914
		w->resize.height = 250;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   915
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   916
		vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   917
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   918
		x =  (((vp->virtual_width - (220*32)) / 2) + vp->virtual_left) / 4;
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   919
		y = ((((vp->virtual_height- (120*32)) / 2) + vp->virtual_top ) / 2) - 32;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   920
		WP(w,smallmap_d).scroll_x = (y-x) & ~0xF;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   921
		WP(w,smallmap_d).scroll_y = (x+y) & ~0xF;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   922
		WP(w,smallmap_d).subscroll = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   923
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   924
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   925
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
   926
/* Extra ViewPort Window Stuff */
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   927
static const Widget _extra_view_port_widgets[] = {
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   928
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,	STR_018B_CLOSE_WINDOW},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   929
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   287,     0,    13, STR_EXTRA_VIEW_PORT_TITLE,				STR_018C_WINDOW_TITLE_DRAG_THIS},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   930
{  WWT_STICKYBOX,     RESIZE_LR,    14,   288,   299,     0,    13, 0x0,       STR_STICKY_BUTTON},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   931
{      WWT_PANEL,     RESIZE_RB,    14,     0,   299,    14,   233, 0x0,				STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   932
{          WWT_6,     RESIZE_RB,    14,     2,   297,    16,   231, 0x0,				STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   933
{      WWT_PANEL,     RESIZE_TB,    14,     0,    21,   234,   255, 0x2DF,			STR_017F_ZOOM_THE_VIEW_IN},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   934
{      WWT_PANEL,     RESIZE_TB,    14,    22,    43,   234,   255, 0x2E0,			STR_0180_ZOOM_THE_VIEW_OUT},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   935
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,    44,   171,   234,   255, STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW,STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW_TT},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   936
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   172,   298,   234,   255, STR_EXTRA_VIEW_MOVE_VIEW_TO_MAIN,STR_EXTRA_VIEW_MOVE_VIEW_TO_MAIN_TT},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   937
{      WWT_PANEL,    RESIZE_RTB,    14,   299,   299,   234,   255, 0x0,				STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   938
{      WWT_PANEL,    RESIZE_RTB,    14,     0,   287,   256,   267, 0x0,				STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   939
{  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
   940
{   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
   941
};
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
   942
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
   943
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
   944
{
1815
733868a48ab3 (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
   945
	switch (e->event) {
733868a48ab3 (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
   946
	case WE_CREATE: /* Disable zoom in button */
733868a48ab3 (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
   947
		w->disabled_state = (1 << 5);
733868a48ab3 (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
   948
		break;
733868a48ab3 (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
   949
	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
   950
		// set the number in the title bar
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   951
		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
   952
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
   953
		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
   954
		DrawWindowViewport(w);
1815
733868a48ab3 (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
   955
		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
   956
1815
733868a48ab3 (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
   957
	case WE_CLICK: {
733868a48ab3 (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
   958
		switch (e->click.widget) {
733868a48ab3 (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
   959
		case 5: /* zoom in */
733868a48ab3 (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
   960
			DoZoomInOutWindow(ZOOM_IN, w);
733868a48ab3 (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
   961
			break;
733868a48ab3 (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
   962
		case 6: /* zoom out */
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   963
			DoZoomInOutWindow(ZOOM_OUT, w);
1815
733868a48ab3 (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
   964
			break;
733868a48ab3 (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
		case 7: { /* location button (move main view to same spot as this view) 'Paste Location' */
733868a48ab3 (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
			Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0);
733868a48ab3 (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
   967
			int x = WP(w, vp_d).scrollpos_x; // Where is the main looking at
733868a48ab3 (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
			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
   969
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
   970
			// set this view to same location. Based on the center, adjusting for zoom
1815
733868a48ab3 (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
   971
			WP(w2, vp_d).scrollpos_x =  x - (w2->viewport->virtual_width -  w->viewport->virtual_width) / 2;
733868a48ab3 (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
   972
			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
   973
		} break;
1815
733868a48ab3 (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
   974
		case 8: { /* inverse location button (move this view to same spot as main view) 'Copy Location' */
733868a48ab3 (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
   975
			const Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0);
733868a48ab3 (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
			int x = WP(w2, vp_d).scrollpos_x;
733868a48ab3 (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
   977
			int y = WP(w2, 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
   978
1815
733868a48ab3 (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
   979
			WP(w, vp_d).scrollpos_x =  x + (w2->viewport->virtual_width -  w->viewport->virtual_width) / 2;
733868a48ab3 (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
   980
			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
   981
		} break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   982
		}
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
   983
	} break;
1815
733868a48ab3 (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
733868a48ab3 (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
	case WE_RESIZE:
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   986
		w->viewport->width  += e->sizing.diff.x;
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   987
		w->viewport->height += e->sizing.diff.y;
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   988
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   989
		w->viewport->virtual_width  += e->sizing.diff.x;
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   990
		w->viewport->virtual_height += e->sizing.diff.y;
1815
733868a48ab3 (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
   991
		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
   992
	}
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
   993
}
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
   994
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
   995
static const WindowDesc _extra_view_port_desc = {
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   996
	-1,-1, 300, 268,
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
	WC_EXTRA_VIEW_PORT,0,
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
   998
	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
   999
	_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
  1000
	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
  1001
};
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
  1002
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1092
diff changeset
  1003
void ShowExtraViewPortWindow(void)
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
  1004
{
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
  1005
	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
  1006
	int i = 0;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1007
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
  1008
	// find next free window number for extra viewport
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
  1009
	while (FindWindowById(WC_EXTRA_VIEW_PORT, 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
  1010
		i++;
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
  1011
	}
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
  1012
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
  1013
	w = AllocateWindowDescFront(&_extra_view_port_desc, 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
  1014
	if (w) {
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 856
diff changeset
  1015
		int x, 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
  1016
		// 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
  1017
		v = FindWindowById(WC_MAIN_WINDOW, 0);
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
  1018
		// New viewport start ats (zero,zero)
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
  1019
		AssignWindowViewport(w, 3, 17, 294, 214, 0 , 0);
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
  1020
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
  1021
		// center on same place as main window (zoom is maximum, no adjustment needed)
1815
733868a48ab3 (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
  1022
		x = WP(v, vp_d).scrollpos_x;
733868a48ab3 (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
  1023
		y = WP(v, vp_d).scrollpos_y;
733868a48ab3 (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
  1024
		WP(w, vp_d).scrollpos_x = x + (v->viewport->virtual_width  - (294)) / 2;
733868a48ab3 (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
  1025
		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
  1026
	}
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
  1027
}