//////////////
// Write file
void ASSSubtitleFormat::WriteFile(wxString _filename,wxString encoding) {
    // Open file
    TextFileWriter file(_filename,encoding);
    bool ssa = _filename.Right(4).Lower() == _T(".ssa");

    // Write lines
    using std::list;
    AssEntry *entry;
    for (list<AssEntry*>::iterator cur=Line->begin(); cur!=Line->end();) {
        // Get entry
        entry = *cur;

        // Only add a line break if there is a next line
        cur++;
        bool lineBreak = cur != Line->end();

        // Write line
        if (ssa) file.WriteLineToFile(entry->GetSSAText(),lineBreak);
        else file.WriteLineToFile(entry->GetEntryData(),lineBreak);
    }
}
///////////
// Process
void AssTransformCleanInfoFilter::ProcessSubs(AssFile *subs, wxWindow *export_dialog) {
	using std::list;
	AssEntry *curEntry;
	entryIter cur, next = subs->Line.begin();
	while (next != subs->Line.end()) {
		cur = next++;

		curEntry = *cur;
		if (curEntry->group != _T("[Script Info]")) {
			continue;
		}
		if (curEntry->GetEntryData().IsEmpty()) {
			continue;
		}
		if (curEntry->GetEntryData() == _T("[Script Info]")) {
			continue;
		}
		if (curEntry->GetEntryData().Left(1) == _T(";")) {
			continue;
		}

		wxString field = curEntry->GetEntryData().Left(curEntry->GetEntryData().Find(_T(':')));
		if (field != _T("ScriptType") &&
			field != _T("Collisions") &&
			field != _T("PlayResX") &&
			field != _T("PlayResY") &&
			field != _T("WrapStyle")) {
			delete curEntry;
			subs->Line.erase(cur);
		}
	}
}
Exemplo n.º 3
0
void AssTransformCleanInfoFilter::ProcessSubs(AssFile *subs, wxWindow *) {
	using std::list;
	AssEntry *curEntry;
	entryIter cur, next = subs->Line.begin();
	while (next != subs->Line.end()) {
		cur = next++;

		curEntry = *cur;
		if (curEntry->group != "[Script Info]") {
			continue;
		}
		if (curEntry->GetEntryData().empty()) {
			continue;
		}
		if (curEntry->GetEntryData() == "[Script Info]") {
			continue;
		}
		if (curEntry->GetEntryData().Left(1) == ";") {
			continue;
		}

		wxString field = curEntry->GetEntryData().Left(curEntry->GetEntryData().Find(_T(':'))).Lower();
		if (field != "scripttype" &&
			field != "collisions" &&
			field != "playresx" &&
			field != "playresy" &&
			field != "wrapstyle" &&
			field != "scaledborderandshadow") {
			delete curEntry;
			subs->Line.erase(cur);
		}
	}
}