mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
-Codechange: Wrap all transparency settings in accessors, hiding the implementation -Change: Clicking "transparent building" menu will toggle Houses And Trees only. The other options can be used in the transparency gui. Initial patch by Smatz (FS#1349), with some rework by BigBB and your humble servant.
This commit is contained in:
parent
3a84801f55
commit
f55fdfb7c4
|
@ -684,6 +684,9 @@
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\train.h">
|
RelativePath=".\..\src\train.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\transparency.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\transparency_gui.h">
|
RelativePath=".\..\src\transparency_gui.h">
|
||||||
</File>
|
</File>
|
||||||
|
|
|
@ -1143,6 +1143,10 @@
|
||||||
RelativePath=".\..\src\train.h"
|
RelativePath=".\..\src\train.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\transparency.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\transparency_gui.h"
|
RelativePath=".\..\src\transparency_gui.h"
|
||||||
>
|
>
|
||||||
|
|
|
@ -194,6 +194,7 @@ tile.h
|
||||||
timetable.h
|
timetable.h
|
||||||
town.h
|
town.h
|
||||||
train.h
|
train.h
|
||||||
|
transparency.h
|
||||||
transparency_gui.h
|
transparency_gui.h
|
||||||
variables.h
|
variables.h
|
||||||
vehicle.h
|
vehicle.h
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
#include "vehicle.h"
|
#include "vehicle.h"
|
||||||
#include "train.h"
|
#include "train.h"
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
static inline TLG GetTLG(TileIndex t)
|
static inline TLG GetTLG(TileIndex t)
|
||||||
{
|
{
|
||||||
|
@ -195,7 +196,7 @@ void DrawCatenaryOnTunnel(const TileInfo *ti)
|
||||||
sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
|
sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
|
||||||
BB_data[2] - sss->x_offset, BB_data[3] - sss->y_offset, BB_Z_SEPARATOR - sss->z_offset + 1,
|
BB_data[2] - sss->x_offset, BB_data[3] - sss->y_offset, BB_Z_SEPARATOR - sss->z_offset + 1,
|
||||||
GetTileZ(ti->tile) + sss->z_offset,
|
GetTileZ(ti->tile) + sss->z_offset,
|
||||||
HASBIT(_transparent_opt, TO_BUILDINGS),
|
IsTransparencySet(TO_BUILDINGS),
|
||||||
BB_data[0] - sss->x_offset, BB_data[1] - sss->y_offset, BB_Z_SEPARATOR - sss->z_offset
|
BB_data[0] - sss->x_offset, BB_data[1] - sss->y_offset, BB_Z_SEPARATOR - sss->z_offset
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -342,7 +343,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
|
||||||
|
|
||||||
AddSortableSpriteToDraw(pylon_sprites[temp], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE,
|
AddSortableSpriteToDraw(pylon_sprites[temp], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE,
|
||||||
GetPCPElevation(ti->tile, i),
|
GetPCPElevation(ti->tile, i),
|
||||||
HASBIT(_transparent_opt, TO_BUILDINGS), -1, -1);
|
IsTransparencySet(TO_BUILDINGS), -1, -1);
|
||||||
break; /* We already have drawn a pylon, bail out */
|
break; /* We already have drawn a pylon, bail out */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,7 +351,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't draw a wire under a low bridge */
|
/* Don't draw a wire under a low bridge */
|
||||||
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !HASBIT(_transparent_opt, TO_BUILDINGS)) {
|
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_BUILDINGS)) {
|
||||||
uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
|
uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
|
||||||
|
|
||||||
if (height <= GetTileMaxZ(ti->tile) + TILE_HEIGHT) return;
|
if (height <= GetTileMaxZ(ti->tile) + TILE_HEIGHT) return;
|
||||||
|
@ -377,7 +378,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
|
||||||
*/
|
*/
|
||||||
AddSortableSpriteToDraw(sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
|
AddSortableSpriteToDraw(sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
|
||||||
sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x + sss->x_offset, ti->y + sss->y_offset) + sss->z_offset,
|
sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x + sss->x_offset, ti->y + sss->y_offset) + sss->z_offset,
|
||||||
HASBIT(_transparent_opt, TO_BUILDINGS));
|
IsTransparencySet(TO_BUILDINGS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -410,7 +411,7 @@ static void DrawCatenaryOnBridge(const TileInfo *ti)
|
||||||
|
|
||||||
AddSortableSpriteToDraw(sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
|
AddSortableSpriteToDraw(sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
|
||||||
sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset,
|
sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset,
|
||||||
HASBIT(_transparent_opt, TO_BUILDINGS)
|
IsTransparencySet(TO_BUILDINGS)
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Finished with wires, draw pylons */
|
/* Finished with wires, draw pylons */
|
||||||
|
@ -421,7 +422,7 @@ static void DrawCatenaryOnBridge(const TileInfo *ti)
|
||||||
if (HASBIT(tlg, (axis == AXIS_X ? 0 : 1))) PPPpos = ReverseDir(PPPpos);
|
if (HASBIT(tlg, (axis == AXIS_X ? 0 : 1))) PPPpos = ReverseDir(PPPpos);
|
||||||
uint x = ti->x + x_pcp_offsets[PCPpos] + x_ppp_offsets[PPPpos];
|
uint x = ti->x + x_pcp_offsets[PCPpos] + x_ppp_offsets[PPPpos];
|
||||||
uint y = ti->y + y_pcp_offsets[PCPpos] + y_ppp_offsets[PPPpos];
|
uint y = ti->y + y_pcp_offsets[PCPpos] + y_ppp_offsets[PPPpos];
|
||||||
AddSortableSpriteToDraw(pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, HASBIT(_transparent_opt, TO_BUILDINGS), -1, -1);
|
AddSortableSpriteToDraw(pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_BUILDINGS), -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* need a pylon on the southern end of the bridge */
|
/* need a pylon on the southern end of the bridge */
|
||||||
|
@ -431,7 +432,7 @@ static void DrawCatenaryOnBridge(const TileInfo *ti)
|
||||||
if (HASBIT(tlg, (axis == AXIS_X ? 0 : 1))) PPPpos = ReverseDir(PPPpos);
|
if (HASBIT(tlg, (axis == AXIS_X ? 0 : 1))) PPPpos = ReverseDir(PPPpos);
|
||||||
uint x = ti->x + x_pcp_offsets[PCPpos] + x_ppp_offsets[PPPpos];
|
uint x = ti->x + x_pcp_offsets[PCPpos] + x_ppp_offsets[PPPpos];
|
||||||
uint y = ti->y + y_pcp_offsets[PCPpos] + y_ppp_offsets[PPPpos];
|
uint y = ti->y + y_pcp_offsets[PCPpos] + y_ppp_offsets[PPPpos];
|
||||||
AddSortableSpriteToDraw(pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, HASBIT(_transparent_opt, TO_BUILDINGS), -1, -1);
|
AddSortableSpriteToDraw(pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_BUILDINGS), -1, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,7 +458,7 @@ void DrawCatenary(const TileInfo *ti)
|
||||||
sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
|
sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
|
||||||
sss->x_size, sss->y_size, sss->z_size,
|
sss->x_size, sss->y_size, sss->z_size,
|
||||||
GetTileMaxZ(ti->tile) + sss->z_offset,
|
GetTileMaxZ(ti->tile) + sss->z_offset,
|
||||||
HASBIT(_transparent_opt, TO_BUILDINGS)
|
IsTransparencySet(TO_BUILDINGS)
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "newgrf_callbacks.h"
|
#include "newgrf_callbacks.h"
|
||||||
#include "misc/autoptr.hpp"
|
#include "misc/autoptr.hpp"
|
||||||
#include "autoslope.h"
|
#include "autoslope.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
void ShowIndustryViewWindow(int industry);
|
void ShowIndustryViewWindow(int industry);
|
||||||
void BuildOilRig(TileIndex tile);
|
void BuildOilRig(TileIndex tile);
|
||||||
|
@ -310,9 +311,9 @@ static void DrawTile_Industry(TileInfo *ti)
|
||||||
dits->height,
|
dits->height,
|
||||||
dits->dz,
|
dits->dz,
|
||||||
ti->z,
|
ti->z,
|
||||||
HASBIT(_transparent_opt, TO_INDUSTRIES));
|
IsTransparencySet(TO_INDUSTRIES));
|
||||||
|
|
||||||
if (HASBIT(_transparent_opt, TO_INDUSTRIES)) return;
|
if (IsTransparencySet(TO_INDUSTRIES)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "network/network_server.h"
|
#include "network/network_server.h"
|
||||||
#include "network/network_gui.h"
|
#include "network/network_gui.h"
|
||||||
#include "industry.h"
|
#include "industry.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
static int _rename_id = 1;
|
static int _rename_id = 1;
|
||||||
static int _rename_what = -1;
|
static int _rename_what = -1;
|
||||||
|
@ -156,22 +157,6 @@ static void ToolbarFastForwardClick(Window *w)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Toggle all transparency options, except for signs */
|
|
||||||
static void ToggleTransparency()
|
|
||||||
{
|
|
||||||
static byte trans_opt = ~0;
|
|
||||||
|
|
||||||
if (GB(_transparent_opt, 1, 7) == 0) {
|
|
||||||
SB(_transparent_opt, 1, 7, GB(trans_opt, 1, 7));
|
|
||||||
} else {
|
|
||||||
trans_opt = _transparent_opt;
|
|
||||||
SB(_transparent_opt, 1, 7, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
MarkWholeScreenDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void MenuClickSettings(int index)
|
static void MenuClickSettings(int index)
|
||||||
{
|
{
|
||||||
switch (index) {
|
switch (index) {
|
||||||
|
@ -187,8 +172,11 @@ static void MenuClickSettings(int index)
|
||||||
case 9: TOGGLEBIT(_display_opt, DO_WAYPOINTS); break;
|
case 9: TOGGLEBIT(_display_opt, DO_WAYPOINTS); break;
|
||||||
case 10: TOGGLEBIT(_display_opt, DO_FULL_ANIMATION); break;
|
case 10: TOGGLEBIT(_display_opt, DO_FULL_ANIMATION); break;
|
||||||
case 11: TOGGLEBIT(_display_opt, DO_FULL_DETAIL); break;
|
case 11: TOGGLEBIT(_display_opt, DO_FULL_DETAIL); break;
|
||||||
case 12: ToggleTransparency(); break;
|
case 12:
|
||||||
case 13: TOGGLEBIT(_transparent_opt, TO_SIGNS); break;
|
ToggleTransparency(TO_TREES);
|
||||||
|
ToggleTransparency(TO_HOUSES);
|
||||||
|
break;
|
||||||
|
case 13: ToggleTransparency(TO_SIGNS); break;
|
||||||
}
|
}
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
}
|
}
|
||||||
|
@ -988,8 +976,8 @@ static void ToolbarOptionsClick(Window *w)
|
||||||
if (HASBIT(_display_opt, DO_WAYPOINTS)) SETBIT(x, 9);
|
if (HASBIT(_display_opt, DO_WAYPOINTS)) SETBIT(x, 9);
|
||||||
if (HASBIT(_display_opt, DO_FULL_ANIMATION)) SETBIT(x, 10);
|
if (HASBIT(_display_opt, DO_FULL_ANIMATION)) SETBIT(x, 10);
|
||||||
if (HASBIT(_display_opt, DO_FULL_DETAIL)) SETBIT(x, 11);
|
if (HASBIT(_display_opt, DO_FULL_DETAIL)) SETBIT(x, 11);
|
||||||
if (GB(_transparent_opt, 1, 7) != 0) SETBIT(x, 12);
|
if (IsTransparencySet(TO_HOUSES) && IsTransparencySet(TO_TREES)) SETBIT(x, 12);
|
||||||
if (HASBIT(_transparent_opt, TO_SIGNS)) SETBIT(x, 13);
|
if (IsTransparencySet(TO_SIGNS)) SETBIT(x, 13);
|
||||||
WP(w,menu_d).checked_items = x;
|
WP(w,menu_d).checked_items = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2259,8 +2247,9 @@ static void MainWindowWndProc(Window *w, WindowEvent *e)
|
||||||
case '5' | WKC_CTRL:
|
case '5' | WKC_CTRL:
|
||||||
case '6' | WKC_CTRL:
|
case '6' | WKC_CTRL:
|
||||||
case '7' | WKC_CTRL:
|
case '7' | WKC_CTRL:
|
||||||
|
case '8' | WKC_CTRL:
|
||||||
/* Transparency toggle hot keys */
|
/* Transparency toggle hot keys */
|
||||||
TOGGLEBIT(_transparent_opt, e->we.keypress.keycode - ('1' | WKC_CTRL));
|
ToggleTransparency((TransparencyOption)(e->we.keypress.keycode - ('1' | WKC_CTRL)));
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2269,7 +2258,7 @@ static void MainWindowWndProc(Window *w, WindowEvent *e)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'X':
|
case 'X':
|
||||||
ToggleTransparency();
|
ResetRestoreAllTransparency();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "newgrf_town.h"
|
#include "newgrf_town.h"
|
||||||
#include "newgrf_sound.h"
|
#include "newgrf_sound.h"
|
||||||
#include "newgrf_commons.h"
|
#include "newgrf_commons.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
static BuildingCounts _building_counts;
|
static BuildingCounts _building_counts;
|
||||||
static HouseClassMapping _class_mapping[HOUSE_CLASS_MAX];
|
static HouseClassMapping _class_mapping[HOUSE_CLASS_MAX];
|
||||||
|
@ -320,7 +321,7 @@ void DrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte stage, Ho
|
||||||
|
|
||||||
if (IS_CUSTOM_SPRITE(image)) image += stage;
|
if (IS_CUSTOM_SPRITE(image)) image += stage;
|
||||||
|
|
||||||
if ((HASBIT(image, SPRITE_MODIFIER_OPAQUE) || !HASBIT(_transparent_opt, TO_HOUSES)) && HASBIT(image, PALETTE_MODIFIER_COLOR)) {
|
if ((HASBIT(image, SPRITE_MODIFIER_OPAQUE) || !IsTransparencySet(TO_HOUSES)) && HASBIT(image, PALETTE_MODIFIER_COLOR)) {
|
||||||
if (pal == 0) {
|
if (pal == 0) {
|
||||||
const HouseSpec *hs = GetHouseSpecs(house_id);
|
const HouseSpec *hs = GetHouseSpecs(house_id);
|
||||||
if (HASBIT(hs->callback_mask, CBM_HOUSE_COLOUR)) {
|
if (HASBIT(hs->callback_mask, CBM_HOUSE_COLOUR)) {
|
||||||
|
@ -343,10 +344,10 @@ void DrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte stage, Ho
|
||||||
ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
||||||
dtss->size_x, dtss->size_y,
|
dtss->size_x, dtss->size_y,
|
||||||
dtss->size_z, ti->z + dtss->delta_z,
|
dtss->size_z, ti->z + dtss->delta_z,
|
||||||
HASBIT(_transparent_opt, TO_HOUSES)
|
IsTransparencySet(TO_HOUSES)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
AddChildSpriteScreen(image, pal, (byte)dtss->delta_x, (byte)dtss->delta_y, HASBIT(_transparent_opt, TO_HOUSES));
|
AddChildSpriteScreen(image, pal, (byte)dtss->delta_x, (byte)dtss->delta_y, IsTransparencySet(TO_HOUSES));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Based on newhouses equivalent, but adapted for newindustries
|
* Based on newhouses equivalent, but adapted for newindustries
|
||||||
|
@ -195,10 +196,10 @@ void IndustryDrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte r
|
||||||
ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
||||||
dtss->size_x, dtss->size_y,
|
dtss->size_x, dtss->size_y,
|
||||||
dtss->size_z, ti->z + dtss->delta_z,
|
dtss->size_z, ti->z + dtss->delta_z,
|
||||||
!HASBIT(image, SPRITE_MODIFIER_OPAQUE) && HASBIT(_transparent_opt, TO_INDUSTRIES)
|
!HASBIT(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_INDUSTRIES)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
AddChildSpriteScreen(image, pal, (byte)dtss->delta_x, (byte)dtss->delta_y, HASBIT(_transparent_opt, TO_INDUSTRIES));
|
AddChildSpriteScreen(image, pal, (byte)dtss->delta_x, (byte)dtss->delta_y, IsTransparencySet(TO_INDUSTRIES));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
#include "date.h"
|
#include "date.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
/** @file news_gui.cpp
|
/** @file news_gui.cpp
|
||||||
*
|
*
|
||||||
|
@ -137,10 +138,10 @@ static void NewsWindowProc(Window *w, WindowEvent *e)
|
||||||
ni->string_id, w->width - 4);
|
ni->string_id, w->width - 4);
|
||||||
} else {
|
} else {
|
||||||
/* Back up transparency options to draw news view */
|
/* Back up transparency options to draw news view */
|
||||||
byte to_backup = _transparent_opt;
|
TransparencyOptionBits to_backup = _transparency_opt;
|
||||||
_transparent_opt = 0;
|
_transparency_opt = 0;
|
||||||
DrawWindowViewport(w);
|
DrawWindowViewport(w);
|
||||||
_transparent_opt = to_backup;
|
_transparency_opt = to_backup;
|
||||||
|
|
||||||
/* Shade the viewport into gray, or color*/
|
/* Shade the viewport into gray, or color*/
|
||||||
vp = w->viewport;
|
vp = w->viewport;
|
||||||
|
|
|
@ -321,9 +321,6 @@ static void LoadIntroGame()
|
||||||
{
|
{
|
||||||
_game_mode = GM_MENU;
|
_game_mode = GM_MENU;
|
||||||
|
|
||||||
/* Clear transparency options */
|
|
||||||
_transparent_opt = 0;
|
|
||||||
|
|
||||||
_opt_ptr = &_opt_newgame;
|
_opt_ptr = &_opt_newgame;
|
||||||
ResetGRFConfig(false);
|
ResetGRFConfig(false);
|
||||||
|
|
||||||
|
|
|
@ -187,17 +187,6 @@ enum {
|
||||||
DO_WAYPOINTS = 6,
|
DO_WAYPOINTS = 6,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
|
||||||
TO_SIGNS,
|
|
||||||
TO_TREES,
|
|
||||||
TO_HOUSES,
|
|
||||||
TO_INDUSTRIES,
|
|
||||||
TO_BUILDINGS,
|
|
||||||
TO_BRIDGES,
|
|
||||||
TO_STRUCTURES,
|
|
||||||
TO_LOADING,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Landscape types */
|
/* Landscape types */
|
||||||
enum {
|
enum {
|
||||||
LT_TEMPERATE = 0,
|
LT_TEMPERATE = 0,
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "train.h"
|
#include "train.h"
|
||||||
#include "misc/autoptr.hpp"
|
#include "misc/autoptr.hpp"
|
||||||
#include "autoslope.h"
|
#include "autoslope.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
const byte _track_sloped_sprites[14] = {
|
const byte _track_sloped_sprites[14] = {
|
||||||
14, 15, 22, 13,
|
14, 15, 22, 13,
|
||||||
|
@ -1755,7 +1756,7 @@ default_waypoint:
|
||||||
image += relocation;
|
image += relocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HASBIT(_transparent_opt, TO_BUILDINGS) && HASBIT(image, PALETTE_MODIFIER_COLOR)) {
|
if (!IsTransparencySet(TO_BUILDINGS) && HASBIT(image, PALETTE_MODIFIER_COLOR)) {
|
||||||
pal = _drawtile_track_palette;
|
pal = _drawtile_track_palette;
|
||||||
} else {
|
} else {
|
||||||
pal = dtss->pal;
|
pal = dtss->pal;
|
||||||
|
@ -1767,7 +1768,7 @@ default_waypoint:
|
||||||
ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
||||||
dtss->size_x, dtss->size_y,
|
dtss->size_x, dtss->size_y,
|
||||||
dtss->size_z, ti->z + dtss->delta_z,
|
dtss->size_z, ti->z + dtss->delta_z,
|
||||||
HASBIT(_transparent_opt, TO_BUILDINGS)
|
IsTransparencySet(TO_BUILDINGS)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y);
|
AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y);
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "tunnel_map.h"
|
#include "tunnel_map.h"
|
||||||
#include "misc/autoptr.hpp"
|
#include "misc/autoptr.hpp"
|
||||||
#include "autoslope.h"
|
#include "autoslope.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
#define M(x) (1 << (x))
|
#define M(x) (1 << (x))
|
||||||
/* Level crossings may only be built on these slopes */
|
/* Level crossings may only be built on these slopes */
|
||||||
|
@ -946,7 +947,7 @@ static bool AlwaysDrawUnpavedRoads(TileIndex tile, Roadside roadside)
|
||||||
void DrawTramCatenary(TileInfo *ti, RoadBits tram)
|
void DrawTramCatenary(TileInfo *ti, RoadBits tram)
|
||||||
{
|
{
|
||||||
/* Don't draw the catenary under a low bridge */
|
/* Don't draw the catenary under a low bridge */
|
||||||
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !HASBIT(_transparent_opt, TO_BUILDINGS)) {
|
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_BUILDINGS)) {
|
||||||
uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
|
uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
|
||||||
|
|
||||||
if (height <= GetTileMaxZ(ti->tile) + TILE_HEIGHT) return;
|
if (height <= GetTileMaxZ(ti->tile) + TILE_HEIGHT) return;
|
||||||
|
@ -963,8 +964,8 @@ void DrawTramCatenary(TileInfo *ti, RoadBits tram)
|
||||||
front = SPR_TRAMWAY_BASE + _road_frontwire_sprites_1[tram];
|
front = SPR_TRAMWAY_BASE + _road_frontwire_sprites_1[tram];
|
||||||
}
|
}
|
||||||
|
|
||||||
AddSortableSpriteToDraw(back, PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, HASBIT(_transparent_opt, TO_BUILDINGS));
|
AddSortableSpriteToDraw(back, PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_BUILDINGS));
|
||||||
AddSortableSpriteToDraw(front, PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, HASBIT(_transparent_opt, TO_BUILDINGS));
|
AddSortableSpriteToDraw(front, PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_BUILDINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1120,7 +1121,7 @@ static void DrawTile_Road(TileInfo *ti)
|
||||||
SpriteID image = dtss->image;
|
SpriteID image = dtss->image;
|
||||||
SpriteID pal;
|
SpriteID pal;
|
||||||
|
|
||||||
if (!HASBIT(_transparent_opt, TO_BUILDINGS) && HASBIT(image, PALETTE_MODIFIER_COLOR)) {
|
if (!IsTransparencySet(TO_BUILDINGS) && HASBIT(image, PALETTE_MODIFIER_COLOR)) {
|
||||||
pal = palette;
|
pal = palette;
|
||||||
} else {
|
} else {
|
||||||
pal = PAL_NONE;
|
pal = PAL_NONE;
|
||||||
|
@ -1131,7 +1132,7 @@ static void DrawTile_Road(TileInfo *ti)
|
||||||
ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
||||||
dtss->size_x, dtss->size_y,
|
dtss->size_x, dtss->size_y,
|
||||||
dtss->size_z, ti->z,
|
dtss->size_z, ti->z,
|
||||||
HASBIT(_transparent_opt, TO_BUILDINGS)
|
IsTransparencySet(TO_BUILDINGS)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#include "fontcache.h"
|
#include "fontcache.h"
|
||||||
#endif
|
#endif
|
||||||
#include "spritecache.h"
|
#include "spritecache.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
/** The patch values that are used for new games and/or modified in config file */
|
/** The patch values that are used for new games and/or modified in config file */
|
||||||
Patches _patches_newgame;
|
Patches _patches_newgame;
|
||||||
|
@ -1275,6 +1276,7 @@ static const SettingDescGlobVarList _misc_settings[] = {
|
||||||
#endif
|
#endif
|
||||||
SDTG_VAR("sprite_cache_size",SLE_UINT, S, 0, _sprite_cache_size, 4, 1, 64, 0, STR_NULL, NULL),
|
SDTG_VAR("sprite_cache_size",SLE_UINT, S, 0, _sprite_cache_size, 4, 1, 64, 0, STR_NULL, NULL),
|
||||||
SDTG_VAR("player_face", SLE_UINT32, S, 0, _player_face, 0,0,0xFFFFFFFF,0, STR_NULL, NULL),
|
SDTG_VAR("player_face", SLE_UINT32, S, 0, _player_face, 0,0,0xFFFFFFFF,0, STR_NULL, NULL),
|
||||||
|
SDTG_VAR("transparency_options", SLE_UINT8, S, 0, _transparency_opt, 0, 0,0xFF,0, STR_NULL, NULL),
|
||||||
SDTG_END()
|
SDTG_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include "cargotype.h"
|
#include "cargotype.h"
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
#include "autoslope.h"
|
#include "autoslope.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
DEFINE_OLD_POOL_GENERIC(Station, Station)
|
DEFINE_OLD_POOL_GENERIC(Station, Station)
|
||||||
DEFINE_OLD_POOL_GENERIC(RoadStop, RoadStop)
|
DEFINE_OLD_POOL_GENERIC(RoadStop, RoadStop)
|
||||||
|
@ -2138,7 +2139,7 @@ static void DrawTile_Station(TileInfo *ti)
|
||||||
}
|
}
|
||||||
|
|
||||||
SpriteID pal;
|
SpriteID pal;
|
||||||
if (!HASBIT(_transparent_opt, TO_BUILDINGS) && HASBIT(image, PALETTE_MODIFIER_COLOR)) {
|
if (!IsTransparencySet(TO_BUILDINGS) && HASBIT(image, PALETTE_MODIFIER_COLOR)) {
|
||||||
pal = palette;
|
pal = palette;
|
||||||
} else {
|
} else {
|
||||||
pal = dtss->pal;
|
pal = dtss->pal;
|
||||||
|
@ -2150,10 +2151,10 @@ static void DrawTile_Station(TileInfo *ti)
|
||||||
ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
||||||
dtss->size_x, dtss->size_y,
|
dtss->size_x, dtss->size_y,
|
||||||
dtss->size_z, ti->z + dtss->delta_z,
|
dtss->size_z, ti->z + dtss->delta_z,
|
||||||
HASBIT(_transparent_opt, TO_BUILDINGS)
|
IsTransparencySet(TO_BUILDINGS)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y, HASBIT(_transparent_opt, TO_BUILDINGS));
|
AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y, IsTransparencySet(TO_BUILDINGS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "date.h"
|
#include "date.h"
|
||||||
#include "texteff.hpp"
|
#include "texteff.hpp"
|
||||||
#include "video/video_driver.hpp"
|
#include "video/video_driver.hpp"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MAX_TEXTMESSAGE_LENGTH = 200,
|
MAX_TEXTMESSAGE_LENGTH = 200,
|
||||||
|
@ -390,7 +391,7 @@ void DrawTextEffects(DrawPixelInfo *dpi)
|
||||||
dpi->top <= te->bottom &&
|
dpi->top <= te->bottom &&
|
||||||
dpi->left + dpi->width > te->x &&
|
dpi->left + dpi->width > te->x &&
|
||||||
dpi->top + dpi->height > te->y) {
|
dpi->top + dpi->height > te->y) {
|
||||||
if (te->mode == TE_RISING || (_patches.loading_indicators && !HASBIT(_transparent_opt, TO_LOADING))) {
|
if (te->mode == TE_RISING || (_patches.loading_indicators && !IsTransparencySet(TO_LOADING))) {
|
||||||
AddStringToDraw(te->x, te->y, te->string_id, te->params_1, te->params_2);
|
AddStringToDraw(te->x, te->y, te->string_id, te->params_1, te->params_2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -405,7 +406,7 @@ void DrawTextEffects(DrawPixelInfo *dpi)
|
||||||
dpi->top <= te->bottom * 2 - te->y &&
|
dpi->top <= te->bottom * 2 - te->y &&
|
||||||
dpi->left + dpi->width > te->x &&
|
dpi->left + dpi->width > te->x &&
|
||||||
dpi->top + dpi->height > te->y) {
|
dpi->top + dpi->height > te->y) {
|
||||||
if (te->mode == TE_RISING || (_patches.loading_indicators && !HASBIT(_transparent_opt, TO_LOADING))) {
|
if (te->mode == TE_RISING || (_patches.loading_indicators && !IsTransparencySet(TO_LOADING))) {
|
||||||
AddStringToDraw(te->x, te->y, (StringID)(te->string_id - 1), te->params_1, te->params_2);
|
AddStringToDraw(te->x, te->y, (StringID)(te->string_id - 1), te->params_1, te->params_2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include "misc/autoptr.hpp"
|
#include "misc/autoptr.hpp"
|
||||||
#include "autoslope.h"
|
#include "autoslope.h"
|
||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
/* Initialize the town-pool */
|
/* Initialize the town-pool */
|
||||||
DEFINE_OLD_POOL_GENERIC(Town, Town)
|
DEFINE_OLD_POOL_GENERIC(Town, Town)
|
||||||
|
@ -183,10 +184,10 @@ static void DrawTile_Town(TileInfo *ti)
|
||||||
dcts->height,
|
dcts->height,
|
||||||
dcts->dz,
|
dcts->dz,
|
||||||
ti->z,
|
ti->z,
|
||||||
HASBIT(_transparent_opt, TO_HOUSES)
|
IsTransparencySet(TO_HOUSES)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (HASBIT(_transparent_opt, TO_HOUSES)) return;
|
if (IsTransparencySet(TO_HOUSES)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/** @file transparency.h */
|
||||||
|
|
||||||
|
#ifndef TRANSPARENCY_H
|
||||||
|
#define TRANSPARENCY_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transparency option bits: which position in _transparency_opt stands for which transparency.
|
||||||
|
* If you change the order, change the order of the ShowTransparencyToolbar() stuff in transparency_gui.cpp too.
|
||||||
|
* If you add or remove an option don't forget to change the transparency 'hot keys' in main_gui.cpp.
|
||||||
|
* If you add an option and have more then 8, change the typedef TransparencyOptionBits and
|
||||||
|
* the save stuff (e.g. SLE_UINT8 to SLE_UINT16) in settings.cpp .
|
||||||
|
*/
|
||||||
|
enum TransparencyOption {
|
||||||
|
TO_SIGNS = 0, ///< signs
|
||||||
|
TO_TREES, ///< trees
|
||||||
|
TO_HOUSES, ///< town buildings
|
||||||
|
TO_INDUSTRIES, ///< industries
|
||||||
|
TO_BUILDINGS, ///< player buildings - depots, stations, HQ, ...
|
||||||
|
TO_BRIDGES, ///< bridges
|
||||||
|
TO_STRUCTURES, ///< unmovable structures
|
||||||
|
TO_LOADING, ///< loading indicators
|
||||||
|
TO_END,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef byte TransparencyOptionBits; ///< transparency option bits
|
||||||
|
extern TransparencyOptionBits _transparency_opt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the transparency option bit is set
|
||||||
|
* and if we aren't in the game menu (there's never transparency)
|
||||||
|
*
|
||||||
|
* @param to the structure which transparency option is ask for
|
||||||
|
*/
|
||||||
|
static inline bool IsTransparencySet(TransparencyOption to)
|
||||||
|
{
|
||||||
|
return (HASBIT(_transparency_opt, to) && _game_mode != GM_MENU);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle the transparency option bit
|
||||||
|
*
|
||||||
|
* @param to the structure which transparency option is toggle
|
||||||
|
*/
|
||||||
|
static inline void ToggleTransparency(TransparencyOption to)
|
||||||
|
{
|
||||||
|
TOGGLEBIT(_transparency_opt, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Toggle all transparency options (except signs) or restore the stored transparencies */
|
||||||
|
static inline void ResetRestoreAllTransparency()
|
||||||
|
{
|
||||||
|
/* backup of the original transparencies or if all transparencies false toggle them to true */
|
||||||
|
static TransparencyOptionBits trans_opt = ~0;
|
||||||
|
|
||||||
|
if (_transparency_opt == 0) {
|
||||||
|
/* no structure is transparent, so restore the old transparency if present otherwise set all true */
|
||||||
|
_transparency_opt = trans_opt;
|
||||||
|
} else {
|
||||||
|
/* any structure is transparent, so store current transparency settings and reset it */
|
||||||
|
trans_opt = _transparency_opt;
|
||||||
|
_transparency_opt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MarkWholeScreenDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* TRANSPARENCY_H */
|
|
@ -11,6 +11,9 @@
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
|
TransparencyOptionBits _transparency_opt;
|
||||||
|
|
||||||
enum TransparencyToolbarWidgets{
|
enum TransparencyToolbarWidgets{
|
||||||
/* Widgets not toggled when pressing the X key */
|
/* Widgets not toggled when pressing the X key */
|
||||||
|
@ -27,16 +30,6 @@ enum TransparencyToolbarWidgets{
|
||||||
TTW_WIDGET_END, ///< End of toggle buttons
|
TTW_WIDGET_END, ///< End of toggle buttons
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Toggle the bits of the transparencies variable
|
|
||||||
* when clicking on a widget, and play a sound
|
|
||||||
* @param widget been clicked.
|
|
||||||
*/
|
|
||||||
static void Transparent_Click(byte widget)
|
|
||||||
{
|
|
||||||
TOGGLEBIT(_transparent_opt, widget);
|
|
||||||
SndPlayFx(SND_15_BEEP);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
|
static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
|
||||||
{
|
{
|
||||||
switch (e->event) {
|
switch (e->event) {
|
||||||
|
@ -44,14 +37,16 @@ static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
|
||||||
/* must be sure that the widgets show the transparency variable changes
|
/* must be sure that the widgets show the transparency variable changes
|
||||||
* also when we use shortcuts */
|
* also when we use shortcuts */
|
||||||
for (uint i = TTW_WIDGET_SIGNS; i < TTW_WIDGET_END; i++) {
|
for (uint i = TTW_WIDGET_SIGNS; i < TTW_WIDGET_END; i++) {
|
||||||
SetWindowWidgetLoweredState(w, i, HASBIT(_transparent_opt, i - TTW_WIDGET_SIGNS));
|
SetWindowWidgetLoweredState(w, i, IsTransparencySet((TransparencyOption)(i - TTW_WIDGET_SIGNS)));
|
||||||
}
|
}
|
||||||
DrawWindowWidgets(w);
|
DrawWindowWidgets(w);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_CLICK:
|
case WE_CLICK:
|
||||||
if (e->we.click.widget >= TTW_WIDGET_SIGNS) {
|
if (e->we.click.widget >= TTW_WIDGET_SIGNS) {
|
||||||
Transparent_Click(e->we.click.widget - TTW_WIDGET_SIGNS);
|
/* toggle the bit of the transparencies variable when clicking on a widget, and play a sound */
|
||||||
|
ToggleTransparency((TransparencyOption)(e->we.click.widget - TTW_WIDGET_SIGNS));
|
||||||
|
SndPlayFx(SND_15_BEEP);
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
#include "genworld.h"
|
#include "genworld.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of tree placer algorithm.
|
* List of tree placer algorithm.
|
||||||
|
@ -427,7 +428,7 @@ static void DrawTile_Trees(TileInfo *ti)
|
||||||
|
|
||||||
StartSpriteCombine();
|
StartSpriteCombine();
|
||||||
|
|
||||||
if (!HASBIT(_transparent_opt, TO_TREES) || !_patches.invisible_trees) {
|
if (!IsTransparencySet(TO_TREES) || !_patches.invisible_trees) {
|
||||||
TreeListEnt te[4];
|
TreeListEnt te[4];
|
||||||
uint i;
|
uint i;
|
||||||
|
|
||||||
|
@ -460,7 +461,7 @@ static void DrawTile_Trees(TileInfo *ti)
|
||||||
|
|
||||||
if (tep == NULL) break;
|
if (tep == NULL) break;
|
||||||
|
|
||||||
AddSortableSpriteToDraw(tep->image, tep->pal, ti->x + tep->x, ti->y + tep->y, 16 - tep->x, 16 - tep->y, 0x30, z, HASBIT(_transparent_opt, TO_TREES), -tep->x, -tep->y);
|
AddSortableSpriteToDraw(tep->image, tep->pal, ti->x + tep->x, ti->y + tep->y, 16 - tep->x, 16 - tep->y, 0x30, z, IsTransparencySet(TO_TREES), -tep->x, -tep->y);
|
||||||
tep->image = 0;
|
tep->image = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "date.h"
|
#include "date.h"
|
||||||
#include "newgrf_sound.h"
|
#include "newgrf_sound.h"
|
||||||
#include "autoslope.h"
|
#include "autoslope.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
#include "table/bridge_land.h"
|
#include "table/bridge_land.h"
|
||||||
|
|
||||||
|
@ -858,12 +859,12 @@ static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo* ti, Axis
|
||||||
for (int cur_z = z_bridge; cur_z >= front_height || cur_z >= back_height; cur_z -= TILE_HEIGHT) {
|
for (int cur_z = z_bridge; cur_z >= front_height || cur_z >= back_height; cur_z -= TILE_HEIGHT) {
|
||||||
/* Draw front facing pillar */
|
/* Draw front facing pillar */
|
||||||
if (cur_z >= front_height) {
|
if (cur_z >= front_height) {
|
||||||
AddSortableSpriteToDraw(image, psid->pal, x, y, w, h, BB_HEIGHT_UNDER_BRIDGE - 5, cur_z, HASBIT(_transparent_opt, TO_BRIDGES), 0, 0, -5);
|
AddSortableSpriteToDraw(image, psid->pal, x, y, w, h, BB_HEIGHT_UNDER_BRIDGE - 5, cur_z, IsTransparencySet(TO_BRIDGES), 0, 0, -5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw back facing pillar, but not the highest part directly under the bridge-floor */
|
/* Draw back facing pillar, but not the highest part directly under the bridge-floor */
|
||||||
if (drawfarpillar && cur_z >= back_height && cur_z < z_bridge - TILE_HEIGHT) {
|
if (drawfarpillar && cur_z >= back_height && cur_z < z_bridge - TILE_HEIGHT) {
|
||||||
AddSortableSpriteToDraw(image, psid->pal, x_back, y_back, w, h, BB_HEIGHT_UNDER_BRIDGE - 5, cur_z, HASBIT(_transparent_opt, TO_BRIDGES), 0, 0, -5);
|
AddSortableSpriteToDraw(image, psid->pal, x_back, y_back, w, h, BB_HEIGHT_UNDER_BRIDGE - 5, cur_z, IsTransparencySet(TO_BRIDGES), 0, 0, -5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -897,16 +898,16 @@ static void DrawBridgeTramBits(int x, int y, byte z, int offset, bool overlay)
|
||||||
|
|
||||||
/* The sprites under the vehicles are drawn as SpriteCombine. StartSpriteCombine() has already been called
|
/* The sprites under the vehicles are drawn as SpriteCombine. StartSpriteCombine() has already been called
|
||||||
* The bounding boxes here are the same as for bridge front/roof */
|
* The bounding boxes here are the same as for bridge front/roof */
|
||||||
AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, x, y, size_x[offset], size_y[offset], 0x28, z, HASBIT(_transparent_opt, TO_BRIDGES));
|
AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, x, y, size_x[offset], size_y[offset], 0x28, z, IsTransparencySet(TO_BRIDGES));
|
||||||
|
|
||||||
AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset], PAL_NONE, x, y, size_x[offset], size_y[offset], 0x28, z, HASBIT(_transparent_opt, TO_BUILDINGS));
|
AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset], PAL_NONE, x, y, size_x[offset], size_y[offset], 0x28, z, IsTransparencySet(TO_BUILDINGS));
|
||||||
|
|
||||||
/* Start a new SpriteCombine for the front part */
|
/* Start a new SpriteCombine for the front part */
|
||||||
EndSpriteCombine();
|
EndSpriteCombine();
|
||||||
StartSpriteCombine();
|
StartSpriteCombine();
|
||||||
|
|
||||||
/* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */
|
/* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */
|
||||||
AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + front_offsets[offset], PAL_NONE, x, y, size_x[offset] + front_bb_offset_x[offset], size_y[offset] + front_bb_offset_y[offset], 0x28, z, HASBIT(_transparent_opt, TO_BUILDINGS), front_bb_offset_x[offset], front_bb_offset_y[offset]);
|
AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + front_offsets[offset], PAL_NONE, x, y, size_x[offset] + front_bb_offset_x[offset], size_y[offset] + front_bb_offset_y[offset], 0x28, z, IsTransparencySet(TO_BUILDINGS), front_bb_offset_x[offset], front_bb_offset_y[offset]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -969,7 +970,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
|
||||||
|
|
||||||
catenary = true;
|
catenary = true;
|
||||||
StartSpriteCombine();
|
StartSpriteCombine();
|
||||||
AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + dir, PAL_NONE, ti->x, ti->y, BB_data[10], BB_data[11], TILE_HEIGHT, ti->z, HASBIT(_transparent_opt, TO_BUILDINGS), BB_data[8], BB_data[9], BB_Z_SEPARATOR);
|
AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + dir, PAL_NONE, ti->x, ti->y, BB_data[10], BB_data[11], TILE_HEIGHT, ti->z, IsTransparencySet(TO_BUILDINGS), BB_data[8], BB_data[9], BB_Z_SEPARATOR);
|
||||||
}
|
}
|
||||||
} else if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) {
|
} else if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) {
|
||||||
DrawCatenary(ti);
|
DrawCatenary(ti);
|
||||||
|
@ -1028,7 +1029,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
|
||||||
* it doesn't disappear behind it
|
* it doesn't disappear behind it
|
||||||
*/
|
*/
|
||||||
AddSortableSpriteToDraw(
|
AddSortableSpriteToDraw(
|
||||||
psid->sprite, psid->pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z, HASBIT(_transparent_opt, TO_BRIDGES)
|
psid->sprite, psid->pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z, IsTransparencySet(TO_BRIDGES)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (GetBridgeTransportType(ti->tile) == TRANSPORT_ROAD) {
|
if (GetBridgeTransportType(ti->tile) == TRANSPORT_ROAD) {
|
||||||
|
@ -1156,9 +1157,9 @@ void DrawBridgeMiddle(const TileInfo* ti)
|
||||||
|
|
||||||
/* Draw floor and far part of bridge*/
|
/* Draw floor and far part of bridge*/
|
||||||
if (axis == AXIS_X) {
|
if (axis == AXIS_X) {
|
||||||
AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 1, 0x28, z, HASBIT(_transparent_opt, TO_BRIDGES), 0, 0, BRIDGE_Z_START);
|
AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 1, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START);
|
||||||
} else {
|
} else {
|
||||||
AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 1, 16, 0x28, z, HASBIT(_transparent_opt, TO_BRIDGES), 0, 0, BRIDGE_Z_START);
|
AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 1, 16, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START);
|
||||||
}
|
}
|
||||||
|
|
||||||
psid++;
|
psid++;
|
||||||
|
@ -1180,10 +1181,10 @@ void DrawBridgeMiddle(const TileInfo* ti)
|
||||||
/* draw roof, the component of the bridge which is logically between the vehicle and the camera */
|
/* draw roof, the component of the bridge which is logically between the vehicle and the camera */
|
||||||
if (axis == AXIS_X) {
|
if (axis == AXIS_X) {
|
||||||
y += 12;
|
y += 12;
|
||||||
if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 4, 0x28, z, HASBIT(_transparent_opt, TO_BRIDGES), 0, 3, BRIDGE_Z_START);
|
if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 4, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 3, BRIDGE_Z_START);
|
||||||
} else {
|
} else {
|
||||||
x += 12;
|
x += 12;
|
||||||
if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 4, 16, 0x28, z, HASBIT(_transparent_opt, TO_BRIDGES), 3, 0, BRIDGE_Z_START);
|
if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 4, 16, 0x28, z, IsTransparencySet(TO_BRIDGES), 3, 0, BRIDGE_Z_START);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw TramFront as SpriteCombine */
|
/* Draw TramFront as SpriteCombine */
|
||||||
|
@ -1195,7 +1196,7 @@ void DrawBridgeMiddle(const TileInfo* ti)
|
||||||
if (psid->sprite != 0) {
|
if (psid->sprite != 0) {
|
||||||
SpriteID image = psid->sprite;
|
SpriteID image = psid->sprite;
|
||||||
SpriteID pal = psid->pal;
|
SpriteID pal = psid->pal;
|
||||||
if (HASBIT(_transparent_opt, TO_BRIDGES)) {
|
if (IsTransparencySet(TO_BRIDGES)) {
|
||||||
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
|
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
|
||||||
pal = PALETTE_TO_TRANSPARENT;
|
pal = PALETTE_TO_TRANSPARENT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "genworld.h"
|
#include "genworld.h"
|
||||||
#include "bridge.h"
|
#include "bridge.h"
|
||||||
#include "autoslope.h"
|
#include "autoslope.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
/** Destroy a HQ.
|
/** Destroy a HQ.
|
||||||
* During normal gameplay you can only implicitely destroy a HQ when you are
|
* During normal gameplay you can only implicitely destroy a HQ when you are
|
||||||
|
@ -129,7 +130,7 @@ static void DrawTile_Unmovable(TileInfo *ti)
|
||||||
AddSortableSpriteToDraw(
|
AddSortableSpriteToDraw(
|
||||||
dtus->image, PAL_NONE, ti->x | dtus->subcoord_x, ti->y | dtus->subcoord_y,
|
dtus->image, PAL_NONE, ti->x | dtus->subcoord_x, ti->y | dtus->subcoord_y,
|
||||||
dtus->width, dtus->height, dtus->z_size, ti->z,
|
dtus->width, dtus->height, dtus->z_size, ti->z,
|
||||||
HASBIT(_transparent_opt, TO_STRUCTURES)
|
IsTransparencySet(TO_STRUCTURES)
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +141,7 @@ static void DrawTile_Unmovable(TileInfo *ti)
|
||||||
|
|
||||||
DrawGroundSprite(SPR_CONCRETE_GROUND, PAL_NONE);
|
DrawGroundSprite(SPR_CONCRETE_GROUND, PAL_NONE);
|
||||||
|
|
||||||
AddSortableSpriteToDraw(SPR_STATUE_COMPANY, PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), ti->x, ti->y, 16, 16, 25, ti->z, HASBIT(_transparent_opt, TO_STRUCTURES));
|
AddSortableSpriteToDraw(SPR_STATUE_COMPANY, PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), ti->x, ti->y, 16, 16, 25, ti->z, IsTransparencySet(TO_STRUCTURES));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UNMOVABLE_OWNED_LAND:
|
case UNMOVABLE_OWNED_LAND:
|
||||||
|
@ -172,7 +173,7 @@ static void DrawTile_Unmovable(TileInfo *ti)
|
||||||
ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
||||||
dtss->size_x, dtss->size_y,
|
dtss->size_x, dtss->size_y,
|
||||||
dtss->size_z, ti->z + dtss->delta_z,
|
dtss->size_z, ti->z + dtss->delta_z,
|
||||||
HASBIT(_transparent_opt, TO_STRUCTURES)
|
IsTransparencySet(TO_STRUCTURES)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -290,7 +290,6 @@ VARDEF bool _do_autosave;
|
||||||
VARDEF int _autosave_ctr;
|
VARDEF int _autosave_ctr;
|
||||||
|
|
||||||
VARDEF byte _display_opt;
|
VARDEF byte _display_opt;
|
||||||
VARDEF byte _transparent_opt;
|
|
||||||
VARDEF int _caret_timer;
|
VARDEF int _caret_timer;
|
||||||
VARDEF uint32 _news_display_opt;
|
VARDEF uint32 _news_display_opt;
|
||||||
VARDEF bool _news_ticker_sound;
|
VARDEF bool _news_ticker_sound;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "roadveh.h"
|
#include "roadveh.h"
|
||||||
#include "vehicle_gui.h"
|
#include "vehicle_gui.h"
|
||||||
#include "blitter/factory.hpp"
|
#include "blitter/factory.hpp"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
#define VIEWPORT_DRAW_MEM (65536 * 2)
|
#define VIEWPORT_DRAW_MEM (65536 * 2)
|
||||||
|
|
||||||
|
@ -1483,10 +1484,10 @@ static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDraw *ss
|
||||||
|
|
||||||
/* Draw the rectangle if 'tranparent station signs' is off,
|
/* Draw the rectangle if 'tranparent station signs' is off,
|
||||||
* or if we are drawing a general text sign (STR_2806) */
|
* or if we are drawing a general text sign (STR_2806) */
|
||||||
if (!HASBIT(_transparent_opt, TO_SIGNS) || ss->string == STR_2806) {
|
if (!IsTransparencySet(TO_SIGNS) || ss->string == STR_2806) {
|
||||||
DrawFrameRect(
|
DrawFrameRect(
|
||||||
x, y, x + w, bottom, ss->color,
|
x, y, x + w, bottom, ss->color,
|
||||||
HASBIT(_transparent_opt, TO_SIGNS) ? FR_TRANSPARENT : FR_NONE
|
IsTransparencySet(TO_SIGNS) ? FR_TRANSPARENT : FR_NONE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1495,7 +1496,7 @@ static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDraw *ss
|
||||||
SetDParam(1, ss->params[1]);
|
SetDParam(1, ss->params[1]);
|
||||||
/* if we didn't draw a rectangle, or if transparant building is on,
|
/* if we didn't draw a rectangle, or if transparant building is on,
|
||||||
* draw the text in the color the rectangle would have */
|
* draw the text in the color the rectangle would have */
|
||||||
if (HASBIT(_transparent_opt, TO_SIGNS) && ss->string != STR_2806 && ss->width != 0) {
|
if (IsTransparencySet(TO_SIGNS) && ss->string != STR_2806 && ss->width != 0) {
|
||||||
/* Real colors need the IS_PALETTE_COLOR flag
|
/* Real colors need the IS_PALETTE_COLOR flag
|
||||||
* otherwise colors from _string_colormap are assumed. */
|
* otherwise colors from _string_colormap are assumed. */
|
||||||
colour = _colour_gradient[ss->color][6] | IS_PALETTE_COLOR;
|
colour = _colour_gradient[ss->color][6] | IS_PALETTE_COLOR;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "newgrf.h"
|
#include "newgrf.h"
|
||||||
#include "newgrf_canal.h"
|
#include "newgrf_canal.h"
|
||||||
#include "misc/autoptr.hpp"
|
#include "misc/autoptr.hpp"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
/** Array for the shore sprites */
|
/** Array for the shore sprites */
|
||||||
static const SpriteID _water_shore_sprites[] = {
|
static const SpriteID _water_shore_sprites[] = {
|
||||||
|
@ -449,7 +450,7 @@ static void DrawWaterStuff(const TileInfo *ti, const WaterDrawTileStruct *wdts,
|
||||||
ti->x + wdts->delta_x, ti->y + wdts->delta_y,
|
ti->x + wdts->delta_x, ti->y + wdts->delta_y,
|
||||||
wdts->width, wdts->height,
|
wdts->width, wdts->height,
|
||||||
wdts->unk, ti->z + wdts->delta_z,
|
wdts->unk, ti->z + wdts->delta_z,
|
||||||
HASBIT(_transparent_opt, TO_BUILDINGS));
|
IsTransparencySet(TO_BUILDINGS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue