mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 00:49:19 +02:00
improvements
This commit is contained in:
@@ -300,6 +300,7 @@ editor_mode::on_mouse_button( int const Button, int const Action, int const Mods
|
||||
if (!cloned)
|
||||
return;
|
||||
|
||||
cloned->mark_dirty();
|
||||
cloned->location(Camera.Pos + GfxRenderer.Mouse_Position());
|
||||
simulation::Instances.insert(cloned);
|
||||
simulation::Region->insert(cloned);
|
||||
|
||||
@@ -40,6 +40,7 @@ basic_editor::translate( scene::basic_node *Node, glm::dvec3 const &Location, bo
|
||||
// NOTE: bit of a waste for single nodes, for the sake of less varied code down the road
|
||||
auto const translation { targetlocation - initiallocation };
|
||||
|
||||
Node->mark_dirty();
|
||||
if( Node->group() == null_handle ) {
|
||||
translate_node( Node, Node->location() + translation );
|
||||
}
|
||||
|
||||
@@ -345,6 +345,10 @@ public:
|
||||
group( scene::group_handle Group );
|
||||
scene::group_handle
|
||||
group() const;
|
||||
void
|
||||
mark_dirty() { m_dirty = true; }
|
||||
bool
|
||||
dirty() const { return m_dirty; }
|
||||
|
||||
protected:
|
||||
// members
|
||||
@@ -354,6 +358,7 @@ protected:
|
||||
double m_rangesquaredmax { 0.0 }; // visibility range, max
|
||||
bool m_visible { true }; // visibility flag
|
||||
std::string m_name;
|
||||
bool m_dirty { false };
|
||||
|
||||
private:
|
||||
// methods
|
||||
|
||||
@@ -119,23 +119,37 @@ node_groups::insert( scene::group_handle const Group, basic_event *Event ) {
|
||||
|
||||
// sends basic content of the class in legacy (text) format to provided stream
|
||||
void
|
||||
node_groups::export_as_text( std::ostream &Output ) const {
|
||||
node_groups::export_as_text( std::ostream &Output, bool Dirty ) const {
|
||||
|
||||
for( auto const &group : m_groupmap ) {
|
||||
|
||||
Output << "group\n";
|
||||
bool any = false;
|
||||
for( auto *node : group.second.nodes ) {
|
||||
if (node->dirty() != Dirty)
|
||||
continue;
|
||||
// HACK: auto-generated memory cells aren't exported, so we check for this
|
||||
// TODO: is_exportable as basic_node method
|
||||
if( ( typeid( *node ) == typeid( TMemCell ) )
|
||||
&& ( false == static_cast<TMemCell *>( node )->is_exportable ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!any)
|
||||
Output << "group\n";
|
||||
any = true;
|
||||
|
||||
node->export_as_text( Output );
|
||||
}
|
||||
for( auto *event : group.second.events ) {
|
||||
if (Dirty)
|
||||
continue;
|
||||
|
||||
if (!any)
|
||||
Output << "group\n";
|
||||
any = true;
|
||||
|
||||
event->export_as_text( Output );
|
||||
}
|
||||
if (any)
|
||||
Output << "endgroup\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
return m_groupmap[ Group ]; }
|
||||
// sends basic content of the class in legacy (text) format to provided stream
|
||||
void
|
||||
export_as_text( std::ostream &Output ) const;
|
||||
export_as_text(std::ostream &Output , bool Dirty) const;
|
||||
|
||||
private:
|
||||
// types
|
||||
|
||||
@@ -967,46 +967,22 @@ state_serializer::export_as_text( std::string const &Scenariofile ) const {
|
||||
filename.erase( 0, 1 );
|
||||
}
|
||||
erase_extension( filename );
|
||||
filename = Global.asCurrentSceneryPath + filename + "_export";
|
||||
auto absfilename = Global.asCurrentSceneryPath + filename + "_export";
|
||||
|
||||
std::ofstream scmdirtyfile { absfilename + "_dirty.scm" };
|
||||
export_nodes_to_stream(scmdirtyfile, true);
|
||||
|
||||
std::ofstream scmfile { absfilename + ".scm" };
|
||||
export_nodes_to_stream(scmfile, false);
|
||||
|
||||
std::ofstream scmfile { filename + ".scm" };
|
||||
// groups
|
||||
scmfile << "// groups\n";
|
||||
scene::Groups.export_as_text( scmfile );
|
||||
// tracks
|
||||
scmfile << "// paths\n";
|
||||
for( auto const *path : Paths.sequence() ) {
|
||||
if( path->group() == null_handle ) {
|
||||
path->export_as_text( scmfile );
|
||||
}
|
||||
}
|
||||
// traction
|
||||
scmfile << "// traction\n";
|
||||
for( auto const *traction : Traction.sequence() ) {
|
||||
if( traction->group() == null_handle ) {
|
||||
traction->export_as_text( scmfile );
|
||||
}
|
||||
}
|
||||
// power grid
|
||||
scmfile << "// traction power sources\n";
|
||||
for( auto const *powersource : Powergrid.sequence() ) {
|
||||
if( powersource->group() == null_handle ) {
|
||||
powersource->export_as_text( scmfile );
|
||||
}
|
||||
}
|
||||
// models
|
||||
scmfile << "// instanced models\n";
|
||||
for( auto const *instance : Instances.sequence() ) {
|
||||
if( instance->group() == null_handle ) {
|
||||
instance->export_as_text( scmfile );
|
||||
}
|
||||
}
|
||||
// sounds
|
||||
// NOTE: sounds currently aren't included in groups
|
||||
scmfile << "// sounds\n";
|
||||
Region->export_as_text( scmfile );
|
||||
|
||||
std::ofstream ctrfile { filename + ".ctr" };
|
||||
scmfile << "// modified objects\ninclude " << filename << "_export_dirty.scm\n";
|
||||
|
||||
std::ofstream ctrfile { absfilename + ".ctr" };
|
||||
// mem cells
|
||||
ctrfile << "// memory cells\n";
|
||||
for( auto const *memorycell : Memory.sequence() ) {
|
||||
@@ -1015,12 +991,49 @@ state_serializer::export_as_text( std::string const &Scenariofile ) const {
|
||||
memorycell->export_as_text( ctrfile );
|
||||
}
|
||||
}
|
||||
|
||||
// events
|
||||
Events.export_as_text( ctrfile );
|
||||
|
||||
WriteLog( "Scenery data export done." );
|
||||
}
|
||||
|
||||
void
|
||||
state_serializer::export_nodes_to_stream(std::ostream &scmfile, bool Dirty) const {
|
||||
// groups
|
||||
scmfile << "// groups\n";
|
||||
scene::Groups.export_as_text( scmfile, Dirty );
|
||||
|
||||
// tracks
|
||||
scmfile << "// paths\n";
|
||||
for( auto const *path : Paths.sequence() ) {
|
||||
if( path->dirty() == Dirty && path->group() == null_handle ) {
|
||||
path->export_as_text( scmfile );
|
||||
}
|
||||
}
|
||||
// traction
|
||||
scmfile << "// traction\n";
|
||||
for( auto const *traction : Traction.sequence() ) {
|
||||
if( traction->dirty() == Dirty && traction->group() == null_handle ) {
|
||||
traction->export_as_text( scmfile );
|
||||
}
|
||||
}
|
||||
// power grid
|
||||
scmfile << "// traction power sources\n";
|
||||
for( auto const *powersource : Powergrid.sequence() ) {
|
||||
if( powersource->dirty() == Dirty && powersource->group() == null_handle ) {
|
||||
powersource->export_as_text( scmfile );
|
||||
}
|
||||
}
|
||||
// models
|
||||
scmfile << "// instanced models\n";
|
||||
for( auto const *instance : Instances.sequence() ) {
|
||||
if( instance && instance->dirty() == Dirty && instance->group() == null_handle ) {
|
||||
instance->export_as_text( scmfile );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // simulation
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -79,6 +79,7 @@ private:
|
||||
void skip_until( cParser &Input, std::string const &Token );
|
||||
// transforms provided location by specifed rotation and offset
|
||||
glm::dvec3 transform( glm::dvec3 Location, scene::scratch_data const &Scratchpad );
|
||||
void export_nodes_to_stream(std::ostream &, bool Dirty) const;
|
||||
};
|
||||
|
||||
} // simulation
|
||||
|
||||
Reference in New Issue
Block a user