author | rubidium |
Fri, 27 Jul 2007 22:10:21 +0000 | |
changeset 7345 | 9770fd47a675 |
parent 7341 | 02515d0d4ced |
child 7369 | 2bfadb828304 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
3 |
/** @file smallmap_gui.cpp */ |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1815
diff
changeset
|
6 |
#include "openttd.h" |
4356
ec4e13f21cd0
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4346
diff
changeset
|
7 |
#include "functions.h" |
3234
a2791a480b71
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3184
diff
changeset
|
8 |
#include "bridge_map.h" |
3144
33e42feae531
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
2989
diff
changeset
|
9 |
#include "clear_map.h" |
3391
3c8a6643ed15
(svn r4199) - Codechange: Use industry map accessors to get industry graphics type.
peter1138
parents:
3338
diff
changeset
|
10 |
#include "industry_map.h" |
3338
7cff208f0446
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
11 |
#include "station_map.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
500
diff
changeset
|
12 |
#include "table/strings.h" |
7266
b16e67e992b4
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
6937
diff
changeset
|
13 |
#include "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
|
14 |
#include "table/sprites.h" |
6453
226bcddeba32
(svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros
parents:
6441
diff
changeset
|
15 |
#include "landscape.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
|
16 |
#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
|
17 |
#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
|
18 |
#include "gui.h" |
3144
33e42feae531
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
2989
diff
changeset
|
19 |
#include "tree_map.h" |
3180
9c87ee130147
(svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents:
3144
diff
changeset
|
20 |
#include "tunnel_map.h" |
0 | 21 |
#include "window.h" |
22 |
#include "gfx.h" |
|
23 |
#include "viewport.h" |
|
24 |
#include "player.h" |
|
25 |
#include "vehicle.h" |
|
26 |
#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
|
27 |
#include "sound.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2062
diff
changeset
|
28 |
#include "variables.h" |
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
29 |
#include "blitter/factory.hpp" |
0 | 30 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
31 |
static const Widget _smallmap_widgets[] = { |
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2635
diff
changeset
|
32 |
{ WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7345
9770fd47a675
(svn r10708) -Codechange: allow automatic downsizing of the smallmap window in case of low resolutions; one could already make the window smaller, but the resize button was unreachable.
rubidium
parents:
7341
diff
changeset
|
33 |
{ WWT_CAPTION, RESIZE_RIGHT, 13, 11, 337, 0, 13, STR_00B0_MAP, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
9770fd47a675
(svn r10708) -Codechange: allow automatic downsizing of the smallmap window in case of low resolutions; one could already make the window smaller, but the resize button was unreachable.
rubidium
parents:
7341
diff
changeset
|
34 |
{ WWT_STICKYBOX, RESIZE_LR, 13, 338, 349, 0, 13, 0x0, STR_STICKY_BUTTON}, |
9770fd47a675
(svn r10708) -Codechange: allow automatic downsizing of the smallmap window in case of low resolutions; one could already make the window smaller, but the resize button was unreachable.
rubidium
parents:
7341
diff
changeset
|
35 |
{ WWT_PANEL, RESIZE_RB, 13, 0, 349, 14, 157, 0x0, STR_NULL}, |
9770fd47a675
(svn r10708) -Codechange: allow automatic downsizing of the smallmap window in case of low resolutions; one could already make the window smaller, but the resize button was unreachable.
rubidium
parents:
7341
diff
changeset
|
36 |
{ WWT_INSET, RESIZE_RB, 13, 2, 347, 16, 155, 0x0, STR_NULL}, |
9770fd47a675
(svn r10708) -Codechange: allow automatic downsizing of the smallmap window in case of low resolutions; one could already make the window smaller, but the resize button was unreachable.
rubidium
parents:
7341
diff
changeset
|
37 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 284, 305, 158, 179, SPR_IMG_SHOW_COUNTOURS, STR_0191_SHOW_LAND_CONTOURS_ON_MAP}, |
9770fd47a675
(svn r10708) -Codechange: allow automatic downsizing of the smallmap window in case of low resolutions; one could already make the window smaller, but the resize button was unreachable.
rubidium
parents:
7341
diff
changeset
|
38 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 306, 327, 158, 179, SPR_IMG_SHOW_VEHICLES, STR_0192_SHOW_VEHICLES_ON_MAP}, |
9770fd47a675
(svn r10708) -Codechange: allow automatic downsizing of the smallmap window in case of low resolutions; one could already make the window smaller, but the resize button was unreachable.
rubidium
parents:
7341
diff
changeset
|
39 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 328, 349, 158, 179, SPR_IMG_INDUSTRY, STR_0193_SHOW_INDUSTRIES_ON_MAP}, |
9770fd47a675
(svn r10708) -Codechange: allow automatic downsizing of the smallmap window in case of low resolutions; one could already make the window smaller, but the resize button was unreachable.
rubidium
parents:
7341
diff
changeset
|
40 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 284, 307, 180, 201, SPR_IMG_SHOW_ROUTES, STR_0194_SHOW_TRANSPORT_ROUTES_ON}, |
9770fd47a675
(svn r10708) -Codechange: allow automatic downsizing of the smallmap window in case of low resolutions; one could already make the window smaller, but the resize button was unreachable.
rubidium
parents:
7341
diff
changeset
|
41 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 306, 327, 180, 201, SPR_IMG_PLANTTREES, STR_0195_SHOW_VEGETATION_ON_MAP}, |
9770fd47a675
(svn r10708) -Codechange: allow automatic downsizing of the smallmap window in case of low resolutions; one could already make the window smaller, but the resize button was unreachable.
rubidium
parents:
7341
diff
changeset
|
42 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 328, 349, 180, 201, SPR_IMG_COMPANY_GENERAL, STR_0196_SHOW_LAND_OWNERS_ON_MAP}, |
9770fd47a675
(svn r10708) -Codechange: allow automatic downsizing of the smallmap window in case of low resolutions; one could already make the window smaller, but the resize button was unreachable.
rubidium
parents:
7341
diff
changeset
|
43 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 262, 283, 158, 179, SPR_IMG_SMALLMAP, STR_SMALLMAP_CENTER}, |
9770fd47a675
(svn r10708) -Codechange: allow automatic downsizing of the smallmap window in case of low resolutions; one could already make the window smaller, but the resize button was unreachable.
rubidium
parents:
7341
diff
changeset
|
44 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 262, 283, 180, 201, SPR_IMG_TOWN, STR_0197_TOGGLE_TOWN_NAMES_ON_OFF}, |
9770fd47a675
(svn r10708) -Codechange: allow automatic downsizing of the smallmap window in case of low resolutions; one could already make the window smaller, but the resize button was unreachable.
rubidium
parents:
7341
diff
changeset
|
45 |
{ WWT_PANEL, RESIZE_RTB, 13, 0, 261, 158, 201, 0x0, STR_NULL}, |
9770fd47a675
(svn r10708) -Codechange: allow automatic downsizing of the smallmap window in case of low resolutions; one could already make the window smaller, but the resize button was unreachable.
rubidium
parents:
7341
diff
changeset
|
46 |
{ WWT_PANEL, RESIZE_RTB, 13, 0, 337, 202, 213, 0x0, STR_NULL}, |
9770fd47a675
(svn r10708) -Codechange: allow automatic downsizing of the smallmap window in case of low resolutions; one could already make the window smaller, but the resize button was unreachable.
rubidium
parents:
7341
diff
changeset
|
47 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 13, 338, 349, 202, 213, 0x0, STR_RESIZE_BUTTON}, |
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 |
{ WIDGETS_END}, |
0 | 49 |
}; |
50 |
||
51 |
static int _smallmap_type; |
|
52 |
static bool _smallmap_show_towns = true; |
|
53 |
||
6475
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
54 |
/** Macro for ordinary entry of LegendAndColor */ |
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
55 |
#define MK(a,b) {a, b, false, false} |
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
56 |
/** Macro for end of list marker in arrays of LegendAndColor */ |
6485
2c310cd45776
(svn r9666) -Fix (r9651): end of data / column flags were reversed
peter1138
parents:
6483
diff
changeset
|
57 |
#define MKEND() {0, STR_NULL, true, false} |
6475
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
58 |
/** Macro for break marker in arrays of LegendAndColor. |
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
59 |
* It will have valid data, though */ |
6485
2c310cd45776
(svn r9666) -Fix (r9651): end of data / column flags were reversed
peter1138
parents:
6483
diff
changeset
|
60 |
#define MS(a,b) {a, b, false, true} |
0 | 61 |
|
6475
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
62 |
/** Structure for holding relevant data for legends in small map */ |
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
63 |
struct LegendAndColour { |
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
64 |
uint16 colour; ///< color of the item on the map |
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
65 |
StringID legend; ///< string corresponding to the colored item |
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
66 |
bool end; ///< this is the end of the list |
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
67 |
bool col_break; ///< perform a break and go one collumn further |
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
68 |
}; |
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
69 |
|
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
70 |
/** Legend text giving the colours to look for on the minimap */ |
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
71 |
static const LegendAndColour _legend_land_contours[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
72 |
MK(0x5A, STR_00F0_100M), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
73 |
MK(0x5C, STR_00F1_200M), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
74 |
MK(0x5E, STR_00F2_300M), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
75 |
MK(0x1F, STR_00F3_400M), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
76 |
MK(0x27, STR_00F4_500M), |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
77 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
78 |
MS(0xD7, STR_00EB_ROADS), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
79 |
MK(0x0A, STR_00EC_RAILROADS), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
80 |
MK(0x98, STR_00ED_STATIONS_AIRPORTS_DOCKS), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
81 |
MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
82 |
MK(0x0F, STR_00EF_VEHICLES), |
0 | 83 |
MKEND() |
84 |
}; |
|
85 |
||
6475
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
86 |
static const LegendAndColour _legend_vehicles[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
87 |
MK(0xB8, STR_00F5_TRAINS), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
88 |
MK(0xBF, STR_00F6_ROAD_VEHICLES), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
89 |
MK(0x98, STR_00F7_SHIPS), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
90 |
MK(0x0F, STR_00F8_AIRCRAFT), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
91 |
MS(0xD7, STR_00F9_TRANSPORT_ROUTES), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
92 |
MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES), |
0 | 93 |
MKEND() |
94 |
}; |
|
95 |
||
6475
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
96 |
static const LegendAndColour _legend_routes[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
97 |
MK(0xD7, STR_00EB_ROADS), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
98 |
MK(0x0A, STR_00EC_RAILROADS), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
99 |
MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
100 |
MS(0x56, STR_011B_RAILROAD_STATION), |
0 | 101 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
102 |
MK(0xC2, STR_011C_TRUCK_LOADING_BAY), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
103 |
MK(0xBF, STR_011D_BUS_STATION), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
104 |
MK(0xB8, STR_011E_AIRPORT_HELIPORT), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
105 |
MK(0x98, STR_011F_DOCK), |
0 | 106 |
MKEND() |
107 |
}; |
|
108 |
||
6475
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
109 |
static const LegendAndColour _legend_vegetation[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
110 |
MK(0x52, STR_0120_ROUGH_LAND), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
111 |
MK(0x54, STR_0121_GRASS_LAND), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
112 |
MK(0x37, STR_0122_BARE_LAND), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
113 |
MK(0x25, STR_0123_FIELDS), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
114 |
MK(0x57, STR_0124_TREES), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
115 |
MK(0xD0, STR_00FC_FOREST), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
116 |
MS(0x0A, STR_0125_ROCKS), |
0 | 117 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
118 |
MK(0xC2, STR_012A_DESERT), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
119 |
MK(0x98, STR_012B_SNOW), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
120 |
MK(0xD7, STR_00F9_TRANSPORT_ROUTES), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
121 |
MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES), |
0 | 122 |
MKEND() |
123 |
}; |
|
124 |
||
6475
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
125 |
static const LegendAndColour _legend_land_owners[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
126 |
MK(0xCA, STR_0126_WATER), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
127 |
MK(0x54, STR_0127_NO_OWNER), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
128 |
MK(0xB4, STR_0128_TOWNS), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
129 |
MK(0x20, STR_0129_INDUSTRIES), |
0 | 130 |
MKEND() |
131 |
}; |
|
132 |
#undef MK |
|
133 |
#undef MS |
|
134 |
#undef MKEND |
|
135 |
||
6533
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
136 |
/** Allow room for all industries, plus a terminator entry |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
137 |
* This is required in order to have the indutry slots all filled up */ |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
138 |
static LegendAndColour _legend_from_industries[NUM_INDUSTRYTYPES+1]; |
0 | 139 |
|
6533
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
140 |
/** |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
141 |
* Fills an array for the industries legends. |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
142 |
*/ |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
143 |
void BuildIndustriesLegend() |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
144 |
{ |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
145 |
const IndustrySpec *indsp; |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
146 |
uint j = 0; |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
147 |
|
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
148 |
/* Add each name */ |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
149 |
for (IndustryType i = 0; i < NUM_INDUSTRYTYPES; i++) { |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
150 |
indsp = GetIndustrySpec(i); |
6748
7579278d958f
(svn r9983) -Codechange: Use the "enabled" property of the industry spec.
belugas
parents:
6730
diff
changeset
|
151 |
if (indsp->enabled) { |
6533
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
152 |
_legend_from_industries[j].legend = indsp->name; |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
153 |
_legend_from_industries[j].colour = indsp->map_colour; |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
154 |
_legend_from_industries[j].col_break = (j % 6) == 0; // break is performed on the 7th item |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
155 |
_legend_from_industries[j].end = false; |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
156 |
j++; |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
157 |
} |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
158 |
} |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
159 |
/* Terminate the list */ |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
160 |
_legend_from_industries[j].end = true; |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
161 |
} |
6475
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
162 |
|
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
163 |
static const LegendAndColour * const _legend_table[] = { |
0 | 164 |
_legend_land_contours, |
165 |
_legend_vehicles, |
|
6533
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
166 |
_legend_from_industries, |
0 | 167 |
_legend_routes, |
168 |
_legend_vegetation, |
|
169 |
_legend_land_owners, |
|
170 |
}; |
|
171 |
||
6878
5cefd3ac59c7
(svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents:
6757
diff
changeset
|
172 |
static inline void WRITE_PIXELS(void *d, uint32 val) |
5cefd3ac59c7
(svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents:
6757
diff
changeset
|
173 |
{ |
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
174 |
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); |
6878
5cefd3ac59c7
(svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents:
6757
diff
changeset
|
175 |
uint8 *val8 = (uint8 *)&val; |
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
176 |
|
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
177 |
blitter->SetPixel(d, 0, 0, val8[0]); |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
178 |
blitter->SetPixel(d, 1, 0, val8[1]); |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
179 |
blitter->SetPixel(d, 2, 0, val8[2]); |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
180 |
blitter->SetPixel(d, 3, 0, val8[3]); |
6878
5cefd3ac59c7
(svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents:
6757
diff
changeset
|
181 |
} |
0 | 182 |
|
6878
5cefd3ac59c7
(svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents:
6757
diff
changeset
|
183 |
static inline void WRITE_PIXELS_OR(void *d, uint32 val) |
5cefd3ac59c7
(svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents:
6757
diff
changeset
|
184 |
{ |
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
185 |
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); |
6878
5cefd3ac59c7
(svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents:
6757
diff
changeset
|
186 |
uint8 *val8 = (uint8 *)&val; |
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
187 |
|
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
188 |
blitter->SetPixelIfEmpty(d, 0, 0, val8[0]); |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
189 |
blitter->SetPixelIfEmpty(d, 1, 0, val8[1]); |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
190 |
blitter->SetPixelIfEmpty(d, 2, 0, val8[2]); |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
191 |
blitter->SetPixelIfEmpty(d, 3, 0, val8[3]); |
6878
5cefd3ac59c7
(svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents:
6757
diff
changeset
|
192 |
} |
0 | 193 |
|
2984
f9d92e013486
(svn r3559) - CodeChange: simplify MKCOLOR(x) macro for smallmap_gui.c by adding a TO_LE32X() macro next to TO_BE32X(). The 'X' signifies them as macros and not-inline functions so they can be used in variable declarations.
Darkvater
parents:
2981
diff
changeset
|
194 |
#define MKCOLOR(x) TO_LE32X(x) |
0 | 195 |
|
7313
a36dc43afcb5
(svn r10665) -Codechange: replace magic 15 with MAX_TILE_HEIGHT (bilbo)
truelight
parents:
7266
diff
changeset
|
196 |
/** |
a36dc43afcb5
(svn r10665) -Codechange: replace magic 15 with MAX_TILE_HEIGHT (bilbo)
truelight
parents:
7266
diff
changeset
|
197 |
* Height encodings; MAX_TILE_HEIGHT + 1 levels, from 0 to MAX_TILE_HEIGHT |
a36dc43afcb5
(svn r10665) -Codechange: replace magic 15 with MAX_TILE_HEIGHT (bilbo)
truelight
parents:
7266
diff
changeset
|
198 |
*/ |
a36dc43afcb5
(svn r10665) -Codechange: replace magic 15 with MAX_TILE_HEIGHT (bilbo)
truelight
parents:
7266
diff
changeset
|
199 |
static const uint32 _map_height_bits[] = { |
0 | 200 |
MKCOLOR(0x5A5A5A5A), |
201 |
MKCOLOR(0x5A5B5A5B), |
|
202 |
MKCOLOR(0x5B5B5B5B), |
|
203 |
MKCOLOR(0x5B5C5B5C), |
|
204 |
MKCOLOR(0x5C5C5C5C), |
|
205 |
MKCOLOR(0x5C5D5C5D), |
|
206 |
MKCOLOR(0x5D5D5D5D), |
|
207 |
MKCOLOR(0x5D5E5D5E), |
|
208 |
MKCOLOR(0x5E5E5E5E), |
|
209 |
MKCOLOR(0x5E5F5E5F), |
|
210 |
MKCOLOR(0x5F5F5F5F), |
|
211 |
MKCOLOR(0x5F1F5F1F), |
|
212 |
MKCOLOR(0x1F1F1F1F), |
|
213 |
MKCOLOR(0x1F271F27), |
|
214 |
MKCOLOR(0x27272727), |
|
215 |
MKCOLOR(0x27272727), |
|
216 |
}; |
|
7313
a36dc43afcb5
(svn r10665) -Codechange: replace magic 15 with MAX_TILE_HEIGHT (bilbo)
truelight
parents:
7266
diff
changeset
|
217 |
assert_compile(lengthof(_map_height_bits) == MAX_TILE_HEIGHT + 1); |
0 | 218 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
219 |
struct AndOr { |
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
|
220 |
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
|
221 |
uint32 mand; |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
222 |
}; |
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
|
223 |
|
4171 | 224 |
static inline uint32 ApplyMask(uint32 colour, const AndOr *mask) |
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
|
225 |
{ |
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
|
226 |
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
|
227 |
} |
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
|
228 |
|
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
|
229 |
|
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
|
230 |
static const AndOr _smallmap_contours_andor[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
231 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
232 |
{MKCOLOR(0x000A0A00), MKCOLOR(0xFF0000FF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
233 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
234 |
{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
235 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
236 |
{MKCOLOR(0x98989898), MKCOLOR(0x00000000)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
237 |
{MKCOLOR(0xCACACACA), MKCOLOR(0x00000000)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
238 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
239 |
{MKCOLOR(0xB5B5B5B5), MKCOLOR(0x00000000)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
240 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
241 |
{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
242 |
{MKCOLOR(0x000A0A00), MKCOLOR(0xFF0000FF)}, |
0 | 243 |
}; |
244 |
||
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
|
245 |
static const AndOr _smallmap_vehicles_andor[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
246 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
247 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
248 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
249 |
{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
250 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
251 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
252 |
{MKCOLOR(0xCACACACA), MKCOLOR(0x00000000)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
253 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
254 |
{MKCOLOR(0xB5B5B5B5), MKCOLOR(0x00000000)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
255 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
256 |
{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
257 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
0 | 258 |
}; |
259 |
||
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
|
260 |
static const AndOr _smallmap_vegetation_andor[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
261 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
262 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
263 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
264 |
{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
265 |
{MKCOLOR(0x00575700), MKCOLOR(0xFF0000FF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
266 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
267 |
{MKCOLOR(0xCACACACA), MKCOLOR(0x00000000)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
268 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
269 |
{MKCOLOR(0xB5B5B5B5), MKCOLOR(0x00000000)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
270 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
271 |
{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
272 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
0 | 273 |
}; |
274 |
||
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
|
275 |
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
|
276 |
|
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
|
277 |
/** |
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
|
278 |
* 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
|
279 |
* 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
|
280 |
* |
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
|
281 |
* @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
|
282 |
* @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
|
283 |
* @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
|
284 |
* @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
|
285 |
* @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
|
286 |
* @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
|
287 |
* @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
|
288 |
* @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
|
289 |
*/ |
6878
5cefd3ac59c7
(svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents:
6757
diff
changeset
|
290 |
static void DrawSmallMapStuff(void *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
|
291 |
{ |
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
292 |
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
293 |
void *dst_ptr_end = blitter->MoveTo(_screen.dst_ptr, _screen.width, _screen.height - 1); |
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
|
294 |
|
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
|
295 |
do { |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
296 |
/* 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
|
297 |
if (xc < MapMaxX() && yc < MapMaxY()) { |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
298 |
/* check if the dst pointer points to a pixel inside the screen buffer */ |
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
|
299 |
if (dst > _screen.dst_ptr && dst < dst_ptr_end) |
1981 | 300 |
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
|
301 |
} |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
302 |
/* switch to next tile in the column */ |
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
303 |
} while (xc++, yc++, dst = blitter->MoveTo(dst, pitch, 0), --reps != 0); |
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
|
304 |
} |
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
|
305 |
|
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
306 |
|
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
307 |
static inline TileType GetEffectiveTileType(TileIndex tile) |
0 | 308 |
{ |
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
309 |
TileType t = GetTileType(tile); |
0 | 310 |
|
311 |
if (t == MP_TUNNELBRIDGE) { |
|
3180
9c87ee130147
(svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents:
3144
diff
changeset
|
312 |
TransportType tt; |
9c87ee130147
(svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents:
3144
diff
changeset
|
313 |
|
3184
118a520164e4
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3180
diff
changeset
|
314 |
if (IsTunnel(tile)) { |
118a520164e4
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3180
diff
changeset
|
315 |
tt = GetTunnelTransportType(tile); |
118a520164e4
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3180
diff
changeset
|
316 |
} else { |
3234
a2791a480b71
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3184
diff
changeset
|
317 |
tt = GetBridgeTransportType(tile); |
3180
9c87ee130147
(svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents:
3144
diff
changeset
|
318 |
} |
9c87ee130147
(svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents:
3144
diff
changeset
|
319 |
switch (tt) { |
9c87ee130147
(svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents:
3144
diff
changeset
|
320 |
case TRANSPORT_RAIL: t = MP_RAILWAY; break; |
9c87ee130147
(svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents:
3144
diff
changeset
|
321 |
case TRANSPORT_ROAD: t = MP_STREET; break; |
9c87ee130147
(svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents:
3144
diff
changeset
|
322 |
default: t = MP_WATER; break; |
0 | 323 |
} |
324 |
} |
|
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
325 |
return t; |
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
326 |
} |
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
327 |
|
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
|
328 |
/** |
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
|
329 |
* 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
|
330 |
* @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
|
331 |
* @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
|
332 |
*/ |
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
333 |
static inline uint32 GetSmallMapContoursPixels(TileIndex tile) |
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
334 |
{ |
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
335 |
TileType t = GetEffectiveTileType(tile); |
0 | 336 |
|
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
|
337 |
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
|
338 |
ApplyMask(_map_height_bits[TileHeight(tile)], &_smallmap_contours_andor[t]); |
0 | 339 |
} |
340 |
||
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
|
341 |
/** |
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 |
* 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
|
343 |
* |
6483
ae78fc3c6b20
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas
parents:
6476
diff
changeset
|
344 |
* @param tile The tile of which we would like to get the color. |
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
|
345 |
* @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
|
346 |
*/ |
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
347 |
static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile) |
0 | 348 |
{ |
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
349 |
TileType t = GetEffectiveTileType(tile); |
0 | 350 |
|
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
|
351 |
return ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]); |
0 | 352 |
} |
353 |
||
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
|
354 |
/** |
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
|
355 |
* 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
|
356 |
* |
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
|
357 |
* @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
|
358 |
* @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
|
359 |
*/ |
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
360 |
static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile) |
0 | 361 |
{ |
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
362 |
TileType t = GetEffectiveTileType(tile); |
0 | 363 |
|
364 |
if (t == MP_INDUSTRY) { |
|
6441
1cb1c647752f
(svn r9578) -Codechange: Cleanup of industry_cmd (Step-10). Use industry's spec map_colour for smallmap industry color code drawing
belugas
parents:
6420
diff
changeset
|
365 |
return GetIndustrySpec(GetIndustryByTile(tile)->type)->map_colour * 0x01010101; |
0 | 366 |
} |
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
|
367 |
|
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
|
368 |
return ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]); |
0 | 369 |
} |
370 |
||
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
|
371 |
/** |
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
|
372 |
* 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
|
373 |
* |
6483
ae78fc3c6b20
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas
parents:
6476
diff
changeset
|
374 |
* @param tile The tile of which we would like to get the color. |
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
|
375 |
* @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
|
376 |
*/ |
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
377 |
static inline uint32 GetSmallMapRoutesPixels(TileIndex tile) |
0 | 378 |
{ |
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
379 |
TileType t = GetEffectiveTileType(tile); |
0 | 380 |
uint32 bits; |
381 |
||
382 |
if (t == MP_STATION) { |
|
3338
7cff208f0446
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
383 |
switch (GetStationType(tile)) { |
7cff208f0446
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
384 |
case STATION_RAIL: bits = MKCOLOR(0x56565656); break; |
7cff208f0446
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
385 |
case STATION_AIRPORT: bits = MKCOLOR(0xB8B8B8B8); break; |
7cff208f0446
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
386 |
case STATION_TRUCK: bits = MKCOLOR(0xC2C2C2C2); break; |
7cff208f0446
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
387 |
case STATION_BUS: bits = MKCOLOR(0xBFBFBFBF); break; |
7cff208f0446
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
388 |
case STATION_DOCK: bits = MKCOLOR(0x98989898); break; |
7cff208f0446
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
389 |
default: bits = MKCOLOR(0xFFFFFFFF); break; |
7cff208f0446
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
390 |
} |
0 | 391 |
} else { |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
392 |
/* 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
|
393 |
bits = ApplyMask(MKCOLOR(0x54545454), &_smallmap_contours_andor[t]); |
0 | 394 |
} |
395 |
return bits; |
|
396 |
} |
|
397 |
||
398 |
||
2955
24de69e236d2
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
399 |
static const uint32 _vegetation_clear_bits[] = { |
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
|
400 |
MKCOLOR(0x54545454), ///< full 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
|
401 |
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
|
402 |
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
|
403 |
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
|
404 |
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
|
405 |
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
|
406 |
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
|
407 |
MKCOLOR(0x54545454), ///< unused |
0 | 408 |
}; |
409 |
||
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
410 |
static inline uint32 GetSmallMapVegetationPixels(TileIndex tile) |
0 | 411 |
{ |
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
412 |
TileType t = GetEffectiveTileType(tile); |
0 | 413 |
uint32 bits; |
414 |
||
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
415 |
switch (t) { |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
416 |
case MP_CLEAR: |
3447 | 417 |
if (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) < 3) { |
2955
24de69e236d2
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
418 |
bits = MKCOLOR(0x37373737); |
24de69e236d2
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
419 |
} else { |
24de69e236d2
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
420 |
bits = _vegetation_clear_bits[GetClearGround(tile)]; |
24de69e236d2
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
421 |
} |
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
422 |
break; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
423 |
|
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
424 |
case MP_INDUSTRY: |
6757
385cb1bf2ba9
(svn r9992) -Codechange: Remove some hardcoded references to Industry IDs.
belugas
parents:
6748
diff
changeset
|
425 |
bits = GetIndustrySpec(GetIndustryByTile(tile)->type)->check_proc == CHECK_FOREST ? MKCOLOR(0xD0D0D0D0) : MKCOLOR(0xB5B5B5B5); |
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
426 |
break; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
427 |
|
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
428 |
case MP_TREES: |
3441
fead68bcb6a3
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3421
diff
changeset
|
429 |
if (GetTreeGround(tile) == TREE_GROUND_SNOW_DESERT) { |
6357
f0f5e7d1713c
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6259
diff
changeset
|
430 |
bits = (_opt.landscape == LT_ARCTIC) ? MKCOLOR(0x98575798) : MKCOLOR(0xC25757C2); |
2951 | 431 |
} else { |
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
432 |
bits = MKCOLOR(0x54575754); |
2951 | 433 |
} |
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
434 |
break; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
435 |
|
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
436 |
default: |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
437 |
bits = ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]); |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
438 |
break; |
0 | 439 |
} |
440 |
||
441 |
return bits; |
|
442 |
} |
|
443 |
||
444 |
||
4846
8cf926d11bfa
(svn r6772) -Codechange: Do not abuse OWNER_SPECTATOR as the "owner" of the industry for
Darkvater
parents:
4727
diff
changeset
|
445 |
static uint32 _owner_colors[OWNER_END + 1]; |
0 | 446 |
|
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
|
447 |
/** |
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
|
448 |
* 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
|
449 |
* |
6483
ae78fc3c6b20
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas
parents:
6476
diff
changeset
|
450 |
* @param tile The tile of which we would like to get the color. |
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
|
451 |
* @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
|
452 |
*/ |
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
453 |
static inline uint32 GetSmallMapOwnerPixels(TileIndex tile) |
0 | 454 |
{ |
2368
cb44b5c6953d
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
455 |
Owner o; |
0 | 456 |
|
2368
cb44b5c6953d
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
457 |
switch (GetTileType(tile)) { |
4846
8cf926d11bfa
(svn r6772) -Codechange: Do not abuse OWNER_SPECTATOR as the "owner" of the industry for
Darkvater
parents:
4727
diff
changeset
|
458 |
case MP_INDUSTRY: o = OWNER_END; break; |
2368
cb44b5c6953d
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
459 |
case MP_HOUSE: o = OWNER_TOWN; break; |
cb44b5c6953d
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
460 |
default: o = GetTileOwner(tile); break; |
0 | 461 |
} |
462 |
||
2368
cb44b5c6953d
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
463 |
return _owner_colors[o]; |
0 | 464 |
} |
465 |
||
466 |
||
467 |
static const uint32 _smallmap_mask_left[3] = { |
|
468 |
MKCOLOR(0xFF000000), |
|
469 |
MKCOLOR(0xFFFF0000), |
|
470 |
MKCOLOR(0xFFFFFF00), |
|
471 |
}; |
|
472 |
||
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
473 |
static const uint32 _smallmap_mask_right[] = { |
0 | 474 |
MKCOLOR(0x000000FF), |
475 |
MKCOLOR(0x0000FFFF), |
|
476 |
MKCOLOR(0x00FFFFFF), |
|
477 |
}; |
|
478 |
||
479 |
/* each tile has 4 x pixels and 1 y pixel */ |
|
480 |
||
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
|
481 |
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
|
482 |
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
|
483 |
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
|
484 |
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
|
485 |
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
|
486 |
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
|
487 |
GetSmallMapOwnerPixels, |
0 | 488 |
}; |
489 |
||
490 |
static const byte _vehicle_type_colors[6] = { |
|
491 |
184, 191, 152, 15, 215, 184 |
|
492 |
}; |
|
493 |
||
494 |
||
495 |
static void DrawVertMapIndicator(int x, int y, int x2, int y2) |
|
496 |
{ |
|
2951 | 497 |
GfxFillRect(x, y, x2, y + 3, 69); |
498 |
GfxFillRect(x, y2 - 3, x2, y2, 69); |
|
0 | 499 |
} |
500 |
||
501 |
static void DrawHorizMapIndicator(int x, int y, int x2, int y2) |
|
502 |
{ |
|
2951 | 503 |
GfxFillRect(x, y, x + 3, y2, 69); |
504 |
GfxFillRect(x2 - 3, y, x2, y2, 69); |
|
0 | 505 |
} |
506 |
||
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
|
507 |
/** |
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
|
508 |
* 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
|
509 |
* |
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
|
510 |
* 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
|
511 |
* 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
|
512 |
* 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
|
513 |
* <ol><li>The colors of tiles in the different modes.</li> |
6488
b6c42e91bb35
(svn r9669) -Documentation: some more doxygen fixes
belugas
parents:
6485
diff
changeset
|
514 |
* <li>Town names (optional)</li></ol> |
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
|
515 |
* |
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 |
* @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
|
517 |
* @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
|
518 |
* @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
|
519 |
* @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
|
520 |
*/ |
0 | 521 |
static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_towns) |
522 |
{ |
|
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
523 |
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); |
0 | 524 |
DrawPixelInfo *old_dpi; |
525 |
int dx,dy, x, y, x2, y2; |
|
6878
5cefd3ac59c7
(svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents:
6757
diff
changeset
|
526 |
void *ptr; |
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
527 |
int tile_x; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
528 |
int tile_y; |
0 | 529 |
ViewPort *vp; |
530 |
||
531 |
old_dpi = _cur_dpi; |
|
532 |
_cur_dpi = dpi; |
|
533 |
||
534 |
/* clear it */ |
|
535 |
GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1, 0); |
|
536 |
||
537 |
/* setup owner table */ |
|
538 |
if (type == 5) { |
|
4171 | 539 |
const Player *p; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
540 |
|
0 | 541 |
/* fill with some special colors */ |
2368
cb44b5c6953d
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
542 |
_owner_colors[OWNER_TOWN] = MKCOLOR(0xB4B4B4B4); |
2332
73edb64097fb
(svn r2858) -Codechange: resolved some magic numbers (_Luca_)
truelight
parents:
2186
diff
changeset
|
543 |
_owner_colors[OWNER_NONE] = MKCOLOR(0x54545454); |
73edb64097fb
(svn r2858) -Codechange: resolved some magic numbers (_Luca_)
truelight
parents:
2186
diff
changeset
|
544 |
_owner_colors[OWNER_WATER] = MKCOLOR(0xCACACACA); |
4847
84e4a64db23c
(svn r6773) -eh...I had to test it didn't i, just forgot to save
Darkvater
parents:
4846
diff
changeset
|
545 |
_owner_colors[OWNER_END] = MKCOLOR(0x20202020); /* industry */ |
0 | 546 |
|
547 |
/* now fill with the player colors */ |
|
548 |
FOR_ALL_PLAYERS(p) { |
|
2951 | 549 |
if (p->is_active) { |
1092 | 550 |
_owner_colors[p->index] = |
4455
f7e53dabbb72
(svn r6238) Use the colour stored in _colour_gradient[] instead of explicitly retrieving it with GetNonSprite()
tron
parents:
4435
diff
changeset
|
551 |
_colour_gradient[p->player_color][5] * 0x01010101; |
2951 | 552 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
553 |
} |
0 | 554 |
} |
555 |
||
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3391
diff
changeset
|
556 |
tile_x = WP(w,smallmap_d).scroll_x / TILE_SIZE; |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3391
diff
changeset
|
557 |
tile_y = WP(w,smallmap_d).scroll_y / TILE_SIZE; |
0 | 558 |
|
559 |
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
|
560 |
tile_x -= dx / 4; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
561 |
tile_y += dx / 4; |
0 | 562 |
dx &= 3; |
563 |
||
564 |
dy = dpi->top; |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
565 |
tile_x += dy / 2; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
566 |
tile_y += dy / 2; |
0 | 567 |
|
568 |
if (dy & 1) { |
|
569 |
tile_x++; |
|
570 |
dx += 2; |
|
571 |
if (dx > 3) { |
|
572 |
dx -= 4; |
|
573 |
tile_x--; |
|
574 |
tile_y++; |
|
575 |
} |
|
576 |
} |
|
577 |
||
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
578 |
ptr = blitter->MoveTo(dpi->dst_ptr, -dx - 4, 0); |
0 | 579 |
x = - dx - 4; |
580 |
y = 0; |
|
581 |
||
2952 | 582 |
for (;;) { |
2989 | 583 |
uint32 mask = 0xFFFFFFFF; |
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
584 |
int reps; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
585 |
int t; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
586 |
|
0 | 587 |
/* distance from left edge */ |
588 |
if (x < 0) { |
|
589 |
if (x < -3) goto skip_column; |
|
590 |
/* mask to use at the left edge */ |
|
591 |
mask = _smallmap_mask_left[x + 3]; |
|
592 |
} |
|
593 |
||
594 |
/* distance from right edge */ |
|
595 |
t = dpi->width - x; |
|
596 |
if (t < 4) { |
|
2951 | 597 |
if (t <= 0) break; /* exit loop */ |
0 | 598 |
/* mask to use at the right edge */ |
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
599 |
mask &= _smallmap_mask_right[t - 1]; |
0 | 600 |
} |
601 |
||
602 |
/* number of lines */ |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
603 |
reps = (dpi->height - y + 1) / 2; |
0 | 604 |
if (reps > 0) { |
4171 | 605 |
DrawSmallMapStuff(ptr, tile_x, tile_y, dpi->pitch * 2, reps, mask, _smallmap_draw_procs[type]); |
0 | 606 |
} |
607 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
608 |
skip_column: |
0 | 609 |
if (y == 0) { |
610 |
tile_y++; |
|
611 |
y++; |
|
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
612 |
ptr = blitter->MoveTo(ptr, 0, 1); |
0 | 613 |
} else { |
614 |
tile_x--; |
|
615 |
y--; |
|
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
616 |
ptr = blitter->MoveTo(ptr, 0, -1); |
0 | 617 |
} |
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
618 |
ptr = blitter->MoveTo(ptr, 2, 0); |
0 | 619 |
x += 2; |
620 |
} |
|
621 |
||
622 |
/* draw vehicles? */ |
|
623 |
if (type == 0 || type == 1) { |
|
624 |
Vehicle *v; |
|
625 |
bool skip; |
|
626 |
byte color; |
|
627 |
||
628 |
FOR_ALL_VEHICLES(v) { |
|
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6248
diff
changeset
|
629 |
if (v->type != VEH_SPECIAL && |
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
630 |
(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) { |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
631 |
/* Remap into flat coordinates. */ |
0 | 632 |
Point pt = RemapCoords( |
5096
739033ce923c
(svn r7166) -Fix: [FS#402] MiniMap was misplacing vehicles sometimes (HMage)
KUDr
parents:
5070
diff
changeset
|
633 |
v->x_pos / TILE_SIZE - WP(w,smallmap_d).scroll_x / TILE_SIZE, // divide each one separately because (a-b)/c != a/c-b/c in integer world |
739033ce923c
(svn r7166) -Fix: [FS#402] MiniMap was misplacing vehicles sometimes (HMage)
KUDr
parents:
5070
diff
changeset
|
634 |
v->y_pos / TILE_SIZE - WP(w,smallmap_d).scroll_y / TILE_SIZE, // dtto |
0 | 635 |
0); |
636 |
x = pt.x; |
|
637 |
y = pt.y; |
|
638 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
639 |
/* Check if y is out of bounds? */ |
0 | 640 |
y -= dpi->top; |
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
641 |
if (!IS_INT_INSIDE(y, 0, dpi->height)) continue; |
0 | 642 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
643 |
/* Default is to draw both pixels. */ |
0 | 644 |
skip = false; |
645 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
646 |
/* Offset X coordinate */ |
0 | 647 |
x -= WP(w,smallmap_d).subscroll + 3 + dpi->left; |
648 |
||
649 |
if (x < 0) { |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
650 |
/* if x+1 is 0, that means we're on the very left edge, |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
651 |
* and should thus only draw a single pixel */ |
2951 | 652 |
if (++x != 0) continue; |
0 | 653 |
skip = true; |
654 |
} else if (x >= dpi->width - 1) { |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
655 |
/* Check if we're at the very right edge, and if so draw only a single pixel */ |
2951 | 656 |
if (x != dpi->width - 1) continue; |
0 | 657 |
skip = true; |
658 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
659 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
660 |
/* Calculate pointer to pixel and the color */ |
5955
fe61588d5188
(svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents:
5893
diff
changeset
|
661 |
color = (type == 1) ? _vehicle_type_colors[v->type] : 0xF; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
662 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
663 |
/* And draw either one or two pixels depending on clipping */ |
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
664 |
blitter->SetPixel(dpi->dst_ptr, x, y, color); |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
6878
diff
changeset
|
665 |
if (!skip) blitter->SetPixel(dpi->dst_ptr, x + 1, y, color); |
0 | 666 |
} |
667 |
} |
|
668 |
} |
|
669 |
||
670 |
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
|
671 |
const Town *t; |
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
672 |
|
0 | 673 |
FOR_ALL_TOWNS(t) { |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
674 |
/* Remap the town coordinate */ |
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
675 |
Point pt = RemapCoords( |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
676 |
(int)(TileX(t->xy) * TILE_SIZE - WP(w, smallmap_d).scroll_x) / TILE_SIZE, |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
677 |
(int)(TileY(t->xy) * TILE_SIZE - WP(w, smallmap_d).scroll_y) / TILE_SIZE, |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
678 |
0); |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
679 |
x = pt.x - WP(w,smallmap_d).subscroll + 3 - (t->sign.width_2 >> 1); |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
680 |
y = pt.y; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
681 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
682 |
/* Check if the town sign is within bounds */ |
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
683 |
if (x + t->sign.width_2 > dpi->left && |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
684 |
x < dpi->left + dpi->width && |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
685 |
y + 6 > dpi->top && |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
686 |
y < dpi->top + dpi->height) { |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
687 |
/* And draw it. */ |
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
688 |
SetDParam(0, t->index); |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
689 |
DrawString(x, y, STR_2056, 12); |
0 | 690 |
} |
691 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
692 |
} |
0 | 693 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
694 |
/* Draw map indicators */ |
0 | 695 |
{ |
696 |
Point pt; |
|
697 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
698 |
/* Find main viewport. */ |
0 | 699 |
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
|
700 |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
701 |
pt = RemapCoords(WP(w, smallmap_d).scroll_x, WP(w, smallmap_d).scroll_y, 0); |
0 | 702 |
|
703 |
x = vp->virtual_left - pt.x; |
|
704 |
y = vp->virtual_top - pt.y; |
|
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3391
diff
changeset
|
705 |
x2 = (x + vp->virtual_width) / TILE_SIZE; |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3391
diff
changeset
|
706 |
y2 = (y + vp->virtual_height) / TILE_SIZE; |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3391
diff
changeset
|
707 |
x /= TILE_SIZE; |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3391
diff
changeset
|
708 |
y /= TILE_SIZE; |
0 | 709 |
|
710 |
x -= WP(w,smallmap_d).subscroll; |
|
711 |
x2 -= WP(w,smallmap_d).subscroll; |
|
712 |
||
713 |
DrawVertMapIndicator(x, y, x, y2); |
|
714 |
DrawVertMapIndicator(x2, y, x2, y2); |
|
715 |
||
716 |
DrawHorizMapIndicator(x, y, x2, y); |
|
717 |
DrawHorizMapIndicator(x, y2, x2, y2); |
|
718 |
} |
|
719 |
_cur_dpi = old_dpi; |
|
720 |
} |
|
721 |
||
4339
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
722 |
void SmallMapCenterOnCurrentPos(Window *w) |
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
723 |
{ |
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
724 |
int x, y; |
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
725 |
ViewPort *vp; |
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
726 |
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport; |
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
727 |
|
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
728 |
x = ((vp->virtual_width - (w->widget[4].right - w->widget[4].left) * TILE_SIZE) / 2 + vp->virtual_left) / 4; |
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
729 |
y = ((vp->virtual_height - (w->widget[4].bottom - w->widget[4].top ) * TILE_SIZE) / 2 + vp->virtual_top ) / 2 - TILE_SIZE * 2; |
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
730 |
WP(w, smallmap_d).scroll_x = (y - x) & ~0xF; |
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
731 |
WP(w, smallmap_d).scroll_y = (x + y) & ~0xF; |
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
732 |
SetWindowDirty(w); |
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
733 |
} |
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
734 |
|
0 | 735 |
static void SmallMapWindowProc(Window *w, WindowEvent *e) |
736 |
{ |
|
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
|
737 |
switch (e->event) { |
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
738 |
case WE_PAINT: { |
6476
1667135677f7
(svn r9652) -Fix(r9651): "const" keyword forgotten. Spotted by glx.
belugas
parents:
6475
diff
changeset
|
739 |
const LegendAndColour *tbl; |
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
740 |
int x, y, y_org; |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
741 |
DrawPixelInfo new_dpi; |
0 | 742 |
|
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
743 |
/* draw the window */ |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
744 |
SetDParam(0, STR_00E5_CONTOURS + _smallmap_type); |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
745 |
DrawWindowWidgets(w); |
0 | 746 |
|
6533
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
747 |
tbl = _legend_table[_smallmap_type]; |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
748 |
|
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
749 |
x = 4; |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
750 |
y_org = w->height - 44 - 11; |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
751 |
y = y_org; |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
752 |
for (;;) { |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
753 |
GfxFillRect(x, y + 1, x + 8, y + 5, 0); |
6475
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
754 |
GfxFillRect(x + 1, y + 2, x + 7, y + 4, tbl->colour); |
6533
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
755 |
|
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
756 |
if (_smallmap_type == 2) { |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
757 |
/* Industry name must be formated, since it's not in tiny font in the specs. |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
758 |
* So, draw with a parameter and use the STR_7065 string, which is tiny, black */ |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
759 |
SetDParam(0, tbl->legend); |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
760 |
DrawString(x + 11, y, STR_7065, 0); |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
761 |
} else { |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
762 |
DrawString(x + 11, y, tbl->legend, 0); |
8be3ef428116
(svn r9721) -Codechange: -Codechange: Cleanup of industry_cmd (Step-12). Dynamically build the legends (name and color) for industries in the smallmap_gui.
belugas
parents:
6488
diff
changeset
|
763 |
} |
0 | 764 |
|
6475
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
765 |
tbl += 1; |
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
766 |
y += 6; |
4339
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
767 |
|
6475
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
768 |
if (tbl->end) { // end of the list |
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
769 |
break; |
6475
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
770 |
} else if (tbl->col_break) { |
b7dce828b7a1
(svn r9651) -Codechange: make legend system of smallmap a little bit less magic with the help of a struct and not an array of bytes
belugas
parents:
6453
diff
changeset
|
771 |
/* break asked, continue at top, 123 pixels (one "row") to the right */ |
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
772 |
x += 123; |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
773 |
y = y_org; |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
774 |
} |
4339
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
775 |
} |
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
776 |
|
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
777 |
if (!FillDrawPixelInfo(&new_dpi, 3, 17, w->width - 28 + 22, w->height - 64 - 11)) |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
778 |
return; |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
779 |
|
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
780 |
DrawSmallMap(&new_dpi, w, _smallmap_type, _smallmap_show_towns); |
0 | 781 |
} break; |
782 |
||
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
783 |
case WE_CLICK: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
784 |
switch (e->we.click.widget) { |
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
785 |
case 4: { // Map window |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
786 |
Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0); |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
787 |
Point pt; |
5127
44b74d23fab1
(svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents:
5096
diff
changeset
|
788 |
|
44b74d23fab1
(svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents:
5096
diff
changeset
|
789 |
/* |
44b74d23fab1
(svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents:
5096
diff
changeset
|
790 |
* XXX: scrolling with the left mouse button is done by subsequently |
44b74d23fab1
(svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents:
5096
diff
changeset
|
791 |
* clicking with the left mouse button; clicking once centers the |
44b74d23fab1
(svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents:
5096
diff
changeset
|
792 |
* large map at the selected point. So by unclicking the left mouse |
44b74d23fab1
(svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents:
5096
diff
changeset
|
793 |
* button here, it gets reclicked during the next inputloop, which |
44b74d23fab1
(svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents:
5096
diff
changeset
|
794 |
* would make it look like the mouse is being dragged, while it is |
44b74d23fab1
(svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents:
5096
diff
changeset
|
795 |
* actually being (virtually) clicked every inputloop. |
44b74d23fab1
(svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents:
5096
diff
changeset
|
796 |
*/ |
44b74d23fab1
(svn r7208) -Revert [r6040]: Remove double-click action in minimap and reintroduce lmb-scrolling (Rubidium)
Darkvater
parents:
5096
diff
changeset
|
797 |
_left_button_clicked = false; |
0 | 798 |
|
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
799 |
pt = RemapCoords(WP(w,smallmap_d).scroll_x, WP(w,smallmap_d).scroll_y, 0); |
6730
9311a208f8f7
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
6626
diff
changeset
|
800 |
WP(w2, vp_d).dest_scrollpos_x = pt.x + ((_cursor.pos.x - w->left + 2) << 4) - (w2->viewport->virtual_width >> 1); |
9311a208f8f7
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
6626
diff
changeset
|
801 |
WP(w2, vp_d).dest_scrollpos_y = pt.y + ((_cursor.pos.y - w->top - 16) << 4) - (w2->viewport->virtual_height >> 1); |
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
802 |
|
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
803 |
SetWindowDirty(w); |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
804 |
} break; |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
805 |
|
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
806 |
case 5: // Show land contours |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
807 |
case 6: // Show vehicles |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
808 |
case 7: // Show industries |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
809 |
case 8: // Show transport routes |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
810 |
case 9: // Show vegetation |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
811 |
case 10: // Show land owners |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
812 |
RaiseWindowWidget(w, _smallmap_type + 5); |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
813 |
_smallmap_type = e->we.click.widget - 5; |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
814 |
LowerWindowWidget(w, _smallmap_type + 5); |
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
815 |
|
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
816 |
SetWindowDirty(w); |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
817 |
SndPlayFx(SND_15_BEEP); |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
818 |
break; |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
819 |
|
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
820 |
case 11: // Center the smallmap again |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
821 |
SmallMapCenterOnCurrentPos(w); |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
822 |
|
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
823 |
SetWindowDirty(w); |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
824 |
SndPlayFx(SND_15_BEEP); |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
825 |
break; |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
826 |
|
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
827 |
case 12: // Toggle town names |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
828 |
ToggleWidgetLoweredState(w, 12); |
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
829 |
_smallmap_show_towns = IsWindowWidgetLowered(w, 12); |
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
830 |
|
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
831 |
SetWindowDirty(w); |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
832 |
SndPlayFx(SND_15_BEEP); |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
833 |
break; |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
834 |
} |
0 | 835 |
break; |
836 |
||
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
837 |
case WE_RCLICK: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
838 |
if (e->we.click.widget == 4) { |
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
839 |
if (_scrolling_viewport) return; |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
840 |
_scrolling_viewport = true; |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
841 |
_cursor.delta.x = 0; |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
842 |
_cursor.delta.y = 0; |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
843 |
} |
4339
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
844 |
break; |
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
845 |
|
4435
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
846 |
case WE_MOUSELOOP: |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
847 |
/* update the window every now and then */ |
40eff4363774
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
848 |
if ((++w->vscroll.pos & 0x1F) == 0) SetWindowDirty(w); |
0 | 849 |
break; |
4335
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
850 |
|
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
851 |
case WE_SCROLL: { |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
852 |
int x; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
853 |
int y; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
854 |
int sub; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
855 |
int hx; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
856 |
int hy; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
857 |
int hvx; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
858 |
int hvy; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
859 |
|
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
860 |
_cursor.fix_at = true; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
861 |
|
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
862 |
x = WP(w, smallmap_d).scroll_x; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
863 |
y = WP(w, smallmap_d).scroll_y; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
864 |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
865 |
sub = WP(w, smallmap_d).subscroll + e->we.scroll.delta.x; |
4335
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
866 |
|
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
867 |
x -= (sub >> 2) << 4; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
868 |
y += (sub >> 2) << 4; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
869 |
sub &= 3; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
870 |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
871 |
x += (e->we.scroll.delta.y >> 1) << 4; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
872 |
y += (e->we.scroll.delta.y >> 1) << 4; |
4335
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
873 |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
874 |
if (e->we.scroll.delta.y & 1) { |
4335
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
875 |
x += TILE_SIZE; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
876 |
sub += 2; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
877 |
if (sub > 3) { |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
878 |
sub -= 4; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
879 |
x -= TILE_SIZE; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
880 |
y += TILE_SIZE; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
881 |
} |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
882 |
} |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
883 |
|
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
884 |
hx = (w->widget[4].right - w->widget[4].left) / 2; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
885 |
hy = (w->widget[4].bottom - w->widget[4].top ) / 2; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
886 |
hvx = hx * -4 + hy * 8; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
887 |
hvy = hx * 4 + hy * 8; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
888 |
if (x < -hvx) { |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
889 |
x = -hvx; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
890 |
sub = 0; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
891 |
} |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
892 |
if (x > (int)MapMaxX() * TILE_SIZE - hvx) { |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
893 |
x = MapMaxX() * TILE_SIZE - hvx; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
894 |
sub = 0; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
895 |
} |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
896 |
if (y < -hvy) { |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
897 |
y = -hvy; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
898 |
sub = 0; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
899 |
} |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
900 |
if (y > (int)MapMaxY() * TILE_SIZE - hvy) { |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
901 |
y = MapMaxY() * TILE_SIZE - hvy; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
902 |
sub = 0; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
903 |
} |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
904 |
|
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
905 |
WP(w, smallmap_d).scroll_x = x; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
906 |
WP(w, smallmap_d).scroll_y = y; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
907 |
WP(w, smallmap_d).subscroll = sub; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
908 |
|
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
909 |
SetWindowDirty(w); |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
910 |
} break; |
0 | 911 |
} |
912 |
} |
|
913 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
914 |
static const WindowDesc _smallmap_desc = { |
7345
9770fd47a675
(svn r10708) -Codechange: allow automatic downsizing of the smallmap window in case of low resolutions; one could already make the window smaller, but the resize button was unreachable.
rubidium
parents:
7341
diff
changeset
|
915 |
WDP_AUTO, WDP_AUTO, 350, 214, 446, 314, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5584
diff
changeset
|
916 |
WC_SMALLMAP, WC_NONE, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
917 |
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
|
918 |
_smallmap_widgets, |
0 | 919 |
SmallMapWindowProc |
920 |
}; |
|
921 |
||
6247 | 922 |
void ShowSmallMap() |
0 | 923 |
{ |
924 |
Window *w; |
|
925 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
926 |
w = AllocateWindowDescFront(&_smallmap_desc, 0); |
4339
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
927 |
if (w == NULL) return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
928 |
|
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
929 |
LowerWindowWidget(w, _smallmap_type + 5); |
4727
6819acce7c57
(svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents:
4719
diff
changeset
|
930 |
SetWindowWidgetLoweredState(w, 12, _smallmap_show_towns); |
0 | 931 |
|
4339
0b1c9f47e69b
(svn r6040) -Add: when clicking twice on a Location Button, the SmallMap centers on your position (based on FS#54 by thomasdev)
truelight
parents:
4337
diff
changeset
|
932 |
SmallMapCenterOnCurrentPos(w); |
0 | 933 |
} |
934 |
||
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
|
935 |
/* 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
|
936 |
static const Widget _extra_view_port_widgets[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
937 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
938 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 287, 0, 13, STR_EXTRA_VIEW_PORT_TITLE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
939 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 288, 299, 0, 13, 0x0, STR_STICKY_BUTTON}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
940 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 299, 14, 233, 0x0, STR_NULL}, |
4939
bef7c24a6027
(svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents:
4938
diff
changeset
|
941 |
{ WWT_INSET, RESIZE_RB, 14, 2, 297, 16, 231, 0x0, STR_NULL}, |
5036
2eb10262d2b4
(svn r7078) -Codechange: Make the zoom in/out buttons of the extra viewport into proper push-buttons.
Darkvater
parents:
4939
diff
changeset
|
942 |
{ WWT_PUSHIMGBTN, RESIZE_TB, 14, 0, 21, 234, 255, SPR_IMG_ZOOMIN, STR_017F_ZOOM_THE_VIEW_IN}, |
2eb10262d2b4
(svn r7078) -Codechange: Make the zoom in/out buttons of the extra viewport into proper push-buttons.
Darkvater
parents:
4939
diff
changeset
|
943 |
{ WWT_PUSHIMGBTN, RESIZE_TB, 14, 22, 43, 234, 255, SPR_IMG_ZOOMOUT, STR_0180_ZOOM_THE_VIEW_OUT}, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
944 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 44, 171, 234, 255, STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW, STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW_TT}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
945 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 172, 298, 234, 255, STR_EXTRA_VIEW_MOVE_VIEW_TO_MAIN, STR_EXTRA_VIEW_MOVE_VIEW_TO_MAIN_TT}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
946 |
{ WWT_PANEL, RESIZE_RTB, 14, 299, 299, 234, 255, 0x0, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
947 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 287, 256, 267, 0x0, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
948 |
{ WWT_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
|
949 |
{ 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
|
950 |
}; |
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
|
951 |
|
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 |
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
|
953 |
{ |
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
|
954 |
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
|
955 |
case WE_CREATE: /* Disable zoom in button */ |
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
956 |
DisableWindowWidget(w, 5); |
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 |
break; |
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3882
diff
changeset
|
958 |
|
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
|
959 |
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
|
960 |
// set the number in the title bar |
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3882
diff
changeset
|
961 |
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
|
962 |
|
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
963 |
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
|
964 |
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
|
965 |
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
|
966 |
|
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3882
diff
changeset
|
967 |
case WE_CLICK: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
968 |
switch (e->we.click.widget) { |
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3882
diff
changeset
|
969 |
case 5: DoZoomInOutWindow(ZOOM_IN, w); break; |
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3882
diff
changeset
|
970 |
case 6: DoZoomInOutWindow(ZOOM_OUT, w); break; |
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3882
diff
changeset
|
971 |
|
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
|
972 |
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
|
973 |
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
|
974 |
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
|
975 |
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
|
976 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
977 |
/* set this view to same location. Based on the center, adjusting for zoom */ |
6730
9311a208f8f7
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
6626
diff
changeset
|
978 |
WP(w2, vp_d).dest_scrollpos_x = x - (w2->viewport->virtual_width - w->viewport->virtual_width) / 2; |
9311a208f8f7
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
6626
diff
changeset
|
979 |
WP(w2, vp_d).dest_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
|
980 |
} break; |
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3882
diff
changeset
|
981 |
|
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
|
982 |
case 8: { /* inverse location button (move this view to same spot as main view) 'Copy Location' */ |
4171 | 983 |
const Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0); |
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2368
diff
changeset
|
984 |
int x = WP(w2, const vp_d).scrollpos_x; |
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2368
diff
changeset
|
985 |
int y = WP(w2, const vp_d).scrollpos_y; |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
986 |
|
6730
9311a208f8f7
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
6626
diff
changeset
|
987 |
WP(w, vp_d).dest_scrollpos_x = x + (w2->viewport->virtual_width - w->viewport->virtual_width) / 2; |
9311a208f8f7
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
6626
diff
changeset
|
988 |
WP(w, vp_d).dest_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
|
989 |
} break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
990 |
} |
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3882
diff
changeset
|
991 |
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
|
992 |
|
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
|
993 |
case WE_RESIZE: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
994 |
w->viewport->width += e->we.sizing.diff.x; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
995 |
w->viewport->height += e->we.sizing.diff.y; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
996 |
w->viewport->virtual_width += e->we.sizing.diff.x; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
997 |
w->viewport->virtual_height += e->we.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
|
998 |
break; |
4335
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
999 |
|
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
1000 |
case WE_SCROLL: { |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
1001 |
ViewPort *vp = IsPtInWindowViewport(w, _cursor.pos.x, _cursor.pos.y); |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
1002 |
|
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
1003 |
if (vp == NULL) { |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
1004 |
_cursor.fix_at = false; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
1005 |
_scrolling_viewport = false; |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
1006 |
} |
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
1007 |
|
6626
207875b9069a
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
6624
diff
changeset
|
1008 |
WP(w, vp_d).scrollpos_x += ScaleByZoom(e->we.scroll.delta.x, vp->zoom); |
207875b9069a
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
6624
diff
changeset
|
1009 |
WP(w, vp_d).scrollpos_y += ScaleByZoom(e->we.scroll.delta.y, vp->zoom); |
6730
9311a208f8f7
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
6626
diff
changeset
|
1010 |
WP(w, vp_d).dest_scrollpos_x = WP(w, vp_d).scrollpos_x; |
9311a208f8f7
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
6626
diff
changeset
|
1011 |
WP(w, vp_d).dest_scrollpos_y = WP(w, vp_d).scrollpos_y; |
4335
02934874f33d
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
1012 |
} break; |
4337
e705eef174bf
(svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents:
4335
diff
changeset
|
1013 |
|
e705eef174bf
(svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents:
4335
diff
changeset
|
1014 |
case WE_MOUSEWHEEL: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
1015 |
ZoomInOrOutToCursorWindow(e->we.wheel.wheel < 0, w); |
4337
e705eef174bf
(svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents:
4335
diff
changeset
|
1016 |
break; |
5045
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5036
diff
changeset
|
1017 |
|
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5036
diff
changeset
|
1018 |
|
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5036
diff
changeset
|
1019 |
case WE_MESSAGE: |
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5036
diff
changeset
|
1020 |
/* Only handle zoom message if intended for us (msg ZOOM_IN/ZOOM_OUT) */ |
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5036
diff
changeset
|
1021 |
if (e->we.message.wparam != w->window_number) break; |
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5036
diff
changeset
|
1022 |
HandleZoomMessage(w, w->viewport, 5, 6); |
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5036
diff
changeset
|
1023 |
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
|
1024 |
} |
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
|
1025 |
} |
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 |
static const WindowDesc _extra_view_port_desc = { |
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7313
diff
changeset
|
1028 |
WDP_AUTO, WDP_AUTO, 300, 268, 300, 268, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5584
diff
changeset
|
1029 |
WC_EXTRA_VIEW_PORT, WC_NONE, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1030 |
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
|
1031 |
_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
|
1032 |
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
|
1033 |
}; |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1034 |
|
6247 | 1035 |
void ShowExtraViewPortWindow() |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1036 |
{ |
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
|
1037 |
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
|
1038 |
int i = 0; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1039 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
1040 |
/* find next free window number for extra viewport */ |
2989 | 1041 |
while (FindWindowById(WC_EXTRA_VIEW_PORT, i) != NULL) i++; |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1042 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1043 |
w = AllocateWindowDescFront(&_extra_view_port_desc, i); |
2989 | 1044 |
if (w != NULL) { |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1045 |
int x, y; |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
1046 |
/* 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
|
1047 |
v = FindWindowById(WC_MAIN_WINDOW, 0); |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
1048 |
/* New viewport start ats (zero,zero) */ |
6624
880e29b1f25e
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
6533
diff
changeset
|
1049 |
AssignWindowViewport(w, 3, 17, 294, 214, 0 , ZOOM_LVL_VIEWPORT); |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1050 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6357
diff
changeset
|
1051 |
/* 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
|
1052 |
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
|
1053 |
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
|
1054 |
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
|
1055 |
WP(w, vp_d).scrollpos_y = y + (v->viewport->virtual_height - (214)) / 2; |
6730
9311a208f8f7
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
6626
diff
changeset
|
1056 |
WP(w, vp_d).dest_scrollpos_x = WP(w, vp_d).scrollpos_x; |
9311a208f8f7
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
6626
diff
changeset
|
1057 |
WP(w, vp_d).dest_scrollpos_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
|
1058 |
} |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1059 |
} |