Make AssFile::GetScriptInfo slightly less dumb

Originally committed to SVN as r5775.
This commit is contained in:
Thomas Goyne 2011-10-25 01:16:36 +00:00
parent 5c487ae75f
commit 2ad0342103
2 changed files with 7 additions and 12 deletions

View file

@ -597,27 +597,22 @@ void AssFile::InsertAttachment (wxString filename) {
InsertAttachment(newAttach);
}
wxString AssFile::GetScriptInfo(const wxString _key) {
wxString key = _key;;
wxString AssFile::GetScriptInfo(wxString key) {
key.Lower();
key += ":";
std::list<AssEntry*>::iterator cur;
bool GotIn = false;
for (cur=Line.begin();cur!=Line.end();cur++) {
for (std::list<AssEntry*>::iterator cur = Line.begin(); cur != Line.end(); ++cur) {
if ((*cur)->group == "[Script Info]") {
GotIn = true;
wxString curText = (*cur)->GetEntryData();
curText.Lower();
if (curText.StartsWith(key)) {
wxString result = curText.Mid(key.length());
result.Trim(false);
result.Trim(true);
return result;
}
wxString value;
if (curText.StartsWith(key, &value))
return value.Trim(true).Trim(false);
}
else if (GotIn) break;
else if (GotIn) return "";
}
return "";

View file

@ -155,7 +155,7 @@ public:
/// Get the value in a [Script Info] key as int.
int GetScriptInfoAsInt(const wxString key);
/// Get the value in a [Script Info] key as string.
wxString GetScriptInfo(const wxString key);
wxString GetScriptInfo(wxString key);
/// Set the value of a [Script Info] key. Adds it if it doesn't exist.
void SetScriptInfo(wxString const& key, wxString const& value);
// Add a ";" comment in the [Script Info] section