Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the same filename conversion when loading and saving files. #135

Merged
merged 1 commit into from
Jan 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions src/MyFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ MyFrame::MyFrame()
m_isTimerRunning(false),
m_autoStartTimer(false),
m_autoSaveTimer(this, ID_AUTOSAVE_TIMER),
m_autoSaveInterval(0),
m_autoSaveInterval(0),
m_showCompletionStatus(true),
m_mgr(),
m_fileHistory(10, ID_FILE_HISTORY_1)
Expand Down Expand Up @@ -434,9 +434,9 @@ MyFrame::MyFrame()
SetIcon(wxIcon(xword_xpm));
#endif // __WXMSW__ && ! __WXPM__

// Try loading the previously saved layout, otherwise default to Full View
// Try loading the previously saved layout, otherwise default to Full View
if (! LoadLayout("(Previous)"))
LoadLayout("Full View");
LoadLayout("Full View");

// Show a blank puzzle
ShowPuzzle();
Expand Down Expand Up @@ -680,26 +680,26 @@ MyFrame::DoSavePuzzle(const wxString & filename,
m_puz.SetTime(m_time);
m_puz.SetTimerRunning(IsTimerRunning());

std::string fn = puz::encode_utf8(wx2puz(filename));
std::string fn = wx2file(filename);
if (! puz::Puzzle::CanSave(fn))
fn.clear();

if (fn.empty())
fn = puz::encode_utf8(wx2puz(
fn = wx2file(
wxFileSelector(
_T("Save Puzzle As"),
wxEmptyString, wxEmptyString, _T("puz"),
GetSaveTypeString(),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT)
));
);

if (fn.empty())
return;

wxStopWatch sw;

m_puz.Save(fn, handler);
m_filename = puz2wx(puz::decode_utf8(fn));
m_filename = fn;
m_isModified = false;

EnableSave(false);
Expand Down Expand Up @@ -1150,10 +1150,10 @@ MyFrame::ShowNotes()

void
MyFrame::CheckPuzzle()
{
if (!m_showCompletionStatus) {
m_status->SetAlert("");
return;
{
if (!m_showCompletionStatus) {
m_status->SetAlert("");
return;
}
GridStats stats;
m_XGridCtrl->GetStats(&stats);
Expand Down Expand Up @@ -1490,7 +1490,7 @@ MyFrame::ManageWindows()
.MinSize(50, 50)
.Layer(2)
.Top()
.Resizable()
.Resizable()
.Caption(_T("Clue Prompt"))
.Name(_T("Clue")) );

Expand Down Expand Up @@ -1681,7 +1681,7 @@ MyFrame::LoadConfig()

// Misc
config.Timer.autoStart.AddCallback(this, &MyFrame::SetAutoStartTimer);
config.autoSaveInterval.AddCallback(this, &MyFrame::SetAutoSaveInterval);
config.autoSaveInterval.AddCallback(this, &MyFrame::SetAutoSaveInterval);
config.Status.showCompletionStatus.AddCallback(this, &MyFrame::SetShowCompletionStatus);

// File History
Expand Down Expand Up @@ -2531,18 +2531,18 @@ MyFrame::OnTimerNotify(wxTimerEvent & WXUNUSED(evt))
{
m_XGridCtrl->SetPaused(true);
}
}

// Status bar
//-----------
void
MyFrame::SetShowCompletionStatus(bool show)
{
m_showCompletionStatus = show;
if (m_puz.IsOk())
{
CheckPuzzle();
}
}
// Status bar
//-----------
void
MyFrame::SetShowCompletionStatus(bool show)
{
m_showCompletionStatus = show;
if (m_puz.IsOk())
{
CheckPuzzle();
}
}

// AutoSave
Expand Down