mirror of https://github.com/odrling/Aegisub
Merge revisions r3160-r3163 (styles manager bug fixes) into the 2.1.8 branch.
Originally committed to SVN as r3171.
This commit is contained in:
parent
65e84aeaca
commit
a0ade19643
|
@ -436,21 +436,8 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
|
||||||
|
|
||||||
// Check if style name is unique
|
// Check if style name is unique
|
||||||
for (unsigned int i=0;i<styles.Count();i++) {
|
for (unsigned int i=0;i<styles.Count();i++) {
|
||||||
if (styles[i] == newStyleName) {
|
if (newStyleName.CmpNoCase(styles[i]) == 0) {
|
||||||
bool ok = true;
|
if ((isLocal && (grid->ass->GetStyle(styles[i]) != style)) || (!isLocal && (store->GetStyle(styles[i]) != style))) {
|
||||||
|
|
||||||
// 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);
|
wxMessageBox(_T("There is already a style with this name. Please choose another name."),_T("Style name conflict."),wxICON_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -559,26 +559,22 @@ void DialogStyleManager::OnCopyToStorage (wxCommandEvent &event) {
|
||||||
|
|
||||||
wxArrayInt selections;
|
wxArrayInt selections;
|
||||||
int n = CurrentList->GetSelections(selections);
|
int n = CurrentList->GetSelections(selections);
|
||||||
AssStyle *temp;
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
int test = StorageList->FindString(CurrentList->GetString(selections[i]), true);
|
wxString styleName = CurrentList->GetString(selections[i]);
|
||||||
if (test == wxNOT_FOUND) {
|
bool addStyle = true;
|
||||||
temp = new AssStyle;
|
|
||||||
*temp = *styleMap.at(selections[i]);
|
for (std::list<AssStyle *>::iterator style = Store.style.begin(); style != Store.style.end(); ++style) {
|
||||||
Store.style.push_back(temp);
|
if ((*style)->name.CmpNoCase(styleName) == 0) {
|
||||||
|
addStyle = false;
|
||||||
|
if (wxYES == wxMessageBox(wxString::Format(_T("There is already a style with the name \"%s\" on the current storage. Proceed and overwrite anyway?"),styleName), _T("Style name collision."), wxYES_NO)) {
|
||||||
|
**style = *styleMap.at(selections[i]);
|
||||||
}
|
}
|
||||||
else {
|
break;
|
||||||
int answer = wxMessageBox(wxString::Format(_T("There is already a style with the name \"%s\" on the current storage. Proceed and overwrite anyway?"),CurrentList->GetString(selections[i]).c_str()),_T("Style name collision."),wxYES_NO);
|
|
||||||
if (answer == wxYES) {
|
|
||||||
// Remove the old style
|
|
||||||
temp = styleStorageMap.at(selections[i]);
|
|
||||||
Store.style.remove(temp);
|
|
||||||
// And save the new one instead
|
|
||||||
temp = new AssStyle;
|
|
||||||
*temp = *styleMap.at(selections[i]);
|
|
||||||
Store.style.push_back(temp);
|
|
||||||
}
|
}
|
||||||
// else do nothing
|
}
|
||||||
|
if (addStyle) {
|
||||||
|
AssStyle *temp = new AssStyle(*styleMap.at(selections[i]));
|
||||||
|
Store.style.push_back(temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Store.Save(CatalogList->GetString(CatalogList->GetSelection()));
|
Store.Save(CatalogList->GetString(CatalogList->GetSelection()));
|
||||||
|
@ -592,29 +588,23 @@ void DialogStyleManager::OnCopyToStorage (wxCommandEvent &event) {
|
||||||
void DialogStyleManager::OnCopyToCurrent (wxCommandEvent &event) {
|
void DialogStyleManager::OnCopyToCurrent (wxCommandEvent &event) {
|
||||||
wxArrayInt selections;
|
wxArrayInt selections;
|
||||||
int n = StorageList->GetSelections(selections);
|
int n = StorageList->GetSelections(selections);
|
||||||
AssStyle *temp;
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
// Check if there is already a style with that name
|
wxString styleName = StorageList->GetString(selections[i]);
|
||||||
int test = CurrentList->FindString(StorageList->GetString(selections[i]), false);
|
bool addStyle = true;
|
||||||
bool proceed = false;
|
|
||||||
if (test == wxNOT_FOUND)
|
|
||||||
proceed = true;
|
|
||||||
if (!proceed) {
|
|
||||||
int answer = wxMessageBox(wxString::Format(_T("There is already a style with the name \"%s\" on the current script. Proceed anyway?"),StorageList->GetString(selections[i]).c_str()),_T("Style name collision."),wxYES_NO);
|
|
||||||
if (answer == wxYES) proceed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy
|
for (std::vector<AssStyle *>::iterator style = styleMap.begin(); style != styleMap.end(); ++style) {
|
||||||
// FIXME: this doesn't overwrite the old style like most of the rest of the style copying functions do,
|
if ((*style)->name.CmpNoCase(styleName) == 0) {
|
||||||
// it just inserts a new one with the same name. Bad usability.
|
addStyle = false;
|
||||||
if (proceed) {
|
if (wxYES == wxMessageBox(wxString::Format(_T("There is already a style with the name \"%s\" on the current script. Proceed and overwrite anyway?"),styleName), _T("Style name collision."), wxYES_NO)) {
|
||||||
temp = new AssStyle;
|
**style = *styleStorageMap.at(selections[i]);
|
||||||
*temp = *styleStorageMap.at(selections[i]);
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (addStyle) {
|
||||||
|
AssStyle *temp = new AssStyle(*styleStorageMap.at(selections[i]));
|
||||||
AssFile::top->InsertStyle(temp);
|
AssFile::top->InsertStyle(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return
|
|
||||||
else return;
|
|
||||||
}
|
}
|
||||||
LoadCurrentStyles(AssFile::top);
|
LoadCurrentStyles(AssFile::top);
|
||||||
grid->ass->FlagAsModified(_("style copy"));
|
grid->ass->FlagAsModified(_("style copy"));
|
||||||
|
@ -628,9 +618,8 @@ void DialogStyleManager::OnCopyToCurrent (wxCommandEvent &event) {
|
||||||
void DialogStyleManager::OnStorageCopy (wxCommandEvent &event) {
|
void DialogStyleManager::OnStorageCopy (wxCommandEvent &event) {
|
||||||
wxArrayInt selections;
|
wxArrayInt selections;
|
||||||
StorageList->GetSelections(selections);
|
StorageList->GetSelections(selections);
|
||||||
AssStyle *temp = new AssStyle;
|
AssStyle *temp = new AssStyle(*(styleStorageMap.at(selections[0])));
|
||||||
|
|
||||||
*temp = *(styleStorageMap.at(selections[0]));
|
|
||||||
wxString newName = _("Copy of ");
|
wxString newName = _("Copy of ");
|
||||||
newName += temp->name;
|
newName += temp->name;
|
||||||
temp->name = newName;
|
temp->name = newName;
|
||||||
|
@ -1095,17 +1084,17 @@ void DialogStyleManager::MoveStyles(bool storage, int type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get sorted list
|
// Get sorted list
|
||||||
wxArrayString stylNames;
|
wxArrayString styleNames;
|
||||||
for (int i=0;i<nStyles;i++) stylNames.Add(srcStyls->at(i)->name.Lower());
|
for (int i=0; i < nStyles; i++) styleNames.Add(srcStyls->at(i)->name);
|
||||||
stylNames.Sort();
|
styleNames.Sort();
|
||||||
AssStyle *curStyl;
|
|
||||||
|
|
||||||
// Find each and copy it
|
std::list<AssStyle *> styles(srcStyls->begin(), srcStyls->end());
|
||||||
for (int i = 0; i < nStyles; i++) {
|
for (int i = 0; i < nStyles; i++) {
|
||||||
for (int j=0;j<nStyles;j++) {
|
for (std::list<AssStyle *>::iterator style = styles.begin(); style != styles.end(); style++) {
|
||||||
curStyl = srcStyls->at(j);
|
if ((*style)->name == styleNames[i]) {
|
||||||
if (curStyl->name.Lower() == stylNames[i]) {
|
styls.push_back(*style);
|
||||||
styls.push_back(curStyl);
|
styles.erase(style);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue