SimsWorld/SimsWorld/ActionNodeConfiguration.cpp

45 lines
1.5 KiB
C++

#include "ActionNodeConfiguration.h"
#include <QGridLayout>
#include "BehaviorEditor.h"
ActionNodeConfiguration::ActionNodeConfiguration(QWidget* p)
:QFrame(p),
_current_present(nullptr),
_execute_select(new QComboBox(this)),
_vars_configuration(new VariablesConfigurationPanel(this))
{
this->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
auto p_layout = new QGridLayout(this);
p_layout->addWidget(new QLabel(u8"Ö´ÐÐÆ÷ÀàÐÍ£º", this));
p_layout->addWidget(_execute_select, 0, 1, 1, 4);
p_layout->addWidget(_vars_configuration, 1, 0, 3, 5);
p_layout->setColumnStretch(1, 1);
connect(this->_execute_select, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](int v){
if(v < 1 || !_current_node) return;
auto inst = this->_current_node->getKernal()->getExecute(this->_execute_select->currentText());
auto new_inst = std::dynamic_pointer_cast<ExecuteDelegate>(inst->newDefault());
_current_node->bindDelegate(new_inst);
_current_present->dataHasBeenUpdate();
});
}
void ActionNodeConfiguration::setTarget(NodePresent* ins)
{
this->_current_present = ins;
auto logic_node = ins->logicalBind();
this->_current_node = std::dynamic_pointer_cast<ExecuteNode>(logic_node);
auto kernel = logic_node->getKernal();
this->_execute_select->clear();
auto types = kernel->executeTypes();
types.prepend(u8"δѡ¶¨");
this->_execute_select->addItems(types);
this->_execute_select->setCurrentText(_current_node->delegateName());
this->_vars_configuration->bindNode(ins->logicalBind());
}