gui: Make file menu paths use path delimiters uniformly (bug #23224)
In particular, this forces using \ on Windows.
This commit is contained in:
parent
1ee80160fc
commit
2bd381617a
2 changed files with 22 additions and 2 deletions
|
@ -4,6 +4,9 @@ Version 1.12.2+dev:
|
|||
* Miscellaneous and bug fixes:
|
||||
* Fixed bug #23445: set default build type in cmake to "Release" to ensure
|
||||
that the game is not unoptimized
|
||||
* Made the file chooser dialog (used for e.g. loading maps in the editor)
|
||||
use uniform path delimiters on Windows, fixing issues with browsing to
|
||||
parent directories (bug #23224).
|
||||
|
||||
Version 1.12.2:
|
||||
* Security fixes:
|
||||
|
|
|
@ -24,17 +24,34 @@
|
|||
|
||||
namespace {
|
||||
std::vector<std::string> empty_string_vector;
|
||||
|
||||
|
||||
std::string uniform_path(const std::string& path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::string res = path;
|
||||
std::replace(res.begin(), res.end(), '/', '\\');
|
||||
return res;
|
||||
#else
|
||||
return path;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace gui {
|
||||
|
||||
static const std::string dir_picture("misc/folder-icon.png");
|
||||
static const std::string path_up("..");
|
||||
#ifdef _WIN32
|
||||
const char file_menu::path_delim('\\');
|
||||
#else
|
||||
const char file_menu::path_delim('/');
|
||||
#endif
|
||||
|
||||
file_menu::file_menu(CVideo &disp, std::string start_file)
|
||||
: menu(disp, empty_string_vector, false),
|
||||
current_dir_(get_path(start_file)),
|
||||
current_dir_(uniform_path(get_path(start_file))),
|
||||
chosen_file_(start_file), last_selection_(-1),
|
||||
type_a_head_(-1)
|
||||
{
|
||||
|
@ -162,7 +179,7 @@ void file_menu::change_directory(const std::string& path) {
|
|||
}
|
||||
|
||||
} else {
|
||||
current_dir_ = path;
|
||||
current_dir_ = uniform_path(path);
|
||||
chosen_file_ = current_dir_;
|
||||
last_selection_ = -1;
|
||||
update_file_lists();
|
||||
|
|
Loading…
Add table
Reference in a new issue