diff --git a/aegisub/ass_style_storage.cpp b/aegisub/ass_style_storage.cpp index 5099b3643..75273b20e 100644 --- a/aegisub/ass_style_storage.cpp +++ b/aegisub/ass_style_storage.cpp @@ -95,10 +95,19 @@ void AssStyleStorage::Clear () { ///////////// // Get names wxArrayString AssStyleStorage::GetNames() { - using std::list; wxArrayString names; - for (list::iterator cur=style.begin();cur!=style.end();cur++) { + for (std::list::iterator cur=style.begin();cur!=style.end();cur++) { names.Add((*cur)->name); } return names; } + + +/////////////////////// +// Get a style by name +AssStyle *AssStyleStorage::GetStyle(wxString name) { + for (std::list::iterator cur=style.begin();cur!=style.end();cur++) { + if ((*cur)->name == name) return *cur; + } + return NULL; +} diff --git a/aegisub/ass_style_storage.h b/aegisub/ass_style_storage.h index 66578a40a..a696ee1d2 100644 --- a/aegisub/ass_style_storage.h +++ b/aegisub/ass_style_storage.h @@ -56,6 +56,7 @@ public: std::list style; wxArrayString GetNames(); + AssStyle *GetStyle(wxString name); void Clear(); void Save(wxString name); void Load(wxString name); diff --git a/aegisub/dialog_style_editor.cpp b/aegisub/dialog_style_editor.cpp index 8638e9c8a..db26397b3 100644 --- a/aegisub/dialog_style_editor.cpp +++ b/aegisub/dialog_style_editor.cpp @@ -440,7 +440,20 @@ void DialogStyleEditor::Apply (bool apply,bool close) { // Check if style name is unique for (unsigned int i=0;iass->GetStyle(styles[i]) != style) { + bool ok = true; + + // Local + if (isLocal) { + if (grid->ass->GetStyle(styles[i]) != style) ok = false; + } + + // Storage + else { + if (store->GetStyle(styles[i]) != style) ok = false; + } + + // Repeated name + if (!ok) { wxMessageBox(_T("There is already a style with this name. Please choose another name."),_T("Style name conflict."),wxICON_ERROR); return; }