From 54fdd21a873305c6b4a822f10f22754567f4320f Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 30 Dec 2021 01:26:26 +0200 Subject: [PATCH 34/34] Ruledit: Add Documents path to default save path in Windows See osdn #43370 Signed-off-by: Marko Lindqvist --- configure.ac | 5 ++++- tools/ruledit/tab_misc.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d9bf6c6234..8de596d1c5 100644 --- a/configure.ac +++ b/configure.ac @@ -189,6 +189,8 @@ AC_ARG_ENABLE([server], esac], [server=yes]) AM_CONDITIONAL(SERVER, test x$server = xyes) +ruledit_uuid="" + dnl Host type variable defaults MINGW=no HAIKU=no @@ -206,6 +208,7 @@ case "$host_os" in dnl Without WINSOCK2, use: LIBS="$LIBS -lwsock32" LIBS="${LIBS} -lws2_32" + ruledit_uuid="-luuid" ;; *haiku*) HAIKU=yes @@ -1325,7 +1328,7 @@ if test "x$ruledit" = "xyes" || test "x$ruledit" = "xtest" ; then ruledit_cxxflags=$FC_QT_CXXFLAGS ruledit_libs=$FC_QT_LIBS ruledit=yes - ruledit_libs="$ruledit_libs $MWINDOWS_FLAG" + ruledit_libs="$ruledit_libs $MWINDOWS_FLAG $ruledit_uuid" elif test "x$ruledit" = "xyes" ; then AC_MSG_ERROR([$qt_ver not found for building freeciv-ruledit]) fi diff --git a/tools/ruledit/tab_misc.cpp b/tools/ruledit/tab_misc.cpp index 5a7d68612f..76261ebb90 100644 --- a/tools/ruledit/tab_misc.cpp +++ b/tools/ruledit/tab_misc.cpp @@ -15,6 +15,10 @@ #include #endif +#ifdef FREECIV_MSWINDOWS +#include +#endif + // Qt #include #include @@ -62,6 +66,7 @@ tab_misc::tab_misc(ruledit_gui *ui_in) : QWidget() QPushButton *refresh_button; int row = 0; QTableWidgetItem *item; + char ttbuf[2048]; ui = ui_in; @@ -81,7 +86,31 @@ tab_misc::tab_misc(ruledit_gui *ui_in) : QWidget() save_label->setParent(this); main_layout->addWidget(save_label, row, 0); savedir = new QLineEdit(this); + +#ifdef FREECIV_MSWINDOWS + PWSTR folder_path; + + if (SHGetKnownFolderPath(FOLDERID_Documents, KF_FLAG_DEFAULT, + NULL, &folder_path) == S_OK) { + savedir->setText(QString::fromWCharArray(folder_path) + "\\ruledit-tmp"); + } else { + savedir->setText("ruledit-tmp"); + } + +#else // FREECIV_MSWINDOWS savedir->setText("ruledit-tmp"); +#endif // FREECIV_MSWINDOWS + + /* TRANS: %s%s%s -> path + directory separator ('/' or '\') + path + * Do not translate command '/rulesetdir' name. */ + fc_snprintf(ttbuf, sizeof(ttbuf), + R__("If you want to be able to load the ruleset directly " + "to freeciv, place it as a subdirectory under %s%s%s\n" + "Use server command \"/rulesetdir \" " + "to load it to freeciv."), + freeciv_storage_dir(), DIR_SEPARATOR, DATASUBDIR); + savedir->setToolTip(ttbuf); + savedir->setFocus(); main_layout->addWidget(savedir, row++, 1); save_ver_label = new QLabel(QString::fromUtf8(R__("Version suffix to directory name"))); -- 2.34.1