void TravMaskCommand::handleChooseMatchStringDialogClosed(DialogWindowEventDetails* const details, UIDrawingSurface* const DrawingSurface, Node* const RootNode) { if(details->getOption() == DialogWindowEventDetails::DIALOG_OPTION_OK) { //Get the Search string returned std::string SearchRegex = details->getInput(); std::string MaskStrValue; try { MaskStrValue = boost::lexical_cast<std::string>(MainApplication::the()->getSettings().get<UInt32>("player.debugger.trav_mask_graph_op.applied_trav_mask")); } catch(boost::bad_lexical_cast & ex) { SWARNING << "Bad lexical cast: " << ex.what() << std::endl; return; } //Open Dialog for setting the traversal mask DialogWindowRefPtr TravMaskDialog = DialogWindow::createTextInputDialog("Traversal Mask", "Enter the traversal mask you would like to be applied", true, std::vector<std::string>(1, MaskStrValue)); TravMaskDialog->connectDialogWindowClosed(boost::bind(&TravMaskCommand::handleChooseTravMaskDialogClosed, _1, SearchRegex, RootNode)); TravMaskDialog->setModal(true); DrawingSurface->openWindow(TravMaskDialog); } }
void TravMaskCommand::execute(void) { if(_RootNode != NULL) { DialogWindowRefPtr SearchStrDialog = DialogWindow::createTextInputDialog("Search string ...", "Enter the text you would like to match.", true, std::vector<std::string>(1, MainApplication::the()->getSettings().get<std::string>("player.debugger.trav_mask_graph_op.search_regex"))); SearchStrDialog->connectDialogWindowClosed(boost::bind(&TravMaskCommand::handleChooseMatchStringDialogClosed, _1, _DrawingSurface.get(), _RootNode.get())); SearchStrDialog->setModal(true); _DrawingSurface->openWindow(SearchStrDialog); } }
void FCPtrFieldEditor::openCreateHandler(void) { const FieldContainerType* ThePtrType(getFieldContainerTypeFromPtrType(getEditingFC()->getFieldDescription(getEditingFieldId())->getFieldType().getContentType())); if(ThePtrType == NULL) { return; } //If the type is a node, then create a NodeCore instead //and then insert it as the core of a newly created node if(*ThePtrType == Node::getClassType()) { ThePtrType = &NodeCore::getClassType(); } std::vector<std::string> inputValues; UInt32 NumFieldContainersFound(0); const FieldContainerType* FoundType(NULL); for(UInt32 j(0) ; NumFieldContainersFound<FieldContainerFactory::the()->getNumTypes(); ++j) { FoundType = FieldContainerFactory::the()->findType(j); if(FoundType != NULL) { if(FoundType->isDerivedFrom(*ThePtrType) && !FoundType->isAbstract()) { inputValues.push_back(FoundType->getName()); } ++NumFieldContainersFound; } } DialogWindowRefPtr TheDialog = DialogWindow::createInputDialog("Create Field Container", "Choose the type of object to create", DialogWindow::INPUT_COMBO, true, inputValues); _CreateContainerDialogClosedConnection = TheDialog->connectDialogWindowClosed(boost::bind(&FCPtrFieldEditor::handleCreateContainerDialogClosed, this, _1)); Pnt2f CenteredPosition = calculateAlignment(Pnt2f(0.0f,0.0f), getParentWindow()->getParentDrawingSurface()->getSize(), TheDialog->getPreferredSize(), 0.5f, 0.5f); TheDialog->setPosition(CenteredPosition); TheDialog->setAllwaysOnTop(true); TheDialog->setModal(true); TheDialog->setResizable(true); getParentWindow()->getParentDrawingSurface()->openWindow(TheDialog); }
void FCPtrFieldEditor::openFindContainerHandler(void) { const FieldContainerType* ThePtrType(getFieldContainerTypeFromPtrType(getEditingFC()->getFieldDescription(getEditingFieldId())->getFieldType().getContentType())); if(ThePtrType == NULL) { return; } std::vector<std::string> inputValues; _FindFCStore->setTypeToStore(ThePtrType); FCPtrEditorStore::FieldContianerVector fcStore(_FindFCStore->getList()); std::string value; for(UInt32 i(0) ; i<fcStore.size(); ++i) { value.clear(); if(fcStore[i]->getType().isDerivedFrom(AttachmentContainer::getClassType()) && getName(dynamic_pointer_cast<AttachmentContainer>(fcStore[i]))) { value += std::string(getName(dynamic_pointer_cast<AttachmentContainer>(fcStore[i]))) + " "; } value += "[" + fcStore[i]->getType().getName() + "] " + boost::lexical_cast<std::string>(fcStore[i]->getId()); inputValues.push_back(value); } DialogWindowRefPtr TheDialog = DialogWindow::createInputDialog("Find Field Container", "Choose the container to use", DialogWindow::INPUT_LIST, true, inputValues); _FindContainerDialogClosedConnection = TheDialog->connectDialogWindowClosed(boost::bind(&FCPtrFieldEditor::handleFindContainerDialogClosed, this, _1)); Pnt2f CenteredPosition = calculateAlignment(Pnt2f(0.0f,0.0f), getParentWindow()->getParentDrawingSurface()->getSize(), TheDialog->getPreferredSize(), 0.5f, 0.5f); TheDialog->setPosition(CenteredPosition); TheDialog->setAllwaysOnTop(true); TheDialog->setResizable(true); getParentWindow()->getParentDrawingSurface()->openWindow(TheDialog); }
void GenericMultiFieldEditor::insertAtIndex(FieldContainer* const fc, UInt32 fieldID, UInt32 index, UIDrawingSurface* const drawingSurface, CommandManager* cmdMgr) { //Is this a pointer field GetFieldHandlePtr TheFieldHandle(fc->getField(fieldID)); if(TheFieldHandle->isPointerField()) { //Create const FieldContainerType* ThePtrType(getFieldContainerTypeFromPtrType(fc->getFieldDescription(fieldID)->getFieldType().getContentType())); if(ThePtrType == NULL) { return; } //If the type is a node, then create a NodeCore instead //and then insert it as the core of a newly created node if(*ThePtrType == Node::getClassType()) { ThePtrType = &NodeCore::getClassType(); } std::vector<std::string> inputValues; UInt32 NumFieldContainersFound(0); const FieldContainerType* FoundType(NULL); for(UInt32 j(0) ; NumFieldContainersFound<FieldContainerFactory::the()->getNumTypes(); ++j) { FoundType = FieldContainerFactory::the()->findType(j); if(FoundType != NULL) { if(FoundType->isDerivedFrom(*ThePtrType) && !FoundType->isAbstract()) { inputValues.push_back(FoundType->getName()); } ++NumFieldContainersFound; } } if(inputValues.size() == 1) { insertAtIndex(fc,fieldID,index,FieldContainerFactory::the()->findType(inputValues[0].c_str()),cmdMgr); } else { DialogWindowRefPtr TheDialog = DialogWindow::createInputDialog("Create " + fc->getFieldDescription(fieldID)->getFieldType().getContentType().getName(), "Choose the type of object to create", DialogWindow::INPUT_COMBO, true, inputValues); TheDialog->connectDialogWindowClosed(boost::bind(&GenericMultiFieldEditor::handleInsertFCPtrDialogClosed, _1, fc, fieldID, index, cmdMgr)); Pnt2f CenteredPosition = calculateAlignment(Pnt2f(0.0f,0.0f), drawingSurface->getSize(), TheDialog->getPreferredSize(), 0.5f, 0.5f); TheDialog->setPosition(CenteredPosition); TheDialog->setAllwaysOnTop(true); TheDialog->setModal(true); TheDialog->setResizable(true); drawingSurface->openWindow(TheDialog); } } else { //Insert the default InsertFieldElementCommandPtr InsertIndexCommand = InsertFieldElementCommand::create(fc, fieldID, "", index); cmdMgr->executeCommand(InsertIndexCommand); } }