2 local old_set_font_file
= set_font_file
;
3 local old_text_metrics
= text_metrics
;
4 local old_render_text
= render_text
;
7 dofile("textrender.lua");
9 local new_set_font_file
= set_font_file
;
10 local new_text_metrics
= text_metrics
;
11 local new_render_text
= render_text
;
13 font
, err
= io
.open_arch_read("subtitle-font");
15 error("Can't open font: " .. err
);
17 new_set_font_file(font
);
20 set_font_file
= old_set_font_file
;
21 text_metrics
= old_text_metrics
;
22 render_text
= old_render_text
;
24 tasvideos_subtitle_this_is_TAS
= function()
25 return "This is a tool-assisted recording.\nFor details, visit http://TASVideos.org/";
28 tasvideos_subtitle_this_is_TAS_fast
= function()
29 return "This was a tool-assisted recording.\nFor details, visit http://TASVideos.org/";
32 for_each_header
= function(callback
)
33 local headers
= jpcrr
.movie_headers();
34 local hdrnum
, hdr
, ret
;
36 for hdrnum
, hdr
in ipairs(headers
) do
44 get_gamename
= function()
45 return for_each_header(function(header
)
46 if header
[1] == "GAMENAME" then
54 get_authors
= function(long_form
)
58 for_each_header(function(header
)
59 if header
[1] == "AUTHORS" or header
[1] == "AUTHORNICKS" then
61 ret
[#ret
+ 1] = header
[i
];
63 elseif header
[1] == "AUTHORFULL" then
65 ret
[#ret
+ 1] = header
[2];
67 ret
[#ret
+ 1] = header
[3];
74 get_long_authors
= function()
75 return get_authors(true);
78 get_short_authors
= function()
79 return get_authors(false);
82 format_runtime
= function()
83 local length
= jpcrr
.movie_length();
84 local subseconds
= length
% 1000000000;
85 local seconds
= (length
- subseconds
) / 1000000000;
86 subseconds
= math
.ceil(subseconds
/ 1000000);
87 local minutes
= (seconds
- seconds
% 60) / 60;
88 seconds
= seconds
% 60;
89 local hours
= (minutes
- minutes
% 60) / 60;
90 minutes
= minutes
% 60;
92 return tostring(hours
) .. ":" .. tostring(minutes
) .. ":" .. tostring(seconds
) .. "." .. tostring(subseconds
);
94 return tostring(minutes
) .. ":" .. tostring(seconds
) .. "." .. tostring(subseconds
);
98 subtitle_runinfo
= function()
100 local w
, h
, x
, y
, wr
, hr
, old_w
;
101 wr
, hr
= jpcrr
.vga_resolution();
103 ret
= (get_gamename() or "<unknown>") .. " in " .. format_runtime() .. "\n";
106 for k
, v
in ipairs(get_short_authors()) do
112 w
, h
= new_text_metrics(rettmp
);
113 if w
> 550 and w
> old_w
then
114 ret
= ret
.. "\n" .. v
;
119 ret
= ret
.. "\nRerecord count: " .. tostring(jpcrr
.movie_rerecords());
123 render_subtitle_text
= function(text
, to_top
, fr
, fg
, fb
, fa
, br
, bg
, bb
, ba
)
125 local w
, h
, x
, y
, wr
, hr
;
127 w
, h
= new_text_metrics(text
);
128 wr
, hr
= jpcrr
.vga_resolution();
129 x
= math
.floor((wr
- w
) / 2);
136 new_render_text(3, x
, y
, text
, false, fr
, fg
, fb
, fa
, br
, bg
, bb
, ba
);
142 --- Title in hh:mm:ss.ss
144 --- Rerecord count: number