Пример #1
0
void Manager::setString (const std::string& setting, const std::string& category, const std::string& value)
{
    CategorySetting s = std::make_pair(category, setting);

    bool found=false;
    try
    {
        Ogre::ConfigFile::SettingsIterator it = mFile.getSettingsIterator(category);
        while (it.hasMoreElements())
        {
            Ogre::ConfigFile::SettingsMultiMap::iterator i = it.current();

            if ((*i).first == setting)
            {
                if ((*i).second != value)
                {
                    mChangedSettings.push_back(std::make_pair(category, setting));
                    (*i).second = value;
                }
                found = true;
            }

            it.getNext();
        }
    }
    catch (Ogre::Exception&)
    {}

    if (!found)
    {
        if (mNewSettings.find(s) != mNewSettings.end())
        {
            if (mNewSettings[s] != value)
            {
                mChangedSettings.push_back(std::make_pair(category, setting));
                mNewSettings[s] = value;
            }
        }
        else
        {
            if (mDefaultFile.getSetting(setting, category) != value)
                mChangedSettings.push_back(std::make_pair(category, setting));
            mNewSettings[s] = value;
        }
    }
}
Пример #2
0
void OISInput::initialise()
{
    Ogre::RenderWindow* window = GetRenderWindow();

    OIS::ParamList param_list;
    std::size_t window_handle = 0;
    window->getCustomAttribute("WINDOW", &window_handle);
    typedef OIS::ParamList::value_type ParamType;
    param_list.insert(
        ParamType("WINDOW",
                  boost::lexical_cast<std::string>(window_handle)));

    OgreGUI* gui = OgreGUI::GetGUI();
    assert(gui);
    const Ogre::SharedPtr<Ogre::DataStream>& config_file_stream = gui->ConfigFileStream();
    if (!config_file_stream.isNull()) {
        Ogre::ConfigFile config_file;
        config_file.load(config_file_stream);
        for (Ogre::ConfigFile::SettingsIterator it = config_file.getSettingsIterator();
             it.hasMoreElements();
             it.getNext()) {
            param_list.insert(ParamType(it.peekNextKey(), it.peekNextValue()));
            Ogre::LogManager::getSingleton().logMessage("OISPlugin using config setting " + it.peekNextKey() + "=" + it.peekNextValue());
        }
    }

    m_input_manager = OIS::InputManager::createInputSystem(param_list);
    m_keyboard = boost::polymorphic_downcast<OIS::Keyboard*>(
        m_input_manager->createInputObject(OIS::OISKeyboard, true));
    m_keyboard->setEventCallback(this);
    m_mouse = boost::polymorphic_downcast<OIS::Mouse*>(
        m_input_manager->createInputObject(OIS::OISMouse, true));
    m_mouse->setEventCallback(this);

    const OIS::MouseState& mouse_state = m_mouse->getMouseState();
    mouse_state.width = Value(gui->AppWidth());
    mouse_state.height = Value(gui->AppHeight());

    ConnectHandlers();
}