diff --git a/aegisub/dialog_splash.cpp b/aegisub/dialog_splash.cpp index 9bd625792..cbe6f6f61 100644 --- a/aegisub/dialog_splash.cpp +++ b/aegisub/dialog_splash.cpp @@ -58,8 +58,11 @@ SplashScreen::SplashScreen(wxWindow *parent) // Center on current display if (wxDisplay::GetCount() < 1) CentreOnParent(); else { + // Get parent position + wxRect parRect = parent->GetRect(); + // Get display number - int point = wxDisplay::GetFromPoint(parent->GetScreenPosition()); + int point = wxDisplay::GetFromPoint(wxPoint(parRect.GetX() + parRect.GetWidth()/2,parRect.GetY() + parRect.GetHeight()/2)); if (point == wxNOT_FOUND) point = 0; // Get display size diff --git a/aegisub/spellchecker_hunspell.cpp b/aegisub/spellchecker_hunspell.cpp index 3a62a19db..74cacf8fb 100644 --- a/aegisub/spellchecker_hunspell.cpp +++ b/aegisub/spellchecker_hunspell.cpp @@ -42,6 +42,8 @@ #include #include #include +#include +#include #include "spellchecker_hunspell.h" #include "main.h" #include "utils.h" @@ -60,10 +62,19 @@ HunspellSpellChecker::HunspellSpellChecker() { ////////////// // Destructor HunspellSpellChecker::~HunspellSpellChecker() { + Reset(); +} + + +///////// +// Reset +void HunspellSpellChecker::Reset() { delete hunspell; hunspell = NULL; delete conv; conv = NULL; + affpath.Clear(); + dicpath.Clear(); } @@ -78,7 +89,51 @@ bool HunspellSpellChecker::CanAddWord(wxString word) { ////////////////////////// // Add word to dictionary void HunspellSpellChecker::AddWord(wxString word) { - if (hunspell) hunspell->put_word(word.mb_str(*conv)); + // Dictionary OK? + if (!hunspell) return; + + // Add to currently loaded file + hunspell->put_word(word.mb_str(*conv)); + + // Load dictionary + wxArrayString dic; + wxString curLine; + if (!dicpath.IsEmpty()) { // Even if you ever want to remove this "if", keep the braces, so the stream closes at the end + bool first = true; + bool added = false; + wxFileInputStream in(dicpath); + if (!in.IsOk()) return; + wxTextInputStream textIn(in,_T(" \t"),*conv); + + // Read it + while (in.CanRead() && !in.Eof()) { + // Read line + curLine = textIn.ReadLine(); + curLine.Trim(); + + // First + if (first) { + first = false; + if (curLine.IsNumber()) continue; + } + + // See if word to be added goes here + if (!added && curLine.Lower() > word.Lower()) { + dic.Add(word); + added = true; + } + + // Add to memory dictionary + dic.Add(curLine); + } + } + + // Write back to disk + wxFileOutputStream out(dicpath); + if (!out.IsOk()) return; + wxTextOutputStream textOut(out,wxEOL_UNIX,*conv); + textOut.WriteString(wxString::Format(_T("%i"),dic.Count())+_T("\n")); + for (unsigned int i=0;i