-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexedit.cpp
More file actions
136 lines (113 loc) · 3.17 KB
/
exedit.cpp
File metadata and controls
136 lines (113 loc) · 3.17 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include "exedit.hpp"
#include <iostream>
#include <aviutl.hpp>
#include <exedit.hpp>
#include "textmodule_lua.hpp"
#include "textmodule_aviutl.hpp"
#include "textmodule_option.hpp"
bool is093rc1 = false;
void lua_pushexeditobject(lua_State* L, ExEdit::Object* object) {
lua_newtable(L);
lua_settablevalue(L, "layer", object->layer_disp + 1);
lua_settablevalue(L, "name", std::string(object->dispname));
lua_settablevalue(L, "frame", lua_Vector2(object->frame_begin + 1, object->frame_end + 1));
lua_newtable(L);
for (int i = 0; i < (object->track_n); i++)
lua_settablevalue(L, i+1, lua_Vector2(object->track_value_left[i], object->track_value_right[i]));
lua_setfield(L, -2, "track");
lua_newtable(L);
for (int i = 0; i < (object->track_n); i++)
lua_settablevalue(L, i + 1, object->track_param[i]);
lua_setfield(L, -2, "trackparam");
lua_newtable(L);
for (int i = 0; i < (object->check_n); i++)
lua_settablevalue(L, i + 1, (bool)(object->check_value[i]));
lua_setfield(L, -2, "check");
}
int exedit_currentscene(lua_State* L) {
try {
int id = *Get_SceneDisplaying(false);
ExEdit::SceneSetting* ss = Get_SceneSetting(false);
const char* name = ss[id].name;
if (name == NULL) name = "";
lua_pushnumber(L, id);
lua_pushstring(L, name);
return 2;
}
catch (std::exception& e) {
luaL_error(L, e.what());
return 1;
}
}
int exedit_scene(lua_State* L) {
try {
int id = 0;
if (lua_type(L, 1) == LUA_TNUMBER) {
id = tm_tointeger(L, 1);
if (id < 0 || id>49) return 0;
}
else if (lua_type(L, 1) == LUA_TNONE) {
id = *Get_SceneDisplaying(false);
}
else {
luaL_argerror(L, 1, "number/none expected");
}
ExEdit::SceneSetting* ss = Get_SceneSetting(false);
const char* name = ss[id].name;
if (name == NULL) name = "";
lua_newtable(L);
lua_settablevalue(L, "id", id);
lua_settablevalue(L, "name", name);
lua_settablevalue(L, "size", lua_Vector2(ss[id].width, ss[id].height));
return 1;
}
catch (std::exception& e) {
luaL_error(L, e.what());
return 1;
}
}
int exedit_textbuffer(lua_State* L) {
try {
lua_pushwstring(L, std::wstring(Get_TextBuffer(false)));
return 1;
}
catch (std::exception& e) {
luaL_error(L, e.what());
return 1;
}
}
int exedit_object(lua_State* L) {
try {
ExEdit::Object** obj_table = Get_ObjectBuffer_Data(false);
int* obj_index = Get_TraScript_ProcessingobjectIndex(false);
ExEdit::Object* object = (*obj_table) + *obj_index;
ExEdit::Filter** Filter = Get_LoadedFilterTable(false);
for (int i = 0; i < object->countFilters(); i++) {
int id = object->filter_param[i].id;
std::cout << id << ": " << Filter[id]->name << std::endl;
}
return 0;
}
catch (std::exception& e) {
luaL_error(L, e.what());
return 1;
}
}
static luaL_Reg TEXTMODULE_EXEDIT_REG[] = {
{"currentscene", exedit_currentscene},
{"scene", exedit_scene},
{"textbuffer", exedit_textbuffer},
{"object", exedit_object},
{ nullptr, nullptr }
};
void luaReg_exedit(lua_State* L, lua_Option opt) {
if (opt["api"]["exedit"]) {
tm_debuglog_apiloaded(opt, "exedit");
lua_newtable(L);
luaL_register(L, NULL, TEXTMODULE_EXEDIT_REG);
lua_setfield(L, -2, "exedit");
}
else {
tm_debuglog_apinoloaded(opt, "exedit");
}
}