[Scummvm-cvs-logs] scummvm master -> dab4ce1f7bc5c72f9f90bc0de8553e4b4e945624

bluegr bluegr at gmail.com
Wed Dec 3 01:39:10 CET 2014


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
dab4ce1f7b ZVISION: Move the subtitle class


Commit: dab4ce1f7bc5c72f9f90bc0de8553e4b4e945624
    https://github.com/scummvm/scummvm/commit/dab4ce1f7bc5c72f9f90bc0de8553e4b4e945624
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-12-03T02:38:06+02:00

Commit Message:
ZVISION: Move the subtitle class

Changed paths:
  A engines/zvision/graphics/subtitles.cpp
  A engines/zvision/graphics/subtitles.h
  R engines/zvision/subtitles/subtitles.cpp
  R engines/zvision/subtitles/subtitles.h
    engines/zvision/module.mk
    engines/zvision/scripting/sidefx/music_node.h
    engines/zvision/scripting/sidefx/syncsound_node.h
    engines/zvision/video/video.cpp



diff --git a/engines/zvision/graphics/subtitles.cpp b/engines/zvision/graphics/subtitles.cpp
new file mode 100644
index 0000000..7847215
--- /dev/null
+++ b/engines/zvision/graphics/subtitles.cpp
@@ -0,0 +1,108 @@
+/* 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.
+ *
+ */
+
+#include "zvision/graphics/render_manager.h"
+#include "zvision/graphics/subtitles.h"
+#include "zvision/core/search_manager.h"
+#include "zvision/text/text.h"
+
+namespace ZVision {
+
+Subtitle::Subtitle(ZVision *engine, const Common::String &subname) :
+	_engine(engine),
+	_areaId(-1),
+	_subId(-1) {
+	Common::File file;
+	if (_engine->getSearchManager()->openFile(file, subname)) {
+		while (!file.eos()) {
+			Common::String str = file.readLine();
+			if (str.lastChar() == '~')
+				str.deleteLastChar();
+
+			if (str.matchString("*Initialization*", true)) {
+				// Not used
+			} else if (str.matchString("*Rectangle*", true)) {
+				int32 x1, y1, x2, y2;
+				sscanf(str.c_str(), "%*[^:]:%d %d %d %d", &x1, &y1, &x2, &y2);
+				Common::Rect rct = Common::Rect(x1, y1, x2, y2);
+				_areaId = _engine->getRenderManager()->createSubArea(rct);
+			} else if (str.matchString("*TextFile*", true)) {
+				char filename[64];
+				sscanf(str.c_str(), "%*[^:]:%s", filename);
+				Common::File txt;
+				if (_engine->getSearchManager()->openFile(txt, filename)) {
+					while (!txt.eos()) {
+						Common::String txtline = readWideLine(txt);
+						sub curSubtitle;
+						curSubtitle.start = -1;
+						curSubtitle.stop = -1;
+						curSubtitle.subStr = txtline;
+
+						_subs.push_back(curSubtitle);
+					}
+					txt.close();
+				}
+			} else {
+				int32 st;
+				int32 en;
+				int32 sb;
+				if (sscanf(str.c_str(), "%*[^:]:(%d,%d)=%d", &st, &en, &sb) == 3) {
+					if (sb <= (int32)_subs.size()) {
+						_subs[sb].start = st;
+						_subs[sb].stop = en;
+					}
+				}
+			}
+		}
+	}
+}
+
+Subtitle::~Subtitle() {
+	if (_areaId != -1)
+		_engine->getRenderManager()->deleteSubArea(_areaId);
+
+	_subs.clear();
+}
+
+void Subtitle::process(int32 time) {
+	int16 j = -1;
+	for (uint16 i = 0; i < _subs.size(); i++)
+		if (time >= _subs[i].start && time <= _subs[i].stop) {
+			j = i;
+			break;
+		}
+
+	if (j == -1 && _subId != -1) {
+		if (_areaId != -1)
+			_engine->getRenderManager()->updateSubArea(_areaId, "");
+		_subId = -1;
+	}
+
+	if (j != -1 && j != _subId) {
+		if (_subs[j].subStr.size())
+			if (_areaId != -1)
+				_engine->getRenderManager()->updateSubArea(_areaId, _subs[j].subStr);
+		_subId = j;
+	}
+}
+
+} // End of namespace ZVision
diff --git a/engines/zvision/graphics/subtitles.h b/engines/zvision/graphics/subtitles.h
new file mode 100644
index 0000000..c3da658
--- /dev/null
+++ b/engines/zvision/graphics/subtitles.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.
+ *
+ */
+
+#ifndef ZVISION_SUBTITLES_H
+#define ZVISION_SUBTITLES_H
+
+#include "zvision/zvision.h"
+
+namespace ZVision {
+
+class ZVision;
+
+class Subtitle {
+public:
+	Subtitle(ZVision *engine, const Common::String &subname);
+	~Subtitle();
+
+	void process(int32 time);
+private:
+	ZVision *_engine;
+	int32 _areaId;
+	int16 _subId;
+
+	struct sub {
+		int start;
+		int stop;
+		Common::String subStr;
+	};
+
+	Common::Array<sub> _subs;
+};
+
+}
+
+#endif
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index e2beeb5..045eb52 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -17,6 +17,7 @@ MODULE_OBJS := \
 	graphics/effects/wave.o \
 	graphics/render_manager.o \
 	graphics/render_table.o \
