From 2c7fe998762bd087955c0989f078746b89628181 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Mon, 5 Feb 2018 03:38:47 +0100 Subject: [PATCH] =?utf8?q?remember=20last=20model=20opened=20folder=20?= =?utf8?q?=E2=80=9CLastModelFolder=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- radiant/entity.cpp | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/radiant/entity.cpp b/radiant/entity.cpp index 797927d0..375e54d6 100644 --- a/radiant/entity.cpp +++ b/radiant/entity.cpp @@ -40,6 +40,8 @@ #include "select.h" #include "map.h" #include "preferences.h" +#include "preferencesystem.h" +#include "stringio.h" #include "gtkdlgs.h" #include "mainframe.h" #include "qe3.h" @@ -536,20 +538,32 @@ void Entity_setColour() } } -const char *misc_model_dialog(ui::Widget parent) -{ - StringOutputStream buffer(1024); - - buffer << g_qeglobals.m_userGamePath.c_str() << "models/"; +CopiedString g_strLastModelFolder = ""; - if (!file_readable(buffer.c_str())) { - // just go to fsmain - buffer.clear(); - buffer << g_qeglobals.m_userGamePath.c_str() << "/"; +const char *getLastModelFolderPath() +{ + if (g_strLastModelFolder.empty()) { + GlobalPreferenceSystem().registerPreference("LastModelFolder", make_property_string(g_strLastModelFolder)); + if (g_strLastModelFolder.empty()) { + StringOutputStream buffer(1024); + buffer << g_qeglobals.m_userGamePath.c_str() << "models/"; + if (!file_readable(buffer.c_str())) { + // just go to fsmain + buffer.clear(); + buffer << g_qeglobals.m_userGamePath.c_str() << "/"; + } + g_strLastModelFolder = buffer.c_str(); + } } + return g_strLastModelFolder.c_str(); +} + +const char *misc_model_dialog(ui::Widget parent) +{ + const char *filename = parent.file_dialog(TRUE, "Choose Model", getLastModelFolderPath(), ModelLoader::Name()); - const char *filename = parent.file_dialog(TRUE, "Choose Model", buffer.c_str(), ModelLoader::Name()); - if (filename != 0) { + if (filename != NULL) { + g_strLastModelFolder = g_path_get_dirname(filename); // use VFS to get the correct relative path const char *relative = path_make_relative(filename, GlobalFileSystem().findRoot(filename)); if (relative == filename) { @@ -603,9 +617,6 @@ void Entity_constructMenu(ui::Menu menu) } -#include "preferencesystem.h" -#include "stringio.h" - void Entity_Construct() { GlobalCommands_insert("EntityColor", makeCallbackF(Entity_setColour), Accelerator('K')); -- 2.39.2