mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 16:55:36 +08:00
refs #358, added a utility class for FS
This commit is contained in:
49
src/blacksim/fscommon/fscommonutil.cpp
Normal file
49
src/blacksim/fscommon/fscommonutil.cpp
Normal file
@@ -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 <QSettings>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
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
|
||||||
38
src/blacksim/fscommon/fscommonutil.h
Normal file
38
src/blacksim/fscommon/fscommonutil.h
Normal file
@@ -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 <QString>
|
||||||
|
|
||||||
|
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
|
||||||
Reference in New Issue
Block a user