File: fictionviewer.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 (69 lines) | stat: -rw-r--r-- 1,857 bytes parent folder | download
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "fictionviewer.h"
#include "missionui/fictionviewer.h"

namespace scripting {
namespace api {

fiction_viewer_stage_h::fiction_viewer_stage_h() : f_stage(-1) {}

fiction_viewer_stage_h::fiction_viewer_stage_h(int stage) : f_stage(stage) {}

bool fiction_viewer_stage_h::isValid() const
{
	return f_stage >= 0;
}

fiction_viewer_stage* fiction_viewer_stage_h::getStage() const
{
	return &Fiction_viewer_stages[f_stage];
}

//**********HANDLE: cmd_briefing
ADE_OBJ(l_FictionViewerStage, fiction_viewer_stage_h, "fiction_viewer_stage", "Fiction Viewer stage handle");

ADE_VIRTVAR(TextFile, l_FictionViewerStage, nullptr, "The text file of the stage", "string", "The text filename")
{
	fiction_viewer_stage_h stage;
	if (!ade_get_args(L, "o", l_FictionViewerStage.Get(&stage))) {
		return ADE_RETURN_NIL;
	}

	if (ADE_SETTING_VAR) {
		LuaError(L, "This property is read only.");
	}

	SCP_string localized_filename = get_localized_fiction_filename(stage.getStage()->story_filename);

	return ade_set_args(L, "s", localized_filename.c_str());
}

ADE_VIRTVAR(FontFile, l_FictionViewerStage, nullptr, "The font file of the stage", "string", "The font filename")
{
	fiction_viewer_stage_h stage;
	if (!ade_get_args(L, "o", l_FictionViewerStage.Get(&stage))) {
		return ADE_RETURN_NIL;
	}

	if (ADE_SETTING_VAR) {
		LuaError(L, "This property is read only.");
	}

	return ade_set_args(L, "s", stage.getStage()->font_filename);
}

ADE_VIRTVAR(VoiceFile, l_FictionViewerStage, nullptr, "The voice file of the stage", "string", "The voice filename")
{
	fiction_viewer_stage_h stage;
	if (!ade_get_args(L, "o", l_FictionViewerStage.Get(&stage))) {
		return ADE_RETURN_NIL;
	}

	if (ADE_SETTING_VAR) {
		LuaError(L, "This property is read only.");
	}

	return ade_set_args(L, "s", stage.getStage()->voice_filename);
}

} // namespace api
} // namespace scripting