Skip to content
This repository has been archived by the owner on Dec 3, 2020. It is now read-only.

Commit

Permalink
Add Clone NodeBox
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Mar 5, 2015
1 parent 20bef07 commit 0e68f5e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/MenuState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum GUI_ID
// Tools
GUI_PROJ_NEW_BOX,
GUI_PROJ_DELETE_BOX,
GUI_PROJ_CLONE,
GUI_PROJ_IMAGE_IM,

// Help
Expand Down
12 changes: 12 additions & 0 deletions src/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ void Node::deleteNodebox(int id)
_selected = boxes.size() - 1;
}

void Node::cloneNodebox(int id)
{
NodeBox *nb = GetNodeBox(id);
if (!nb)
return;

NodeBox *new_nb = addNodeBox();
new_nb->one = nb->one;
new_nb->two = nb->two;
new_nb->buildNode(state, position, device, images);
}

void Node::setTexture(CubeSide face, Media::Image *image)
{
if (image) {
Expand Down
1 change: 1 addition & 0 deletions src/Node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Node
NodeBox* GetNodeBox(int id);
NodeBox* addNodeBox();
void deleteNodebox(int id);
void cloneNodebox(int id);
void select(int id) { _selected = id; }

// Node bulk updaters
Expand Down
14 changes: 13 additions & 1 deletion src/modes/NBEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ void NBEditor::load()
lb->setVisible(false);
IGUIButton* b1 = guienv->addButton(rect<s32>(0, 100, 50, 125),
lb, GUI_PROJ_NEW_BOX, L"+", L"Add a node box");
IGUIButton* b2 = guienv->addButton(rect<s32>(60, 100, 110,125),
IGUIButton* b2 = guienv->addButton(rect<s32>(60, 100, 110, 125),
lb, GUI_PROJ_DELETE_BOX, L"-", L"Delete node box");
IGUIButton* b3 = guienv->addButton(rect<s32>(120, 100, 170, 125),
lb, GUI_PROJ_CLONE, L"Clone", L"Duplicate node box");
b1->setNotClipped(true);
b2->setNotClipped(true);
b3->setNotClipped(true);
}


Expand Down Expand Up @@ -447,6 +450,15 @@ bool NBEditor::OnEvent(const irr::SEvent &event) {
}
break;
}
case GUI_PROJ_CLONE: {
Node* node = state->project->GetCurrentNode();
IGUIListBox* lb = (IGUIListBox*) state->menu->sidebar->getElementFromId(ENB_GUI_MAIN_LISTBOX);
if (node && node->GetNodeBox(lb->getSelected())){
node->cloneNodebox(lb->getSelected());
load_ui();
}
break;
}
case ENB_GUI_PROP_REVERT:
fillProperties();
break;
Expand Down

0 comments on commit 0e68f5e

Please sign in to comment.