mirror of
https://github.com/spiffcode/hostile-takeover.git
synced 2025-12-16 12:08:36 +00:00
Support maps that are smaller than the device screen
This commit is contained in:
parent
dc42d310d6
commit
a8d606e957
@ -931,6 +931,24 @@ void Simulation::Draw(UpdateMap *pupd, DibBitmap *pbm)
|
||||
|
||||
pupd->SetViewOrigin(0, 0);
|
||||
HostSoundServiceProc();
|
||||
|
||||
// If the screen is larger than the map size we clear those areas to black color
|
||||
|
||||
Size sizDib;
|
||||
pbm->GetSize(&sizDib);
|
||||
Size sizMap;
|
||||
m_plvl->GetTileMap()->GetMapSize(&sizMap);
|
||||
|
||||
if (sizMap.cx < sizDib.cx) {
|
||||
Rect rc;
|
||||
rc.Set(sizMap.cx, 0, sizDib.cx, sizMap.cy);
|
||||
FillHelper(pbm, pupd, &rc, GetColor(kiclrBlack));
|
||||
}
|
||||
if (sizMap.cy < sizDib.cy) {
|
||||
Rect rc;
|
||||
rc.Set(0, sizMap.cy, sizDib.cx, sizDib.cy);
|
||||
FillHelper(pbm, pupd, &rc, GetColor(kiclrBlack));
|
||||
}
|
||||
}
|
||||
|
||||
void Simulation::DrawFog(UpdateMap *pupd, DibBitmap *pbm)
|
||||
@ -953,8 +971,19 @@ bool Simulation::SetViewPos(WCoord wx, WCoord wy, bool fInit)
|
||||
Size sizPlayfield;
|
||||
ggame.GetPlayfieldSize(&sizPlayfield);
|
||||
|
||||
WCoord wcxMax = WcFromUpc(sizMap.cx - sizPlayfield.cx);
|
||||
WCoord wcyMax = WcFromUpc(sizMap.cy - sizPlayfield.cy);
|
||||
WCoord wcxMax, wcyMax;
|
||||
int cxMax = sizMap.cx - sizPlayfield.cx;
|
||||
int cyyMax = sizMap.cy - sizPlayfield.cy;
|
||||
|
||||
if (cxMax <= 0 || cxMax > kpcMax)
|
||||
wcxMax = 0;
|
||||
else
|
||||
wcxMax = WcFromUpc(cxMax);
|
||||
|
||||
if (cyyMax <= 0 || cyyMax > kpcMax)
|
||||
wcyMax = 0;
|
||||
else
|
||||
wcyMax = WcFromUpc(cyyMax);
|
||||
|
||||
if (wx < 0)
|
||||
wx = 0;
|
||||
|
||||
@ -170,6 +170,20 @@ void TileMap::Draw(DibBitmap *pbm, int x, int y, int cx, int cy, int xMap, int y
|
||||
int cty = TcFromPc(cy - pmnfo->cyTopTile + gcyTile - 1) + TcFromPc(pmnfo->cyTopTile + gcyTile - 1);
|
||||
int ctxMap = BigWord(m_ptmaph->ctx);
|
||||
|
||||
// Deal with case of map being smaller than the screen
|
||||
|
||||
Size sizMap;
|
||||
GetMapSize(&sizMap);
|
||||
|
||||
if (sizMap.cx < cx) {
|
||||
Assert(xMap == 0);
|
||||
ctx = TcFromPc(sizMap.cx);
|
||||
}
|
||||
if (sizMap.cy < cy) {
|
||||
Assert(yMap == 0);
|
||||
cty = TcFromPc(sizMap.cy);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
Assert(ctx <= m_ctx);
|
||||
Assert(cty <= m_cty);
|
||||
|
||||
@ -470,6 +470,14 @@ void UpdateMap::SetMapOffset(int xMapOffset, int yMapOffset, bool fInvalidate)
|
||||
m_yMapOffset = yMapOffset;
|
||||
int cxDib = m_rcDib.Width();
|
||||
int cyDib = m_rcDib.Height();
|
||||
if (gsim.GetLevel() != NULL) {
|
||||
Size sizTMap;
|
||||
gsim.GetLevel()->GetTileMap()->GetMapSize(&sizTMap);
|
||||
if (sizTMap.cx < cxDib)
|
||||
cxDib = sizTMap.cx;
|
||||
if (sizTMap.cy < cyDib)
|
||||
cyDib = sizTMap.cy;
|
||||
}
|
||||
m_mnfo.cxLeftTile = PcFracFromUpc(gcxTile - m_xMapOffset);
|
||||
if (cyDib < gcyTile - m_yMapOffset) {
|
||||
m_mnfo.cyTopTile = cyDib;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user