Eliminate all unnecessary uses of L and _T

Originally committed to SVN as r5611.
This commit is contained in:
Thomas Goyne 2011-09-28 19:43:11 +00:00
parent 7250b89cbd
commit d990bbbb99
115 changed files with 1426 additions and 1434 deletions

View file

@ -82,13 +82,13 @@ void AegisubLocale::Init(int language) {
locale = new wxLocale(language);
#ifdef __WINDOWS__
locale->AddCatalogLookupPathPrefix(StandardPaths::DecodePath(_T("?data/locale/")));
locale->AddCatalog(_T("aegisub"));
locale->AddCatalogLookupPathPrefix(StandardPaths::DecodePath("?data/locale/"));
locale->AddCatalog("aegisub");
#else
locale->AddCatalog(_T(GETTEXT_PACKAGE));
locale->AddCatalog(GETTEXT_PACKAGE);
#endif
locale->AddCatalog(_T("wxstd"));
locale->AddCatalog("wxstd");
setlocale(LC_NUMERIC, "C");
setlocale(LC_CTYPE, "C");
}
@ -124,7 +124,7 @@ int AegisubLocale::PickLanguage() {
if (langs.Count() == 0) return -1;
// Popup
int picked = wxGetSingleChoiceIndex(_T("Please choose a language:"),_T("Language"),langNames,NULL,-1,-1,true,300,400);
int picked = wxGetSingleChoiceIndex("Please choose a language:","Language",langNames,NULL,-1,-1,true,300,400);
if (picked == -1) return -1;
return langs[picked];
}
@ -140,15 +140,15 @@ wxArrayInt AegisubLocale::GetAvailableLanguages() {
wxString temp1;
// Open directory
wxString folder = StandardPaths::DecodePath(_T("?data/locale/"));
wxString folder = StandardPaths::DecodePath("?data/locale/");
wxDir dir;
if (!dir.Exists(folder)) return final;
if (!dir.Open(folder)) return final;
// Enumerate folders
for (bool cont = dir.GetFirst(&temp1,_T(""),wxDIR_DIRS);cont;cont = dir.GetNext(&temp1)) {
for (bool cont = dir.GetFirst(&temp1,"",wxDIR_DIRS);cont;cont = dir.GetNext(&temp1)) {
// Check if .so exists inside folder
wxFileName file(folder + temp1 + _T("/aegisub.mo"));
wxFileName file(folder + temp1 + "/aegisub.mo");
if (file.FileExists()) {
const wxLanguageInfo *lang = wxLocale::FindLanguageInfo(temp1);
if (lang) {
@ -159,33 +159,33 @@ wxArrayInt AegisubLocale::GetAvailableLanguages() {
#else
const wchar_t* langs[] = {
_T("ca"),
_T("cs"),
_T("da"),
_T("de"),
_T("el"),
_T("es"),
_T("fi"),
_T("fr_FR"),
_T("hu"),
_T("it"),
_T("ja"),
_T("ko"),
_T("pt_BR"),
_T("ru"),
_T("vi"),
_T("zh_CN"),
_T("zh_TW")
const char* langs[] = {
"ca",
"cs",
"da",
"de",
"el",
"es",
"fi",
"fr_FR",
"hu",
"it",
"ja",
"ko",
"pt_BR",
"ru",
"vi",
"zh_CN",
"zh_TW"
};
size_t len = sizeof(langs)/sizeof(wchar_t*);
size_t len = sizeof(langs)/sizeof(char*);
for (size_t i=0; i<len; i++) {
const wxLanguageInfo *lang = wxLocale::FindLanguageInfo(langs[i]);
// If the locale file doesn't exist then don't list it as an option.
wxString locDir = wxStandardPaths::Get().GetLocalizedResourcesDir(langs[i], wxStandardPathsBase::ResourceCat_Messages);
wxFileName file(wxString::Format(_T("%s/%s.mo"), locDir.c_str(), _T(GETTEXT_PACKAGE)));
wxFileName file(wxString::Format("%s/%s.mo", locDir.c_str(), GETTEXT_PACKAGE));
if (lang && file.FileExists()) final.Add(lang->Language);
}
#endif

View file

@ -57,8 +57,8 @@ AssAttachment::AssAttachment(wxString _name) {
wxFileName fname(GetFileName());
wxString ext = fname.GetExt().Lower();
wxString name;
if (ext == _T("ttf")) {
name = fname.GetName() + _T("_0.") + ext;
if (ext == "ttf") {
name = fname.GetName() + "_0." + ext;
}
else name = _name;
@ -133,9 +133,9 @@ const wxString AssAttachment::GetEntryData() const {
// Write header
wxString entryData;
if (group == _T("[Fonts]")) entryData = _T("fontname: ");
else entryData = _T("filename: ");
entryData += filename + _T("\r\n");
if (group == "[Fonts]") entryData = "fontname: ";
else entryData = "filename: ";
entryData += filename + "\r\n";
// Read three bytes
while (pos < size) {
@ -162,13 +162,13 @@ const wxString AssAttachment::GetEntryData() const {
// Convert to text
for (int i=0;i<toWrite;i++) {
entryData += wxChar(dst[i]+33);
entryData += dst[i]+33;
written++;
// Line break
if (written == 80 && pos < size) {
written = 0;
entryData += _T("\r\n");
entryData += "\r\n";
}
}
}
@ -201,7 +201,7 @@ void AssAttachment::Import(wxString filename) {
// Open file and get size
wxFileInputStream fp(filename);
if (!fp.Ok()) throw _T("Failed opening file");
if (!fp.Ok()) throw "Failed opening file";
int size = fp.SeekI(0,wxFromEnd);
fp.SeekI(0,wxFromStart);
@ -218,18 +218,18 @@ void AssAttachment::Import(wxString filename) {
///
wxString AssAttachment::GetFileName(bool raw) {
// Raw
if (raw || filename.Right(4).Lower() != _T(".ttf")) return filename;
if (raw || filename.Right(4).Lower() != ".ttf") return filename;
// Remove stuff after last underscore if it's a font
int lastUnder = -1;
for (size_t i=0;i<filename.Length();i++) {
if (filename[i] == _T('_')) lastUnder = i;
if (filename[i] == '_') lastUnder = i;
}
// Underline found
wxString final = filename;
if (lastUnder != -1) {
final = filename.Left(lastUnder) + _T(".ttf");
final = filename.Left(lastUnder) + ".ttf";
}
return final;
}

View file

@ -53,12 +53,12 @@ AssDialogue::AssDialogue()
, Layer(0)
, Start(0)
, End(5000)
, Style(L"Default")
, Actor(L"")
, Effect(L"")
, Text(L"")
, Style("Default")
, Actor("")
, Effect("")
, Text("")
{
group = L"[Events]";
group = "[Events]";
Valid = true;
for (int i=0;i<4;i++) Margin[i] = 0;
}
@ -87,12 +87,12 @@ AssDialogue::AssDialogue(wxString _data,int version)
, Layer(0)
, Start(0)
, End(5000)
, Style(L"Default")
, Actor(L"")
, Effect(L"")
, Text(L"")
, Style("Default")
, Actor("")
, Effect("")
, Text("")
{
group = L"[Events]";
group = "[Events]";
Valid = false;
// Try parsing in different ways
int count = 0;
@ -105,7 +105,7 @@ AssDialogue::AssDialogue(wxString _data,int version)
// Not valid
if (!Valid) {
throw _T("Failed parsing line.");
throw "Failed parsing line.";
}
}
@ -122,22 +122,22 @@ bool AssDialogue::Parse(wxString rawData, int version) {
wxString temp;
// Get type
if (rawData.StartsWith(_T("Dialogue:"))) {
if (rawData.StartsWith("Dialogue:")) {
Comment = false;
pos = 10;
}
else if (rawData.StartsWith(_T("Comment:"))) {
else if (rawData.StartsWith("Comment:")) {
Comment = true;
pos = 9;
}
else return false;
wxStringTokenizer tkn(rawData.Mid(pos),_T(","),wxTOKEN_RET_EMPTY_ALL);
wxStringTokenizer tkn(rawData.Mid(pos),",",wxTOKEN_RET_EMPTY_ALL);
if (!tkn.HasMoreTokens()) return false;
// Get first token and see if it has "Marked=" in it
temp = tkn.GetNextToken().Trim(false).Trim(true);
if (temp.Lower().StartsWith(_T("marked="))) version = 0;
if (temp.Lower().StartsWith("marked=")) version = 0;
else if (version == 0) version = 1;
// Get layer number
@ -213,14 +213,14 @@ wxString AssDialogue::GetData(bool ssa) const {
wxString s = Style;
wxString a = Actor;
wxString e = Effect;
s.Replace(L",",L";");
a.Replace(L",",L";");
e.Replace(L",",L";");
s.Replace(",",";");
a.Replace(",",";");
e.Replace(",",";");
wxString str = wxString::Format(
L"%s: %s,%s,%s,%s,%s,%d,%d,%d,%s,%s",
Comment ? L"Comment" : L"Dialogue",
ssa ? L"Marked=0" : wxString::Format("%01d", Layer).c_str(),
"%s: %s,%s,%s,%s,%s,%d,%d,%d,%s,%s",
Comment ? "Comment" : "Dialogue",
ssa ? "Marked=0" : wxString::Format("%01d", Layer).c_str(),
Start.GetASSFormated().c_str(),
End.GetASSFormated().c_str(),
s.c_str(), a.c_str(),
@ -229,8 +229,8 @@ wxString AssDialogue::GetData(bool ssa) const {
Text.c_str());
// Make sure that final has no line breaks
str.Replace(L"\n", "");
str.Replace(L"\r", "");
str.Replace("\n", "");
str.Replace("\r", "");
return str;
}
@ -246,14 +246,14 @@ wxString AssDialogue::GetSSAText () const {
void AssDialogue::ParseSRTTags () {
// Search and replace
size_t total = 0;
total += Text.Replace(_T("<i>"),_T("{\\i1}"));
total += Text.Replace(_T("</i>"),_T("{\\i0}"));
total += Text.Replace(_T("<b>"),_T("{\\b1}"));
total += Text.Replace(_T("</b>"),_T("{\\b0}"));
total += Text.Replace(_T("<u>"),_T("{\\u1}"));
total += Text.Replace(_T("</u>"),_T("{\\u0}"));
total += Text.Replace(_T("<s>"),_T("{\\s1}"));
total += Text.Replace(_T("</s>"),_T("{\\s0}"));
total += Text.Replace("<i>","{\\i1}");
total += Text.Replace("</i>","{\\i0}");
total += Text.Replace("<b>","{\\b1}");
total += Text.Replace("</b>","{\\b0}");
total += Text.Replace("<u>","{\\u1}");
total += Text.Replace("</u>","{\\u0}");
total += Text.Replace("<s>","{\\s1}");
total += Text.Replace("</s>","{\\s0}");
// Process <font> tag
wxString work = Text;
@ -266,8 +266,8 @@ void AssDialogue::ParseSRTTags () {
bool isOpen;
// Iterate
pos_open = work.find(_T("<FONT"),0);
pos_close = work.find(_T("</FONT"),0);
pos_open = work.find("<FONT",0);
pos_close = work.find("</FONT",0);
while (pos_open != wxString::npos || pos_close != wxString::npos) {
// Determine if it's an open or close tag
if (pos_open < pos_close) {
@ -278,7 +278,7 @@ void AssDialogue::ParseSRTTags () {
start = pos_close;
isOpen = false;
}
end = work.find(_T(">"),start)+1;
end = work.find(">",start)+1;
//if (end == wxString::npos) continue;
// Open tag
@ -286,17 +286,17 @@ void AssDialogue::ParseSRTTags () {
wxString replaced;
// Color tag
if ((pos = work.find(_T("COLOR=\""),start)) != wxString::npos) {
if ((pos = work.find("COLOR=\"",start)) != wxString::npos) {
if (pos < end) {
pos += 7;
size_t end_tag = Text.find(_T("\""),pos);
size_t end_tag = Text.find("\"",pos);
if (end_tag != wxString::npos) {
if (end_tag-pos == 7) {
replaced += _T("{\\c&H");
replaced += "{\\c&H";
replaced += work.substr(pos+5,2);
replaced += work.substr(pos+3,2);
replaced += work.substr(pos+1,2);
replaced += _T("&}");
replaced += "&}";
total++;
}
}
@ -304,28 +304,28 @@ void AssDialogue::ParseSRTTags () {
}
// Face tag
if ((pos = work.find(_T("FACE=\""),start)) != wxString::npos) {
if ((pos = work.find("FACE=\"",start)) != wxString::npos) {
if (pos < end) {
pos += 6;
size_t end_tag = work.find(_T("\""),pos);
size_t end_tag = work.find("\"",pos);
if (end_tag != wxString::npos) {
replaced += _T("{\\fn");
replaced += "{\\fn";
replaced += work.substr(pos,end_tag-pos);
replaced += _T("}");
replaced += "}";
total++;
}
}
}
// Size tag
if ((pos = work.find(_T("SIZE=\""),start)) != wxString::npos) {
if ((pos = work.find("SIZE=\"",start)) != wxString::npos) {
if (pos < end) {
pos += 6;
size_t end_tag = Text.find(_T("\""),pos);
size_t end_tag = Text.find("\"",pos);
if (end_tag != wxString::npos) {
replaced += _T("{\\fs");
replaced += "{\\fs";
replaced += work.substr(pos,end_tag-pos);
replaced += _T("}");
replaced += "}";
total++;
}
}
@ -343,18 +343,18 @@ void AssDialogue::ParseSRTTags () {
// Find if it's italic, bold, underline, and strikeout
wxString prev = Text.Left(start);
bool isItalic=false,isBold=false,isUnder=false,isStrike=false;
if (CountMatches(prev,_T("{\\i1}")) > CountMatches(prev,_T("{\\i0}"))) isItalic = true;
if (CountMatches(prev,_T("{\\b1}")) > CountMatches(prev,_T("{\\b0}"))) isBold = true;
if (CountMatches(prev,_T("{\\u1}")) > CountMatches(prev,_T("{\\u0}"))) isUnder = true;
if (CountMatches(prev,_T("{\\s1}")) > CountMatches(prev,_T("{\\s0}"))) isStrike = true;
if (CountMatches(prev,"{\\i1}") > CountMatches(prev,"{\\i0}")) isItalic = true;
if (CountMatches(prev,"{\\b1}") > CountMatches(prev,"{\\b0}")) isBold = true;
if (CountMatches(prev,"{\\u1}") > CountMatches(prev,"{\\u0}")) isUnder = true;
if (CountMatches(prev,"{\\s1}") > CountMatches(prev,"{\\s0}")) isStrike = true;
// Generate new tag, by reseting and then restoring flags
wxString replaced = _T("{\\r");
if (isItalic) replaced += _T("\\i1");
if (isBold) replaced += _T("\\b1");
if (isUnder) replaced += _T("\\u1");
if (isStrike) replaced += _T("\\s1");
replaced += _T("}");
wxString replaced = "{\\r";
if (isItalic) replaced += "\\i1";
if (isBold) replaced += "\\b1";
if (isUnder) replaced += "\\u1";
if (isStrike) replaced += "\\s1";
replaced += "}";
// Replace
//Text = Text.substr(0,start) + replaced + Text.substr(end);
@ -366,12 +366,12 @@ void AssDialogue::ParseSRTTags () {
// Get next
work = Text;
work.UpperCase();
pos_open = work.find(_T("<FONT"),0);
pos_close = work.find(_T("</FONT"),0);
pos_open = work.find("<FONT",0);
pos_close = work.find("</FONT",0);
}
// Remove double tagging
Text.Replace(_T("}{"),_T(""));
Text.Replace("}{","");
}
void AssDialogue::ParseASSTags () {
@ -387,14 +387,14 @@ void AssDialogue::ParseASSTags () {
if (Text[cur] == '{') {
// Get contents of block
wxString work;
end = Text.find(_T("}"),cur);
end = Text.find("}",cur);
if (end == wxString::npos) {
work = Text.substr(cur);
end = len;
}
else work = Text.substr(cur,end-cur+1);
if (work.Find(_T("\\")) == wxNOT_FOUND) {
if (work.Find("\\") == wxNOT_FOUND) {
//We've found an override block with no backslashes
//We're going to assume it's a comment and not consider it an override block
//Currently we'll treat this as a plain text block, but feel free to create a new class
@ -415,7 +415,7 @@ void AssDialogue::ParseASSTags () {
// Look for \p in block
std::vector<AssOverrideTag*>::iterator curTag;
for (curTag = block->Tags.begin();curTag != block->Tags.end();curTag++) {
if ((*curTag)->Name == L"\\p") {
if ((*curTag)->Name == "\\p") {
drawingLevel = (*curTag)->Params[0]->Get<int>(0);
}
}
@ -428,7 +428,7 @@ void AssDialogue::ParseASSTags () {
// Plain-text/drawing block
else {
wxString work;
end = Text.find(_T("{"),cur);
end = Text.find("{",cur);
if (end == wxString::npos) {
work = Text.substr(cur);
end = len;
@ -457,7 +457,7 @@ void AssDialogue::ParseASSTags () {
// Empty line, make an empty block
if (len == 0) {
AssDialogueBlockPlain *block = new AssDialogueBlockPlain;
block->text = _T("");
block->text = "";
Blocks.push_back(block);
}
}
@ -482,7 +482,7 @@ void AssDialogue::StripTag (wxString tagName) {
}
// Insert
if (!temp.IsEmpty()) final += _T("{") + temp + _T("}");
if (!temp.IsEmpty()) final += "{" + temp + "}";
}
else final += (*cur)->GetText();
}
@ -497,7 +497,7 @@ void AssDialogue::ConvertTagsToSRT () {
AssDialogueBlockOverride* curBlock;
AssDialogueBlockPlain *curPlain;
AssOverrideTag* curTag;
wxString final = _T("");
wxString final = "";
bool isItalic=false,isBold=false,isUnder=false,isStrike=false;
bool temp;
@ -511,54 +511,54 @@ void AssDialogue::ConvertTagsToSRT () {
curTag = curBlock->Tags.at(j);
if (curTag->IsValid()) {
// Italics
if (curTag->Name == _T("\\i")) {
if (curTag->Name == "\\i") {
temp = curTag->Params.at(0)->Get<bool>();
if (temp && !isItalic) {
isItalic = true;
final += _T("<i>");
final += "<i>";
}
if (!temp && isItalic) {
isItalic = false;
final += _T("</i>");
final += "</i>";
}
}
// Underline
if (curTag->Name == _T("\\u")) {
if (curTag->Name == "\\u") {
temp = curTag->Params.at(0)->Get<bool>();
if (temp && !isUnder) {
isUnder = true;
final += _T("<u>");
final += "<u>";
}
if (!temp && isUnder) {
isUnder = false;
final += _T("</u>");
final += "</u>";
}
}
// Strikeout
if (curTag->Name == _T("\\s")) {
if (curTag->Name == "\\s") {
temp = curTag->Params.at(0)->Get<bool>();
if (temp && !isStrike) {
isStrike = true;
final += _T("<s>");
final += "<s>";
}
if (!temp && isStrike) {
isStrike = false;
final += _T("</s>");
final += "</s>";
}
}
// Bold
if (curTag->Name == _T("\\b")) {
if (curTag->Name == "\\b") {
temp = curTag->Params.at(0)->Get<bool>();
if (temp && !isBold) {
isBold = true;
final += _T("<b>");
final += "<b>";
}
if (!temp && isBold) {
isBold = false;
final += _T("</b>");
final += "</b>";
}
}
}
@ -576,13 +576,13 @@ void AssDialogue::ConvertTagsToSRT () {
// Ensure all tags are closed
if (isBold)
final += _T("</b>");
final += "</b>";
if (isItalic)
final += _T("</i>");
final += "</i>";
if (isUnder)
final += _T("</u>");
final += "</u>";
if (isStrike)
final += _T("</s>");
final += "</s>";
Text = final;
ClearBlocks();
@ -593,9 +593,9 @@ void AssDialogue::UpdateText () {
Text.clear();
for (std::vector<AssDialogueBlock*>::iterator cur=Blocks.begin();cur!=Blocks.end();cur++) {
if ((*cur)->GetType() == BLOCK_OVERRIDE) {
Text += _T("{");
Text += "{";
Text += (*cur)->GetText();
Text += _T("}");
Text += "}";
}
else Text += (*cur)->GetText();
}
@ -607,7 +607,7 @@ void AssDialogue::SetMarginString(const wxString origvalue,int which) {
// Make it numeric
wxString strvalue = origvalue;
if (!strvalue.IsNumber()) {
strvalue = _T("");
strvalue = "";
for (size_t i=0;i<origvalue.Length();i++) {
if (origvalue.Mid(i,1).IsNumber()) {
strvalue += origvalue.Mid(i,1);
@ -630,8 +630,8 @@ void AssDialogue::SetMarginString(const wxString origvalue,int which) {
wxString AssDialogue::GetMarginString(int which,bool pad) const {
if (which < 0 || which >= 4) throw Aegisub::InvalidMarginIdError();
int value = Margin[which];
if (pad) return wxString::Format(_T("%04i"),value);
else return wxString::Format(_T("%i"),value);
if (pad) return wxString::Format("%04i",value);
else return wxString::Format("%i",value);
}
void AssDialogue::ProcessParameters(AssDialogueBlockOverride::ProcessParametersCallback callback,void *userData) {
@ -657,9 +657,9 @@ bool AssDialogue::CollidesWith(AssDialogue *target) {
}
wxString AssDialogue::GetStrippedText() const {
static wxRegEx reg(_T("\\{[^\\{]*\\}"),wxRE_ADVANCED);
static wxRegEx reg("\\{[^\\{]*\\}",wxRE_ADVANCED);
wxString txt(Text);
reg.Replace(&txt,_T(""));
reg.Replace(&txt,"");
return txt;
}
@ -670,7 +670,7 @@ AssEntry *AssDialogue::Clone() const {
void AssDialogueBlockDrawing::TransformCoords(int mx,int my,double x,double y) {
// HACK: Implement a proper parser ffs!!
// Could use Spline but it'd be slower and this seems to work fine
wxStringTokenizer tkn(GetText(),_T(" "),wxTOKEN_DEFAULT);
wxStringTokenizer tkn(GetText()," ",wxTOKEN_DEFAULT);
wxString cur;
wxString final;
bool isX = true;
@ -688,7 +688,7 @@ void AssDialogueBlockDrawing::TransformCoords(int mx,int my,double x,double y) {
else temp = (long int)((temp+my)*y + 0.5);
// Write back to list
final += wxString::Format(_T("%i "),temp);
final += wxString::Format("%i ",temp);
// Toggle X/Y
isX = !isX;
@ -696,8 +696,8 @@ void AssDialogueBlockDrawing::TransformCoords(int mx,int my,double x,double y) {
// Text
else {
if (cur == _T("m") || cur == _T("n") || cur == _T("l") || cur == _T("b") || cur == _T("s") || cur == _T("p") || cur == _T("c")) isX = true;
final += cur + _T(" ");
if (cur == "m" || cur == "n" || cur == "l" || cur == "b" || cur == "s" || cur == "p" || cur == "c") isX = true;
final += cur + " ";
}
}

View file

@ -68,11 +68,11 @@ AssEntry::~AssEntry() {
///
wxString AssEntry::GetSSAText() const {
// Special cases
if (data.Lower() == _T("[v4+ styles]")) return wxString(_T("[V4 Styles]"));
if (data.Lower() == _T("scripttype: v4.00+")) return wxString(_T("ScriptType: v4.00"));
if (data.Lower().Left(7) == _T("format:")) {
if (group.Lower() == _T("[events]")) return wxString(_T("Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"));
if (group.Lower() == _T("[v4+ styles]")) return wxString(_T("Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding"));
if (data.Lower() == "[v4+ styles]") return wxString("[V4 Styles]");
if (data.Lower() == "scripttype: v4.00+") return wxString("ScriptType: v4.00");
if (data.Lower().Left(7) == "format:") {
if (group.Lower() == "[events]") return wxString("Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text");
if (group.Lower() == "[v4+ styles]") return wxString("Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding");
}
return GetEntryData();
}

View file

@ -91,7 +91,7 @@ void AssFile::Load(const wxString &_filename,wxString charset,bool addToRecent)
SubtitleFormat *reader = SubtitleFormat::GetReader(_filename);
if (!reader) {
wxMessageBox(L"Unknown file type","Error loading file",wxICON_ERROR | wxOK);
wxMessageBox("Unknown file type","Error loading file",wxICON_ERROR | wxOK);
return;
}
@ -104,25 +104,25 @@ void AssFile::Load(const wxString &_filename,wxString charset,bool addToRecent)
catch (agi::UserCancelException const&) {
return;
}
catch (const wchar_t *except) {
wxMessageBox(except,_T("Error loading file"),wxICON_ERROR | wxOK);
catch (const char *except) {
wxMessageBox(except,"Error loading file",wxICON_ERROR | wxOK);
return;
}
catch (wxString &except) {
wxMessageBox(except,_T("Error loading file"),wxICON_ERROR | wxOK);
wxMessageBox(except,"Error loading file",wxICON_ERROR | wxOK);
return;
}
// Real exception
catch (agi::Exception &e) {
wxMessageBox(wxString(e.GetChainedMessage().c_str(), wxConvUTF8), L"Error loading file", wxICON_ERROR|wxOK);
wxMessageBox(wxString(e.GetChainedMessage().c_str(), wxConvUTF8), "Error loading file", wxICON_ERROR|wxOK);
return;
}
// Other error
catch (...) {
wxMessageBox(_T("Unknown error"),_T("Error loading file"),wxICON_ERROR | wxOK);
wxMessageBox("Unknown error","Error loading file",wxICON_ERROR | wxOK);
return;
}
@ -156,8 +156,8 @@ void AssFile::Load(const wxString &_filename,wxString charset,bool addToRecent)
// Add comments and set vars
AddComment(wxString("Script generated by Aegisub ") + GetAegisubLongVersionString());
AddComment(_T("http://www.aegisub.org/"));
SetScriptInfo(_T("ScriptType"),_T("v4.00+"));
AddComment("http://www.aegisub.org/");
SetScriptInfo("ScriptType","v4.00+");
// Push the initial state of the file onto the undo stack
UndoStack.clear();
@ -195,8 +195,8 @@ void AssFile::Save(wxString filename, bool setfilename, bool addToRecent, wxStri
void AssFile::SaveMemory(std::vector<char> &dst,const wxString encoding) {
// Set encoding
wxString enc = encoding;
if (enc.IsEmpty()) enc = _T("UTF-8");
if (enc != _T("UTF-8")) throw _T("Memory writer only supports UTF-8 for now.");
if (enc.IsEmpty()) enc = "UTF-8";
if (enc != "UTF-8") throw "Memory writer only supports UTF-8 for now.";
// Check if subs contain at least one style
// Add a default style if they don't for compatibility with libass/asa
@ -215,7 +215,7 @@ void AssFile::SaveMemory(std::vector<char> &dst,const wxString encoding) {
wxCharBuffer buffer;
for (cur=Line.begin();cur!=Line.end();cur++) {
// Convert
wxString temp = (*cur)->GetEntryData() + _T("\r\n");
wxString temp = (*cur)->GetEntryData() + "\r\n";
buffer = temp.mb_str(wxConvUTF8);
lineSize = strlen(buffer);
@ -237,16 +237,16 @@ void AssFile::SaveMemory(std::vector<char> &dst,const wxString encoding) {
void AssFile::Export(wxString _filename) {
AssExporter exporter(this);
exporter.AddAutoFilters();
exporter.Export(_filename,_T("UTF-8"));
exporter.Export(_filename,"UTF-8");
}
bool AssFile::CanSave() {
// ASS format?
wxString ext = filename.Lower().Right(4);
if (ext == _T(".ass")) return true;
if (ext == ".ass") return true;
// Never save texts
if (ext == _T(".txt")) return false;
if (ext == ".txt") return false;
// Check if it's a known extension
SubtitleFormat *writer = SubtitleFormat::GetWriter(filename);
@ -254,7 +254,7 @@ bool AssFile::CanSave() {
// Check if format supports timing
bool canTime = true;
//if (filename.Lower().Right(4) == _T(".txt")) canTime = false;
//if (filename.Lower().Right(4) == ".txt") canTime = false;
// Scan through the lines
AssStyle defstyle;
@ -305,7 +305,7 @@ void AssFile::AddLine(wxString data,wxString group,int &version,wxString *outGro
wxString lowGroup = group.Lower();
// Attachment
if (lowGroup == _T("[fonts]") || lowGroup == _T("[graphics]")) {
if (lowGroup == "[fonts]" || lowGroup == "[graphics]") {
// Check if it's valid data
size_t dataLen = data.Length();
bool validData = (dataLen > 0) && (dataLen <= 80);
@ -314,7 +314,7 @@ void AssFile::AddLine(wxString data,wxString group,int &version,wxString *outGro
}
// Is the filename line?
bool isFilename = (data.StartsWith(_T("fontname: ")) || data.StartsWith(_T("filename: ")));
bool isFilename = (data.StartsWith("fontname: ") || data.StartsWith("filename: "));
// The attachment file is static, since it is built through several calls to this
// After it's done building, it's reset to NULL
@ -361,54 +361,54 @@ void AssFile::AddLine(wxString data,wxString group,int &version,wxString *outGro
}
// Dialogue
else if (lowGroup == _T("[events]")) {
if (data.StartsWith(_T("Dialogue:")) || data.StartsWith(_T("Comment:"))) {
else if (lowGroup == "[events]") {
if (data.StartsWith("Dialogue:") || data.StartsWith("Comment:")) {
AssDialogue *diag = new AssDialogue(data,version);
//diag->ParseASSTags();
entry = diag;
entry->group = group;
}
else if (data.StartsWith(_T("Format:"))) {
entry = new AssEntry(_T("Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"));
else if (data.StartsWith("Format:")) {
entry = new AssEntry("Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text");
entry->group = group;
}
}
// Style
else if (lowGroup == _T("[v4+ styles]")) {
if (data.StartsWith(_T("Style:"))) {
else if (lowGroup == "[v4+ styles]") {
if (data.StartsWith("Style:")) {
AssStyle *style = new AssStyle(data,version);
entry = style;
entry->group = group;
}
if (data.StartsWith(_T("Format:"))) {
entry = new AssEntry(_T("Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding"));
if (data.StartsWith("Format:")) {
entry = new AssEntry("Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding");
entry->group = group;
}
}
// Script info
else if (lowGroup == _T("[script info]")) {
else if (lowGroup == "[script info]") {
// Comment
if (data.StartsWith(_T(";"))) {
if (data.StartsWith(";")) {
// Skip stupid comments added by other programs
// Of course, we'll add our own in place later... ;)
return;
}
// Version
if (data.StartsWith(_T("ScriptType:"))) {
if (data.StartsWith("ScriptType:")) {
wxString versionString = data.Mid(11);
versionString.Trim(true);
versionString.Trim(false);
versionString.MakeLower();
int trueVersion;
if (versionString == _T("v4.00")) trueVersion = 0;
else if (versionString == _T("v4.00+")) trueVersion = 1;
else if (versionString == _T("v4.00++")) trueVersion = 2;
else throw _T("Unknown SSA file format version");
if (versionString == "v4.00") trueVersion = 0;
else if (versionString == "v4.00+") trueVersion = 1;
else if (versionString == "v4.00++") trueVersion = 2;
else throw "Unknown SSA file format version";
if (trueVersion != version) {
if (!(trueVersion == 2 && version == 1)) wxLogMessage(_T("Warning: File has the wrong extension."));
if (!(trueVersion == 2 && version == 1)) wxLogMessage("Warning: File has the wrong extension.");
version = trueVersion;
}
}
@ -447,25 +447,25 @@ void AssFile::LoadDefault(bool defline) {
// Write headers
AssStyle defstyle;
int version = 1;
AddLine(_T("[Script Info]"),_T("[Script Info]"),version);
AddLine(_T("Title: Default Aegisub file"),_T("[Script Info]"),version);
AddLine(_T("ScriptType: v4.00+"),_T("[Script Info]"),version);
AddLine(_T("WrapStyle: 0"), _T("[Script Info]"),version);
AddLine(_T("PlayResX: 640"),_T("[Script Info]"),version);
AddLine(_T("PlayResY: 480"),_T("[Script Info]"),version);
AddLine(_T("ScaledBorderAndShadow: yes"),_T("[Script Info]"),version);
AddLine(_T("Collisions: Normal"),_T("[Script Info]"),version);
AddLine("",_T("[Script Info]"),version);
AddLine(_T("[V4+ Styles]"),_T("[V4+ Styles]"),version);
AddLine(_T("Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding"),_T("[V4+ Styles]"),version);
AddLine(defstyle.GetEntryData(),_T("[V4+ Styles]"),version);
AddLine("",_T("[V4+ Styles]"),version);
AddLine(_T("[Events]"),_T("[Events]"),version);
AddLine(_T("Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"),_T("[Events]"),version);
AddLine("[Script Info]","[Script Info]",version);
AddLine("Title: Default Aegisub file","[Script Info]",version);
AddLine("ScriptType: v4.00+","[Script Info]",version);
AddLine("WrapStyle: 0", "[Script Info]",version);
AddLine("PlayResX: 640","[Script Info]",version);
AddLine("PlayResY: 480","[Script Info]",version);
AddLine("ScaledBorderAndShadow: yes","[Script Info]",version);
AddLine("Collisions: Normal","[Script Info]",version);
AddLine("","[Script Info]",version);
AddLine("[V4+ Styles]","[V4+ Styles]",version);
AddLine("Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding","[V4+ Styles]",version);
AddLine(defstyle.GetEntryData(),"[V4+ Styles]",version);
AddLine("","[V4+ Styles]",version);
AddLine("[Events]","[Events]",version);
AddLine("Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text","[Events]",version);
if (defline) {
AssDialogue def;
AddLine(def.GetEntryData(),_T("[Events]"),version);
AddLine(def.GetEntryData(),"[Events]",version);
}
Commit("", COMMIT_NEW);
@ -507,7 +507,7 @@ void AssFile::InsertStyle (AssStyle *style) {
// Look for insert position
for (cur=Line.begin();cur!=Line.end();cur++) {
curEntry = *cur;
if (curEntry->GetType() == ENTRY_STYLE || (lastGroup == _T("[V4+ Styles]") && curEntry->GetEntryData().substr(0,7) == _T("Format:"))) {
if (curEntry->GetType() == ENTRY_STYLE || (lastGroup == "[V4+ Styles]" && curEntry->GetEntryData().substr(0,7) == "Format:")) {
lastStyle = cur;
}
lastGroup = curEntry->group;
@ -521,17 +521,17 @@ void AssFile::InsertStyle (AssStyle *style) {
Line.push_back(curEntry);
// Add header
curEntry = new AssEntry(_T("[V4+ Styles]"));
curEntry->group = _T("[V4+ Styles]");
curEntry = new AssEntry("[V4+ Styles]");
curEntry->group = "[V4+ Styles]";
Line.push_back(curEntry);
// Add format line
curEntry = new AssEntry(_T("Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding"));
curEntry->group = _T("[V4+ Styles]");
curEntry = new AssEntry("Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding");
curEntry->group = "[V4+ Styles]";
Line.push_back(curEntry);
// Add style
style->group = _T("[V4+ Styles]");
style->group = "[V4+ Styles]";
Line.push_back(style);
}
@ -590,20 +590,20 @@ void AssFile::InsertAttachment (wxString filename) {
// Insert
wxString ext = filename.Right(4).Lower();
if (ext == _T(".ttf") || ext == _T(".ttc") || ext == _T(".pfb")) newAttach->group = _T("[Fonts]");
else newAttach->group = _T("[Graphics]");
if (ext == ".ttf" || ext == ".ttc" || ext == ".pfb") newAttach->group = "[Fonts]";
else newAttach->group = "[Graphics]";
InsertAttachment(newAttach);
}
wxString AssFile::GetScriptInfo(const wxString _key) {
wxString key = _key;;
key.Lower();
key += _T(":");
key += ":";
std::list<AssEntry*>::iterator cur;
bool GotIn = false;
for (cur=Line.begin();cur!=Line.end();cur++) {
if ((*cur)->group == _T("[Script Info]")) {
if ((*cur)->group == "[Script Info]") {
GotIn = true;
wxString curText = (*cur)->GetEntryData();
curText.Lower();
@ -639,7 +639,7 @@ void AssFile::SetScriptInfo(wxString const& key, wxString const& value) {
bool found_script_info = false;
for (std::list<AssEntry*>::iterator cur = Line.begin(); cur != Line.end(); ++cur) {
if ((*cur)->group == _T("[Script Info]")) {
if ((*cur)->group == "[Script Info]") {
found_script_info = true;
wxString cur_text = (*cur)->GetEntryData().Left(key_size).Lower();
@ -667,7 +667,7 @@ void AssFile::SetScriptInfo(wxString const& key, wxString const& value) {
}
void AssFile::GetResolution(int &sw,int &sh) {
wxString temp = GetScriptInfo(_T("PlayResY"));
wxString temp = GetScriptInfo("PlayResY");
if (temp.IsEmpty() || !temp.IsNumber()) {
sh = 0;
}
@ -677,7 +677,7 @@ void AssFile::GetResolution(int &sw,int &sh) {
sh = templ;
}
temp = GetScriptInfo(_T("PlayResX"));
temp = GetScriptInfo("PlayResX");
if (temp.IsEmpty() || !temp.IsNumber()) {
sw = 0;
}
@ -706,17 +706,17 @@ void AssFile::GetResolution(int &sw,int &sh) {
}
void AssFile::AddComment(const wxString _comment) {
wxString comment = _T("; ");
wxString comment = "; ";
comment += _comment;
std::list<AssEntry*>::iterator cur;
int step = 0;
for (cur=Line.begin();cur!=Line.end();cur++) {
// Start of group
if (step == 0 && (*cur)->group == _T("[Script Info]")) step = 1;
if (step == 0 && (*cur)->group == "[Script Info]") step = 1;
// First line after a ;
else if (step == 1 && !(*cur)->GetEntryData().StartsWith(_T(";"))) {
else if (step == 1 && !(*cur)->GetEntryData().StartsWith(";")) {
AssEntry *prev = *cur;
AssEntry *comm = new AssEntry(comment);
comm->group = prev->group;
@ -755,7 +755,7 @@ void AssFile::AddToRecent(wxString file) {
wxString AssFile::GetWildcardList(int mode) {
if (mode == 0) return SubtitleFormat::GetWildcards(0);
else if (mode == 1) return _T("Advanced Substation Alpha (*.ass)|*.ass");
else if (mode == 1) return "Advanced Substation Alpha (*.ass)|*.ass";
else if (mode == 2) return SubtitleFormat::GetWildcards(1);
else return "";
}

View file

@ -128,10 +128,10 @@ public:
/// @param setfilename Should the filename be changed to the passed path?
/// @param addToRecent Should the file be added to the MRU list?
/// @param encoding Encoding to use, or empty to let the writer decide (which usually means "App/Save Charset")
void Save(wxString file,bool setfilename=false,bool addToRecent=true,const wxString encoding=_T(""));
void Save(wxString file,bool setfilename=false,bool addToRecent=true,const wxString encoding="");
/// @brief Save to a memory buffer. Used for subtitle providers which support it
/// @param[out] dst Destination vector
void SaveMemory(std::vector<char> &dst,const wxString encoding=_T(""));
void SaveMemory(std::vector<char> &dst,const wxString encoding="");
/// @brief Saves exported copy, with effects applied
/// @param file Path to save to; file name is never set to this
void Export(wxString file);

View file

@ -74,21 +74,21 @@ AssDialogueBlockOverride::~AssDialogueBlockOverride() {
void AssDialogueBlockOverride::ParseTags() {
delete_clear(Tags);
wxStringTokenizer tkn(text, L"\\", wxTOKEN_STRTOK);
wxStringTokenizer tkn(text, "\\", wxTOKEN_STRTOK);
wxString curTag;
if (text.StartsWith(L"\\")) curTag = L"\\";
if (text.StartsWith("\\")) curTag = "\\";
while (tkn.HasMoreTokens()) {
curTag += tkn.GetNextToken();
// Check for parenthesis matching for \t
while (curTag.Freq(L'(') > curTag.Freq(L')') && tkn.HasMoreTokens()) {
curTag << L"\\" << tkn.GetNextToken();
while (curTag.Freq('(') > curTag.Freq(')') && tkn.HasMoreTokens()) {
curTag << "\\" << tkn.GetNextToken();
}
Tags.push_back(new AssOverrideTag(curTag));
curTag = L"\\";
curTag = "\\";
}
}
void AssDialogueBlockOverride::AddTag(wxString const& tag) {
@ -149,17 +149,17 @@ static void load_protos() {
// Longer tag names must appear before shorter tag names
proto[0].Set(L"\\alpha", VARDATA_TEXT); // \alpha
proto[++i].Set(L"\\bord", VARDATA_FLOAT,PARCLASS_ABSOLUTE_SIZE); // \bord<depth>
proto[++i].Set(L"\\xbord", VARDATA_FLOAT,PARCLASS_ABSOLUTE_SIZE); // \xbord<depth>
proto[++i].Set(L"\\ybord", VARDATA_FLOAT,PARCLASS_ABSOLUTE_SIZE); // \ybord<depth>
proto[++i].Set(L"\\shad", VARDATA_FLOAT,PARCLASS_ABSOLUTE_SIZE); // \shad<depth>
proto[++i].Set(L"\\xshad", VARDATA_FLOAT,PARCLASS_ABSOLUTE_SIZE); // \xshad<depth>
proto[++i].Set(L"\\yshad", VARDATA_FLOAT,PARCLASS_ABSOLUTE_SIZE); // \yshad<depth>
proto[0].Set("\\alpha", VARDATA_TEXT); // \alpha
proto[++i].Set("\\bord", VARDATA_FLOAT,PARCLASS_ABSOLUTE_SIZE); // \bord<depth>
proto[++i].Set("\\xbord", VARDATA_FLOAT,PARCLASS_ABSOLUTE_SIZE); // \xbord<depth>
proto[++i].Set("\\ybord", VARDATA_FLOAT,PARCLASS_ABSOLUTE_SIZE); // \ybord<depth>
proto[++i].Set("\\shad", VARDATA_FLOAT,PARCLASS_ABSOLUTE_SIZE); // \shad<depth>
proto[++i].Set("\\xshad", VARDATA_FLOAT,PARCLASS_ABSOLUTE_SIZE); // \xshad<depth>
proto[++i].Set("\\yshad", VARDATA_FLOAT,PARCLASS_ABSOLUTE_SIZE); // \yshad<depth>
// \fade(<a1>,<a2>,<a3>,<t1>,<t2>,<t3>,<t4>)
i++;
proto[i].name = L"\\fade";
proto[i].name = "\\fade";
proto[i].AddParam(VARDATA_INT);
proto[i].AddParam(VARDATA_INT);
proto[i].AddParam(VARDATA_INT);
@ -170,7 +170,7 @@ static void load_protos() {
// \move(<x1>,<y1>,<x2>,<y2>[,<t1>,<t2>])
i++;
proto[i].name = L"\\move";
proto[i].name = "\\move";
proto[i].AddParam(VARDATA_FLOAT,PARCLASS_ABSOLUTE_POS_X);
proto[i].AddParam(VARDATA_FLOAT,PARCLASS_ABSOLUTE_POS_Y);
proto[i].AddParam(VARDATA_FLOAT,PARCLASS_ABSOLUTE_POS_X);
@ -181,7 +181,7 @@ static void load_protos() {
// If these are rearranged, keep rect clip and vector clip adjacent in this order
// \clip(<x1>,<y1>,<x2>,<y2>)
i++;
proto[i].name = L"\\clip";
proto[i].name = "\\clip";
proto[i].AddParam(VARDATA_INT,PARCLASS_ABSOLUTE_POS_X);
proto[i].AddParam(VARDATA_INT,PARCLASS_ABSOLUTE_POS_Y);
proto[i].AddParam(VARDATA_INT,PARCLASS_ABSOLUTE_POS_X);
@ -189,13 +189,13 @@ static void load_protos() {
// \clip([<scale>,]<some drawings>)
i++;
proto[i].name = L"\\clip";
proto[i].name = "\\clip";
proto[i].AddParam(VARDATA_INT,PARCLASS_NORMAL,OPTIONAL_2);
proto[i].AddParam(VARDATA_TEXT,PARCLASS_DRAWING);
// \iclip(<x1>,<y1>,<x2>,<y2>)
i++;
proto[i].name = L"\\iclip";
proto[i].name = "\\iclip";
proto[i].AddParam(VARDATA_INT,PARCLASS_ABSOLUTE_POS_X);
proto[i].AddParam(VARDATA_INT,PARCLASS_ABSOLUTE_POS_Y);
proto[i].AddParam(VARDATA_INT,PARCLASS_ABSOLUTE_POS_X);
@ -203,71 +203,71 @@ static void load_protos() {
// \iclip([<scale>,]<some drawings>)
i++;
proto[i].name = L"\\iclip";
proto[i].name = "\\iclip";
proto[i].AddParam(VARDATA_INT,PARCLASS_NORMAL,OPTIONAL_2);
proto[i].AddParam(VARDATA_TEXT,PARCLASS_DRAWING);
proto[++i].Set(L"\\fscx", VARDATA_FLOAT,PARCLASS_RELATIVE_SIZE_X); // \fscx<percent>
proto[++i].Set(L"\\fscy", VARDATA_FLOAT,PARCLASS_RELATIVE_SIZE_Y); // \fscy<percent>
proto[++i].Set("\\fscx", VARDATA_FLOAT,PARCLASS_RELATIVE_SIZE_X); // \fscx<percent>
proto[++i].Set("\\fscy", VARDATA_FLOAT,PARCLASS_RELATIVE_SIZE_Y); // \fscy<percent>
// \pos(<x>,<y>)
i++;
proto[i].name = L"\\pos";
proto[i].name =