From 92254a9806348b7ffd8482f7b7925b16f74fdfb6 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 26 Dec 2011 22:21:14 +0000 Subject: [PATCH] Start the translation assistant at the first translatable block rather than always the first block Originally committed to SVN as r6166. --- aegisub/src/dialog_translation.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/aegisub/src/dialog_translation.cpp b/aegisub/src/dialog_translation.cpp index e6f794df5..a04237337 100644 --- a/aegisub/src/dialog_translation.cpp +++ b/aegisub/src/dialog_translation.cpp @@ -53,6 +53,15 @@ static void add_hotkey(wxSizer *sizer, wxWindow *parent, const char *command, co sizer->Add(new wxStaticText(parent, -1, hotkey::get_hotkey_str_first("Translation Assistant", command))); } +// Skip over override blocks, comments, and whitespace between blocks +static bool bad_block(AssDialogueBlock *block) { + if (block->GetType() != BLOCK_PLAIN) return true; + wxString text = block->GetText(); + if (text.Trim().Trim(false).empty()) return true; + if (text[0] == '{' && text.Last() == '}') return true; + return false; +} + DialogTranslation::DialogTranslation(agi::Context *c) : wxDialog(c->parent, -1, _("Translation Assistant"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX, "TranslationAssistant") , c(c) @@ -141,27 +150,21 @@ DialogTranslation::DialogTranslation(agi::Context *c) main_sizer->Add(standard_buttons, 0, wxALIGN_RIGHT | wxLEFT | wxBOTTOM | wxRIGHT, 5); } - SetSizer(main_sizer); - main_sizer->SetSizeHints(this); + SetSizerAndFit(main_sizer); persist.reset(new PersistLocation(this, "Tool/Translation Assistant")); Bind(wxEVT_KEY_DOWN, &DialogTranslation::OnKeyDown, this); + active_line->ParseASSTags(); - UpdateDisplay(); + if (bad_block(active_line->Blocks[0])) + NextBlock(); + else + UpdateDisplay(); } DialogTranslation::~DialogTranslation() { } -// Skip over override blocks, comments, and whitespace between blocks -static bool bad_block(AssDialogueBlock *block) { - if (block->GetType() != BLOCK_PLAIN) return true; - wxString text = block->GetText(); - if (text.Trim().Trim(false).empty()) return true; - if (text[0] == '{' && text.Last() == '}') return true; - return false; -} - bool DialogTranslation::NextBlock() { do { if (cur_block == active_line->Blocks.size() - 1) {