// Loads the default shortcuts from the registry void EventManager::loadAccelerators() { if (_debugMode) { std::cout << "EventManager: Loading accelerators...\n"; } xml::NodeList shortcutSets = GlobalRegistry().findXPath("user/ui/input//shortcuts"); if (_debugMode) { std::cout << "Found " << shortcutSets.size() << " sets.\n"; } // If we have two sets of shortcuts, delete the default ones if (shortcutSets.size() > 1) { GlobalRegistry().deleteXPath("user/ui/input//shortcuts[@name='default']"); } // Find all accelerators xml::NodeList shortcutList = GlobalRegistry().findXPath("user/ui/input/shortcuts//shortcut"); if (shortcutList.size() > 0) { rMessage() << "EventManager: Shortcuts found in Registry: " << static_cast<int>(shortcutList.size()) << std::endl; for (unsigned int i = 0; i < shortcutList.size(); i++) { const std::string key = shortcutList[i].getAttributeValue("key"); if (_debugMode) { std::cout << "Looking up command: " << shortcutList[i].getAttributeValue("command") << "\n"; std::cout << "Key is: >> " << key << " << \n"; } // Try to lookup the command IEventPtr event = findEvent(shortcutList[i].getAttributeValue("command")); // Check for a non-empty key string if (key != "") { // Check for valid command definitions were found if (!event->empty()) { // Get the modifier string (e.g. "SHIFT+ALT") const std::string modifierStr = shortcutList[i].getAttributeValue("modifiers"); if (!duplicateAccelerator(key, modifierStr, event)) { // Create the accelerator object IAccelerator& accelerator = addAccelerator(key, modifierStr); // Connect the newly created accelerator to the command accelerator.connectEvent(event); } } else { rWarning() << "EventManager: Cannot load shortcut definition (command invalid)." << std::endl; } } } } else { // No accelerator definitions found! rWarning() << "EventManager: No shortcut definitions found..." << std::endl; } }
void StimTypes::save() { // Find the storage entity std::string storageEClass = GlobalRegistry().get(RKEY_STORAGE_ECLASS); Entity* storageEntity = findEntityByClass(storageEClass); if (storageEntity != NULL) { std::string prefix = GlobalRegistry().get(RKEY_STORAGE_PREFIX); // Clean the storage entity from any previous definitions { // Instantiate a visitor to gather the keys to delete CustomStimRemover remover(storageEntity); // Visit each keyvalue with the <self> class as visitor storageEntity->forEachKeyValue(remover); // Scope ends here, the keys are deleted now // as the CustomStimRemover gets destructed } // Now store all custom stim types to the storage entity for (StimTypeMap::iterator i = _stimTypes.begin(); i != _stimTypes.end(); ++i) { StimType& s = i->second; std::string idStr = string::to_string(i->first); if (s.custom) { // spawnarg is something like "editor_dr_stim_1002" => "MyStim" storageEntity->setKeyValue(prefix + idStr, s.caption); } } } }
void StimTypes::reload() { _stimTypes.clear(); _listStore->clear(); // Find all the relevant nodes xml::NodeList stimNodes = GlobalRegistry().findXPath(RKEY_STIM_DEFINITIONS); for (std::size_t i = 0; i < stimNodes.size(); ++i) { // Add the new stim type add(string::convert<int>(stimNodes[i].getAttributeValue("id")), stimNodes[i].getAttributeValue("name"), stimNodes[i].getAttributeValue("caption"), stimNodes[i].getAttributeValue("description"), stimNodes[i].getAttributeValue("icon"), false // non-custom stim ); } // Load the custom stims from the storage entity std::string storageEClass = GlobalRegistry().get(RKEY_STORAGE_ECLASS); Entity* storageEntity = findEntityByClass(storageEClass); if (storageEntity != NULL) { // Visit each keyvalue with the <self> class as visitor storageEntity->forEachKeyValue(*this); } }
void makeVisportal(const cmd::ArgumentList& args) { BrushPtrVector brushes = getSelectedBrushes(); if (brushes.size() <= 0) { gtkutil::errorDialog(_("No brushes selected."), GlobalMainFrame().getTopLevelWindow()); return; } // Create a scoped undocmd object UndoableCommand cmd("brushMakeVisportal"); for (std::size_t i = 0; i < brushes.size(); i++) { Brush& brush = brushes[i]->getBrush(); // don't allow empty brushes if (brush.getNumFaces() == 0) continue; // Set all faces to nodraw first brush.setShader(GlobalRegistry().get(RKEY_NODRAW_SHADER)); // Find the largest face (in terms of area) LargestFaceFinder finder; brush.forEachFace(finder); finder.getLargestFace().setShader(GlobalRegistry().get(RKEY_VISPORTAL_SHADER)); } }
void WindowPosition::saveToPath(const std::string& path) { GlobalRegistry().setAttribute(path, "xPosition", string::to_string(_position[0])); GlobalRegistry().setAttribute(path, "yPosition", string::to_string(_position[1])); GlobalRegistry().setAttribute(path, "width", string::to_string(_size[0])); GlobalRegistry().setAttribute(path, "height", string::to_string(_size[1])); }
void Clipper::initialiseModule(const ApplicationContext& ctx) { rMessage() << "Clipper::initialiseModule called\n"; _useCaulk = registry::getValue<bool>(RKEY_CLIPPER_USE_CAULK); _caulkShader = GlobalRegistry().get(RKEY_CLIPPER_CAULK_SHADER); GlobalRegistry().signalForKey(RKEY_CLIPPER_USE_CAULK).connect( sigc::mem_fun(this, &Clipper::keyChanged) ); GlobalRegistry().signalForKey(RKEY_CLIPPER_CAULK_SHADER).connect( sigc::mem_fun(this, &Clipper::keyChanged) ); constructPreferences(); // Register the clip commands GlobalCommandSystem().addCommand("ClipSelected", boost::bind(&Clipper::clipSelectionCmd, this, _1)); GlobalCommandSystem().addCommand("SplitSelected", boost::bind(&Clipper::splitSelectedCmd, this, _1)); GlobalCommandSystem().addCommand("FlipClip", boost::bind(&Clipper::flipClipperCmd, this, _1)); // Connect some events to these commands GlobalEventManager().addCommand("ClipSelected", "ClipSelected"); GlobalEventManager().addCommand("SplitSelected", "SplitSelected"); GlobalEventManager().addCommand("FlipClip", "FlipClip"); }
void SplitPaneLayout::saveStateToPath(const std::string& path) { GlobalRegistry().createKeyWithName(path, "pane", "horizontal"); _splitPane.posHPane.saveToPath(path + "/pane[@name='horizontal']"); GlobalRegistry().createKeyWithName(path, "pane", "vertical1"); _splitPane.posVPane1.saveToPath(path + "/pane[@name='vertical1']"); GlobalRegistry().createKeyWithName(path, "pane", "vertical2"); _splitPane.posVPane2.saveToPath(path + "/pane[@name='vertical2']"); GlobalRegistry().deleteXPath(RKEY_SPLITPANE_VIEWTYPES); xml::Node node = GlobalRegistry().createKey(RKEY_SPLITPANE_VIEWTYPES); // Camera is assigned -1 as viewtype int topLeft = _quadrants[QuadrantTopLeft].xyWnd != NULL ? _quadrants[QuadrantTopLeft].xyWnd->getViewType() : -1; int topRight = _quadrants[QuadrantTopRight].xyWnd != NULL ? _quadrants[QuadrantTopRight].xyWnd->getViewType() : -1; int bottomLeft = _quadrants[QuadrantBottomLeft].xyWnd != NULL ? _quadrants[QuadrantBottomLeft].xyWnd->getViewType() : -1; int bottomRight = _quadrants[QuadrantBottomRight].xyWnd != NULL ? _quadrants[QuadrantBottomRight].xyWnd->getViewType() : -1; node.setAttributeValue("topleft", string::to_string(topLeft)); node.setAttributeValue("topright", string::to_string(topRight)); node.setAttributeValue("bottomleft", string::to_string(bottomLeft)); node.setAttributeValue("bottomright", string::to_string(bottomRight)); }
// Get default textures TexturePtr Doom3ShaderSystem::getDefaultInteractionTexture(ShaderLayer::Type t) { TexturePtr defaultTex; // Look up based on layer type switch (t) { case ShaderLayer::DIFFUSE: case ShaderLayer::SPECULAR: defaultTex = GetTextureManager().getBinding( GlobalRegistry().get(RKEY_BITMAPS_PATH) + IMAGE_BLACK ); break; case ShaderLayer::BUMP: defaultTex = GetTextureManager().getBinding( GlobalRegistry().get(RKEY_BITMAPS_PATH) + IMAGE_FLAT ); break; default: break; } return defaultTex; }
// RegistryKeyObserver implementation, gets called upon key change void MapCompiler::keyChanged (const std::string& changedKey, const std::string& newValue) { _errorCheckParameters = GlobalRegistry().get(RKEY_ERROR_CHECK_PARAMETERS); _errorFixParameters = GlobalRegistry().get(RKEY_ERROR_FIX_PARAMETERS); _compilerBinary = GlobalRegistry().get(RKEY_COMPILER_BINARY); _compileParameters = GlobalRegistry().get(RKEY_COMPILE_PARAMETERS); _materialParameters = GlobalRegistry().get(RKEY_MATERIAL_PARAMETERS); }
void RegularLayout::saveStateToPath(const std::string& path) { GlobalRegistry().createKeyWithName(path, "pane", "horizontal"); _regular.posHPane.saveToPath(path + "/pane[@name='horizontal']"); GlobalRegistry().createKeyWithName(path, "pane", "texcam"); _regular.posTexCamPane.saveToPath(path + "/pane[@name='texcam']"); }
void WindowPosition::loadFromPath(const std::string& path) { _position[0] = string::convert<int>(GlobalRegistry().getAttribute(path, "xPosition")); _position[1] = string::convert<int>(GlobalRegistry().getAttribute(path, "yPosition")); _size[0] = string::convert<int>(GlobalRegistry().getAttribute(path, "width")); _size[1] = string::convert<int>(GlobalRegistry().getAttribute(path, "height")); }
MapPosition::MapPosition(unsigned int index) : _index(index), _position(0,0,0), _angle(0,0,0) { // Construct the entity key names from the index _posKey = GlobalRegistry().get(RKEY_MAP_POSROOT) + string::to_string(_index); _angleKey = GlobalRegistry().get(RKEY_MAP_ANGLEROOT) + string::to_string(_index); }
// greebo: This toggles the brush size info display in the ortho views void ToggleShowSizeInfo () { if (GlobalRegistry().get("user/ui/showSizeInfo") == "1") { GlobalRegistry().set("user/ui/showSizeInfo", "0"); } else { GlobalRegistry().set("user/ui/showSizeInfo", "1"); } SceneChangeNotify(); }
void GlobalCameraManager::increaseCameraSpeed(const cmd::ArgumentList& args) { int movementSpeed = GlobalRegistry().getInt(RKEY_MOVEMENT_SPEED); movementSpeed *= 2; if (movementSpeed > MAX_CAMERA_SPEED){ movementSpeed = MAX_CAMERA_SPEED; } GlobalRegistry().setInt(RKEY_MOVEMENT_SPEED, movementSpeed); }
void GlobalCameraManager::decreaseCameraSpeed(const cmd::ArgumentList& args) { int movementSpeed = GlobalRegistry().getInt(RKEY_MOVEMENT_SPEED); movementSpeed /= 2; if (movementSpeed < 1){ movementSpeed = 1; } GlobalRegistry().setInt(RKEY_MOVEMENT_SPEED, movementSpeed); }
void BrushModuleClass::initialiseModule(const ApplicationContext& ctx) { globalOutputStream() << "BrushModuleClass::initialiseModule called." << std::endl; construct(); _textureLockEnabled = (GlobalRegistry().get(RKEY_ENABLE_TEXTURE_LOCK) == "1"); GlobalRegistry().addKeyObserver(this, RKEY_ENABLE_TEXTURE_LOCK); // add the preference settings constructPreferences(); }
void MainFrame::SaveWindowInfo (void) { // Delete all the current window states from the registry GlobalRegistry().deleteXPath(RKEY_WINDOW_STATE); // Tell the position tracker to save the information _windowPosition.saveToPath(RKEY_WINDOW_STATE); GdkWindow* window = GTK_WIDGET(m_window)->window; if (window != NULL) GlobalRegistry().setAttribute(RKEY_WINDOW_STATE, "state", string::toString(gdk_window_get_state(window))); }
void Map::removeCameraPosition() { const std::string keyLastCamPos = GlobalRegistry().get(RKEY_LAST_CAM_POSITION); const std::string keyLastCamAngle = GlobalRegistry().get(RKEY_LAST_CAM_ANGLE); if (m_world_node != NULL) { // Retrieve the entity from the worldspawn node Entity* worldspawn = Node_getEntity(m_world_node); assert(worldspawn != NULL); // This must succeed worldspawn->setKeyValue(keyLastCamPos, ""); worldspawn->setKeyValue(keyLastCamAngle, ""); } }
MapCompiler::MapCompiler () { GlobalRegistry().addKeyObserver(this, RKEY_ERROR_CHECK_PARAMETERS); GlobalRegistry().addKeyObserver(this, RKEY_ERROR_FIX_PARAMETERS); GlobalRegistry().addKeyObserver(this, RKEY_COMPILER_BINARY); GlobalRegistry().addKeyObserver(this, RKEY_COMPILE_PARAMETERS); GlobalRegistry().addKeyObserver(this, RKEY_MATERIAL_PARAMETERS); // greebo: Register this class in the preference system so that the constructPreferencePage() gets called. GlobalPreferenceSystem().addConstructor(this); keyChanged("", ""); }
void RegularLayout::restoreStateFromPath(const std::string& path) { // Now load the paned positions from the registry if (GlobalRegistry().keyExists(path + "/pane[@name='horizontal']")) { _regular.posHPane.loadFromPath(path + "/pane[@name='horizontal']"); _regular.posHPane.applyPosition(); } if (GlobalRegistry().keyExists(path + "/pane[@name='texcam']")) { _regular.posTexCamPane.loadFromPath(path + "/pane[@name='texcam']"); _regular.posTexCamPane.applyPosition(); } }
void surroundWithMonsterclip(const cmd::ArgumentList& args) { UndoableCommand command("addMonsterclip"); // create a ModelFinder and retrieve the modelList selection::algorithm::ModelFinder visitor; GlobalSelectionSystem().foreachSelected(visitor); // Retrieve the list with all the found models from the visitor selection::algorithm::ModelFinder::ModelList list = visitor.getList(); selection::algorithm::ModelFinder::ModelList::iterator iter; for (iter = list.begin(); iter != list.end(); ++iter) { // one of the models in the SelectionStack const scene::INodePtr& node = *iter; // retrieve the AABB AABB brushAABB(node->worldAABB()); // create the brush scene::INodePtr brushNode(GlobalBrushCreator().createBrush()); if (brushNode != NULL) { scene::addNodeToContainer(brushNode, GlobalMap().findOrInsertWorldspawn()); Brush* theBrush = Node_getBrush(brushNode); std::string clipShader = GlobalRegistry().get(RKEY_MONSTERCLIP_SHADER); Scene_BrushResize(*theBrush, brushAABB, clipShader); } } }
void MouseEventManager::loadCameraEventDefinitions () { xml::NodeList camviews = GlobalRegistry().findXPath("user/ui/input//cameraview"); if (camviews.size() > 0) { // Find all the camera definitions xml::NodeList eventList = camviews[0].getNamedChildren("event"); if (eventList.size() > 0) { globalOutputStream() << "MouseEventManager: Camera Definitions found: " << eventList.size() << "\n"; for (unsigned int i = 0; i < eventList.size(); i++) { // Get the event name const std::string eventName = eventList[i].getAttributeValue("name"); // Check if any recognised event names are found and construct the according condition. if (eventName == "EnableFreeLookMode") { _cameraConditions[ui::camEnableFreeLookMode] = getCondition(eventList[i]); } else if (eventName == "DisableFreeLookMode") { _cameraConditions[ui::camDisableFreeLookMode] = getCondition(eventList[i]); } else { globalOutputStream() << "MouseEventManager: Warning: Ignoring unknown event name: " << eventName << "\n"; } } } else { // No Camera definitions found! globalOutputStream() << "MouseEventManager: Critical: No camera event definitions found!\n"; } } else { // No Camera definitions found! globalOutputStream() << "MouseEventManager: Critical: No camera event definitions found!\n"; } }
void MouseEventManager::loadButtonDefinitions () { xml::NodeList buttons = GlobalRegistry().findXPath("user/ui/input//buttons"); if (buttons.size() > 0) { // Find all the button definitions xml::NodeList buttonList = buttons[0].getNamedChildren("button"); if (buttonList.size() > 0) { globalOutputStream() << "MouseEventManager: Buttons found: " << buttonList.size() << "\n"; for (unsigned int i = 0; i < buttonList.size(); i++) { const std::string name = buttonList[i].getAttributeValue("name"); unsigned int id = string::toInt(buttonList[i].getAttributeValue("id")); if (name != "" && id > 0) { // Save the button ID into the map _buttonId[name] = id; } else { globalOutputStream() << "MouseEventManager: Warning: Invalid button definition found.\n"; } } } else { // No Button definitions found! globalOutputStream() << "MouseEventManager: Critical: No button definitions found!\n"; } } else { // No Button definitions found! globalOutputStream() << "MouseEventManager: Critical: No button definitions found!\n"; } }
void RadiantSelectionSystem::initialiseModule(const ApplicationContext& ctx) { rMessage() << "RadiantSelectionSystem::initialiseModule called.\n"; constructStatic(); SetManipulatorMode(eTranslate); pivotChanged(); _sigSelectionChanged.connect( sigc::mem_fun(this, &RadiantSelectionSystem::pivotChangedSelection) ); GlobalGrid().signal_gridChanged().connect( sigc::mem_fun(this, &RadiantSelectionSystem::pivotChanged) ); GlobalRegistry().signalForKey(RKEY_ROTATION_PIVOT).connect( sigc::mem_fun(this, &RadiantSelectionSystem::keyChanged) ); // Pass a reference to self to the global event manager GlobalEventManager().connectSelectionSystem(this); // Connect the bounds changed caller GlobalSceneGraph().signal_boundsChanged().connect( sigc::mem_fun(this, &RadiantSelectionSystem::onSceneBoundsChanged) ); GlobalRenderSystem().attachRenderable(*this); }
/* Parses the XML Document for toolbars and instantiates them * Returns nothing, toolbars can be obtained via GetToolbar() */ void ToolbarManager::loadToolbars() { xml::NodeList toolbarList = GlobalRegistry().findXPath("//ui//toolbar"); if (!toolbarList.empty()) { // Create a new tooltips element _tooltips = gtk_tooltips_new(); gtk_tooltips_enable(_tooltips); for (std::size_t i = 0; i < toolbarList.size(); i++) { std::string toolbarName = toolbarList[i].getAttributeValue("name"); if (toolbarExists(toolbarName)) { //globalOutputStream() << "This toolbar already exists: "; continue; } globalOutputStream() << "Found toolbar: " << toolbarName << std::endl; _toolbars.insert(toolbarName); } } else { throw std::runtime_error("No toolbars found."); } }
void MRU::saveRecentFiles() { // Delete all existing MRU/element nodes GlobalRegistry().deleteXPath(RKEY_MAP_MRUS); std::size_t counter = 1; // Now wade through the list and save them in the correct order for (MRUList::const_iterator i = _list.begin(); i != _list.end(); ++counter, ++i) { const std::string key = RKEY_MAP_MRUS + "/map" + string::to_string(counter); // Save the string into the registry GlobalRegistry().set(key, (*i)); } }
MRU::MRU() : _numMaxFiles(registry::getValue<int>(RKEY_MRU_LENGTH)), _loadLastMap(registry::getValue<bool>(RKEY_LOAD_LAST_MAP)), _list(_numMaxFiles), _emptyMenuItem(_(RECENT_FILES_CAPTION), *this, 0) { GlobalRegistry().signalForKey(RKEY_MRU_LENGTH).connect( sigc::mem_fun(this, &MRU::keyChanged) ); // Add the preference settings constructPreferences(); // Create _numMaxFiles menu items for (std::size_t i = 0; i < _numMaxFiles; i++) { _menuItems.push_back(MRUMenuItem(string::to_string(i), *this, i+1)); MRUMenuItem& item = (*_menuItems.rbegin()); const std::string commandName = std::string("MRUOpen") + string::to_string(i+1); // Connect the command to the last inserted menuItem GlobalCommandSystem().addCommand( commandName, std::bind(&MRUMenuItem::activate, &item, std::placeholders::_1) ); GlobalEventManager().addCommand(commandName, commandName); } }
void renderWireframe (Renderer& renderer, const VolumeTest& volume, const Matrix4& localToWorld, bool selected) const { renderSolid(renderer, volume, localToWorld, selected); if (GlobalRegistry().get("user/ui/xyview/showEntityNames") == "1") { renderer.addRenderable(m_renderName, localToWorld); } }
void RegularLayout::deactivate() { // Show the camera toggle option again GlobalUIManager().getMenuManager().setVisibility("main/view/cameraview", true); GlobalUIManager().getMenuManager().setVisibility("main/view/textureBrowser", true); // Remove all previously stored pane information GlobalRegistry().deleteXPath(RKEY_REGULAR_ROOT + "//pane"); // Save pane info saveStateToPath(RKEY_REGULAR_ROOT); // Delete all active views GlobalXYWndManager().destroyViews(); // Delete the CamWnd _camWnd = CamWndPtr(); // Hide the group dialog GlobalGroupDialog().hideDialogWindow(); GlobalTextureBrowser().destroyWindow(); // Destroy the widget, so it gets removed from the main container gtk_widget_destroy(GTK_WIDGET(_regular.horizPane)); }
void MouseEventManager::loadCameraStrafeDefinitions() { // Find all the camera strafe definitions xml::NodeList strafeList = GlobalRegistry().findXPath("user/ui/input/cameraview/strafemode"); if (!strafeList.empty()) { // Get the strafe condition flags _toggleStrafeCondition.modifierFlags = _modifiers.getModifierFlags(strafeList[0].getAttributeValue("toggle")); _toggleForwardStrafeCondition.modifierFlags = _modifiers.getModifierFlags(strafeList[0].getAttributeValue("forward")); try { _strafeSpeed = boost::lexical_cast<float>(strafeList[0].getAttributeValue("speed")); } catch (boost::bad_lexical_cast e) { _strafeSpeed = DEFAULT_STRAFE_SPEED; } try { _forwardStrafeFactor = boost::lexical_cast<float>(strafeList[0].getAttributeValue("forwardFactor")); } catch (boost::bad_lexical_cast e) { _forwardStrafeFactor = 1.0f; } } else { // No Camera strafe definitions found! rMessage() << "MouseEventManager: Critical: No camera strafe definitions found!\n"; } }