Skip to content

Commit

Permalink
Merge branch 'release/2.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Pancir committed Nov 28, 2018
2 parents cf572f4 + 191cbbf commit c70f5a6
Show file tree
Hide file tree
Showing 121 changed files with 5,783 additions and 3,467 deletions.
4 changes: 2 additions & 2 deletions cmake/StsProjectDesc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ set(ProjectId ${ProjectName})
# Set it to ON if you are in unstable branch otherwise set it to OFF
set(ProjectVersionSnapshot OFF)
set(ProjectVersionMajor 2)
set(ProjectVersionMinor 5)
set(ProjectVersionMinor 6)
set(ProjectVersionPatch 0)
set(ProjectVersion "${ProjectVersionMajor}.${ProjectVersionMinor}.${ProjectVersionPatch}")

# You can use any string you wish,
# but i will be changed to snapshot if it is enabled.
set(ProjectReleaseType "beta")
set(ProjectReleaseType "")
if (ProjectVersionSnapshot)
set(ProjectReleaseType "snapshot")
endif()
Expand Down
2 changes: 1 addition & 1 deletion conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[requires]
XplnObj/0.8.0@steptosky/stable
XplnObj/0.9.0@steptosky/stable
sts-signals/0.1.2@steptosky/stable
sts-semver/0.2.1@steptosky/stable
jsonformoderncpp/3.1.2@vthiery/stable
Expand Down
11 changes: 10 additions & 1 deletion doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Change-log
===============================================================================

.. note:: Don't forget to see :ref:`backward-compatibility`

2.6.0 (28.11.2018)
-------------------------
- Added: Settings - enable/disable project's DataRefs and Commands ID usage.
- Added: Settings - enable/disable project's DataRefs and Commands Sorting.
- Updated: Datarefs and Commands project format. Symbol '':'' must immediately follow the ID. See the help for more details.
- Fixed: Bug when you try to set custom DataRef or Command key while project's DataRef or Command list is open, the key was set as ``ERROR_DATA_NOT_FOUND``

2.5.0-beta (27.10.2018)
-------------------------
- Added: Dialog DataRefs/Commands selector. I.e. buttons ``drf:`` and ``cmd:`` are implemented now.
Expand All @@ -11,7 +20,7 @@ Change-log
- Updated: Link to the help. It is on-line now.
- Updated: Embedded named and param lights' names lists. Full list you can find here ``X-Plane-root/Resources/bitmaps/world/lites/lights.txt``
- Fixed: Sorting algorithm for LODs. `#9 <https://github.com/steptosky/3DsMax-XplnObj/issues/9>`_
- Fixed: Fixed bug for attribute printing: ``AttrShiny`` ``AttrBlend``. Default/disabled values were not printed when those attributes were enabled and then disabled.
- Fixed: Bug for attribute printing: ``AttrShiny`` ``AttrBlend``. Default/disabled values were not printed when those attributes were enabled and then disabled.

2.4.0-beta (12.09.2018)
-------------------------
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Importing is still under developing and doesn't work properly!

