mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-08 23:36:22 +00:00
gui: Make file menu paths use path delimiters uniformly (bug #23224)
In particular, this forces using \ on Windows.
This commit is contained in:
parent
2a8bc5b339
commit
c46f05fe29
@ -24,17 +24,34 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
std::vector<std::string> empty_string_vector;
|
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 {
|
namespace gui {
|
||||||
|
|
||||||
static const std::string dir_picture("misc/folder-icon.png");
|
static const std::string dir_picture("misc/folder-icon.png");
|
||||||
static const std::string path_up("..");
|
static const std::string path_up("..");
|
||||||
|
#ifdef _WIN32
|
||||||
|
const char file_menu::path_delim('\\');
|
||||||
|
#else
|
||||||
const char file_menu::path_delim('/');
|
const char file_menu::path_delim('/');
|
||||||
|
#endif
|
||||||
|
|
||||||
file_menu::file_menu(CVideo &disp, std::string start_file)
|
file_menu::file_menu(CVideo &disp, std::string start_file)
|
||||||
: menu(disp, empty_string_vector, false),
|
: 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),
|
chosen_file_(start_file), last_selection_(-1),
|
||||||
type_a_head_(-1)
|
type_a_head_(-1)
|
||||||
{
|
{
|
||||||
@ -162,7 +179,7 @@ void file_menu::change_directory(const std::string& path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
current_dir_ = path;
|
current_dir_ = uniform_path(path);
|
||||||
chosen_file_ = current_dir_;
|
chosen_file_ = current_dir_;
|
||||||
last_selection_ = -1;
|
last_selection_ = -1;
|
||||||
update_file_lists();
|
update_file_lists();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user