+	graphics/subtitles.o \
 	graphics/truetype_font.o \
 	scripting/actions.o \
 	scripting/control.o \
@@ -41,7 +42,6 @@ MODULE_OBJS := \
 	scripting/sidefx/timer_node.o \
 	scripting/sidefx/ttytext_node.o \
 	sound/zork_raw.o \
-	subtitles/subtitles.o \
 	text/string_manager.o \
 	text/text.o \
 	utility/clock.o \
diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h
index 954e2f4..c89345f 100644
--- a/engines/zvision/scripting/sidefx/music_node.h
+++ b/engines/zvision/scripting/sidefx/music_node.h
@@ -25,7 +25,7 @@
 
 #include "audio/mixer.h"
 #include "zvision/scripting/sidefx.h"
-#include "zvision/subtitles/subtitles.h"
+#include "zvision/graphics/subtitles.h"
 
 namespace Common {
 class String;
diff --git a/engines/zvision/scripting/sidefx/syncsound_node.h b/engines/zvision/scripting/sidefx/syncsound_node.h
index c16ffeb..7cd02a8 100644
--- a/engines/zvision/scripting/sidefx/syncsound_node.h
+++ b/engines/zvision/scripting/sidefx/syncsound_node.h
@@ -25,7 +25,7 @@
 
 #include "audio/mixer.h"
 #include "zvision/scripting/sidefx.h"
-#include "zvision/subtitles/subtitles.h"
+#include "zvision/graphics/subtitles.h"
 
 namespace Common {
 class String;
diff --git a/engines/zvision/subtitles/subtitles.cpp b/engines/zvision/subtitles/subtitles.cpp
deleted file mode 100644
index d36eb24..0000000
--- a/engines/zvision/subtitles/subtitles.cpp
+++ /dev/null
@@ -1,108 +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.
- *
- */
-
-#include "zvision/subtitles/subtitles.h"
-#include "zvision/graphics/render_manager.h"
-#include "zvision/core/search_manager.h"
-#include "zvision/text/text.h"
-
-namespace ZVision {
-
-Subtitle::Subtitle(ZVision *engine, const Common::String &subname) :
-	_engine(engine),
-	_areaId(-1),
-	_subId(-1) {
-	Common::File file;
-	if (_engine->getSearchManager()->openFile(file, subname)) {
-		while (!file.eos()) {
-			Common::String str = file.readLine();
-			if (str.lastChar() == '~')
-				str.deleteLastChar();
-
-			if (str.matchString("*Initialization*", true)) {
-				// Not used
-			} else if (str.matchString("*Rectangle*", true)) {
-				int32 x1, y1, x2, y2;
-				sscanf(str.c_str(), "%*[^:]:%d %d %d %d", &x1, &y1, &x2, &y2);
-				Common::Rect rct = Common::Rect(x1, y1, x2, y2);
-				_areaId = _engine->getRenderManager()->createSubArea(rct);
-			} else if (str.matchString("*TextFile*", true)) {
-				char filename[64];
-				sscanf(str.c_str(), "%*[^:]:%s", filename);
-				Common::File txt;
-				if (_engine->getSearchManager()->openFile(txt, filename)) {
-					while (!txt.eos()) {
-						Common::String txtline = readWideLine(txt);
-						sub curSubtitle;
-						curSubtitle.start = -1;
-						curSubtitle.stop = -1;
-						curSubtitle.subStr = txtline;
-
-						_subs.push_back(curSubtitle);
-					}
-					txt.close();
-				}
-			} else {
-				int32 st;
-				int32 en;
-				int32 sb;
-				if (sscanf(str.c_str(), "%*[^:]:(%d,%d)=%d", &st, &en, &sb) == 3) {
-					if (sb <= (int32)_subs.size()) {
-						_subs[sb].start = st;
-						_subs[sb].stop = en;
-					}
-				}
-			}
-		}
-	}
-}
-
-Subtitle::~Subtitle() {
-	if (_areaId != -1)
-		_engine->getRenderManager()->deleteSubArea(_areaId);
-
-	_subs.clear();
-}
-
-void Subtitle::process(int32 time) {
-	int16 j = -1;
-	for (uint16 i = 0; i < _subs.size(); i++)
-		if (time >= _subs[i].start && time <= _subs[i].stop) {
-			j = i;
-			break;
-		}
-
-	if (j == -1 && _subId != -1) {
-		if (_areaId != -1)
-			_engine->getRenderManager()->updateSubArea(_areaId, "");
-		_subId = -1;
-	}
-
-	if (j != -1 && j != _subId) {
-		if (_subs[j].subStr.size())
-			if (_areaId != -1)
-				_engine->getRenderManager()->updateSubArea(_areaId, _subs[j].subStr);
-		_subId = j;
-	}
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/subtitles/subtitles.h b/engines/zvision/subtitles/subtitles.h
deleted file mode 100644
index c3da658..0000000
--- a/engines/zvision/subtitles/subtitles.h
+++ /dev/null
@@ -1,54 +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.
- *
- */
-
-#ifndef ZVISION_SUBTITLES_H
-#define ZVISION_SUBTITLES_H
-
-#include "zvision/zvision.h"
-
-namespace ZVision {
-
-class ZVision;
-
-class Subtitle {
-public:
-	Subtitle(ZVision *engine, const Common::String &subname);
-	~Subtitle();
-
-	void process(int32 time);
-private:
-	ZVision *_engine;
-	int32 _areaId;
-	int16 _subId;
-
-	struct sub {
-		int start;
-		int stop;
-		Common::String subStr;
-	};
-
-	Common::Array<sub> _subs;
-};
-
-}
-
-#endif
diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp
index 25125ec..36b5f9b 100644
--- a/engines/zvision/video/video.cpp
+++ b/engines/zvision/video/video.cpp
@@ -29,7 +29,7 @@
 #include "zvision/zvision.h"
 #include "zvision/utility/clock.h"
 #include "zvision/graphics/render_manager.h"
-#include "zvision/subtitles/subtitles.h"
+#include "zvision/graphics/subtitles.h"
 
 namespace ZVision {
 






More information about the Scummvm-git-logs mailing list