author | glx |
Sun, 15 Jun 2008 22:18:10 +0000 | |
branch | noai |
changeset 10971 | aaf89f8c59b9 |
parent 10776 | 07203fc29812 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10294
diff
changeset
|
3 |
/** @file smallmap_gui.cpp GUI that shows a small map of the world with metadata like owner or height. */ |
9574 | 4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1815
diff
changeset
|
6 |
#include "openttd.h" |
3234
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3184
diff
changeset
|
7 |
#include "bridge_map.h" |
3144
426b825578f9
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
2989
diff
changeset
|
8 |
#include "clear_map.h" |
3391
c3747f4b259b
(svn r4199) - Codechange: Use industry map accessors to get industry graphics type.
peter1138
parents:
3338
diff
changeset
|
9 |
#include "industry_map.h" |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
10 |
#include "industry.h" |
3338
2c60ed0dcce3
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
11 |
#include "station_map.h" |
9599 | 12 |
#include "landscape.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
|
13 |
#include "gui.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
14 |
#include "window_gui.h" |
3144
426b825578f9
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
2989
diff
changeset
|
15 |
#include "tree_map.h" |
3180
2123f8062a2d
(svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents:
3144
diff
changeset
|
16 |
#include "tunnel_map.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
17 |
#include "viewport_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
18 |
#include "gfx_func.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
19 |
#include "player_base.h" |
0 | 20 |
#include "town.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2062
diff
changeset
|
21 |
#include "variables.h" |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9625
diff
changeset
|
22 |
#include "blitter/factory.hpp" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
23 |
#include "tunnelbridge_map.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
24 |
#include "strings_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
25 |
#include "zoom_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
26 |
#include "core/endian_func.hpp" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
27 |
#include "vehicle_base.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
28 |
#include "sound_func.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
29 |
#include "settings_type.h" |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10294
diff
changeset
|
30 |
#include "window_func.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
31 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
32 |
#include "table/strings.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
33 |
#include "table/sprites.h" |
0 | 34 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
35 |
static const Widget _smallmap_widgets[] = { |
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2635
diff
changeset
|
36 |
{ WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
37 |
{ WWT_CAPTION, RESIZE_RIGHT, 13, 11, 337, 0, 13, STR_00B0_MAP, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
38 |
{ WWT_STICKYBOX, RESIZE_LR, 13, 338, 349, 0, 13, 0x0, STR_STICKY_BUTTON}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
39 |
{ WWT_PANEL, RESIZE_RB, 13, 0, 349, 14, 157, 0x0, STR_NULL}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
40 |
{ WWT_INSET, RESIZE_RB, 13, 2, 347, 16, 155, 0x0, STR_NULL}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
41 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 284, 305, 158, 179, SPR_IMG_SHOW_COUNTOURS, STR_0191_SHOW_LAND_CONTOURS_ON_MAP}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
42 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 306, 327, 158, 179, SPR_IMG_SHOW_VEHICLES, STR_0192_SHOW_VEHICLES_ON_MAP}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
43 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 328, 349, 158, 179, SPR_IMG_INDUSTRY, STR_0193_SHOW_INDUSTRIES_ON_MAP}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
44 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 284, 307, 180, 201, SPR_IMG_SHOW_ROUTES, STR_0194_SHOW_TRANSPORT_ROUTES_ON}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
45 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 306, 327, 180, 201, SPR_IMG_PLANTTREES, STR_0195_SHOW_VEGETATION_ON_MAP}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
46 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 328, 349, 180, 201, SPR_IMG_COMPANY_GENERAL, STR_0196_SHOW_LAND_OWNERS_ON_MAP}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
47 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 262, 283, 158, 179, SPR_IMG_SMALLMAP, STR_SMALLMAP_CENTER}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
48 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 262, 283, 180, 201, SPR_IMG_TOWN, STR_0197_TOGGLE_TOWN_NAMES_ON_OFF}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
49 |
{ WWT_PANEL, RESIZE_RTB, 13, 0, 261, 158, 201, 0x0, STR_NULL}, |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
50 |
{ WWT_PANEL, RESIZE_LRTB, 13, 262, 349, 202, 202, 0x0, STR_NULL}, |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
51 |
{ WWT_PANEL, RESIZE_RTB, 13, 0, 337, 202, 213, 0x0, STR_NULL}, |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
52 |
{ WWT_TEXTBTN, RESIZE_TB, 13, 0, 99, 202, 213, STR_MESSAGES_ENABLE_ALL, STR_NULL}, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
53 |
{ WWT_TEXTBTN, RESIZE_TB, 13, 100, 201, 202, 213, STR_MESSAGES_DISABLE_ALL,STR_NULL}, |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
54 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 13, 338, 349, 202, 213, 0x0, STR_RESIZE_BUTTON}, |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
55 |
{ WIDGETS_END}, |
0 | 56 |
}; |
57 |
||
58 |
static int _smallmap_type; |
|
59 |
static bool _smallmap_show_towns = true; |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
60 |
/* number of used industries */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
61 |
static int _smallmap_industry_count; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
62 |
/* number of industries per column*/ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
63 |
static uint _industries_per_column; |
0 | 64 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
65 |
/** Macro for ordinary entry of LegendAndColor */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
66 |
#define MK(a,b) {a, b, INVALID_INDUSTRYTYPE, true, false, false} |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
67 |
/** Macro for end of list marker in arrays of LegendAndColor */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
68 |
#define MKEND() {0, STR_NULL, INVALID_INDUSTRYTYPE, true, true, false} |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
69 |
/** Macro for break marker in arrays of LegendAndColor. |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
70 |
* It will have valid data, though */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
71 |
#define MS(a,b) {a, b, INVALID_INDUSTRYTYPE, true, false, true} |
0 | 72 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
73 |
/** Structure for holding relevant data for legends in small map */ |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
74 |
struct LegendAndColour { |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
75 |
uint16 colour; ///< color of the item on the map |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
76 |
StringID legend; ///< string corresponding to the colored item |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
77 |
IndustryType type; ///< type of industry |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
78 |
bool show_on_map; ///< for filtering industries, if true is shown on map in color |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
79 |
bool end; ///< this is the end of the list |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
80 |
bool col_break; ///< perform a break and go one collumn further |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
81 |
}; |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
82 |
|
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
83 |
/** Legend text giving the colours to look for on the minimap */ |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
84 |
static const LegendAndColour _legend_land_contours[] = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
85 |
MK(0x5A, STR_00F0_100M), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
86 |
MK(0x5C, STR_00F1_200M), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
87 |
MK(0x5E, STR_00F2_300M), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
88 |
MK(0x1F, STR_00F3_400M), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
89 |
MK(0x27, STR_00F4_500M), |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
90 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
91 |
MS(0xD7, STR_00EB_ROADS), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
92 |
MK(0x0A, STR_00EC_RAILROADS), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
93 |
MK(0x98, STR_00ED_STATIONS_AIRPORTS_DOCKS), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
94 |
MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
95 |
MK(0x0F, STR_00EF_VEHICLES), |
0 | 96 |
MKEND() |
97 |
}; |
|
98 |
||
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
99 |
static const LegendAndColour _legend_vehicles[] = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
100 |
MK(0xB8, STR_00F5_TRAINS), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
101 |
MK(0xBF, STR_00F6_ROAD_VEHICLES), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
102 |
MK(0x98, STR_00F7_SHIPS), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
103 |
MK(0x0F, STR_00F8_AIRCRAFT), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
104 |
MS(0xD7, STR_00F9_TRANSPORT_ROUTES), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
105 |
MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES), |
0 | 106 |
MKEND() |
107 |
}; |
|
108 |
||
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
109 |
static const LegendAndColour _legend_routes[] = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
110 |
MK(0xD7, STR_00EB_ROADS), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
111 |
MK(0x0A, STR_00EC_RAILROADS), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
112 |
MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
113 |
MS(0x56, STR_011B_RAILROAD_STATION), |
0 | 114 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
115 |
MK(0xC2, STR_011C_TRUCK_LOADING_BAY), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
116 |
MK(0xBF, STR_011D_BUS_STATION), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
117 |
MK(0xB8, STR_011E_AIRPORT_HELIPORT), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
118 |
MK(0x98, STR_011F_DOCK), |
0 | 119 |
MKEND() |
120 |
}; |
|
121 |
||
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
122 |
static const LegendAndColour _legend_vegetation[] = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
123 |
MK(0x52, STR_0120_ROUGH_LAND), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
124 |
MK(0x54, STR_0121_GRASS_LAND), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
125 |
MK(0x37, STR_0122_BARE_LAND), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
126 |
MK(0x25, STR_0123_FIELDS), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
127 |
MK(0x57, STR_0124_TREES), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
128 |
MK(0xD0, STR_00FC_FOREST), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
129 |
MS(0x0A, STR_0125_ROCKS), |
0 | 130 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
131 |
MK(0xC2, STR_012A_DESERT), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
132 |
MK(0x98, STR_012B_SNOW), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
133 |
MK(0xD7, STR_00F9_TRANSPORT_ROUTES), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
134 |
MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES), |
0 | 135 |
MKEND() |
136 |
}; |
|
137 |
||
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
138 |
static const LegendAndColour _legend_land_owners[] = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
139 |
MK(0xCA, STR_0126_WATER), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
140 |
MK(0x54, STR_0127_NO_OWNER), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
141 |
MK(0xB4, STR_0128_TOWNS), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
142 |
MK(0x20, STR_0129_INDUSTRIES), |
0 | 143 |
MKEND() |
144 |
}; |
|
145 |
#undef MK |
|
146 |
#undef MS |
|
147 |
#undef MKEND |
|
148 |
||
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
149 |
/** Allow room for all industries, plus a terminator entry |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
150 |
* This is required in order to have the indutry slots all filled up */ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
151 |
static LegendAndColour _legend_from_industries[NUM_INDUSTRYTYPES+1]; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
152 |
/* For connecting industry type to position in industries list(small map legend) */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
153 |
static uint _industry_to_list_pos[NUM_INDUSTRYTYPES]; |
0 | 154 |
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
155 |
/** |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
156 |
* Fills an array for the industries legends. |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
157 |
*/ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
158 |
void BuildIndustriesLegend() |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
159 |
{ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
160 |
const IndustrySpec *indsp; |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
161 |
uint j = 0; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
162 |
uint free_slot, diff; |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
163 |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
164 |
/* Add each name */ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
165 |
for (IndustryType i = 0; i < NUM_INDUSTRYTYPES; i++) { |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
166 |
indsp = GetIndustrySpec(i); |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
167 |
if (indsp->enabled) { |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
168 |
_legend_from_industries[j].legend = indsp->name; |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
169 |
_legend_from_industries[j].colour = indsp->map_colour; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
170 |
_legend_from_industries[j].type = i; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
171 |
_legend_from_industries[j].show_on_map = true; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
172 |
_legend_from_industries[j].col_break = false; |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
173 |
_legend_from_industries[j].end = false; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
174 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
175 |
/* Store widget number for this industry type */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
176 |
_industry_to_list_pos[i] = j; |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
177 |
j++; |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
178 |
} |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
179 |
} |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
180 |
/* Terminate the list */ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
181 |
_legend_from_industries[j].end = true; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
182 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
183 |
/* Store number of enabled industries */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
184 |
_smallmap_industry_count = j; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
185 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
186 |
_industries_per_column = _smallmap_industry_count / 3; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
187 |
free_slot = _smallmap_industry_count % 3; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
188 |
|
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
189 |
/* recalculate column break for first two columns(i) */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
190 |
diff = 0; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
191 |
for (int i = 1; i <= 2; i++) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
192 |
if (free_slot > 0) diff = diff + 1; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
193 |
_legend_from_industries[i * _industries_per_column + diff].col_break = true; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
194 |
if (free_slot > 0) free_slot--; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
195 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
196 |
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
197 |
} |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
198 |
|
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
199 |
static const LegendAndColour * const _legend_table[] = { |
0 | 200 |
_legend_land_contours, |
201 |
_legend_vehicles, |
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
202 |
_legend_from_industries, |
0 | 203 |
_legend_routes, |
204 |
_legend_vegetation, |
|
205 |
_legend_land_owners, |
|
206 |
}; |
|
207 |
||
2984
225bffc79071
(svn r3559) - CodeChange: simplify MKCOLOR(x) macro for smallmap_gui.c by adding a TO_LE32X() macro next to TO_BE32X(). The 'X' signifies them as macros and not-inline functions so they can be used in variable declarations.
Darkvater
parents:
2981
diff
changeset
|
208 |
#define MKCOLOR(x) TO_LE32X(x) |
0 | 209 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
210 |
/** |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
211 |
* Height encodings; MAX_TILE_HEIGHT + 1 levels, from 0 to MAX_TILE_HEIGHT |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
212 |
*/ |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
213 |
static const uint32 _map_height_bits[] = { |
0 | 214 |
MKCOLOR(0x5A5A5A5A), |
215 |
MKCOLOR(0x5A5B5A5B), |
|
216 |
MKCOLOR(0x5B5B5B5B), |
|
217 |
MKCOLOR(0x5B5C5B5C), |
|
218 |
MKCOLOR(0x5C5C5C5C), |
|
219 |
MKCOLOR(0x5C5D5C5D), |
|
220 |
MKCOLOR(0x5D5D5D5D), |
|
221 |
MKCOLOR(0x5D5E5D5E), |
|
222 |
MKCOLOR(0x5E5E5E5E), |
|
223 |
MKCOLOR(0x5E5F5E5F), |
|
224 |
MKCOLOR(0x5F5F5F5F), |
|
225 |
MKCOLOR(0x5F1F5F1F), |
|
226 |
MKCOLOR(0x1F1F1F1F), |
|
227 |
MKCOLOR(0x1F271F27), |
|
228 |
MKCOLOR(0x27272727), |
|
229 |
MKCOLOR(0x27272727), |
|
230 |
}; |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
231 |
assert_compile(lengthof(_map_height_bits) == MAX_TILE_HEIGHT + 1); |
0 | 232 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
233 |
struct AndOr { |
1511
32b095e3da76
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
234 |
uint32 mor; |
32b095e3da76
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
235 |
uint32 mand; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
236 |
}; |
1511
32b095e3da76
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
237 |
|
4171 | 238 |
static inline uint32 ApplyMask(uint32 colour, const AndOr *mask) |
1511
32b095e3da76
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
239 |
{ |
32b095e3da76
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
240 |
return (colour & mask->mand) | mask->mor; |
32b095e3da76
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
241 |
} |
32b095e3da76
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
242 |
|
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
243 |
|
1511
32b095e3da76
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
244 |
static const AndOr _smallmap_contours_andor[] = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
245 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
246 |
{MKCOLOR(0x000A0A00), MKCOLOR(0xFF0000FF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
247 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
248 |
{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
249 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
250 |
{MKCOLOR(0x98989898), MKCOLOR(0x00000000)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
251 |
{MKCOLOR(0xCACACACA), MKCOLOR(0x00000000)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
252 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
253 |
{MKCOLOR(0xB5B5B5B5), MKCOLOR(0x00000000)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
254 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
255 |
{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
256 |
{MKCOLOR(0x000A0A00), MKCOLOR(0xFF0000FF)}, |
0 | 257 |
}; |
258 |
||
1511
32b095e3da76
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
259 |
static const AndOr _smallmap_vehicles_andor[] = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
260 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
261 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
262 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
263 |
{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
264 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
265 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
266 |
{MKCOLOR(0xCACACACA), MKCOLOR(0x00000000)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
267 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
268 |
{MKCOLOR(0xB5B5B5B5), MKCOLOR(0x00000000)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
269 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
270 |
{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
271 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
0 | 272 |
}; |
273 |
||
1511
32b095e3da76
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
274 |
static const AndOr _smallmap_vegetation_andor[] = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
275 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
276 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
277 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
278 |
{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
279 |
{MKCOLOR(0x00575700), MKCOLOR(0xFF0000FF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
280 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
281 |
{MKCOLOR(0xCACACACA), MKCOLOR(0x00000000)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
282 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
283 |
{MKCOLOR(0xB5B5B5B5), MKCOLOR(0x00000000)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
284 |
{MKCOLOR(0x00000000), MKCOLOR(0xFFFFFFFF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
285 |
{MKCOLOR(0x00B5B500), MKCOLOR(0xFF0000FF)}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4339
diff
changeset
|
286 |
{MKCOLOR(0x00D7D700), MKCOLOR(0xFF0000FF)}, |
0 | 287 |
}; |
288 |
||
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
289 |
typedef uint32 GetSmallMapPixels(TileIndex tile); // typedef callthrough function |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
290 |
|
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
291 |
/** |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
292 |
* Draws one column of the small map in a certain mode onto the screen buffer. This |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
293 |
* function looks exactly the same for all types |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
294 |
* |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
295 |
* @param dst Pointer to a part of the screen buffer to write to. |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
296 |
* @param xc The X coordinate of the first tile in the column. |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
297 |
* @param yc The Y coordinate of the first tile in the column |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
298 |
* @param pitch Number of pixels to advance in the screen buffer each time a pixel is written. |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
299 |
* @param reps Number of lines to draw |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
300 |
* @param mask ? |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
301 |
* @param proc Pointer to the colour function |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
302 |
* @see GetSmallMapPixels(TileIndex) |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
303 |
*/ |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9625
diff
changeset
|
304 |
static void DrawSmallMapStuff(void *dst, uint xc, uint yc, int pitch, int reps, uint32 mask, GetSmallMapPixels *proc) |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
305 |
{ |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9625
diff
changeset
|
306 |
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
307 |
void *dst_ptr_abs_end = blitter->MoveTo(_screen.dst_ptr, 0, _screen.height); |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
308 |
void *dst_ptr_end = blitter->MoveTo(dst_ptr_abs_end, -4, 0); |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
309 |
|
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
310 |
do { |
9574 | 311 |
/* check if the tile (xc,yc) is within the map range */ |
1919
0ad642b26ff2
(svn r2425) - Fix (regression): wrong sprite for level-land cursor (thx Tron)
Darkvater
parents:
1918
diff
changeset
|
312 |
if (xc < MapMaxX() && yc < MapMaxY()) { |
9574 | 313 |
/* check if the dst pointer points to a pixel inside the screen buffer */ |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
314 |
if (dst < _screen.dst_ptr) continue; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
315 |
if (dst >= dst_ptr_abs_end) continue; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
316 |
|
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
317 |
uint32 val = proc(TileXY(xc, yc)) & mask; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
318 |
uint8 *val8 = (uint8 *)&val; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
319 |
|
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
320 |
if (dst <= dst_ptr_end) { |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
321 |
blitter->SetPixelIfEmpty(dst, 0, 0, val8[0]); |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
322 |
blitter->SetPixelIfEmpty(dst, 1, 0, val8[1]); |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
323 |
blitter->SetPixelIfEmpty(dst, 2, 0, val8[2]); |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
324 |
blitter->SetPixelIfEmpty(dst, 3, 0, val8[3]); |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
325 |
} else { |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
326 |
/* It happens that there are only 1, 2 or 3 pixels left to fill, so in that special case, write till the end of the video-buffer */ |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
327 |
int i = 0; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
328 |
do { |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
329 |
blitter->SetPixelIfEmpty(dst, 0, 0, val8[i]); |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
330 |
} while (i++, dst = blitter->MoveTo(dst, 1, 0), dst < dst_ptr_abs_end); |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
331 |
} |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
332 |
} |
9574 | 333 |
/* switch to next tile in the column */ |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9625
diff
changeset
|
334 |
} while (xc++, yc++, dst = blitter->MoveTo(dst, pitch, 0), --reps != 0); |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
335 |
} |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
336 |
|
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
337 |
|
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
338 |
static inline TileType GetEffectiveTileType(TileIndex tile) |
0 | 339 |
{ |
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
340 |
TileType t = GetTileType(tile); |
0 | 341 |
|
342 |
if (t == MP_TUNNELBRIDGE) { |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
343 |
TransportType tt = GetTunnelBridgeTransportType(tile); |
3180
2123f8062a2d
(svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents:
3144
diff
changeset
|
344 |
|
2123f8062a2d
(svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents:
3144
diff
changeset
|
345 |
switch (tt) { |
2123f8062a2d
(svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents:
3144
diff
changeset
|
346 |
case TRANSPORT_RAIL: t = MP_RAILWAY; break; |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
347 |
case TRANSPORT_ROAD: t = MP_ROAD; break; |
3180
2123f8062a2d
(svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents:
3144
diff
changeset
|
348 |
default: t = MP_WATER; break; |
0 | 349 |
} |
350 |
} |
|
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
351 |
return t; |
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
352 |
} |
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
353 |
|
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
354 |
/** |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
355 |
* Return the color a tile would be displayed with in the small map in mode "Contour". |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
356 |
* @param tile The tile of which we would like to get the color. |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
357 |
* @return The color of tile in the small map in mode "Contour" |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
358 |
*/ |
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
359 |
static inline uint32 GetSmallMapContoursPixels(TileIndex tile) |
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
360 |
{ |
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
361 |
TileType t = GetEffectiveTileType(tile); |
0 | 362 |
|
1511
32b095e3da76
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
363 |
return |
32b095e3da76
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
364 |
ApplyMask(_map_height_bits[TileHeight(tile)], &_smallmap_contours_andor[t]); |
0 | 365 |
} |
366 |
||
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
367 |
/** |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
368 |
* Return the color a tile would be displayed with in the small map in mode "Vehicles". |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
369 |
* |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
370 |
* @param tile The tile of which we would like to get the color. |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
371 |
* @return The color of tile in the small map in mode "Vehicles" |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
372 |
*/ |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
373 |
static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile) |
0 | 374 |
{ |
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
375 |
TileType t = GetEffectiveTileType(tile); |
0 | 376 |
|
1511
32b095e3da76
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
377 |
return ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]); |
0 | 378 |
} |
379 |
||
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
380 |
/** |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
381 |
* Return the color a tile would be displayed with in the small map in mode "Industries". |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
382 |
* |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
383 |
* @param tile The tile of which we would like to get the color. |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
384 |
* @return The color of tile in the small map in mode "Industries" |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
385 |
*/ |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
386 |
static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile) |
0 | 387 |
{ |
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
388 |
TileType t = GetEffectiveTileType(tile); |
0 | 389 |
|
390 |
if (t == MP_INDUSTRY) { |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
391 |
/* If industry is allowed to be seen, use its color on the map */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
392 |
if (_legend_from_industries[_industry_to_list_pos[GetIndustryByTile(tile)->type]].show_on_map) { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
393 |
return GetIndustrySpec(GetIndustryByTile(tile)->type)->map_colour * 0x01010101; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
394 |
} else { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
395 |
/* otherwise, return the color of the clear tiles, which will make it disappear */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
396 |
return ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[MP_CLEAR]); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
397 |
} |
0 | 398 |
} |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
399 |
|
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
400 |
return ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]); |
0 | 401 |
} |
402 |
||
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
403 |
/** |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
404 |
* Return the color a tile would be displayed with in the small map in mode "Routes". |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
405 |
* |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
406 |
* @param tile The tile of which we would like to get the color. |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
407 |
* @return The color of tile in the small map in mode "Routes" |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
408 |
*/ |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
409 |
static inline uint32 GetSmallMapRoutesPixels(TileIndex tile) |
0 | 410 |
{ |
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
411 |
TileType t = GetEffectiveTileType(tile); |
0 | 412 |
uint32 bits; |
413 |
||
414 |
if (t == MP_STATION) { |
|
3338
2c60ed0dcce3
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
415 |
switch (GetStationType(tile)) { |
2c60ed0dcce3
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
416 |
case STATION_RAIL: bits = MKCOLOR(0x56565656); break; |
2c60ed0dcce3
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
417 |
case STATION_AIRPORT: bits = MKCOLOR(0xB8B8B8B8); break; |
2c60ed0dcce3
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
418 |
case STATION_TRUCK: bits = MKCOLOR(0xC2C2C2C2); break; |
2c60ed0dcce3
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
419 |
case STATION_BUS: bits = MKCOLOR(0xBFBFBFBF); break; |
2c60ed0dcce3
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
420 |
case STATION_DOCK: bits = MKCOLOR(0x98989898); break; |
2c60ed0dcce3
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
421 |
default: bits = MKCOLOR(0xFFFFFFFF); break; |
2c60ed0dcce3
(svn r4120) Use the new station functions where appropriate
tron
parents:
3326
diff
changeset
|
422 |
} |
0 | 423 |
} else { |
9574 | 424 |
/* ground color */ |
1511
32b095e3da76
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
425 |
bits = ApplyMask(MKCOLOR(0x54545454), &_smallmap_contours_andor[t]); |
0 | 426 |
} |
427 |
return bits; |
|
428 |
} |
|
429 |
||
430 |
||
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
431 |
static const uint32 _vegetation_clear_bits[] = { |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
432 |
MKCOLOR(0x54545454), ///< full grass |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
433 |
MKCOLOR(0x52525252), ///< rough land |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
434 |
MKCOLOR(0x0A0A0A0A), ///< rocks |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
435 |
MKCOLOR(0x25252525), ///< fields |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
436 |
MKCOLOR(0x98989898), ///< snow |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
437 |
MKCOLOR(0xC2C2C2C2), ///< desert |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
438 |
MKCOLOR(0x54545454), ///< unused |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
439 |
MKCOLOR(0x54545454), ///< unused |
0 | 440 |
}; |
441 |
||
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
442 |
static inline uint32 GetSmallMapVegetationPixels(TileIndex tile) |
0 | 443 |
{ |
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
444 |
TileType t = GetEffectiveTileType(tile); |
0 | 445 |
uint32 bits; |
446 |
||
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
447 |
switch (t) { |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
448 |
case MP_CLEAR: |
3447 | 449 |
if (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) < 3) { |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
450 |
bits = MKCOLOR(0x37373737); |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
451 |
} else { |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
452 |
bits = _vegetation_clear_bits[GetClearGround(tile)]; |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
453 |
} |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
454 |
break; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
455 |
|
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
456 |
case MP_INDUSTRY: |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
457 |
bits = GetIndustrySpec(GetIndustryByTile(tile)->type)->check_proc == CHECK_FOREST ? MKCOLOR(0xD0D0D0D0) : MKCOLOR(0xB5B5B5B5); |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
458 |
break; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
459 |
|
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
460 |
case MP_TREES: |
3441
d1cef7047cd4
(svn r4271) s/\<TR_/TREE_/ resp. s/\<TR_/TREE_GROUND/
tron
parents:
3421
diff
changeset
|
461 |
if (GetTreeGround(tile) == TREE_GROUND_SNOW_DESERT) { |
10776 | 462 |
bits = (_settings_game.game_creation.landscape == LT_ARCTIC) ? MKCOLOR(0x98575798) : MKCOLOR(0xC25757C2); |
2951 | 463 |
} else { |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
464 |
bits = MKCOLOR(0x54575754); |
2951 | 465 |
} |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
466 |
break; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
467 |
|
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
468 |
default: |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
469 |
bits = ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]); |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
470 |
break; |
0 | 471 |
} |
472 |
||
473 |
return bits; |
|
474 |
} |
|
475 |
||
476 |
||
4846
a6c472d934c0
(svn r6772) -Codechange: Do not abuse OWNER_SPECTATOR as the "owner" of the industry for
Darkvater
parents:
4727
diff
changeset
|
477 |
static uint32 _owner_colors[OWNER_END + 1]; |
0 | 478 |
|
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
479 |
/** |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
480 |
* Return the color a tile would be displayed with in the small map in mode "Owner". |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
481 |
* |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
482 |
* @param tile The tile of which we would like to get the color. |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
483 |
* @return The color of tile in the small map in mode "Owner" |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
484 |
*/ |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
485 |
static inline uint32 GetSmallMapOwnerPixels(TileIndex tile) |
0 | 486 |
{ |
2368
d5a31a409219
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
487 |
Owner o; |
0 | 488 |
|
2368
d5a31a409219
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
489 |
switch (GetTileType(tile)) { |
4846
a6c472d934c0
(svn r6772) -Codechange: Do not abuse OWNER_SPECTATOR as the "owner" of the industry for
Darkvater
parents:
4727
diff
changeset
|
490 |
case MP_INDUSTRY: o = OWNER_END; break; |
2368
d5a31a409219
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
491 |
case MP_HOUSE: o = OWNER_TOWN; break; |
d5a31a409219
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
492 |
default: o = GetTileOwner(tile); break; |
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
493 |
/* FIXME: For MP_ROAD there are multiple owners. |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
494 |
* GetTileOwner returns the rail owner (level crossing) resp. the owner of ROADTYPE_ROAD (normal road), |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
495 |
* even if there are no ROADTYPE_ROAD bits on the tile. |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
10645
diff
changeset
|
496 |
*/ |
0 | 497 |
} |
498 |
||
2368
d5a31a409219
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
499 |
return _owner_colors[o]; |
0 | 500 |
} |
501 |
||
502 |
||
503 |
static const uint32 _smallmap_mask_left[3] = { |
|
504 |
MKCOLOR(0xFF000000), |
|
505 |
MKCOLOR(0xFFFF0000), |
|
506 |
MKCOLOR(0xFFFFFF00), |
|
507 |
}; |
|
508 |
||
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
509 |
static const uint32 _smallmap_mask_right[] = { |
0 | 510 |
MKCOLOR(0x000000FF), |
511 |
MKCOLOR(0x0000FFFF), |
|
512 |
MKCOLOR(0x00FFFFFF), |
|
513 |
}; |
|
514 |
||
515 |
/* each tile has 4 x pixels and 1 y pixel */ |
|
516 |
||
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
517 |
static GetSmallMapPixels *_smallmap_draw_procs[] = { |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
518 |
GetSmallMapContoursPixels, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
519 |
GetSmallMapVehiclesPixels, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
520 |
GetSmallMapIndustriesPixels, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
521 |
GetSmallMapRoutesPixels, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
522 |
GetSmallMapVegetationPixels, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
523 |
GetSmallMapOwnerPixels, |
0 | 524 |
}; |
525 |
||
526 |
static const byte _vehicle_type_colors[6] = { |
|
527 |
184, 191, 152, 15, 215, 184 |
|
528 |
}; |
|
529 |
||
530 |
||
531 |
static void DrawVertMapIndicator(int x, int y, int x2, int y2) |
|
532 |
{ |
|
2951 | 533 |
GfxFillRect(x, y, x2, y + 3, 69); |
534 |
GfxFillRect(x, y2 - 3, x2, y2, 69); |
|
0 | 535 |
} |
536 |
||
537 |
static void DrawHorizMapIndicator(int x, int y, int x2, int y2) |
|
538 |
{ |
|
2951 | 539 |
GfxFillRect(x, y, x + 3, y2, 69); |
540 |
GfxFillRect(x2 - 3, y, x2, y2, 69); |
|
0 | 541 |
} |
542 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
543 |
enum SmallMapWindowWidgets { |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
544 |
SM_WIDGET_MAP = 4, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
545 |
SM_WIDGET_CONTOUR, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
546 |
SM_WIDGET_VEHICLES, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
547 |
SM_WIDGET_INDUSTRIES, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
548 |
SM_WIDGET_ROUTES, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
549 |
SM_WIDGET_VEGETATION, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
550 |
SM_WIDGET_OWNERS, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
551 |
SM_WIDGET_CENTERMAP, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
552 |
SM_WIDGET_TOGGLETOWNNAME, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
553 |
SM_WIDGET_LEGEND, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
554 |
SM_WIDGET_BUTTONSPANEL, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
555 |
SM_WIDGET_BOTTOMPANEL, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
556 |
SM_WIDGET_ENABLEINDUSTRIES, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
557 |
SM_WIDGET_DISABLEINDUSTRIES, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
558 |
SM_WIDGET_RESIZEBOX, |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
559 |
}; |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9701
diff
changeset
|
560 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
561 |
class SmallMapWindow : public Window |
0 | 562 |
{ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
563 |
enum SmallMapType { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
564 |
SMT_CONTOUR, |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
565 |
SMT_VEHICLES, |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
566 |
SMT_INDUSTRY, |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
567 |
SMT_OWNER = 5, |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
568 |
}; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
569 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
570 |
enum { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
571 |
BASE_NB_PER_COLUMN = 6, |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
572 |
}; |
0 | 573 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
574 |
int32 scroll_x; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
575 |
int32 scroll_y; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
576 |
int32 subscroll; |
10776 | 577 |
uint8 refresh; |
0 | 578 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
579 |
public: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
580 |
/** |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
581 |
* Draws the small map. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
582 |
* |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
583 |
* Basically, the small map is draw column of pixels by column of pixels. The pixels |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
584 |
* are drawn directly into the screen buffer. The final map is drawn in multiple passes. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
585 |
* The passes are: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
586 |
* <ol><li>The colors of tiles in the different modes.</li> |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
587 |
* <li>Town names (optional)</li></ol> |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
588 |
* |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
589 |
* @param dpi pointer to pixel to write onto |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
590 |
* @param w pointer to Window struct |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
591 |
* @param type type of map requested (vegetation, owners, routes, etc) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
592 |
* @param show_towns true if the town names should be displayed, false if not. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
593 |
*/ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
594 |
void DrawSmallMap(DrawPixelInfo *dpi, int type, bool show_towns) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
595 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
596 |
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
597 |
DrawPixelInfo *old_dpi; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
598 |
int dx,dy, x, y, x2, y2; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
599 |
void *ptr; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
600 |
int tile_x; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
601 |
int tile_y; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
602 |
ViewPort *vp; |
0 | 603 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
604 |
old_dpi = _cur_dpi; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
605 |
_cur_dpi = dpi; |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
606 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
607 |
/* clear it */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
608 |
GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1, 0); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
609 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
610 |
/* setup owner table */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
611 |
if (type == SMT_OWNER) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
612 |
const Player *p; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
613 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
614 |
/* fill with some special colors */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
615 |
_owner_colors[OWNER_TOWN] = MKCOLOR(0xB4B4B4B4); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
616 |
_owner_colors[OWNER_NONE] = MKCOLOR(0x54545454); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
617 |
_owner_colors[OWNER_WATER] = MKCOLOR(0xCACACACA); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
618 |
_owner_colors[OWNER_END] = MKCOLOR(0x20202020); /* industry */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
619 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
620 |
/* now fill with the player colors */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
621 |
FOR_ALL_PLAYERS(p) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
622 |
if (p->is_active) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
623 |
_owner_colors[p->index] = |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
624 |
_colour_gradient[p->player_color][5] * 0x01010101; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
625 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
626 |
} |
0 | 627 |
} |
628 |
||
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
629 |
tile_x = this->scroll_x / TILE_SIZE; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
630 |
tile_y = this->scroll_y / TILE_SIZE; |
0 | 631 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
632 |
dx = dpi->left + this->subscroll; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
633 |
tile_x -= dx / 4; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
634 |
tile_y += dx / 4; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
635 |
dx &= 3; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
636 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
637 |
dy = dpi->top; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
638 |
tile_x += dy / 2; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
639 |
tile_y += dy / 2; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
640 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
641 |
if (dy & 1) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
642 |
tile_x++; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
643 |
dx += 2; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
644 |
if (dx > 3) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
645 |
dx -= 4; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
646 |
tile_x--; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
647 |
tile_y++; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
648 |
} |
0 | 649 |
} |
650 |
||
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
651 |
ptr = blitter->MoveTo(dpi->dst_ptr, -dx - 4, 0); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
652 |
x = - dx - 4; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
653 |
y = 0; |
0 | 654 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
655 |
for (;;) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
656 |
uint32 mask = 0xFFFFFFFF; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
657 |
int reps; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
658 |
int t; |
0 | 659 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
660 |
/* distance from left edge */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
661 |
if (x < 0) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
662 |
if (x < -3) goto skip_column; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
663 |
/* mask to use at the left edge */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
664 |
mask = _smallmap_mask_left[x + 3]; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
665 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
666 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
667 |
/* distance from right edge */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
668 |
t = dpi->width - x; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
669 |
if (t < 4) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
670 |
if (t <= 0) break; /* exit loop */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
671 |
/* mask to use at the right edge */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
672 |
mask &= _smallmap_mask_right[t - 1]; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
673 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
674 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
675 |
/* number of lines */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
676 |
reps = (dpi->height - y + 1) / 2; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
677 |
if (reps > 0) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
678 |
DrawSmallMapStuff(ptr, tile_x, tile_y, dpi->pitch * 2, reps, mask, _smallmap_draw_procs[type]); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
679 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
680 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
681 |
skip_column: |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
682 |
if (y == 0) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
683 |
tile_y++; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
684 |
y++; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
685 |
ptr = blitter->MoveTo(ptr, 0, 1); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
686 |
} else { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
687 |
tile_x--; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
688 |
y--; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
689 |
ptr = blitter->MoveTo(ptr, 0, -1); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
690 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
691 |
ptr = blitter->MoveTo(ptr, 2, 0); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
692 |
x += 2; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
693 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
694 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
695 |
/* draw vehicles? */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
696 |
if (type == SMT_CONTOUR || type == SMT_VEHICLES) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
697 |
Vehicle *v; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
698 |
bool skip; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
699 |
byte color; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
700 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
701 |
FOR_ALL_VEHICLES(v) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
702 |
if (v->type != VEH_EFFECT && |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
703 |
(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
704 |
/* Remap into flat coordinates. */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
705 |
Point pt = RemapCoords( |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
706 |
v->x_pos / TILE_SIZE - this->scroll_x / TILE_SIZE, // divide each one separately because (a-b)/c != a/c-b/c in integer world |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
707 |
v->y_pos / TILE_SIZE - this->scroll_y / TILE_SIZE, // dtto |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
708 |
0); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
709 |
x = pt.x; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
710 |
y = pt.y; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
711 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
712 |
/* Check if y is out of bounds? */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
713 |
y -= dpi->top; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
714 |
if (!IsInsideMM(y, 0, dpi->height)) continue; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
715 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
716 |
/* Default is to draw both pixels. */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
717 |
skip = false; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
718 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
719 |
/* Offset X coordinate */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
720 |
x -= this->subscroll + 3 + dpi->left; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
721 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
722 |
if (x < 0) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
723 |
/* if x+1 is 0, that means we're on the very left edge, |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
724 |
* and should thus only draw a single pixel */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
725 |
if (++x != 0) continue; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
726 |
skip = true; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
727 |
} else if (x >= dpi->width - 1) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
728 |
/* Check if we're at the very right edge, and if so draw only a single pixel */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
729 |
if (x != dpi->width - 1) continue; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
730 |
skip = true; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
731 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
732 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
733 |
/* Calculate pointer to pixel and the color */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
734 |
color = (type == SMT_VEHICLES) ? _vehicle_type_colors[v->type] : 0xF; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
735 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
736 |
/* And draw either one or two pixels depending on clipping */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
737 |
blitter->SetPixel(dpi->dst_ptr, x, y, color); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
738 |
if (!skip) blitter->SetPixel(dpi->dst_ptr, x + 1, y, color); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
739 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
740 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
741 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
742 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
743 |
if (show_towns) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
744 |
const Town *t; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
745 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
746 |
FOR_ALL_TOWNS(t) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
747 |
/* Remap the town coordinate */ |
0 | 748 |
Point pt = RemapCoords( |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
749 |
(int)(TileX(t->xy) * TILE_SIZE - this->scroll_x) / TILE_SIZE, |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
750 |
(int)(TileY(t->xy) * TILE_SIZE - this->scroll_y) / TILE_SIZE, |
0 | 751 |
0); |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
752 |
x = pt.x - this->subscroll + 3 - (t->sign.width_2 >> 1); |
0 | 753 |
y = pt.y; |
754 |
||
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
755 |
/* Check if the town sign is within bounds */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
756 |
if (x + t->sign.width_2 > dpi->left && |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
757 |
x < dpi->left + dpi->width && |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
758 |
y + 6 > dpi->top && |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
759 |
y < dpi->top + dpi->height) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
760 |
/* And draw it. */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
761 |
SetDParam(0, t->index); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
762 |
DrawString(x, y, STR_2056, TC_WHITE); |
0 | 763 |
} |
764 |
} |
|
765 |
} |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
766 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
767 |
/* Draw map indicators */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
768 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
769 |
Point pt; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
770 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
771 |
/* Find main viewport. */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
772 |
vp = FindWindowById(WC_MAIN_WINDOW,0)->viewport; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
773 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
774 |
pt = RemapCoords(this->scroll_x, this->scroll_y, 0); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
775 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
776 |
x = vp->virtual_left - pt.x; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
777 |
y = vp->virtual_top - pt.y; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
778 |
x2 = (x + vp->virtual_width) / TILE_SIZE; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
779 |
y2 = (y + vp->virtual_height) / TILE_SIZE; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
780 |
x /= TILE_SIZE; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
781 |
y /= TILE_SIZE; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
782 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
783 |
x -= this->subscroll; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
784 |
x2 -= this->subscroll; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
785 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
786 |
DrawVertMapIndicator(x, y, x, y2); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
787 |
DrawVertMapIndicator(x2, y, x2, y2); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
788 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
789 |
DrawHorizMapIndicator(x, y, x2, y); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
790 |
DrawHorizMapIndicator(x, y2, x2, y2); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
791 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
792 |
_cur_dpi = old_dpi; |
0 | 793 |
} |
794 |
||
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
795 |
void SmallMapCenterOnCurrentPos() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
796 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
797 |
int x, y; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
798 |
ViewPort *vp; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
799 |
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport; |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
800 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
801 |
x = ((vp->virtual_width - (this->widget[SM_WIDGET_MAP].right - this->widget[SM_WIDGET_MAP].left) * TILE_SIZE) / 2 + vp->virtual_left) / 4; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
802 |
y = ((vp->virtual_height - (this->widget[SM_WIDGET_MAP].bottom - this->widget[SM_WIDGET_MAP].top ) * TILE_SIZE) / 2 + vp->virtual_top ) / 2 - TILE_SIZE * 2; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
803 |
this->scroll_x = (y - x) & ~0xF; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
804 |
this->scroll_y = (x + y) & ~0xF; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
805 |
this->SetDirty(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
806 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
807 |
|
10645 | 808 |
SmallMapWindow(const WindowDesc *desc, int window_number) : Window(desc, window_number) |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
809 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
810 |
/* Resize the window to fit industries list */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
811 |
if (_industries_per_column > BASE_NB_PER_COLUMN) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
812 |
uint diff = ((_industries_per_column - BASE_NB_PER_COLUMN) * BASE_NB_PER_COLUMN) + 1; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
813 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
814 |
this->height = this->height + diff; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
815 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
816 |
Widget *wi = &this->widget[SM_WIDGET_LEGEND]; // label panel |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
817 |
wi->bottom = wi->bottom + diff; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
818 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
819 |
wi = &this->widget[SM_WIDGET_BUTTONSPANEL]; // filler panel under smallmap buttons |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
820 |
wi->bottom = wi->bottom + diff - 1; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
821 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
822 |
/* Change widget position |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
823 |
* - footer panel |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
824 |
* - enable all industry |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
825 |
* - disable all industry |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
826 |
* - resize window button |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
827 |
*/ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
828 |
for (uint i = SM_WIDGET_BOTTOMPANEL; i <= SM_WIDGET_RESIZEBOX; i++) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
829 |
wi = &this->widget[i]; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
830 |
wi->top = wi->top + diff; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
831 |
wi->bottom = wi->bottom + diff; |
0 | 832 |
} |
833 |
} |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
834 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
835 |
this->LowerWidget(_smallmap_type + SMT_OWNER); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
836 |
this->SetWidgetLoweredState(SM_WIDGET_TOGGLETOWNNAME, _smallmap_show_towns); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
837 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
838 |
this->SmallMapCenterOnCurrentPos(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
839 |
this->FindWindowPlacementAndResize(desc); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
840 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
841 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
842 |
virtual void OnPaint() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
843 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
844 |
const LegendAndColour *tbl; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
845 |
int x, y, y_org; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
846 |
uint diff; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
847 |
DrawPixelInfo new_dpi; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
848 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
849 |
/* Hide Enable all/Disable all buttons if is not industry type small map*/ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
850 |
this->SetWidgetHiddenState(SM_WIDGET_ENABLEINDUSTRIES, _smallmap_type != SMT_INDUSTRY); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
851 |
this->SetWidgetHiddenState(SM_WIDGET_DISABLEINDUSTRIES, _smallmap_type != SMT_INDUSTRY); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
852 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
853 |
/* draw the window */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
854 |
SetDParam(0, STR_00E5_CONTOURS + _smallmap_type); |
10645 | 855 |
this->DrawWidgets(); |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
856 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
857 |
tbl = _legend_table[_smallmap_type]; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
858 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
859 |
/* difference in window size */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
860 |
diff = (_industries_per_column > BASE_NB_PER_COLUMN) ? ((_industries_per_column - BASE_NB_PER_COLUMN) * BASE_NB_PER_COLUMN) + 1 : 0; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
861 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
862 |
x = 4; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
863 |
y_org = this->height - 44 - 11 - diff; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
864 |
y = y_org; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
865 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
866 |
for (;;) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
867 |
if (_smallmap_type == SMT_INDUSTRY) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
868 |
/* Industry name must be formated, since it's not in tiny font in the specs. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
869 |
* So, draw with a parameter and use the STR_SMALLMAP_INDUSTRY string, which is tiny font.*/ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
870 |
SetDParam(0, tbl->legend); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
871 |
assert(tbl->type < NUM_INDUSTRYTYPES); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
872 |
SetDParam(1, _industry_counts[tbl->type]); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
873 |
if (!tbl->show_on_map) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
874 |
/* Simply draw the string, not the black border of the legend color. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
875 |
* This will enforce the idea of the disabled item */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
876 |
DrawString(x + 11, y, STR_SMALLMAP_INDUSTRY, TC_GREY); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
877 |
} else { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
878 |
DrawString(x + 11, y, STR_SMALLMAP_INDUSTRY, TC_BLACK); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
879 |
GfxFillRect(x, y + 1, x + 8, y + 5, 0); // outer border of the legend color |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
880 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
881 |
} else { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
882 |
/* Anything that is not an industry is using normal process */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
883 |
GfxFillRect(x, y + 1, x + 8, y + 5, 0); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
884 |
DrawString(x + 11, y, tbl->legend, TC_FROMSTRING); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
885 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
886 |
GfxFillRect(x + 1, y + 2, x + 7, y + 4, tbl->colour); // legend color |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
887 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
888 |
tbl += 1; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
889 |
y += 6; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
890 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
891 |
if (tbl->end) { // end of the list |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
892 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
893 |
} else if (tbl->col_break) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
894 |
/* break asked, continue at top, 123 pixels (one "row") to the right */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
895 |
x += 123; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
896 |
y = y_org; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
897 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
898 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
899 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
900 |
if (!FillDrawPixelInfo(&new_dpi, 3, 17, this->width - 28 + 22, this->height - 64 - 11 - diff)) return; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
901 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
902 |
this->DrawSmallMap(&new_dpi, _smallmap_type, _smallmap_show_towns); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
903 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
904 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
905 |
virtual void OnClick(Point pt, int widget) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
906 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
907 |
switch (widget) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
908 |
case SM_WIDGET_MAP: { // Map window |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
909 |
/* |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
910 |
* XXX: scrolling with the left mouse button is done by subsequently |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
911 |
* clicking with the left mouse button; clicking once centers the |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
912 |
* large map at the selected point. So by unclicking the left mouse |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
913 |
* button here, it gets reclicked during the next inputloop, which |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
914 |
* would make it look like the mouse is being dragged, while it is |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
915 |
* actually being (virtually) clicked every inputloop. |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
916 |
*/ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
917 |
_left_button_clicked = false; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
918 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
919 |
Point pt = RemapCoords(this->scroll_x, this->scroll_y, 0); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
920 |
Window *w = FindWindowById(WC_MAIN_WINDOW, 0); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
921 |
w->viewport->dest_scrollpos_x = pt.x + ((_cursor.pos.x - this->left + 2) << 4) - (w->viewport->virtual_width >> 1); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
922 |
w->viewport->dest_scrollpos_y = pt.y + ((_cursor.pos.y - this->top - 16) << 4) - (w->viewport->virtual_height >> 1); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
923 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
924 |
this->SetDirty(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
925 |
} break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
926 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
927 |
case SM_WIDGET_CONTOUR: // Show land contours |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
928 |
case SM_WIDGET_VEHICLES: // Show vehicles |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
929 |
case SM_WIDGET_INDUSTRIES: // Show industries |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
930 |
case SM_WIDGET_ROUTES: // Show transport routes |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
931 |
case SM_WIDGET_VEGETATION: // Show vegetation |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
932 |
case SM_WIDGET_OWNERS: // Show land owners |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
933 |
this->RaiseWidget(_smallmap_type + SM_WIDGET_CONTOUR); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
934 |
_smallmap_type = widget - SM_WIDGET_CONTOUR; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
935 |
this->LowerWidget(_smallmap_type + SM_WIDGET_CONTOUR); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
936 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
937 |
this->SetDirty(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
938 |
SndPlayFx(SND_15_BEEP); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
939 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
940 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
941 |
case SM_WIDGET_CENTERMAP: // Center the smallmap again |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
942 |
this->SmallMapCenterOnCurrentPos(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
943 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
944 |
this->SetDirty(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
945 |
SndPlayFx(SND_15_BEEP); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
946 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
947 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
948 |
case SM_WIDGET_TOGGLETOWNNAME: // Toggle town names |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
949 |
this->ToggleWidgetLoweredState(SM_WIDGET_TOGGLETOWNNAME); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
950 |
_smallmap_show_towns = this->IsWidgetLowered(SM_WIDGET_TOGGLETOWNNAME); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
951 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
952 |
this->SetDirty(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
953 |
SndPlayFx(SND_15_BEEP); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
954 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
955 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
956 |
case SM_WIDGET_LEGEND: // Legend |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
957 |
/* if industry type small map*/ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
958 |
if (_smallmap_type == SMT_INDUSTRY) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
959 |
/* if click on industries label, find right industry type and enable/disable it */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
960 |
Widget *wi = &this->widget[SM_WIDGET_LEGEND]; // label panel |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
961 |
uint column = (pt.x - 4) / 123; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
962 |
uint line = (pt.y - wi->top - 2) / 6; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
963 |
uint free = _smallmap_industry_count % 3; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
964 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
965 |
if (column <= 3) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
966 |
/* check if click is on industry label*/ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
967 |
uint industry_pos = 0; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
968 |
for (uint i = 0; i <= column; i++) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
969 |
uint diff = (free > 0) ? 1 : 0; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
970 |
uint max_column_lines = _industries_per_column + diff; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
971 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
972 |
if (i < column) industry_pos = industry_pos + _industries_per_column + diff; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
973 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
974 |
if (i == column && line <= max_column_lines - 1) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
975 |
industry_pos = industry_pos + line; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
976 |
_legend_from_industries[industry_pos].show_on_map = !_legend_from_industries[industry_pos].show_on_map; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
977 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
978 |
if( free > 0) free--; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
979 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
980 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
981 |
/* Raise the two buttons "all", as we have done a specific choice */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
982 |
this->RaiseWidget(SM_WIDGET_ENABLEINDUSTRIES); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
983 |
this->RaiseWidget(SM_WIDGET_DISABLEINDUSTRIES); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
984 |
this->SetDirty(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
985 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
986 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
987 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
988 |
case SM_WIDGET_ENABLEINDUSTRIES: // Enable all industries |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
989 |
for (int i = 0; i != _smallmap_industry_count; i++) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
990 |
_legend_from_industries[i].show_on_map = true; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
991 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
992 |
/* toggle appeareance indicating the choice */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
993 |
this->LowerWidget(SM_WIDGET_ENABLEINDUSTRIES); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
994 |
this->RaiseWidget(SM_WIDGET_DISABLEINDUSTRIES); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
995 |
this->SetDirty(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
996 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
997 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
998 |
case SM_WIDGET_DISABLEINDUSTRIES: // disable all industries |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
999 |
for (int i = 0; i != _smallmap_industry_count; i++) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1000 |
_legend_from_industries[i].show_on_map = false; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1001 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1002 |
/* toggle appeareance indicating the choice */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1003 |
this->RaiseWidget(SM_WIDGET_ENABLEINDUSTRIES); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1004 |
this->LowerWidget(SM_WIDGET_DISABLEINDUSTRIES); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1005 |
this->SetDirty(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1006 |
break; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1007 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1008 |
} |
0 | 1009 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1010 |
virtual void OnRightClick(Point pt, int widget) |
0 | 1011 |
{ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1012 |
if (widget == SM_WIDGET_MAP) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1013 |
if (_scrolling_viewport) return; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1014 |
_scrolling_viewport = true; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1015 |
_cursor.delta.x = 0; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1016 |
_cursor.delta.y = 0; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1017 |
} |
0 | 1018 |
} |
4435
cde1d8fc5c8f
(svn r6205) -CodeChange : use a switch case instead of a cascade of if
belugas
parents:
4429
diff
changeset
|
1019 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1020 |
virtual void OnTick() |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1021 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1022 |
/* update the window every now and then */ |
10776 | 1023 |
if ((++this->refresh & 0x1F) == 0) this->SetDirty(); |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1024 |
} |
0 | 1025 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1026 |
virtual void OnScroll(Point delta) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1027 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1028 |
_cursor.fix_at = true; |
4335
18bc63352a17
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
1029 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1030 |
int x = this->scroll_x; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1031 |
int y = this->scroll_y; |
4335
18bc63352a17
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
1032 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1033 |
int sub = this->subscroll + delta.x; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1034 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1035 |
x -= (sub >> 2) << 4; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1036 |
y += (sub >> 2) << 4; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1037 |
sub &= 3; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1038 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1039 |
x += (delta.y >> 1) << 4; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1040 |
y += (delta.y >> 1) << 4; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1041 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1042 |
if (delta.y & 1) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1043 |
x += TILE_SIZE; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1044 |
sub += 2; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1045 |
if (sub > 3) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1046 |
sub -= 4; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1047 |
x -= TILE_SIZE; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1048 |
y += TILE_SIZE; |
4335
18bc63352a17
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
1049 |
} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1050 |
} |
4335
18bc63352a17
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
1051 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1052 |
int hx = (this->widget[SM_WIDGET_MAP].right - this->widget[SM_WIDGET_MAP].left) / 2; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1053 |
int hy = (this->widget[SM_WIDGET_MAP].bottom - this->widget[SM_WIDGET_MAP].top ) / 2; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1054 |
int hvx = hx * -4 + hy * 8; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1055 |
int hvy = hx * 4 + hy * 8; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1056 |
if (x < -hvx) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1057 |
x = -hvx; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1058 |
sub = 0; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1059 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1060 |
if (x > (int)MapMaxX() * TILE_SIZE - hvx) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1061 |
x = MapMaxX() * TILE_SIZE - hvx; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1062 |
sub = 0; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1063 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1064 |
if (y < -hvy) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1065 |
y = -hvy; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1066 |
sub = 0; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1067 |
} |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1068 |
if (y > (int)MapMaxY() * TILE_SIZE - hvy) { |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1069 |
y = MapMaxY() * TILE_SIZE - hvy; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1070 |
sub = 0; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1071 |
} |
4335
18bc63352a17
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
1072 |
|
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1073 |
this->scroll_x = x; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1074 |
this->scroll_y = y; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1075 |
this->subscroll = sub; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1076 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1077 |
this->SetDirty(); |
0 | 1078 |
} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1079 |
}; |
0 | 1080 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1081 |
static const WindowDesc _smallmap_desc = { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1082 |
WDP_AUTO, WDP_AUTO, 350, 214, 446, 314, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5835
diff
changeset
|
1083 |
WC_SMALLMAP, WC_NONE, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1084 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1085 |
_smallmap_widgets, |
0 | 1086 |
}; |
1087 |
||
6573 | 1088 |
void ShowSmallMap() |
0 | 1089 |
{ |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1090 |
AllocateWindowDescFront<SmallMapWindow>(&_smallmap_desc, 0); |
0 | 1091 |
} |
1092 |
||
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
|
1093 |
/* Extra ViewPort Window Stuff */ |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1094 |
static const Widget _extra_view_port_widgets[] = { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1095 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1096 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 287, 0, 13, STR_EXTRA_VIEW_PORT_TITLE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1097 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 288, 299, 0, 13, 0x0, STR_STICKY_BUTTON}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1098 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 299, 14, 33, 0x0, STR_NULL}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1099 |
{ WWT_INSET, RESIZE_RB, 14, 2, 297, 16, 31, 0x0, STR_NULL}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1100 |
{ WWT_PUSHIMGBTN, RESIZE_TB, 14, 0, 21, 34, 55, SPR_IMG_ZOOMIN, STR_017F_ZOOM_THE_VIEW_IN}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1101 |
{ WWT_PUSHIMGBTN, RESIZE_TB, 14, 22, 43, 34, 55, SPR_IMG_ZOOMOUT, STR_0180_ZOOM_THE_VIEW_OUT}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1102 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 44, 171, 34, 55, STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW, STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW_TT}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1103 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 172, 298, 34, 55, STR_EXTRA_VIEW_MOVE_VIEW_TO_MAIN, STR_EXTRA_VIEW_MOVE_VIEW_TO_MAIN_TT}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1104 |
{ WWT_PANEL, RESIZE_RTB, 14, 299, 299, 34, 55, 0x0, STR_NULL}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1105 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 287, 56, 67, 0x0, STR_NULL}, |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1106 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 288, 299, 56, 67, 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
|
1107 |
{ 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
|
1108 |
}; |
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
|
1109 |
|
10645 | 1110 |
class ExtraViewportWindow : public Window |
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
|
1111 |
{ |
10645 | 1112 |
enum ExtraViewportWindowWidgets { |
1113 |
EVW_CLOSE, |
|
1114 |
EVW_CAPTION, |
|
1115 |
EVW_STICKY, |
|
1116 |
EVW_BACKGROUND, |
|
1117 |
EVW_VIEWPORT, |
|
1118 |
EVW_ZOOMIN, |
|
1119 |
EVW_ZOOMOUT, |
|
1120 |
EVW_MAIN_TO_VIEW, |
|
1121 |
EVW_VIEW_TO_MAIN, |
|
1122 |
EVW_SPACER1, |
|
1123 |
EVW_SPACER2, |
|
1124 |
EVW_RESIZE, |
|
1125 |
}; |
|
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3882
diff
changeset
|
1126 |
|
10645 | 1127 |
public: |
1128 |
ExtraViewportWindow(const WindowDesc *desc, int window_number, TileIndex tile) : Window(desc, window_number) |
|
1129 |
{ |
|
1130 |
/* New viewport start at (zero,zero) */ |
|
1131 |
InitializeWindowViewport(this, 3, 17, this->widget[EVW_VIEWPORT].right - this->widget[EVW_VIEWPORT].left - 1, this->widget[EVW_VIEWPORT].bottom - this->widget[EVW_VIEWPORT].top - 1, 0, ZOOM_LVL_VIEWPORT); |
|
4335
18bc63352a17
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
1132 |
|
10645 | 1133 |
this->DisableWidget(EVW_ZOOMIN); |
1134 |
this->FindWindowPlacementAndResize(desc); |
|
4335
18bc63352a17
(svn r6036) -Codechange: do not handle SCROLL in a central function, but let windows handle them theirself. Added WE_SCROLL for this.
truelight
parents:
4171
diff
changeset
|
1135 |
|
10645 | 1136 |
Point pt; |
1137 |
if (tile == INVALID_TILE) { |
|
1138 |
/* the main window with the main view */ |
|
1139 |
const Window *w = FindWindowById(WC_MAIN_WINDOW, 0); |
|
4337
f77887bd2634
(svn r6038) -Codechange: move mousewheel code to event WE_MOUSEWHEEL instead of a general function that handles that
truelight
parents:
4335
diff
changeset
|
1140 |
|
10645 | 1141 |
/* center on same place as main window (zoom is maximum, no adjustment needed) */ |
1142 |
pt.x = w->viewport->scrollpos_x + w->viewport->virtual_height / 2; |
|
1143 |
pt.y = w->viewport->scrollpos_y + w->viewport->virtual_height / 2; |
|
1144 |
} else { |
|
1145 |
pt = RemapCoords(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, TileHeight(tile)); |
|
1146 |
} |
|
5045
3e734e178dae
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5036
diff
changeset
|
1147 |
|
10645 | 1148 |
this->viewport->scrollpos_x = pt.x - ((this->widget[EVW_VIEWPORT].right - this->widget[EVW_VIEWPORT].left) - 1) / 2; |
1149 |
this->viewport->scrollpos_y = pt.y - ((this->widget[EVW_VIEWPORT].bottom - this->widget[EVW_VIEWPORT].top) - 1) / 2; |
|
1150 |
this->viewport->dest_scrollpos_x = this->viewport->scrollpos_x; |
|
1151 |
this->viewport->dest_scrollpos_y = this->viewport->scrollpos_y; |
|
1152 |
||
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
|
1153 |
} |
10645 | 1154 |
|
1155 |
virtual void OnPaint() |
|
1156 |
{ |
|
1157 |
/* set the number in the title bar */ |
|
1158 |
SetDParam(0, this->window_number + 1); |
|
1159 |
||
1160 |
this->DrawWidgets(); |
|
1161 |
this->DrawViewport(); |
|
1162 |
} |
|
1163 |
||
1164 |
virtual void OnClick(Point pt, int widget) |
|
1165 |
{ |
|
1166 |
switch (widget) { |
|
1167 |
case EVW_ZOOMIN: DoZoomInOutWindow(ZOOM_IN, this); break; |
|
1168 |
case EVW_ZOOMOUT: DoZoomInOutWindow(ZOOM_OUT, this); break; |
|
1169 |
||
1170 |
case EVW_MAIN_TO_VIEW: { // location button (move main view to same spot as this view) 'Paste Location' |
|
1171 |
Window *w = FindWindowById(WC_MAIN_WINDOW, 0); |
|
1172 |
int x = this->viewport->scrollpos_x; // Where is the main looking at |
|
1173 |
int y = this->viewport->scrollpos_y; |
|
1174 |
||
1175 |
/* set this view to same location. Based on the center, adjusting for zoom */ |
|
1176 |
w->viewport->dest_scrollpos_x = x - (w->viewport->virtual_width - this->viewport->virtual_width) / 2; |
|
1177 |
w->viewport->dest_scrollpos_y = y - (w->viewport->virtual_height - this->viewport->virtual_height) / 2; |
|
1178 |
} break; |
|
1179 |
||
1180 |
case EVW_VIEW_TO_MAIN: { // inverse location button (move this view to same spot as main view) 'Copy Location' |
|
1181 |
const Window *w = FindWindowById(WC_MAIN_WINDOW, 0); |
|
1182 |
int x = w->viewport->scrollpos_x; |
|
1183 |
int y = w->viewport->scrollpos_y; |
|
1184 |
||
1185 |
this->viewport->dest_scrollpos_x = x + (w->viewport->virtual_width - this->viewport->virtual_width) / 2; |
|
1186 |
this->viewport->dest_scrollpos_y = y + (w->viewport->virtual_height - this->viewport->virtual_height) / 2; |
|
1187 |
} break; |
|
1188 |
} |
|
1189 |
} |
|
1190 |
||
1191 |
virtual void OnResize(Point new_size, Point delta) |
|
1192 |
{ |
|
1193 |
this->viewport->width += delta.x; |
|
1194 |
this->viewport->height += delta.y; |
|
1195 |
this->viewport->virtual_width += delta.x; |
|
1196 |
this->viewport->virtual_height += delta.y; |
|
1197 |
} |
|
1198 |
||
1199 |
virtual void OnScroll(Point delta) |
|
1200 |
{ |
|
1201 |
ViewPort *vp = IsPtInWindowViewport(this, _cursor.pos.x, _cursor.pos.y); |
|
1202 |
||
1203 |
if (vp == NULL) { |
|
1204 |
_cursor.fix_at = false; |
|
1205 |
_scrolling_viewport = false; |
|
1206 |
} |
|
1207 |
||
1208 |
this->viewport->scrollpos_x += ScaleByZoom(delta.x, vp->zoom); |
|
1209 |
this->viewport->scrollpos_y += ScaleByZoom(delta.y, vp->zoom); |
|
1210 |
this->viewport->dest_scrollpos_x = this->viewport->scrollpos_x; |
|
1211 |
this->viewport->dest_scrollpos_y = this->viewport->scrollpos_y; |
|
1212 |
} |
|
1213 |
||
1214 |
virtual void OnMouseWheel(int wheel) |
|
1215 |
{ |
|
1216 |
ZoomInOrOutToCursorWindow(wheel < 0, this); |
|
1217 |
} |
|
1218 |
||
1219 |
virtual void OnInvalidateData(int data = 0) |
|
1220 |
{ |
|
1221 |
/* Only handle zoom message if intended for us (msg ZOOM_IN/ZOOM_OUT) */ |
|
1222 |
HandleZoomMessage(this, this->viewport, EVW_ZOOMIN, EVW_ZOOMOUT); |
|
1223 |
} |
|
1224 |
}; |
|
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
|
1225 |
|
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
|
1226 |
static const WindowDesc _extra_view_port_desc = { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1227 |
WDP_AUTO, WDP_AUTO, 300, 68, 300, 268, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5835
diff
changeset
|
1228 |
WC_EXTRA_VIEW_PORT, WC_NONE, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1229 |
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
|
1230 |
_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
|
1231 |
}; |
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
|
1232 |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10294
diff
changeset
|
1233 |
void ShowExtraViewPortWindow(TileIndex tile) |
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
|
1234 |
{ |
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
|
1235 |
int i = 0; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1236 |
|
9574 | 1237 |
/* find next free window number for extra viewport */ |
2989 | 1238 |
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
|
1239 |
|
10645 | 1240 |
new ExtraViewportWindow(&_extra_view_port_desc, i, tile); |
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
|
1241 |
} |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1242 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1243 |
bool ScrollMainWindowTo(int x, int y, bool instant) |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1244 |
{ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1245 |
bool res = ScrollWindowTo(x, y, FindWindowById(WC_MAIN_WINDOW, 0), instant); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1246 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1247 |
/* If a user scrolls to a tile (via what way what so ever) and already is on |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1248 |
* that tile (e.g.: pressed twice), move the smallmap to that location, |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1249 |
* so you directly see where you are on the smallmap. */ |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1250 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1251 |
if (res) return res; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1252 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1253 |
SmallMapWindow *w = dynamic_cast<SmallMapWindow*>(FindWindowById(WC_SMALLMAP, 0)); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1254 |
if (w != NULL) w->SmallMapCenterOnCurrentPos(); |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1255 |
|
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1256 |
return res; |
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10455
diff
changeset
|
1257 |
} |