## Dependencies
- [CMake [3.10.0+]](https://cmake.org/) building tool.
- [Conan [1.6+]](https://www.conan.io) package manager.
- [Conan [1.6+]](https://www.conan.io) package manager.
- [Python 3](https://www.python.org) - is needed for the Conan.
- [XplnObj](https://github.com/steptosky/XplnObj) is used via conan.
- [sts-signals](https://github.com/steptosky/sts-signals) is used via conan.
- [sts-semver](https://github.com/steptosky/sts-semver) is used via conan.
Expand Down
77 changes: 15 additions & 62 deletions src/common/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ inline MSTR toMStr(const std::string & str) {
#endif
}

/*!
* \details temporary solution until whole code uses corrected string
* \todo
*/
inline MSTR toMStr(const std::wstring & str) {
#ifdef UNICODE
return MSTR::FromUTF16(str.data(), str.length());
#else
return MSTR(sts::toMbString(str).c_str());
#endif
}

inline std::string fromMStr(const CStr & str) {
return std::string(str.data(), str.Length());
}
Expand All @@ -89,7 +101,9 @@ inline std::string fromMStr(const WStr & str) {
#endif
}

//-------------------------------------------------------------------------
/**************************************************************************************************/
////////////////////////////////////////////////////////////////////////////////////////////////////
/**************************************************************************************************/

inline Path fromMPath(const MaxSDK::Util::Path & path) {
#ifdef UNICODE
Expand All @@ -99,69 +113,8 @@ inline Path fromMPath(const MaxSDK::Util::Path & path) {
return Path(sts::toWString(fromMStr(path.GetString())));
#endif
}

}

/**************************************************************************************************/
////////////////////////////////////////////////////////////////////////////////////////////////////
/**************************************************************************************************/

#if MAX_VERSION_MAJOR > 14

/*!
* \deprecated use xobj::toMStr
*/
inline TSTR toTSTR(TSTR str) { return str; }

/*!
* \deprecated use xobj::toMStr
*/
inline TSTR toTSTR(const char * str) { return sts::toWString(str).c_str(); }

/*!
* \deprecated use xobj::toMStr
*/
inline TSTR toTSTR(const wchar_t * str) { return sts::toWString(str).c_str(); }

/*!
* \deprecated use xobj::toMStr
*/
inline TSTR toTSTR(std::string & str) { return sts::toWString(str).c_str(); }

/*!
* \deprecated use xobj::toMStr
*/
inline TSTR toTSTR(std::wstring & str) { return sts::toWString(str).c_str(); }

#else

/*!
* \deprecated use xobj::toMStr
*/
inline TSTR toTSTR(TSTR str) { return str; }

/*!
* \deprecated use xobj::toMStr
*/
inline TSTR toTSTR(const char * str) { return sts::toMbString(str).c_str(); }

/*!
* \deprecated use xobj::toMStr
*/
inline TSTR toTSTR(const wchar_t * str) { return sts::toMbString(str).c_str(); }

/*!
* \deprecated use xobj::toMStr
*/
inline TSTR toTSTR(std::string & str) { return sts::toMbString(str).c_str(); }

/*!
* \deprecated use xobj::toMStr
*/
inline TSTR toTSTR(std::wstring & str) { return sts::toMbString(str).c_str(); }

#endif

/**************************************************************************************************/
////////////////////////////////////////////////////////////////////////////////////////////////////
/**************************************************************************************************/
2 changes: 1 addition & 1 deletion src/converters/ConverterDummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ INode * ConverterDummy::toMax(const xobj::ObjAbstract * inXObj, const ImportPara
return nullptr;
}

pnode->SetName(toTSTR(inXObj->objectName().c_str()));
pnode->SetName(xobj::toMStr(inXObj->objectName()));
return pnode;
}

Expand Down
2 changes: 1 addition & 1 deletion src/converters/ConverterLod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ INode * ConverterLod::toMax(const xobj::ObjLodGroup & inXObj, const ImportParams
LodObjParamsWrapper values(node, params.mCurrTime, FOREVER);
values.setNearValue(inXObj.nearVal());
values.setFarValue(inXObj.nearVal());
node->SetName(toTSTR(inXObj.objectName().c_str()));
node->SetName(xobj::toMStr(inXObj.objectName()));
return node;
}

Expand Down
2 changes: 1 addition & 1 deletion src/converters/ConverterMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ INode * ConverterMain::toMax(const xobj::ObjMain & inXObj) {
attr.setCockpitRegion(inXObj.pAttr.cockpitRegion(xobj::AttrCockpitRegion::r3), xobj::AttrCockpitRegion::r3);
attr.setCockpitRegion(inXObj.pAttr.cockpitRegion(xobj::AttrCockpitRegion::r4), xobj::AttrCockpitRegion::r4);

node->SetName(toTSTR(inXObj.objectName().c_str()));
node->SetName(xobj::toMStr(inXObj.objectName()));
return node;
}

Expand Down
2 changes: 1 addition & 1 deletion src/converters/ConverterSmoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ INode * ConverterSmoke::toMax(const xobj::ObjAbstract * object, const ImportPara
values.setType(smoke->smokeType());
values.setSize(smoke->size());
if (!smoke->objectName().empty()) {
pnode->SetName(toTSTR(smoke->objectName().c_str()));
pnode->SetName(xobj::toMStr(smoke->objectName()));
}
// todo set the position XYZ
return pnode;
Expand Down
74 changes: 74 additions & 0 deletions src/gup/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,80 @@
#include "Info.h"
#include "common/NodeUtils.h"

/********************************************************************************************************/
//////////////////////////////////////////////////////////////////////////////////////////////////////////
/********************************************************************************************************/

#define SETTINGS_PROJECT "PROJECT"
#define SETTINGS_PROJECT_USE_DATAREFS_ID "datarefsId"
#define SETTINGS_PROJECT_USE_COMMANDS_ID "commandsId"
#define SETTINGS_PROJECT_SORTING_DATAREFS "datarefsSort"
#define SETTINGS_PROJECT_SORTING_COMMANDS "commandsSort"

/**************************************************************************************************/
//////////////////////////////////////////* Functions */////////////////////////////////////////////
/**************************************************************************************************/

void Settings::setUseDatarefsId(const bool state) {
beginGroup(SETTINGS_PROJECT);
setValue(SETTINGS_PROJECT_USE_DATAREFS_ID, state);
endGroup();
onProjectSettingsChanged(this);
}

void Settings::setUseCommandsId(const bool state) {
beginGroup(SETTINGS_PROJECT);
setValue(SETTINGS_PROJECT_USE_COMMANDS_ID, state);
endGroup();
onProjectSettingsChanged(this);
}

bool Settings::isUseDatarefsId() {
beginGroup(SETTINGS_PROJECT);
const auto val = value(SETTINGS_PROJECT_USE_DATAREFS_ID, false);
endGroup();
return val;
}

bool Settings::isUseCommandsId() {
beginGroup(SETTINGS_PROJECT);
const auto val = value(SETTINGS_PROJECT_USE_COMMANDS_ID, false);
endGroup();
return val;
}

/**************************************************************************************************/
//////////////////////////////////////////* Functions */////////////////////////////////////////////
/**************************************************************************************************/

void Settings::setSortDatarefs(const bool state) {
beginGroup(SETTINGS_PROJECT);
setValue(SETTINGS_PROJECT_SORTING_DATAREFS, state);
endGroup();
onProjectSettingsChanged(this);
}

void Settings::setSortCommands(const bool state) {
beginGroup(SETTINGS_PROJECT);
setValue(SETTINGS_PROJECT_SORTING_COMMANDS, state);
endGroup();
onProjectSettingsChanged(this);
}

bool Settings::sortDatarefs() {
beginGroup(SETTINGS_PROJECT);
const auto val = value(SETTINGS_PROJECT_SORTING_DATAREFS, false);
endGroup();
return val;
}

bool Settings::sortCommands() {
beginGroup(SETTINGS_PROJECT);
const auto val = value(SETTINGS_PROJECT_SORTING_COMMANDS, false);
endGroup();
return val;
}

/**************************************************************************************************/
//////////////////////////////////////////* Functions */////////////////////////////////////////////
/**************************************************************************************************/
Expand Down
31 changes: 29 additions & 2 deletions src/gup/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,55 @@

#pragma once

#include "additional/utils/Settings.h"
#include <sts/signals/Signal.h>
#include <sts/semver/SemVersion.h>
#include "additional/utils/Settings.h"

/**************************************************************************************************/
////////////////////////////////////////////////////////////////////////////////////////////////////
/**************************************************************************************************/

/*!
* \details Access to the settings which are stored with the GUP (ObjCommon) class.
* \Note This settings are saved with the scene, so each scene has its own parameters.
* \Note This settings are saved with the scene, so each scene has its own values.
*/
class Settings : public sts::Settings {
public:

//-------------------------------------------------------------------------
/// @{

Settings() = default;

/// @}
//-------------------------------------------------------------------------
/// @{

void setUseDatarefsId(bool state);
void setUseCommandsId(bool state);
bool isUseDatarefsId();
bool isUseCommandsId();

void setSortDatarefs(bool state);
void setSortCommands(bool state);
bool sortDatarefs();
bool sortCommands();

sts::signals::Signal<Settings*> onProjectSettingsChanged;

/// @}
//-------------------------------------------------------------------------
/// @{

bool isSavedAsXplnScene() const;
void prepareDataForSave();
void setSceneVersion(const sts::semver::SemVersion & version);
sts::semver::SemVersion sceneVersion() const;
static sts::semver::SemVersion pluginVersion();

/// @}
//-------------------------------------------------------------------------

};

/**************************************************************************************************/
Expand Down
29 changes: 18 additions & 11 deletions src/models/CommandsFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <algorithm>
#include <cctype>
#include "CommandsFile.h"
#include "gup/ObjCommon.h"

namespace md {

Expand Down Expand Up @@ -81,13 +82,17 @@ bool CommandsFile::loadSimData(const MaxSDK::Util::Path & filePath) {
mUsesId = false;
mIsForProject = false;
mFilePath = filePath;
mSort = true;
mDisplayName = _T("[X-Plane] Commands");
return loadData(filePath);
}

bool CommandsFile::loadProjectData(const MaxSDK::Util::Path & filePath) {
auto & settings = ObjCommon::instance()->pSettings;
mUsesId = settings.isUseCommandsId();
mSort = settings.sortCommands();

mIsEditable = true;
mUsesId = true;
mIsForProject = true;
mFilePath = filePath;
mDisplayName = _T("[Project] Commands");
Expand Down Expand Up @@ -164,16 +169,18 @@ std::uint64_t CommandsFile::generateId() {
//////////////////////////////////////////* Functions */////////////////////////////////////////////
/**************************************************************************************************/

void CommandsFile::sortData() {
const auto sortFn = [](const xobj::Command & v1, const xobj::Command & v2) {
return std::lexicographical_compare(v1.mKey.begin(), v1.mKey.end(),
v2.mKey.begin(), v2.mKey.end(),
[](const char x, const char y) {
return std::tolower(static_cast<unsigned char>(x)) <
std::tolower(static_cast<unsigned char>(y));
});
};
std::sort(mData.begin(), mData.end(), sortFn);
void CommandsFile::sortDataIfEnabled() {
if (mSort) {
const auto sortFn = [](const xobj::Command & v1, const xobj::Command & v2) {
return std::lexicographical_compare(v1.mKey.begin(), v1.mKey.end(),
v2.mKey.begin(), v2.mKey.end(),
[](const char x, const char y) {
return std::tolower(static_cast<unsigned char>(x)) <
std::tolower(static_cast<unsigned char>(y));
});
};
std::sort(mData.begin(), mData.end(), sortFn);
}
}

/**************************************************************************************************/
Expand Down

0 comments on commit c70f5a6

Please sign in to comment.