From 7ca1c2237c7e3cd176f91d319810f7f72780be21 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 14 Sep 2016 12:15:11 +0200 Subject: [PATCH] Tweak default capture save behaviour to 'soft' remember dir. Refs #335 * Rather than exclusively always opening at the default directory, it will only do that until a capture has been successfully saved - then it will re-use that previous directory. This is only remembered for as long as RenderDoc is open, thereafter it will revert back to the dir specified in the options. --- renderdocui/Windows/MainWindow.cs | 44 ++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/renderdocui/Windows/MainWindow.cs b/renderdocui/Windows/MainWindow.cs index e948532d9..14a79eede 100644 --- a/renderdocui/Windows/MainWindow.cs +++ b/renderdocui/Windows/MainWindow.cs @@ -961,20 +961,42 @@ namespace renderdocui.Windows saveLogToolStripMenuItem.Enabled = false; } + private string lastSaveCapturePath = ""; + public string GetSavePath() { - try - { - saveDialog.InitialDirectory = m_Core.Config.DefaultCaptureSaveDirectory; - } - catch (Exception) + if(m_Core.Config.DefaultCaptureSaveDirectory != "") { + try + { + if (lastSaveCapturePath == "") + saveDialog.InitialDirectory = m_Core.Config.DefaultCaptureSaveDirectory; + else + saveDialog.InitialDirectory = lastSaveCapturePath; + } + catch (Exception) + { + } } + saveDialog.FileName = ""; + DialogResult res = saveDialog.ShowDialog(); if (res == DialogResult.OK) + { + try + { + string dir = Path.GetDirectoryName(saveDialog.FileName); + if(Directory.Exists(dir)) + lastSaveCapturePath = dir; + } + catch (Exception) + { + } + return saveDialog.FileName; + } return ""; } @@ -1566,17 +1588,9 @@ namespace renderdocui.Windows private bool PromptSaveLog() { - try - { - saveDialog.InitialDirectory = m_Core.Config.DefaultCaptureSaveDirectory; - } - catch (Exception) - { - } + string saveFilename = GetSavePath(); - DialogResult res = saveDialog.ShowDialog(); - - if (res == DialogResult.OK) + if (saveFilename != "") { if (m_Core.IsLogLocal && !File.Exists(m_Core.LogFileName)) {