[Scummvm-cvs-logs] scummvm master -> 784241c17b57c31af0722d3d98d89314c40743cd
somaen
einarjohants at gmail.com
Wed Nov 5 20:24:47 CET 2014
This automated email contains information about 52 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
cc175b5af4 WINTERMUTE: Import subtitle code from WME1
5ee11d6c21 WINTERMUTE: Astyle imported WME subtitle code
ec3b8fdde2 WINTERMUTE: Use long-style braces around blocks in imported subtitle code
ba1862ecb8 WINTERMUTE: Use BaseFileManager to load SUB file
d9d80db869 WINTERMUTE: Take const char in loadSubtitles
532217bcee WINTERMUTE: Reinstate subtitle loading
6f6e49f4cf WINTERMUTE: Display subtitles in console
1715196325 WINTERMUTE: Re-enable and use PathUtils for auto SRT detection
d8b432fe51 WINTERMUTE: Use native C types instead of macros
472d3e3231 WINTERMUTE: Add getter for _videoFont
389e06bdfc WINTERMUTE: Port actual subtitle display code.
ad5fde9db3 WINTERMUTE: Reinstate CVidSubtitle destructor
621a068c00 WINTERMUTE: Mass ScummVM-style renaming in subtitles code
0475fd1a5c WINTERMUTE: Declare counters as uint to match Array::size()
113e837d55 WINTERMUTE: Correctly delete _subtitler (which is not an array)
647b721744 WINTERMUTE: Refactor/Reformat VideoSubtitler::update
6d16fdbf4a WINTERMUTE: Expand subtitles by string table
f2441da3da WINTERMUTE: Make sure subtitle files could be found before anything else
2eee488e36 WINTERMUTE: Do some refactoring over a bunch of attrs in VideoSubtitle
8decf3d742 WINTERMUTE: Remove ////-style separators from imported subtitle code
a78a4d40dd WINTERMUTE: Use Common::String in place of char *text in loadSubtitles
581aff7f8f WINTERMUTE: Keep a bunch of attrs private in VideoSubtitler
afb3ae3034 WINTERMUTE: Treat edge case - prevents crash if SRT file is blank.
7c6f9772d3 WINTERMUTE: Save frames as uint rather than long
40c5b01aad WINTERMUTE: Preserve const when handing chars over to drawText
2acb2f558c WINTERMUTE: Add clarification comment in loadSubtitles
a4d5d14581 WINTERMUTE: Turn display() and update() into void functions.
7b4084b7e0 WINTERMUTE: s/uint32 _lastSample/long _lastSample/
dd820a7a1e WINTERMUTE: Turn a bunch of uint into uint32 in VideoSubtitle
388fbdb6eb WINTERMUTE: Rename VideoSubtitle to SubtitleCard
1a571d9611 WINTERMUTE: Avoid doing check before delete (deleting 0-pointer is safe)
4742acf939 WINTERMUTE: Rename VideoTheoraPlayer->_subtitles to _foundSubtitles for clarity
599390a5ad WINTERMUTE: Lose unnecessary if() in VideoTheoraPlayer
f1ae8e6e8d WINTERMUTE: Introduce BaseGame->expandStringByStringTable(&Common::String)
5f25cf1bd7 WINTERMUTE: Don't bother inheriting BaseGame in SubtitleCard
856e281bf1 WINTERMUTE: Remove useless constructor from SubtitleCard.
578edde66f WINTERMUTE: Const'fy members of class SubtitleCard
f525514da5 WINTERMUTE: Use BaseGame->expandStringByStringTable(&Common::String) in SubtitleCard
ebb48a1704 WINTERMUTE: s/delete array/delete[] array/
c6930d9a64 WINTERMUTE: Use int32 for _lastSample in VideoSubtitler
2fc69d770c WINTERMUTE: Initialize tokenSomething vars in VideoSubtitler
d5ed8c29f1 WINTERMUTE: Turn _subtitles into Common::Array<SubtitleCard> in VideoSubtitler
3cef639f91 WINTERMUTE: new char[str.size()+1] in BaseStringTable::expand
e9b722278e WINTERMUTE: Declare and init size in one place in VideoSubtitler
a4b9bc5877 WINTERMUTE: Rename a bunch of variabiles in loadSubtitles
e12f30ed03 WINTERMUTE: Add a bunch of comments in loadSubtitles
0a2c1a809f WINTERMUTE: Keep _[show|current]Subtitle private in video_subtitler.h
215ac157e6 WINTERMUTE: Declare vars inside appropriate block in loadSubtitles
2f082f6e43 WINTERMUTE: Remove redundant explicit call to Common::String constructor
998da18c05 WINTERMUTE: Move var declarations inside loop in loadSubtitles
9787fc5768 WINTERMUTE: Fix formatting in video_subtitler.h
784241c17b Merge pull request #437 from tobiatesan/wme_subtitles
Commit: cc175b5af4e2e9117f1313e38304fa9343b0d095
https://github.com/scummvm/scummvm/commit/cc175b5af4e2e9117f1313e38304fa9343b0d095
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T19:28:21+02:00
Commit Message:
WINTERMUTE: Import subtitle code from WME1
Changed paths:
A engines/wintermute/video/video_subtitle.cpp
A engines/wintermute/video/video_subtitle.h
A engines/wintermute/video/video_subtitler.cpp
A engines/wintermute/video/video_subtitler.h
engines/wintermute/module.mk
engines/wintermute/video/video_theora_player.cpp
engines/wintermute/video/video_theora_player.h
diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk
index 1b6c52e..b4845b0 100644
--- a/engines/wintermute/module.mk
+++ b/engines/wintermute/module.mk
@@ -109,6 +109,8 @@ MODULE_OBJS := \
utils/string_util.o \
utils/utils.o \
video/video_player.o \
+ video/video_subtitle.o \
+ video/video_subtitler.o \
video/video_theora_player.o \
debugger.o \
wintermute.o \
diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp
new file mode 100644
index 0000000..45b0ee6
--- /dev/null
+++ b/engines/wintermute/video/video_subtitle.cpp
@@ -0,0 +1,59 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on Wintermute Engine
+ * http://dead-code.org/redir.php?target=wme
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+// #include "dcgf.h"
+#include "engines/wintermute/video/video_subtitle.h"
+
+namespace Wintermute {
+
+//////////////////////////////////////////////////////////////////////////
+CVidSubtitle::CVidSubtitle(BaseGame* inGame):BaseClass(inGame)
+{
+ m_Text = NULL;
+ m_StartFrame = m_EndFrame = 0;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+CVidSubtitle::CVidSubtitle(BaseGame* inGame, char* Text, long StartFrame, long EndFrame):BaseClass(inGame)
+{
+ m_Text = new char[strlen(Text)+1];
+ strcpy(m_Text, Text);
+// _gameRef->m_StringTable->Expand(&m_Text);
+
+ m_StartFrame = StartFrame;
+ m_EndFrame = EndFrame;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+CVidSubtitle::~CVidSubtitle()
+{
+ // SAFE_DELETE_ARRAY(m_Text);
+}
+}
diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h
new file mode 100644
index 0000000..0b3d591
--- /dev/null
+++ b/engines/wintermute/video/video_subtitle.h
@@ -0,0 +1,49 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on Wintermute Engine
+ * http://dead-code.org/redir.php?target=wme
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#ifndef WINTERMUTE_VIDSUBTITLE_H
+#define WINTERMUTE_VIDSUBTITLE_H
+
+#include "engines/wintermute/base/base.h"
+
+namespace Wintermute {
+
+class CVidSubtitle : public BaseClass
+{
+public:
+ long m_EndFrame;
+ long m_StartFrame;
+ char* m_Text;
+ CVidSubtitle(BaseGame* inGame);
+ CVidSubtitle(BaseGame* inGame, char* Text, long StartFrame, long EndFrame);
+ virtual ~CVidSubtitle();
+
+};
+}
+
+#endif
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
new file mode 100644
index 0000000..ca812c5
--- /dev/null
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -0,0 +1,213 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on Wintermute Engine
+ * http://dead-code.org/redir.php?target=wme
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+
+// #include "dcgf.h"
+#include "engines/wintermute/video/video_subtitler.h"
+#define S_OK 0
+#define BYTE byte
+#define LONG long
+#define MAX_PATH 127
+#define _MAX_DRIVE 127
+#define _MAX_DIR 127
+#define _MAX_FNAME 127
+#define DWORD byte
+
+namespace Wintermute {
+//////////////////////////////////////////////////////////////////////////
+CVidSubtitler::CVidSubtitler(BaseGame *inGame):BaseClass(inGame)
+{
+ m_LastSample = -1;
+ m_CurrentSubtitle = 0;
+ m_ShowSubtitle = false;
+}
+
+//////////////////////////////////////////////////////////////////////////
+CVidSubtitler::~CVidSubtitler(void)
+{
+ for(int i=0; i<m_Subtitles.size(); i++) delete m_Subtitles[i];
+ m_Subtitles.clear();
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+bool CVidSubtitler::LoadSubtitles(char* Filename, char* SubtitleFile)
+{
+ if(!Filename) return S_OK;
+
+ for(int i=0; i<m_Subtitles.size(); i++) delete m_Subtitles[i];
+ m_Subtitles.clear();
+
+ m_LastSample = -1;
+ m_CurrentSubtitle = 0;
+ m_ShowSubtitle = false;
+
+
+ char NewFile[MAX_PATH];
+ char drive[_MAX_DRIVE];
+ char dir[_MAX_DIR];
+ char fname[_MAX_FNAME];
+
+ if(SubtitleFile)
+ {
+ strcpy(NewFile, SubtitleFile);
+ }
+#if 0
+ else
+ {
+ _splitpath(Filename, drive, dir, fname, NULL);
+ _makepath(NewFile, drive, dir, fname, ".SUB");
+ }
+#endif
+ DWORD Size;
+
+#if 0
+ BYTE* Buffer = _gameRef->m_FileManager->ReadWholeFile(NewFile, &Size, false);
+
+ if(Buffer==NULL) return S_OK; // no subtitles
+
+
+ LONG Start, End;
+ bool InToken;
+ char* TokenStart;
+ int TokenLength;
+ int TokenPos;
+ int TextLength;
+
+ int Pos = 0;
+ int LineLength = 0;
+ while(Pos<Size){
+ Start = End = -1;
+ InToken = false;
+ TokenPos = -1;
+ TextLength = 0;
+
+ LineLength = 0;
+ while(Pos+LineLength < Size && Buffer[Pos+LineLength]!='\n' && Buffer[Pos+LineLength]!='\0') LineLength++;
+
+ int RealLength = LineLength - (Pos+LineLength>=Size?0:1);
+ char* Text = new char[RealLength+1];
+ char* line = (char*)&Buffer[Pos];
+
+ for(int i=0; i<RealLength; i++){
+ if(line[i]=='{'){
+ if(!InToken){
+ InToken = true;
+ TokenStart = line+i+1;
+ TokenLength = 0;
+ TokenPos++;
+ }
+ else TokenLength++;
+ }
+ else if(line[i]=='}'){
+ if(InToken){
+ InToken = false;
+ char* Token = new char[TokenLength+1];
+ strncpy(Token, TokenStart, TokenLength);
+ Token[TokenLength] = '\0';
+ if(TokenPos==0) Start = atoi(Token);
+ else if(TokenPos==1) End = atoi(Token);
+
+ delete [] Token;
+ }
+ else{
+ Text[TextLength] = line[i];
+ TextLength++;
+ }
+ }
+ else{
+ if(InToken){
+ TokenLength++;
+ }
+ else{
+ Text[TextLength] = line[i];
+ if(Text[TextLength]=='|') Text[TextLength] = '\n';
+ TextLength++;
+ }
+ }
+ }
+ Text[TextLength] = '\0';
+
+ if(Start!=-1 && TextLength>0 && (Start!=1 || End!=1)) m_Subtitles.Add(new CVidSubtitle(Game, Text, Start, End));
+
+ delete [] Text;
+
+ Pos+=LineLength+1;
+ }
+
+ delete [] Buffer;
+#endif
+ return S_OK;
+}
+
+//////////////////////////////////////////////////////////////////////////
+bool CVidSubtitler::Display()
+{
+#if 0
+ if(m_ShowSubtitle)
+ {
+ CBFont* font = Game->m_VideoFont?Game->m_VideoFont:Game->m_SystemFont;
+ int Height = font->GetTextHeight((BYTE*)m_Subtitles[m_CurrentSubtitle]->m_Text, Game->m_Renderer->m_Width);
+ font->DrawText((BYTE*)m_Subtitles[m_CurrentSubtitle]->m_Text, 0, Game->m_Renderer->m_Height-Height-5, Game->m_Renderer->m_Width, TAL_CENTER);
+ }
+#endif
+ return S_OK;
+}
+
+//////////////////////////////////////////////////////////////////////////
+bool CVidSubtitler::Update(LONG Frame)
+{
+ if(Frame != m_LastSample)
+ {
+ m_LastSample = Frame;
+
+ // process subtitles
+ m_ShowSubtitle = false;
+ while(m_CurrentSubtitle<m_Subtitles.size()){
+ int End = m_Subtitles[m_CurrentSubtitle]->m_EndFrame;
+
+ bool NextFrameOK = (m_CurrentSubtitle < m_Subtitles.size()-1 && m_Subtitles[m_CurrentSubtitle+1]->m_StartFrame <= Frame);
+
+ if(Frame > End){
+ if(NextFrameOK){
+ m_CurrentSubtitle++;
+ }
+ else{
+ m_ShowSubtitle = (End==0);
+ break;
+ }
+ }
+ else{
+ m_ShowSubtitle = true;
+ break;
+ }
+ }
+ }
+ return S_OK;
+}
+}
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
new file mode 100644
index 0000000..144e90f
--- /dev/null
+++ b/engines/wintermute/video/video_subtitler.h
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on Wintermute Engine
+ * http://dead-code.org/redir.php?target=wme
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#ifndef WINTERMUTE_VIDSUBTITLER_H
+#define WINTERMUTE_VIDSUBTITLER_H
+
+#include "engines/wintermute/base/base.h"
+#include "engines/wintermute/video/video_subtitle.h"
+
+namespace Wintermute {
+
+class CVidSubtitler :
+ public BaseClass
+{
+public:
+ CVidSubtitler(BaseGame *inGame);
+ virtual ~CVidSubtitler(void);
+
+ bool m_ShowSubtitle;
+ int m_CurrentSubtitle;
+ bool LoadSubtitles(char* Filename, char* SubtitleFile);
+ bool Display();
+ bool Update(long Frame);
+ long m_LastSample;
+ Common::Array<CVidSubtitle*> m_Subtitles;
+};
+}
+
+#endif
diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp
index e155358..fc15710 100644
--- a/engines/wintermute/video/video_theora_player.cpp
+++ b/engines/wintermute/video/video_theora_player.cpp
@@ -85,8 +85,7 @@ void VideoTheoraPlayer::SetDefaults() {
_volume = 100;
_theoraDecoder = nullptr;
- // TODO: Add subtitles-support
- //_subtitler = nullptr;
+ _subtitler = new CVidSubtitler(_gameRef);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h
index 8274a14..2d79c54 100644
--- a/engines/wintermute/video/video_theora_player.h
+++ b/engines/wintermute/video/video_theora_player.h
@@ -31,6 +31,7 @@
#include "engines/wintermute/base/base.h"
#include "engines/wintermute/persistent.h"
+#include "engines/wintermute/video/video_subtitler.h"
#include "video/video_decoder.h"
#include "common/stream.h"
#include "graphics/surface.h"
@@ -59,7 +60,7 @@ public:
Common::String _filename;
BaseSurface *_texture;
- //CVidSubtitler *_subtitler;
+ CVidSubtitler *_subtitler;
// control methods
bool initialize(const Common::String &filename, const Common::String &subtitleFile = Common::String());
Commit: 5ee11d6c21ad991ed30a043dd94656a9da0d6256
https://github.com/scummvm/scummvm/commit/5ee11d6c21ad991ed30a043dd94656a9da0d6256
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T19:29:12+02:00
Commit Message:
WINTERMUTE: Astyle imported WME subtitle code
Changed paths:
engines/wintermute/video/video_subtitle.cpp
engines/wintermute/video/video_subtitle.h
engines/wintermute/video/video_subtitler.cpp
engines/wintermute/video/video_subtitler.h
diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp
index 45b0ee6..74b3119 100644
--- a/engines/wintermute/video/video_subtitle.cpp
+++ b/engines/wintermute/video/video_subtitle.cpp
@@ -32,17 +32,15 @@
namespace Wintermute {
//////////////////////////////////////////////////////////////////////////
-CVidSubtitle::CVidSubtitle(BaseGame* inGame):BaseClass(inGame)
-{
+CVidSubtitle::CVidSubtitle(BaseGame *inGame): BaseClass(inGame) {
m_Text = NULL;
m_StartFrame = m_EndFrame = 0;
}
//////////////////////////////////////////////////////////////////////////
-CVidSubtitle::CVidSubtitle(BaseGame* inGame, char* Text, long StartFrame, long EndFrame):BaseClass(inGame)
-{
- m_Text = new char[strlen(Text)+1];
+CVidSubtitle::CVidSubtitle(BaseGame *inGame, char *Text, long StartFrame, long EndFrame): BaseClass(inGame) {
+ m_Text = new char[strlen(Text) + 1];
strcpy(m_Text, Text);
// _gameRef->m_StringTable->Expand(&m_Text);
@@ -52,8 +50,7 @@ CVidSubtitle::CVidSubtitle(BaseGame* inGame, char* Text, long StartFrame, long E
//////////////////////////////////////////////////////////////////////////
-CVidSubtitle::~CVidSubtitle()
-{
+CVidSubtitle::~CVidSubtitle() {
// SAFE_DELETE_ARRAY(m_Text);
}
}
diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h
index 0b3d591..e93007b 100644
--- a/engines/wintermute/video/video_subtitle.h
+++ b/engines/wintermute/video/video_subtitle.h
@@ -33,14 +33,13 @@
namespace Wintermute {
-class CVidSubtitle : public BaseClass
-{
+class CVidSubtitle : public BaseClass {
public:
long m_EndFrame;
long m_StartFrame;
- char* m_Text;
- CVidSubtitle(BaseGame* inGame);
- CVidSubtitle(BaseGame* inGame, char* Text, long StartFrame, long EndFrame);
+ char *m_Text;
+ CVidSubtitle(BaseGame *inGame);
+ CVidSubtitle(BaseGame *inGame, char *Text, long StartFrame, long EndFrame);
virtual ~CVidSubtitle();
};
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index ca812c5..8c6d222 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -40,27 +40,24 @@
namespace Wintermute {
//////////////////////////////////////////////////////////////////////////
-CVidSubtitler::CVidSubtitler(BaseGame *inGame):BaseClass(inGame)
-{
+CVidSubtitler::CVidSubtitler(BaseGame *inGame): BaseClass(inGame) {
m_LastSample = -1;
m_CurrentSubtitle = 0;
m_ShowSubtitle = false;
}
//////////////////////////////////////////////////////////////////////////
-CVidSubtitler::~CVidSubtitler(void)
-{
- for(int i=0; i<m_Subtitles.size(); i++) delete m_Subtitles[i];
+CVidSubtitler::~CVidSubtitler(void) {
+ for (int i = 0; i < m_Subtitles.size(); i++) delete m_Subtitles[i];
m_Subtitles.clear();
}
//////////////////////////////////////////////////////////////////////////
-bool CVidSubtitler::LoadSubtitles(char* Filename, char* SubtitleFile)
-{
- if(!Filename) return S_OK;
+bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) {
+ if (!Filename) return S_OK;
- for(int i=0; i<m_Subtitles.size(); i++) delete m_Subtitles[i];
+ for (int i = 0; i < m_Subtitles.size(); i++) delete m_Subtitles[i];
m_Subtitles.clear();
m_LastSample = -1;
@@ -73,13 +70,11 @@ bool CVidSubtitler::LoadSubtitles(char* Filename, char* SubtitleFile)
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
- if(SubtitleFile)
- {
+ if (SubtitleFile) {
strcpy(NewFile, SubtitleFile);
}
#if 0
- else
- {
+ else {
_splitpath(Filename, drive, dir, fname, NULL);
_makepath(NewFile, drive, dir, fname, ".SUB");
}
@@ -87,77 +82,72 @@ bool CVidSubtitler::LoadSubtitles(char* Filename, char* SubtitleFile)
DWORD Size;
#if 0
- BYTE* Buffer = _gameRef->m_FileManager->ReadWholeFile(NewFile, &Size, false);
+ BYTE *Buffer = _gameRef->m_FileManager->ReadWholeFile(NewFile, &Size, false);
- if(Buffer==NULL) return S_OK; // no subtitles
+ if (Buffer == NULL) return S_OK; // no subtitles
LONG Start, End;
bool InToken;
- char* TokenStart;
+ char *TokenStart;
int TokenLength;
int TokenPos;
int TextLength;
int Pos = 0;
int LineLength = 0;
- while(Pos<Size){
+ while (Pos < Size) {
Start = End = -1;
InToken = false;
TokenPos = -1;
TextLength = 0;
LineLength = 0;
- while(Pos+LineLength < Size && Buffer[Pos+LineLength]!='\n' && Buffer[Pos+LineLength]!='\0') LineLength++;
+ while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') LineLength++;
- int RealLength = LineLength - (Pos+LineLength>=Size?0:1);
- char* Text = new char[RealLength+1];
- char* line = (char*)&Buffer[Pos];
+ int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1);
+ char *Text = new char[RealLength + 1];
+ char *line = (char *)&Buffer[Pos];
- for(int i=0; i<RealLength; i++){
- if(line[i]=='{'){
- if(!InToken){
+ for (int i = 0; i < RealLength; i++) {
+ if (line[i] == '{') {
+ if (!InToken) {
InToken = true;
- TokenStart = line+i+1;
+ TokenStart = line + i + 1;
TokenLength = 0;
TokenPos++;
- }
- else TokenLength++;
- }
- else if(line[i]=='}'){
- if(InToken){
+ } else TokenLength++;
+ } else if (line[i] == '}') {
+ if (InToken) {
InToken = false;
- char* Token = new char[TokenLength+1];
+ char *Token = new char[TokenLength + 1];
strncpy(Token, TokenStart, TokenLength);
Token[TokenLength] = '\0';
- if(TokenPos==0) Start = atoi(Token);
- else if(TokenPos==1) End = atoi(Token);
+ if (TokenPos == 0) Start = atoi(Token);
+ else if (TokenPos == 1) End = atoi(Token);
delete [] Token;
- }
- else{
+ } else {
Text[TextLength] = line[i];
TextLength++;
}
- }
- else{
- if(InToken){
+ } else {
+ if (InToken) {
TokenLength++;
- }
- else{
+ } else {
Text[TextLength] = line[i];
- if(Text[TextLength]=='|') Text[TextLength] = '\n';
+ if (Text[TextLength] == '|') Text[TextLength] = '\n';
TextLength++;
}
}
}
Text[TextLength] = '\0';
- if(Start!=-1 && TextLength>0 && (Start!=1 || End!=1)) m_Subtitles.Add(new CVidSubtitle(Game, Text, Start, End));
+ if (Start != -1 && TextLength > 0 && (Start != 1 || End != 1)) m_Subtitles.Add(new CVidSubtitle(Game, Text, Start, End));
delete [] Text;
- Pos+=LineLength+1;
+ Pos += LineLength + 1;
}
delete [] Buffer;
@@ -166,43 +156,37 @@ bool CVidSubtitler::LoadSubtitles(char* Filename, char* SubtitleFile)
}
//////////////////////////////////////////////////////////////////////////
-bool CVidSubtitler::Display()
-{
+bool CVidSubtitler::Display() {
#if 0
- if(m_ShowSubtitle)
- {
- CBFont* font = Game->m_VideoFont?Game->m_VideoFont:Game->m_SystemFont;
- int Height = font->GetTextHeight((BYTE*)m_Subtitles[m_CurrentSubtitle]->m_Text, Game->m_Renderer->m_Width);
- font->DrawText((BYTE*)m_Subtitles[m_CurrentSubtitle]->m_Text, 0, Game->m_Renderer->m_Height-Height-5, Game->m_Renderer->m_Width, TAL_CENTER);
+ if (m_ShowSubtitle) {
+ CBFont *font = Game->m_VideoFont ? Game->m_VideoFont : Game->m_SystemFont;
+ int Height = font->GetTextHeight((BYTE *)m_Subtitles[m_CurrentSubtitle]->m_Text, Game->m_Renderer->m_Width);
+ font->DrawText((BYTE *)m_Subtitles[m_CurrentSubtitle]->m_Text, 0, Game->m_Renderer->m_Height - Height - 5, Game->m_Renderer->m_Width, TAL_CENTER);
}
#endif
return S_OK;
}
//////////////////////////////////////////////////////////////////////////
-bool CVidSubtitler::Update(LONG Frame)
-{
- if(Frame != m_LastSample)
- {
+bool CVidSubtitler::Update(LONG Frame) {
+ if (Frame != m_LastSample) {
m_LastSample = Frame;
// process subtitles
m_ShowSubtitle = false;
- while(m_CurrentSubtitle<m_Subtitles.size()){
+ while (m_CurrentSubtitle < m_Subtitles.size()) {
int End = m_Subtitles[m_CurrentSubtitle]->m_EndFrame;
- bool NextFrameOK = (m_CurrentSubtitle < m_Subtitles.size()-1 && m_Subtitles[m_CurrentSubtitle+1]->m_StartFrame <= Frame);
+ bool NextFrameOK = (m_CurrentSubtitle < m_Subtitles.size() - 1 && m_Subtitles[m_CurrentSubtitle + 1]->m_StartFrame <= Frame);
- if(Frame > End){
- if(NextFrameOK){
+ if (Frame > End) {
+ if (NextFrameOK) {
m_CurrentSubtitle++;
- }
- else{
- m_ShowSubtitle = (End==0);
+ } else {
+ m_ShowSubtitle = (End == 0);
break;
}
- }
- else{
+ } else {
m_ShowSubtitle = true;
break;
}
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index 144e90f..fb3da8d 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -35,19 +35,18 @@
namespace Wintermute {
class CVidSubtitler :
- public BaseClass
-{
+ public BaseClass {
public:
CVidSubtitler(BaseGame *inGame);
virtual ~CVidSubtitler(void);
bool m_ShowSubtitle;
int m_CurrentSubtitle;
- bool LoadSubtitles(char* Filename, char* SubtitleFile);
+ bool LoadSubtitles(char *Filename, char *SubtitleFile);
bool Display();
bool Update(long Frame);
long m_LastSample;
- Common::Array<CVidSubtitle*> m_Subtitles;
+ Common::Array<CVidSubtitle *> m_Subtitles;
};
}
Commit: ec3b8fdde24324fd4a2ad5c37735644a79f1e574
https://github.com/scummvm/scummvm/commit/ec3b8fdde24324fd4a2ad5c37735644a79f1e574
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T19:40:48+02:00
Commit Message:
WINTERMUTE: Use long-style braces around blocks in imported subtitle code
Changed paths:
engines/wintermute/video/video_subtitler.cpp
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 8c6d222..5373789 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -48,16 +48,23 @@ CVidSubtitler::CVidSubtitler(BaseGame *inGame): BaseClass(inGame) {
//////////////////////////////////////////////////////////////////////////
CVidSubtitler::~CVidSubtitler(void) {
- for (int i = 0; i < m_Subtitles.size(); i++) delete m_Subtitles[i];
+ for (int i = 0; i < m_Subtitles.size(); i++) {
+ delete m_Subtitles[i];
+ }
m_Subtitles.clear();
}
//////////////////////////////////////////////////////////////////////////
bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) {
- if (!Filename) return S_OK;
+ if (!Filename) {
+ return S_OK;
+ }
+
+ for (int i = 0; i < m_Subtitles.size(); i++) {
+ delete m_Subtitles[i];
+ }
- for (int i = 0; i < m_Subtitles.size(); i++) delete m_Subtitles[i];
m_Subtitles.clear();
m_LastSample = -1;
@@ -84,7 +91,9 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) {
#if 0
BYTE *Buffer = _gameRef->m_FileManager->ReadWholeFile(NewFile, &Size, false);
- if (Buffer == NULL) return S_OK; // no subtitles
+ if (Buffer == NULL) {
+ return S_OK; // no subtitles
+ }
LONG Start, End;
@@ -103,7 +112,9 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) {
TextLength = 0;
LineLength = 0;
- while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') LineLength++;
+ while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') {
+ LineLength++;
+ }
int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1);
char *Text = new char[RealLength + 1];
@@ -116,16 +127,20 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) {
TokenStart = line + i + 1;
TokenLength = 0;
TokenPos++;
- } else TokenLength++;
+ } else {
+ TokenLength++;
+ }
} else if (line[i] == '}') {
if (InToken) {
InToken = false;
char *Token = new char[TokenLength + 1];
strncpy(Token, TokenStart, TokenLength);
Token[TokenLength] = '\0';
- if (TokenPos == 0) Start = atoi(Token);
- else if (TokenPos == 1) End = atoi(Token);
-
+ if (TokenPos == 0) {
+ Start = atoi(Token);
+ } else if (TokenPos == 1) {
+ End = atoi(Token);
+ }
delete [] Token;
} else {
Text[TextLength] = line[i];
@@ -136,14 +151,18 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) {
TokenLength++;
} else {
Text[TextLength] = line[i];
- if (Text[TextLength] == '|') Text[TextLength] = '\n';
+ if (Text[TextLength] == '|') {
+ Text[TextLength] = '\n';
+ }
TextLength++;
}
}
}
Text[TextLength] = '\0';
- if (Start != -1 && TextLength > 0 && (Start != 1 || End != 1)) m_Subtitles.Add(new CVidSubtitle(Game, Text, Start, End));
+ if (Start != -1 && TextLength > 0 && (Start != 1 || End != 1)) {
+ m_Subtitles.Add(new CVidSubtitle(Game, Text, Start, End));
+ }
delete [] Text;
Commit: ba1862ecb8bb80751c58e70f233449dd05e4245c
https://github.com/scummvm/scummvm/commit/ba1862ecb8bb80751c58e70f233449dd05e4245c
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T19:43:26+02:00
Commit Message:
WINTERMUTE: Use BaseFileManager to load SUB file
Conflicts:
engines/wintermute/video/video_subtitler.cpp
Changed paths:
engines/wintermute/video/video_subtitler.cpp
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 5373789..072d1e1 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -29,6 +29,8 @@
// #include "dcgf.h"
#include "engines/wintermute/video/video_subtitler.h"
+#include "engines/wintermute/base/base_file_manager.h"
+
#define S_OK 0
#define BYTE byte
#define LONG long
@@ -73,9 +75,6 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) {
char NewFile[MAX_PATH];
- char drive[_MAX_DRIVE];
- char dir[_MAX_DIR];
- char fname[_MAX_FNAME];
if (SubtitleFile) {
strcpy(NewFile, SubtitleFile);
@@ -88,13 +87,14 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) {
#endif
DWORD Size;
-#if 0
- BYTE *Buffer = _gameRef->m_FileManager->ReadWholeFile(NewFile, &Size, false);
-
- if (Buffer == NULL) {
+ Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(NewFile, true, false);
+ if (file == nullptr) {
return S_OK; // no subtitles
}
+ Size = file->size();
+ BYTE *Buffer = new BYTE[Size];
+ file->read(Buffer, Size);
LONG Start, End;
bool InToken;
@@ -105,6 +105,7 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) {
int Pos = 0;
int LineLength = 0;
+
while (Pos < Size) {
Start = End = -1;
InToken = false;
@@ -161,7 +162,7 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) {
Text[TextLength] = '\0';
if (Start != -1 && TextLength > 0 && (Start != 1 || End != 1)) {
- m_Subtitles.Add(new CVidSubtitle(Game, Text, Start, End));
+ m_Subtitles.push_back(new CVidSubtitle(_gameRef, Text, Start, End));
}
delete [] Text;
@@ -170,7 +171,7 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) {
}
delete [] Buffer;
-#endif
+
return S_OK;
}
Commit: d9d80db869b21e4625d445e4f00af6b03b09e6c8
https://github.com/scummvm/scummvm/commit/d9d80db869b21e4625d445e4f00af6b03b09e6c8
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T19:50:48+02:00
Commit Message:
WINTERMUTE: Take const char in loadSubtitles
Changed paths:
engines/wintermute/video/video_subtitler.cpp
engines/wintermute/video/video_subtitler.h
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 072d1e1..6d65ade 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -58,7 +58,7 @@ CVidSubtitler::~CVidSubtitler(void) {
//////////////////////////////////////////////////////////////////////////
-bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) {
+bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile) {
if (!Filename) {
return S_OK;
}
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index fb3da8d..25641bc 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -42,7 +42,7 @@ public:
bool m_ShowSubtitle;
int m_CurrentSubtitle;
- bool LoadSubtitles(char *Filename, char *SubtitleFile);
+ bool LoadSubtitles(const char *Filename, const char *SubtitleFile);
bool Display();
bool Update(long Frame);
long m_LastSample;
Commit: 532217bcee6ee33a189f71e6c37323442299c4e2
https://github.com/scummvm/scummvm/commit/532217bcee6ee33a189f71e6c37323442299c4e2
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T19:50:50+02:00
Commit Message:
WINTERMUTE: Reinstate subtitle loading
Changed paths:
engines/wintermute/video/video_theora_player.cpp
diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp
index fc15710..205ebe5 100644
--- a/engines/wintermute/video/video_theora_player.cpp
+++ b/engines/wintermute/video/video_theora_player.cpp
@@ -129,6 +129,10 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common:
warning("VideoTheoraPlayer::initialize - Theora support not compiled in, video will be skipped: %s", filename.c_str());
return STATUS_FAILED;
#endif
+
+
+ _subtitler->LoadSubtitles(_filename.c_str(), subtitleFile.c_str());
+
_theoraDecoder->loadStream(_file);
if (!_theoraDecoder->isVideoLoaded()) {
Commit: 6f6e49f4cf183d9cbdf75060f4c271a538c6d1d1
https://github.com/scummvm/scummvm/commit/6f6e49f4cf183d9cbdf75060f4c271a538c6d1d1
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T20:08:21+02:00
Commit Message:
WINTERMUTE: Display subtitles in console
Changed paths:
engines/wintermute/video/video_subtitler.cpp
engines/wintermute/video/video_theora_player.cpp
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 6d65ade..965f7f1 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -177,6 +177,7 @@ bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile
//////////////////////////////////////////////////////////////////////////
bool CVidSubtitler::Display() {
+ warning((const char *)m_Subtitles[m_CurrentSubtitle]->m_Text);
#if 0
if (m_ShowSubtitle) {
CBFont *font = Game->m_VideoFont ? Game->m_VideoFont : Game->m_SystemFont;
diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp
index 205ebe5..232c484 100644
--- a/engines/wintermute/video/video_theora_player.cpp
+++ b/engines/wintermute/video/video_theora_player.cpp
@@ -217,7 +217,8 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame,
_state = THEORA_STATE_PLAYING;
_looping = looping;
_playbackType = type;
-
+ _subtitler->Update(_theoraDecoder->getFrameCount());
+ _subtitler->Display();
_startTime = startTime;
_volume = volume;
_posX = x;
@@ -292,6 +293,9 @@ bool VideoTheoraPlayer::update() {
}
if (_theoraDecoder) {
+
+ _subtitler->Update(_theoraDecoder->getCurFrame());
+
if (_theoraDecoder->endOfVideo() && _looping) {
warning("Should loop movie %s, hacked for now", _filename.c_str());
_theoraDecoder->rewind();
@@ -419,6 +423,7 @@ bool VideoTheoraPlayer::display(uint32 alpha) {
/* if (m_Subtitler && _gameRef->m_VideoSubtitles) {
m_Subtitler->display();
}*/
+ _subtitler->Display();
return res;
}
Commit: 1715196325c5b5867fd9bc684ca5204655fc9573
https://github.com/scummvm/scummvm/commit/1715196325c5b5867fd9bc684ca5204655fc9573
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T20:09:31+02:00
Commit Message:
WINTERMUTE: Re-enable and use PathUtils for auto SRT detection
Changed paths:
engines/wintermute/video/video_subtitler.cpp
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 965f7f1..facc707 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -30,6 +30,7 @@
// #include "dcgf.h"
#include "engines/wintermute/video/video_subtitler.h"
#include "engines/wintermute/base/base_file_manager.h"
+#include "engines/wintermute/utils/path_util.h"
#define S_OK 0
#define BYTE byte
@@ -74,17 +75,17 @@ bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile
m_ShowSubtitle = false;
- char NewFile[MAX_PATH];
+ Common::String NewFile;
if (SubtitleFile) {
- strcpy(NewFile, SubtitleFile);
+ NewFile = Common::String(SubtitleFile);
+ } else {
+ Common::String path = PathUtil::getDirectoryName(Filename);
+ Common::String name = PathUtil::getFileNameWithoutExtension(Filename);
+ Common::String ext = ".SUB";
+ NewFile = PathUtil::combine(path, name + ext);
}
-#if 0
- else {
- _splitpath(Filename, drive, dir, fname, NULL);
- _makepath(NewFile, drive, dir, fname, ".SUB");
- }
-#endif
+
DWORD Size;
Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(NewFile, true, false);
Commit: d8b432fe51d93edaff631792868489eb2bc3ec4a
https://github.com/scummvm/scummvm/commit/d8b432fe51d93edaff631792868489eb2bc3ec4a
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T20:11:16+02:00
Commit Message:
WINTERMUTE: Use native C types instead of macros
Changed paths:
engines/wintermute/video/video_subtitler.cpp
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index facc707..24eda70 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -26,21 +26,10 @@
* Copyright (c) 2011 Jan Nedoma
*/
-
-// #include "dcgf.h"
#include "engines/wintermute/video/video_subtitler.h"
#include "engines/wintermute/base/base_file_manager.h"
#include "engines/wintermute/utils/path_util.h"
-#define S_OK 0
-#define BYTE byte
-#define LONG long
-#define MAX_PATH 127
-#define _MAX_DRIVE 127
-#define _MAX_DIR 127
-#define _MAX_FNAME 127
-#define DWORD byte
-
namespace Wintermute {
//////////////////////////////////////////////////////////////////////////
CVidSubtitler::CVidSubtitler(BaseGame *inGame): BaseClass(inGame) {
@@ -61,11 +50,7 @@ CVidSubtitler::~CVidSubtitler(void) {
//////////////////////////////////////////////////////////////////////////
bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile) {
if (!Filename) {
- return S_OK;
- }
-
- for (int i = 0; i < m_Subtitles.size(); i++) {
- delete m_Subtitles[i];
+ return false;
}
m_Subtitles.clear();
@@ -86,18 +71,20 @@ bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile
NewFile = PathUtil::combine(path, name + ext);
}
- DWORD Size;
+ long Size;
Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(NewFile, true, false);
+
if (file == nullptr) {
- return S_OK; // no subtitles
+ return false; // no subtitles
}
Size = file->size();
- BYTE *Buffer = new BYTE[Size];
+ char *Buffer = new char[Size];
+
file->read(Buffer, Size);
- LONG Start, End;
+ long Start, End;
bool InToken;
char *TokenStart;
int TokenLength;
@@ -173,7 +160,7 @@ bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile
delete [] Buffer;
- return S_OK;
+ return false;
}
//////////////////////////////////////////////////////////////////////////
@@ -182,15 +169,15 @@ bool CVidSubtitler::Display() {
#if 0
if (m_ShowSubtitle) {
CBFont *font = Game->m_VideoFont ? Game->m_VideoFont : Game->m_SystemFont;
- int Height = font->GetTextHeight((BYTE *)m_Subtitles[m_CurrentSubtitle]->m_Text, Game->m_Renderer->m_Width);
- font->DrawText((BYTE *)m_Subtitles[m_CurrentSubtitle]->m_Text, 0, Game->m_Renderer->m_Height - Height - 5, Game->m_Renderer->m_Width, TAL_CENTER);
+ int Height = font->GetTextHeight((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text, Game->m_Renderer->m_Width);
+ font->DrawText((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text, 0, Game->m_Renderer->m_Height - Height - 5, Game->m_Renderer->m_Width, TAL_CENTER);
}
#endif
- return S_OK;
+ return false;
}
//////////////////////////////////////////////////////////////////////////
-bool CVidSubtitler::Update(LONG Frame) {
+bool CVidSubtitler::Update(long Frame) {
if (Frame != m_LastSample) {
m_LastSample = Frame;
@@ -214,6 +201,6 @@ bool CVidSubtitler::Update(LONG Frame) {
}
}
}
- return S_OK;
+ return false;
}
}
Commit: 472d3e3231ac0677cef6edd6417686800f167d29
https://github.com/scummvm/scummvm/commit/472d3e3231ac0677cef6edd6417686800f167d29
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T20:11:17+02:00
Commit Message:
WINTERMUTE: Add getter for _videoFont
Changed paths:
engines/wintermute/base/base_game.h
diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h
index cdbbff6..f62416e 100644
--- a/engines/wintermute/base/base_game.h
+++ b/engines/wintermute/base/base_game.h
@@ -123,6 +123,7 @@ public:
inline BaseObject *getMainObject() { return _mainObject; }
inline BaseFont *getSystemFont() { return _systemFont; }
+ inline BaseFont *getVideoFont() { return _videoFont; }
bool initInput();
bool initLoop();
Commit: 389e06bdfcecab07c2a48c8092b22b423e529ac4
https://github.com/scummvm/scummvm/commit/389e06bdfcecab07c2a48c8092b22b423e529ac4
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T20:16:07+02:00
Commit Message:
WINTERMUTE: Port actual subtitle display code.
Changed paths:
engines/wintermute/video/video_subtitler.cpp
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 24eda70..dd65787 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -29,6 +29,9 @@
#include "engines/wintermute/video/video_subtitler.h"
#include "engines/wintermute/base/base_file_manager.h"
#include "engines/wintermute/utils/path_util.h"
+#include "engines/wintermute/base/font/base_font.h"
+#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/gfx/base_renderer.h"
namespace Wintermute {
//////////////////////////////////////////////////////////////////////////
@@ -165,14 +168,14 @@ bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile
//////////////////////////////////////////////////////////////////////////
bool CVidSubtitler::Display() {
- warning((const char *)m_Subtitles[m_CurrentSubtitle]->m_Text);
-#if 0
if (m_ShowSubtitle) {
- CBFont *font = Game->m_VideoFont ? Game->m_VideoFont : Game->m_SystemFont;
- int Height = font->GetTextHeight((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text, Game->m_Renderer->m_Width);
- font->DrawText((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text, 0, Game->m_Renderer->m_Height - Height - 5, Game->m_Renderer->m_Width, TAL_CENTER);
+ BaseFont *font = _gameRef->getVideoFont() ? _gameRef->getVideoFont() : _gameRef->getSystemFont();
+ int textHeight = font->getTextHeight((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text, _gameRef->_renderer->getWidth());
+ font->drawText((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text,
+ 0,
+ (_gameRef->_renderer->getHeight() - textHeight - 5),
+ (_gameRef->_renderer->getWidth(), TAL_CENTER));
}
-#endif
return false;
}
Commit: ad5fde9db3767bee7af4e8c23277a07cad705de7
https://github.com/scummvm/scummvm/commit/ad5fde9db3767bee7af4e8c23277a07cad705de7
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T20:17:04+02:00
Commit Message:
WINTERMUTE: Reinstate CVidSubtitle destructor
Changed paths:
engines/wintermute/video/video_subtitle.cpp
diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp
index 74b3119..3d0688d 100644
--- a/engines/wintermute/video/video_subtitle.cpp
+++ b/engines/wintermute/video/video_subtitle.cpp
@@ -26,7 +26,6 @@
* Copyright (c) 2011 Jan Nedoma
*/
-// #include "dcgf.h"
#include "engines/wintermute/video/video_subtitle.h"
namespace Wintermute {
@@ -42,8 +41,7 @@ CVidSubtitle::CVidSubtitle(BaseGame *inGame): BaseClass(inGame) {
CVidSubtitle::CVidSubtitle(BaseGame *inGame, char *Text, long StartFrame, long EndFrame): BaseClass(inGame) {
m_Text = new char[strlen(Text) + 1];
strcpy(m_Text, Text);
-// _gameRef->m_StringTable->Expand(&m_Text);
-
+ // _gameRef->m_StringTable->Expand(&m_Text);
m_StartFrame = StartFrame;
m_EndFrame = EndFrame;
}
@@ -51,6 +49,9 @@ CVidSubtitle::CVidSubtitle(BaseGame *inGame, char *Text, long StartFrame, long E
//////////////////////////////////////////////////////////////////////////
CVidSubtitle::~CVidSubtitle() {
- // SAFE_DELETE_ARRAY(m_Text);
+ if (m_Text) {
+ delete [] m_Text;
+ m_Text = NULL;
+ }
}
}
Commit: 621a068c0065783bba0430f57b71112d7e42a5a9
https://github.com/scummvm/scummvm/commit/621a068c0065783bba0430f57b71112d7e42a5a9
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:38+02:00
Commit Message:
WINTERMUTE: Mass ScummVM-style renaming in subtitles code
Changed paths:
engines/wintermute/video/video_subtitle.cpp
engines/wintermute/video/video_subtitle.h
engines/wintermute/video/video_subtitler.cpp
engines/wintermute/video/video_subtitler.h
engines/wintermute/video/video_theora_player.cpp
engines/wintermute/video/video_theora_player.h
diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp
index 3d0688d..0fab6fb 100644
--- a/engines/wintermute/video/video_subtitle.cpp
+++ b/engines/wintermute/video/video_subtitle.cpp
@@ -31,27 +31,26 @@
namespace Wintermute {
//////////////////////////////////////////////////////////////////////////
-CVidSubtitle::CVidSubtitle(BaseGame *inGame): BaseClass(inGame) {
- m_Text = NULL;
- m_StartFrame = m_EndFrame = 0;
+VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) {
+ _text = NULL;
+ _startFrame = _endFrame = 0;
}
-
//////////////////////////////////////////////////////////////////////////
-CVidSubtitle::CVidSubtitle(BaseGame *inGame, char *Text, long StartFrame, long EndFrame): BaseClass(inGame) {
- m_Text = new char[strlen(Text) + 1];
- strcpy(m_Text, Text);
- // _gameRef->m_StringTable->Expand(&m_Text);
- m_StartFrame = StartFrame;
- m_EndFrame = EndFrame;
+VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, long startFrame, long endFrame): BaseClass(inGame) {
+ _text = new char[strlen(text) + 1];
+ strcpy(_text, text);
+ // _gameRef->m_StringTable->Expand(&this->text);
+ _startFrame = startFrame;
+ _endFrame = endFrame;
}
//////////////////////////////////////////////////////////////////////////
-CVidSubtitle::~CVidSubtitle() {
- if (m_Text) {
- delete [] m_Text;
- m_Text = NULL;
+VideoSubtitle::~VideoSubtitle() {
+ if (_text) {
+ delete [] _text;
+ _text = NULL;
}
}
}
diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h
index e93007b..6d629b3 100644
--- a/engines/wintermute/video/video_subtitle.h
+++ b/engines/wintermute/video/video_subtitle.h
@@ -33,15 +33,14 @@
namespace Wintermute {
-class CVidSubtitle : public BaseClass {
+class VideoSubtitle : public BaseClass {
public:
- long m_EndFrame;
- long m_StartFrame;
- char *m_Text;
- CVidSubtitle(BaseGame *inGame);
- CVidSubtitle(BaseGame *inGame, char *Text, long StartFrame, long EndFrame);
- virtual ~CVidSubtitle();
-
+ long _endFrame;
+ long _startFrame;
+ char *_text;
+ VideoSubtitle(BaseGame *inGame);
+ VideoSubtitle(BaseGame *inGame, char *text, long startFrame, long endFrame);
+ virtual ~VideoSubtitle();
};
}
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index dd65787..9d0a066 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -35,143 +35,145 @@
namespace Wintermute {
//////////////////////////////////////////////////////////////////////////
-CVidSubtitler::CVidSubtitler(BaseGame *inGame): BaseClass(inGame) {
- m_LastSample = -1;
- m_CurrentSubtitle = 0;
- m_ShowSubtitle = false;
+VideoSubtitler::VideoSubtitler(BaseGame *inGame): BaseClass(inGame) {
+ _lastSample = -1;
+ _currentSubtitle = 0;
+ _showSubtitle = false;
}
//////////////////////////////////////////////////////////////////////////
-CVidSubtitler::~CVidSubtitler(void) {
- for (int i = 0; i < m_Subtitles.size(); i++) {
- delete m_Subtitles[i];
+VideoSubtitler::~VideoSubtitler(void) {
+ for (int i = 0; i < _subtitles.size(); i++) {
+ delete _subtitles[i];
}
- m_Subtitles.clear();
+ _subtitles.clear();
}
//////////////////////////////////////////////////////////////////////////
-bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile) {
+bool VideoSubtitler::loadSubtitles(const char *Filename, const char *subtitleFile) {
if (!Filename) {
return false;
}
- m_Subtitles.clear();
+ for (int i = 0; i < _subtitles.size(); i++) {
+ delete _subtitles[i];
+ }
+
+ _subtitles.clear();
- m_LastSample = -1;
- m_CurrentSubtitle = 0;
- m_ShowSubtitle = false;
+ _lastSample = -1;
+ _currentSubtitle = 0;
+ _showSubtitle = false;
- Common::String NewFile;
+ Common::String newFile;
- if (SubtitleFile) {
- NewFile = Common::String(SubtitleFile);
+ if (subtitleFile) {
+ newFile = Common::String(subtitleFile);
} else {
Common::String path = PathUtil::getDirectoryName(Filename);
Common::String name = PathUtil::getFileNameWithoutExtension(Filename);
Common::String ext = ".SUB";
- NewFile = PathUtil::combine(path, name + ext);
+ newFile = PathUtil::combine(path, name + ext);
}
- long Size;
+ long size;
- Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(NewFile, true, false);
+ Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(newFile, true, false);
if (file == nullptr) {
return false; // no subtitles
}
- Size = file->size();
- char *Buffer = new char[Size];
+ size = file->size();
+ char *buffer = new char[size];
+ file->read(buffer, size);
- file->read(Buffer, Size);
+ long start, end;
+ bool inToken;
+ char *tokenStart;
+ int tokenLength;
+ int tokenPos;
+ int textLength;
- long Start, End;
- bool InToken;
- char *TokenStart;
- int TokenLength;
- int TokenPos;
- int TextLength;
+ int pos = 0;
+ int lineLength = 0;
- int Pos = 0;
- int LineLength = 0;
+ while (pos < size) {
+ start = end = -1;
+ inToken = false;
+ tokenPos = -1;
+ textLength = 0;
- while (Pos < Size) {
- Start = End = -1;
- InToken = false;
- TokenPos = -1;
- TextLength = 0;
+ lineLength = 0;
+ while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++;
- LineLength = 0;
- while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') {
- LineLength++;
- }
+ int realLength = lineLength - (pos + lineLength >= size ? 0 : 1);
+ char *Text = new char[realLength + 1];
+ char *line = (char *)&buffer[pos];
- int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1);
- char *Text = new char[RealLength + 1];
- char *line = (char *)&Buffer[Pos];
-
- for (int i = 0; i < RealLength; i++) {
+ for (int i = 0; i < realLength; i++) {
if (line[i] == '{') {
- if (!InToken) {
- InToken = true;
- TokenStart = line + i + 1;
- TokenLength = 0;
- TokenPos++;
+ if (!inToken) {
+ inToken = true;
+ tokenStart = line + i + 1;
+ tokenLength = 0;
+ tokenPos++;
} else {
- TokenLength++;
+ tokenLength++;
}
} else if (line[i] == '}') {
- if (InToken) {
- InToken = false;
- char *Token = new char[TokenLength + 1];
- strncpy(Token, TokenStart, TokenLength);
- Token[TokenLength] = '\0';
- if (TokenPos == 0) {
- Start = atoi(Token);
- } else if (TokenPos == 1) {
- End = atoi(Token);
+ if (inToken) {
+ inToken = false;
+ char *token = new char[tokenLength + 1];
+ strncpy(token, tokenStart, tokenLength);
+ token[tokenLength] = '\0';
+ if (tokenPos == 0) {
+ start = atoi(token);
+ } else if (tokenPos == 1) {
+ end = atoi(token);
}
- delete [] Token;
+
+ delete[] token;
} else {
- Text[TextLength] = line[i];
- TextLength++;
+ Text[textLength] = line[i];
+ textLength++;
}
} else {
- if (InToken) {
- TokenLength++;
+ if (inToken) {
+ tokenLength++;
} else {
- Text[TextLength] = line[i];
- if (Text[TextLength] == '|') {
- Text[TextLength] = '\n';
+ Text[textLength] = line[i];
+ if (Text[textLength] == '|') {
+ Text[textLength] = '\n';
}
- TextLength++;
+ textLength++;
}
}
}
- Text[TextLength] = '\0';
+ Text[textLength] = '\0';
- if (Start != -1 && TextLength > 0 && (Start != 1 || End != 1)) {
- m_Subtitles.push_back(new CVidSubtitle(_gameRef, Text, Start, End));
+ if (start != -1 && textLength > 0 && (start != 1 || end != 1)) {
+ _subtitles.push_back(new VideoSubtitle(_gameRef, Text, start, end));
}
delete [] Text;
- Pos += LineLength + 1;
+ pos += lineLength + 1;
}
- delete [] Buffer;
+ delete[] buffer;
return false;
}
//////////////////////////////////////////////////////////////////////////
-bool CVidSubtitler::Display() {
- if (m_ShowSubtitle) {
+bool VideoSubtitler::display() {
+ if (_showSubtitle) {
BaseFont *font = _gameRef->getVideoFont() ? _gameRef->getVideoFont() : _gameRef->getSystemFont();
- int textHeight = font->getTextHeight((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text, _gameRef->_renderer->getWidth());
- font->drawText((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text,
+ int textHeight = font->getTextHeight((byte *)_subtitles[_currentSubtitle]->_text, _gameRef->_renderer->getWidth());
+ font->drawText((byte *)_subtitles[_currentSubtitle]->_text,
0,
(_gameRef->_renderer->getHeight() - textHeight - 5),
(_gameRef->_renderer->getWidth(), TAL_CENTER));
@@ -180,26 +182,26 @@ bool CVidSubtitler::Display() {
}
//////////////////////////////////////////////////////////////////////////
-bool CVidSubtitler::Update(long Frame) {
- if (Frame != m_LastSample) {
- m_LastSample = Frame;
+bool VideoSubtitler::update(long frame) {
+ if (frame != _lastSample) {
+ _lastSample = frame;
// process subtitles
- m_ShowSubtitle = false;
- while (m_CurrentSubtitle < m_Subtitles.size()) {
- int End = m_Subtitles[m_CurrentSubtitle]->m_EndFrame;
+ _showSubtitle = false;
+ while (_currentSubtitle < _subtitles.size()) {
+ int end = _subtitles[_currentSubtitle]->_endFrame;
- bool NextFrameOK = (m_CurrentSubtitle < m_Subtitles.size() - 1 && m_Subtitles[m_CurrentSubtitle + 1]->m_StartFrame <= Frame);
+ bool nextFrameOK = (_currentSubtitle < _subtitles.size() - 1 && _subtitles[_currentSubtitle + 1]->_startFrame <= frame);
- if (Frame > End) {
- if (NextFrameOK) {
- m_CurrentSubtitle++;
+ if (frame > end) {
+ if (nextFrameOK) {
+ _currentSubtitle++;
} else {
- m_ShowSubtitle = (End == 0);
+ _showSubtitle = (end == 0);
break;
}
} else {
- m_ShowSubtitle = true;
+ _showSubtitle = true;
break;
}
}
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index 25641bc..e42fbeb 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -34,19 +34,18 @@
namespace Wintermute {
-class CVidSubtitler :
- public BaseClass {
+class VideoSubtitler : public BaseClass {
public:
- CVidSubtitler(BaseGame *inGame);
- virtual ~CVidSubtitler(void);
-
- bool m_ShowSubtitle;
- int m_CurrentSubtitle;
- bool LoadSubtitles(const char *Filename, const char *SubtitleFile);
- bool Display();
- bool Update(long Frame);
- long m_LastSample;
- Common::Array<CVidSubtitle *> m_Subtitles;
+ VideoSubtitler(BaseGame *inGame);
+ virtual ~VideoSubtitler(void);
+
+ bool _showSubtitle;
+ int _currentSubtitle;
+ bool loadSubtitles(const char *filename, const char *subtitleFile);
+ bool display();
+ bool update(long frame);
+ long _lastSample;
+ Common::Array<VideoSubtitle *> _subtitles;
};
}
diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp
index 232c484..a90fb02 100644
--- a/engines/wintermute/video/video_theora_player.cpp
+++ b/engines/wintermute/video/video_theora_player.cpp
@@ -85,13 +85,16 @@ void VideoTheoraPlayer::SetDefaults() {
_volume = 100;
_theoraDecoder = nullptr;
- _subtitler = new CVidSubtitler(_gameRef);
+ _subtitler = new VideoSubtitler(_gameRef);
}
//////////////////////////////////////////////////////////////////////////
VideoTheoraPlayer::~VideoTheoraPlayer(void) {
cleanup();
-// SAFE_DELETE(_subtitler);
+ if(_subtitler) {
+ delete [] _subtitler;
+ _subtitler = NULL;
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -131,7 +134,7 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common:
#endif
- _subtitler->LoadSubtitles(_filename.c_str(), subtitleFile.c_str());
+ _subtitler->loadSubtitles(_filename.c_str(), subtitleFile.c_str());
_theoraDecoder->loadStream(_file);
@@ -217,8 +220,8 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame,
_state = THEORA_STATE_PLAYING;
_looping = looping;
_playbackType = type;
- _subtitler->Update(_theoraDecoder->getFrameCount());
- _subtitler->Display();
+ _subtitler->update(_theoraDecoder->getFrameCount());
+ _subtitler->display();
_startTime = startTime;
_volume = volume;
_posX = x;
@@ -260,7 +263,7 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame,
#if 0 // Stubbed for now as theora isn't seekable
if (StartTime) SeekToTime(StartTime);
- Update();
+ update();
#endif
return STATUS_FAILED;
}
@@ -294,7 +297,7 @@ bool VideoTheoraPlayer::update() {
if (_theoraDecoder) {
- _subtitler->Update(_theoraDecoder->getCurFrame());
+ _subtitler->update(_theoraDecoder->getCurFrame());
if (_theoraDecoder->endOfVideo() && _looping) {
warning("Should loop movie %s, hacked for now", _filename.c_str());
@@ -423,7 +426,7 @@ bool VideoTheoraPlayer::display(uint32 alpha) {
/* if (m_Subtitler && _gameRef->m_VideoSubtitles) {
m_Subtitler->display();
}*/
- _subtitler->Display();
+ _subtitler->display();
return res;
}
diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h
index 2d79c54..698326c 100644
--- a/engines/wintermute/video/video_theora_player.h
+++ b/engines/wintermute/video/video_theora_player.h
@@ -60,7 +60,7 @@ public:
Common::String _filename;
BaseSurface *_texture;
- CVidSubtitler *_subtitler;
+ VideoSubtitler *_subtitler;
// control methods
bool initialize(const Common::String &filename, const Common::String &subtitleFile = Common::String());
Commit: 0475fd1a5c845fe785184bafa42b9302c814b654
https://github.com/scummvm/scummvm/commit/0475fd1a5c845fe785184bafa42b9302c814b654
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:44+02:00
Commit Message:
WINTERMUTE: Declare counters as uint to match Array::size()
Changed paths:
engines/wintermute/video/video_subtitler.cpp
engines/wintermute/video/video_subtitler.h
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 9d0a066..3c607ce 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -43,7 +43,7 @@ VideoSubtitler::VideoSubtitler(BaseGame *inGame): BaseClass(inGame) {
//////////////////////////////////////////////////////////////////////////
VideoSubtitler::~VideoSubtitler(void) {
- for (int i = 0; i < _subtitles.size(); i++) {
+ for (uint i = 0; i < _subtitles.size(); i++) {
delete _subtitles[i];
}
_subtitles.clear();
@@ -56,7 +56,7 @@ bool VideoSubtitler::loadSubtitles(const char *Filename, const char *subtitleFil
return false;
}
- for (int i = 0; i < _subtitles.size(); i++) {
+ for (uint i = 0; i < _subtitles.size(); i++) {
delete _subtitles[i];
}
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index e42fbeb..0025f19 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -40,7 +40,7 @@ public:
virtual ~VideoSubtitler(void);
bool _showSubtitle;
- int _currentSubtitle;
+ uint _currentSubtitle;
bool loadSubtitles(const char *filename, const char *subtitleFile);
bool display();
bool update(long frame);
Commit: 113e837d557d4316efc83b771480199a5cc023c8
https://github.com/scummvm/scummvm/commit/113e837d557d4316efc83b771480199a5cc023c8
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:44+02:00
Commit Message:
WINTERMUTE: Correctly delete _subtitler (which is not an array)
Changed paths:
engines/wintermute/video/video_theora_player.cpp
diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp
index a90fb02..600eae8 100644
--- a/engines/wintermute/video/video_theora_player.cpp
+++ b/engines/wintermute/video/video_theora_player.cpp
@@ -92,7 +92,7 @@ void VideoTheoraPlayer::SetDefaults() {
VideoTheoraPlayer::~VideoTheoraPlayer(void) {
cleanup();
if(_subtitler) {
- delete [] _subtitler;
+ delete _subtitler;
_subtitler = NULL;
}
}
Commit: 647b7217444fbe88f21a99073cb2377092bef9ab
https://github.com/scummvm/scummvm/commit/647b7217444fbe88f21a99073cb2377092bef9ab
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:44+02:00
Commit Message:
WINTERMUTE: Refactor/Reformat VideoSubtitler::update
Changed paths:
engines/wintermute/video/video_subtitler.cpp
engines/wintermute/video/video_subtitler.h
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 3c607ce..e4c55fe 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -46,13 +46,14 @@ VideoSubtitler::~VideoSubtitler(void) {
for (uint i = 0; i < _subtitles.size(); i++) {
delete _subtitles[i];
}
+
_subtitles.clear();
}
//////////////////////////////////////////////////////////////////////////
-bool VideoSubtitler::loadSubtitles(const char *Filename, const char *subtitleFile) {
- if (!Filename) {
+bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFile) {
+ if (!filename) {
return false;
}
@@ -72,8 +73,8 @@ bool VideoSubtitler::loadSubtitles(const char *Filename, const char *subtitleFil
if (subtitleFile) {
newFile = Common::String(subtitleFile);
} else {
- Common::String path = PathUtil::getDirectoryName(Filename);
- Common::String name = PathUtil::getFileNameWithoutExtension(Filename);
+ Common::String path = PathUtil::getDirectoryName(filename);
+ Common::String name = PathUtil::getFileNameWithoutExtension(filename);
Common::String ext = ".SUB";
newFile = PathUtil::combine(path, name + ext);
}
@@ -107,10 +108,22 @@ bool VideoSubtitler::loadSubtitles(const char *Filename, const char *subtitleFil
textLength = 0;
lineLength = 0;
- while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++;
- int realLength = lineLength - (pos + lineLength >= size ? 0 : 1);
- char *Text = new char[realLength + 1];
+ while (pos + lineLength < size &&
+ buffer[pos + lineLength] != '\n' &&
+ buffer[pos + lineLength] != '\0') {
+ lineLength++;
+ }
+
+ int realLength;
+
+ if (pos + lineLength >= size) {
+ realLength = lineLength - 0;
+ } else {
+ realLength = lineLength - 1;
+ }
+
+ char *text = new char[realLength + 1];
char *line = (char *)&buffer[pos];
for (int i = 0; i < realLength; i++) {
@@ -134,31 +147,31 @@ bool VideoSubtitler::loadSubtitles(const char *Filename, const char *subtitleFil
} else if (tokenPos == 1) {
end = atoi(token);
}
-
delete[] token;
} else {
- Text[textLength] = line[i];
+ text[textLength] = line[i];
textLength++;
}
} else {
if (inToken) {
tokenLength++;
} else {
- Text[textLength] = line[i];
- if (Text[textLength] == '|') {
- Text[textLength] = '\n';
+ text[textLength] = line[i];
+ if (text[textLength] == '|') {
+ text[textLength] = '\n';
}
textLength++;
}
}
}
- Text[textLength] = '\0';
+
+ text[textLength] = '\0';
if (start != -1 && textLength > 0 && (start != 1 || end != 1)) {
- _subtitles.push_back(new VideoSubtitle(_gameRef, Text, start, end));
+ _subtitles.push_back(new VideoSubtitle(_gameRef, text, start, end));
}
- delete [] Text;
+ delete [] text;
pos += lineLength + 1;
}
@@ -184,27 +197,57 @@ bool VideoSubtitler::display() {
//////////////////////////////////////////////////////////////////////////
bool VideoSubtitler::update(long frame) {
if (frame != _lastSample) {
+ /*
+ * If the frame count hasn't advanced the previous state still matches
+ * the current frame (obviously).
+ */
+
_lastSample = frame;
+ // Otherwise, we update _lastSample; see above.
- // process subtitles
_showSubtitle = false;
- while (_currentSubtitle < _subtitles.size()) {
- int end = _subtitles[_currentSubtitle]->_endFrame;
- bool nextFrameOK = (_currentSubtitle < _subtitles.size() - 1 && _subtitles[_currentSubtitle + 1]->_startFrame <= frame);
+ bool overdue = (frame > _subtitles[_currentSubtitle]->_endFrame);
+ bool hasNext = (_currentSubtitle + 1 < _subtitles.size());
+ bool nextStarted = false;
+ if (hasNext) {
+ nextStarted = (_subtitles[_currentSubtitle + 1]->_startFrame <= frame);
+ }
- if (frame > end) {
- if (nextFrameOK) {
- _currentSubtitle++;
- } else {
- _showSubtitle = (end == 0);
- break;
- }
+ while (_currentSubtitle < _subtitles.size() &&
+ overdue && hasNext && nextStarted) {
+ /*
+ * We advance until we get past all overdue subtitles.
+ * We should exit the cycle when we either reach the first
+ * subtitle which is not overdue whose subsequent subtitle
+ * has not started yet (aka the one we must display now or
+ * the one which WILL be displayed when its time comes)
+ * and / or when we reach the last one.
+ */
+
+ _currentSubtitle++;
+
+ overdue = (frame > _subtitles[_currentSubtitle]->_endFrame);
+ hasNext = (_currentSubtitle + 1 < _subtitles.size());
+ if (hasNext) {
+ nextStarted = (_subtitles[_currentSubtitle + 1]->_startFrame <= frame);
} else {
- _showSubtitle = true;
- break;
+ nextStarted = false;
}
}
+
+ bool currentValid = (_subtitles[_currentSubtitle]->_endFrame != 0);
+ /*
+ * No idea why we do this check, carried over from Mnemonic's code.
+ * Possibly a workaround for buggy subtitles or some kind of sentinel? :-\
+ */
+
+ bool currentStarted = frame >= _subtitles[_currentSubtitle]->_startFrame;
+
+ if (currentStarted && !overdue && currentValid) {
+ _showSubtitle = true;
+ }
+
}
return false;
}
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index 0025f19..68964a4 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -34,7 +34,8 @@
namespace Wintermute {
-class VideoSubtitler : public BaseClass {
+class VideoSubtitler :
+ public BaseClass {
public:
VideoSubtitler(BaseGame *inGame);
virtual ~VideoSubtitler(void);
Commit: 6d16fdbf4ab9139d368ab7585f9ad1fae5c8a523
https://github.com/scummvm/scummvm/commit/6d16fdbf4ab9139d368ab7585f9ad1fae5c8a523
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:44+02:00
Commit Message:
WINTERMUTE: Expand subtitles by string table
Changed paths:
engines/wintermute/video/video_subtitle.cpp
diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp
index 0fab6fb..5be22de 100644
--- a/engines/wintermute/video/video_subtitle.cpp
+++ b/engines/wintermute/video/video_subtitle.cpp
@@ -27,7 +27,7 @@
*/
#include "engines/wintermute/video/video_subtitle.h"
-
+#include "engines/wintermute/base/base_game.h"
namespace Wintermute {
//////////////////////////////////////////////////////////////////////////
@@ -40,7 +40,7 @@ VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) {
VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, long startFrame, long endFrame): BaseClass(inGame) {
_text = new char[strlen(text) + 1];
strcpy(_text, text);
- // _gameRef->m_StringTable->Expand(&this->text);
+ _gameRef->expandStringByStringTable(&_text);
_startFrame = startFrame;
_endFrame = endFrame;
}
Commit: f2441da3da9ce4802ce12dc5c815095098e57ee2
https://github.com/scummvm/scummvm/commit/f2441da3da9ce4802ce12dc5c815095098e57ee2
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:44+02:00
Commit Message:
WINTERMUTE: Make sure subtitle files could be found before anything else
Changed paths:
engines/wintermute/video/video_subtitler.cpp
engines/wintermute/video/video_theora_player.cpp
engines/wintermute/video/video_theora_player.h
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index e4c55fe..06b8bab 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -177,8 +177,9 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil
}
delete[] buffer;
+ // Succeeded loading subtitles!
- return false;
+ return true;
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp
index 600eae8..2af3ac1 100644
--- a/engines/wintermute/video/video_theora_player.cpp
+++ b/engines/wintermute/video/video_theora_player.cpp
@@ -86,6 +86,7 @@ void VideoTheoraPlayer::SetDefaults() {
_theoraDecoder = nullptr;
_subtitler = new VideoSubtitler(_gameRef);
+ _subtitles = false;
}
//////////////////////////////////////////////////////////////////////////
@@ -134,7 +135,13 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common:
#endif
- _subtitler->loadSubtitles(_filename.c_str(), subtitleFile.c_str());
+ if (_subtitler->loadSubtitles(_filename.c_str(), subtitleFile.c_str())) {
+ // We have subtitles
+ _subtitles = true;
+ } else {
+ // We couldn't load subtitles...
+ _subtitles = false;
+ }
_theoraDecoder->loadStream(_file);
@@ -220,8 +227,10 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame,
_state = THEORA_STATE_PLAYING;
_looping = looping;
_playbackType = type;
- _subtitler->update(_theoraDecoder->getFrameCount());
- _subtitler->display();
+ if (_subtitler && _subtitles && _gameRef->_subtitles) {
+ _subtitler->update(_theoraDecoder->getFrameCount());
+ _subtitler->display();
+ }
_startTime = startTime;
_volume = volume;
_posX = x;
@@ -296,8 +305,9 @@ bool VideoTheoraPlayer::update() {
}
if (_theoraDecoder) {
-
- _subtitler->update(_theoraDecoder->getCurFrame());
+ if (_subtitler && _subtitles && _gameRef->_subtitles) {
+ _subtitler->update(_theoraDecoder->getCurFrame());
+ }
if (_theoraDecoder->endOfVideo() && _looping) {
warning("Should loop movie %s, hacked for now", _filename.c_str());
@@ -422,12 +432,10 @@ bool VideoTheoraPlayer::display(uint32 alpha) {
} else {
res = STATUS_FAILED;
}
- // TODO: Add subtitles-support
-/* if (m_Subtitler && _gameRef->m_VideoSubtitles) {
- m_Subtitler->display();
- }*/
- _subtitler->display();
+ if (_subtitler && _subtitles && _gameRef->_subtitles) {
+ _subtitler->display();
+ }
return res;
}
diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h
index 698326c..48f75ef 100644
--- a/engines/wintermute/video/video_theora_player.h
+++ b/engines/wintermute/video/video_theora_player.h
@@ -138,9 +138,10 @@ private:
bool _playbackStarted;
+ bool _subtitles;
+
// helpers
void SetDefaults();
-
};
} // End of namespace Wintermute
Commit: 2eee488e364460772dcb8a85962f6c210810587b
https://github.com/scummvm/scummvm/commit/2eee488e364460772dcb8a85962f6c210810587b
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:45+02:00
Commit Message:
WINTERMUTE: Do some refactoring over a bunch of attrs in VideoSubtitle
Conflicts:
engines/wintermute/video/video_subtitler.cpp
Changed paths:
engines/wintermute/video/video_subtitle.cpp
engines/wintermute/video/video_subtitle.h
engines/wintermute/video/video_subtitler.cpp
diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp
index 5be22de..bcaa293 100644
--- a/engines/wintermute/video/video_subtitle.cpp
+++ b/engines/wintermute/video/video_subtitle.cpp
@@ -32,25 +32,26 @@ namespace Wintermute {
//////////////////////////////////////////////////////////////////////////
VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) {
- _text = NULL;
_startFrame = _endFrame = 0;
}
//////////////////////////////////////////////////////////////////////////
-VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, long startFrame, long endFrame): BaseClass(inGame) {
- _text = new char[strlen(text) + 1];
- strcpy(_text, text);
- _gameRef->expandStringByStringTable(&_text);
+VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, const long &startFrame, const long &endFrame): BaseClass(inGame) {
+ _gameRef->expandStringByStringTable(&text);
+ _text = Common::String(text);
_startFrame = startFrame;
_endFrame = endFrame;
}
+long VideoSubtitle::getStartFrame() {
+ return _startFrame;
+}
-//////////////////////////////////////////////////////////////////////////
-VideoSubtitle::~VideoSubtitle() {
- if (_text) {
- delete [] _text;
- _text = NULL;
- }
+long VideoSubtitle::getEndFrame() {
+ return _endFrame;
+}
+
+Common::String VideoSubtitle::getText() {
+ return _text;
}
}
diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h
index 6d629b3..5df1348 100644
--- a/engines/wintermute/video/video_subtitle.h
+++ b/engines/wintermute/video/video_subtitle.h
@@ -35,12 +35,15 @@ namespace Wintermute {
class VideoSubtitle : public BaseClass {
public:
+ VideoSubtitle(BaseGame *inGame);
+ VideoSubtitle(BaseGame *inGame, char *text, const long &startFrame, const long &endFrame);
+ long getEndFrame();
+ long getStartFrame();
+ Common::String getText();
+private:
long _endFrame;
long _startFrame;
- char *_text;
- VideoSubtitle(BaseGame *inGame);
- VideoSubtitle(BaseGame *inGame, char *text, long startFrame, long endFrame);
- virtual ~VideoSubtitle();
+ Common::String _text;
};
}
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 06b8bab..a1294dd 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -186,8 +186,8 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil
bool VideoSubtitler::display() {
if (_showSubtitle) {
BaseFont *font = _gameRef->getVideoFont() ? _gameRef->getVideoFont() : _gameRef->getSystemFont();
- int textHeight = font->getTextHeight((byte *)_subtitles[_currentSubtitle]->_text, _gameRef->_renderer->getWidth());
- font->drawText((byte *)_subtitles[_currentSubtitle]->_text,
+ int textHeight = font->getTextHeight((byte *)_subtitles[_currentSubtitle]->getText().c_str(), _gameRef->_renderer->getWidth());
+ font->drawText((byte *)_subtitles[_currentSubtitle]->getText().c_str(),
0,
(_gameRef->_renderer->getHeight() - textHeight - 5),
(_gameRef->_renderer->getWidth(), TAL_CENTER));
@@ -208,11 +208,11 @@ bool VideoSubtitler::update(long frame) {
_showSubtitle = false;
- bool overdue = (frame > _subtitles[_currentSubtitle]->_endFrame);
+ bool overdue = (frame > _subtitles[_currentSubtitle]->getEndFrame());
bool hasNext = (_currentSubtitle + 1 < _subtitles.size());
bool nextStarted = false;
if (hasNext) {
- nextStarted = (_subtitles[_currentSubtitle + 1]->_startFrame <= frame);
+ nextStarted = (_subtitles[_currentSubtitle + 1]->getStartFrame() <= frame);
}
while (_currentSubtitle < _subtitles.size() &&
@@ -228,22 +228,22 @@ bool VideoSubtitler::update(long frame) {
_currentSubtitle++;
- overdue = (frame > _subtitles[_currentSubtitle]->_endFrame);
+ overdue = (frame > _subtitles[_currentSubtitle]->getEndFrame());
hasNext = (_currentSubtitle + 1 < _subtitles.size());
if (hasNext) {
- nextStarted = (_subtitles[_currentSubtitle + 1]->_startFrame <= frame);
+ nextStarted = (_subtitles[_currentSubtitle + 1]->getStartFrame() <= frame);
} else {
nextStarted = false;
}
}
- bool currentValid = (_subtitles[_currentSubtitle]->_endFrame != 0);
+ bool currentValid = (_subtitles[_currentSubtitle]->getEndFrame() != 0);
/*
* No idea why we do this check, carried over from Mnemonic's code.
* Possibly a workaround for buggy subtitles or some kind of sentinel? :-\
*/
- bool currentStarted = frame >= _subtitles[_currentSubtitle]->_startFrame;
+ bool currentStarted = frame >= _subtitles[_currentSubtitle]->getStartFrame();
if (currentStarted && !overdue && currentValid) {
_showSubtitle = true;
Commit: 8decf3d7424c8cb8eeae99d0aede78c445f18e9f
https://github.com/scummvm/scummvm/commit/8decf3d7424c8cb8eeae99d0aede78c445f18e9f
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:45+02:00
Commit Message:
WINTERMUTE: Remove ////-style separators from imported subtitle code
Changed paths:
engines/wintermute/video/video_subtitle.cpp
engines/wintermute/video/video_subtitle.h
engines/wintermute/video/video_subtitler.cpp
engines/wintermute/video/video_subtitler.h
diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp
index bcaa293..21fb5ec 100644
--- a/engines/wintermute/video/video_subtitle.cpp
+++ b/engines/wintermute/video/video_subtitle.cpp
@@ -30,12 +30,10 @@
#include "engines/wintermute/base/base_game.h"
namespace Wintermute {
-//////////////////////////////////////////////////////////////////////////
VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) {
_startFrame = _endFrame = 0;
}
-//////////////////////////////////////////////////////////////////////////
VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, const long &startFrame, const long &endFrame): BaseClass(inGame) {
_gameRef->expandStringByStringTable(&text);
_text = Common::String(text);
@@ -54,4 +52,5 @@ long VideoSubtitle::getEndFrame() {
Common::String VideoSubtitle::getText() {
return _text;
}
-}
+
+} // End of namespace Wintermute
diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h
index 5df1348..3af0d06 100644
--- a/engines/wintermute/video/video_subtitle.h
+++ b/engines/wintermute/video/video_subtitle.h
@@ -45,6 +45,7 @@ private:
long _startFrame;
Common::String _text;
};
-}
+
+} // End of namespace Wintermute
#endif
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index a1294dd..b85e179 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -34,14 +34,13 @@
#include "engines/wintermute/base/gfx/base_renderer.h"
namespace Wintermute {
-//////////////////////////////////////////////////////////////////////////
+
VideoSubtitler::VideoSubtitler(BaseGame *inGame): BaseClass(inGame) {
_lastSample = -1;
_currentSubtitle = 0;
_showSubtitle = false;
}
-//////////////////////////////////////////////////////////////////////////
VideoSubtitler::~VideoSubtitler(void) {
for (uint i = 0; i < _subtitles.size(); i++) {
delete _subtitles[i];
@@ -50,8 +49,6 @@ VideoSubtitler::~VideoSubtitler(void) {
_subtitles.clear();
}
-
-//////////////////////////////////////////////////////////////////////////
bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFile) {
if (!filename) {
return false;
@@ -182,7 +179,6 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil
return true;
}
-//////////////////////////////////////////////////////////////////////////
bool VideoSubtitler::display() {
if (_showSubtitle) {
BaseFont *font = _gameRef->getVideoFont() ? _gameRef->getVideoFont() : _gameRef->getSystemFont();
@@ -195,7 +191,6 @@ bool VideoSubtitler::display() {
return false;
}
-//////////////////////////////////////////////////////////////////////////
bool VideoSubtitler::update(long frame) {
if (frame != _lastSample) {
/*
@@ -252,4 +247,5 @@ bool VideoSubtitler::update(long frame) {
}
return false;
}
-}
+
+} // End of namespace Wintermute
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index 68964a4..977fc10 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -48,6 +48,7 @@ public:
long _lastSample;
Common::Array<VideoSubtitle *> _subtitles;
};
-}
+
+} // End of namespace Wintermute
#endif
Commit: a78a4d40dd1be6649f83a9411311d9210f1ddeea
https://github.com/scummvm/scummvm/commit/a78a4d40dd1be6649f83a9411311d9210f1ddeea
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:45+02:00
Commit Message:
WINTERMUTE: Use Common::String in place of char *text in loadSubtitles
Changed paths:
engines/wintermute/video/video_subtitle.cpp
engines/wintermute/video/video_subtitle.h
engines/wintermute/video/video_subtitler.cpp
engines/wintermute/video/video_subtitler.h
engines/wintermute/video/video_theora_player.cpp
diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp
index 21fb5ec..c9892b5 100644
--- a/engines/wintermute/video/video_subtitle.cpp
+++ b/engines/wintermute/video/video_subtitle.cpp
@@ -34,9 +34,12 @@ VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) {
_startFrame = _endFrame = 0;
}
-VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, const long &startFrame, const long &endFrame): BaseClass(inGame) {
- _gameRef->expandStringByStringTable(&text);
- _text = Common::String(text);
+VideoSubtitle::VideoSubtitle(BaseGame *inGame, const Common::String &text, const long &startFrame, const long &endFrame): BaseClass(inGame) {
+ // TODO: Fix expandStringByStringTable instead of this ugly hack
+ char *tmp = new char[text.size()];
+ strcpy(tmp, text.c_str());
+ _gameRef->expandStringByStringTable(&tmp);
+ _text = Common::String(tmp);
_startFrame = startFrame;
_endFrame = endFrame;
}
diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h
index 3af0d06..03d4b6b 100644
--- a/engines/wintermute/video/video_subtitle.h
+++ b/engines/wintermute/video/video_subtitle.h
@@ -36,7 +36,7 @@ namespace Wintermute {
class VideoSubtitle : public BaseClass {
public:
VideoSubtitle(BaseGame *inGame);
- VideoSubtitle(BaseGame *inGame, char *text, const long &startFrame, const long &endFrame);
+ VideoSubtitle(BaseGame *inGame, const Common::String &text, const long &startFrame, const long &endFrame);
long getEndFrame();
long getStartFrame();
Common::String getText();
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index b85e179..f1becb0 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -49,8 +49,8 @@ VideoSubtitler::~VideoSubtitler(void) {
_subtitles.clear();
}
-bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFile) {
- if (!filename) {
+bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common::String &subtitleFile) {
+ if (filename.size() == 0) {
return false;
}
@@ -67,7 +67,7 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil
Common::String newFile;
- if (subtitleFile) {
+ if (subtitleFile.size() != 0) {
newFile = Common::String(subtitleFile);
} else {
Common::String path = PathUtil::getDirectoryName(filename);
@@ -93,7 +93,6 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil
char *tokenStart;
int tokenLength;
int tokenPos;
- int textLength;
int pos = 0;
int lineLength = 0;
@@ -102,7 +101,6 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil
start = end = -1;
inToken = false;
tokenPos = -1;
- textLength = 0;
lineLength = 0;
@@ -120,7 +118,7 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil
realLength = lineLength - 1;
}
- char *text = new char[realLength + 1];
+ Common::String text;
char *line = (char *)&buffer[pos];
for (int i = 0; i < realLength; i++) {
@@ -146,30 +144,25 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil
}
delete[] token;
} else {
- text[textLength] = line[i];
- textLength++;
+ text += line[i];
}
} else {
if (inToken) {
tokenLength++;
} else {
- text[textLength] = line[i];
- if (text[textLength] == '|') {
- text[textLength] = '\n';
+ if (line[i] == '|') {
+ text += '\n';
+ } else {
+ text += line[i];
}
- textLength++;
}
}
}
- text[textLength] = '\0';
-
- if (start != -1 && textLength > 0 && (start != 1 || end != 1)) {
+ if (start != -1 && text.size() > 0 && (start != 1 || end != 1)) {
_subtitles.push_back(new VideoSubtitle(_gameRef, text, start, end));
}
- delete [] text;
-
pos += lineLength + 1;
}
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index 977fc10..38fdf89 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -42,7 +42,7 @@ public:
bool _showSubtitle;
uint _currentSubtitle;
- bool loadSubtitles(const char *filename, const char *subtitleFile);
+ bool loadSubtitles(const Common::String &filename, const Common::String &subtitleFile);
bool display();
bool update(long frame);
long _lastSample;
diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp
index 2af3ac1..36d012c 100644
--- a/engines/wintermute/video/video_theora_player.cpp
+++ b/engines/wintermute/video/video_theora_player.cpp
@@ -135,7 +135,7 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common:
#endif
- if (_subtitler->loadSubtitles(_filename.c_str(), subtitleFile.c_str())) {
+ if (_subtitler->loadSubtitles(_filename, subtitleFile)) {
// We have subtitles
_subtitles = true;
} else {
Commit: 581aff7f8f0938e71c3c7b8f197269e9a7146f93
https://github.com/scummvm/scummvm/commit/581aff7f8f0938e71c3c7b8f197269e9a7146f93
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:45+02:00
Commit Message:
WINTERMUTE: Keep a bunch of attrs private in VideoSubtitler
Changed paths:
engines/wintermute/video/video_subtitler.h
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index 38fdf89..b369d0b 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -45,8 +45,9 @@ public:
bool loadSubtitles(const Common::String &filename, const Common::String &subtitleFile);
bool display();
bool update(long frame);
- long _lastSample;
+private:
Common::Array<VideoSubtitle *> _subtitles;
+ long _lastSample;
};
} // End of namespace Wintermute
Commit: afb3ae303461668d4807eaa047a5585a7c870adc
https://github.com/scummvm/scummvm/commit/afb3ae303461668d4807eaa047a5585a7c870adc
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:45+02:00
Commit Message:
WINTERMUTE: Treat edge case - prevents crash if SRT file is blank.
Changed paths:
engines/wintermute/video/video_subtitler.cpp
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index f1becb0..0ade366 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -185,6 +185,12 @@ bool VideoSubtitler::display() {
}
bool VideoSubtitler::update(long frame) {
+
+ if (_subtitles.size() == 0) {
+ // Edge case: we have loaded subtitles early on... from a blank file.
+ return false;
+ }
+
if (frame != _lastSample) {
/*
* If the frame count hasn't advanced the previous state still matches
Commit: 7c6f9772d37e3ab7724d20c838883ee8abc2c2b3
https://github.com/scummvm/scummvm/commit/7c6f9772d37e3ab7724d20c838883ee8abc2c2b3
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:45+02:00
Commit Message:
WINTERMUTE: Save frames as uint rather than long
It's just as good: at 30 FPS, this allows for
2 ^ 32 / 30 / 60 = 2386093 mins, which is, I guess, a reasonable limit.
Changed paths:
engines/wintermute/video/video_subtitle.cpp
engines/wintermute/video/video_subtitle.h
engines/wintermute/video/video_subtitler.cpp
engines/wintermute/video/video_subtitler.h
diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp
index c9892b5..eb95f25 100644
--- a/engines/wintermute/video/video_subtitle.cpp
+++ b/engines/wintermute/video/video_subtitle.cpp
@@ -34,7 +34,7 @@ VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) {
_startFrame = _endFrame = 0;
}
-VideoSubtitle::VideoSubtitle(BaseGame *inGame, const Common::String &text, const long &startFrame, const long &endFrame): BaseClass(inGame) {
+VideoSubtitle::VideoSubtitle(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame): BaseClass(inGame) {
// TODO: Fix expandStringByStringTable instead of this ugly hack
char *tmp = new char[text.size()];
strcpy(tmp, text.c_str());
@@ -44,11 +44,11 @@ VideoSubtitle::VideoSubtitle(BaseGame *inGame, const Common::String &text, const
_endFrame = endFrame;
}
-long VideoSubtitle::getStartFrame() {
+uint VideoSubtitle::getStartFrame() {
return _startFrame;
}
-long VideoSubtitle::getEndFrame() {
+uint VideoSubtitle::getEndFrame() {
return _endFrame;
}
diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h
index 03d4b6b..4c80c0c 100644
--- a/engines/wintermute/video/video_subtitle.h
+++ b/engines/wintermute/video/video_subtitle.h
@@ -36,13 +36,13 @@ namespace Wintermute {
class VideoSubtitle : public BaseClass {
public:
VideoSubtitle(BaseGame *inGame);
- VideoSubtitle(BaseGame *inGame, const Common::String &text, const long &startFrame, const long &endFrame);
- long getEndFrame();
- long getStartFrame();
+ VideoSubtitle(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame);
+ uint getEndFrame();
+ uint getStartFrame();
Common::String getText();
private:
- long _endFrame;
- long _startFrame;
+ uint _endFrame;
+ uint _startFrame;
Common::String _text;
};
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 0ade366..8f3032a 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -76,7 +76,7 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
newFile = PathUtil::combine(path, name + ext);
}
- long size;
+ int size;
Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(newFile, true, false);
@@ -88,7 +88,7 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
char *buffer = new char[size];
file->read(buffer, size);
- long start, end;
+ int start, end;
bool inToken;
char *tokenStart;
int tokenLength;
@@ -184,7 +184,7 @@ bool VideoSubtitler::display() {
return false;
}
-bool VideoSubtitler::update(long frame) {
+bool VideoSubtitler::update(uint frame) {
if (_subtitles.size() == 0) {
// Edge case: we have loaded subtitles early on... from a blank file.
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index b369d0b..2940d69 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -44,7 +44,7 @@ public:
uint _currentSubtitle;
bool loadSubtitles(const Common::String &filename, const Common::String &subtitleFile);
bool display();
- bool update(long frame);
+ bool update(uint frame);
private:
Common::Array<VideoSubtitle *> _subtitles;
long _lastSample;
Commit: 40c5b01aad085f1cf69792f1ef945f54d5e844e1
https://github.com/scummvm/scummvm/commit/40c5b01aad085f1cf69792f1ef945f54d5e844e1
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:45+02:00
Commit Message:
WINTERMUTE: Preserve const when handing chars over to drawText
Changed paths:
engines/wintermute/video/video_subtitler.cpp
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 8f3032a..a8ce868 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -64,7 +64,6 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
_currentSubtitle = 0;
_showSubtitle = false;
-
Common::String newFile;
if (subtitleFile.size() != 0) {
@@ -174,18 +173,28 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
bool VideoSubtitler::display() {
if (_showSubtitle) {
- BaseFont *font = _gameRef->getVideoFont() ? _gameRef->getVideoFont() : _gameRef->getSystemFont();
- int textHeight = font->getTextHeight((byte *)_subtitles[_currentSubtitle]->getText().c_str(), _gameRef->_renderer->getWidth());
- font->drawText((byte *)_subtitles[_currentSubtitle]->getText().c_str(),
+
+ BaseFont *font;
+
+ if (_gameRef->getVideoFont() == nullptr) {
+ font = _gameRef->getSystemFont();
+ } else {
+ font = _gameRef->getVideoFont();
+ }
+
+ int textHeight = font->getTextHeight(
+ (const byte *)_subtitles[_currentSubtitle]->getText().c_str(),
+ _gameRef->_renderer->getWidth());
+ font->drawText((const byte *)_subtitles[_currentSubtitle]->getText().c_str(),
0,
(_gameRef->_renderer->getHeight() - textHeight - 5),
- (_gameRef->_renderer->getWidth(), TAL_CENTER));
+ (_gameRef->_renderer->getWidth()),
+ TAL_CENTER);
}
return false;
}
bool VideoSubtitler::update(uint frame) {
-
if (_subtitles.size() == 0) {
// Edge case: we have loaded subtitles early on... from a blank file.
return false;
@@ -242,7 +251,6 @@ bool VideoSubtitler::update(uint frame) {
if (currentStarted && !overdue && currentValid) {
_showSubtitle = true;
}
-
}
return false;
}
Commit: 2acb2f558c4ee018ad30ce6fb6e8412d175b6c46
https://github.com/scummvm/scummvm/commit/2acb2f558c4ee018ad30ce6fb6e8412d175b6c46
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:45+02:00
Commit Message:
WINTERMUTE: Add clarification comment in loadSubtitles
Changed paths:
engines/wintermute/video/video_subtitler.cpp
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index a8ce868..cc46ddf 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -66,6 +66,13 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
Common::String newFile;
+ /*
+ * Okay, the expected behaviour is this: either we are
+ * provided with a subtitle file to use by the script when
+ * calling PlayTheora(), or we try to autodetect a suitable
+ * one which, for /some/path/movie/ogg is to be called
+ * /some/path/movie.sub
+ */
if (subtitleFile.size() != 0) {
newFile = Common::String(subtitleFile);
} else {
Commit: a4d5d1458102959bdc26fc73184e2cfc5f918894
https://github.com/scummvm/scummvm/commit/a4d5d1458102959bdc26fc73184e2cfc5f918894
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:45+02:00
Commit Message:
WINTERMUTE: Turn display() and update() into void functions.
No idea why they were bools in the first place.
Changed paths:
engines/wintermute/video/video_subtitler.cpp
engines/wintermute/video/video_subtitler.h
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index cc46ddf..05c7b6c 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -178,7 +178,7 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
return true;
}
-bool VideoSubtitler::display() {
+void VideoSubtitler::display() {
if (_showSubtitle) {
BaseFont *font;
@@ -192,19 +192,19 @@ bool VideoSubtitler::display() {
int textHeight = font->getTextHeight(
(const byte *)_subtitles[_currentSubtitle]->getText().c_str(),
_gameRef->_renderer->getWidth());
+
font->drawText((const byte *)_subtitles[_currentSubtitle]->getText().c_str(),
0,
(_gameRef->_renderer->getHeight() - textHeight - 5),
(_gameRef->_renderer->getWidth()),
TAL_CENTER);
}
- return false;
}
-bool VideoSubtitler::update(uint frame) {
+void VideoSubtitler::update(uint frame) {
if (_subtitles.size() == 0) {
// Edge case: we have loaded subtitles early on... from a blank file.
- return false;
+ return;
}
if (frame != _lastSample) {
@@ -259,7 +259,6 @@ bool VideoSubtitler::update(uint frame) {
_showSubtitle = true;
}
}
- return false;
}
} // End of namespace Wintermute
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index 2940d69..8c57fd2 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -43,8 +43,8 @@ public:
bool _showSubtitle;
uint _currentSubtitle;
bool loadSubtitles(const Common::String &filename, const Common::String &subtitleFile);
- bool display();
- bool update(uint frame);
+ void display();
+ void update(uint frame);
private:
Common::Array<VideoSubtitle *> _subtitles;
long _lastSample;
Commit: 7b4084b7e0273b37f1fb0583431540d977c424ae
https://github.com/scummvm/scummvm/commit/7b4084b7e0273b37f1fb0583431540d977c424ae
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:45+02:00
Commit Message:
WINTERMUTE: s/uint32 _lastSample/long _lastSample/
Changed paths:
engines/wintermute/video/video_subtitler.h
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index 8c57fd2..3f62c05 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -47,7 +47,7 @@ public:
void update(uint frame);
private:
Common::Array<VideoSubtitle *> _subtitles;
- long _lastSample;
+ uint32 _lastSample;
};
} // End of namespace Wintermute
Commit: dd820a7a1e9adcb7c46d2cb2fe178c895e40b8c3
https://github.com/scummvm/scummvm/commit/dd820a7a1e9adcb7c46d2cb2fe178c895e40b8c3
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:46+02:00
Commit Message:
WINTERMUTE: Turn a bunch of uint into uint32 in VideoSubtitle
Changed paths:
engines/wintermute/video/video_subtitle.cpp
engines/wintermute/video/video_subtitle.h
engines/wintermute/video/video_subtitler.cpp
engines/wintermute/video/video_subtitler.h
diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp
index eb95f25..b02a3ec 100644
--- a/engines/wintermute/video/video_subtitle.cpp
+++ b/engines/wintermute/video/video_subtitle.cpp
@@ -44,11 +44,11 @@ VideoSubtitle::VideoSubtitle(BaseGame *inGame, const Common::String &text, const
_endFrame = endFrame;
}
-uint VideoSubtitle::getStartFrame() {
+uint32 VideoSubtitle::getStartFrame() {
return _startFrame;
}
-uint VideoSubtitle::getEndFrame() {
+uint32 VideoSubtitle::getEndFrame() {
return _endFrame;
}
diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h
index 4c80c0c..fb80a58 100644
--- a/engines/wintermute/video/video_subtitle.h
+++ b/engines/wintermute/video/video_subtitle.h
@@ -37,12 +37,12 @@ class VideoSubtitle : public BaseClass {
public:
VideoSubtitle(BaseGame *inGame);
VideoSubtitle(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame);
- uint getEndFrame();
- uint getStartFrame();
+ uint32 getEndFrame();
+ uint32 getStartFrame();
Common::String getText();
private:
- uint _endFrame;
- uint _startFrame;
+ uint32 _endFrame;
+ uint32 _startFrame;
Common::String _text;
};
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 05c7b6c..c8acbeb 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -201,7 +201,7 @@ void VideoSubtitler::display() {
}
}
-void VideoSubtitler::update(uint frame) {
+void VideoSubtitler::update(uint32 frame) {
if (_subtitles.size() == 0) {
// Edge case: we have loaded subtitles early on... from a blank file.
return;
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index 3f62c05..655b1a5 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -41,10 +41,10 @@ public:
virtual ~VideoSubtitler(void);
bool _showSubtitle;
- uint _currentSubtitle;
+ uint32 _currentSubtitle;
bool loadSubtitles(const Common::String &filename, const Common::String &subtitleFile);
void display();
- void update(uint frame);
+ void update(uint32 frame);
private:
Common::Array<VideoSubtitle *> _subtitles;
uint32 _lastSample;
Commit: 388fbdb6eb8df910c2fff2dc34954f34759c5b16
https://github.com/scummvm/scummvm/commit/388fbdb6eb8df910c2fff2dc34954f34759c5b16
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:46+02:00
Commit Message:
WINTERMUTE: Rename VideoSubtitle to SubtitleCard
Changed paths:
A engines/wintermute/video/subtitle_card.cpp
A engines/wintermute/video/subtitle_card.h
R engines/wintermute/video/video_subtitle.cpp
R engines/wintermute/video/video_subtitle.h
engines/wintermute/module.mk
engines/wintermute/video/video_subtitler.cpp
engines/wintermute/video/video_subtitler.h
diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk
index b4845b0..4c95314 100644
--- a/engines/wintermute/module.mk
+++ b/engines/wintermute/module.mk
@@ -108,8 +108,8 @@ MODULE_OBJS := \
utils/path_util.o \
utils/string_util.o \
utils/utils.o \
+ video/subtitle_card.o \
video/video_player.o \
- video/video_subtitle.o \
video/video_subtitler.o \
video/video_theora_player.o \
debugger.o \
diff --git a/engines/wintermute/video/subtitle_card.cpp b/engines/wintermute/video/subtitle_card.cpp
new file mode 100644
index 0000000..971b2c0
--- /dev/null
+++ b/engines/wintermute/video/subtitle_card.cpp
@@ -0,0 +1,59 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on Wintermute Engine
+ * http://dead-code.org/redir.php?target=wme
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#include "engines/wintermute/video/subtitle_card.h"
+#include "engines/wintermute/base/base_game.h"
+namespace Wintermute {
+
+SubtitleCard::SubtitleCard(BaseGame *inGame): BaseClass(inGame) {
+ _startFrame = _endFrame = 0;
+}
+
+SubtitleCard::SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame): BaseClass(inGame) {
+ // TODO: Fix expandStringByStringTable instead of this ugly hack
+ char *tmp = new char[text.size()];
+ strcpy(tmp, text.c_str());
+ _gameRef->expandStringByStringTable(&tmp);
+ _text = Common::String(tmp);
+ _startFrame = startFrame;
+ _endFrame = endFrame;
+}
+
+uint32 SubtitleCard::getStartFrame() {
+ return _startFrame;
+}
+
+uint32 SubtitleCard::getEndFrame() {
+ return _endFrame;
+}
+
+Common::String SubtitleCard::getText() {
+ return _text;
+}
+
+} // End of namespace Wintermute
diff --git a/engines/wintermute/video/subtitle_card.h b/engines/wintermute/video/subtitle_card.h
new file mode 100644
index 0000000..5390d64
--- /dev/null
+++ b/engines/wintermute/video/subtitle_card.h
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file is based on Wintermute Engine
+ * http://dead-code.org/redir.php?target=wme
+ * Copyright (c) 2011 Jan Nedoma
+ */
+
+#ifndef WINTERMUTE_SUBTITLECARD_H
+#define WINTERMUTE_SUBTITLECARD_H
+
+#include "engines/wintermute/base/base.h"
+
+namespace Wintermute {
+
+class SubtitleCard : public BaseClass {
+public:
+ SubtitleCard(BaseGame *inGame);
+ SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame);
+ uint32 getEndFrame();
+ uint32 getStartFrame();
+ Common::String getText();
+private:
+ uint32 _endFrame;
+ uint32 _startFrame;
+ Common::String _text;
+};
+
+} // End of namespace Wintermute
+
+#endif
diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp
deleted file mode 100644
index b02a3ec..0000000
--- a/engines/wintermute/video/video_subtitle.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This file is based on Wintermute Engine
- * http://dead-code.org/redir.php?target=wme
- * Copyright (c) 2011 Jan Nedoma
- */
-
-#include "engines/wintermute/video/video_subtitle.h"
-#include "engines/wintermute/base/base_game.h"
-namespace Wintermute {
-
-VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) {
- _startFrame = _endFrame = 0;
-}
-
-VideoSubtitle::VideoSubtitle(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame): BaseClass(inGame) {
- // TODO: Fix expandStringByStringTable instead of this ugly hack
- char *tmp = new char[text.size()];
- strcpy(tmp, text.c_str());
- _gameRef->expandStringByStringTable(&tmp);
- _text = Common::String(tmp);
- _startFrame = startFrame;
- _endFrame = endFrame;
-}
-
-uint32 VideoSubtitle::getStartFrame() {
- return _startFrame;
-}
-
-uint32 VideoSubtitle::getEndFrame() {
- return _endFrame;
-}
-
-Common::String VideoSubtitle::getText() {
- return _text;
-}
-
-} // End of namespace Wintermute
diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h
deleted file mode 100644
index fb80a58..0000000
--- a/engines/wintermute/video/video_subtitle.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This file is based on Wintermute Engine
- * http://dead-code.org/redir.php?target=wme
- * Copyright (c) 2011 Jan Nedoma
- */
-
-#ifndef WINTERMUTE_VIDSUBTITLE_H
-#define WINTERMUTE_VIDSUBTITLE_H
-
-#include "engines/wintermute/base/base.h"
-
-namespace Wintermute {
-
-class VideoSubtitle : public BaseClass {
-public:
- VideoSubtitle(BaseGame *inGame);
- VideoSubtitle(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame);
- uint32 getEndFrame();
- uint32 getStartFrame();
- Common::String getText();
-private:
- uint32 _endFrame;
- uint32 _startFrame;
- Common::String _text;
-};
-
-} // End of namespace Wintermute
-
-#endif
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index c8acbeb..c57a70e 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -166,7 +166,7 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
}
if (start != -1 && text.size() > 0 && (start != 1 || end != 1)) {
- _subtitles.push_back(new VideoSubtitle(_gameRef, text, start, end));
+ _subtitles.push_back(new SubtitleCard(_gameRef, text, start, end));
}
pos += lineLength + 1;
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index 655b1a5..32e4368 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -30,7 +30,7 @@
#define WINTERMUTE_VIDSUBTITLER_H
#include "engines/wintermute/base/base.h"
-#include "engines/wintermute/video/video_subtitle.h"
+#include "engines/wintermute/video/subtitle_card.h"
namespace Wintermute {
@@ -46,7 +46,7 @@ public:
void display();
void update(uint32 frame);
private:
- Common::Array<VideoSubtitle *> _subtitles;
+ Common::Array<SubtitleCard *> _subtitles;
uint32 _lastSample;
};
Commit: 1a571d9611ea21040f7b5ff971fcd7b70580a025
https://github.com/scummvm/scummvm/commit/1a571d9611ea21040f7b5ff971fcd7b70580a025
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:46+02:00
Commit Message:
WINTERMUTE: Avoid doing check before delete (deleting 0-pointer is safe)
Changed paths:
engines/wintermute/video/video_theora_player.cpp
diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp
index 36d012c..d16b2ed 100644
--- a/engines/wintermute/video/video_theora_player.cpp
+++ b/engines/wintermute/video/video_theora_player.cpp
@@ -92,10 +92,7 @@ void VideoTheoraPlayer::SetDefaults() {
//////////////////////////////////////////////////////////////////////////
VideoTheoraPlayer::~VideoTheoraPlayer(void) {
cleanup();
- if(_subtitler) {
- delete _subtitler;
- _subtitler = NULL;
- }
+ delete _subtitler;
}
//////////////////////////////////////////////////////////////////////////
Commit: 4742acf9395d069d8e9ee1752c3f8f09c1034b08
https://github.com/scummvm/scummvm/commit/4742acf9395d069d8e9ee1752c3f8f09c1034b08
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:46+02:00
Commit Message:
WINTERMUTE: Rename VideoTheoraPlayer->_subtitles to _foundSubtitles for clarity
Changed paths:
engines/wintermute/video/video_theora_player.cpp
engines/wintermute/video/video_theora_player.h
diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp
index d16b2ed..99fce7b 100644
--- a/engines/wintermute/video/video_theora_player.cpp
+++ b/engines/wintermute/video/video_theora_player.cpp
@@ -86,7 +86,7 @@ void VideoTheoraPlayer::SetDefaults() {
_theoraDecoder = nullptr;
_subtitler = new VideoSubtitler(_gameRef);
- _subtitles = false;
+ _foundSubtitles = false;
}
//////////////////////////////////////////////////////////////////////////
@@ -134,10 +134,10 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common:
if (_subtitler->loadSubtitles(_filename, subtitleFile)) {
// We have subtitles
- _subtitles = true;
+ _foundSubtitles = true;
} else {
// We couldn't load subtitles...
- _subtitles = false;
+ _foundSubtitles = false;
}
_theoraDecoder->loadStream(_file);
@@ -224,7 +224,7 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame,
_state = THEORA_STATE_PLAYING;
_looping = looping;
_playbackType = type;
- if (_subtitler && _subtitles && _gameRef->_subtitles) {
+ if (_subtitler && _foundSubtitles && _gameRef->_subtitles) {
_subtitler->update(_theoraDecoder->getFrameCount());
_subtitler->display();
}
@@ -302,7 +302,7 @@ bool VideoTheoraPlayer::update() {
}
if (_theoraDecoder) {
- if (_subtitler && _subtitles && _gameRef->_subtitles) {
+ if (_subtitler && _foundSubtitles && _gameRef->_subtitles) {
_subtitler->update(_theoraDecoder->getCurFrame());
}
@@ -430,7 +430,7 @@ bool VideoTheoraPlayer::display(uint32 alpha) {
res = STATUS_FAILED;
}
- if (_subtitler && _subtitles && _gameRef->_subtitles) {
+ if (_subtitler && _foundSubtitles && _gameRef->_subtitles) {
_subtitler->display();
}
return res;
diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h
index 48f75ef..0b9b3d4 100644
--- a/engines/wintermute/video/video_theora_player.h
+++ b/engines/wintermute/video/video_theora_player.h
@@ -138,7 +138,7 @@ private:
bool _playbackStarted;
- bool _subtitles;
+ bool _foundSubtitles;
// helpers
void SetDefaults();
Commit: 599390a5ad5b0df7a480230a97b51b9ccb41a177
https://github.com/scummvm/scummvm/commit/599390a5ad5b0df7a480230a97b51b9ccb41a177
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:46+02:00
Commit Message:
WINTERMUTE: Lose unnecessary if() in VideoTheoraPlayer
Changed paths:
engines/wintermute/video/video_theora_player.cpp
diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp
index 99fce7b..22c235c 100644
--- a/engines/wintermute/video/video_theora_player.cpp
+++ b/engines/wintermute/video/video_theora_player.cpp
@@ -131,14 +131,7 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common:
return STATUS_FAILED;
#endif
-
- if (_subtitler->loadSubtitles(_filename, subtitleFile)) {
- // We have subtitles
- _foundSubtitles = true;
- } else {
- // We couldn't load subtitles...
- _foundSubtitles = false;
- }
+ _foundSubtitles = _subtitler->loadSubtitles(_filename, subtitleFile);
_theoraDecoder->loadStream(_file);
Commit: f1ae8e6e8d89f53e8fcd6ffb7eb3faf1e5ab8993
https://github.com/scummvm/scummvm/commit/f1ae8e6e8d89f53e8fcd6ffb7eb3faf1e5ab8993
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:46+02:00
Commit Message:
WINTERMUTE: Introduce BaseGame->expandStringByStringTable(&Common::String)
Changed paths:
engines/wintermute/base/base_game.cpp
engines/wintermute/base/base_game.h
engines/wintermute/base/base_game_settings.cpp
engines/wintermute/base/base_game_settings.h
engines/wintermute/base/base_string_table.cpp
engines/wintermute/base/base_string_table.h
diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp
index 8df39c8..668053b 100644
--- a/engines/wintermute/base/base_game.cpp
+++ b/engines/wintermute/base/base_game.cpp
@@ -3896,6 +3896,11 @@ void BaseGame::expandStringByStringTable(char **str) const {
_settings->expandStringByStringTable(str);
}
+//////////////////////////////////////////////////////////////////////////
+void BaseGame::expandStringByStringTable(Common::String &str) const {
+ _settings->expandStringByStringTable(str);
+}
+
char *BaseGame::getKeyFromStringTable(const char *str) const {
return _settings->getKeyFromStringTable(str);
}
diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h
index f62416e..e535cc9 100644
--- a/engines/wintermute/base/base_game.h
+++ b/engines/wintermute/base/base_game.h
@@ -141,6 +141,7 @@ public:
// String Table
void expandStringByStringTable(char **str) const;
+ void expandStringByStringTable(Common::String &str) const;
char *getKeyFromStringTable(const char *str) const;
void LOG(bool res, const char *fmt, ...);
diff --git a/engines/wintermute/base/base_game_settings.cpp b/engines/wintermute/base/base_game_settings.cpp
index 61c5894..996bada 100644
--- a/engines/wintermute/base/base_game_settings.cpp
+++ b/engines/wintermute/base/base_game_settings.cpp
@@ -215,6 +215,11 @@ void BaseGameSettings::expandStringByStringTable(char **str) const {
_stringTable->expand(str);
}
+//////////////////////////////////////////////////////////////////////////
+void BaseGameSettings::expandStringByStringTable(Common::String &str) const {
+ _stringTable->expand(str);
+}
+
char *BaseGameSettings::getKeyFromStringTable(const char *str) const {
return _stringTable->getKey(str);
}
diff --git a/engines/wintermute/base/base_game_settings.h b/engines/wintermute/base/base_game_settings.h
index 2059cb0..15afb06 100644
--- a/engines/wintermute/base/base_game_settings.h
+++ b/engines/wintermute/base/base_game_settings.h
@@ -46,6 +46,7 @@ public:
bool loadSettings(const char *filename);
bool loadStringTable(const char *filename, bool clearOld);
void expandStringByStringTable(char **str) const;
+ void expandStringByStringTable(Common::String &str) const;
char *getKeyFromStringTable(const char *str) const;
bool persist(BasePersistenceManager *persistMgr);
diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp
index 89407a7..8a9edbe 100644
--- a/engines/wintermute/base/base_string_table.cpp
+++ b/engines/wintermute/base/base_string_table.cpp
@@ -147,6 +147,15 @@ void BaseStringTable::expand(char **str) const {
}
}
+//////////////////////////////////////////////////////////////////////////
+void BaseStringTable::expand(Common::String &str) const {
+ char *tmp = new char[str.size()];
+ strcpy(tmp, str.c_str());
+ expand(&tmp);
+ str = tmp;
+ delete tmp;
+}
+
//////////////////////////////////////////////////////////////////////////
const char *BaseStringTable::expandStatic(const char *string) const {
diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h
index cdcf119..cfa3eeb 100644
--- a/engines/wintermute/base/base_string_table.h
+++ b/engines/wintermute/base/base_string_table.h
@@ -41,6 +41,7 @@ class BaseStringTable : public BaseClass {
public:
bool loadFile(const char *filename, bool deleteAll = true);
void expand(char **str) const;
+ void expand(Common::String &str) const;
const char *expandStatic(const char *string) const;
bool addString(const char *key, const char *val, bool reportDuplicities = true);
BaseStringTable(BaseGame *inGame);
Commit: 5f25cf1bd731ed2bae852610c74a9917942ab883
https://github.com/scummvm/scummvm/commit/5f25cf1bd731ed2bae852610c74a9917942ab883
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:46+02:00
Commit Message:
WINTERMUTE: Don't bother inheriting BaseGame in SubtitleCard
Changed paths:
engines/wintermute/video/subtitle_card.cpp
engines/wintermute/video/subtitle_card.h
diff --git a/engines/wintermute/video/subtitle_card.cpp b/engines/wintermute/video/subtitle_card.cpp
index 971b2c0..c0ad8cc 100644
--- a/engines/wintermute/video/subtitle_card.cpp
+++ b/engines/wintermute/video/subtitle_card.cpp
@@ -28,16 +28,19 @@
#include "engines/wintermute/video/subtitle_card.h"
#include "engines/wintermute/base/base_game.h"
+
namespace Wintermute {
-SubtitleCard::SubtitleCard(BaseGame *inGame): BaseClass(inGame) {
+SubtitleCard::SubtitleCard(BaseGame *inGame) {
+ _gameRef = inGame;
_startFrame = _endFrame = 0;
}
-SubtitleCard::SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame): BaseClass(inGame) {
+SubtitleCard::SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame) {
// TODO: Fix expandStringByStringTable instead of this ugly hack
char *tmp = new char[text.size()];
strcpy(tmp, text.c_str());
+ _gameRef = inGame;
_gameRef->expandStringByStringTable(&tmp);
_text = Common::String(tmp);
_startFrame = startFrame;
diff --git a/engines/wintermute/video/subtitle_card.h b/engines/wintermute/video/subtitle_card.h
index 5390d64..94543d9 100644
--- a/engines/wintermute/video/subtitle_card.h
+++ b/engines/wintermute/video/subtitle_card.h
@@ -29,11 +29,13 @@
#ifndef WINTERMUTE_SUBTITLECARD_H
#define WINTERMUTE_SUBTITLECARD_H
-#include "engines/wintermute/base/base.h"
+#include "common/str.h"
namespace Wintermute {
-class SubtitleCard : public BaseClass {
+class BaseGame;
+
+class SubtitleCard {
public:
SubtitleCard(BaseGame *inGame);
SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame);
@@ -41,6 +43,7 @@ public:
uint32 getStartFrame();
Common::String getText();
private:
+ BaseGame* _gameRef;
uint32 _endFrame;
uint32 _startFrame;
Common::String _text;
Commit: 856e281bf17a7adca88ded8bc93fd2e892bfa973
https://github.com/scummvm/scummvm/commit/856e281bf17a7adca88ded8bc93fd2e892bfa973
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:46+02:00
Commit Message:
WINTERMUTE: Remove useless constructor from SubtitleCard.
Changed paths:
engines/wintermute/video/subtitle_card.cpp
engines/wintermute/video/subtitle_card.h
diff --git a/engines/wintermute/video/subtitle_card.cpp b/engines/wintermute/video/subtitle_card.cpp
index c0ad8cc..a0a88b1 100644
--- a/engines/wintermute/video/subtitle_card.cpp
+++ b/engines/wintermute/video/subtitle_card.cpp
@@ -31,10 +31,6 @@
namespace Wintermute {
-SubtitleCard::SubtitleCard(BaseGame *inGame) {
- _gameRef = inGame;
- _startFrame = _endFrame = 0;
-}
SubtitleCard::SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame) {
// TODO: Fix expandStringByStringTable instead of this ugly hack
diff --git a/engines/wintermute/video/subtitle_card.h b/engines/wintermute/video/subtitle_card.h
index 94543d9..6f2e47f 100644
--- a/engines/wintermute/video/subtitle_card.h
+++ b/engines/wintermute/video/subtitle_card.h
@@ -37,7 +37,6 @@ class BaseGame;
class SubtitleCard {
public:
- SubtitleCard(BaseGame *inGame);
SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame);
uint32 getEndFrame();
uint32 getStartFrame();
Commit: 578edde66fc87eb1d4f630cbd1a9e402172440fa
https://github.com/scummvm/scummvm/commit/578edde66fc87eb1d4f630cbd1a9e402172440fa
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:46+02:00
Commit Message:
WINTERMUTE: Const'fy members of class SubtitleCard
Changed paths:
engines/wintermute/video/subtitle_card.cpp
engines/wintermute/video/subtitle_card.h
diff --git a/engines/wintermute/video/subtitle_card.cpp b/engines/wintermute/video/subtitle_card.cpp
index a0a88b1..fb2ac06 100644
--- a/engines/wintermute/video/subtitle_card.cpp
+++ b/engines/wintermute/video/subtitle_card.cpp
@@ -31,27 +31,28 @@
namespace Wintermute {
-
-SubtitleCard::SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame) {
+SubtitleCard::SubtitleCard(BaseGame *inGame,
+ const Common::String &text,
+ const uint &startFrame,
+ const uint &endFrame) : _gameRef(inGame),
+ _startFrame(startFrame),
+ _endFrame(endFrame) {
// TODO: Fix expandStringByStringTable instead of this ugly hack
char *tmp = new char[text.size()];
strcpy(tmp, text.c_str());
- _gameRef = inGame;
_gameRef->expandStringByStringTable(&tmp);
_text = Common::String(tmp);
- _startFrame = startFrame;
- _endFrame = endFrame;
}
-uint32 SubtitleCard::getStartFrame() {
+uint32 SubtitleCard::getStartFrame() const {
return _startFrame;
}
-uint32 SubtitleCard::getEndFrame() {
+uint32 SubtitleCard::getEndFrame() const {
return _endFrame;
}
-Common::String SubtitleCard::getText() {
+Common::String SubtitleCard::getText() const {
return _text;
}
diff --git a/engines/wintermute/video/subtitle_card.h b/engines/wintermute/video/subtitle_card.h
index 6f2e47f..7b372c7 100644
--- a/engines/wintermute/video/subtitle_card.h
+++ b/engines/wintermute/video/subtitle_card.h
@@ -38,13 +38,13 @@ class BaseGame;
class SubtitleCard {
public:
SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame);
- uint32 getEndFrame();
- uint32 getStartFrame();
- Common::String getText();
+ uint32 getEndFrame() const;
+ uint32 getStartFrame() const;
+ Common::String getText() const;
private:
- BaseGame* _gameRef;
- uint32 _endFrame;
- uint32 _startFrame;
+ const BaseGame* _gameRef;
+ const uint32 _endFrame;
+ const uint32 _startFrame;
Common::String _text;
};
Commit: f525514da576be7f5c645c38ff121b764378349e
https://github.com/scummvm/scummvm/commit/f525514da576be7f5c645c38ff121b764378349e
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:46+02:00
Commit Message:
WINTERMUTE: Use BaseGame->expandStringByStringTable(&Common::String) in SubtitleCard
Changed paths:
engines/wintermute/video/subtitle_card.cpp
diff --git a/engines/wintermute/video/subtitle_card.cpp b/engines/wintermute/video/subtitle_card.cpp
index fb2ac06..28fb654 100644
--- a/engines/wintermute/video/subtitle_card.cpp
+++ b/engines/wintermute/video/subtitle_card.cpp
@@ -31,17 +31,14 @@
namespace Wintermute {
-SubtitleCard::SubtitleCard(BaseGame *inGame,
- const Common::String &text,
- const uint &startFrame,
- const uint &endFrame) : _gameRef(inGame),
- _startFrame(startFrame),
+SubtitleCard::SubtitleCard(BaseGame *inGame,
+ const Common::String &text,
+ const uint &startFrame,
+ const uint &endFrame) : _gameRef(inGame),
+ _startFrame(startFrame),
_endFrame(endFrame) {
- // TODO: Fix expandStringByStringTable instead of this ugly hack
- char *tmp = new char[text.size()];
- strcpy(tmp, text.c_str());
- _gameRef->expandStringByStringTable(&tmp);
- _text = Common::String(tmp);
+ _text = text;
+ _gameRef->expandStringByStringTable(_text);
}
uint32 SubtitleCard::getStartFrame() const {
Commit: ebb48a1704b236d986539dbc716aae2d73921bb7
https://github.com/scummvm/scummvm/commit/ebb48a1704b236d986539dbc716aae2d73921bb7
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:47+02:00
Commit Message:
WINTERMUTE: s/delete array/delete[] array/
Changed paths:
engines/wintermute/base/base_string_table.cpp
diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp
index 8a9edbe..bcdd7cb 100644
--- a/engines/wintermute/base/base_string_table.cpp
+++ b/engines/wintermute/base/base_string_table.cpp
@@ -153,7 +153,7 @@ void BaseStringTable::expand(Common::String &str) const {
strcpy(tmp, str.c_str());
expand(&tmp);
str = tmp;
- delete tmp;
+ delete[] tmp;
}
Commit: c6930d9a64d6d61ece2f0b531ad93459d2730150
https://github.com/scummvm/scummvm/commit/c6930d9a64d6d61ece2f0b531ad93459d2730150
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:47+02:00
Commit Message:
WINTERMUTE: Use int32 for _lastSample in VideoSubtitler
We are thus making room for the sentinel == -1
Changed paths:
engines/wintermute/video/video_subtitler.cpp
engines/wintermute/video/video_subtitler.h
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index c57a70e..2117832 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -207,7 +207,7 @@ void VideoSubtitler::update(uint32 frame) {
return;
}
- if (frame != _lastSample) {
+ if ((int32)frame != _lastSample) {
/*
* If the frame count hasn't advanced the previous state still matches
* the current frame (obviously).
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index 32e4368..f2dcdf1 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -47,7 +47,7 @@ public:
void update(uint32 frame);
private:
Common::Array<SubtitleCard *> _subtitles;
- uint32 _lastSample;
+ int32 _lastSample;
};
} // End of namespace Wintermute
Commit: 2fc69d770c7f80b0f6027dd66a8cf4be401b2853
https://github.com/scummvm/scummvm/commit/2fc69d770c7f80b0f6027dd66a8cf4be401b2853
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:47+02:00
Commit Message:
WINTERMUTE: Initialize tokenSomething vars in VideoSubtitler
MSVC complains otherwise.
Changed paths:
engines/wintermute/video/video_subtitler.cpp
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 2117832..2bd728c 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -96,9 +96,9 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
int start, end;
bool inToken;
- char *tokenStart;
- int tokenLength;
- int tokenPos;
+ char *tokenStart = 0;
+ int tokenLength = 0;
+ int tokenPos = 0;
int pos = 0;
int lineLength = 0;
Commit: d5ed8c29f1f97519bd72aec8585edf04ac46181f
https://github.com/scummvm/scummvm/commit/d5ed8c29f1f97519bd72aec8585edf04ac46181f
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:47+02:00
Commit Message:
WINTERMUTE: Turn _subtitles into Common::Array<SubtitleCard> in VideoSubtitler
This necessarily loses const in SubtitleCard's attributes
Changed paths:
engines/wintermute/video/subtitle_card.cpp
engines/wintermute/video/subtitle_card.h
engines/wintermute/video/video_subtitler.cpp
engines/wintermute/video/video_subtitler.h
diff --git a/engines/wintermute/video/subtitle_card.cpp b/engines/wintermute/video/subtitle_card.cpp
index 28fb654..5d88250 100644
--- a/engines/wintermute/video/subtitle_card.cpp
+++ b/engines/wintermute/video/subtitle_card.cpp
@@ -32,11 +32,11 @@
namespace Wintermute {
SubtitleCard::SubtitleCard(BaseGame *inGame,
- const Common::String &text,
- const uint &startFrame,
- const uint &endFrame) : _gameRef(inGame),
- _startFrame(startFrame),
- _endFrame(endFrame) {
+ const Common::String &text,
+ const uint &startFrame,
+ const uint &endFrame) : _gameRef(inGame),
+ _startFrame(startFrame),
+ _endFrame(endFrame) {
_text = text;
_gameRef->expandStringByStringTable(_text);
}
diff --git a/engines/wintermute/video/subtitle_card.h b/engines/wintermute/video/subtitle_card.h
index 7b372c7..629df77 100644
--- a/engines/wintermute/video/subtitle_card.h
+++ b/engines/wintermute/video/subtitle_card.h
@@ -42,9 +42,9 @@ public:
uint32 getStartFrame() const;
Common::String getText() const;
private:
- const BaseGame* _gameRef;
- const uint32 _endFrame;
- const uint32 _startFrame;
+ BaseGame *_gameRef;
+ uint32 _endFrame;
+ uint32 _startFrame;
Common::String _text;
};
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 2bd728c..2123991 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -42,10 +42,6 @@ VideoSubtitler::VideoSubtitler(BaseGame *inGame): BaseClass(inGame) {
}
VideoSubtitler::~VideoSubtitler(void) {
- for (uint i = 0; i < _subtitles.size(); i++) {
- delete _subtitles[i];
- }
-
_subtitles.clear();
}
@@ -54,10 +50,6 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
return false;
}
- for (uint i = 0; i < _subtitles.size(); i++) {
- delete _subtitles[i];
- }
-
_subtitles.clear();
_lastSample = -1;
@@ -166,7 +158,7 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
}
if (start != -1 && text.size() > 0 && (start != 1 || end != 1)) {
- _subtitles.push_back(new SubtitleCard(_gameRef, text, start, end));
+ _subtitles.push_back(SubtitleCard(_gameRef, text, start, end));
}
pos += lineLength + 1;
@@ -190,14 +182,15 @@ void VideoSubtitler::display() {
}
int textHeight = font->getTextHeight(
- (const byte *)_subtitles[_currentSubtitle]->getText().c_str(),
+ (const byte *)_subtitles[_currentSubtitle].getText().c_str(),
_gameRef->_renderer->getWidth());
- font->drawText((const byte *)_subtitles[_currentSubtitle]->getText().c_str(),
- 0,
- (_gameRef->_renderer->getHeight() - textHeight - 5),
- (_gameRef->_renderer->getWidth()),
- TAL_CENTER);
+ font->drawText(
+ (const byte *)_subtitles[_currentSubtitle].getText().c_str(),
+ 0,
+ (_gameRef->_renderer->getHeight() - textHeight - 5),
+ (_gameRef->_renderer->getWidth()),
+ TAL_CENTER);
}
}
@@ -218,11 +211,11 @@ void VideoSubtitler::update(uint32 frame) {
_showSubtitle = false;
- bool overdue = (frame > _subtitles[_currentSubtitle]->getEndFrame());
+ bool overdue = (frame > _subtitles[_currentSubtitle].getEndFrame());
bool hasNext = (_currentSubtitle + 1 < _subtitles.size());
bool nextStarted = false;
if (hasNext) {
- nextStarted = (_subtitles[_currentSubtitle + 1]->getStartFrame() <= frame);
+ nextStarted = (_subtitles[_currentSubtitle + 1].getStartFrame() <= frame);
}
while (_currentSubtitle < _subtitles.size() &&
@@ -238,22 +231,22 @@ void VideoSubtitler::update(uint32 frame) {
_currentSubtitle++;
- overdue = (frame > _subtitles[_currentSubtitle]->getEndFrame());
+ overdue = (frame > _subtitles[_currentSubtitle].getEndFrame());
hasNext = (_currentSubtitle + 1 < _subtitles.size());
if (hasNext) {
- nextStarted = (_subtitles[_currentSubtitle + 1]->getStartFrame() <= frame);
+ nextStarted = (_subtitles[_currentSubtitle + 1].getStartFrame() <= frame);
} else {
nextStarted = false;
}
}
- bool currentValid = (_subtitles[_currentSubtitle]->getEndFrame() != 0);
+ bool currentValid = (_subtitles[_currentSubtitle].getEndFrame() != 0);
/*
* No idea why we do this check, carried over from Mnemonic's code.
* Possibly a workaround for buggy subtitles or some kind of sentinel? :-\
*/
- bool currentStarted = frame >= _subtitles[_currentSubtitle]->getStartFrame();
+ bool currentStarted = frame >= _subtitles[_currentSubtitle].getStartFrame();
if (currentStarted && !overdue && currentValid) {
_showSubtitle = true;
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index f2dcdf1..c1730c8 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -46,7 +46,7 @@ public:
void display();
void update(uint32 frame);
private:
- Common::Array<SubtitleCard *> _subtitles;
+ Common::Array<SubtitleCard> _subtitles;
int32 _lastSample;
};
Commit: 3cef639f911264547b08428110e33a3d5a595fee
https://github.com/scummvm/scummvm/commit/3cef639f911264547b08428110e33a3d5a595fee
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:47+02:00
Commit Message:
WINTERMUTE: new char[str.size()+1] in BaseStringTable::expand
This makes room for the EOS char.
Changed paths:
engines/wintermute/base/base_string_table.cpp
diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp
index bcdd7cb..4c750eb 100644
--- a/engines/wintermute/base/base_string_table.cpp
+++ b/engines/wintermute/base/base_string_table.cpp
@@ -149,7 +149,7 @@ void BaseStringTable::expand(char **str) const {
//////////////////////////////////////////////////////////////////////////
void BaseStringTable::expand(Common::String &str) const {
- char *tmp = new char[str.size()];
+ char *tmp = new char[str.size()+1];
strcpy(tmp, str.c_str());
expand(&tmp);
str = tmp;
Commit: e9b722278e5c893bd488bdb7d430598ba711d5ee
https://github.com/scummvm/scummvm/commit/e9b722278e5c893bd488bdb7d430598ba711d5ee
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:47+02:00
Commit Message:
WINTERMUTE: Declare and init size in one place in VideoSubtitler
Changed paths:
engines/wintermute/video/video_subtitler.cpp
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 2123991..ed4677f 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -74,16 +74,15 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
newFile = PathUtil::combine(path, name + ext);
}
- int size;
-
Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(newFile, true, false);
if (file == nullptr) {
return false; // no subtitles
}
- size = file->size();
+ int size = file->size();
char *buffer = new char[size];
+
file->read(buffer, size);
int start, end;
Commit: a4b9bc58775d6a0f2e6fbce8ac2eff872892830e
https://github.com/scummvm/scummvm/commit/a4b9bc58775d6a0f2e6fbce8ac2eff872892830e
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:47+02:00
Commit Message:
WINTERMUTE: Rename a bunch of variabiles in loadSubtitles
Changed paths:
engines/wintermute/video/video_subtitler.cpp
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index ed4677f..f540fdd 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -80,10 +80,10 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
return false; // no subtitles
}
- int size = file->size();
- char *buffer = new char[size];
+ int fileSize = file->size();
+ char *buffer = new char[fileSize];
- file->read(buffer, size);
+ file->read(buffer, fileSize);
int start, end;
bool inToken;
@@ -93,42 +93,42 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
int pos = 0;
int lineLength = 0;
-
- while (pos < size) {
+ while (pos < fileSize) {
start = end = -1;
inToken = false;
tokenPos = -1;
lineLength = 0;
- while (pos + lineLength < size &&
- buffer[pos + lineLength] != '\n' &&
- buffer[pos + lineLength] != '\0') {
+ while (pos + lineLength < fileSize &&
+ buffer[pos + lineLength] != '\n' &&
+ buffer[pos + lineLength] != '\0') {
+ // Measure the line until we hit EOL, EOS or just hit the boundary
lineLength++;
}
int realLength;
- if (pos + lineLength >= size) {
+ if (pos + lineLength >= fileSize) {
realLength = lineLength - 0;
} else {
realLength = lineLength - 1;
}
- Common::String text;
- char *line = (char *)&buffer[pos];
+ Common::String cardText;
+ char *fileLine = (char *)&buffer[pos];
for (int i = 0; i < realLength; i++) {
- if (line[i] == '{') {
+ if (fileLine[i] == '{') {
if (!inToken) {
inToken = true;
- tokenStart = line + i + 1;
+ tokenStart = fileLine + i + 1;
tokenLength = 0;
tokenPos++;
} else {
tokenLength++;
}
- } else if (line[i] == '}') {
+ } else if (fileLine[i] == '}') {
if (inToken) {
inToken = false;
char *token = new char[tokenLength + 1];
@@ -141,23 +141,23 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
}
delete[] token;
} else {
- text += line[i];
+ cardText += fileLine[i];
}
} else {
if (inToken) {
tokenLength++;
} else {
- if (line[i] == '|') {
- text += '\n';
+ if (fileLine[i] == '|') {
+ cardText += '\n';
} else {
- text += line[i];
+ cardText += fileLine[i];
}
}
}
}
- if (start != -1 && text.size() > 0 && (start != 1 || end != 1)) {
- _subtitles.push_back(SubtitleCard(_gameRef, text, start, end));
+ if (start != -1 && cardText.size() > 0 && (start != 1 || end != 1)){
+ _subtitles.push_back(SubtitleCard(_gameRef, cardText, start, end));
}
pos += lineLength + 1;
Commit: e12f30ed030fc719b56e2be8418707f258af05d5
https://github.com/scummvm/scummvm/commit/e12f30ed030fc719b56e2be8418707f258af05d5
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-10-15T21:36:47+02:00
Commit Message:
WINTERMUTE: Add a bunch of comments in loadSubtitles
Changed paths:
engines/wintermute/video/video_subtitler.cpp
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index f540fdd..52bae27 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -93,6 +93,10 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
int pos = 0;
int lineLength = 0;
+ /* This is where we parse .sub files.
+ * Subtitles cards are in the form
+ * {StartFrame}{EndFrame} FirstLine | SecondLine \n
+ */
while (pos < fileSize) {
start = end = -1;
inToken = false;
@@ -112,6 +116,7 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
if (pos + lineLength >= fileSize) {
realLength = lineLength - 0;
} else {
+ // If we got here the above loop exited after hitting "\0" "\n"
realLength = lineLength - 1;
}
@@ -121,26 +126,32 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
for (int i = 0; i < realLength; i++) {
if (fileLine[i] == '{') {
if (!inToken) {
+ // We've hit the start of a Start/EndFrame token
inToken = true;
tokenStart = fileLine + i + 1;
tokenLength = 0;
tokenPos++;
} else {
+ // Actually, we were already inside an (invalid) one.
tokenLength++;
}
} else if (fileLine[i] == '}') {
if (inToken) {
+ // we were /inside/ a {.*} token, so this is the end of the block
inToken = false;
char *token = new char[tokenLength + 1];
strncpy(token, tokenStart, tokenLength);
token[tokenLength] = '\0';
if (tokenPos == 0) {
+ // Was this StartFrame...
start = atoi(token);
} else if (tokenPos == 1) {
+ // Or the EndFrame?
end = atoi(token);
}
delete[] token;
} else {
+ // This char is part of the plain text, just append it
cardText += fileLine[i];
}
} else {
@@ -148,8 +159,10 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
tokenLength++;
} else {
if (fileLine[i] == '|') {
+ // The pipe character signals a linebreak in the text
cardText += '\n';
} else {
+ // This char is part of the plain text, just append it
cardText += fileLine[i];
}
}
@@ -157,6 +170,7 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
}
if (start != -1 && cardText.size() > 0 && (start != 1 || end != 1)){
+ // Add a subtitlecard based on the line we have just parsed
_subtitles.push_back(SubtitleCard(_gameRef, cardText, start, end));
}
Commit: 0a2c1a809f1335f2d259fa7e3070405232687b00
https://github.com/scummvm/scummvm/commit/0a2c1a809f1335f2d259fa7e3070405232687b00
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-11-05T19:07:03+01:00
Commit Message:
WINTERMUTE: Keep _[show|current]Subtitle private in video_subtitler.h
Changed paths:
engines/wintermute/video/video_subtitler.h
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index c1730c8..f97461c 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -39,15 +39,14 @@ class VideoSubtitler :
public:
VideoSubtitler(BaseGame *inGame);
virtual ~VideoSubtitler(void);
-
- bool _showSubtitle;
- uint32 _currentSubtitle;
bool loadSubtitles(const Common::String &filename, const Common::String &subtitleFile);
void display();
void update(uint32 frame);
private:
Common::Array<SubtitleCard> _subtitles;
int32 _lastSample;
+ bool _showSubtitle;
+ uint32 _currentSubtitle;
};
} // End of namespace Wintermute
Commit: 215ac157e6f694327d5de0ec46a6fc1eabbf4719
https://github.com/scummvm/scummvm/commit/215ac157e6f694327d5de0ec46a6fc1eabbf4719
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-11-05T19:28:42+01:00
Commit Message:
WINTERMUTE: Declare vars inside appropriate block in loadSubtitles
Changed paths:
engines/wintermute/video/video_subtitler.cpp
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 52bae27..e3127d1 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -85,7 +85,6 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
file->read(buffer, fileSize);
- int start, end;
bool inToken;
char *tokenStart = 0;
int tokenLength = 0;
@@ -98,6 +97,8 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
* {StartFrame}{EndFrame} FirstLine | SecondLine \n
*/
while (pos < fileSize) {
+ int start, end;
+
start = end = -1;
inToken = false;
tokenPos = -1;
Commit: 2f082f6e438598f9093c92482bd6f75af264d785
https://github.com/scummvm/scummvm/commit/2f082f6e438598f9093c92482bd6f75af264d785
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-11-05T19:31:10+01:00
Commit Message:
WINTERMUTE: Remove redundant explicit call to Common::String constructor
Changed paths:
engines/wintermute/video/video_subtitler.cpp
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index e3127d1..86f8f9b 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -66,7 +66,7 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
* /some/path/movie.sub
*/
if (subtitleFile.size() != 0) {
- newFile = Common::String(subtitleFile);
+ newFile = subtitleFile;
} else {
Common::String path = PathUtil::getDirectoryName(filename);
Common::String name = PathUtil::getFileNameWithoutExtension(filename);
Commit: 998da18c05c159f6dffe2b25d0afe23021c8ec38
https://github.com/scummvm/scummvm/commit/998da18c05c159f6dffe2b25d0afe23021c8ec38
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-11-05T19:42:17+01:00
Commit Message:
WINTERMUTE: Move var declarations inside loop in loadSubtitles
Changed paths:
engines/wintermute/video/video_subtitler.cpp
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index 86f8f9b..95d9385 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -85,25 +85,20 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common:
file->read(buffer, fileSize);
- bool inToken;
- char *tokenStart = 0;
- int tokenLength = 0;
- int tokenPos = 0;
-
- int pos = 0;
- int lineLength = 0;
/* This is where we parse .sub files.
* Subtitles cards are in the form
* {StartFrame}{EndFrame} FirstLine | SecondLine \n
*/
- while (pos < fileSize) {
- int start, end;
-
- start = end = -1;
- inToken = false;
- tokenPos = -1;
+ int pos = 0;
- lineLength = 0;
+ while (pos < fileSize) {
+ char *tokenStart = 0;
+ int tokenLength = 0;
+ int tokenPos = -1;
+ int lineLength = 0;
+ int start = -1;
+ int end = -1;
+ bool inToken = false;
while (pos + lineLength < fileSize &&
buffer[pos + lineLength] != '\n' &&
Commit: 9787fc5768fdc7338433fa5bcbc606f7d8ffe1d2
https://github.com/scummvm/scummvm/commit/9787fc5768fdc7338433fa5bcbc606f7d8ffe1d2
Author: Tobia Tesan (tobia.tesan at gmail.com)
Date: 2014-11-05T19:45:39+01:00
Commit Message:
WINTERMUTE: Fix formatting in video_subtitler.h
Changed paths:
engines/wintermute/video/video_subtitler.h
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index f97461c..94f2290 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -34,8 +34,7 @@
namespace Wintermute {
-class VideoSubtitler :
- public BaseClass {
+class VideoSubtitler : public BaseClass {
public:
VideoSubtitler(BaseGame *inGame);
virtual ~VideoSubtitler(void);
Commit: 784241c17b57c31af0722d3d98d89314c40743cd
https://github.com/scummvm/scummvm/commit/784241c17b57c31af0722d3d98d89314c40743cd
Author: Einar Johan Trøan Sømåen (einarjohants at gmail.com)
Date: 2014-11-05T20:22:34+01:00
Commit Message:
Merge pull request #437 from tobiatesan/wme_subtitles
WME Subtitles
Changed paths:
A engines/wintermute/video/subtitle_card.cpp
A engines/wintermute/video/subtitle_card.h
A engines/wintermute/video/video_subtitler.cpp
A engines/wintermute/video/video_subtitler.h
engines/wintermute/base/base_game.cpp
engines/wintermute/base/base_game.h
engines/wintermute/base/base_game_settings.cpp
engines/wintermute/base/base_game_settings.h
engines/wintermute/base/base_string_table.cpp
engines/wintermute/base/base_string_table.h
engines/wintermute/module.mk
engines/wintermute/video/video_theora_player.cpp
engines/wintermute/video/video_theora_player.h
More information about the Scummvm-git-logs
mailing list