File: hudscripting.cpp

package info (click to toggle)
freespace2 24.2.0%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 43,716 kB
  • sloc: cpp: 595,001; ansic: 21,741; python: 1,174; sh: 457; makefile: 248; xml: 181
file content (47 lines) | stat: -rw-r--r-- 1,284 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
//

#include "hud/hudscripting.h"

#include "parse/parselo.h"
#include "scripting/api/objs/hudgauge.h"
#include "scripting/scripting.h"

HudGaugeScripting::HudGaugeScripting() :
	HudGauge(HUD_OBJECT_SCRIPTING,
	         HUD_CENTER_RETICLE,
	         true,
	         false,
	         (VM_EXTERNAL | VM_DEAD_VIEW | VM_WARP_CHASE | VM_PADLOCK_ANY | VM_TOPDOWN | VM_OTHER_SHIP),
	         255,
	         255,
	         255) {
}

void HudGaugeScripting::render(float /*frametime*/) {
	using namespace scripting::api;

	if (!_renderFunction.isValid()) {
		return;
	}

	_renderFunction.call(Script_system.GetLuaSession(),
		{luacpp::LuaValue::createValue(_renderFunction.getLuaState(), l_HudGaugeDrawFuncs.Set(this))});
}

void HudGaugeScripting::initName(SCP_string name) {
	if (name.size() > NAME_LENGTH - 1) {
		error_display(0,
		              "Name \"%s\" is too long. May not be longer than %d! Name will be truncated",
		              name.c_str(),
		              NAME_LENGTH - 1);
		name.resize(NAME_LENGTH - 1);
	}
	strcpy(custom_name, name.c_str());
}
const luacpp::LuaFunction& HudGaugeScripting::getRenderFunction() const {
	return _renderFunction;
}
void HudGaugeScripting::setRenderFunction(const luacpp::LuaFunction& renderFunction) {
	_renderFunction = renderFunction;
}