VIDEO: subtitles dev mode config
This commit is contained in:
parent
105a94c967
commit
6d7d970e17
2 changed files with 18 additions and 4 deletions
|
@ -31,6 +31,7 @@
|
||||||
#include "graphics/surface.h"
|
#include "graphics/surface.h"
|
||||||
|
|
||||||
#include "video/subtitles.h"
|
#include "video/subtitles.h"
|
||||||
|
#include "common/config-manager.h"
|
||||||
|
|
||||||
namespace Video {
|
namespace Video {
|
||||||
|
|
||||||
|
@ -118,8 +119,10 @@ bool SRTParser::parseFile(const char *fname) {
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
if (!f.open(fname))
|
if (!f.open(fname)) {
|
||||||
|
_entries.push_back(new SRTEntry(0, 0, 99999999, fname));
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
byte buf[3];
|
byte buf[3];
|
||||||
f.read(buf, 3);
|
f.read(buf, 3);
|
||||||
|
@ -230,6 +233,7 @@ Common::String SRTParser::getSubtitle(uint32 timestamp) {
|
||||||
|
|
||||||
Subtitles::Subtitles() : _loaded(false), _font(nullptr), _hPad(0), _vPad(0) {
|
Subtitles::Subtitles() : _loaded(false), _font(nullptr), _hPad(0), _vPad(0) {
|
||||||
_surface = new Graphics::Surface();
|
_surface = new Graphics::Surface();
|
||||||
|
_subtitleDev = ConfMan.getBool("subtitle_dev");
|
||||||
}
|
}
|
||||||
|
|
||||||
Subtitles::~Subtitles() {
|
Subtitles::~Subtitles() {
|
||||||
|
@ -284,10 +288,19 @@ void Subtitles::setPadding(uint16 horizontal, uint16 vertical) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Subtitles::drawSubtitle(uint32 timestamp, bool force) {
|
void Subtitles::drawSubtitle(uint32 timestamp, bool force) {
|
||||||
if (!_loaded)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Common::String subtitle = _srtParser.getSubtitle(timestamp);
|
Common::String subtitle = _srtParser.getSubtitle(timestamp);
|
||||||
|
|
||||||
|
if (!_loaded) {
|
||||||
|
if (!_subtitleDev)
|
||||||
|
return;
|
||||||
|
uint32 hours, mins, secs, msecs;
|
||||||
|
secs = timestamp / 1000;
|
||||||
|
hours = secs / 3600;
|
||||||
|
mins = (secs / 60) % 60;
|
||||||
|
secs %= 60;
|
||||||
|
msecs = timestamp % 1000;
|
||||||
|
subtitle += " " + Common::String::format("%u:%u:%u,%u", hours, mins, secs, msecs);
|
||||||
|
}
|
||||||
|
|
||||||
if (!force && subtitle == _prevSubtitle)
|
if (!force && subtitle == _prevSubtitle)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -73,6 +73,7 @@ public:
|
||||||
private:
|
private:
|
||||||
SRTParser _srtParser;
|
SRTParser _srtParser;
|
||||||
bool _loaded;
|
bool _loaded;
|
||||||
|
bool _subtitleDev;
|
||||||
|
|
||||||
const Graphics::Font *_font;
|
const Graphics::Font *_font;
|
||||||
int _fontHeight;
|
int _fontHeight;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue