diff --git a/aegisub/main.cpp b/aegisub/main.cpp index 8d2fc9caf..c9ce86a0f 100644 --- a/aegisub/main.cpp +++ b/aegisub/main.cpp @@ -135,6 +135,14 @@ bool AegisubApp::OnInit() { } +//////// +// Exit +int AegisubApp::OnExit() { + Options.Clear(); + return wxApp::OnExit(); +} + + #ifndef _DEBUG /////////////////////// // Unhandled exception diff --git a/aegisub/main.h b/aegisub/main.h index 9ec2aa3f4..c1759cda5 100644 --- a/aegisub/main.h +++ b/aegisub/main.h @@ -75,6 +75,7 @@ public: void AssociateType(wxString type); bool OnInit(); + int OnExit(); int OnRun(); #ifdef __WXMAC__ diff --git a/aegisub/options.cpp b/aegisub/options.cpp index 9fdec6af7..775783bd7 100644 --- a/aegisub/options.cpp +++ b/aegisub/options.cpp @@ -59,7 +59,15 @@ OptionsManager::OptionsManager() { ////////////// // Destructor OptionsManager::~OptionsManager() { + Clear(); +} + + +///////// +// Clear +void OptionsManager::Clear() { opt.clear(); + optType.clear(); } diff --git a/aegisub/options.h b/aegisub/options.h index 047e16b00..db45cab35 100644 --- a/aegisub/options.h +++ b/aegisub/options.h @@ -73,6 +73,7 @@ public: OptionsManager(); ~OptionsManager(); + void Clear(); void SetFile(wxString file); void Save(); void Load(); diff --git a/aegisub/text_file_reader.cpp b/aegisub/text_file_reader.cpp index a4f0279bc..4c06e6755 100644 --- a/aegisub/text_file_reader.cpp +++ b/aegisub/text_file_reader.cpp @@ -203,7 +203,7 @@ wxString TextFileReader::ReadLineFromFile() { // Read ASCII/UTF-8 line from file else { #ifdef WIN32 - char *buffer = new char[512]; + char buffer[512]; while (1) { buffer[511] = '\1'; if (fgets(buffer, 512, file)) { diff --git a/aegisub/video_display_visual.cpp b/aegisub/video_display_visual.cpp index 148a19138..31f573549 100644 --- a/aegisub/video_display_visual.cpp +++ b/aegisub/video_display_visual.cpp @@ -988,16 +988,23 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) { // Rotate Z else if (hold == 2) { - // Find screen angle + // Find angle float screenAngle = atan2(double(lineOrgY-y*sh/h),double(x*sw/w-lineOrgX)) * 180.0 / 3.1415926535897932; + curAngle = screenAngle - startAngle + origAngle; + while (curAngle < 0.0f) curAngle += 360.0f; + while (curAngle >= 360.0f) curAngle -= 360.0f; + + // Snap + if (event.ShiftDown()) { + curAngle = (float)((int)((curAngle+15.0f)/30.0f))*30.0f; + if (curAngle == 360.0f) curAngle = 0.0f; + } // Update - curAngle = screenAngle - startAngle + origAngle; - while (curAngle < 0.0) curAngle += 360.0; - while (curAngle >= 360.0) curAngle -= 360.0; if (realTime) { AssLimitToVisibleFilter::SetFrame(frame_n); - grid->editBox->SetOverride(_T("\\frz"),PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle)),0); + wxString param = PrettyFloat(wxString::Format(_T("(%0.3f)"),curAngle)); + grid->editBox->SetOverride(_T("\\frz"),param,0); grid->editBox->CommitText(true); grid->CommitChanges(false,true); } @@ -1017,6 +1024,14 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) { while (curAngle2 < 0.0) curAngle2 += 360.0; while (curAngle2 >= 360.0) curAngle2 -= 360.0; + // Oh Snap + if (event.ShiftDown()) { + curAngle = (float)((int)((curAngle+15.0f)/30.0f))*30.0f; + curAngle2 = (float)((int)((curAngle2+15.0f)/30.0f))*30.0f; + if (curAngle == 360.0f) curAngle = 0.0f; + if (curAngle2 == 360.0f) curAngle = 0.0f; + } + // Update if (realTime) { AssLimitToVisibleFilter::SetFrame(frame_n); @@ -1035,6 +1050,12 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) { if (curScaleX < 0.0f) curScaleX = 0.0f; if (curScaleY < 0.0f) curScaleY = 0.0f; + // Snap + if (event.ShiftDown()) { + curScaleX = (float)((int)((curScaleX+12.5f)/25.0f))*25.0f; + curScaleY = (float)((int)((curScaleY+12.5f)/25.0f))*25.0f; + } + // Update if (realTime) { AssLimitToVisibleFilter::SetFrame(frame_n);