More fixes for athenasub.

Originally committed to SVN as r2437.
This commit is contained in:
Rodrigo Braz Monteiro 2008-11-09 23:08:22 +00:00
parent b81c534aab
commit 3496022b15
4 changed files with 17 additions and 16 deletions

View file

@ -178,6 +178,10 @@
RelativePath=".\include\athenasub\athenasub.h"
>
</File>
<File
RelativePath=".\include\athenasub\athenatime.h"
>
</File>
<File
RelativePath=".\include\athenasub\athenawin.h"
>

View file

@ -44,9 +44,9 @@ namespace Athenasub {
public:
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; }
};

View file

@ -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 == 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
String final;
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);
// Write terminator
final.WriteText("\0",1,pos);
//final.WriteText("\0",1,pos);
// Restore string's state and return
final.SetSize(pos-1);

View file

@ -86,16 +86,15 @@ int main()
// Save subtitles
cout << "Saving file... ";
timer.Start();
control->SaveFile(L"subs_out.ass",L"UTF-8");
control->SaveFile("subs_out.ass","UTF-8");
timer.Pause();
cout << "Done in " << timer.Time() << " ms.\n";
system("pause");
// Issue an action
#ifdef WXDEBUG
int n = 1;
#else
int n = 1000;
#else
int n = 1;
#endif
cout << "Executing action " << n << " times... ";
timer.Start();
@ -117,8 +116,6 @@ int main()
timer.Pause();
cout << "Done in " << timer.Time() << " ms.\n";
system("pause");
// Rollback
cout << "Undoing " << n-1 << " times... ";
timer.Start();
@ -128,8 +125,6 @@ int main()
timer.Pause();
cout << "Done in " << timer.Time() << " ms.\n";
system("pause");
// Undo
n = 1000;
cout << "Undoing and redoing " << n << " times... ";
@ -143,21 +138,17 @@ int main()
// Get style test
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
control->SaveFile("subs_out2.ass","UTF-8");
control->Undo();
control->SaveFile("subs_out3.ass","UTF-8");
system("pause");
}
catch (std::exception &e) {
cout << "\n\nException: " << e.what() << endl << endl;
}
system("pause");
return true;
}