Skip to content

Commit

Permalink
Add item name info
Browse files Browse the repository at this point in the history
  • Loading branch information
postm1 committed Apr 13, 2024
1 parent c8faaca commit af5f469
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions SpacerNET_Union/Spacer_Loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,11 @@ namespace GOTHIC_ENGINE {

wasCopiedPressed = false;
}

if (auto pItem = pVob->CastTo <oCItem>())
{
PrintItemName(pItem);
}
}
else
{
Expand Down
37 changes: 37 additions & 0 deletions SpacerNET_Union/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,43 @@ namespace GOTHIC_ENGINE {
}
}

void PrintItemName(oCItem* pItem)
{
if (!pItem) return;



if (auto visual = pItem->GetVisual())
{
zPOINT3 focusNamePosWS;

focusNamePosWS = pItem->GetBBox3DWorld().GetCenter();
focusNamePosWS.n[VY] += (pItem->GetBBox3DWorld().maxs.n[VY] - pItem->GetBBox3DWorld().mins.n[VY]) * 1.75F;

zCCamera::activeCam->Activate();
zPOINT3 ProjPoint1 = zCCamera::activeCam->Transform(focusNamePosWS);
if (ProjPoint1[VZ] > 0.0f)
{
auto text = pItem->GetName(0);

zPOINT2 ProjPoint2;
zCCamera::activeCam->Project(&ProjPoint1, ProjPoint2[VX], ProjPoint2[VY]);
ProjPoint2[VX] = ProjPoint2[VX] - screen->nax(screen->FontSize(text) / 2);

// CLAMP
int nX = screen->anx(ProjPoint2[VX]);
int nY = screen->any(ProjPoint2[VY]);

if (nY < screen->FontY()) nY = screen->FontY();
if (nY > 8192 - screen->FontY()) nY = 8192 - screen->FontY();

// [Ulf] Clampen auch in X-Richtung
zClamp(nX, 0, 8191 - screen->FontSize(text));

screen->Print(nX, nY, text);

};
}
}
}

0 comments on commit af5f469

Please sign in to comment.