From ca19ee8053d8fee106a1f5fc861d053e8a9adc4f Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 15 Dec 2014 00:35:32 +0100 Subject: [PATCH] refs #358, added a utility class for FS --- src/blacksim/fscommon/fscommonutil.cpp | 49 ++++++++++++++++++++++++++ src/blacksim/fscommon/fscommonutil.h | 38 ++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 src/blacksim/fscommon/fscommonutil.cpp create mode 100644 src/blacksim/fscommon/fscommonutil.h diff --git a/src/blacksim/fscommon/fscommonutil.cpp b/src/blacksim/fscommon/fscommonutil.cpp new file mode 100644 index 000000000..1cb559613 --- /dev/null +++ b/src/blacksim/fscommon/fscommonutil.cpp @@ -0,0 +1,49 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "blackmisc/project.h" +#include "fscommonutil.h" +#include +#include + +using namespace BlackMisc; + +namespace BlackSim +{ + namespace FsCommon + { + + QString CFsCommonUtil::fsxDirFromRegistry() + { + QString fsxPath; + if (CProject::isCompiledWithFsxSupport()) + { + // set FSX path + QSettings fsxRegistry("HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", QSettings::NativeFormat); + fsxPath = fsxRegistry.value("AppPath").toString().trimmed(); + if (fsxPath.isEmpty()) + { + // another trial + QSettings fsxRegistry("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", QSettings::NativeFormat); + fsxPath = fsxRegistry.value("SetupPath").toString().trimmed(); + } + } + return fsxPath; + } + + QString CFsCommonUtil::fsxSimObjectsDirFromRegistry() + { + QString fsxPath = fsxDirFromRegistry(); + if (fsxPath.isEmpty()) { return ""; } + fsxPath = QDir(fsxPath).filePath("SimObjects"); + return fsxPath; + } + + } // namespace +} // namespace diff --git a/src/blacksim/fscommon/fscommonutil.h b/src/blacksim/fscommon/fscommonutil.h new file mode 100644 index 000000000..25077f4b6 --- /dev/null +++ b/src/blacksim/fscommon/fscommonutil.h @@ -0,0 +1,38 @@ +/* Copyright (C) 2013 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef FSCOMMONUTIL_H +#define FSCOMMONUTIL_H + +#include + +namespace BlackSim +{ + namespace FsCommon + { + //! FS9/X utils + class CFsCommonUtil + { + public: + CFsCommonUtil(); + + //! FSX directory obtained from registry + static QString fsxDirFromRegistry(); + + //! FSX's simObject directory from registry + static QString fsxSimObjectsDirFromRegistry(); + + }; + + } // namespace +} // namespace + +#endif // guard