forked from mia/Aegisub
More fixes for athenasub.
Originally committed to SVN as r2437.
This commit is contained in:
parent
b81c534aab
commit
3496022b15
4 changed files with 17 additions and 16 deletions
|
@ -178,6 +178,10 @@
|
||||||
RelativePath=".\include\athenasub\athenasub.h"
|
RelativePath=".\include\athenasub\athenasub.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\athenasub\athenatime.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\athenasub\athenawin.h"
|
RelativePath=".\include\athenasub\athenawin.h"
|
||||||
>
|
>
|
||||||
|
|
|
@ -44,9 +44,9 @@ namespace Athenasub {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Time() { ms = 0; }
|
Time() { ms = 0; }
|
||||||
Time(int milliseconds) { ms = milliseconds; }
|
Time(int milliseconds) { SetMS(milliseconds); }
|
||||||
|
|
||||||
inline void SetMS(int milliseconds) { ms = milliseconds; }
|
inline void SetMS(int milliseconds) { ms = milliseconds > 0 ? milliseconds : 0; }
|
||||||
inline int GetMS() const { return ms; }
|
inline int GetMS() const { return ms; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,12 @@ String GetTimeString(const Time& time,int ms_precision,int h_precision)
|
||||||
else if (ms_precision == 1) _ms /= 100;
|
else if (ms_precision == 1) _ms /= 100;
|
||||||
else if (ms_precision == 0) _ms = 0;
|
else if (ms_precision == 0) _ms = 0;
|
||||||
|
|
||||||
|
// Asserts
|
||||||
|
assert(h >= 0 && h <= 9);
|
||||||
|
assert(min >= 0 && min <= 59);
|
||||||
|
assert(s >= 0 && s <= 59);
|
||||||
|
assert(_ms >= 0 && _ms <= 999);
|
||||||
|
|
||||||
// Get write buffer
|
// Get write buffer
|
||||||
String final;
|
String final;
|
||||||
size_t size = 7+h_precision+ms_precision;
|
size_t size = 7+h_precision+ms_precision;
|
||||||
|
@ -110,7 +116,7 @@ String GetTimeString(const Time& time,int ms_precision,int h_precision)
|
||||||
final.WriteNumber(temp,_ms,ms_precision,pos);
|
final.WriteNumber(temp,_ms,ms_precision,pos);
|
||||||
|
|
||||||
// Write terminator
|
// Write terminator
|
||||||
final.WriteText("\0",1,pos);
|
//final.WriteText("\0",1,pos);
|
||||||
|
|
||||||
// Restore string's state and return
|
// Restore string's state and return
|
||||||
final.SetSize(pos-1);
|
final.SetSize(pos-1);
|
||||||
|
|
|
@ -86,16 +86,15 @@ int main()
|
||||||
// Save subtitles
|
// Save subtitles
|
||||||
cout << "Saving file... ";
|
cout << "Saving file... ";
|
||||||
timer.Start();
|
timer.Start();
|
||||||
control->SaveFile(L"subs_out.ass",L"UTF-8");
|
control->SaveFile("subs_out.ass","UTF-8");
|
||||||
timer.Pause();
|
timer.Pause();
|
||||||
cout << "Done in " << timer.Time() << " ms.\n";
|
cout << "Done in " << timer.Time() << " ms.\n";
|
||||||
system("pause");
|
|
||||||
|
|
||||||
// Issue an action
|
// Issue an action
|
||||||
#ifdef WXDEBUG
|
#ifdef WXDEBUG
|
||||||
int n = 1;
|
|
||||||
#else
|
|
||||||
int n = 1000;
|
int n = 1000;
|
||||||
|
#else
|
||||||
|
int n = 1;
|
||||||
#endif
|
#endif
|
||||||
cout << "Executing action " << n << " times... ";
|
cout << "Executing action " << n << " times... ";
|
||||||
timer.Start();
|
timer.Start();
|
||||||
|
@ -117,8 +116,6 @@ int main()
|
||||||
timer.Pause();
|
timer.Pause();
|
||||||
cout << "Done in " << timer.Time() << " ms.\n";
|
cout << "Done in " << timer.Time() << " ms.\n";
|
||||||
|
|
||||||
system("pause");
|
|
||||||
|
|
||||||
// Rollback
|
// Rollback
|
||||||
cout << "Undoing " << n-1 << " times... ";
|
cout << "Undoing " << n-1 << " times... ";
|
||||||
timer.Start();
|
timer.Start();
|
||||||
|
@ -128,8 +125,6 @@ int main()
|
||||||
timer.Pause();
|
timer.Pause();
|
||||||
cout << "Done in " << timer.Time() << " ms.\n";
|
cout << "Done in " << timer.Time() << " ms.\n";
|
||||||
|
|
||||||
system("pause");
|
|
||||||
|
|
||||||
// Undo
|
// Undo
|
||||||
n = 1000;
|
n = 1000;
|
||||||
cout << "Undoing and redoing " << n << " times... ";
|
cout << "Undoing and redoing " << n << " times... ";
|
||||||
|
@ -143,21 +138,17 @@ int main()
|
||||||
|
|
||||||
// Get style test
|
// Get style test
|
||||||
ConstStyle style = control->GetStyle("japro1_star");
|
ConstStyle style = control->GetStyle("japro1_star");
|
||||||
cout << "Style " << style->GetName().c_str() << " font is " << style->GetFontName().c_str() << " " << style->GetFontSize() << ".\n";
|
cout << "Style " << style->GetName() << " font is " << style->GetFontName() << " " << style->GetFontSize() << ".\n";
|
||||||
|
|
||||||
// Save a few more
|
// Save a few more
|
||||||
control->SaveFile("subs_out2.ass","UTF-8");
|
control->SaveFile("subs_out2.ass","UTF-8");
|
||||||
control->Undo();
|
control->Undo();
|
||||||
control->SaveFile("subs_out3.ass","UTF-8");
|
control->SaveFile("subs_out3.ass","UTF-8");
|
||||||
|
|
||||||
system("pause");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (std::exception &e) {
|
catch (std::exception &e) {
|
||||||
cout << "\n\nException: " << e.what() << endl << endl;
|
cout << "\n\nException: " << e.what() << endl << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
system("pause");
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue