Skip to content

Commit 0e4056f

Browse files
authored
Merge pull request #1 from scp-fs2open/master
Rebase
2 parents f798c5b + fa0140f commit 0e4056f

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

code/scripting/api/objs/hudgauge.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "hudgauge.h"
55
#include "hud/hudscripting.h"
6+
#include "texture.h"
67

78
namespace scripting {
89
namespace api {
@@ -95,5 +96,29 @@ ADE_FUNC(drawString,
9596
return ADE_RETURN_TRUE;
9697
}
9798

99+
ADE_FUNC(drawImage, l_HudGaugeDrawFuncs, "texture handle Texture, [number X=0, Y=0]",
100+
"Draws an image in the context of the HUD gauge.", "boolean",
101+
"true on success, false otherwise")
102+
{
103+
HudGauge* gauge;
104+
texture_h* texture = nullptr;
105+
float x1 = 0;
106+
float y1 = 0;
107+
108+
if (!ade_get_args(L, "oo|ff", l_HudGaugeDrawFuncs.Get(&gauge), l_Texture.GetPtr(&texture), &x1, &y1)) {
109+
return ADE_RETURN_FALSE;
110+
}
111+
if (!texture->isValid()) {
112+
return ADE_RETURN_FALSE;
113+
}
114+
115+
int gauge_x, gauge_y;
116+
gauge->getPosition(&gauge_x, &gauge_y);
117+
118+
gauge->renderBitmapColor(texture->handle, fl2i(gauge_x + x1), fl2i(gauge_y + y1));
119+
120+
return ADE_RETURN_TRUE;
121+
}
122+
98123
}
99124
}

0 commit comments

Comments
 (0)