Start the translation assistant at the first translatable block rather than always the first block

Originally committed to SVN as r6166.
This commit is contained in:
Thomas Goyne 2011-12-26 22:21:14 +00:00
parent 9cfe230682
commit 92254a9806
1 changed files with 15 additions and 12 deletions

View File

@ -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))); 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) DialogTranslation::DialogTranslation(agi::Context *c)
: wxDialog(c->parent, -1, _("Translation Assistant"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX, "TranslationAssistant") : wxDialog(c->parent, -1, _("Translation Assistant"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX, "TranslationAssistant")
, c(c) , c(c)
@ -141,27 +150,21 @@ DialogTranslation::DialogTranslation(agi::Context *c)
main_sizer->Add(standard_buttons, 0, wxALIGN_RIGHT | wxLEFT | wxBOTTOM | wxRIGHT, 5); main_sizer->Add(standard_buttons, 0, wxALIGN_RIGHT | wxLEFT | wxBOTTOM | wxRIGHT, 5);
} }
SetSizer(main_sizer); SetSizerAndFit(main_sizer);
main_sizer->SetSizeHints(this);
persist.reset(new PersistLocation(this, "Tool/Translation Assistant")); persist.reset(new PersistLocation(this, "Tool/Translation Assistant"));
Bind(wxEVT_KEY_DOWN, &DialogTranslation::OnKeyDown, this); Bind(wxEVT_KEY_DOWN, &DialogTranslation::OnKeyDown, this);
active_line->ParseASSTags(); active_line->ParseASSTags();
UpdateDisplay(); if (bad_block(active_line->Blocks[0]))
NextBlock();
else
UpdateDisplay();
} }
DialogTranslation::~DialogTranslation() { } 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() { bool DialogTranslation::NextBlock() {
do { do {
if (cur_block == active_line->Blocks.size() - 1) { if (cur_block == active_line->Blocks.size() - 1) {