Skip to content
Draft
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
27 changes: 15 additions & 12 deletions src/Misc/FlyingStrings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

std::vector<FlyingStrings::Item> FlyingStrings::Data;

bool FlyingStrings::DrawAllowed(CoordStruct& nCoords)
bool FlyingStrings::DrawAllowed(const CoordStruct& nCoords)
{
if (auto const pCell = MapClass::Instance.TryGetCellAt(nCoords))
return !(pCell->IsFogged() || pCell->IsShrouded());
Expand All @@ -30,7 +30,7 @@ void FlyingStrings::Add(const wchar_t* text, const CoordStruct& coords, ColorStr
void FlyingStrings::AddMoneyString(int amount, ObjectClass* pSource, HouseClass* pOwner,
AffectedHouse displayToHouses, const CoordStruct& coords, Point2D pixelOffset)
{
if (amount == 0 || MapClass::Instance.IsLocationShrouded(coords))
if (amount == 0 || !FlyingStrings::DrawAllowed(coords))
return;

if (displayToHouses != AffectedHouse::All && !EnumFunctions::CanTargetHouse(displayToHouses, pOwner, HouseClass::CurrentPlayer))
Expand Down Expand Up @@ -64,17 +64,20 @@ void FlyingStrings::UpdateAll()

point += dataItem.PixelOffset;

RectangleStruct bound = DSurface::Temp->GetRect();
bound.Height -= 32;

if (Unsorted::CurrentFrame > dataItem.CreationFrame + Duration - 70)
{
point.Y -= (Unsorted::CurrentFrame - dataItem.CreationFrame);
DSurface::Temp->DrawText(dataItem.Text, &bound, &point, dataItem.Color, 0, TextPrintType::NoShadow);
}
else
if (FlyingStrings::DrawAllowed(dataItem.Location))
{
DSurface::Temp->DrawText(dataItem.Text, &bound, &point, dataItem.Color, 0, TextPrintType::NoShadow);
RectangleStruct bound = DSurface::Temp->GetRect();
bound.Height -= 32;

if (Unsorted::CurrentFrame > dataItem.CreationFrame + Duration - 70)
{
point.Y -= (Unsorted::CurrentFrame - dataItem.CreationFrame);
DSurface::Temp->DrawText(dataItem.Text, &bound, &point, dataItem.Color, 0, TextPrintType::NoShadow);
}
else
{
DSurface::Temp->DrawText(dataItem.Text, &bound, &point, dataItem.Color, 0, TextPrintType::NoShadow);
}
}

if (Unsorted::CurrentFrame > dataItem.CreationFrame + Duration || Unsorted::CurrentFrame < dataItem.CreationFrame)
Expand Down
2 changes: 1 addition & 1 deletion src/Misc/FlyingStrings.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class FlyingStrings
static const int Duration = 75;
static std::vector<Item> Data;

static bool DrawAllowed(CoordStruct& nCoords);
static bool DrawAllowed(const CoordStruct& nCoords);

public:
static void Add(const wchar_t* text, const CoordStruct& coords, ColorStruct color, Point2D pixelOffset = Point2D::Empty);
Expand Down
Loading