Renaming a style will now ask you if you want to rename all instances of it on the script.

Originally committed to SVN as r567.
This commit is contained in:
Rodrigo Braz Monteiro 2006-12-17 20:16:22 +00:00
parent a5105d2552
commit 73fdf2a9d3
2 changed files with 47 additions and 3 deletions

View File

@ -29,6 +29,7 @@ Please visit http://aegisub.net to download latest version
- Times can now be copy and pasted with ctrl+c and ctrl+v, as well as from context menu, in the time edit boxes. (AMZ)
- Plain-text lines can now be pasted into the grid. They will be inserted as default lines with the text as their content. (AMZ)
- Added Paste Over function, which allows you to paste subtitle lines over others, overwriting the fields of your choice. (AMZ)
- Renaming a style will now ask you if you want to rename all instances of it on the script. (AMZ)
= 1.10 beta - 2006.08.07 ===========================

View File

@ -39,8 +39,10 @@
#include <wx/fontdlg.h>
#include <wx/colordlg.h>
#include "dialog_style_editor.h"
#include "ass_dialogue.h"
#include "ass_style.h"
#include "ass_file.h"
#include "ass_override.h"
#include "validators.h"
#include "subs_grid.h"
#include "utils.h"
@ -356,11 +358,55 @@ void DialogStyleEditor::OnSetColor3 (wxCommandEvent &event) { OnSetColor(3); }
void DialogStyleEditor::OnSetColor4 (wxCommandEvent &event) { OnSetColor(4); }
/////////////////
// Replace Style
void ReplaceStyle(wxString tag,int n,AssOverrideParameter* param,void *userData) {
wxArrayString strings = *((wxArrayString*)userData);
if (tag == _T("\\r")) {
if (param->GetType() == VARDATA_TEXT) {
if (param->AsText() == strings[0]) {
param->SetText(strings[1]);
}
}
}
}
//////////
// Events
void DialogStyleEditor::Apply (bool apply,bool close) {
// Apply
if (apply) {
// Style name
wxString newStyleName = StyleName->GetValue();
if (work->name != newStyleName) {
// See if user wants to update style name through script
int answer = wxMessageBox(_T("Do you want to change all instances of this style in the script to this new name?"),_T("Update script?"),wxYES_NO | wxCANCEL);
// Cancel
if (answer == wxCANCEL) return;
// Update
if (answer == wxYES) {
int n = grid->GetRows();
wxArrayString strings;
strings.Add(work->name);
strings.Add(newStyleName);
for (int i=0;i<n;i++) {
AssDialogue *curDiag = grid->GetDialogue(i);
if (curDiag->Style == work->name) curDiag->Style = newStyleName;
curDiag->ParseASSTags();
curDiag->ProcessParameters(ReplaceStyle,&strings);
curDiag->UpdateText();
curDiag->UpdateData();
curDiag->ClearBlocks();
}
}
// Change name
work->name = newStyleName;
}
// Update scale
ScaleX->GetValue().ToDouble(&(work->scalex));
ScaleY->GetValue().ToDouble(&(work->scaley));
@ -411,9 +457,6 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
work->font = FontName->GetValue();
FontSize->GetValue().ToDouble(&(work->fontsize));
// Style name
work->name = StyleName->GetValue();
// Copy
*style = *work;
style->UpdateData();