/* * Copyright (C) 2004-2005 Vadim Berezniker * http://www.kryptolus.com * * 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, 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 GNU Make; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * http://www.gnu.org/copyleft/gpl.html * */ #include "stdafx.h" #include "common.h" #include "sabbu.h" #include "gui_export.h" #include "gui_export_encore.h" #include "krySubWriter.h" #include "krySubWriterAdobeEncore.h" krySubWriterAdobeEncore::krySubWriterAdobeEncore(kryScript *script, char *filename, struct export_settings_encore *settings) : krySubWriter(script, filename), m_settings(settings) { } char *krySubWriterAdobeEncore::WriteScript() { if(!this->Open()) return strerror(errno); this->WriteHeaders(); int filters = kryEvent::EVENT_DIALOG; if(m_settings->comments) filters |= kryEvent::EVENT_COMMENT_DIALOG; this->SetEventFilter(filters); char *buffer; int index = 1; while(kryEventDetailed *event = this->GetNextEvent()) { buffer = kry_strdup_printf(KRY_LOC "%d ", index); this->WriteString(buffer); struct time_parts parts; char *format; if(m_settings->fps == ENCORE_FPS_PAL) format = "%02d:%02d:%02d:%02d "; else format = "%02d;%02d;%02d;%02d "; double fps = (m_settings->fps == ENCORE_FPS_PAL ? 25 : 29.97); time_mili_to_parts(event->GetStart(), &parts); char *time = kry_strdup_printf(KRY_LOC format, parts.hours, parts.minutes, parts.seconds, time_mili_to_frames(parts.mili, fps)); this->WriteString(time); kry_free(time); time_mili_to_parts(event->GetEnd(), &parts); time = kry_strdup_printf(KRY_LOC format, parts.hours, parts.minutes, parts.seconds, time_mili_to_frames(parts.mili, fps)); this->WriteString(time); kry_free(time); buffer = event->GetText(); if(buffer) this->WriteString(buffer); this->WriteString("\n"); index++; } return NULL; }