void SelectionSetToolmenu::onEntryActivated() { // Create new selection set if possible std::string name = _entry->get_entry()->get_text(); if (name.empty()) return; // don't create empty sets if (GlobalSelectionSystem().countSelected() == 0) { ui::IDialogPtr dialog = GlobalDialogManager().createMessageBox( _("Cannot create selection set"), _("Cannot create a selection set, there is nothing selected in the current scene."), ui::IDialog::MESSAGE_CONFIRM); dialog->run(); return; } ISelectionSetPtr set = GlobalSelectionSetManager().createSelectionSet(name); assert(set != NULL); set->assignFromCurrentScene(); // Clear the entry again _entry->get_entry()->set_text(""); }
void WaveFrontModule::exportSelectionAsOBJ(const cmd::ArgumentList& args) { const SelectionInfo& info = GlobalSelectionSystem().getSelectionInfo(); if (info.totalCount == 0) { globalErrorStream() << "Nothing selected, cannot export." << std::endl; return; } // Query the filename from the user ui::IFileChooserPtr chooser = GlobalDialogManager().createFileChooser( _("Save as Obj"), false, false, "*.obj", ".obj" ); chooser->setCurrentPath(GlobalRegistry().get(RKEY_MAP_PATH)); std::string path = chooser->display(); if (!path.empty()) { globalOutputStream() << "Exporting selection as OBJ to " << path << std::endl; // Instantiate a new exporter WaveFrontExporter exporter(path); exporter.exportSelection(); } }
void CustomStimEditor::removeStimType() { IDialogPtr dialog = GlobalDialogManager().createMessageBox(_("Delete Custom Stim"), _("Beware that other entities <i>might</i> still be using this stim type.\n" "Do you really want to delete this custom stim?"), ui::IDialog::MESSAGE_ASK); if (dialog->run() == IDialog::RESULT_YES) { _stimTypes.remove(getIdFromSelection()); } }
void SelectionSetToolmenu::onDeleteAllSetsClicked() { ui::IDialogPtr dialog = GlobalDialogManager().createMessageBox( _("Delete all selection sets?"), _("This will delete all set definitions. The actual map objects will not be affected by this step.\n\nContinue with that operation?"), ui::IDialog::MESSAGE_ASK); ui::IDialog::Result result = dialog->run(); if (result == ui::IDialog::RESULT_YES) { GlobalSelectionSetManager().deleteAllSelectionSets(); } }
bool Map::askForSave(const std::string& title) { if (!isModified()) { // Map is not modified, return positive return true; } // Ask the user ui::IDialogPtr msgBox = GlobalDialogManager().createMessageBox( title, getSaveConfirmationText(), ui::IDialog::MESSAGE_SAVECONFIRMATION ); ui::IDialog::Result result = msgBox->run(); if (result == ui::IDialog::RESULT_CANCELLED) { return false; } if (result == ui::IDialog::RESULT_YES) { // The user wants to save the map if (isUnnamed()) { // Map still unnamed, try to save the map with a new name // and take the return value from the other routine. return saveAs(); } else { // Map is named, save it save(); } } // Default behaviour: allow the save return true; }
void DoFind(const cmd::ArgumentList& args) { ui::IDialogPtr dialog = GlobalDialogManager().createDialog(_("Find Brush")); ui::IDialog::Handle entityEntry = dialog->addEntryBox(_("Entity Number:")); ui::IDialog::Handle brushEntry = dialog->addEntryBox(_("Brush Number:")); std::size_t ent(0), br(0); GetSelectionIndex(ent, br); dialog->setElementValue(entityEntry, sizetToStr(ent)); dialog->setElementValue(brushEntry, sizetToStr(br)); if (dialog->run() == ui::IDialog::RESULT_OK) { std::string entityValue = dialog->getElementValue(entityEntry); std::string brushValue = dialog->getElementValue(brushEntry); SelectBrush(strToInt(entityValue), strToInt(brushValue)); } }
bool ShortcutChooser::assignShortcut() { bool shortcutsChanged = false; // Check, if the user has pressed a meaningful key if (_keyval != 0) { // Construct an eventkey structure to be passed to the EventManager query GdkEventKey eventKey; eventKey.keyval = _keyval; eventKey.state = _state; // Try to lookup an existing command with the same shortcut IEventPtr foundEvent = GlobalEventManager().findEvent(&eventKey); // Only react on non-empty and non-"self" events if (!foundEvent->empty() && foundEvent != _event) { // There is already a command connected to this shortcut, ask the user const std::string foundEventName = GlobalEventManager().getEventName(foundEvent); // Construct the message std::string message = (boost::format(_("The specified shortcut is already assigned to <b>%s</b>" "\nOverwrite the current setting and assign this shortcut to <b>%s</b> instead?")) % foundEventName % _commandName).str(); // Fire up the dialog to ask the user what action to take IDialogPtr popup = GlobalDialogManager().createMessageBox( _("Overwrite existing shortcut?"), message, ui::IDialog::MESSAGE_ASK); // Only react on "YES" if (popup->run() == ui::IDialog::RESULT_YES) { // Disconnect both the found command and the new command GlobalEventManager().disconnectAccelerator(foundEventName); GlobalEventManager().disconnectAccelerator(_commandName); // Create a new accelerator and connect it to the selected command IAccelerator& accel = GlobalEventManager().addAccelerator(&eventKey); GlobalEventManager().connectAccelerator(accel, _commandName); shortcutsChanged = true; } } else { // No command is using the accelerator up to now, so assign it // Disconnect the current command to avoid duplicate accelerators GlobalEventManager().disconnectAccelerator(_commandName); // Create a new accelerator and connect it to the selected command IAccelerator& accel = GlobalEventManager().addAccelerator(&eventKey); GlobalEventManager().connectAccelerator(accel, _commandName); shortcutsChanged = true; } } else { // No key is specified, disconnect the command GlobalEventManager().disconnectAccelerator(_commandName); shortcutsChanged = true; } return shortcutsChanged; }