mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-09 17:52:08 -10:00
As described in #1278, the current scripting system has issues with handling non-trivial C++ types. Since fixing that deficiency is too much work, especially since we are in a feature freeze, I decided to simply enforce the usage of trivial types for scripting handles. Fortunately, only two handles used non-trivial types so it was relatively easy to fix those instances by dynamically allocating those and only storing the pointers in the lua memory. This fixes a bug in JAD-XA where the game would crash at the last boss. Also, I noticed that the HudGauge handle used a copy of the hud gauge rather than a pointer to the actual instance so I'm pretty sure that any scripting changes to a custom HUD gauge simply didn't work before.
46 lines
983 B
C++
46 lines
983 B
C++
//
|
|
//
|
|
|
|
#include "hudgauge.h"
|
|
|
|
namespace scripting {
|
|
namespace api {
|
|
|
|
ADE_OBJ(l_HudGauge, HudGauge*, "HudGauge", "HUD Gauge handle");
|
|
|
|
ADE_VIRTVAR(Name, l_HudGauge, "string", "Custom HUD Gauge name", "string", "Custom HUD Gauge name, or nil if handle is invalid")
|
|
{
|
|
HudGauge* gauge;
|
|
|
|
if (!ade_get_args(L, "o", l_HudGauge.Get(&gauge)))
|
|
return ADE_RETURN_NIL;
|
|
|
|
if (gauge->getObjectType() != HUD_OBJECT_CUSTOM)
|
|
return ADE_RETURN_NIL;
|
|
|
|
return ade_set_args(L, "s", gauge->getCustomGaugeName());
|
|
}
|
|
|
|
ADE_VIRTVAR(Text, l_HudGauge, "string", "Custom HUD Gauge text", "string", "Custom HUD Gauge text, or nil if handle is invalid")
|
|
{
|
|
HudGauge* gauge;
|
|
char* text = NULL;
|
|
|
|
if (!ade_get_args(L, "o|s", l_HudGauge.Get(&gauge), &text))
|
|
return ADE_RETURN_NIL;
|
|
|
|
if (gauge->getObjectType() != HUD_OBJECT_CUSTOM)
|
|
return ADE_RETURN_NIL;
|
|
|
|
if (ADE_SETTING_VAR && text != NULL)
|
|
{
|
|
gauge->updateCustomGaugeText(text);
|
|
}
|
|
|
|
return ade_set_args(L, "s", gauge->getCustomGaugeText());
|
|
}
|
|
|
|
|
|
}
|
|
}
|