Esempio n. 1
0
	RenderWindow* Win32GLSupport::newWindow(const String &name, unsigned int width, 
		unsigned int height, bool fullScreen, const NameValuePairList *miscParams)
	{		
		Win32Window* window = OGRE_NEW Win32Window(*this);
		NameValuePairList newParams;
	
		if (miscParams != NULL)
		{	
			newParams = *miscParams;
			miscParams = &newParams;

			NameValuePairList::const_iterator monitorIndexIt = miscParams->find("monitorIndex");			
			HMONITOR hMonitor = NULL;
			int monitorIndex = -1;
		
			// If monitor index found, try to assign the monitor handle based on it.
			if (monitorIndexIt != miscParams->end())
			{				
				if (mMonitorInfoList.empty())		
					EnumDisplayMonitors(NULL, NULL, sCreateMonitorsInfoEnumProc, (LPARAM)&mMonitorInfoList);			

				monitorIndex = StringConverter::parseInt(monitorIndexIt->second);
				if (monitorIndex < (int)mMonitorInfoList.size())
				{						
					hMonitor = mMonitorInfoList[monitorIndex].hMonitor;					
				}
			}
			// If we didn't specified the monitor index, or if it didn't find it
			if (hMonitor == NULL)
			{
				POINT windowAnchorPoint;
		
				NameValuePairList::const_iterator opt;
				int left = -1;
				int top  = -1;

				if ((opt = newParams.find("left")) != newParams.end())
					left = StringConverter::parseInt(opt->second);

				if ((opt = newParams.find("top")) != newParams.end())
					top = StringConverter::parseInt(opt->second);

				// Fill in anchor point.
				windowAnchorPoint.x = left;
				windowAnchorPoint.y = top;


				// Get the nearest monitor to this window.
				hMonitor = MonitorFromPoint(windowAnchorPoint, MONITOR_DEFAULTTOPRIMARY);				
			}

			newParams["monitorHandle"] = StringConverter::toString((size_t)hMonitor);																
		}

		window->create(name, width, height, fullScreen, miscParams);

		if(!mInitialWindow)
			mInitialWindow = window;
		return window;
	}
 //-----------------------------------------------------------------------
 void StringInterface::setParameterList(const NameValuePairList& paramList)
 {
     NameValuePairList::const_iterator i, iend;
     iend = paramList.end();
     for (i = paramList.begin(); i != iend; ++i)
     {
         setParameter(i->first, i->second);
     }
 }
    void CommandMapper::buildCommandMap(KeyAndMouseCommandMap& cmdMap,
        const NameValuePairList& values)
    {
        for (NameValuePairList::const_iterator it = values.begin(); it != values.end(); it++)
        {
            // Split the path at the ',' character
            StringVector keys = Ogre::StringUtil::split(it->second, ",");

            for (size_t i = 0; i < keys.size(); i++)
            {
                int keycode = getKeyCode(keys[i]);
                cmdMap[keycode] = CeGuiString(it->first);
                LOG_MESSAGE(Logger::UI,
                    Ogre::String("Key ") + keys[i] + " ("
                    + StringConverter::toString(keycode)
                    + ") is assigned to command " + it->first);
            }
        }
    }