gui2/game_version: Add logs dir to the Game Version dialog on Windows

This commit is contained in:
Iris Morelle 2021-03-25 21:21:42 -03:00
parent 2e2f551199
commit 00fbce5872
5 changed files with 31 additions and 4 deletions

View file

@ -11,6 +11,7 @@
### Translations
### Units
### User interface
* Added logs folder path to the Game Version dialog on Windows.
### WML Engine
### Miscellaneous and Bug Fixes

View file

@ -12,6 +12,7 @@
horizontal_alignment = "left"
[label]
id = "label_"+{ID_STEM}
definition = "default"
label = {LABEL}
@ -135,6 +136,8 @@
{_GUI_GAME_PATHS_ENTRY cache ( _ "Cache:")}
{_GUI_GAME_PATHS_ENTRY logs ( _ "Logs:")}
[/grid]
[/column]

View file

@ -74,6 +74,9 @@ game_version::game_version()
path_map_["saves"] = filesystem::get_saves_dir();
path_map_["addons"] = filesystem::get_addons_dir();
path_map_["cache"] = filesystem::get_cache_dir();
#ifdef _WIN32
path_map_["logs"] = filesystem::get_logs_dir();
#endif
for(unsigned k = 0; k < game_config::LIB_COUNT; ++k) {
const game_config::LIBRARY_ID lib = game_config::LIBRARY_ID(k);
@ -155,9 +158,9 @@ void game_version::pre_show(window& window)
}
#ifndef _WIN32
grid& w32_options_grid
= find_widget<grid>(&window, "win32_paths", false);
w32_options_grid.set_visible(widget::visibility::invisible);
for(const auto& wid : {"win32_paths", "label_logs", "path_logs", "copy_logs", "browse_logs"}) {
find_widget<widget>(&window, wid, false).set_visible(widget::visibility::invisible);
}
#else
button& stderr_button
= find_widget<button>(&window, "open_stderr", false);

View file

@ -42,6 +42,16 @@ static lg::log_domain log_setup("logsetup");
#define LOG_LS LOG_STREAM(info, log_setup)
#define DBG_LS LOG_STREAM(debug, log_setup)
namespace filesystem
{
std::string get_logs_dir()
{
return filesystem::get_user_data_dir() + "/logs";
}
}
namespace lg
{
@ -514,7 +524,7 @@ void finish_log_file_setup()
return;
}
const std::string log_dir = filesystem::get_user_data_dir() + "/logs";
const std::string log_dir = filesystem::get_logs_dir();
if(!filesystem::file_exists(log_dir) && !filesystem::make_directory(log_dir)) {
log_init_panic(std::string("Could not create logs directory at ") +
log_dir + ".");

View file

@ -38,6 +38,16 @@
* and later versions, requiring UAC virtualization to be enabled).
*/
namespace filesystem
{
/**
* Returns the path to the permanent log storage directory.
*/
std::string get_logs_dir();
}
namespace lg
{