mirror of https://github.com/odrling/Aegisub
Fixed karaoke next/prev
Originally committed to SVN as r79.
This commit is contained in:
parent
e080a06834
commit
14e54bce4e
|
@ -305,23 +305,23 @@ void AudioDisplay::UpdateImage(bool weak) {
|
||||||
|
|
||||||
// Draw karaoke
|
// Draw karaoke
|
||||||
if (hasKaraoke) {
|
if (hasKaraoke) {
|
||||||
// Prepare
|
try {
|
||||||
wxPen curPen(Options.AsColour(_T("Audio Syllable boundaries")),1,wxDOT);
|
// Prepare
|
||||||
dc.SetPen(curPen);
|
wxPen curPen(Options.AsColour(_T("Audio Syllable boundaries")),1,wxDOT);
|
||||||
wxFont curFont(9,wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_T("Verdana"),wxFONTENCODING_SYSTEM);
|
dc.SetPen(curPen);
|
||||||
dc.SetFont(curFont);
|
wxFont curFont(9,wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_T("Verdana"),wxFONTENCODING_SYSTEM);
|
||||||
if (!spectrum) dc.SetTextForeground(Options.AsColour(_T("Audio Syllable text")));
|
dc.SetFont(curFont);
|
||||||
else dc.SetTextForeground(wxColour(255,255,255));
|
if (!spectrum) dc.SetTextForeground(Options.AsColour(_T("Audio Syllable text")));
|
||||||
size_t karn = karaoke->syllables.size();
|
else dc.SetTextForeground(wxColour(255,255,255));
|
||||||
__int64 pos1,pos2;
|
size_t karn = karaoke->syllables.size();
|
||||||
int len,curpos;
|
__int64 pos1,pos2;
|
||||||
wxCoord tw=0,th=0;
|
int len,curpos;
|
||||||
KaraokeSyllable *curSyl;
|
wxCoord tw=0,th=0;
|
||||||
wxString temptext;
|
KaraokeSyllable *curSyl;
|
||||||
|
wxString temptext;
|
||||||
|
|
||||||
// Draw syllables
|
// Draw syllables
|
||||||
for (size_t i=0;i<karn;i++) {
|
for (size_t i=0;i<karn;i++) {
|
||||||
try {
|
|
||||||
curSyl = &karaoke->syllables.at(i);
|
curSyl = &karaoke->syllables.at(i);
|
||||||
len = curSyl->length*10;
|
len = curSyl->length*10;
|
||||||
curpos = curSyl->position*10;
|
curpos = curSyl->position*10;
|
||||||
|
@ -336,8 +336,8 @@ void AudioDisplay::UpdateImage(bool weak) {
|
||||||
dc.DrawText(temptext,(pos1+pos2-tw)/2,h-th-4);
|
dc.DrawText(temptext,(pos1+pos2-tw)/2,h-th-4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (...) {
|
}
|
||||||
}
|
catch (...) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -592,25 +592,29 @@ void AudioDisplay::GetDialoguePos(__int64 &selStart,__int64 &selEnd, bool cap) {
|
||||||
////////////////////////
|
////////////////////////
|
||||||
// Get karaoke position
|
// Get karaoke position
|
||||||
void AudioDisplay::GetKaraokePos(__int64 &karStart,__int64 &karEnd, bool cap) {
|
void AudioDisplay::GetKaraokePos(__int64 &karStart,__int64 &karEnd, bool cap) {
|
||||||
// Wrap around
|
try {
|
||||||
int nsyls = karaoke->syllables.size();
|
// Wrap around
|
||||||
if (karaoke->curSyllable == -1) {
|
int nsyls = karaoke->syllables.size();
|
||||||
karaoke->SetSyllable(nsyls-1);
|
if (karaoke->curSyllable == -1) {
|
||||||
|
karaoke->SetSyllable(nsyls-1);
|
||||||
|
}
|
||||||
|
if (karaoke->curSyllable >= nsyls) karaoke->curSyllable = nsyls-1;
|
||||||
|
|
||||||
|
// Get positions
|
||||||
|
int pos = karaoke->syllables.at(karaoke->curSyllable).position;
|
||||||
|
int len = karaoke->syllables.at(karaoke->curSyllable).length;
|
||||||
|
karStart = GetXAtMS(curStartMS+pos*10);
|
||||||
|
karEnd = GetXAtMS(curStartMS+pos*10+len*10);
|
||||||
|
|
||||||
|
// Cap
|
||||||
|
if (cap) {
|
||||||
|
if (karStart < 0) karStart = 0;
|
||||||
|
if (karEnd < 0) karEnd = 0;
|
||||||
|
if (karStart >= w) karStart = w-1;
|
||||||
|
if (karEnd >= w) karEnd = w-1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (karaoke->curSyllable >= nsyls) karaoke->curSyllable = nsyls-1;
|
catch (...) {
|
||||||
|
|
||||||
// Get positions
|
|
||||||
int pos = karaoke->syllables.at(karaoke->curSyllable).position;
|
|
||||||
int len = karaoke->syllables.at(karaoke->curSyllable).length;
|
|
||||||
karStart = GetXAtMS(curStartMS+pos*10);
|
|
||||||
karEnd = GetXAtMS(curStartMS+pos*10+len*10);
|
|
||||||
|
|
||||||
// Cap
|
|
||||||
if (cap) {
|
|
||||||
if (karStart < 0) karStart = 0;
|
|
||||||
if (karEnd < 0) karEnd = 0;
|
|
||||||
if (karStart >= w) karStart = w-1;
|
|
||||||
if (karEnd >= w) karEnd = w-1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -881,22 +885,23 @@ void AudioDisplay::GetTimesDialogue(int &start,int &end) {
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Get samples of selection
|
// Get samples of selection
|
||||||
void AudioDisplay::GetTimesSelection(int &start,int &end) {
|
void AudioDisplay::GetTimesSelection(int &start,int &end) {
|
||||||
if (!dialogue) {
|
start = 0;
|
||||||
start = 0;
|
end = 0;
|
||||||
end = 0;
|
if (!dialogue) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (karaoke->enabled) {
|
try {
|
||||||
int pos = karaoke->syllables.at(karaoke->curSyllable).position;
|
if (karaoke->enabled) {
|
||||||
int len = karaoke->syllables.at(karaoke->curSyllable).length;
|
int pos = karaoke->syllables.at(karaoke->curSyllable).position;
|
||||||
start = curStartMS+pos*10;
|
int len = karaoke->syllables.at(karaoke->curSyllable).length;
|
||||||
end = curStartMS+pos*10+len*10;
|
start = curStartMS+pos*10;
|
||||||
}
|
end = curStartMS+pos*10+len*10;
|
||||||
else {
|
}
|
||||||
start = curStartMS;
|
else {
|
||||||
end = curEndMS;
|
start = curStartMS;
|
||||||
|
end = curEndMS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch (...) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1600,16 +1605,16 @@ void AudioDisplay::ChangeLine(int delta) {
|
||||||
if (dialogue) {
|
if (dialogue) {
|
||||||
// Get next line number and make sure it's within bounds
|
// Get next line number and make sure it's within bounds
|
||||||
int next = line_n+delta;
|
int next = line_n+delta;
|
||||||
if (next == -1) return;
|
if (next == -1) next = 0;
|
||||||
if (next == grid->GetRows()) return;
|
if (next == grid->GetRows()) next = grid->GetRows() - 1;
|
||||||
|
|
||||||
// Set stuff
|
// Set stuff
|
||||||
NeedCommit = false;
|
NeedCommit = false;
|
||||||
dialogue = NULL;
|
dialogue = NULL;
|
||||||
grid->editBox->SetToLine(next);
|
grid->editBox->SetToLine(next);
|
||||||
grid->SelectRow(next);
|
grid->SelectRow(next);
|
||||||
if (!dialogue)
|
if (!dialogue) UpdateImage(true);
|
||||||
UpdateImage(true);
|
else UpdateImage(false);
|
||||||
line_n = next;
|
line_n = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1620,10 +1625,14 @@ void AudioDisplay::ChangeLine(int delta) {
|
||||||
void AudioDisplay::Next() {
|
void AudioDisplay::Next() {
|
||||||
// Karaoke
|
// Karaoke
|
||||||
if (karaoke->enabled) {
|
if (karaoke->enabled) {
|
||||||
karaoke->curSyllable++;
|
int nextSyl = karaoke->curSyllable+1;
|
||||||
|
bool needsUpdate = true;
|
||||||
|
|
||||||
// Last syllable; jump to next
|
// Last syllable; jump to next
|
||||||
if (karaoke->curSyllable >= (signed int)karaoke->syllables.size()) {
|
if (nextSyl >= (signed int)karaoke->syllables.size()) {
|
||||||
|
// Already last?
|
||||||
|
if (line_n == grid->GetRows()-1) return;
|
||||||
|
|
||||||
if (NeedCommit) {
|
if (NeedCommit) {
|
||||||
int result = wxMessageBox(_("Do you want to commit your changes? If you choose No, they will be discarded."),_("Commit?"),wxYES_NO | wxCANCEL | wxICON_QUESTION);
|
int result = wxMessageBox(_("Do you want to commit your changes? If you choose No, they will be discarded."),_("Commit?"),wxYES_NO | wxCANCEL | wxICON_QUESTION);
|
||||||
//int result = wxNO;
|
//int result = wxNO;
|
||||||
|
@ -1635,13 +1644,15 @@ void AudioDisplay::Next() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nextSyl = 0;
|
||||||
karaoke->curSyllable = 0;
|
karaoke->curSyllable = 0;
|
||||||
ChangeLine(1);
|
ChangeLine(1);
|
||||||
|
needsUpdate = false;
|
||||||
}
|
}
|
||||||
else Update();
|
|
||||||
|
|
||||||
// Set syllable
|
// Set syllable
|
||||||
karaoke->SetSyllable(karaoke->curSyllable);
|
karaoke->SetSyllable(nextSyl);
|
||||||
|
if (needsUpdate) Update();
|
||||||
int start=0,end=0;
|
int start=0,end=0;
|
||||||
GetTimesSelection(start,end);
|
GetTimesSelection(start,end);
|
||||||
Play(start,end);
|
Play(start,end);
|
||||||
|
@ -1659,10 +1670,14 @@ void AudioDisplay::Next() {
|
||||||
void AudioDisplay::Prev() {
|
void AudioDisplay::Prev() {
|
||||||
// Karaoke
|
// Karaoke
|
||||||
if (karaoke->enabled) {
|
if (karaoke->enabled) {
|
||||||
karaoke->curSyllable--;
|
int nextSyl = karaoke->curSyllable-1;
|
||||||
|
bool needsUpdate = true;
|
||||||
|
|
||||||
// First syllable; jump line
|
// First syllable; jump line
|
||||||
if (karaoke->curSyllable < 0) {
|
if (nextSyl < 0) {
|
||||||
|
// Already first?
|
||||||
|
if (line_n == 0) return;
|
||||||
|
|
||||||
if (NeedCommit) {
|
if (NeedCommit) {
|
||||||
int result = wxMessageBox(_("Do you want to commit your changes? If you choose No, they will be discarded."),_("Commit?"),wxYES_NO | wxCANCEL);
|
int result = wxMessageBox(_("Do you want to commit your changes? If you choose No, they will be discarded."),_("Commit?"),wxYES_NO | wxCANCEL);
|
||||||
if (result == wxYES) {
|
if (result == wxYES) {
|
||||||
|
@ -1673,12 +1688,14 @@ void AudioDisplay::Prev() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
karaoke->curSyllable = -1;
|
||||||
ChangeLine(-1);
|
ChangeLine(-1);
|
||||||
|
needsUpdate = false;
|
||||||
}
|
}
|
||||||
else Update();
|
|
||||||
|
|
||||||
// Set syllable
|
// Set syllable
|
||||||
karaoke->SetSyllable(karaoke->curSyllable);
|
karaoke->SetSyllable(nextSyl);
|
||||||
|
if (needsUpdate) Update();
|
||||||
int start=0,end=0;
|
int start=0,end=0;
|
||||||
GetTimesSelection(start,end);
|
GetTimesSelection(start,end);
|
||||||
Play(start,end);
|
Play(start,end);
|
||||||
|
|
|
@ -97,8 +97,10 @@ bool AudioKaraoke::LoadFromDialogue(AssDialogue *_diag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
SetSelection(curSyllable);
|
//if (curSyllable < 0) curSyllable = syllables.size()-1;
|
||||||
Refresh(false);
|
//if (curSyllable >= (signed) syllables.size()) curSyllable = 0;
|
||||||
|
//SetSelection(curSyllable);
|
||||||
|
//Refresh(false);
|
||||||
return !hasKar;
|
return !hasKar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,6 +251,8 @@ bool AudioKaraoke::ParseDialogue(AssDialogue *curDiag) {
|
||||||
////////////////
|
////////////////
|
||||||
// Set syllable
|
// Set syllable
|
||||||
void AudioKaraoke::SetSyllable(int n) {
|
void AudioKaraoke::SetSyllable(int n) {
|
||||||
|
if (n == -1) n = syllables.size()-1;
|
||||||
|
if (n >= syllables.size()) n = 0;
|
||||||
curSyllable = n;
|
curSyllable = n;
|
||||||
startClickSyl = n;
|
startClickSyl = n;
|
||||||
SetSelection(n);
|
SetSelection(n);
|
||||||
|
|
|
@ -167,9 +167,12 @@ int AegisubApp::OnRun() {
|
||||||
wxMessageBox(err, _T("Unhandled exception"), wxOK | wxICON_ERROR, NULL);
|
wxMessageBox(err, _T("Unhandled exception"), wxOK | wxICON_ERROR, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (wchar_t *error) {
|
catch (wxChar *error) {
|
||||||
wxString err (error,wxConvUTF8);
|
wxMessageBox(error, _T("Unhandled exception"), wxOK | wxICON_ERROR, NULL);
|
||||||
wxMessageBox(err, _T("Unhandled exception"), wxOK | wxICON_ERROR, NULL);
|
}
|
||||||
|
|
||||||
|
catch (std::exception e) {
|
||||||
|
wxMessageBox(wxString(_T("std::exception: ")) + wxString(e.what(),wxConvUTF8), _T("Unhandled exception"), wxOK | wxICON_ERROR, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (...) {
|
catch (...) {
|
||||||
|
|
Loading…
Reference in New Issue