16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-19 04:19:19 +02:00

node delete in editor

This commit is contained in:
milek7
2019-02-23 15:35:23 +01:00
parent cbb61ce639
commit 37dc56a8d8
2 changed files with 28 additions and 2 deletions

10
Names.h
View File

@@ -62,6 +62,16 @@ public:
m_itemmap.erase(lookup);
}
void purge (Type_ *Item)
{
for (auto it = m_items.begin(); it != m_items.end(); it++) {
if (*it == Item) {
delete *it;
*it = nullptr;
return;
}
}
}
// locates item with specified name. returns pointer to the item, or nullptr
Type_ *
find( std::string const &Name ) const {

View File

@@ -180,6 +180,22 @@ editor_mode::on_key( int const Key, int const Scancode, int const Action, int co
break;
}
case GLFW_KEY_DELETE: {
TAnimModel *model = dynamic_cast<TAnimModel*>(m_node);
if (!model)
break;
m_node = nullptr;
m_dragging = false;
Application.set_cursor( GLFW_CURSOR_NORMAL );
static_cast<editor_ui*>( m_userinterface.get() )->set_node(nullptr);
simulation::Region->erase(model);
simulation::Instances.purge(model);
break;
}
default: {
break;
}
@@ -231,13 +247,13 @@ editor_mode::on_mouse_button( int const Button, int const Action, int const Mods
if( Action == GLFW_PRESS ) {
// left button press
auto const mode = dynamic_cast<editor_ui*>( m_userinterface.get() )->mode();
auto const mode = static_cast<editor_ui*>( m_userinterface.get() )->mode();
m_node = nullptr;
GfxRenderer.pick_node([this, mode](scene::basic_node *node)
{
editor_ui *ui = dynamic_cast<editor_ui*>( m_userinterface.get() );
editor_ui *ui = static_cast<editor_ui*>( m_userinterface.get() );
if (mode == nodebank_panel::MODIFY) {
if (!m_dragging)