mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +00:00
(svn r9844) -Codechange: replace zoomlevel with an enum
-Codechange: use predefined enums for viewport zoomlevels
This commit is contained in:
parent
196ddae1db
commit
d3f375231f
@ -662,6 +662,9 @@
|
||||
<File
|
||||
RelativePath=".\..\src\window.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\zoom.hpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="GUI Source Code"
|
||||
|
@ -1111,6 +1111,10 @@
|
||||
RelativePath=".\..\src\window.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\zoom.hpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="GUI Source Code"
|
||||
|
@ -188,6 +188,7 @@ music/win32_m.h
|
||||
sound/win32_s.h
|
||||
video/win32_v.h
|
||||
window.h
|
||||
zoom.hpp
|
||||
|
||||
# GUI Source Code
|
||||
aircraft_gui.cpp
|
||||
|
@ -393,6 +393,6 @@ void ShowAircraftViewWindow(const Vehicle *v)
|
||||
|
||||
if (w != NULL) {
|
||||
w->caption_color = v->owner;
|
||||
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
|
||||
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), ZOOM_LVL_AIRCRAFT);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "fontcache.h"
|
||||
#include "genworld.h"
|
||||
#include "debug.h"
|
||||
#include "zoom.hpp"
|
||||
|
||||
#ifdef _DEBUG
|
||||
bool _dbg_screen_rect;
|
||||
@ -153,7 +154,7 @@ void GfxFillRect(int left, int top, int right, int bottom, int color)
|
||||
const int otop = top;
|
||||
const int oleft = left;
|
||||
|
||||
if (dpi->zoom != 0) return;
|
||||
if (dpi->zoom != ZOOM_LVL_NORMAL) return;
|
||||
if (left > right || top > bottom) return;
|
||||
if (right < dpi->left || left >= dpi->left + dpi->width) return;
|
||||
if (bottom < dpi->top || top >= dpi->top + dpi->height) return;
|
||||
@ -1444,7 +1445,7 @@ static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode)
|
||||
/* tile blit */
|
||||
start_y = 0;
|
||||
|
||||
if (dpi->zoom > 0) {
|
||||
if (dpi->zoom > ZOOM_LVL_NORMAL) {
|
||||
start_y += bp.height & ~zoom_mask;
|
||||
bp.height &= zoom_mask;
|
||||
if (bp.height == 0) return;
|
||||
@ -1946,7 +1947,7 @@ bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int heigh
|
||||
{
|
||||
const DrawPixelInfo *o = _cur_dpi;
|
||||
|
||||
n->zoom = 0;
|
||||
n->zoom = ZOOM_LVL_NORMAL;
|
||||
|
||||
assert(width > 0);
|
||||
assert(height > 0);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define GFX_H
|
||||
|
||||
#include "openttd.h"
|
||||
#include "zoom.hpp"
|
||||
|
||||
enum WindowKeyCodes {
|
||||
WKC_SHIFT = 0x8000,
|
||||
@ -136,7 +137,7 @@ struct DrawPixelInfo {
|
||||
Pixel *dst_ptr;
|
||||
int left, top, width, height;
|
||||
int pitch;
|
||||
uint16 zoom;
|
||||
ZoomLevel zoom;
|
||||
};
|
||||
|
||||
struct Colour {
|
||||
|
@ -452,7 +452,7 @@ void ShowIndustryViewWindow(int industry)
|
||||
WP(w, vp2_d).data_1 = 0;
|
||||
WP(w, vp2_d).data_2 = 0;
|
||||
WP(w, vp2_d).data_3 = 0;
|
||||
AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetIndustry(w->window_number)->xy + TileDiffXY(1, 1), 1);
|
||||
AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetIndustry(w->window_number)->xy + TileDiffXY(1, 1), ZOOM_LVL_INDUSTRY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -880,8 +880,8 @@ bool DoZoomInOutWindow(int how, Window *w)
|
||||
|
||||
switch (how) {
|
||||
case ZOOM_IN:
|
||||
if (vp->zoom == 0) return false;
|
||||
vp->zoom--;
|
||||
if (vp->zoom == ZOOM_LVL_NORMAL) return false;
|
||||
vp->zoom = (ZoomLevel)((byte)vp->zoom - 1);
|
||||
vp->virtual_width >>= 1;
|
||||
vp->virtual_height >>= 1;
|
||||
|
||||
@ -889,8 +889,8 @@ bool DoZoomInOutWindow(int how, Window *w)
|
||||
WP(w,vp_d).scrollpos_y += vp->virtual_height >> 1;
|
||||
break;
|
||||
case ZOOM_OUT:
|
||||
if (vp->zoom == 2) return false;
|
||||
vp->zoom++;
|
||||
if (vp->zoom == ZOOM_LVL_OUT_4X) return false;
|
||||
vp->zoom = (ZoomLevel)((byte)vp->zoom + 1);
|
||||
|
||||
WP(w,vp_d).scrollpos_x -= vp->virtual_width >> 1;
|
||||
WP(w,vp_d).scrollpos_y -= vp->virtual_height >> 1;
|
||||
@ -1049,7 +1049,7 @@ void ZoomInOrOutToCursorWindow(bool in, Window *w)
|
||||
vp = w->viewport;
|
||||
|
||||
if (_game_mode != GM_MENU) {
|
||||
if ((in && vp->zoom == 0) || (!in && vp->zoom == 2))
|
||||
if ((in && vp->zoom == ZOOM_LVL_NORMAL) || (!in && vp->zoom == ZOOM_LVL_OUT_4X))
|
||||
return;
|
||||
|
||||
pt = GetTileZoomCenterWindow(in,w);
|
||||
@ -2460,7 +2460,7 @@ void SetupColorsAndInitialWindow()
|
||||
height = _screen.height;
|
||||
|
||||
w = AllocateWindow(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL);
|
||||
AssignWindowViewport(w, 0, 0, width, height, TileXY(32, 32), 0);
|
||||
AssignWindowViewport(w, 0, 0, width, height, TileXY(32, 32), ZOOM_LVL_VIEWPORT);
|
||||
|
||||
/* XXX: these are not done */
|
||||
switch (_game_mode) {
|
||||
|
@ -427,7 +427,7 @@ static void ShowNewspaper(NewsItem *ni)
|
||||
w = AllocateWindowDesc(&_news_type13_desc);
|
||||
if (ni->flags & NF_VIEWPORT)
|
||||
AssignWindowViewport(w, 2, 58, 0x1AA, 0x6E,
|
||||
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), 0);
|
||||
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -436,7 +436,7 @@ static void ShowNewspaper(NewsItem *ni)
|
||||
w = AllocateWindowDesc(&_news_type2_desc);
|
||||
if (ni->flags & NF_VIEWPORT)
|
||||
AssignWindowViewport(w, 2, 58, 0x1AA, 0x46,
|
||||
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), 0);
|
||||
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -445,7 +445,7 @@ static void ShowNewspaper(NewsItem *ni)
|
||||
w = AllocateWindowDesc(&_news_type0_desc);
|
||||
if (ni->flags & NF_VIEWPORT)
|
||||
AssignWindowViewport(w, 3, 17, 0x112, 0x2F,
|
||||
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), 0);
|
||||
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -725,7 +725,7 @@ static void DrawRoadBits(TileInfo* ti)
|
||||
}
|
||||
|
||||
/* Return if full detail is disabled, or we are zoomed fully out. */
|
||||
if (!HASBIT(_display_opt, DO_FULL_DETAIL) || _cur_dpi->zoom == 2) return;
|
||||
if (!HASBIT(_display_opt, DO_FULL_DETAIL) || _cur_dpi->zoom == ZOOM_LVL_OUT_4X) return;
|
||||
|
||||
/* Draw extra details. */
|
||||
for (drts = _road_display_table[roadside][road]; drts->image != 0; drts++) {
|
||||
|
@ -346,7 +346,7 @@ void ShowRoadVehViewWindow(const Vehicle *v)
|
||||
|
||||
if (w != NULL) {
|
||||
w->caption_color = v->owner;
|
||||
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
|
||||
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), ZOOM_LVL_ROADVEH);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -469,7 +469,7 @@ static void LargeWorldCallback(void *userdata, Pixel *buf, uint y, uint pitch, u
|
||||
dpi.height = n;
|
||||
dpi.width = vp->width;
|
||||
dpi.pitch = pitch;
|
||||
dpi.zoom = 0;
|
||||
dpi.zoom = ZOOM_LVL_WORLD_SCREENSHOT;
|
||||
dpi.left = 0;
|
||||
dpi.top = y;
|
||||
|
||||
@ -540,7 +540,7 @@ static bool MakeWorldScreenshot()
|
||||
ViewPort vp;
|
||||
const ScreenshotFormat *sf;
|
||||
|
||||
vp.zoom = 0;
|
||||
vp.zoom = ZOOM_LVL_WORLD_SCREENSHOT;
|
||||
vp.left = 0;
|
||||
vp.top = 0;
|
||||
vp.virtual_left = -(int)MapMaxX() * TILE_PIXELS;
|
||||
|
@ -347,6 +347,6 @@ void ShowShipViewWindow(const Vehicle *v)
|
||||
|
||||
if (w != NULL) {
|
||||
w->caption_color = v->owner;
|
||||
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
|
||||
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), ZOOM_LVL_SHIP);
|
||||
}
|
||||
}
|
||||
|
@ -1055,7 +1055,7 @@ void ShowExtraViewPortWindow()
|
||||
/* the main window with the main view */
|
||||
v = FindWindowById(WC_MAIN_WINDOW, 0);
|
||||
/* New viewport start ats (zero,zero) */
|
||||
AssignWindowViewport(w, 3, 17, 294, 214, 0 , 0);
|
||||
AssignWindowViewport(w, 3, 17, 294, 214, 0 , ZOOM_LVL_VIEWPORT);
|
||||
|
||||
/* center on same place as main window (zoom is maximum, no adjustment needed) */
|
||||
x = WP(v, vp_d).scrollpos_x;
|
||||
|
@ -327,7 +327,7 @@ void DrawTextEffects(DrawPixelInfo *dpi)
|
||||
const TextEffect* te;
|
||||
|
||||
switch (dpi->zoom) {
|
||||
case 0:
|
||||
case ZOOM_LVL_NORMAL:
|
||||
for (te = _text_effect_list; te != endof(_text_effect_list); te++) {
|
||||
if (te->string_id != INVALID_STRING_ID &&
|
||||
dpi->left <= te->right &&
|
||||
@ -339,7 +339,7 @@ void DrawTextEffects(DrawPixelInfo *dpi)
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case ZOOM_LVL_OUT_2X:
|
||||
for (te = _text_effect_list; te != endof(_text_effect_list); te++) {
|
||||
if (te->string_id != INVALID_STRING_ID &&
|
||||
dpi->left <= te->right * 2 - te->x &&
|
||||
@ -350,6 +350,9 @@ void DrawTextEffects(DrawPixelInfo *dpi)
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -349,7 +349,7 @@ void ShowTownViewWindow(TownID town)
|
||||
|
||||
if (w != NULL) {
|
||||
w->flags4 |= WF_DISABLE_VP_SCROLL;
|
||||
AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetTown(town)->xy, 1);
|
||||
AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetTown(town)->xy, ZOOM_LVL_TOWN);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,7 @@ void ShowTrainViewWindow(const Vehicle *v)
|
||||
|
||||
if (w != NULL) {
|
||||
w->caption_color = v->owner;
|
||||
AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), 0);
|
||||
AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), ZOOM_LVL_TRAIN);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,6 @@ VARDEF byte _trees_tick_ctr;
|
||||
/* Keep track of current game position */
|
||||
VARDEF int _saved_scrollpos_x;
|
||||
VARDEF int _saved_scrollpos_y;
|
||||
VARDEF byte _saved_scrollpos_zoom;
|
||||
|
||||
/* ********* END OF SAVE REGION */
|
||||
|
||||
|
@ -26,6 +26,8 @@
|
||||
|
||||
#define VIEWPORT_DRAW_MEM (65536 * 2)
|
||||
|
||||
ZoomLevel _saved_scrollpos_zoom;
|
||||
|
||||
/* XXX - maximum viewports is maximum windows - 2 (main toolbar + status bar) */
|
||||
static ViewPort _viewports[25 - 2];
|
||||
static uint32 _active_viewports; ///< bitmasked variable where each bit signifies if a viewport is in use or not
|
||||
@ -143,7 +145,7 @@ void DeleteWindowViewport(Window *w)
|
||||
}
|
||||
|
||||
void AssignWindowViewport(Window *w, int x, int y,
|
||||
int width, int height, uint32 follow_flags, byte zoom)
|
||||
int width, int height, uint32 follow_flags, ZoomLevel zoom)
|
||||
{
|
||||
ViewPort *vp;
|
||||
Point pt;
|
||||
@ -404,10 +406,10 @@ Point GetTileZoomCenterWindow(bool in, Window * w)
|
||||
* @param widget_zoom_out widget index for window with zoom-out button */
|
||||
void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out)
|
||||
{
|
||||
SetWindowWidgetDisabledState(w, widget_zoom_in, vp->zoom == 0);
|
||||
SetWindowWidgetDisabledState(w, widget_zoom_in, vp->zoom == ZOOM_LVL_NORMAL);
|
||||
InvalidateWidget(w, widget_zoom_in);
|
||||
|
||||
SetWindowWidgetDisabledState(w, widget_zoom_out, vp->zoom == 2);
|
||||
SetWindowWidgetDisabledState(w, widget_zoom_out, vp->zoom == ZOOM_LVL_OUT_4X);
|
||||
InvalidateWidget(w, widget_zoom_out);
|
||||
}
|
||||
|
||||
@ -669,7 +671,7 @@ static void DrawTileSelection(const TileInfo *ti)
|
||||
z += TILE_HEIGHT;
|
||||
if (ti->tileh == SLOPE_STEEP_N) z += TILE_HEIGHT;
|
||||
}
|
||||
DrawGroundSpriteAt(_cur_dpi->zoom != 2 ? SPR_DOT : SPR_DOT_SMALL, PAL_NONE, ti->x, ti->y, z);
|
||||
DrawGroundSpriteAt(_cur_dpi->zoom != ZOOM_LVL_OUT_4X ? SPR_DOT : SPR_DOT_SMALL, PAL_NONE, ti->x, ti->y, z);
|
||||
} else if (_thd.drawstyle & HT_RAIL /*&& _thd.place_mode == VHM_RAIL*/) {
|
||||
/* autorail highlight piece under cursor */
|
||||
uint type = _thd.drawstyle & 0xF;
|
||||
@ -808,7 +810,7 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi)
|
||||
bottom = top + dpi->height;
|
||||
|
||||
switch (dpi->zoom) {
|
||||
case 0:
|
||||
case ZOOM_LVL_NORMAL:
|
||||
FOR_ALL_TOWNS(t) {
|
||||
if (bottom > t->sign.top &&
|
||||
top < t->sign.top + 12 &&
|
||||
@ -821,7 +823,7 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi)
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case ZOOM_LVL_OUT_2X:
|
||||
right += 2;
|
||||
bottom += 2;
|
||||
|
||||
@ -838,7 +840,7 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi)
|
||||
break;
|
||||
|
||||
default: NOT_REACHED();
|
||||
case 2:
|
||||
case ZOOM_LVL_OUT_4X:
|
||||
right += 4;
|
||||
bottom += 5;
|
||||
|
||||
@ -882,7 +884,7 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi)
|
||||
bottom = top + dpi->height;
|
||||
|
||||
switch (dpi->zoom) {
|
||||
case 0:
|
||||
case ZOOM_LVL_NORMAL:
|
||||
FOR_ALL_STATIONS(st) {
|
||||
if (bottom > st->sign.top &&
|
||||
top < st->sign.top + 12 &&
|
||||
@ -893,7 +895,7 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi)
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case ZOOM_LVL_OUT_2X:
|
||||
right += 2;
|
||||
bottom += 2;
|
||||
FOR_ALL_STATIONS(st) {
|
||||
@ -907,7 +909,7 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi)
|
||||
break;
|
||||
|
||||
default: NOT_REACHED();
|
||||
case 2:
|
||||
case ZOOM_LVL_OUT_4X:
|
||||
right += 4;
|
||||
bottom += 5;
|
||||
FOR_ALL_STATIONS(st) {
|
||||
@ -949,7 +951,7 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
|
||||
bottom = top + dpi->height;
|
||||
|
||||
switch (dpi->zoom) {
|
||||
case 0:
|
||||
case ZOOM_LVL_NORMAL:
|
||||
FOR_ALL_SIGNS(si) {
|
||||
if (bottom > si->sign.top &&
|
||||
top < si->sign.top + 12 &&
|
||||
@ -960,7 +962,7 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case ZOOM_LVL_OUT_2X:
|
||||
right += 2;
|
||||
bottom += 2;
|
||||
FOR_ALL_SIGNS(si) {
|
||||
@ -974,7 +976,7 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
|
||||
break;
|
||||
|
||||
default: NOT_REACHED();
|
||||
case 2:
|
||||
case ZOOM_LVL_OUT_4X:
|
||||
right += 4;
|
||||
bottom += 5;
|
||||
FOR_ALL_SIGNS(si) {
|
||||
@ -1016,7 +1018,7 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi)
|
||||
bottom = top + dpi->height;
|
||||
|
||||
switch (dpi->zoom) {
|
||||
case 0:
|
||||
case ZOOM_LVL_NORMAL:
|
||||
FOR_ALL_WAYPOINTS(wp) {
|
||||
if (bottom > wp->sign.top &&
|
||||
top < wp->sign.top + 12 &&
|
||||
@ -1027,7 +1029,7 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi)
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case ZOOM_LVL_OUT_2X:
|
||||
right += 2;
|
||||
bottom += 2;
|
||||
FOR_ALL_WAYPOINTS(wp) {
|
||||
@ -1041,7 +1043,7 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi)
|
||||
break;
|
||||
|
||||
default: NOT_REACHED();
|
||||
case 2:
|
||||
case ZOOM_LVL_OUT_4X:
|
||||
right += 4;
|
||||
bottom += 5;
|
||||
FOR_ALL_WAYPOINTS(wp) {
|
||||
@ -1163,13 +1165,13 @@ static void ViewportDrawParentSprites(ParentSpriteToDraw *psd[])
|
||||
static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDraw *ss)
|
||||
{
|
||||
DrawPixelInfo dp;
|
||||
byte zoom;
|
||||
ZoomLevel zoom;
|
||||
|
||||
_cur_dpi = &dp;
|
||||
dp = *dpi;
|
||||
|
||||
zoom = dp.zoom;
|
||||
dp.zoom = 0;
|
||||
dp.zoom = ZOOM_LVL_NORMAL;
|
||||
|
||||
dp.left >>= zoom;
|
||||
dp.top >>= zoom;
|
||||
@ -1490,7 +1492,7 @@ static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
|
||||
if (!HASBIT(_display_opt, DO_SHOW_TOWN_NAMES)) return false;
|
||||
|
||||
switch (vp->zoom) {
|
||||
case 0:
|
||||
case ZOOM_LVL_NORMAL:
|
||||
x = x - vp->left + vp->virtual_left;
|
||||
y = y - vp->top + vp->virtual_top;
|
||||
FOR_ALL_TOWNS(t) {
|
||||
@ -1504,7 +1506,7 @@ static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case ZOOM_LVL_OUT_2X:
|
||||
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
||||
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
||||
FOR_ALL_TOWNS(t) {
|
||||
@ -1518,7 +1520,8 @@ static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
default: NOT_REACHED();
|
||||
case ZOOM_LVL_OUT_4X:
|
||||
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
||||
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
||||
FOR_ALL_TOWNS(t) {
|
||||
@ -1544,7 +1547,7 @@ static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
|
||||
if (!HASBIT(_display_opt, DO_SHOW_STATION_NAMES)) return false;
|
||||
|
||||
switch (vp->zoom) {
|
||||
case 0:
|
||||
case ZOOM_LVL_NORMAL:
|
||||
x = x - vp->left + vp->virtual_left;
|
||||
y = y - vp->top + vp->virtual_top;
|
||||
FOR_ALL_STATIONS(st) {
|
||||
@ -1558,7 +1561,7 @@ static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case ZOOM_LVL_OUT_2X:
|
||||
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
||||
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
||||
FOR_ALL_STATIONS(st) {
|
||||
@ -1572,7 +1575,8 @@ static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
default: NOT_REACHED();
|
||||
case ZOOM_LVL_OUT_4X:
|
||||
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
||||
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
||||
FOR_ALL_STATIONS(st) {
|
||||
@ -1598,7 +1602,7 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
|
||||
if (!HASBIT(_display_opt, DO_SHOW_SIGNS) || _current_player == PLAYER_SPECTATOR) return false;
|
||||
|
||||
switch (vp->zoom) {
|
||||
case 0:
|
||||
case ZOOM_LVL_NORMAL:
|
||||
x = x - vp->left + vp->virtual_left;
|
||||
y = y - vp->top + vp->virtual_top;
|
||||
FOR_ALL_SIGNS(si) {
|
||||
@ -1612,7 +1616,7 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case ZOOM_LVL_OUT_2X:
|
||||
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
||||
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
||||
FOR_ALL_SIGNS(si) {
|
||||
@ -1626,7 +1630,8 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
default: NOT_REACHED();
|
||||
case ZOOM_LVL_OUT_4X:
|
||||
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
||||
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
||||
FOR_ALL_SIGNS(si) {
|
||||
@ -1652,7 +1657,7 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
|
||||
if (!HASBIT(_display_opt, DO_WAYPOINTS)) return false;
|
||||
|
||||
switch (vp->zoom) {
|
||||
case 0:
|
||||
case ZOOM_LVL_NORMAL:
|
||||
x = x - vp->left + vp->virtual_left;
|
||||
y = y - vp->top + vp->virtual_top;
|
||||
FOR_ALL_WAYPOINTS(wp) {
|
||||
@ -1666,7 +1671,7 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case ZOOM_LVL_OUT_2X:
|
||||
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
||||
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
||||
FOR_ALL_WAYPOINTS(wp) {
|
||||
@ -1680,7 +1685,8 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
default: NOT_REACHED();
|
||||
case ZOOM_LVL_OUT_4X:
|
||||
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
||||
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
||||
FOR_ALL_WAYPOINTS(wp) {
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef VIEWPORT_H
|
||||
#define VIEWPORT_H
|
||||
|
||||
#include "zoom.hpp"
|
||||
|
||||
struct ViewPort {
|
||||
int left,top; // screen coordinates for the viewport
|
||||
int width, height; // screen width/height for the viewport
|
||||
@ -12,7 +14,7 @@ struct ViewPort {
|
||||
int virtual_left, virtual_top; // virtual coordinates
|
||||
int virtual_width, virtual_height; // these are just width << zoom, height << zoom
|
||||
|
||||
byte zoom;
|
||||
ZoomLevel zoom;
|
||||
};
|
||||
|
||||
void SetSelectionRed(bool);
|
||||
@ -21,7 +23,7 @@ void SetSelectionRed(bool);
|
||||
void InitViewports();
|
||||
void DeleteWindowViewport(Window *w);
|
||||
void AssignWindowViewport(Window *w, int x, int y,
|
||||
int width, int height, uint32 follow_flags, byte zoom);
|
||||
int width, int height, uint32 follow_flags, ZoomLevel zoom);
|
||||
ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
|
||||
Point GetTileBelowCursor();
|
||||
void UpdateViewportPosition(Window *w);
|
||||
|
@ -271,7 +271,7 @@ static void DrawOverlappedWindow(Window* const *wz, int left, int top, int right
|
||||
dp->top = top - (*wz)->top;
|
||||
dp->pitch = _screen.pitch;
|
||||
dp->dst_ptr = _screen.dst_ptr + top * _screen.pitch + left;
|
||||
dp->zoom = 0;
|
||||
dp->zoom = ZOOM_LVL_NORMAL;
|
||||
CallWindowEventNP(*wz, WE_PAINT);
|
||||
}
|
||||
}
|
||||
|
29
src/zoom.hpp
Normal file
29
src/zoom.hpp
Normal file
@ -0,0 +1,29 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file zoom.hpp */
|
||||
|
||||
#ifndef ZOOM_HPP
|
||||
#define ZOOM_HPP
|
||||
|
||||
enum ZoomLevel {
|
||||
/* Our possible zoom-levels */
|
||||
ZOOM_LVL_NORMAL = 0,
|
||||
ZOOM_LVL_OUT_2X,
|
||||
ZOOM_LVL_OUT_4X,
|
||||
ZOOM_LVL_END,
|
||||
|
||||
/* Here we define in which zoom viewports are */
|
||||
ZOOM_LVL_VIEWPORT = ZOOM_LVL_NORMAL,
|
||||
ZOOM_LVL_NEWS = ZOOM_LVL_NORMAL,
|
||||
ZOOM_LVL_INDUSTRY = ZOOM_LVL_OUT_2X,
|
||||
ZOOM_LVL_TOWN = ZOOM_LVL_OUT_2X,
|
||||
ZOOM_LVL_AIRCRAFT = ZOOM_LVL_NORMAL,
|
||||
ZOOM_LVL_SHIP = ZOOM_LVL_NORMAL,
|
||||
ZOOM_LVL_TRAIN = ZOOM_LVL_NORMAL,
|
||||
ZOOM_LVL_ROADVEH = ZOOM_LVL_NORMAL,
|
||||
ZOOM_LVL_WORLD_SCREENSHOT = ZOOM_LVL_NORMAL,
|
||||
};
|
||||
|
||||
extern ZoomLevel _saved_scrollpos_zoom;
|
||||
|
||||
#endif /* ZOOM_HPP */
|
Loading…
Reference in New Issue
Block a user