public bool Initiliase(IntPtr windowHandle) { this.input = MOIS.InputManager.CreateInputSystem((uint)windowHandle.ToInt32()); //Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse) this.keyboard = (Keyboard)input.CreateInputObject(MOIS.Type.OISKeyboard, true); this.mouse = (Mouse)input.CreateInputObject(MOIS.Type.OISMouse, true); return(true); }
public bool Initiliase(IntPtr windowHandle) { this.input = MOIS.InputManager.CreateInputSystem((uint)windowHandle.ToInt32()); //Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse) this.keyboard = (Keyboard)input.CreateInputObject(MOIS.Type.OISKeyboard, true); this.mouse = (Mouse)input.CreateInputObject(MOIS.Type.OISMouse, true); return true; }
public AdvancedMogreFramework() { m_pRoot = null; m_pRenderWnd = null; m_pViewport = null; m_pLog = null; m_pTimer = null; m_pInputMgr = null; m_pKeyboard = null; m_pMouse = null; m_pTrayMgr = null; }
public GameManager() { root = null; renderWindow = null; viewport = null; log = null; timer = null; inputMgr = null; keyboard = null; mouse = null; appStateMgr = null; soundMgr = null; VideoMode = new NameValuePairList(); isEditMode = false; isCheatMode = false; loadingData = new LoadingData(LoadingType.NONE, null, null, null); GlobalValueTable = new Dictionary <string, object>(); }
protected virtual void InitializeInput() { LogManager.Singleton.LogMessage("*** Initializing OIS ***"); mRenderWindow = mWindow; int windowHnd; mWindow.GetCustomAttribute("WINDOW", out windowHnd); inputMgr = MOIS.InputManager.CreateInputSystem((uint)windowHnd); mKeyboard = (MOIS.Keyboard)inputMgr.CreateInputObject(MOIS.Type.OISKeyboard, true); mMouse = (MOIS.Mouse)inputMgr.CreateInputObject(MOIS.Type.OISMouse, true); MOIS.MouseState_NativePtr state = mMouse.MouseState; state.width = mWindow.GetViewport(0).ActualWidth; state.height = mWindow.GetViewport(0).ActualHeight; mKeyboard.KeyPressed += new KeyListener.KeyPressedHandler(OnKeyPressed); mKeyboard.KeyReleased += new KeyListener.KeyReleasedHandler(OnKeyReleased); mMouse.MouseMoved += new MouseListener.MouseMovedHandler(OnMouseMoved); mMouse.MousePressed += new MouseListener.MousePressedHandler(OnMousePressed); mMouse.MouseReleased += new MouseListener.MouseReleasedHandler(OnMouseReleased); }
private bool InitRender(string wndTitle, ref GameConfigXml gameOptions) { root = Root.Singleton == null ? new Root() : Root.Singleton; root.FrameStarted += new FrameListener.FrameStartedHandler(frameStarted); log = EngineLogManager.Instance.CreateLog("./Log/Engine.log"); rendererLog = LogManager.Singleton.CreateLog("./Log/Mogre.log", true, true, false); rendererLog.SetDebugOutputEnabled(true); RenderSystem rs = null; IniConfigFileParser parser = new IniConfigFileParser(); if (gameOptions == null) { gameOptions = GameConfigXml.Load("game.xml", root); } defaultRenderSystemName = gameOptions.GraphicConfig.CurrentRenderSystem; var renderParams = gameOptions.GraphicConfig[gameOptions.GraphicConfig.CurrentRenderSystem]; if (!string.IsNullOrEmpty(defaultRenderSystemName)) { var videModeRenderParam = renderParams.Where(o => o.Name == "Video Mode").First(); rs = root.GetRenderSystemByName(defaultRenderSystemName); string strVideoMode = Regex.Match( videModeRenderParam.Value, "[0-9]{3,4} x [0-9]{3,4}").Value; VideoMode["Width"] = strVideoMode.Split('x')[0].Trim(); VideoMode["Height"] = strVideoMode.Split('x')[1].Trim(); } var ogreConfigMap = rs.GetConfigOptions(); if (rs != null && renderParams != null) { foreach (var kpl in renderParams) { string renderParamKey = kpl.Name; string renderParamValue = kpl.Value; //Validate the render parameter if (!ogreConfigMap[renderParamKey].possibleValues.Contains(renderParamValue)) { renderParamValue = ogreConfigMap[renderParamKey].possibleValues[0]; } rs.SetConfigOption(renderParamKey, renderParamValue); } root.RenderSystem = rs; } renderWindow = root.Initialise(true, wndTitle); IntPtr hwnd; renderWindow.GetCustomAttribute("WINDOW", out hwnd); Helper.SetRenderWindowIcon(new System.Drawing.Icon(Path.Combine(Environment.CurrentDirectory, "app.ico")), hwnd); viewport = renderWindow.AddViewport(null); ColourValue cv = new ColourValue(0.5f, 0.5f, 0.5f); viewport.BackgroundColour = cv; viewport.Camera = null; int hWnd = 0; renderWindow.GetCustomAttribute("WINDOW", out hWnd); inputMgr = MOIS.InputManager.CreateInputSystem((uint)hWnd); keyboard = (Keyboard)inputMgr.CreateInputObject(MOIS.Type.OISKeyboard, true); mouse = (Mouse)inputMgr.CreateInputObject(MOIS.Type.OISMouse, true); keyMouseManager = new InputKeyMouseManager(); keyMouseManager.SomeKeyPressd += KeyMouseManager_SomeKeyPressd; MouseState_NativePtr mouseState = mouse.MouseState; mouseState.width = viewport.ActualWidth; mouseState.height = viewport.ActualHeight; foreach (var resource in gameOptions.ResourcesConfig.Resources) { foreach (var resLoc in resource.ResourceLocs) { ResourceGroupManager.Singleton.AddResourceLocation(resLoc, resource.Type, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME); } } foreach (var keyMapper in gameOptions.InputConfig.Mappers) { KeyMapperManager.Instance.AddKeyMapper(keyMapper.GameKeyCode, keyMapper.GetKeyCollections()); } if (!LocateSystem.Instance.IsInit) { LocateSystem.Instance.InitLocateSystem(LocateSystem.Instance.ConvertReadableStringToLocate(gameOptions.LocateConfig.CurrentLocate)); } SkinManager.Instance.LoadSkin("Default.skn"); ResourceGroupManager.Singleton.AddResourceLocation( string.Format("./Media/Engine/Fonts/{0}/", LocateSystem.Instance.Locate.ToString()), "FileSystem", "General"); TextureManager.Singleton.DefaultNumMipmaps = 5; ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); UIManager.Instance.Init("AMOFTrayMgr", renderWindow, mouse, new UIListener()); timer = new Timer(); timer.Reset(); renderWindow.IsActive = true; this.gameOptions = gameOptions; log.LogMessage("Game Started!"); return(true); }
public bool initOgre(String wndTitle) { LogManager logMgr = new LogManager(); m_pLog = LogManager.Singleton.CreateLog("OgreLogfile.log", true, true, false); m_pLog.SetDebugOutputEnabled(true); m_pRoot = new Root(); if (!m_pRoot.ShowConfigDialog()) { return(false); } m_pRenderWnd = m_pRoot.Initialise(true, wndTitle); m_pViewport = m_pRenderWnd.AddViewport(null); ColourValue cv = new ColourValue(0.5f, 0.5f, 0.5f); m_pViewport.BackgroundColour = cv; m_pViewport.Camera = null; int hWnd = 0; //ParamList paramList; m_pRenderWnd.GetCustomAttribute("WINDOW", out hWnd); m_pInputMgr = InputManager.CreateInputSystem((uint)hWnd); m_pKeyboard = (MOIS.Keyboard)m_pInputMgr.CreateInputObject(MOIS.Type.OISKeyboard, true); m_pMouse = (MOIS.Mouse)m_pInputMgr.CreateInputObject(MOIS.Type.OISMouse, true); m_pMouse.MouseMoved += new MouseListener.MouseMovedHandler(mouseMoved); m_pMouse.MousePressed += new MouseListener.MousePressedHandler(mousePressed); m_pMouse.MouseReleased += new MouseListener.MouseReleasedHandler(mouseReleased); m_pKeyboard.KeyPressed += new KeyListener.KeyPressedHandler(keyPressed); m_pKeyboard.KeyReleased += new KeyListener.KeyReleasedHandler(keyReleased); MOIS.MouseState_NativePtr mouseState = m_pMouse.MouseState; mouseState.width = m_pViewport.ActualWidth; mouseState.height = m_pViewport.ActualHeight; //m_pMouse.MouseState = tempMouseState; String secName, typeName, archName; ConfigFile cf = new ConfigFile(); cf.Load("resources.cfg", "\t:=", true); ConfigFile.SectionIterator seci = cf.GetSectionIterator(); while (seci.MoveNext()) { secName = seci.CurrentKey; ConfigFile.SettingsMultiMap settings = seci.Current; foreach (KeyValuePair <string, string> pair in settings) { typeName = pair.Key; archName = pair.Value; ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName); } } TextureManager.Singleton.DefaultNumMipmaps = 5; ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); m_pTrayMgr = new SdkTrayManager("AOFTrayMgr", m_pRenderWnd, m_pMouse, null); m_pTimer = new Timer(); m_pTimer.Reset(); m_pRenderWnd.IsActive = true; return(true); }