I would like to claim that auto3 now "works". It's just somewhat useless currently.
Originally committed to SVN as r1162.
This commit is contained in:
parent
73288ed43f
commit
6087314600
4 changed files with 164 additions and 8 deletions
|
@ -414,7 +414,51 @@ namespace Automation4 {
|
|||
int *borderstyle, float *outline, float *shadow, int *align, int *margin_l, int *margin_r, int *margin_v, int *encoding)
|
||||
{
|
||||
Auto3ThreadedProcessor *self = (Auto3ThreadedProcessor*)cbdata;
|
||||
// TODO
|
||||
|
||||
while (self->style_pointer != self->file->Line.end()) {
|
||||
AssStyle *style = AssEntry::GetAsStyle(*self->style_pointer);
|
||||
// Increase iterator before we test for and return style data, since it needs to be done either way
|
||||
// The iterator should always point to the next line to be examined
|
||||
self->style_pointer++;
|
||||
if (style) {
|
||||
// Put strings into buffers
|
||||
self->stylename = style->name.mb_str(wxConvUTF8);
|
||||
self->stylefont = style->font.mb_str(wxConvUTF8);
|
||||
self->stylecolor[0] = style->primary.GetASSFormatted(true, false, true).mb_str(wxConvUTF8);
|
||||
self->stylecolor[1] = style->secondary.GetASSFormatted(true, false, true).mb_str(wxConvUTF8);
|
||||
self->stylecolor[2] = style->outline.GetASSFormatted(true, false, true).mb_str(wxConvUTF8);
|
||||
self->stylecolor[3] = style->shadow.GetASSFormatted(true, false, true).mb_str(wxConvUTF8);
|
||||
|
||||
// Store data to lib
|
||||
*name = self->stylename.data();
|
||||
*fontname = self->stylefont.data();
|
||||
*fontsize = (int)style->fontsize;
|
||||
*color1 = self->stylecolor[0].data();
|
||||
*color2 = self->stylecolor[1].data();
|
||||
*color3 = self->stylecolor[2].data();
|
||||
*color4 = self->stylecolor[3].data();
|
||||
*bold = (int)style->bold;
|
||||
*italic = (int)style->italic;
|
||||
*underline = (int)style->italic;
|
||||
*strikeout = (int)style->strikeout;
|
||||
*scale_x = style->scalex;
|
||||
*scale_y = style->scaley;
|
||||
*spacing = style->spacing;
|
||||
*angle = style->angle;
|
||||
*borderstyle = style->borderstyle;
|
||||
*outline = style->outline_w;
|
||||
*shadow = style->shadow_w;
|
||||
*align = style->alignment;
|
||||
*margin_l = style->Margin[0];
|
||||
*margin_r = style->Margin[1];
|
||||
*margin_v = style->Margin[2];
|
||||
*encoding = style->encoding;
|
||||
|
||||
// and return success
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -423,7 +467,35 @@ namespace Automation4 {
|
|||
int *margin_l, int *margin_r, int *margin_v, char **effect, char **text, int *comment)
|
||||
{
|
||||
Auto3ThreadedProcessor *self = (Auto3ThreadedProcessor*)cbdata;
|
||||
// TODO
|
||||
|
||||
while (self->subs_pointer != self->file->Line.end()) {
|
||||
AssDialogue *dia = AssEntry::GetAsDialogue(*self->subs_pointer);
|
||||
self->subs_pointer++;
|
||||
if (dia) {
|
||||
// Put strings into buffers
|
||||
self->diagstyle = dia->Style.mb_str(wxConvUTF8);
|
||||
self->diagactor = dia->Actor.mb_str(wxConvUTF8);
|
||||
self->diageffect = dia->Effect.mb_str(wxConvUTF8);
|
||||
self->diagtext = dia->Text.mb_str(wxConvUTF8);
|
||||
|
||||
// Store data to lib
|
||||
*comment = (int)dia->Comment;
|
||||
*layer = dia->Layer;
|
||||
*start_time = dia->Start.GetMS()/10;
|
||||
*end_time = dia->End.GetMS()/10;
|
||||
*style = self->diagstyle.data();
|
||||
*actor = self->diagactor.data();
|
||||
*margin_l = dia->Margin[0];
|
||||
*margin_r = dia->Margin[1];
|
||||
*margin_v = dia->Margin[2];
|
||||
*effect = self->diageffect.data();
|
||||
*text = self->diagtext.data();
|
||||
|
||||
// return success
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -431,7 +503,17 @@ namespace Automation4 {
|
|||
void Auto3ThreadedProcessor::StartSubsWrite(void *cbdata)
|
||||
{
|
||||
Auto3ThreadedProcessor *self = (Auto3ThreadedProcessor*)cbdata;
|
||||
// TODO: clear events section and set subs_pointer
|
||||
|
||||
// clear all dialogue lines
|
||||
std::list<AssEntry*>::iterator line = self->file->Line.begin();
|
||||
while (line != self->file->Line.end()) {
|
||||
std::list<AssEntry*>::iterator cur = line;
|
||||
line++;
|
||||
if (AssEntry::GetAsDialogue(*cur)) {
|
||||
delete *cur;
|
||||
self->file->Line.erase(cur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -439,7 +521,23 @@ namespace Automation4 {
|
|||
int margin_l, int margin_r, int margin_v, const char *effect, const char *text, int comment)
|
||||
{
|
||||
Auto3ThreadedProcessor *self = (Auto3ThreadedProcessor*)cbdata;
|
||||
// TODO
|
||||
|
||||
// Construct dialogue object
|
||||
AssDialogue *dia = new AssDialogue();
|
||||
dia->Comment = !!comment;
|
||||
dia->Layer = layer;
|
||||
dia->Start.SetMS(start_time*10);
|
||||
dia->End.SetMS(end_time*10);
|
||||
dia->Style = wxString(style, wxConvUTF8);
|
||||
dia->Actor = wxString(actor, wxConvUTF8);
|
||||
dia->Margin[0] = margin_l;
|
||||
dia->Margin[1] = margin_r;
|
||||
dia->Margin[2] = dia->Margin[3] = margin_v;
|
||||
dia->Effect = wxString(effect, wxConvUTF8);
|
||||
dia->Text = wxString(text, wxConvUTF8);
|
||||
|
||||
// Append to file
|
||||
self->file->Line.push_back(dia);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -115,9 +115,14 @@ namespace Automation4 {
|
|||
Auto3ConfigDialog *config;
|
||||
Auto3ProgressSink *sink;
|
||||
|
||||
// Iterators used for read/write callbacks
|
||||
std::list<AssEntry*>::iterator style_pointer;
|
||||
std::list<AssEntry*>::iterator subs_pointer;
|
||||
|
||||
// Char buffers holding data used in callbacks
|
||||
wxCharBuffer stylename, stylefont, stylecolor[4], diagstyle, diagactor, diageffect, diagtext;
|
||||
|
||||
// Read/write callback functions
|
||||
static void ResetStylePointer(void *cbdata);
|
||||
static void ResetSubsPointer(void *cbdata);
|
||||
static void GetMetaInfo(void *cbdata, int *res_x, int *res_y);
|
||||
|
|
|
@ -560,7 +560,7 @@ static void MakeStylesTable(lua_State *L, struct Auto3Interpreter *script)
|
|||
int n;
|
||||
|
||||
lua_newtable(L);
|
||||
n = 0;
|
||||
n = -1;
|
||||
|
||||
script->cb.reset_style_pointer(script->cb.rwdata);
|
||||
while (script->cb.get_next_style(script->cb.rwdata, &name, &fontname, &fontsize, &color1, &color2, &color3, &color4,
|
||||
|
@ -688,7 +688,7 @@ static void MakeEventsTable(lua_State *L, struct Auto3Interpreter *script)
|
|||
int n;
|
||||
|
||||
lua_newtable(L);
|
||||
n = 0;
|
||||
n = -1;
|
||||
|
||||
script->cb.reset_subs_pointer(script->cb.rwdata);
|
||||
while (script->cb.get_next_sub(script->cb.rwdata, &layer, &start_time, &end_time, &style, &actor,
|
||||
|
|
|
@ -82,9 +82,62 @@ static int LuaInclude(lua_State *L)
|
|||
static int LuaTextExtents(lua_State *L)
|
||||
{
|
||||
struct Auto3Interpreter *script;
|
||||
const char *text, *fontname;
|
||||
int fontsize, bold, italic, spacing, encoding;
|
||||
float scale_x, scale_y;
|
||||
float out_width, out_height, out_descent, out_extlead;
|
||||
|
||||
script = GetScriptObject(L);
|
||||
// TODO
|
||||
return 0;
|
||||
|
||||
if (!script->cb.text_extents) return 0;
|
||||
|
||||
// get text
|
||||
text = luaL_checkstring(L, 2);
|
||||
|
||||
// check we have style table
|
||||
if (!lua_istable(L, 1)) {
|
||||
lua_pushstring(L, "First argument to text_extents must be style table");
|
||||
lua_error(L);
|
||||
}
|
||||
|
||||
// get style def
|
||||
lua_pushstring(L, "fontname"); lua_gettable(L, 1);
|
||||
fontname = lua_tostring(L, -1);
|
||||
|
||||
lua_pushstring(L, "fontsize"); lua_gettable(L, 1);
|
||||
fontsize = lua_tonumber(L, -1);
|
||||
|
||||
lua_pushstring(L, "bold"); lua_gettable(L, 1);
|
||||
bold = lua_toboolean(L, -1);
|
||||
|
||||
lua_pushstring(L, "italic"); lua_gettable(L, 1);
|
||||
italic = lua_toboolean(L, -1);
|
||||
|
||||
lua_pushstring(L, "scale_x"); lua_gettable(L, 1);
|
||||
scale_x = lua_tonumber(L, -1);
|
||||
|
||||
lua_pushstring(L, "scale_y"); lua_gettable(L, 1);
|
||||
scale_y = lua_tonumber(L, -1);
|
||||
|
||||
lua_pushstring(L, "spacing"); lua_gettable(L, 1);
|
||||
spacing = lua_tonumber(L, -1);
|
||||
|
||||
lua_pushstring(L, "encoding"); lua_gettable(L, 1);
|
||||
encoding = lua_tonumber(L, -1);
|
||||
|
||||
// get measurements
|
||||
script->cb.text_extents(script->cb.rundata, text, fontname, fontsize, bold, italic,
|
||||
spacing, scale_x, scale_y, encoding, &out_width, &out_height, &out_descent, &out_extlead);
|
||||
|
||||
// remove strings and stuff
|
||||
lua_pop(L, 8);
|
||||
|
||||
// return result
|
||||
lua_pushnumber(L, out_width);
|
||||
lua_pushnumber(L, out_height);
|
||||
lua_pushnumber(L, out_descent);
|
||||
lua_pushnumber(L, out_extlead);
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue