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 local tostring2
= function(num
)
84 return "0" .. tostring(num
);
90 local tostring3
= function(num
)
92 return "00" .. tostring(num
);
94 return "0" .. tostring(num
);
100 format_runtime
= function()
101 local length
= jpcrr
.movie_length();
102 local subseconds
= length
% 1000000000;
103 local seconds
= (length
- subseconds
) / 1000000000;
104 subseconds
= math
.ceil(subseconds
/ 1000000);
105 local minutes
= (seconds
- seconds
% 60) / 60;
106 seconds
= seconds
% 60;
107 local hours
= (minutes
- minutes
% 60) / 60;
108 minutes
= minutes
% 60;
110 return tostring(hours
) .. ":" .. tostring2(minutes
) .. ":" .. tostring2(seconds
) .. "." .. tostring3(subseconds
);
112 return tostring2(minutes
) .. ":" .. tostring2(seconds
) .. "." .. tostring3(subseconds
);
116 subtitle_runinfo
= function()
118 local w
, h
, x
, y
, wr
, hr
, old_w
;
119 wr
, hr
= jpcrr
.vga_resolution();
121 ret
= (get_gamename() or "<unknown>") .. " in " .. format_runtime() .. "\n";
124 for k
, v
in ipairs(get_short_authors()) do
130 w
, h
= new_text_metrics(rettmp
);
131 if w
> 550 and w
> old_w
then
132 ret
= ret
.. "\n" .. v
;
137 ret
= ret
.. "\nRerecord count: " .. tostring(jpcrr
.movie_rerecords());
141 render_subtitle_text
= function(text
, to_top
, fr
, fg
, fb
, fa
, br
, bg
, bb
, ba
)
143 local w
, h
, x
, y
, wr
, hr
;
145 w
, h
= new_text_metrics(text
);
146 wr
, hr
= jpcrr
.vga_resolution();
147 x
= math
.floor((wr
- w
) / 2);
154 new_render_text(3, x
, y
, text
, false, fr
, fg
, fb
, fa
, br
, bg
, bb
, ba
);
160 --- Title in hh:mm:ss.ss
162 --- Rerecord count: number