Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions libs/s25main/Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,8 +709,9 @@ void Loader::fillCaches()

bmp.add(dynamic_cast<glArchivItem_Bitmap_Player*>(
bob_jobs->getBody(spriteData.isFat(), imgDir, ani_step)));
bmp.add(dynamic_cast<glArchivItem_Bitmap_Player*>(
bob_jobs->getOverlay(spriteData.getBobId(Nation(nation)), spriteData.isFat(), imgDir, ani_step)));
auto overlay =
bob_jobs->getOverlay(spriteData.getBobId(Nation(nation)), spriteData.isFat(), imgDir, ani_step);
bmp.add(dynamic_cast<glArchivItem_Bitmap_Player*>(overlay.first), overlay.second);
bmp.addShadow(GetMapImage(900 + static_cast<unsigned>(imgDir) * 8 + ani_step));

stp->add(bmp);
Expand All @@ -728,7 +729,8 @@ void Loader::fillCaches()
const libsiedler2::ImgDir imgDir = toImgDir(dir);

bmp.add(dynamic_cast<glArchivItem_Bitmap_Player*>(bob_jobs->getBody(true, imgDir, ani_step)));
bmp.add(dynamic_cast<glArchivItem_Bitmap_Player*>(bob_jobs->getOverlay(0, true, imgDir, ani_step)));
auto overlay = bob_jobs->getOverlay(0, true, imgDir, ani_step);
bmp.add(dynamic_cast<glArchivItem_Bitmap_Player*>(overlay.first), overlay.second);
bmp.addShadow(GetMapImage(900 + static_cast<unsigned>(imgDir) * 8 + ani_step));

stp->add(bmp);
Expand Down Expand Up @@ -939,8 +941,8 @@ void Loader::fillCaches()
} else
{
bmp.add(dynamic_cast<glArchivItem_Bitmap_Player*>(bob_carrier->getBody(fat, imgDir, ani_step)));
bmp.add(dynamic_cast<glArchivItem_Bitmap_Player*>(
bob_carrier->getOverlay(id, fat, imgDir, ani_step)));
auto overlay = bob_carrier->getOverlay(id, fat, imgDir, ani_step);
bmp.add(dynamic_cast<glArchivItem_Bitmap_Player*>(overlay.first), overlay.second);
}
bmp.addShadow(GetMapImage(900 + static_cast<unsigned>(imgDir) * 8 + ani_step));

Expand Down
17 changes: 11 additions & 6 deletions libs/s25main/ogl/glArchivItem_Bob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later

#include "glArchivItem_Bob.h"
#include "DrawPoint.h"
#include "glArchivItem_Bitmap_Player.h"
#include "s25util/colors.h"

Expand All @@ -15,9 +16,13 @@ void glArchivItem_Bob::Draw(unsigned item, libsiedler2::ImgDir direction, bool f
auto* body = dynamic_cast<glArchivItem_Bitmap_Player*>(getBody(fat, direction, animationstep));
if(body)
body->DrawFull(drawPt, COLOR_WHITE, color);
auto* overlay = dynamic_cast<glArchivItem_Bitmap_Player*>(getOverlay(item, fat, direction, animationstep));
if(overlay)
overlay->DrawFull(drawPt, COLOR_WHITE, color);
auto overlay = getOverlay(item, fat, direction, animationstep);
auto* glOverlay = dynamic_cast<glArchivItem_Bitmap_Player*>(overlay.first);
if(glOverlay)
{
drawPt.y -= overlay.second;
glOverlay->DrawFull(drawPt, COLOR_WHITE, color);
}
}

void glArchivItem_Bob::mergeLinks(const std::map<uint16_t, uint16_t>& overrideLinks)
Expand All @@ -26,10 +31,10 @@ void glArchivItem_Bob::mergeLinks(const std::map<uint16_t, uint16_t>& overrideLi
return;
// Get last key of sorted map
const auto maxIdx = overrideLinks.rbegin()->first;
if(maxIdx >= links.size())
links.resize(maxIdx + 1u);
if(maxIdx >= spriteOverlayIdx.size())
spriteOverlayIdx.resize(maxIdx + 1u);
for(const auto& newLink : overrideLinks)
{
links[newLink.first] = newLink.second;
spriteOverlayIdx[newLink.first] = newLink.second;
}
}
4 changes: 2 additions & 2 deletions libs/s25main/ogl/glBitmapItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ glBitmapItem::glBitmapItem(libsiedler2::baseArchivItem_Bitmap* b, bool shadow, b
b->getVisibleArea(pos.x, pos.y, size.x, size.y);
origin = Position(b->getNx(), b->getNy()) - pos;
}
glBitmapItem::glBitmapItem(libsiedler2::ArchivItem_Bitmap_Player* b, bool isOwning)
glBitmapItem::glBitmapItem(libsiedler2::ArchivItem_Bitmap_Player* b, int yOffset, bool isOwning)
: bmp(b), type(glBitmapItemType::PlayerBitmap), isOwning_(isOwning)
{
b->getVisibleArea(pos.x, pos.y, size.x, size.y);
origin = Position(b->getNx(), b->getNy()) - pos;
origin = Position(b->getNx(), b->getNy() - yOffset) - pos;
}
2 changes: 1 addition & 1 deletion libs/s25main/ogl/glBitmapItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class glBitmapItem
{
public:
glBitmapItem(libsiedler2::baseArchivItem_Bitmap* b, bool shadow = false, bool isOwning = false);
glBitmapItem(libsiedler2::ArchivItem_Bitmap_Player* b, bool isOwning = false);
glBitmapItem(libsiedler2::ArchivItem_Bitmap_Player* b, int nyOffset, bool isOwning = false);

libsiedler2::ArchivItem_BitmapBase* bmp;
glBitmapItemType type;
Expand Down
4 changes: 2 additions & 2 deletions libs/s25main/ogl/glSmartBitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ Extent glSmartBitmap::getRequiredTexSize() const
return texSize;
}

void glSmartBitmap::add(libsiedler2::ArchivItem_Bitmap_Player* bmp)
void glSmartBitmap::add(libsiedler2::ArchivItem_Bitmap_Player* bmp, int nyOffset)
{
if(!bmp)
return;
items.push_back(glBitmapItem(bmp));
items.push_back(glBitmapItem(bmp, nyOffset));
calcDimensions();
}

Expand Down
2 changes: 1 addition & 1 deletion libs/s25main/ogl/glSmartBitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ class glSmartBitmap : public ITexture

void add(libsiedler2::baseArchivItem_Bitmap* bmp);
void add(std::unique_ptr<libsiedler2::baseArchivItem_Bitmap> bmp);
void add(libsiedler2::ArchivItem_Bitmap_Player* bmp);
void add(libsiedler2::ArchivItem_Bitmap_Player* bmp, int nyOffset = 0);
void addShadow(libsiedler2::baseArchivItem_Bitmap* bmp);
};
Loading