/* 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; im_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?0:1); char* Text = new char[RealLength+1]; char* line = (char*)&Buffer[Pos]; for(int i=0; i0 && (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_CurrentSubtitlem_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; } }