mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-01 23:59:12 +01:00
feat(editor): edit session (-edit) and scenery layers
This commit is contained in:
@@ -56,6 +56,7 @@ namespace scene {
|
||||
struct node_data;
|
||||
class basic_node;
|
||||
using group_handle = std::size_t;
|
||||
using layer_handle = std::uint16_t;
|
||||
}
|
||||
|
||||
namespace Mtable
|
||||
|
||||
@@ -84,6 +84,7 @@ struct global_settings {
|
||||
std::string szDefaultExt{ szTexturesDDS };
|
||||
std::string SceneryFile;
|
||||
std::string local_start_vehicle{ "EU07-424" };
|
||||
bool editor_session{ false }; // scenery was opened for editing (-edit): loader keeps track of scenery layers and hands over to the editor
|
||||
int iConvertModels{ 0 }; // tworzenie plików binarnych
|
||||
int iConvertIndexRange{ 1000 }; // range of duplicate vertex scan
|
||||
bool file_binary_terrain{ true }; // enable binary terrain (de)serialization
|
||||
|
||||
@@ -12,6 +12,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "utilities/Logs.h"
|
||||
|
||||
#include "scene/scenenodegroups.h"
|
||||
#include "scene/scenelayers.h"
|
||||
|
||||
/*
|
||||
MaSzyna EU07 locomotive simulator parser
|
||||
@@ -118,6 +119,11 @@ cParser::~cParser()
|
||||
// wrap up the node group holding content of processed file
|
||||
scene::Groups.close();
|
||||
}
|
||||
if (true == mLayerFile)
|
||||
{
|
||||
// content of the processed file ended, following nodes belong to the parent layer again
|
||||
scene::Layers.close();
|
||||
}
|
||||
}
|
||||
|
||||
template <> glm::vec3 cParser::getToken(bool const ToLower, char const *Break)
|
||||
@@ -336,6 +342,12 @@ void cParser::startIncludeFromParser(cParser& srcParser, bool ToLower, std::stri
|
||||
if (isTerrain && true == Global.file_binary_terrain_state) {
|
||||
WriteLog("SBT found, ignoring: " + includefile);
|
||||
readParameters(srcParser); // preserve original side-effect: still consume parameters
|
||||
if (sceneryLayers)
|
||||
{
|
||||
// the file is still a part of the scenery, even though its content comes from the binary terrain file
|
||||
scene::Layers.layer(scene::Layers.open(includefile)).binary = true;
|
||||
scene::Layers.close();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -355,6 +367,18 @@ void cParser::startIncludeFromParser(cParser& srcParser, bool ToLower, std::stri
|
||||
if (mIncludeParser->mSize <= 0) {
|
||||
ErrorLog("Bad include: can't open file \"" + includefile + "\"");
|
||||
}
|
||||
|
||||
if (sceneryLayers)
|
||||
{
|
||||
mIncludeParser->sceneryLayers = true;
|
||||
// content of an included scenery file forms a layer of its own. *.inc files are node templates
|
||||
// reused all over the scenery, so their content stays in the layer of the file which includes them
|
||||
if (false == mIncludeParser->mIncFile && mIncludeParser->mSize > 0)
|
||||
{
|
||||
scene::Layers.open(includefile);
|
||||
mIncludeParser->mLayerFile = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool cParser::handleIncludeIfPresent(std::string& token, bool ToLower, const char* Break) {
|
||||
@@ -524,6 +548,7 @@ void cParser::injectString(const std::string &str)
|
||||
{
|
||||
mIncludeParser = std::make_shared<cParser>(str, buffer_TEXT, "", LoadTraction, std::vector<std::string>(), allowRandomIncludes);
|
||||
mIncludeParser->autoclear(m_autoclear);
|
||||
mIncludeParser->sceneryLayers = sceneryLayers;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ class cParser //: public std::stringstream
|
||||
bool expandIncludes = true;
|
||||
bool allowRandomIncludes = false;
|
||||
bool skipComments = true;
|
||||
bool sceneryLayers = false; // included scenery files are registered as scenery layers (scenery opened for editing)
|
||||
|
||||
private:
|
||||
void startIncludeFromParser(cParser &srcParser, bool ToLower, std::string includefile);
|
||||
@@ -118,6 +119,7 @@ class cParser //: public std::stringstream
|
||||
std::streamoff mSize { 0 }; // size of open stream, for progress report.
|
||||
std::size_t mLine { 0 }; // currently processed line
|
||||
bool mIncFile { false }; // the parser is processing an *.inc file
|
||||
bool mLayerFile { false }; // the parser is processing a file registered as scenery layer
|
||||
bool mFirstToken { true }; // processing first token in the current file; helper used when checking for utf bom
|
||||
typedef std::map<std::string, std::string> commentmap;
|
||||
commentmap mComments {
|
||||
|
||||
Reference in New Issue
Block a user