Replace TileSIze[XY] by PixeltileSize
This commit is contained in:
parent
f9ae39e6a6
commit
7828cf1020
27 changed files with 367 additions and 377 deletions
src
action
editor
game
include
map
sound
stratagus
ui
unit
video
|
@ -139,10 +139,10 @@ void HandleActionFollow(CUnit &unit)
|
|||
PlayGameSound(SoundForName("invisibility"), MaxSampleVolume);
|
||||
// FIXME: MissileTypeByIdent() should be called once
|
||||
MakeMissile(MissileTypeByIdent("missile-normal-spell"),
|
||||
unit.tilePos.x * TileSizeX + TileSizeX / 2,
|
||||
unit.tilePos.y * TileSizeY + TileSizeY / 2,
|
||||
unit.tilePos.x * TileSizeX + TileSizeX / 2,
|
||||
unit.tilePos.y * TileSizeY + TileSizeY / 2);
|
||||
unit.tilePos.x * PixelTileSize.x + PixelTileSize.x / 2,
|
||||
unit.tilePos.y * PixelTileSize.y + PixelTileSize.y / 2,
|
||||
unit.tilePos.x * PixelTileSize.x + PixelTileSize.x / 2,
|
||||
unit.tilePos.y * PixelTileSize.y + PixelTileSize.y / 2);
|
||||
#endif
|
||||
unit.ClearAction();
|
||||
|
||||
|
|
|
@ -137,8 +137,8 @@ int DoActionMove(CUnit &unit)
|
|||
}
|
||||
}
|
||||
|
||||
unit.IX = -posd.x * TileSizeX;
|
||||
unit.IY = -posd.y * TileSizeY;
|
||||
unit.IX = -posd.x * PixelTileSize.x;
|
||||
unit.IY = -posd.y * PixelTileSize.y;
|
||||
unit.Frame = unit.Type->StillFrame;
|
||||
UnitHeadingFromDeltaXY(unit, posd);
|
||||
} else {
|
||||
|
|
|
@ -483,8 +483,8 @@ static int CalculateVisibleIcons(bool tiles = false)
|
|||
int count;
|
||||
|
||||
if (tiles) {
|
||||
w = TileSizeX;//+2,
|
||||
h = TileSizeY;//+2
|
||||
w = PixelTileSize.x;//+2,
|
||||
h = PixelTileSize.y;//+2
|
||||
} else {
|
||||
w = IconWidth;
|
||||
h = IconHeight;
|
||||
|
@ -684,19 +684,19 @@ static void DrawTileIcon(unsigned tilenum, unsigned x, unsigned y, unsigned flag
|
|||
|
||||
color = (flags & IconActive) ? ColorGray : ColorBlack;
|
||||
|
||||
Video.DrawRectangleClip(color, x, y, TileSizeX + 7, TileSizeY + 7);
|
||||
Video.DrawRectangleClip(ColorBlack, x + 1, y + 1, TileSizeX + 5, TileSizeY + 5);
|
||||
Video.DrawRectangleClip(color, x, y, PixelTileSize.x + 7, PixelTileSize.y+ 7);
|
||||
Video.DrawRectangleClip(ColorBlack, x + 1, y + 1, PixelTileSize.x + 5, PixelTileSize.y + 5);
|
||||
|
||||
Video.DrawVLine(ColorGray, x + TileSizeX + 4, y + 5, TileSizeY - 1); // _|
|
||||
Video.DrawVLine(ColorGray, x + TileSizeX + 5, y + 5, TileSizeY - 1);
|
||||
Video.DrawHLine(ColorGray, x + 5, y + TileSizeY + 4, TileSizeX + 1);
|
||||
Video.DrawHLine(ColorGray, x + 5, y + TileSizeY + 5, TileSizeX + 1);
|
||||
Video.DrawVLine(ColorGray, x + PixelTileSize.x + 4, y + 5, PixelTileSize.y - 1); // _|
|
||||
Video.DrawVLine(ColorGray, x + PixelTileSize.x + 5, y + 5, PixelTileSize.y - 1);
|
||||
Video.DrawHLine(ColorGray, x + 5, y + PixelTileSize.y + 4, PixelTileSize.x + 1);
|
||||
Video.DrawHLine(ColorGray, x + 5, y + PixelTileSize.y + 5, PixelTileSize.x + 1);
|
||||
|
||||
color = (flags & IconClicked) ? ColorGray : ColorWhite;
|
||||
Video.DrawHLine(color, x + 5, y + 3, TileSizeX + 1);
|
||||
Video.DrawHLine(color, x + 5, y + 4, TileSizeX + 1);
|
||||
Video.DrawVLine(color, x + 3, y + 3, TileSizeY + 3);
|
||||
Video.DrawVLine(color, x + 4, y + 3, TileSizeY + 3);
|
||||
Video.DrawHLine(color, x + 5, y + 3, PixelTileSize.x + 1);
|
||||
Video.DrawHLine(color, x + 5, y + 4, PixelTileSize.x + 1);
|
||||
Video.DrawVLine(color, x + 3, y + 3, PixelTileSize.y + 3);
|
||||
Video.DrawVLine(color, x + 4, y + 3, PixelTileSize.y + 3);
|
||||
|
||||
if (flags & IconClicked) {
|
||||
++x;
|
||||
|
@ -708,7 +708,7 @@ static void DrawTileIcon(unsigned tilenum, unsigned x, unsigned y, unsigned flag
|
|||
Map.TileGraphic->DrawFrameClip(Map.Tileset.Table[tilenum], x, y);
|
||||
|
||||
if (flags & IconSelected) {
|
||||
Video.DrawRectangleClip(ColorGreen, x, y, TileSizeX, TileSizeY);
|
||||
Video.DrawRectangleClip(ColorGreen, x, y, PixelTileSize.x, PixelTileSize.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -755,35 +755,35 @@ static void DrawTileIcons(void)
|
|||
i = Editor.TileIndex;
|
||||
Assert(Editor.TileIndex != -1);
|
||||
y = UI.ButtonPanel.Y + 24;
|
||||
while (y < UI.ButtonPanel.Y + ButtonPanelHeight - TileSizeY) {
|
||||
while (y < UI.ButtonPanel.Y + ButtonPanelHeight - PixelTileSize.y) {
|
||||
if (i >= (int)Editor.ShownTileTypes.size()) {
|
||||
break;
|
||||
}
|
||||
x = UI.ButtonPanel.X + 10;
|
||||
while (x < UI.ButtonPanel.X + ButtonPanelWidth - TileSizeX) {
|
||||
while (x < UI.ButtonPanel.X + ButtonPanelWidth - PixelTileSize.x) {
|
||||
if (i >= (int) Editor.ShownTileTypes.size()) {
|
||||
break;
|
||||
}
|
||||
tile = Editor.ShownTileTypes[i];
|
||||
|
||||
Map.TileGraphic->DrawFrameClip(Map.Tileset.Table[tile], x, y);
|
||||
Video.DrawRectangleClip(ColorGray, x, y, TileSizeX, TileSizeY);
|
||||
Video.DrawRectangleClip(ColorGray, x, y, PixelTileSize.x, PixelTileSize.y);
|
||||
|
||||
if (i == Editor.SelectedTileIndex) {
|
||||
Video.DrawRectangleClip(ColorGreen, x + 1, y + 1,
|
||||
TileSizeX-2, TileSizeY-2);
|
||||
PixelTileSize.x - 2, PixelTileSize.y - 2);
|
||||
}
|
||||
if (i == Editor.CursorTileIndex) {
|
||||
Video.DrawRectangleClip(ColorWhite, x - 1, y - 1,
|
||||
TileSizeX+2, TileSizeY+2);
|
||||
PixelTileSize.x + 2, PixelTileSize.y + 2);
|
||||
Editor.PopUpX = x;
|
||||
Editor.PopUpY = y;
|
||||
}
|
||||
|
||||
x += TileSizeX + 8;
|
||||
x += PixelTileSize.x + 8;
|
||||
++i;
|
||||
}
|
||||
y += TileSizeY + 2;
|
||||
y += PixelTileSize.y + 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -906,12 +906,12 @@ static void DrawMapCursor(void)
|
|||
SetClipping(UI.MouseViewport->X, UI.MouseViewport->Y,
|
||||
UI.MouseViewport->EndX, UI.MouseViewport->EndY);
|
||||
for (int j = 0; j < TileCursorSize; ++j) {
|
||||
const int ty = y + j * TileSizeY;
|
||||
const int ty = y + j * PixelTileSize.y;
|
||||
if (ty >= UI.MouseViewport->EndY) {
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < TileCursorSize; ++i) {
|
||||
const int tx = x + i * TileSizeX;
|
||||
const int tx = x + i * PixelTileSize.x;
|
||||
if (tx >= UI.MouseViewport->EndX) {
|
||||
break;
|
||||
}
|
||||
|
@ -919,8 +919,7 @@ static void DrawMapCursor(void)
|
|||
Map.Tileset.Table[Editor.ShownTileTypes[Editor.SelectedTileIndex]], tx, ty);
|
||||
}
|
||||
}
|
||||
Video.DrawRectangleClip(ColorWhite, x, y, TileSizeX * TileCursorSize,
|
||||
TileSizeY * TileCursorSize);
|
||||
Video.DrawRectangleClip(ColorWhite, x, y, PixelTileSize.x * TileCursorSize, PixelTileSize.y * TileCursorSize);
|
||||
PopClipping();
|
||||
} else {
|
||||
//
|
||||
|
@ -931,7 +930,7 @@ static void DrawMapCursor(void)
|
|||
PushClipping();
|
||||
SetClipping(UI.MouseViewport->X, UI.MouseViewport->Y,
|
||||
UI.MouseViewport->EndX, UI.MouseViewport->EndY);
|
||||
Video.DrawRectangleClip(ColorWhite, x, y, TileSizeX, TileSizeY);
|
||||
Video.DrawRectangleClip(ColorWhite, x, y, PixelTileSize.x, PixelTileSize.y);
|
||||
PopClipping();
|
||||
}
|
||||
}
|
||||
|
@ -956,8 +955,8 @@ static void DrawStartLocations()
|
|||
if (type) {
|
||||
DrawUnitType(*type, type->Sprite, i, 0, x, y);
|
||||
} else {
|
||||
Video.DrawLineClip(PlayerColors[i][0], x, y, x + TileSizeX, y + TileSizeY);
|
||||
Video.DrawLineClip(PlayerColors[i][0], x, y + TileSizeY, x + TileSizeX, y);
|
||||
Video.DrawLineClip(PlayerColors[i][0], x, y, x + PixelTileSize.x, y + PixelTileSize.y);
|
||||
Video.DrawLineClip(PlayerColors[i][0], x, y + PixelTileSize.y, x + PixelTileSize.x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -971,7 +970,7 @@ static void DrawStartLocations()
|
|||
**
|
||||
** If cursor is on map or minimap show information about the current tile.
|
||||
*/
|
||||
static void DrawEditorInfo(void)
|
||||
static void DrawEditorInfo()
|
||||
{
|
||||
#if 0
|
||||
int tile;
|
||||
|
@ -1185,7 +1184,7 @@ static void EditorCallbackButtonDown(unsigned button)
|
|||
UI.Minimap.Screen2MapX(CursorX) -
|
||||
UI.SelectedViewport->MapWidth / 2,
|
||||
UI.Minimap.Screen2MapY(CursorY) -
|
||||
UI.SelectedViewport->MapHeight / 2, TileSizeX / 2, TileSizeY / 2);
|
||||
UI.SelectedViewport->MapHeight / 2, PixelTileSize.x / 2, PixelTileSize.y / 2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1585,7 +1584,7 @@ static void EditorCallbackMouse(int x, int y)
|
|||
}
|
||||
UI.MouseWarpX = CursorStartX;
|
||||
UI.MouseWarpY = CursorStartY;
|
||||
UI.MouseViewport->Set(xo, yo, TileSizeX / 2, TileSizeY / 2);
|
||||
UI.MouseViewport->Set(xo, yo, PixelTileSize.x / 2, PixelTileSize.y / 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1608,21 +1607,21 @@ static void EditorCallbackMouse(int x, int y)
|
|||
if (CursorX <= UI.SelectedViewport->X) {
|
||||
UI.SelectedViewport->Set(
|
||||
UI.SelectedViewport->MapX - 1,
|
||||
UI.SelectedViewport->MapY, TileSizeX / 2, TileSizeY / 2);
|
||||
UI.SelectedViewport->MapY, PixelTileSize.x / 2, PixelTileSize.y / 2);
|
||||
} else if (CursorX >= UI.SelectedViewport->EndX) {
|
||||
UI.SelectedViewport->Set(
|
||||
UI.SelectedViewport->MapX + 1,
|
||||
UI.SelectedViewport->MapY, TileSizeX / 2, TileSizeY / 2);
|
||||
UI.SelectedViewport->MapY, PixelTileSize.x / 2, PixelTileSize.y / 2);
|
||||
}
|
||||
|
||||
if (CursorY <= UI.SelectedViewport->Y) {
|
||||
UI.SelectedViewport->Set(
|
||||
UI.SelectedViewport->MapX,
|
||||
UI.SelectedViewport->MapY - 1, TileSizeX / 2, TileSizeY / 2);
|
||||
UI.SelectedViewport->MapY - 1, PixelTileSize.x / 2, PixelTileSize.y / 2);
|
||||
} else if (CursorY >= UI.SelectedViewport->EndY) {
|
||||
UI.SelectedViewport->Set(
|
||||
UI.SelectedViewport->MapX,
|
||||
UI.SelectedViewport->MapY + 1, TileSizeX / 2, TileSizeY / 2);
|
||||
UI.SelectedViewport->MapY + 1, PixelTileSize.x / 2, PixelTileSize.y / 2);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1765,27 +1764,27 @@ static void EditorCallbackMouse(int x, int y)
|
|||
|
||||
i = Editor.TileIndex;
|
||||
by = UI.ButtonPanel.Y + 24;
|
||||
while (by < UI.ButtonPanel.Y + ButtonPanelHeight - TileSizeY) {
|
||||
while (by < UI.ButtonPanel.Y + ButtonPanelHeight - PixelTileSize.y) {
|
||||
if (i >= (int)Editor.ShownTileTypes.size()) {
|
||||
break;
|
||||
}
|
||||
bx = UI.ButtonPanel.X + 10;
|
||||
while (bx < UI.ButtonPanel.X + ButtonPanelWidth - TileSizeX) {
|
||||
while (bx < UI.ButtonPanel.X + ButtonPanelWidth - PixelTileSize.x) {
|
||||
//while (bx < UI.ButtonPanel.X + 144) {
|
||||
if (i >= (int)Editor.ShownTileTypes.size()) {
|
||||
break;
|
||||
}
|
||||
if (bx < x && x < bx + TileSizeX &&
|
||||
by < y && y < by + TileSizeY) {
|
||||
if (bx < x && x < bx + PixelTileSize.x &&
|
||||
by < y && y < by + PixelTileSize.y) {
|
||||
int base = Map.Tileset.Tiles[Editor.ShownTileTypes[i]].BaseTerrain;
|
||||
UI.StatusLine.Set(Map.Tileset.SolidTerrainTypes[base].TerrainName);
|
||||
Editor.CursorTileIndex = i;
|
||||
return;
|
||||
}
|
||||
bx += TileSizeX + 8;
|
||||
bx += PixelTileSize.x + 8;
|
||||
i++;
|
||||
}
|
||||
by += TileSizeY + 2;
|
||||
by += PixelTileSize.y + 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1815,9 +1814,9 @@ static void EditorCallbackMouse(int x, int y)
|
|||
}
|
||||
if (Editor.TerrainEditable) {
|
||||
if (UI.InfoPanel.X + 4 + TILE_ICON_X < CursorX &&
|
||||
CursorX < UI.InfoPanel.X + 4 + TILE_ICON_X + TileSizeX + 7 &&
|
||||
CursorX < UI.InfoPanel.X + 4 + TILE_ICON_X + PixelTileSize.x + 7 &&
|
||||
UI.InfoPanel.Y + 4 + TILE_ICON_Y < CursorY &&
|
||||
CursorY < UI.InfoPanel.Y + 4 + TILE_ICON_Y + TileSizeY + 7) {
|
||||
CursorY < UI.InfoPanel.Y + 4 + TILE_ICON_Y + PixelTileSize.y + 7) {
|
||||
ButtonAreaUnderCursor = -1;
|
||||
ButtonUnderCursor = TileButton;
|
||||
CursorOn = CursorOnButton;
|
||||
|
@ -1827,9 +1826,9 @@ static void EditorCallbackMouse(int x, int y)
|
|||
}
|
||||
|
||||
int StartUnitWidth = Editor.StartUnit ?
|
||||
Editor.StartUnit->Icon.Icon->G->Width : TileSizeX + 7;
|
||||
Editor.StartUnit->Icon.Icon->G->Width : PixelTileSize.x + 7;
|
||||
int StartUnitHeight = Editor.StartUnit ?
|
||||
Editor.StartUnit->Icon.Icon->G->Height : TileSizeY + 7;
|
||||
Editor.StartUnit->Icon.Icon->G->Height : PixelTileSize.y + 7;
|
||||
if (UI.InfoPanel.X + 4 + START_ICON_X < CursorX &&
|
||||
CursorX < UI.InfoPanel.X + 4 + START_ICON_X + StartUnitWidth &&
|
||||
UI.InfoPanel.Y + 4 + START_ICON_Y < CursorY &&
|
||||
|
@ -1882,9 +1881,9 @@ static void EditorCallbackMouse(int x, int y)
|
|||
//
|
||||
UnitUnderCursor = UnitOnScreen(NULL,
|
||||
CursorX - UI.MouseViewport->X +
|
||||
UI.MouseViewport->MapX * TileSizeX + UI.MouseViewport->OffsetX,
|
||||
UI.MouseViewport->MapX * PixelTileSize.x + UI.MouseViewport->OffsetX,
|
||||
CursorY - UI.MouseViewport->Y +
|
||||
UI.MouseViewport->MapY * TileSizeY + UI.MouseViewport->OffsetY);
|
||||
UI.MouseViewport->MapY * PixelTileSize.y + UI.MouseViewport->OffsetY);
|
||||
if (UnitUnderCursor != NULL) {
|
||||
ShowUnitInfo(*UnitUnderCursor);
|
||||
return;
|
||||
|
|
|
@ -766,8 +766,8 @@ void CreateGame(const std::string &filename, CMap *map)
|
|||
UI.SelectedViewport = UI.Viewports;
|
||||
}
|
||||
#endif
|
||||
UI.SelectedViewport->Center(
|
||||
ThisPlayer->StartX, ThisPlayer->StartY, TileSizeX / 2, TileSizeY / 2);
|
||||
const Vec2i start = {ThisPlayer->StartX, ThisPlayer->StartY};
|
||||
UI.SelectedViewport->Center(start, PixelTileSize / 2);
|
||||
|
||||
//
|
||||
// Various hacks wich must be done after the map is loaded.
|
||||
|
|
|
@ -207,17 +207,17 @@
|
|||
** Missile::position
|
||||
**
|
||||
** Missile current map position in pixels. To convert a map tile
|
||||
** position to pixel position use: (mapx * ::TileSizeX + ::TileSizeX / 2)
|
||||
** and (mapy * ::TileSizeY + ::TileSizeY / 2)
|
||||
** @note ::TileSizeX % 2 == 0 && ::TileSizeY % 2 == 0
|
||||
** position to pixel position use: (mapx * ::PixelTileSize.x + ::PixelTileSize.x / 2)
|
||||
** and (mapy * ::PixelTileSize.y + ::PixelTileSize.y / 2)
|
||||
** @note ::PixelTileSize.x % 2 == 0 && ::PixelTileSize.y % 2 == 0
|
||||
**
|
||||
** Missile::source
|
||||
**
|
||||
** Missile original map position in pixels. To convert a map tile
|
||||
** position to pixel position use: (mapx*::TileSizeX+::TileSizeX/2)
|
||||
** and (mapy*::TileSizeY+::TileSizeY/2)
|
||||
** @note ::TileSizeX%2==0 && ::TileSizeY%2==0 and ::TileSizeX,
|
||||
** ::TileSizeY are currently fixed 32 pixels.
|
||||
** position to pixel position use: (mapx*::PixelTileSize.x+::PixelTileSize.x/2)
|
||||
** and (mapy*::PixelTileSize.y+::PixelTileSize.y/2)
|
||||
** @note ::PixelTileSize.x%2==0 && ::PixelTileSize.y%2==0 and ::PixelTileSize.x,
|
||||
** ::PixelTileSize.y are currently fixed 32 pixels.
|
||||
**
|
||||
** Missile::destination
|
||||
**
|
||||
|
|
|
@ -202,9 +202,10 @@
|
|||
-- Declarations
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "vec2i.h"
|
||||
|
||||
extern int TileSizeX; /// Size of a tile in X
|
||||
extern int TileSizeY; /// Size of a tile in Y
|
||||
|
||||
extern PixelSize PixelTileSize; /// Size of a tile in pixels
|
||||
|
||||
/**
|
||||
** These are used for lookup tiles types
|
||||
|
@ -246,8 +247,7 @@ public:
|
|||
Name.clear();
|
||||
ImageFile.clear();
|
||||
NumTiles = 0;
|
||||
TileSizeX = 0;
|
||||
TileSizeY = 0;
|
||||
PixelTileSize.x = PixelTileSize.y = 0;
|
||||
delete[] Table;
|
||||
Table = NULL;
|
||||
delete[] FlagsTable;
|
||||
|
@ -279,8 +279,7 @@ public:
|
|||
std::string ImageFile; /// File containing image data
|
||||
|
||||
int NumTiles; /// Number of tiles in the tables
|
||||
int TileSizeX; /// Size of a tile in X
|
||||
int TileSizeY; /// Size of a tile in Y
|
||||
PixelSize PixelTileSize; /// Size of a tile in pixel
|
||||
unsigned short *Table; /// Pud to Internal conversion table
|
||||
unsigned short *FlagsTable; /// Flag table for editor
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ public:
|
|||
/// Set the current map view to x,y(upper,left corner)
|
||||
void Set(int x, int y, int offsetx, int offsety);
|
||||
/// Center map on point in viewport
|
||||
void Center(int x, int y, int offsetx, int offsety);
|
||||
void Center(const Vec2i& pos, const PixelPos &offset);
|
||||
protected:
|
||||
/// Draw the map background
|
||||
void DrawMapBackgroundInViewport() const;
|
||||
|
|
|
@ -120,9 +120,9 @@
|
|||
**
|
||||
** The tile map coordinates of the unit. 0,0 is the upper left on
|
||||
** the map. To convert the map coordinates into pixels, they
|
||||
** must be multiplicated with the #TileSizeX and #TileSizeY.
|
||||
** must be multiplicated with the #PixelTileSize.x and #PixelTileSize.y.
|
||||
** To get the pixel coordinates of a unit, calculate
|
||||
** CUnit::X*#TileSizeX+CUnit::IX , CUnit::Y*#TileSizeY+CUnit::IY.
|
||||
** CUnit::X*#PixelTileSize.x+CUnit::IX , CUnit::Y*#PixelTileSize.y+CUnit::IY.
|
||||
**
|
||||
** CUnit::Type
|
||||
**
|
||||
|
|
|
@ -82,18 +82,18 @@ bool CViewport::IsInsideMapArea(int x, int y) const
|
|||
int tilex;
|
||||
int tiley;
|
||||
|
||||
tilex = x - this->X + this->MapX * TileSizeX + this->OffsetX;
|
||||
tilex = x - this->X + this->MapX * PixelTileSize.x + this->OffsetX;
|
||||
if (tilex < 0) {
|
||||
tilex = (tilex - TileSizeX + 1) / TileSizeX;
|
||||
tilex = (tilex - PixelTileSize.x + 1) / PixelTileSize.x;
|
||||
} else {
|
||||
tilex /= TileSizeX;
|
||||
tilex /= PixelTileSize.x;
|
||||
}
|
||||
|
||||
tiley = y - this->Y + this->MapY * TileSizeY + this->OffsetY;
|
||||
tiley = y - this->Y + this->MapY * PixelTileSize.y + this->OffsetY;
|
||||
if (tiley < 0) {
|
||||
tiley = (tiley - TileSizeY + 1) / TileSizeY;
|
||||
tiley = (tiley - PixelTileSize.y + 1) / PixelTileSize.y;
|
||||
} else {
|
||||
tiley /= TileSizeY;
|
||||
tiley /= PixelTileSize.y;
|
||||
}
|
||||
|
||||
return (tilex >= 0 && tiley >= 0 && tilex < Map.Info.MapWidth && tiley < Map.Info.MapHeight);
|
||||
|
@ -110,7 +110,7 @@ bool CViewport::IsInsideMapArea(int x, int y) const
|
|||
*/
|
||||
int CViewport::Viewport2MapX(int x) const
|
||||
{
|
||||
int r = (x - this->X + this->MapX * TileSizeX + this->OffsetX) / TileSizeX;
|
||||
int r = (x - this->X + this->MapX * PixelTileSize.x + this->OffsetX) / PixelTileSize.x;
|
||||
return std::min<int>(r, Map.Info.MapWidth - 1);
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ int CViewport::Viewport2MapX(int x) const
|
|||
*/
|
||||
int CViewport::Viewport2MapY(int y) const
|
||||
{
|
||||
int r = (y - this->Y + this->MapY * TileSizeY + this->OffsetY) / TileSizeY;
|
||||
int r = (y - this->Y + this->MapY * PixelTileSize.y + this->OffsetY) / PixelTileSize.y;
|
||||
return std::min<int>(r, Map.Info.MapHeight - 1);
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ int CViewport::Viewport2MapY(int y) const
|
|||
*/
|
||||
int CViewport::Map2ViewportX(int x) const
|
||||
{
|
||||
return this->X + (x - this->MapX) * TileSizeX - this->OffsetX;
|
||||
return this->X + (x - this->MapX) * PixelTileSize.x - this->OffsetX;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -152,7 +152,7 @@ int CViewport::Map2ViewportX(int x) const
|
|||
*/
|
||||
int CViewport::Map2ViewportY(int y) const
|
||||
{
|
||||
return this->Y + (y - this->MapY) * TileSizeY - this->OffsetY;
|
||||
return this->Y + (y - this->MapY) * PixelTileSize.y - this->OffsetY;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,8 +160,8 @@ int CViewport::Map2ViewportY(int y) const
|
|||
*/
|
||||
void CViewport::MapPixel2Viewport(int &x, int &y) const
|
||||
{
|
||||
x = x + this->X - (this->MapX * TileSizeX + this->OffsetX);
|
||||
y = y + this->Y - (this->MapY * TileSizeY + this->OffsetY);
|
||||
x = x + this->X - (this->MapX * PixelTileSize.x + this->OffsetX);
|
||||
y = y + this->Y - (this->MapY * PixelTileSize.y + this->OffsetY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -174,8 +174,8 @@ void CViewport::MapPixel2Viewport(int &x, int &y) const
|
|||
*/
|
||||
void CViewport::Set(int x, int y, int offsetx, int offsety)
|
||||
{
|
||||
x = x * TileSizeX + offsetx;
|
||||
y = y * TileSizeY + offsety;
|
||||
x = x * PixelTileSize.x + offsetx;
|
||||
y = y * PixelTileSize.y + offsety;
|
||||
|
||||
if (x < -UI.MapArea.ScrollPaddingLeft) {
|
||||
x = -UI.MapArea.ScrollPaddingLeft;
|
||||
|
@ -183,46 +183,44 @@ void CViewport::Set(int x, int y, int offsetx, int offsety)
|
|||
if (y < -UI.MapArea.ScrollPaddingTop) {
|
||||
y = -UI.MapArea.ScrollPaddingTop;
|
||||
}
|
||||
if (x > Map.Info.MapWidth * TileSizeX - (this->EndX - this->X) - 1 + UI.MapArea.ScrollPaddingRight) {
|
||||
x = Map.Info.MapWidth * TileSizeX - (this->EndX - this->X) - 1 + UI.MapArea.ScrollPaddingRight;
|
||||
if (x > Map.Info.MapWidth * PixelTileSize.x - (this->EndX - this->X) - 1 + UI.MapArea.ScrollPaddingRight) {
|
||||
x = Map.Info.MapWidth * PixelTileSize.x- (this->EndX - this->X) - 1 + UI.MapArea.ScrollPaddingRight;
|
||||
}
|
||||
if (y > Map.Info.MapHeight * TileSizeY - (this->EndY - this->Y) - 1 + UI.MapArea.ScrollPaddingBottom) {
|
||||
y = Map.Info.MapHeight * TileSizeY - (this->EndY - this->Y) - 1 + UI.MapArea.ScrollPaddingBottom;
|
||||
if (y > Map.Info.MapHeight * PixelTileSize.y- (this->EndY - this->Y) - 1 + UI.MapArea.ScrollPaddingBottom) {
|
||||
y = Map.Info.MapHeight * PixelTileSize.y- (this->EndY - this->Y) - 1 + UI.MapArea.ScrollPaddingBottom;
|
||||
}
|
||||
|
||||
this->MapX = x / TileSizeX;
|
||||
if (x < 0 && x % TileSizeX) {
|
||||
this->MapX = x / PixelTileSize.x;
|
||||
if (x < 0 && x % PixelTileSize.x) {
|
||||
this->MapX--;
|
||||
}
|
||||
this->MapY = y / TileSizeY;
|
||||
if (y < 0 && y % TileSizeY) {
|
||||
this->MapY = y / PixelTileSize.y;
|
||||
if (y < 0 && y % PixelTileSize.y) {
|
||||
this->MapY--;
|
||||
}
|
||||
this->OffsetX = x % TileSizeX;
|
||||
this->OffsetX = x % PixelTileSize.x;
|
||||
if (this->OffsetX < 0) {
|
||||
this->OffsetX += TileSizeX;
|
||||
this->OffsetX += PixelTileSize.x;
|
||||
}
|
||||
this->OffsetY = y % TileSizeY;
|
||||
this->OffsetY = y % PixelTileSize.y;
|
||||
if (this->OffsetY < 0) {
|
||||
this->OffsetY += TileSizeY;
|
||||
this->OffsetY += PixelTileSize.y;
|
||||
}
|
||||
this->MapWidth = ((this->EndX - this->X) + this->OffsetX - 1) / TileSizeX + 1;
|
||||
this->MapHeight = ((this->EndY - this->Y) + this->OffsetY - 1) / TileSizeY + 1;
|
||||
this->MapWidth = ((this->EndX - this->X) + this->OffsetX - 1) / PixelTileSize.x + 1;
|
||||
this->MapHeight = ((this->EndY - this->Y) + this->OffsetY - 1) / PixelTileSize.y + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
** Center map viewport v on map tile (x,y).
|
||||
** Center map viewport v on map tile (pos).
|
||||
**
|
||||
** @param x X map tile position.
|
||||
** @param y Y map tile position.
|
||||
** @param offsetx X offset in tile.
|
||||
** @param offsety Y offset in tile.
|
||||
** @param pos map tile position.
|
||||
** @param offset offset in tile.
|
||||
*/
|
||||
void CViewport::Center(int x, int y, int offsetx, int offsety)
|
||||
void CViewport::Center(const Vec2i &pos, const PixelDiff &offset)
|
||||
{
|
||||
x = x * TileSizeX + offsetx - (this->EndX - this->X) / 2;
|
||||
y = y * TileSizeY + offsety - (this->EndY - this->Y) / 2;
|
||||
this->Set(x / TileSizeX, y / TileSizeY, x % TileSizeX, y % TileSizeY);
|
||||
int x = pos.x * PixelTileSize.x + offset.x - (this->EndX - this->X) / 2;
|
||||
int y = pos.y * PixelTileSize.y + offset.y - (this->EndY - this->Y) / 2;
|
||||
this->Set(x / PixelTileSize.x, y / PixelTileSize.y, x % PixelTileSize.x, y % PixelTileSize.y);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -261,7 +259,7 @@ void CViewport::DrawMapBackgroundInViewport() const
|
|||
|
||||
while (sy < 0) {
|
||||
sy++;
|
||||
dy += TileSizeY;
|
||||
dy += PixelTileSize.y;
|
||||
}
|
||||
sy *= Map.Info.MapWidth;
|
||||
|
||||
|
@ -270,7 +268,7 @@ void CViewport::DrawMapBackgroundInViewport() const
|
|||
/*
|
||||
if (sy / Map.Info.MapWidth < 0) {
|
||||
sy += Map.Info.MapWidth;
|
||||
dy += TileSizeY;
|
||||
dy += PixelTileSize.y;
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
|
@ -279,7 +277,7 @@ void CViewport::DrawMapBackgroundInViewport() const
|
|||
while (dx <= ex && (sx - sy < Map.Info.MapWidth)) {
|
||||
if (sx - sy < 0) {
|
||||
++sx;
|
||||
dx += TileSizeX;
|
||||
dx += PixelTileSize.x;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -315,8 +313,8 @@ void CViewport::DrawMapBackgroundInViewport() const
|
|||
break;
|
||||
}
|
||||
|
||||
Video.DrawHLineClip(color, dx, dy, TileSizeX);
|
||||
Video.DrawVLineClip(color, dx, dy, TileSizeY);
|
||||
Video.DrawHLineClip(color, dx, dy, PixelTileSize.x);
|
||||
Video.DrawVLineClip(color, dx, dy, PixelTileSize.y);
|
||||
if ( 0 && my_mask ) {
|
||||
CLabel label(SmallFont);
|
||||
label.Draw(dx + 2, dy +2, tile);
|
||||
|
@ -326,10 +324,10 @@ void CViewport::DrawMapBackgroundInViewport() const
|
|||
}
|
||||
#endif
|
||||
++sx;
|
||||
dx += TileSizeX;
|
||||
dx += PixelTileSize.x;
|
||||
}
|
||||
sy += Map.Info.MapWidth;
|
||||
dy += TileSizeY;
|
||||
dy += PixelTileSize.y;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -444,7 +444,7 @@ void VideoDrawOnlyFog(int x, int y)
|
|||
SDL_BlitSurface(OnlyFogSurface, &srect, TheScreen, &drect);
|
||||
} else {
|
||||
Video.FillRectangleClip(Video.MapRGBA(0, 0, 0, 0, FogOfWarOpacity),
|
||||
x, y, TileSizeX, TileSizeY);
|
||||
x, y, PixelTileSize.x, PixelTileSize.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -643,13 +643,13 @@ void CViewport::DrawMapFogOfWar() const
|
|||
if (VisibleTable[sx]) {
|
||||
DrawFogOfWarTile(sx, sy, dx, dy);
|
||||
} else {
|
||||
Video.FillRectangleClip(FogOfWarColorSDL, dx, dy, TileSizeX, TileSizeY);
|
||||
Video.FillRectangleClip(FogOfWarColorSDL, dx, dy, PixelTileSize.x, PixelTileSize.y);
|
||||
}
|
||||
++sx;
|
||||
dx += TileSizeX;
|
||||
dx += PixelTileSize.x;
|
||||
}
|
||||
sy += Map.Info.MapWidth;
|
||||
dy += TileSizeY;
|
||||
dy += PixelTileSize.y;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -672,7 +672,7 @@ void CMap::InitFogOfWar(void)
|
|||
//
|
||||
// Generate Only Fog surface.
|
||||
//
|
||||
s = SDL_CreateRGBSurface(SDL_SWSURFACE, TileSizeX, TileSizeY,
|
||||
s = SDL_CreateRGBSurface(SDL_SWSURFACE, PixelTileSize.x, PixelTileSize.y,
|
||||
32, RMASK, GMASK, BMASK, AMASK);
|
||||
|
||||
SDL_GetRGB(FogOfWarColorSDL, TheScreen->format, &r, &g, &b);
|
||||
|
@ -698,7 +698,7 @@ void CMap::InitFogOfWar(void)
|
|||
|
||||
// Copy the top row to a new surface
|
||||
f = FogGraphic->Surface->format;
|
||||
s = SDL_CreateRGBSurface(SDL_SWSURFACE, FogGraphic->Surface->w, TileSizeY,
|
||||
s = SDL_CreateRGBSurface(SDL_SWSURFACE, FogGraphic->Surface->w, PixelTileSize.y,
|
||||
f->BitsPerPixel, f->Rmask, f->Gmask, f->Bmask, f->Amask);
|
||||
SDL_LockSurface(s);
|
||||
SDL_LockSurface(FogGraphic->Surface);
|
||||
|
@ -727,8 +727,8 @@ void CMap::InitFogOfWar(void)
|
|||
}
|
||||
AlphaFogG = CGraphic::New("");
|
||||
AlphaFogG->Surface = s;
|
||||
AlphaFogG->Width = TileSizeX;
|
||||
AlphaFogG->Height = TileSizeY;
|
||||
AlphaFogG->Width = PixelTileSize.x;
|
||||
AlphaFogG->Height = PixelTileSize.y;
|
||||
AlphaFogG->GraphicWidth = s->w;
|
||||
AlphaFogG->GraphicHeight = s->h;
|
||||
AlphaFogG->NumFrames = 16;//1;
|
||||
|
|
|
@ -242,7 +242,7 @@ void CMinimap::UpdateTerrain(void)
|
|||
}
|
||||
}
|
||||
|
||||
tilepitch = Map.TileGraphic->Surface->w / TileSizeX;
|
||||
tilepitch = Map.TileGraphic->Surface->w / PixelTileSize.x;
|
||||
|
||||
if (!UseOpenGL) {
|
||||
SDL_LockSurface(MinimapTerrainSurface);
|
||||
|
@ -260,8 +260,8 @@ void CMinimap::UpdateTerrain(void)
|
|||
|
||||
tile = Map.Fields[Minimap2MapX[mx] + Minimap2MapY[my]].Tile;
|
||||
|
||||
xofs = TileSizeX * (tile % tilepitch);
|
||||
yofs = TileSizeY * (tile / tilepitch);
|
||||
xofs = PixelTileSize.x * (tile % tilepitch);
|
||||
yofs = PixelTileSize.y * (tile / tilepitch);
|
||||
|
||||
if (!UseOpenGL) {
|
||||
if (bpp == 1) {
|
||||
|
@ -334,7 +334,7 @@ void CMinimap::UpdateXY(const Vec2i &pos)
|
|||
scaley = 1;
|
||||
}
|
||||
|
||||
const int tilepitch = Map.TileGraphic->Surface->w / TileSizeX;
|
||||
const int tilepitch = Map.TileGraphic->Surface->w / PixelTileSize.x;
|
||||
const int bpp = Map.TileGraphic->Surface->format->BytesPerPixel;
|
||||
|
||||
//
|
||||
|
@ -371,8 +371,8 @@ void CMinimap::UpdateXY(const Vec2i &pos)
|
|||
tile = Map.Fields[x + y].Tile;
|
||||
}
|
||||
|
||||
const int xofs = TileSizeX * (tile % tilepitch);
|
||||
const int yofs = TileSizeY * (tile / tilepitch);
|
||||
const int xofs = PixelTileSize.x * (tile % tilepitch);
|
||||
const int yofs = PixelTileSize.y * (tile / tilepitch);
|
||||
|
||||
if (!UseOpenGL) {
|
||||
if (bpp == 1) {
|
||||
|
|
|
@ -253,9 +253,9 @@ static int CclRevealMap(lua_State *l)
|
|||
static int CclCenterMap(lua_State *l)
|
||||
{
|
||||
LuaCheckArgs(l, 2);
|
||||
UI.SelectedViewport->Center(
|
||||
LuaToNumber(l, 1), LuaToNumber(l, 2), TileSizeX / 2, TileSizeY / 2);
|
||||
const Vec2i pos = {LuaToNumber(l, 1), LuaToNumber(l, 2)};
|
||||
|
||||
UI.SelectedViewport->Center(pos, PixelTileSize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -436,7 +436,7 @@ static int CclSetFogOfWarGraphics(lua_State *l)
|
|||
if (CMap::FogGraphic) {
|
||||
CGraphic::Free(CMap::FogGraphic);
|
||||
}
|
||||
CMap::FogGraphic = CGraphic::New(FogGraphicFile, TileSizeX, TileSizeY);
|
||||
CMap::FogGraphic = CGraphic::New(FogGraphicFile, PixelTileSize.x, PixelTileSize.y);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -487,8 +487,8 @@ static int CclDefineTileset(lua_State *l)
|
|||
{
|
||||
Map.Tileset.Clear();
|
||||
|
||||
Map.Tileset.TileSizeX = 32;
|
||||
Map.Tileset.TileSizeY = 32;
|
||||
Map.Tileset.PixelTileSize.x = 32;
|
||||
Map.Tileset.PixelTileSize.y = 32;
|
||||
|
||||
//
|
||||
// Parse the list: (still everything could be changed!)
|
||||
|
@ -507,10 +507,10 @@ static int CclDefineTileset(lua_State *l)
|
|||
LuaError(l, "incorrect argument");
|
||||
}
|
||||
lua_rawgeti(l, j, 1);
|
||||
Map.Tileset.TileSizeX = LuaToNumber(l, -1);
|
||||
Map.Tileset.PixelTileSize.x = LuaToNumber(l, -1);
|
||||
lua_pop(l, 1);
|
||||
lua_rawgeti(l, j, 2);
|
||||
Map.Tileset.TileSizeY = LuaToNumber(l, -1);
|
||||
Map.Tileset.PixelTileSize.y = LuaToNumber(l, -1);
|
||||
lua_pop(l, 1);
|
||||
} else if (!strcmp(value, "slots")) {
|
||||
if (!lua_istable(l, j)) {
|
||||
|
|
|
@ -50,14 +50,10 @@
|
|||
----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
** Size of a tile in X
|
||||
** Size of a tile in pixel
|
||||
*/
|
||||
int TileSizeX = 32;
|
||||
PixelSize PixelTileSize = {32, 32};
|
||||
|
||||
/**
|
||||
** Size of a tile in Y
|
||||
*/
|
||||
int TileSizeY = 32;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
|
@ -68,15 +64,14 @@ int TileSizeY = 32;
|
|||
**
|
||||
** @see Map @see Map.Tileset.
|
||||
*/
|
||||
void LoadTileset(void)
|
||||
void LoadTileset()
|
||||
{
|
||||
// Load and prepare the tileset
|
||||
TileSizeX = Map.Tileset.TileSizeX;
|
||||
TileSizeY = Map.Tileset.TileSizeY;
|
||||
PixelTileSize = Map.Tileset.PixelTileSize;
|
||||
|
||||
ShowLoadProgress("Tileset `%s'", Map.Tileset.ImageFile.c_str());
|
||||
//Map.TileGraphic = CGraphic::New(Map.Tileset.ImageFile);
|
||||
Map.TileGraphic = CGraphic::New(Map.Tileset.ImageFile, TileSizeX, TileSizeY);
|
||||
Map.TileGraphic = CGraphic::New(Map.Tileset.ImageFile, PixelTileSize.x, PixelTileSize.y);
|
||||
Map.TileGraphic->Load();
|
||||
}
|
||||
|
||||
|
@ -86,7 +81,7 @@ void LoadTileset(void)
|
|||
**
|
||||
** @note this didn't frees the configuration memory.
|
||||
*/
|
||||
void CleanTilesets(void)
|
||||
void CleanTilesets()
|
||||
{
|
||||
Map.Tileset.Clear();
|
||||
|
||||
|
|
|
@ -251,9 +251,9 @@ static char CalculateStereo(const CUnit &unit)
|
|||
{
|
||||
int stereo;
|
||||
|
||||
stereo = ((unit.tilePos.x * TileSizeX + unit.Type->TileWidth * TileSizeX / 2 +
|
||||
unit.IX - UI.SelectedViewport->MapX * TileSizeX) * 256 /
|
||||
((UI.SelectedViewport->MapWidth - 1) * TileSizeX)) - 128;
|
||||
stereo = ((unit.tilePos.x * PixelTileSize.x + unit.Type->TileWidth * PixelTileSize.x / 2 +
|
||||
unit.IX - UI.SelectedViewport->MapX * PixelTileSize.x) * 256 /
|
||||
((UI.SelectedViewport->MapWidth - 1) * PixelTileSize.x)) - 128;
|
||||
if (stereo < -128) {
|
||||
stereo = -128;
|
||||
} else if (stereo > 127) {
|
||||
|
@ -316,11 +316,10 @@ void PlayUnitSound(const CUnit &unit, CSound *sound)
|
|||
*/
|
||||
void PlayMissileSound(const Missile *missile, CSound *sound)
|
||||
{
|
||||
int stereo;
|
||||
int stereo = ((missile->position.x + missile->Type->G->Width / 2 -
|
||||
UI.SelectedViewport->MapX * PixelTileSize.x) * 256 /
|
||||
((UI.SelectedViewport->MapWidth - 1) * PixelTileSize.x)) - 128;
|
||||
|
||||
stereo = ((missile->position.x + missile->Type->G->Width / 2 -
|
||||
UI.SelectedViewport->MapX * TileSizeX) * 256 /
|
||||
((UI.SelectedViewport->MapWidth - 1) * TileSizeX)) - 128;
|
||||
if (stereo < -128) {
|
||||
stereo = -128;
|
||||
} else if (stereo > 127) {
|
||||
|
@ -560,8 +559,8 @@ void InitSoundClient(void)
|
|||
SoundForName(GameSounds.ChatMessage.Name);
|
||||
}
|
||||
|
||||
int MapWidth = (UI.MapArea.EndX - UI.MapArea.X + TileSizeX) / TileSizeX;
|
||||
int MapHeight = (UI.MapArea.EndY - UI.MapArea.Y + TileSizeY) / TileSizeY;
|
||||
int MapWidth = (UI.MapArea.EndX - UI.MapArea.X + PixelTileSize.x) / PixelTileSize.x;
|
||||
int MapHeight = (UI.MapArea.EndY - UI.MapArea.Y + PixelTileSize.y) / PixelTileSize.y;
|
||||
DistanceSilent = 3 * std::max<int>(MapWidth, MapHeight);
|
||||
ViewPointOffset = std::max<int>(MapWidth / 2, MapHeight / 2);
|
||||
}
|
||||
|
|
|
@ -137,12 +137,12 @@ void DoScrollArea(int state, bool fast)
|
|||
vp = UI.SelectedViewport;
|
||||
|
||||
if (fast) {
|
||||
stepx = vp->MapWidth / 2 * TileSizeX * FRAMES_PER_SECOND;
|
||||
stepy = vp->MapHeight / 2 * TileSizeY * FRAMES_PER_SECOND;
|
||||
stepx = vp->MapWidth / 2 * PixelTileSize.x * FRAMES_PER_SECOND;
|
||||
stepy = vp->MapHeight / 2 * PixelTileSize.y * FRAMES_PER_SECOND;
|
||||
} else {// dynamic: let these variables increase upto fast..
|
||||
// FIXME: pixels per second should be configurable
|
||||
stepx = TileSizeX * FRAMES_PER_SECOND;
|
||||
stepy = TileSizeY * FRAMES_PER_SECOND;
|
||||
stepx = PixelTileSize.x * FRAMES_PER_SECOND;
|
||||
stepy = PixelTileSize.y * FRAMES_PER_SECOND;
|
||||
}
|
||||
if ((state & (ScrollLeft | ScrollRight)) &&
|
||||
(state & (ScrollLeft | ScrollRight)) != (ScrollLeft | ScrollRight)) {
|
||||
|
@ -205,11 +205,11 @@ void DrawMapArea(void)
|
|||
vp->Unit->CurrentAction() == UnitActionDie) {
|
||||
vp->Unit = NoUnitP;
|
||||
} else {
|
||||
vp->Center(vp->Unit->tilePos.x, vp->Unit->tilePos.y,
|
||||
vp->Unit->IX + TileSizeX / 2, vp->Unit->IY + TileSizeY / 2);
|
||||
const PixelSize offset = {vp->Unit->IX + PixelTileSize.x / 2, vp->Unit->IY + PixelTileSize.y / 2};
|
||||
|
||||
vp->Center(vp->Unit->tilePos, offset);
|
||||
}
|
||||
}
|
||||
|
||||
vp->Draw();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -410,11 +410,11 @@ void FireMissile(CUnit &unit)
|
|||
|
||||
// If Firing from inside a Bunker
|
||||
if (unit.Container) {
|
||||
x = unit.Container->tilePos.x * TileSizeX + TileSizeX / 2; // missile starts in tile middle
|
||||
y = unit.Container->tilePos.y * TileSizeY + TileSizeY / 2;
|
||||
x = unit.Container->tilePos.x * PixelTileSize.x + PixelTileSize.x / 2; // missile starts in tile middle
|
||||
y = unit.Container->tilePos.y * PixelTileSize.y + PixelTileSize.y / 2;
|
||||
} else {
|
||||
x = unit.tilePos.x * TileSizeX + TileSizeX / 2; // missile starts in tile middle
|
||||
y = unit.tilePos.y * TileSizeY + TileSizeY / 2;
|
||||
x = unit.tilePos.x * PixelTileSize.x + PixelTileSize.x / 2; // missile starts in tile middle
|
||||
y = unit.tilePos.y * PixelTileSize.y + PixelTileSize.y / 2;
|
||||
}
|
||||
|
||||
Vec2i dpos;
|
||||
|
@ -442,8 +442,8 @@ void FireMissile(CUnit &unit)
|
|||
}
|
||||
|
||||
// Fire to the tile center of the destination.
|
||||
dpos.x = dpos.x * TileSizeX + TileSizeX / 2;
|
||||
dpos.y = dpos.y * TileSizeY + TileSizeY / 2;
|
||||
dpos.x = dpos.x * PixelTileSize.x + PixelTileSize.x / 2;
|
||||
dpos.y = dpos.y * PixelTileSize.y + PixelTileSize.y / 2;
|
||||
Missile *missile = MakeMissile(unit.Type->Missile.Missile, x, y, dpos.x, dpos.y);
|
||||
//
|
||||
// Damage of missile
|
||||
|
@ -470,10 +470,10 @@ static void GetMissileMapArea(const Missile *missile, Vec2i& boxMin, Vec2i &boxM
|
|||
#define BoundX(x) std::min<int>(std::max<int>(0, x), Map.Info.MapWidth - 1)
|
||||
#define BoundY(y) std::min<int>(std::max<int>(0, y), Map.Info.MapHeight - 1)
|
||||
|
||||
boxMin.x = BoundX(missile->position.x / TileSizeX);
|
||||
boxMin.y = BoundY(missile->position.y / TileSizeY);
|
||||
boxMax.x = BoundX((missile->position.x + missile->Type->Width() + TileSizeX - 1) / TileSizeX);
|
||||
boxMax.y = BoundY((missile->position.y + missile->Type->Height() + TileSizeY - 1) / TileSizeY);
|
||||
boxMin.x = BoundX(missile->position.x / PixelTileSize.x);
|
||||
boxMin.y = BoundY(missile->position.y / PixelTileSize.y);
|
||||
boxMax.x = BoundX((missile->position.x + missile->Type->Width() + PixelTileSize.x - 1) / PixelTileSize.x);
|
||||
boxMax.y = BoundY((missile->position.y + missile->Type->Height() + PixelTileSize.y - 1) / PixelTileSize.y);
|
||||
|
||||
#undef BoundX
|
||||
#undef BoundY
|
||||
|
@ -553,8 +553,8 @@ void MissileType::DrawMissileType(int frame, const PixelPos &pos) const
|
|||
|
||||
void MissileDrawProxy::DrawMissile(const CViewport *vp) const
|
||||
{
|
||||
const int x = this->X - vp->MapX * TileSizeX + vp->X - vp->OffsetX;
|
||||
const int y = this->Y - vp->MapY * TileSizeY + vp->Y - vp->OffsetY;
|
||||
const int x = this->X - vp->MapX * PixelTileSize.x + vp->X - vp->OffsetX;
|
||||
const int y = this->Y - vp->MapY * PixelTileSize.y + vp->Y - vp->OffsetY;
|
||||
switch (this->Type->Class) {
|
||||
case MissileClassHit:
|
||||
CLabel(GameFont).DrawClip(x,y, this->data.Damage);
|
||||
|
@ -592,8 +592,8 @@ void Missile::DrawMissile(const CViewport *vp) const
|
|||
}
|
||||
#endif
|
||||
}
|
||||
const int x = this->position.x - vp->MapX * TileSizeX + vp->X - vp->OffsetX;
|
||||
const int y = this->position.y - vp->MapY * TileSizeY + vp->Y - vp->OffsetY;
|
||||
const int x = this->position.x - vp->MapX * PixelTileSize.x + vp->X - vp->OffsetX;
|
||||
const int y = this->position.y - vp->MapY * PixelTileSize.y + vp->Y - vp->OffsetY;
|
||||
switch (this->Type->Class) {
|
||||
case MissileClassHit:
|
||||
CLabel(GameFont).DrawClip(x, y, this->Damage);
|
||||
|
@ -894,7 +894,7 @@ void MissileHit(Missile *missile)
|
|||
return;
|
||||
}
|
||||
|
||||
const Vec2i pos = {pixelPos.x / TileSizeX, pixelPos.y / TileSizeY};
|
||||
const Vec2i pos = {pixelPos.x / PixelTileSize.x, pixelPos.y / PixelTileSize.y};
|
||||
|
||||
if (!Map.Info.IsPointOnMap(pos)) {
|
||||
// FIXME: this should handled by caller?
|
||||
|
@ -1126,7 +1126,7 @@ void MissileActions()
|
|||
int ViewPointDistanceToMissile(const Missile *missile)
|
||||
{
|
||||
const PixelPos pixelPos = missile->position + missile->Type->size / 2;
|
||||
const Vec2i tilePos = { pixelPos.x / TileSizeX, pixelPos.y / TileSizeY };
|
||||
const Vec2i tilePos = { pixelPos.x / PixelTileSize.x, pixelPos.y / PixelTileSize.y };
|
||||
|
||||
return ViewPointDistance(tilePos);
|
||||
}
|
||||
|
@ -1401,7 +1401,7 @@ void MissilePointToPointBounce::Action()
|
|||
if (this->State < 2 * this->Type->NumBounces - 1 && this->TotalStep) {
|
||||
const PixelPos step = (this->destination - this->source);
|
||||
|
||||
this->destination += step * ((TileSizeX + TileSizeY) * 3) / 4 / this->TotalStep;
|
||||
this->destination += step * ((PixelTileSize.x + PixelTileSize.y) * 3) / 4 / this->TotalStep;
|
||||
this->State++; // !(State & 1) to initialise
|
||||
this->source = this->position;
|
||||
PointToPointMissile(*this);
|
||||
|
@ -1529,8 +1529,8 @@ void MissileFlameShield::Action()
|
|||
const int iy = unit->IY;
|
||||
const int uw = unit->Type->TileWidth;
|
||||
const int uh = unit->Type->TileHeight;
|
||||
this->position.x = upos.x * TileSizeX + ix + uw * TileSizeX / 2 + dx - 16;
|
||||
this->position.y = upos.y * TileSizeY + iy + uh * TileSizeY / 2 + dy - 32;
|
||||
this->position.x = upos.x * PixelTileSize.x + ix + uw * PixelTileSize.x / 2 + dx - 16;
|
||||
this->position.y = upos.y * PixelTileSize.y + iy + uh * PixelTileSize.y / 2 + dy - 32;
|
||||
if (unit->CurrentAction() == UnitActionDie) {
|
||||
this->TTL = index;
|
||||
}
|
||||
|
@ -1586,12 +1586,11 @@ struct LandMineTargetFinder {
|
|||
*/
|
||||
void MissileLandMine::Action()
|
||||
{
|
||||
const int x = this->position.x / TileSizeX;
|
||||
const int y = this->position.y / TileSizeY;
|
||||
const Vec2i pos = {this->position.x / PixelTileSize.x, this->position.y / PixelTileSize.y};
|
||||
|
||||
if(LandMineTargetFinder(this->SourceUnit,
|
||||
this->Type->CanHitOwner).FindOnTile(Map.Field(x, y)) != NULL) {
|
||||
DebugPrint("Landmine explosion at %d,%d.\n" _C_ x _C_ y);
|
||||
this->Type->CanHitOwner).FindOnTile(Map.Field(pos)) != NULL) {
|
||||
DebugPrint("Landmine explosion at %d,%d.\n" _C_ pos.x _C_ pos.y);
|
||||
MissileHit(this);
|
||||
this->TTL = 0;
|
||||
return;
|
||||
|
@ -1625,8 +1624,8 @@ void MissileWhirlwind::Action()
|
|||
// Center of the tornado
|
||||
//
|
||||
PixelPos center = this->position + this->Type->size / 2;
|
||||
center.x = (center.x + TileSizeX / 2) / TileSizeX;
|
||||
center.y = (center.y + TileSizeY) / TileSizeY;
|
||||
center.x = (center.x + PixelTileSize.x / 2) / PixelTileSize.x;
|
||||
center.y = (center.y + PixelTileSize.y) / PixelTileSize.y;
|
||||
|
||||
#if 0
|
||||
CUnit *table[UnitMax];
|
||||
|
@ -1678,8 +1677,8 @@ void MissileWhirlwind::Action()
|
|||
nx = center.x + SyncRand() % 5 - 2;
|
||||
ny = center.y + SyncRand() % 5 - 2;
|
||||
} while (!Map.Info.IsPointOnMap(nx, ny));
|
||||
this->destination.x = nx * TileSizeX + TileSizeX / 2;
|
||||
this->destination.y = ny * TileSizeY + TileSizeY / 2;
|
||||
this->destination.x = nx * PixelTileSize.x + PixelTileSize.x / 2;
|
||||
this->destination.y = ny * PixelTileSize.y + PixelTileSize.y / 2;
|
||||
this->source = this->position;
|
||||
this->State = 0;
|
||||
DebugPrint("Whirlwind new direction: %d, %d, TTL: %d\n" _C_
|
||||
|
@ -1721,8 +1720,8 @@ void MissileDeathCoil::Action()
|
|||
//
|
||||
int ec = 0; // enemy count
|
||||
CUnit* table[UnitMax];
|
||||
const int x = this->destination.x / TileSizeX;
|
||||
const int y = this->destination.y / TileSizeY;
|
||||
const int x = this->destination.x / PixelTileSize.x;
|
||||
const int y = this->destination.y / PixelTileSize.y;
|
||||
const int n = Map.Select(x - 2, y - 2, x + 2 + 1, y + 2 + 1, table);
|
||||
|
||||
if (n == 0) {
|
||||
|
|
|
@ -659,11 +659,11 @@ static int SelectSpritesInsideRectangle (int sx0, int sy0, int sx1, int sy1,
|
|||
CUnit* unit = (CUnit*)table[i];
|
||||
const CUnitType *type = unit->Type;
|
||||
|
||||
sprite_x = unit->tilePos.x * TileSizeX + unit->IX;
|
||||
sprite_x -= (type->BoxWidth - TileSizeX * type->TileWidth) / 2;
|
||||
sprite_x = unit->tilePos.x * PixelTileSize.x + unit->IX;
|
||||
sprite_x -= (type->BoxWidth - PixelTileSize.x * type->TileWidth) / 2;
|
||||
sprite_x += type->OffsetX;
|
||||
sprite_y = unit->tilePos.y * TileSizeY + unit->IY;
|
||||
sprite_y -= (type->BoxHeight - TileSizeY * type->TileHeight) / 2;
|
||||
sprite_y = unit->tilePos.y * PixelTileSize.y + unit->IY;
|
||||
sprite_y -= (type->BoxHeight - PixelTileSize.y * type->TileHeight) / 2;
|
||||
sprite_y += type->OffsetY;
|
||||
if (sprite_x + type->BoxWidth < sx0) {
|
||||
continue;
|
||||
|
@ -685,10 +685,10 @@ static int SelectSpritesInsideRectangle (int sx0, int sy0, int sx1, int sy1,
|
|||
static int DoSelectUnitsInRectangle (int sx0, int sy0, int sx1, int sy1,
|
||||
CUnit**table, int num_units = UnitMax)
|
||||
{
|
||||
const int tx0 = sx0 / TileSizeX;
|
||||
const int ty0 = sy0 / TileSizeY;
|
||||
const int tx1 = sx1 / TileSizeX;
|
||||
const int ty1 = sy1 / TileSizeY;
|
||||
const int tx0 = sx0 / PixelTileSize.x;
|
||||
const int ty0 = sy0 / PixelTileSize.y;
|
||||
const int tx1 = sx1 / PixelTileSize.x;
|
||||
const int ty1 = sy1 / PixelTileSize.y;
|
||||
int r = Map.Select(tx0 - 2, ty0 - 2, tx1 + 2 + 1, ty1 + 2 + 1, table, num_units);
|
||||
r = SelectSpritesInsideRectangle(sx0, sy0, sx1, sy1, table, r);
|
||||
|
||||
|
@ -802,8 +802,8 @@ int AddSelectedUnitsInRectangle(int x0, int y0, int x1, int y1)
|
|||
}
|
||||
|
||||
// If no unit in rectangle area... do nothing
|
||||
toggle_num = Map.Select((x0 / TileSizeX) - 2, (y0 / TileSizeY) - 2,
|
||||
(x1 / TileSizeX) + 2 + 1, (y1 / TileSizeX) + 2 + 1, table);
|
||||
toggle_num = Map.Select((x0 / PixelTileSize.x) - 2, (y0 / PixelTileSize.y) - 2,
|
||||
(x1 / PixelTileSize.x) + 2 + 1, (y1 / PixelTileSize.y) + 2 + 1, table);
|
||||
if (!toggle_num) {
|
||||
return NumSelected;
|
||||
}
|
||||
|
@ -835,10 +835,10 @@ CUnit**table, int num_units = UnitMax)
|
|||
int tx1;
|
||||
int ty1;
|
||||
|
||||
tx0 = sx0 / TileSizeX;
|
||||
ty0 = sy0 / TileSizeY;
|
||||
tx1 = sx1 / TileSizeX;
|
||||
ty1 = sy1 / TileSizeY;
|
||||
tx0 = sx0 / PixelTileSize.x;
|
||||
ty0 = sy0 / PixelTileSize.y;
|
||||
tx1 = sx1 / PixelTileSize.x;
|
||||
ty1 = sy1 / PixelTileSize.y;
|
||||
|
||||
r = Map.Select(tx0 - 2, ty0 - 2, tx1 + 2 + 1, ty1 + 2 + 1, table, num_units);
|
||||
r = SelectSpritesInsideRectangle(sx0, sy0, sx1, sy1, table, r);
|
||||
|
@ -886,10 +886,10 @@ int SelectGroundUnitsInRectangle(int sx0, int sy0, int sx1, int sy1)
|
|||
|
||||
int DoSelectAirUnitsInRectangle(int sx0, int sy0, int sx1, int sy1, CUnit**table)
|
||||
{
|
||||
const int tx0 = sx0 / TileSizeX;
|
||||
const int ty0 = sy0 / TileSizeY;
|
||||
const int tx1 = sx1 / TileSizeX;
|
||||
const int ty1 = sy1 / TileSizeY;
|
||||
const int tx0 = sx0 / PixelTileSize.x;
|
||||
const int ty0 = sy0 / PixelTileSize.y;
|
||||
const int tx1 = sx1 / PixelTileSize.x;
|
||||
const int ty1 = sy1 / PixelTileSize.y;
|
||||
|
||||
int r = Map.Select(tx0 - 2, ty0 - 2, tx1 + 2 + 1, ty1 + 2 + 1, table);
|
||||
r = SelectSpritesInsideRectangle(sx0, sy0, sx1, sy1, table, r);
|
||||
|
@ -963,10 +963,10 @@ int AddSelectedGroundUnitsInRectangle(int sx0, int sy0, int sx1, int sy1)
|
|||
return DoSelectGroundUnitsInRectangle(sx0, sy0, sx1, sy1, table);
|
||||
}
|
||||
|
||||
const int tx0 = sx0 / TileSizeX;
|
||||
const int ty0 = sy0 / TileSizeY;
|
||||
const int tx1 = sx1 / TileSizeX;
|
||||
const int ty1 = sy1 / TileSizeY;
|
||||
const int tx0 = sx0 / PixelTileSize.x;
|
||||
const int ty0 = sy0 / PixelTileSize.y;
|
||||
const int tx1 = sx1 / PixelTileSize.x;
|
||||
const int ty1 = sy1 / PixelTileSize.y;
|
||||
int r = Map.Select(tx0 - 2, ty0 - 2, tx1 + 2 + 1, ty1 + 2 + 1, table);
|
||||
r = SelectSpritesInsideRectangle(sx0, sy0, sx1, sy1, table, r);
|
||||
|
||||
|
@ -1029,10 +1029,10 @@ int AddSelectedAirUnitsInRectangle(int sx0, int sy0, int sx1, int sy1)
|
|||
return DoSelectAirUnitsInRectangle(sx0, sy0, sx1, sy1, table);
|
||||
}
|
||||
|
||||
const int tx0 = sx0 / TileSizeX;
|
||||
const int ty0 = sy0 / TileSizeY;
|
||||
const int tx1 = sx1 / TileSizeX;
|
||||
const int ty1 = sy1 / TileSizeY;
|
||||
const int tx0 = sx0 / PixelTileSize.x;
|
||||
const int ty0 = sy0 / PixelTileSize.y;
|
||||
const int tx1 = sx1 / PixelTileSize.x;
|
||||
const int ty1 = sy1 / PixelTileSize.y;
|
||||
|
||||
int r = Map.Select(tx0 - 2, ty0 - 2, tx1 + 2 + 1, ty1 + 2 + 1, table);
|
||||
r = SelectSpritesInsideRectangle(sx0, sy0, sx1, sy1, table, r);
|
||||
|
|
|
@ -265,14 +265,14 @@ int AreaBombardment::Cast(CUnit &caster, const SpellType *, CUnit *, int x, int
|
|||
} while (!Map.Info.IsPointOnMap(dx, dy));
|
||||
for (i = 0; i < shards; ++i) {
|
||||
mis = MakeMissile(missile,
|
||||
dx * TileSizeX + TileSizeX / 2 + offsetx,
|
||||
dy * TileSizeY + TileSizeY / 2 + offsety,
|
||||
dx * TileSizeX + TileSizeX / 2,
|
||||
dy * TileSizeY + TileSizeY / 2);
|
||||
dx * PixelTileSize.x + PixelTileSize.x / 2 + offsetx,
|
||||
dy * PixelTileSize.y + PixelTileSize.y / 2 + offsety,
|
||||
dx * PixelTileSize.x + PixelTileSize.x / 2,
|
||||
dy * PixelTileSize.y + PixelTileSize.y / 2);
|
||||
// FIXME: This is just patched up, it works, but I have no idea why.
|
||||
// FIXME: What is the reasoning behind all this?
|
||||
if (mis->Type->Speed) {
|
||||
mis->Delay = i * mis->Type->Sleep * 2 * TileSizeX / mis->Type->Speed;
|
||||
mis->Delay = i * mis->Type->Sleep * 2 * PixelTileSize.x / mis->Type->Speed;
|
||||
} else {
|
||||
mis->Delay = i * mis->Type->Sleep * mis->Type->G->NumFrames;
|
||||
}
|
||||
|
@ -301,15 +301,15 @@ static void EvaluateMissileLocation(const SpellActionMissileLocation *location,
|
|||
CUnit &caster, CUnit *target, int x, int y, int *resx, int *resy)
|
||||
{
|
||||
if (location->Base == LocBaseCaster) {
|
||||
*resx = caster.tilePos.x * TileSizeX + TileSizeX / 2;
|
||||
*resy = caster.tilePos.y * TileSizeY + TileSizeY / 2;
|
||||
*resx = caster.tilePos.x * PixelTileSize.x + PixelTileSize.x / 2;
|
||||
*resy = caster.tilePos.y * PixelTileSize.y + PixelTileSize.y / 2;
|
||||
} else {
|
||||
if (target) {
|
||||
*resx = target->tilePos.x * TileSizeX + TileSizeX / 2;
|
||||
*resy = target->tilePos.y * TileSizeY + TileSizeY / 2;
|
||||
*resx = target->tilePos.x * PixelTileSize.x + PixelTileSize.x / 2;
|
||||
*resy = target->tilePos.y * PixelTileSize.y + PixelTileSize.y / 2;
|
||||
} else {
|
||||
*resx = x * TileSizeX + TileSizeX / 2;
|
||||
*resy = y * TileSizeY + TileSizeY / 2;
|
||||
*resx = x * PixelTileSize.x + PixelTileSize.x / 2;
|
||||
*resy = y * PixelTileSize.y + PixelTileSize.y / 2;
|
||||
}
|
||||
}
|
||||
*resx += location->AddX;
|
||||
|
|
|
@ -177,7 +177,7 @@ static void UiCenterOnGroup(unsigned group, GroupSelectionMode mode = SELECTABLE
|
|||
}
|
||||
}
|
||||
if (pos.x != -1) {
|
||||
UI.SelectedViewport->Center(pos.x, pos.y, TileSizeX / 2, TileSizeY / 2);
|
||||
UI.SelectedViewport->Center(pos, PixelTileSize / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -395,7 +395,7 @@ static void UiCenterOnSelected(void)
|
|||
while (n--) {
|
||||
pos += (Selected[n]->tilePos - pos) / 2;
|
||||
}
|
||||
UI.SelectedViewport->Center(pos.x, pos.y, TileSizeX / 2, TileSizeY / 2);
|
||||
UI.SelectedViewport->Center(pos, PixelTileSize / 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ static void UiSaveMapPosition(unsigned position)
|
|||
static void UiRecallMapPosition(unsigned position)
|
||||
{
|
||||
UI.SelectedViewport->Set(
|
||||
SavedMapPositionX[position], SavedMapPositionY[position], TileSizeX / 2, TileSizeY / 2);
|
||||
SavedMapPositionX[position], SavedMapPositionY[position], PixelTileSize.x / 2, PixelTileSize.y / 2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -452,7 +452,7 @@ static void UiFindIdleWorker()
|
|||
CurrentButtonLevel = 0;
|
||||
PlayUnitSound(*Selected[0], VoiceSelected);
|
||||
SelectionChanged();
|
||||
UI.SelectedViewport->Center(unit->tilePos.x, unit->tilePos.y, TileSizeX / 2, TileSizeY / 2);
|
||||
UI.SelectedViewport->Center(unit->tilePos, PixelTileSize / 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1181,14 +1181,13 @@ void CenterOnMessage(void)
|
|||
if (MessagesEventCount == 0) {
|
||||
return;
|
||||
}
|
||||
UI.SelectedViewport->Center(
|
||||
MessagesEventX[MessagesEventIndex], MessagesEventY[MessagesEventIndex],
|
||||
TileSizeX / 2, TileSizeY / 2);
|
||||
const Vec2i pos = {MessagesEventX[MessagesEventIndex], MessagesEventY[MessagesEventIndex]};
|
||||
UI.SelectedViewport->Center(pos, PixelTileSize / 2);
|
||||
SetMessage(_("~<Event: %s~>"), MessagesEvent[MessagesEventIndex]);
|
||||
++MessagesEventIndex;
|
||||
}
|
||||
|
||||
void ToggleShowMessages(void) {
|
||||
void ToggleShowMessages() {
|
||||
allmessages.ToggleShowMessages();
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ void DoRightButton(int sx, int sy)
|
|||
return;
|
||||
}
|
||||
|
||||
const Vec2i pos = {sx / TileSizeX, sy / TileSizeY};
|
||||
const Vec2i pos = {sx / PixelTileSize.x, sy / PixelTileSize.y};
|
||||
|
||||
//
|
||||
// Right mouse with SHIFT appends command to old commands.
|
||||
|
@ -868,10 +868,10 @@ void UIHandleMouseMove(int x, int y)
|
|||
// Restrict mouse to minimap when dragging
|
||||
if (OldCursorOn == CursorOnMinimap && CursorOn != CursorOnMinimap &&
|
||||
(MouseButtons & LeftButton)) {
|
||||
const Vec2i cursorPos = {UI.Minimap.Screen2MapX(CursorX), UI.Minimap.Screen2MapY(CursorY)};
|
||||
|
||||
RestrictCursorToMinimap();
|
||||
UI.SelectedViewport->Center(
|
||||
UI.Minimap.Screen2MapX(CursorX), UI.Minimap.Screen2MapY(CursorY),
|
||||
TileSizeX / 2, TileSizeY / 2);
|
||||
UI.SelectedViewport->Center(cursorPos, PixelTileSize / 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -889,8 +889,8 @@ void UIHandleMouseMove(int x, int y)
|
|||
const Vec2i tilePos = {vp->Viewport2MapX(x), vp->Viewport2MapY(y)};
|
||||
|
||||
if (Map.IsFieldExplored(ThisPlayer, tilePos) || ReplayRevealMap) {
|
||||
UnitUnderCursor = UnitOnScreen(NULL, x - vp->X + vp->MapX * TileSizeX + vp->OffsetX,
|
||||
y - vp->Y + vp->MapY * TileSizeY + vp->OffsetY);
|
||||
UnitUnderCursor = UnitOnScreen(NULL, x - vp->X + vp->MapX * PixelTileSize.x + vp->OffsetX,
|
||||
y - vp->Y + vp->MapY * PixelTileSize.y + vp->OffsetY);
|
||||
}
|
||||
} else if (CursorOn == CursorOnMinimap) {
|
||||
const Vec2i tilePos = {UI.Minimap.Screen2MapX(x), UI.Minimap.Screen2MapY(y)};
|
||||
|
@ -921,12 +921,11 @@ void UIHandleMouseMove(int x, int y)
|
|||
}
|
||||
}
|
||||
if (CursorOn == CursorOnMinimap && (MouseButtons & RightButton)) {
|
||||
const Vec2i cursorPos = {UI.Minimap.Screen2MapX(CursorX), UI.Minimap.Screen2MapY(CursorY)};
|
||||
//
|
||||
// Minimap move viewpoint
|
||||
//
|
||||
UI.SelectedViewport->Center(
|
||||
UI.Minimap.Screen2MapX(CursorX),
|
||||
UI.Minimap.Screen2MapY(CursorY), TileSizeX / 2, TileSizeY / 2);
|
||||
UI.SelectedViewport->Center(cursorPos, PixelTileSize / 2);
|
||||
}
|
||||
}
|
||||
// FIXME: must move minimap if right button is down !
|
||||
|
@ -952,9 +951,9 @@ void UIHandleMouseMove(int x, int y)
|
|||
//
|
||||
// Minimap move viewpoint
|
||||
//
|
||||
UI.SelectedViewport->Center(
|
||||
UI.Minimap.Screen2MapX(CursorX), UI.Minimap.Screen2MapY(CursorY),
|
||||
TileSizeX / 2, TileSizeY / 2);
|
||||
const Vec2i cursorPos = {UI.Minimap.Screen2MapX(CursorX), UI.Minimap.Screen2MapY(CursorY)};
|
||||
|
||||
UI.SelectedViewport->Center(cursorPos, PixelTileSize / 2);
|
||||
CursorStartX = CursorX;
|
||||
CursorStartY = CursorY;
|
||||
return;
|
||||
|
@ -982,7 +981,7 @@ static int SendRepair(int sx, int sy)
|
|||
CUnit *unit = Selected[i];
|
||||
|
||||
if (unit->Type->RepairRange) {
|
||||
const Vec2i tilePos = {sx / TileSizeX, sy / TileSizeY};
|
||||
const Vec2i tilePos = {sx / PixelTileSize.x, sy / PixelTileSize.y};
|
||||
const int flush = !(KeyModifiers & ModifierShift);
|
||||
|
||||
SendCommandRepair(*unit, tilePos, dest, flush);
|
||||
|
@ -1026,7 +1025,7 @@ static int SendMove(int sx, int sy)
|
|||
transporter = NULL;
|
||||
}
|
||||
|
||||
const Vec2i tilePos = {sx / TileSizeX, sy / TileSizeY};
|
||||
const Vec2i tilePos = {sx / PixelTileSize.x, sy / PixelTileSize.y};
|
||||
const int flush = !(KeyModifiers & ModifierShift);
|
||||
|
||||
for (int i = 0; i < NumSelected; ++i) {
|
||||
|
@ -1063,7 +1062,7 @@ static int SendMove(int sx, int sy)
|
|||
*/
|
||||
static int SendAttack(int sx, int sy)
|
||||
{
|
||||
const Vec2i tilePos = {sx / TileSizeX, sy / TileSizeY};
|
||||
const Vec2i tilePos = {sx / PixelTileSize.x, sy / PixelTileSize.y};
|
||||
const int flush = !(KeyModifiers & ModifierShift);
|
||||
CUnit *dest = UnitUnderCursor;
|
||||
int ret = 0;
|
||||
|
@ -1100,7 +1099,7 @@ static int SendAttack(int sx, int sy)
|
|||
*/
|
||||
static int SendAttackGround(int sx, int sy)
|
||||
{
|
||||
const Vec2i tilePos = {sx / TileSizeX, sy / TileSizeY};
|
||||
const Vec2i tilePos = {sx / PixelTileSize.x, sy / PixelTileSize.y};
|
||||
const int flush = !(KeyModifiers & ModifierShift);
|
||||
int ret = 0;
|
||||
|
||||
|
@ -1125,7 +1124,7 @@ static int SendAttackGround(int sx, int sy)
|
|||
*/
|
||||
static int SendPatrol(int sx, int sy)
|
||||
{
|
||||
const Vec2i tilePos = {sx / TileSizeX, sy / TileSizeY};
|
||||
const Vec2i tilePos = {sx / PixelTileSize.x, sy / PixelTileSize.y};
|
||||
const int flush = !(KeyModifiers & ModifierShift);
|
||||
|
||||
int ret = 0;
|
||||
|
@ -1151,7 +1150,7 @@ static int SendResource(int sx, int sy)
|
|||
int res;
|
||||
CUnit *dest = UnitUnderCursor;
|
||||
int ret = 0;
|
||||
const Vec2i pos = {sx / TileSizeX, sy / TileSizeY};
|
||||
const Vec2i pos = {sx / PixelTileSize.x, sy / PixelTileSize.y};
|
||||
const int flush = !(KeyModifiers & ModifierShift);
|
||||
|
||||
for (int i = 0; i < NumSelected; ++i) {
|
||||
|
@ -1216,7 +1215,7 @@ static int SendResource(int sx, int sy)
|
|||
*/
|
||||
static int SendUnload(int sx, int sy)
|
||||
{
|
||||
const Vec2i tilePos = {sx / TileSizeX, sy / TileSizeY};
|
||||
const Vec2i tilePos = {sx / PixelTileSize.x, sy / PixelTileSize.y};
|
||||
const int flush = !(KeyModifiers & ModifierShift);
|
||||
int ret = 0;
|
||||
|
||||
|
@ -1242,7 +1241,7 @@ static int SendUnload(int sx, int sy)
|
|||
*/
|
||||
static int SendSpellCast(int sx, int sy)
|
||||
{
|
||||
const Vec2i tilePos = {sx / TileSizeX, sy / TileSizeY};
|
||||
const Vec2i tilePos = {sx / PixelTileSize.x, sy / PixelTileSize.y};
|
||||
const int flush = !(KeyModifiers & ModifierShift);
|
||||
CUnit *dest = UnitUnderCursor;
|
||||
int ret = 0;
|
||||
|
@ -1409,13 +1408,13 @@ static void UISelectStateButtonDown(unsigned)
|
|||
if (MouseButtons & LeftButton) {
|
||||
const CViewport *vp = UI.MouseViewport;
|
||||
if (!ClickMissile.empty()) {
|
||||
int mx = vp->MapX * TileSizeX + CursorX - vp->X + vp->OffsetX;
|
||||
int my = vp->MapY * TileSizeY + CursorY - vp->Y + vp->OffsetY;
|
||||
int mx = vp->MapX * PixelTileSize.x + CursorX - vp->X + vp->OffsetX;
|
||||
int my = vp->MapY * PixelTileSize.y + CursorY - vp->Y + vp->OffsetY;
|
||||
MakeLocalMissile(MissileTypeByIdent(ClickMissile),
|
||||
mx, my, mx, my);
|
||||
}
|
||||
int sx = CursorX - vp->X + TileSizeX * vp->MapX + vp->OffsetX;
|
||||
int sy = CursorY - vp->Y + TileSizeY * vp->MapY + vp->OffsetY;
|
||||
int sx = CursorX - vp->X + PixelTileSize.x * vp->MapX + vp->OffsetX;
|
||||
int sy = CursorY - vp->Y + PixelTileSize.y * vp->MapY + vp->OffsetY;
|
||||
SendCommand(sx, sy);
|
||||
}
|
||||
return;
|
||||
|
@ -1429,8 +1428,8 @@ static void UISelectStateButtonDown(unsigned)
|
|||
int my = UI.Minimap.Screen2MapY(CursorY);
|
||||
|
||||
if (MouseButtons & LeftButton) {
|
||||
int sx = mx * TileSizeX;
|
||||
int sy = my * TileSizeY;
|
||||
int sx = mx * PixelTileSize.x;
|
||||
int sy = my * PixelTileSize.y;
|
||||
UI.StatusLine.Clear();
|
||||
ClearCosts();
|
||||
CursorState = CursorStatePoint;
|
||||
|
@ -1439,11 +1438,13 @@ static void UISelectStateButtonDown(unsigned)
|
|||
UI.ButtonPanel.Update();
|
||||
if (!ClickMissile.empty()) {
|
||||
MakeLocalMissile(MissileTypeByIdent(ClickMissile),
|
||||
sx + TileSizeX / 2, sy + TileSizeY / 2, 0, 0);
|
||||
sx + PixelTileSize.x / 2, sy + PixelTileSize.y / 2, 0, 0);
|
||||
}
|
||||
SendCommand(sx, sy);
|
||||
} else {
|
||||
UI.SelectedViewport->Center(mx, my, TileSizeX / 2, TileSizeY / 2);
|
||||
const Vec2i cursorPos = {mx, my};
|
||||
|
||||
UI.SelectedViewport->Center(cursorPos, PixelTileSize / 2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1627,21 +1628,21 @@ void UIHandleButtonDown(unsigned button)
|
|||
} else { // if not not click on building -- green cross
|
||||
if (!ClickMissile.empty()) {
|
||||
MakeLocalMissile(MissileTypeByIdent(ClickMissile),
|
||||
UI.MouseViewport->MapX * TileSizeX +
|
||||
UI.MouseViewport->MapX * PixelTileSize.x +
|
||||
CursorX - UI.MouseViewport->X + UI.MouseViewport->OffsetX,
|
||||
UI.MouseViewport->MapY * TileSizeY +
|
||||
UI.MouseViewport->MapY * PixelTileSize.y +
|
||||
CursorY - UI.MouseViewport->Y + UI.MouseViewport->OffsetY, 0, 0);
|
||||
}
|
||||
}
|
||||
DoRightButton(tilePos.x * TileSizeX, tilePos.y * TileSizeY);
|
||||
DoRightButton(tilePos.x * PixelTileSize.x, tilePos.y * PixelTileSize.y);
|
||||
}
|
||||
} else if (MouseButtons & LeftButton) { // enter select mode
|
||||
CursorStartX = CursorX;
|
||||
CursorStartY = CursorY;
|
||||
CursorStartScrMapX = CursorStartX - UI.MouseViewport->X +
|
||||
TileSizeX * UI.MouseViewport->MapX + UI.MouseViewport->OffsetX;
|
||||
PixelTileSize.x * UI.MouseViewport->MapX + UI.MouseViewport->OffsetX;
|
||||
CursorStartScrMapY = CursorStartY - UI.MouseViewport->Y +
|
||||
TileSizeY * UI.MouseViewport->MapY + UI.MouseViewport->OffsetY;
|
||||
PixelTileSize.y * UI.MouseViewport->MapY + UI.MouseViewport->OffsetY;
|
||||
GameCursor = UI.Cross.Cursor;
|
||||
CursorState = CursorStateRectangle;
|
||||
} else if (MouseButtons & MiddleButton) {// enter move map mode
|
||||
|
@ -1654,19 +1655,19 @@ void UIHandleButtonDown(unsigned button)
|
|||
//
|
||||
} else if (CursorOn == CursorOnMinimap) {
|
||||
if (MouseButtons & LeftButton) { // enter move mini-mode
|
||||
UI.SelectedViewport->Center(
|
||||
UI.Minimap.Screen2MapX(CursorX), UI.Minimap.Screen2MapY(CursorY),
|
||||
TileSizeX / 2, TileSizeY / 2);
|
||||
const Vec2i cursorPos = {UI.Minimap.Screen2MapX(CursorX), UI.Minimap.Screen2MapY(CursorY)};
|
||||
|
||||
UI.SelectedViewport->Center(cursorPos, PixelTileSize / 2);
|
||||
} else if (MouseButtons & RightButton) {
|
||||
if (!GameObserve && !GamePaused) {
|
||||
if (!ClickMissile.empty()) {
|
||||
MakeLocalMissile(MissileTypeByIdent(ClickMissile),
|
||||
UI.Minimap.Screen2MapX(CursorX) * TileSizeX + TileSizeX / 2,
|
||||
UI.Minimap.Screen2MapY(CursorY) * TileSizeY + TileSizeY / 2, 0, 0);
|
||||
UI.Minimap.Screen2MapX(CursorX) * PixelTileSize.x + PixelTileSize.x / 2,
|
||||
UI.Minimap.Screen2MapY(CursorY) * PixelTileSize.y + PixelTileSize.y / 2, 0, 0);
|
||||
}
|
||||
// DoRightButton() takes screen map coordinates
|
||||
DoRightButton(UI.Minimap.Screen2MapX(CursorX) * TileSizeX,
|
||||
UI.Minimap.Screen2MapY(CursorY) * TileSizeY);
|
||||
DoRightButton(UI.Minimap.Screen2MapX(CursorX) * PixelTileSize.x,
|
||||
UI.Minimap.Screen2MapY(CursorY) * PixelTileSize.y);
|
||||
}
|
||||
}
|
||||
//
|
||||
|
@ -1701,10 +1702,11 @@ void UIHandleButtonDown(unsigned button)
|
|||
// clicked on single unit shown
|
||||
//
|
||||
if (ButtonUnderCursor == 0 && NumSelected == 1) {
|
||||
const PixelPos offset = {Selected[0]->IX + PixelTileSize.x / 2,
|
||||
Selected[0]->IY + PixelTileSize.y / 2};
|
||||
|
||||
PlayGameSound(GameSounds.Click.Sound, MaxSampleVolume);
|
||||
UI.SelectedViewport->Center(Selected[0]->tilePos.x,
|
||||
Selected[0]->tilePos.y, Selected[0]->IX + TileSizeX / 2,
|
||||
Selected[0]->IY + TileSizeY / 2);
|
||||
UI.SelectedViewport->Center(Selected[0]->tilePos, offset);
|
||||
}
|
||||
//
|
||||
// clicked on training button
|
||||
|
@ -1881,9 +1883,9 @@ void UIHandleButtonUp(unsigned button)
|
|||
int x0 = CursorStartScrMapX;
|
||||
int y0 = CursorStartScrMapY;
|
||||
int x1 = CursorX - UI.MouseViewport->X +
|
||||
UI.MouseViewport->MapX * TileSizeX + UI.MouseViewport->OffsetX;
|
||||
UI.MouseViewport->MapX * PixelTileSize.x + UI.MouseViewport->OffsetX;
|
||||
int y1 = CursorY - UI.MouseViewport->Y +
|
||||
UI.MouseViewport->MapY * TileSizeY + UI.MouseViewport->OffsetY;
|
||||
UI.MouseViewport->MapY * PixelTileSize.y + UI.MouseViewport->OffsetY;
|
||||
|
||||
if (x0 > x1) {
|
||||
std::swap(x0, x1);
|
||||
|
@ -1923,8 +1925,8 @@ void UIHandleButtonUp(unsigned button)
|
|||
const Vec2i cursorTilePos = {UI.MouseViewport->Viewport2MapX(CursorX),
|
||||
UI.MouseViewport->Viewport2MapY(CursorY)};
|
||||
if (Map.IsFieldVisible(ThisPlayer, cursorTilePos) || ReplayRevealMap) {
|
||||
int pixelposx = CursorX - UI.MouseViewport->X + UI.MouseViewport->MapX * TileSizeX + UI.MouseViewport->OffsetX;
|
||||
int pixelposy = CursorY - UI.MouseViewport->Y + UI.MouseViewport->MapY * TileSizeY + UI.MouseViewport->OffsetY;
|
||||
int pixelposx = CursorX - UI.MouseViewport->X + UI.MouseViewport->MapX * PixelTileSize.x + UI.MouseViewport->OffsetX;
|
||||
int pixelposy = CursorY - UI.MouseViewport->Y + UI.MouseViewport->MapY * PixelTileSize.y + UI.MouseViewport->OffsetY;
|
||||
|
||||
unit = UnitOnScreen(unit, pixelposx, pixelposy);
|
||||
}
|
||||
|
|
|
@ -127,11 +127,11 @@ void InitUserInterface(void)
|
|||
// Calculations
|
||||
//
|
||||
if (Map.Info.MapWidth) {
|
||||
if (UI.MapArea.EndX > Map.Info.MapWidth * TileSizeX - 1) {
|
||||
UI.MapArea.EndX = Map.Info.MapWidth * TileSizeX - 1;
|
||||
if (UI.MapArea.EndX > Map.Info.MapWidth * PixelTileSize.x - 1) {
|
||||
UI.MapArea.EndX = Map.Info.MapWidth * PixelTileSize.x - 1;
|
||||
}
|
||||
if (UI.MapArea.EndY > Map.Info.MapHeight * TileSizeY - 1) {
|
||||
UI.MapArea.EndY = Map.Info.MapHeight * TileSizeY - 1;
|
||||
if (UI.MapArea.EndY > Map.Info.MapHeight * PixelTileSize.y - 1) {
|
||||
UI.MapArea.EndY = Map.Info.MapHeight * PixelTileSize.y - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -368,8 +368,8 @@ static void FinishViewportModeConfiguration(CViewport new_vps[], int num_vps)
|
|||
new_vps[i].MapY = 0;
|
||||
vp = GetViewport(new_vps[i].X, new_vps[i].Y);
|
||||
if (vp) {
|
||||
new_vps[i].OffsetX = new_vps[i].X - vp->X + vp->MapX * TileSizeX + vp->OffsetX;
|
||||
new_vps[i].OffsetY = new_vps[i].Y - vp->Y + vp->MapY * TileSizeY + vp->OffsetY;
|
||||
new_vps[i].OffsetX = new_vps[i].X - vp->X + vp->MapX * PixelTileSize.x + vp->OffsetX;
|
||||
new_vps[i].OffsetY = new_vps[i].Y - vp->Y + vp->MapY * PixelTileSize.y + vp->OffsetY;
|
||||
} else {
|
||||
new_vps[i].OffsetX = 0;
|
||||
new_vps[i].OffsetY = 0;
|
||||
|
@ -425,8 +425,8 @@ static void FinishViewportModeConfiguration(CViewport new_vps[], int num_vps)
|
|||
static void ClipViewport(CViewport *vp, int ClipX, int ClipY)
|
||||
{
|
||||
// begin with maximum possible viewport size
|
||||
vp->EndX = vp->X + Map.Info.MapWidth * TileSizeX - 1;
|
||||
vp->EndY = vp->Y + Map.Info.MapHeight * TileSizeY - 1;
|
||||
vp->EndX = vp->X + Map.Info.MapWidth * PixelTileSize.x - 1;
|
||||
vp->EndY = vp->Y + Map.Info.MapHeight * PixelTileSize.y - 1;
|
||||
|
||||
// first clip it to MapArea size if necessary
|
||||
if (vp->EndX > ClipX) {
|
||||
|
|
|
@ -1417,13 +1417,13 @@ bool CUnit::IsVisibleInViewport(const CViewport *vp) const
|
|||
//
|
||||
// Check if the graphic is inside the viewport.
|
||||
//
|
||||
int x = tilePos.x * TileSizeX + IX - (Type->Width - Type->TileWidth * TileSizeX) / 2 + Type->OffsetX;
|
||||
int y = tilePos.y * TileSizeY + IY - (Type->Height - Type->TileHeight * TileSizeY) / 2 + Type->OffsetY;
|
||||
int x = tilePos.x * PixelTileSize.x + IX - (Type->Width - Type->TileWidth * PixelTileSize.x) / 2 + Type->OffsetX;
|
||||
int y = tilePos.y * PixelTileSize.y + IY - (Type->Height - Type->TileHeight * PixelTileSize.y) / 2 + Type->OffsetY;
|
||||
|
||||
if (x + Type->Width < vp->MapX * TileSizeX + vp->OffsetX ||
|
||||
x > vp->MapX * TileSizeX + vp->OffsetX + (vp->EndX - vp->X) ||
|
||||
y + Type->Height < vp->MapY * TileSizeY + vp->OffsetY ||
|
||||
y > vp->MapY * TileSizeY + vp->OffsetY + (vp->EndY - vp->Y))
|
||||
if (x + Type->Width < vp->MapX * PixelTileSize.x + vp->OffsetX ||
|
||||
x > vp->MapX * PixelTileSize.x + vp->OffsetX + (vp->EndX - vp->X) ||
|
||||
y + Type->Height < vp->MapY * PixelTileSize.y + vp->OffsetY ||
|
||||
y > vp->MapY * PixelTileSize.y + vp->OffsetY + (vp->EndY - vp->Y))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -2687,10 +2687,10 @@ CUnit *UnitOnScreen(CUnit *ounit, int x, int y)
|
|||
//
|
||||
// Check if mouse is over the unit.
|
||||
//
|
||||
gx = unit->tilePos.x * TileSizeX + unit->IX;
|
||||
gx = unit->tilePos.x * PixelTileSize.x + unit->IX;
|
||||
|
||||
{
|
||||
const int local_width = type->TileWidth * TileSizeX;
|
||||
const int local_width = type->TileWidth * PixelTileSize.x;
|
||||
if (x + (type->BoxWidth - local_width) / 2 < gx) {
|
||||
continue;
|
||||
}
|
||||
|
@ -2699,9 +2699,9 @@ CUnit *UnitOnScreen(CUnit *ounit, int x, int y)
|
|||
}
|
||||
}
|
||||
|
||||
gy = unit->tilePos.y * TileSizeY + unit->IY;
|
||||
gy = unit->tilePos.y * PixelTileSize.y + unit->IY;
|
||||
{
|
||||
const int local_height = type->TileHeight * TileSizeY;
|
||||
const int local_height = type->TileHeight * PixelTileSize.y;
|
||||
if (y + (type->BoxHeight - local_height) / 2 < gy) {
|
||||
continue;
|
||||
}
|
||||
|
@ -2758,16 +2758,16 @@ void LetUnitDie(CUnit &unit)
|
|||
//
|
||||
if (type->ExplodeWhenKilled) {
|
||||
MakeMissile(type->Explosion.Missile,
|
||||
unit.tilePos.x * TileSizeX + type->TileWidth * TileSizeX / 2,
|
||||
unit.tilePos.y * TileSizeY + type->TileHeight * TileSizeY / 2,
|
||||
unit.tilePos.x * PixelTileSize.x + type->TileWidth * PixelTileSize.x / 2,
|
||||
unit.tilePos.y * PixelTileSize.y + type->TileHeight * PixelTileSize.y / 2,
|
||||
0, 0);
|
||||
}
|
||||
if (type->DeathExplosion) {
|
||||
type->DeathExplosion->pushPreamble();
|
||||
type->DeathExplosion->pushInteger(unit.tilePos.x * TileSizeX +
|
||||
type->TileWidth * TileSizeX / 2);
|
||||
type->DeathExplosion->pushInteger(unit.tilePos.y * TileSizeY +
|
||||
type->TileHeight * TileSizeY / 2);
|
||||
type->DeathExplosion->pushInteger(unit.tilePos.x * PixelTileSize.x +
|
||||
type->TileWidth * PixelTileSize.x / 2);
|
||||
type->DeathExplosion->pushInteger(unit.tilePos.y * PixelTileSize.y +
|
||||
type->TileHeight * PixelTileSize.y / 2);
|
||||
type->DeathExplosion->run();
|
||||
}
|
||||
// Handle Teleporter Destination Removal
|
||||
|
@ -2991,10 +2991,10 @@ void HitUnit(CUnit *attacker, CUnit &target, int damage)
|
|||
|
||||
if ((target.IsVisibleOnMap(*ThisPlayer) || ReplayRevealMap) && !DamageMissile.empty()) {
|
||||
MakeLocalMissile(MissileTypeByIdent(DamageMissile),
|
||||
target.tilePos.x * TileSizeX + target.Type->TileWidth * TileSizeX / 2,
|
||||
target.tilePos.y * TileSizeY + target.Type->TileHeight * TileSizeY / 2,
|
||||
target.tilePos.x * TileSizeX + target.Type->TileWidth * TileSizeX / 2 + 3,
|
||||
target.tilePos.y * TileSizeY + target.Type->TileHeight * TileSizeY / 2 -
|
||||
target.tilePos.x * PixelTileSize.x + target.Type->TileWidth * PixelTileSize.x / 2,
|
||||
target.tilePos.y * PixelTileSize.y + target.Type->TileHeight * PixelTileSize.y / 2,
|
||||
target.tilePos.x * PixelTileSize.x + target.Type->TileWidth * PixelTileSize.x / 2 + 3,
|
||||
target.tilePos.y * PixelTileSize.y + target.Type->TileHeight * PixelTileSize.y / 2 -
|
||||
MissileTypeByIdent(DamageMissile)->Range)->Damage = -damage;
|
||||
}
|
||||
|
||||
|
@ -3002,13 +3002,13 @@ void HitUnit(CUnit *attacker, CUnit &target, int damage)
|
|||
// FIXME: want to show hits.
|
||||
if (type.Organic) {
|
||||
MakeMissile(MissileBlood,
|
||||
target.tilePos.x * TileSizeX + TileSizeX / 2,
|
||||
target.tilePos.y * TileSizeY + TileSizeY / 2, 0, 0);
|
||||
target.tilePos.x * PixelTileSize.x + PixelTileSize.x / 2,
|
||||
target.tilePos.y * PixelTileSize.y + PixelTileSize.y / 2, 0, 0);
|
||||
}
|
||||
if (type.Building) {
|
||||
MakeMissile(MissileSmallFire,
|
||||
target.tilePos.x * TileSizeX + (type->TileWidth * TileSizeX) / 2,
|
||||
target.tilePos.y * TileSizeY + (type->TileHeight * TileSizeY) / 2, 0, 0);
|
||||
target.tilePos.x * PixelTileSize.x + (type->TileWidth * PixelTileSize.x) / 2,
|
||||
target.tilePos.y * PixelTileSize.y + (type->TileHeight * PixelTileSize.y) / 2, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -3021,8 +3021,8 @@ void HitUnit(CUnit *attacker, CUnit &target, int damage)
|
|||
fire = MissileBurningBuilding(f);
|
||||
if (fire) {
|
||||
missile = MakeMissile(fire,
|
||||
target.tilePos.x * TileSizeX + (type->TileWidth * TileSizeX) / 2,
|
||||
target.tilePos.y * TileSizeY + (type->TileHeight * TileSizeY) / 2 - TileSizeY,
|
||||
target.tilePos.x * PixelTileSize.x + (type->TileWidth * PixelTileSize.x) / 2,
|
||||
target.tilePos.y * PixelTileSize.y + (type->TileHeight * PixelTileSize.y) / 2 - PixelTileSize.y,
|
||||
0, 0);
|
||||
missile->SourceUnit = ⌖
|
||||
target.Burning = 1;
|
||||
|
|
|
@ -174,10 +174,10 @@ void DrawUnitSelection(const CViewport *vp, const CUnit &unit)
|
|||
|
||||
const CUnitType *type = unit.Type;
|
||||
int x = vp->Map2ViewportX(unit.tilePos.x) + unit.IX +
|
||||
type->TileWidth * TileSizeX / 2 - type->BoxWidth / 2 -
|
||||
type->TileWidth * PixelTileSize.x / 2 - type->BoxWidth / 2 -
|
||||
(type->Width - type->Sprite->Width) / 2;
|
||||
int y = vp->Map2ViewportY(unit.tilePos.y) + unit.IY +
|
||||
type->TileHeight * TileSizeY / 2 - type->BoxHeight / 2 -
|
||||
type->TileHeight * PixelTileSize.y / 2 - type->BoxHeight / 2 -
|
||||
(type->Height - type->Sprite->Height) / 2;
|
||||
|
||||
DrawSelection(color, x, y, x + type->BoxWidth, y + type->BoxHeight);
|
||||
|
@ -598,8 +598,8 @@ static void DrawDecoration(const CUnit &unit, const CUnitType *type, int x, int
|
|||
(ThisPlayer->IsAllied(unit) && (unit.Player != ThisPlayer) && var->HideAllied) ||
|
||||
max == 0)) {
|
||||
var->Draw(
|
||||
x + var->OffsetX + var->OffsetXPercent * unit.Type->TileWidth * TileSizeX / 100,
|
||||
y + var->OffsetY + var->OffsetYPercent * unit.Type->TileHeight * TileSizeY / 100,
|
||||
x + var->OffsetX + var->OffsetXPercent * unit.Type->TileWidth * PixelTileSize.x / 100,
|
||||
y + var->OffsetY + var->OffsetYPercent * unit.Type->TileHeight * PixelTileSize.y / 100,
|
||||
type, unit.Variable[var->Index]);
|
||||
}
|
||||
}
|
||||
|
@ -616,9 +616,9 @@ static void DrawDecoration(const CUnit &unit, const CUnitType *type, int x, int
|
|||
for (groupId = 0; !(unit.GroupId & (1 << groupId)); ++groupId)
|
||||
;
|
||||
int width = GameFont->Width(groupId);
|
||||
x += (unit.Type->TileWidth * TileSizeX + unit.Type->BoxWidth) / 2 - width;
|
||||
x += (unit.Type->TileWidth * PixelTileSize.x + unit.Type->BoxWidth) / 2 - width;
|
||||
width = GameFont->Height();
|
||||
y += (unit.Type->TileHeight * TileSizeY + unit.Type->BoxHeight) / 2 - width;
|
||||
y += (unit.Type->TileHeight * PixelTileSize.y + unit.Type->BoxHeight) / 2 - width;
|
||||
CLabel(GameFont).DrawClip(x, y, groupId);
|
||||
}
|
||||
}
|
||||
|
@ -639,8 +639,8 @@ void DrawShadow(const CUnitType &type, int frame, int x, int y)
|
|||
if (!type.ShadowSprite) {
|
||||
return;
|
||||
}
|
||||
x -= (type.ShadowWidth - type.TileWidth * TileSizeX) / 2;
|
||||
y -= (type.ShadowHeight - type.TileHeight * TileSizeY) / 2;
|
||||
x -= (type.ShadowWidth - type.TileWidth * PixelTileSize.x) / 2;
|
||||
y -= (type.ShadowHeight - type.TileHeight * PixelTileSize.y) / 2;
|
||||
x += type.OffsetX + type.ShadowOffsetX;
|
||||
y += type.OffsetY + type.ShadowOffsetY;
|
||||
|
||||
|
@ -677,25 +677,25 @@ static void GetOrderPosition(const CUnit &unit, const COrderPtr order, int *x, i
|
|||
if ((goal = order->GetGoal()) && (!goal->Removed)) {
|
||||
// Order has a goal, get it's location.
|
||||
*x = CurrentViewport->Map2ViewportX(goal->tilePos.x) + goal->IX +
|
||||
goal->Type->TileWidth * TileSizeX / 2;
|
||||
goal->Type->TileWidth * PixelTileSize.x / 2;
|
||||
*y = CurrentViewport->Map2ViewportY(goal->tilePos.y) + goal->IY +
|
||||
goal->Type->TileHeight * TileSizeY / 2;
|
||||
goal->Type->TileHeight * PixelTileSize.y / 2;
|
||||
} else {
|
||||
if (order->goalPos.x >= 0 && order->goalPos.y >= 0) {
|
||||
// Order is for a location, show that.
|
||||
*x = CurrentViewport->Map2ViewportX(order->goalPos.x) + TileSizeX / 2;
|
||||
*y = CurrentViewport->Map2ViewportY(order->goalPos.y) + TileSizeY / 2;
|
||||
*x = CurrentViewport->Map2ViewportX(order->goalPos.x) + PixelTileSize.x / 2;
|
||||
*y = CurrentViewport->Map2ViewportY(order->goalPos.y) + PixelTileSize.y / 2;
|
||||
} else {
|
||||
// Some orders ignore x,y (like StandStill).
|
||||
// Use the unit's position instead.
|
||||
*x = CurrentViewport->Map2ViewportX(unit.tilePos.x) + unit.IX +
|
||||
unit.Type->TileWidth * TileSizeX / 2;
|
||||
unit.Type->TileWidth * PixelTileSize.x / 2;
|
||||
*y = CurrentViewport->Map2ViewportY(unit.tilePos.y) + unit.IY +
|
||||
unit.Type->TileHeight * TileSizeY / 2;
|
||||
unit.Type->TileHeight * PixelTileSize.y / 2;
|
||||
}
|
||||
if (order->Action == UnitActionBuild) {
|
||||
*x += (order->Arg1.Type->TileWidth - 1) * TileSizeX / 2;
|
||||
*y += (order->Arg1.Type->TileHeight - 1) * TileSizeY / 2;
|
||||
*x += (order->Arg1.Type->TileWidth - 1) * PixelTileSize.x / 2;
|
||||
*y += (order->Arg1.Type->TileHeight - 1) * PixelTileSize.y / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -741,8 +741,8 @@ static void ShowSingleOrder(const CUnit &unit, int x1, int y1, const COrderPtr o
|
|||
case UnitActionPatrol:
|
||||
Video.DrawLineClip(ColorGreen, x1, y1, x2, y2);
|
||||
e_color = color = ColorBlue;
|
||||
x1 = CurrentViewport->Map2ViewportX(order->Arg1.Patrol.x) + TileSizeX / 2;
|
||||
y1 = CurrentViewport->Map2ViewportY(order->Arg1.Patrol.y) + TileSizeY / 2;
|
||||
x1 = CurrentViewport->Map2ViewportX(order->Arg1.Patrol.x) + PixelTileSize.x / 2;
|
||||
y1 = CurrentViewport->Map2ViewportY(order->Arg1.Patrol.y) + PixelTileSize.y / 2;
|
||||
dest = true;
|
||||
break;
|
||||
|
||||
|
@ -752,8 +752,8 @@ static void ShowSingleOrder(const CUnit &unit, int x1, int y1, const COrderPtr o
|
|||
break;
|
||||
|
||||
case UnitActionAttackGround:
|
||||
x2 = CurrentViewport->Map2ViewportX(order->goalPos.x) + TileSizeX / 2;
|
||||
y2 = CurrentViewport->Map2ViewportY(order->goalPos.y) + TileSizeY / 2;
|
||||
x2 = CurrentViewport->Map2ViewportX(order->goalPos.x) + PixelTileSize.x / 2;
|
||||
y2 = CurrentViewport->Map2ViewportY(order->goalPos.y) + PixelTileSize.y / 2;
|
||||
// FALL THROUGH
|
||||
case UnitActionAttack:
|
||||
if (unit.SubAction & 2) { // Show weak targets.
|
||||
|
@ -855,9 +855,9 @@ void ShowOrder(const CUnit &unit)
|
|||
|
||||
// Get current position
|
||||
x1 = CurrentViewport->Map2ViewportX(
|
||||
unit.tilePos.x) + unit.IX + unit.Type->TileWidth * TileSizeX / 2;
|
||||
unit.tilePos.x) + unit.IX + unit.Type->TileWidth * PixelTileSize.x / 2;
|
||||
y1 = CurrentViewport->Map2ViewportY(
|
||||
unit.tilePos.y) + unit.IY + unit.Type->TileHeight * TileSizeY / 2;
|
||||
unit.tilePos.y) + unit.IY + unit.Type->TileHeight * PixelTileSize.y / 2;
|
||||
|
||||
// If the current order is cancelled show the next one
|
||||
if (unit.OrderCount > 1 && unit.OrderFlush) {
|
||||
|
@ -912,9 +912,9 @@ static void DrawInformations(const CUnit &unit, const CUnitType *type, int x, in
|
|||
if (Preference.ShowSightRange) {
|
||||
// Radius -1 so you can see all ranges
|
||||
Video.DrawCircleClip(ColorGreen,
|
||||
x + type->TileWidth * TileSizeX / 2,
|
||||
y + type->TileHeight * TileSizeY / 2,
|
||||
((stats->Variables[SIGHTRANGE_INDEX].Max + (type->TileWidth - 1)) * TileSizeX) - 1);
|
||||
x + type->TileWidth * PixelTileSize.x / 2,
|
||||
y + type->TileHeight * PixelTileSize.y / 2,
|
||||
((stats->Variables[SIGHTRANGE_INDEX].Max + (type->TileWidth - 1)) * PixelTileSize.x) - 1);
|
||||
}
|
||||
if (type->CanAttack) {
|
||||
if (Preference.ShowReactionRange) {
|
||||
|
@ -922,17 +922,17 @@ static void DrawInformations(const CUnit &unit, const CUnitType *type, int x, in
|
|||
type->ReactRangePerson : type->ReactRangeComputer;
|
||||
if (r) {
|
||||
Video.DrawCircleClip(ColorBlue,
|
||||
x + type->TileWidth * TileSizeX / 2,
|
||||
y + type->TileHeight * TileSizeY / 2,
|
||||
(r + (type->TileWidth - 1)) * TileSizeX);
|
||||
x + type->TileWidth * PixelTileSize.x / 2,
|
||||
y + type->TileHeight * PixelTileSize.y / 2,
|
||||
(r + (type->TileWidth - 1)) * PixelTileSize.x);
|
||||
}
|
||||
}
|
||||
if (Preference.ShowAttackRange && stats->Variables[ATTACKRANGE_INDEX].Max) {
|
||||
// Radius + 1 so you can see all ranges
|
||||
Video.DrawCircleClip(ColorRed,
|
||||
x + type->TileWidth * TileSizeX / 2,
|
||||
y + type->TileHeight * TileSizeY / 2,
|
||||
(stats->Variables[ATTACKRANGE_INDEX].Max + (type->TileWidth - 1)) * TileSizeX + 1);
|
||||
x + type->TileWidth * PixelTileSize.x / 2,
|
||||
y + type->TileHeight * PixelTileSize.y / 2,
|
||||
(stats->Variables[ATTACKRANGE_INDEX].Max + (type->TileWidth - 1)) * PixelTileSize.x + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -980,8 +980,8 @@ void DrawUnitPlayerColor(const CUnitType *type, CGraphic *sprite,
|
|||
}
|
||||
|
||||
// FIXME: move this calculation to high level.
|
||||
x -= (type->Width - type->TileWidth * TileSizeX) / 2;
|
||||
y -= (type->Height - type->TileHeight * TileSizeY) / 2;
|
||||
x -= (type->Width - type->TileWidth * PixelTileSize.x) / 2;
|
||||
y -= (type->Height - type->TileHeight * PixelTileSize.y) / 2;
|
||||
|
||||
if (type->Flip) {
|
||||
if (frame < 0) {
|
||||
|
@ -1017,9 +1017,9 @@ static void DrawConstructionShadow(const CUnitType &type, const CConstructionFra
|
|||
{
|
||||
if (cframe->File == ConstructionFileConstruction) {
|
||||
if (type.Construction->ShadowSprite) {
|
||||
x -= (type.Construction->Width - type.TileWidth * TileSizeX) / 2;
|
||||
x -= (type.Construction->Width - type.TileWidth * PixelTileSize.x) / 2;
|
||||
x += type.OffsetX;
|
||||
y -= (type.Construction->Height - type.TileHeight * TileSizeY )/ 2;
|
||||
y -= (type.Construction->Height - type.TileHeight * PixelTileSize.y )/ 2;
|
||||
y += type.OffsetY;
|
||||
if (frame < 0) {
|
||||
type.Construction->ShadowSprite->DrawFrameClipX(-frame - 1, x, y);
|
||||
|
@ -1029,9 +1029,9 @@ static void DrawConstructionShadow(const CUnitType &type, const CConstructionFra
|
|||
}
|
||||
} else {
|
||||
if (type.ShadowSprite) {
|
||||
x -= (type.ShadowWidth - type.TileWidth * TileSizeX) / 2;
|
||||
x -= (type.ShadowWidth - type.TileWidth * PixelTileSize.x) / 2;
|
||||
x += type.ShadowOffsetX + type.OffsetX;
|
||||
y -= (type.ShadowHeight - type.TileHeight * TileSizeY) / 2;
|
||||
y -= (type.ShadowHeight - type.TileHeight * PixelTileSize.y) / 2;
|
||||
y += type.ShadowOffsetY + type.OffsetY;
|
||||
if (frame < 0) {
|
||||
type.ShadowSprite->DrawFrameClipX(-frame - 1, x, y);
|
||||
|
@ -1191,8 +1191,8 @@ void CUnit::Draw(const CViewport *vp) const
|
|||
if (state == 1) {
|
||||
if (constructed) {
|
||||
DrawConstruction(player, cframe, *type, frame,
|
||||
x + (type->TileWidth * TileSizeX) / 2,
|
||||
y + (type->TileHeight * TileSizeY) / 2);
|
||||
x + (type->TileWidth * PixelTileSize.x) / 2,
|
||||
y + (type->TileHeight * PixelTileSize.y) / 2);
|
||||
}
|
||||
//
|
||||
// Draw the future unit type, if upgrading to it.
|
||||
|
@ -1325,8 +1325,8 @@ void CUnitDrawProxy::DrawDecorationAt(int x, int y) const
|
|||
(ThisPlayer->IsAllied(*Player) && var->HideAllied))) ||
|
||||
max == 0)) {
|
||||
var->Draw(
|
||||
x + var->OffsetX + var->OffsetXPercent * Type->TileWidth * TileSizeX / 100,
|
||||
y + var->OffsetY + var->OffsetYPercent * Type->TileHeight * TileSizeY / 100,
|
||||
x + var->OffsetX + var->OffsetXPercent * Type->TileWidth * PixelTileSize.x / 100,
|
||||
y + var->OffsetY + var->OffsetYPercent * Type->TileHeight * PixelTileSize.y / 100,
|
||||
Type, Variable[i]);
|
||||
}
|
||||
}
|
||||
|
@ -1341,9 +1341,9 @@ void CUnitDrawProxy::DrawDecorationAt(int x, int y) const
|
|||
#endif
|
||||
) {
|
||||
int width = GameFont->Width(GroupId - 1);
|
||||
x += (Type->TileWidth * TileSizeX + Type->BoxWidth) / 2 - width;
|
||||
x += (Type->TileWidth * PixelTileSize.x + Type->BoxWidth) / 2 - width;
|
||||
width = GameFont->Height();
|
||||
y += (Type->TileHeight * TileSizeY + Type->BoxHeight) / 2 - width;
|
||||
y += (Type->TileHeight * PixelTileSize.y + Type->BoxHeight) / 2 - width;
|
||||
CLabel(GameFont).DrawClip(x, y, GroupId - 1);
|
||||
}
|
||||
}
|
||||
|
@ -1386,9 +1386,9 @@ void CUnitDrawProxy::DrawSelectionAt(int x, int y) const
|
|||
return;
|
||||
}
|
||||
|
||||
int xx = x + Type->TileWidth * TileSizeX / 2 - Type->BoxWidth / 2 -
|
||||
int xx = x + Type->TileWidth * PixelTileSize.x / 2 - Type->BoxWidth / 2 -
|
||||
(Type->Width - Type->Sprite->Width) / 2;
|
||||
int yy = y + Type->TileHeight * TileSizeY / 2 - Type->BoxHeight / 2 -
|
||||
int yy = y + Type->TileHeight * PixelTileSize.y / 2 - Type->BoxHeight / 2 -
|
||||
(Type->Height - Type->Sprite->Height) / 2;
|
||||
|
||||
DrawSelection(color, xx, yy, xx + Type->BoxWidth, yy + Type->BoxHeight);
|
||||
|
@ -1438,8 +1438,8 @@ void CUnitDrawProxy::Draw(const CViewport *vp) const
|
|||
if (state == 1) {
|
||||
if (cframe) {
|
||||
DrawConstruction(Player->Index, cframe, *Type, frame,
|
||||
x + (Type->TileWidth * TileSizeX) / 2,
|
||||
y + (Type->TileHeight * TileSizeY) / 2);
|
||||
x + (Type->TileWidth * PixelTileSize.x) / 2,
|
||||
y + (Type->TileHeight * PixelTileSize.y) / 2);
|
||||
}
|
||||
//
|
||||
// Draw the future unit type, if upgrading to it.
|
||||
|
@ -1476,8 +1476,8 @@ static inline bool DrawLevelCompare(const CUnit*c1, const CUnit*c2)
|
|||
// diffpos compares unit's Y positions (bottom of sprite) on the map
|
||||
// and uses X position in case Y positions are equal.
|
||||
// FIXME: Use BoxHeight?
|
||||
const int pos1 = (c1->tilePos.y * TileSizeY + c1->IY + c1->Type->Height);
|
||||
const int pos2 = (c2->tilePos.y * TileSizeY + c2->IY + c2->Type->Height);
|
||||
const int pos1 = (c1->tilePos.y * PixelTileSize.y + c1->IY + c1->Type->Height);
|
||||
const int pos2 = (c2->tilePos.y * PixelTileSize.y + c2->IY + c2->Type->Height);
|
||||
return pos1 == pos2 ?
|
||||
(c1->tilePos.x - c2->tilePos.x ? c1->tilePos.x < c2->tilePos.x : c1->Slot < c2->Slot) : pos1 < pos2;
|
||||
} else {
|
||||
|
|
|
@ -416,8 +416,8 @@ CUnitType *NewUnitTypeSlot(const std::string &ident)
|
|||
void DrawUnitType(const CUnitType &type, CPlayerColorGraphic *sprite, int player, int frame, int x, int y)
|
||||
{
|
||||
// FIXME: move this calculation to high level.
|
||||
x -= (type.Width - type.TileWidth * TileSizeX) / 2;
|
||||
y -= (type.Height - type.TileHeight * TileSizeY) / 2;
|
||||
x -= (type.Width - type.TileWidth * PixelTileSize.x) / 2;
|
||||
y -= (type.Height - type.TileHeight * PixelTileSize.y) / 2;
|
||||
x += type.OffsetX;
|
||||
y += type.OffsetY;
|
||||
|
||||
|
|
|
@ -193,8 +193,8 @@ static void DrawBuildingCursor()
|
|||
{
|
||||
// Align to grid
|
||||
const CViewport &vp = *UI.MouseViewport;
|
||||
int x = CursorX - (CursorX - vp.X + vp.OffsetX) % TileSizeX;
|
||||
int y = CursorY - (CursorY - vp.Y + vp.OffsetY) % TileSizeY;
|
||||
int x = CursorX - (CursorX - vp.X + vp.OffsetX) % PixelTileSize.x;
|
||||
int y = CursorY - (CursorY - vp.Y + vp.OffsetY) % PixelTileSize.y;
|
||||
const Vec2i mpos = {vp.Viewport2MapX(x), vp.Viewport2MapY(y)};
|
||||
CUnit *ontop = NULL;
|
||||
|
||||
|
@ -213,9 +213,9 @@ static void DrawBuildingCursor()
|
|||
CursorBuilding->StillFrame, x, y);
|
||||
if (CursorBuilding->CanAttack && CursorBuilding->Stats->Variables[ATTACKRANGE_INDEX].Value>0){
|
||||
Video.DrawCircleClip(ColorRed,
|
||||
x + CursorBuilding->TileWidth * TileSizeX / 2,
|
||||
y + CursorBuilding->TileHeight * TileSizeY / 2,
|
||||
(CursorBuilding->Stats->Variables[ATTACKRANGE_INDEX].Max + (CursorBuilding->TileWidth - 1)) * TileSizeX + 1);
|
||||
x + CursorBuilding->TileWidth * PixelTileSize.x / 2,
|
||||
y + CursorBuilding->TileHeight * PixelTileSize.y / 2,
|
||||
(CursorBuilding->Stats->Variables[ATTACKRANGE_INDEX].Max + (CursorBuilding->TileWidth - 1)) * PixelTileSize.x + 1);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -261,8 +261,8 @@ static void DrawBuildingCursor()
|
|||
} else {
|
||||
color = ColorRed;
|
||||
}
|
||||
Video.FillTransRectangleClip(color, x + w * TileSizeX, y + h *
|
||||
TileSizeY, TileSizeX, TileSizeY, 95);
|
||||
Video.FillTransRectangleClip(color, x + w * PixelTileSize.x, y + h *
|
||||
PixelTileSize.y, PixelTileSize.x, PixelTileSize.y, 95);
|
||||
}
|
||||
}
|
||||
PopClipping();
|
||||
|
@ -278,8 +278,8 @@ void DrawCursor()
|
|||
if (CursorState == CursorStateRectangle &&
|
||||
(CursorStartX != CursorX || CursorStartY != CursorY)) {
|
||||
DrawVisibleRectangleCursor(
|
||||
CursorStartScrMapX + UI.MouseViewport->X - TileSizeX * UI.MouseViewport->MapX - UI.MouseViewport->OffsetX,
|
||||
CursorStartScrMapY + UI.MouseViewport->Y - TileSizeY * UI.MouseViewport->MapY - UI.MouseViewport->OffsetY,
|
||||
CursorStartScrMapX + UI.MouseViewport->X - PixelTileSize.x * UI.MouseViewport->MapX - UI.MouseViewport->OffsetX,
|
||||
CursorStartScrMapY + UI.MouseViewport->Y - PixelTileSize.y * UI.MouseViewport->MapY - UI.MouseViewport->OffsetY,
|
||||
CursorX, CursorY);
|
||||
} else if (CursorBuilding && CursorOn == CursorOnMap) {
|
||||
// Selecting position for building
|
||||
|
|
Loading…
Add table
Reference in a new issue