private void CreateInput() { LogManager.Singleton.LogMessage("*** Initializing OIS ***"); MOIS.ParamList pl = new MOIS.ParamList(); if (AutoLockMouse == false) { pl.Insert("w32_mouse", "DISCL_FOREGROUND"); pl.Insert("w32_mouse", "DISCL_NONEXCLUSIVE"); } window.GetCustomAttribute("WINDOW", out WindowHandle); pl.Insert("WINDOW", WindowHandle.ToString()); inputManager = MOIS.InputManager.CreateInputSystem(pl); //Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse) inputKeyboard = (MOIS.Keyboard)inputManager.CreateInputObject(MOIS.Type.OISKeyboard, UseBufferedInput); inputMouse = (MOIS.Mouse)inputManager.CreateInputObject(MOIS.Type.OISMouse, UseBufferedInput); if (inputKeyboard != null) { LogManager.Singleton.LogMessage("Setting up keyboard listeners"); inputKeyboard.KeyPressed += new MOIS.KeyListener.KeyPressedHandler(KeyPressed); inputKeyboard.KeyReleased += new MOIS.KeyListener.KeyReleasedHandler(KeyReleased); } if (inputMouse != null) { LogManager.Singleton.LogMessage("Setting up mouse listeners"); inputMouse.MousePressed += new MOIS.MouseListener.MousePressedHandler(MousePressed); inputMouse.MouseReleased += new MOIS.MouseListener.MouseReleasedHandler(MouseReleased); inputMouse.MouseMoved += new MOIS.MouseListener.MouseMovedHandler(MouseMoved); } }
public virtual void CreateInput() { LogManager.Singleton.LogMessage("*** Initializing OIS ***"); MOIS.ParamList pl = new MOIS.ParamList(); IntPtr windowHnd; window.GetCustomAttribute("WINDOW", out windowHnd); pl.Insert("WINDOW", windowHnd.ToString()); if (this.IsMouseNonExclusive) { pl.Insert("w32_mouse", "DISCL_FOREGROUND"); pl.Insert("w32_mouse", "DISCL_NONEXCLUSIVE"); } inputManager = MOIS.InputManager.CreateInputSystem(pl); //Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse) inputKeyboard = (MOIS.Keyboard)inputManager.CreateInputObject(MOIS.Type.OISKeyboard, UseBufferedInput); inputMouse = (MOIS.Mouse)inputManager.CreateInputObject(MOIS.Type.OISMouse, UseBufferedInput); uint width; uint height; uint depth; int left; int top; window.GetMetrics(out width, out height, out depth, out left, out top); MOIS.MouseState_NativePtr cState = inputMouse.MouseState; cState.width = (int)width; cState.height = (int)height; }
public void PositionBrowser() { int w, h; int x, y; if (BrowserSize != Size.Empty) { w = BrowserSize.Width; h = BrowserSize.Height; } else { RenderWindow rw = (Root.Instance.RenderSystem as D3D9RenderSystem).PrimaryWindow; Control c = (Control)rw.GetCustomAttribute("HWND"); w = (c.Width) - (BrowserBorder * 2); h = (c.Height) - (BrowserBorder * 2); } if (BrowserLocation != Point.Empty) { x = BrowserLocation.X; y = BrowserLocation.Y; } else { RenderWindow rw = (Root.Instance.RenderSystem as D3D9RenderSystem).PrimaryWindow; Control c = (Control)rw.GetCustomAttribute("HWND"); x = (c.Width - w) / 2; y = (c.Height - h) / 2; } Size = new Size(w, h); Location = new Point(x, y); b.Size = new Size(w - (BrowserLine * 2), h - (BrowserLine * 2)); b.Location = new Point(BrowserLine, BrowserLine); }
public virtual void CreateInput() { mouseTimer = new System.Windows.Forms.Timer(); mouseTimer.Tick += new EventHandler(mouseTimer_Tick); mouseTimer.Interval = 50; mouseTimer.Start(); LogManager.Singleton.LogMessage("*** Initializing OIS ***"); ParamList pl = new ParamList(); IntPtr windowHnd; window.GetCustomAttribute("WINDOW", out windowHnd); // pl.Insert("WINDOW", windowHnd.ToString()); pl.Insert("WINDOW", Parent.Parent.Parent.Parent.Parent.Parent.Handle.ToString()); inputManager = InputManager.CreateInputSystem(pl); //Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse) try { inputKeyboard = (Keyboard)inputManager.CreateInputObject(MOIS.Type.OISKeyboard, UseBufferedInput); } catch (Exception e) { throw e; } // inputMouse = (Mouse) inputManager.CreateInputObject(MOIS.Type.OISMouse, UseBufferedInput); }
protected virtual void InitializeInput() { int windowHandle; mRenderWindow.GetCustomAttribute("WINDOW", out windowHandle); mInputMgr = MOIS.InputManager.CreateInputSystem((uint)windowHandle); mKeyboard = (MOIS.Keyboard)mInputMgr.CreateInputObject(MOIS.Type.OISKeyboard, false); mMouse = (MOIS.Mouse)mInputMgr.CreateInputObject(MOIS.Type.OISMouse, false); }
/************************************************************************/ /* start up ogre manager */ /************************************************************************/ internal bool Startup() { // check if already initialized if (mRoot != null) { return(false); } // create ogre root mRoot = new Root("plugins.cfg", "settings.cfg", "mogre.log"); // create resource manager and initialize it mResourceMgr = new ResourceManager(); if (!mResourceMgr.Startup("../resources.cfg")) { return(false); } if (!Configure()) { return(false); } // register event to get notified when application lost or regained focus mRoot.RenderSystem.EventOccurred += OnRenderSystemEventOccurred; // create window and get the native window handle (needed for MOIS) mWindow = mRoot.CreateRenderWindow("Project Sustain", Program.WINDOW_WIDTH, Program.WINDOW_HEIGHT, true); mWindow.GetCustomAttribute("WINDOW", out mWindowHandle); mResourceMgr.InitGroup("PostLoad"); // create scene manager mSceneMgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC, "DefaultSceneManager"); // create default camera mCamera = mSceneMgr.CreateCamera("DefaultCamera"); mCamera.AutoAspectRatio = true; mCamera.NearClipDistance = 1.0f; mCamera.FarClipDistance = 1000.0f; // create default viewport mViewport = mWindow.AddViewport(mCamera); mResourceMgr.Load(); mResourceMgr.LoadGroup("PostLoad"); // set rendering active flag mRenderingActive = true; // OK return(true); }
/// <summary> /// Sets up the keyboard/mouse for input. /// </summary> void SetUpInput() { MOIS.ParamList pl = new MOIS.ParamList(); IntPtr windowHnd; window.GetCustomAttribute("WINDOW", out windowHnd); // window is your RenderWindow! pl.Insert("WINDOW", windowHnd.ToString()); inputManager = MOIS.InputManager.CreateInputSystem(pl); // Create all devices (except joystick, as most people have Keyboard/Mouse) using unbuffered input inputKeyboard = (MOIS.Keyboard)inputManager.CreateInputObject(MOIS.Type.OISKeyboard, true); inputMouse = (MOIS.Mouse)inputManager.CreateInputObject(MOIS.Type.OISMouse, true); }
public virtual void CreateInput() { LogManager.Singleton.LogMessage("*** Initializing OIS ***"); MOIS.ParamList pl = new MOIS.ParamList(); IntPtr windowHnd; window.GetCustomAttribute("WINDOW", out windowHnd); pl.Insert("WINDOW", windowHnd.ToString()); inputManager = MOIS.InputManager.CreateInputSystem(pl); //Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse) inputKeyboard = (MOIS.Keyboard)inputManager.CreateInputObject(MOIS.Type.OISKeyboard, UseBufferedInput); inputMouse = (MOIS.Mouse)inputManager.CreateInputObject(MOIS.Type.OISMouse, UseBufferedInput); }
// Not currently used, but there should be some code to trap resize events // when I am fullscreen. private void DefaultForm_Resizing(object sender, System.ComponentModel.CancelEventArgs ce) { object device = renderWindow.GetCustomAttribute("D3DDEVICE"); if (device != null) { Microsoft.DirectX.Direct3D.Device d3dDevice = device as Microsoft.DirectX.Direct3D.Device; if (d3dDevice.PresentationParameters.Windowed == false) { ce.Cancel = true; } log.InfoFormat("Canceled resize event for full screen window"); return; } }
public void StartRendering() { InitializeResources(); CreateScene(); CreateFrameListeners(); // var overlays = new OverlayScene(new Vector(800, 800)); // overlays.AddButton("hello", Vector.Zero, new Vector(50,20)); // overlays.AddButton("world", new Vector(0, 20), new Vector(50, 20)); int windowHandle; m_RenderWindow.GetCustomAttribute("WINDOW", out windowHandle); SetFocus(new IntPtr(windowHandle)); m_InputController = new InputController(windowHandle.ToString(), m_Camera, m_Bus, m_Clock, m_PlayerId); m_Root.StartRendering(); }
public Control(RenderWindow window) { // Create input manager MOIS.ParamList pl = new MOIS.ParamList(); IntPtr windowHnd; window.GetCustomAttribute("WINDOW", out windowHnd); pl.Insert("WINDOW", windowHnd.ToString()); mInputManager = MOIS.InputManager.CreateInputSystem(pl); mKeyBoard = (MOIS.Keyboard)mInputManager.CreateInputObject(MOIS.Type.OISKeyboard, true); mMouse = (MOIS.Mouse)mInputManager.CreateInputObject(MOIS.Type.OISMouse, true); try { mJoystick = (MOIS.JoyStick)mInputManager.CreateInputObject(MOIS.Type.OISJoyStick, true); Program.Instance.gameManager.hasJoy = true; try { mFF = (MOIS.ForceFeedback)mJoystick.QueryInterface(MOIS.Interface.IType.ForceFeedback); mSupportedEffectList = mFF.GetSupportedEffects(); } catch { //Console.WriteLine("No ForceFeedback"); } } catch { //Console.WriteLine("No Joystick"); } //Callbacks for Inputs mKeyBoard.KeyPressed += new MOIS.KeyListener.KeyPressedHandler(mKeyBoard_KeyPressed); mKeyBoard.KeyReleased += new MOIS.KeyListener.KeyReleasedHandler(mKeyBoard_KeyReleased); mMouse.MouseMoved += new MOIS.MouseListener.MouseMovedHandler(mMouse_MouseMoved); mMouse.MousePressed += new MOIS.MouseListener.MousePressedHandler(mMouse_MousePressed); mMouse.MouseReleased += new MOIS.MouseListener.MouseReleasedHandler(mMouse_MouseReleased); if (mInputManager.GetNumberOfDevices(MOIS.Type.OISJoyStick) > 0) { mJoystick.ButtonPressed += new MOIS.JoyStickListener.ButtonPressedHandler(mJoystick_ButtonPressed); mJoystick.ButtonReleased += new MOIS.JoyStickListener.ButtonReleasedHandler(mJoystick_ButtonReleased); mJoystick.AxisMoved += new MOIS.JoyStickListener.AxisMovedHandler(mJoystick_AxisMoved); } }
protected override HandleRef BuildWindowCore(HandleRef hwndParent) { NameValuePairList misc = new NameValuePairList(); misc["parentWindowHandle"] = hwndParent.Handle.ToString(); m_RenderWindow = m_Root.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc); CreateCamera(); Viewport viewport = m_RenderWindow.AddViewport(m_Camera); viewport.BackgroundColour = ColourValue.Black; m_Camera.AspectRatio = (double)viewport.ActualWidth / (double)viewport.ActualHeight; int windowHandle; m_RenderWindow.GetCustomAttribute("WINDOW", out windowHandle); return(new HandleRef(this, new IntPtr(windowHandle))); }
public virtual void CreateInput() { IntPtr handle; window.GetCustomAttribute("HWND", out handle); MOIS.ParamList pl = new MOIS.ParamList(); pl.Insert("WINDOW", handle.ToString()); //Default mode is foreground exclusive..but, we want to show mouse - so nonexclusive pl.Insert("w32_mouse", "DISCL_FOREGROUND"); pl.Insert("w32_mouse", "DISCL_NONEXCLUSIVE"); //This never returns null.. it will raise an exception on errors MOIS.InputManager g_InputManager = MOIS.InputManager.CreateInputSystem(pl); input = (MOIS.Keyboard)g_InputManager.CreateInputObject(MOIS.Type.OISKeyboard, false); }
public void SetupBrowser() { RenderWindow rw = (Root.Instance.RenderSystem as D3D9RenderSystem).PrimaryWindow; Control c = (Control)rw.GetCustomAttribute("HWND"); // dummy label used to 'unfocus' the browser dummy = new Label(); dummy.Size = new Size(1, 1); dummy.Location = new Point(1, 1); Controls.Add(dummy); dummy.CreateControl(); b = new WebBrowser(); PositionBrowser(); Controls.Add(b); b.CreateControl(); b.BringToFront(); c.Controls.Add(this); CreateControl(); }
protected static void InitializeInput() { int windowHandle; mRenderWindow.GetCustomAttribute("WINDOW", out windowHandle); ParamList pl = new ParamList(); pl.Insert("WINDOW", windowHandle.ToString()); pl.Insert("w32_mouse", "DISCL_FOREGROUND"); pl.Insert("w32_mouse", "DISCL_NONEXCLUSIVE"); pl.Insert("w32_keyboard", "DISCL_FOREGROUND"); pl.Insert("w32_keyboard", "DISCL_NONEXCLUSIVE"); mInputMgr = MOIS.InputManager.CreateInputSystem(pl); mNinjaKeyboard = (MOIS.Keyboard)mInputMgr.CreateInputObject(MOIS.Type.OISKeyboard, false); mNinjaMouse = (MOIS.Mouse)mInputMgr.CreateInputObject(MOIS.Type.OISMouse, true); mNinjaMouse.MousePressed += MousePressed; var state = mNinjaMouse.MouseState; state.height = 600; state.width = 800; }
public void Initialise() { m_Root = new Root(); ConfigFile cf = new ConfigFile(); cf.Load("Resources.cfg", "\t:=", true); ConfigFile.SectionIterator seci = cf.GetSectionIterator(); while (seci.MoveNext()) { ConfigFile.SettingsMultiMap settings = seci.Current; foreach (KeyValuePair<string, string> pair in settings) ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey); } if (!m_Root.RestoreConfig()) if (!m_Root.ShowConfigDialog()) return; m_RenderWindow = m_Root.Initialise(true); ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); m_SceneManager = m_Root.CreateSceneManager(SceneType.ST_GENERIC); m_Camera = m_SceneManager.CreateCamera("MainCamera"); m_Viewport = m_RenderWindow.AddViewport(m_Camera); m_Camera.NearClipDistance = 0.1f; m_Camera.FarClipDistance = 1000.0f; MOIS.ParamList pl = new MOIS.ParamList(); IntPtr windowHnd; m_RenderWindow.GetCustomAttribute("WINDOW", out windowHnd); pl.Insert("WINDOW", windowHnd.ToString()); m_InputManager = MOIS.InputManager.CreateInputSystem(pl); m_Keyboard = (MOIS.Keyboard)m_InputManager.CreateInputObject(MOIS.Type.OISKeyboard, false); m_Mouse = (MOIS.Mouse)m_InputManager.CreateInputObject(MOIS.Type.OISMouse, false); m_NewtonWorld = new World(); m_NewtonDebugger = new Debugger(m_NewtonWorld); m_NewtonDebugger.Init(m_SceneManager); m_GameCamera = new GameCamera(); m_ObjectManager = new ObjectManager(); }
protected override HandleRef BuildWindowCore(HandleRef hwndParent) { NameValuePairList misc = new NameValuePairList(); misc["parentWindowHandle"] = hwndParent.Handle.ToString(); m_RenderWindow = m_Root.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc); CreateCamera(); Viewport viewport = m_RenderWindow.AddViewport(m_Camera); viewport.BackgroundColour = ColourValue.Black; m_Camera.AspectRatio = (double)viewport.ActualWidth / (double)viewport.ActualHeight; int windowHandle; m_RenderWindow.GetCustomAttribute("WINDOW", out windowHandle); return new HandleRef(this, new IntPtr(windowHandle)); }
public void Initialise() { Root = new Root(); ConfigFile cf = new ConfigFile(); cf.Load("Resources.cfg", "\t:=", true); ConfigFile.SectionIterator seci = cf.GetSectionIterator(); while (seci.MoveNext()) { ConfigFile.SettingsMultiMap settings = seci.Current; foreach (KeyValuePair <string, string> pair in settings) { ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey); } } if (!Root.RestoreConfig()) { if (!Root.ShowConfigDialog()) { return; } } Root.RenderSystem.SetConfigOption("VSync", "Yes"); RenderWindow = Root.Initialise(true, "Kolejny epicki erpeg"); // @@@@@@@@@@@@@@@ Nazwa okna gry. ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); SceneManager = Root.CreateSceneManager(SceneType.ST_GENERIC); Camera = SceneManager.CreateCamera("MainCamera"); Viewport = RenderWindow.AddViewport(Camera); Camera.NearClipDistance = 0.1f; Camera.FarClipDistance = 1000.0f; Camera.AspectRatio = ((float)RenderWindow.Width / (float)RenderWindow.Height); MOIS.ParamList pl = new MOIS.ParamList(); IntPtr windowHnd; RenderWindow.GetCustomAttribute("WINDOW", out windowHnd); pl.Insert("WINDOW", windowHnd.ToString()); InputManager = MOIS.InputManager.CreateInputSystem(pl); Keyboard = (MOIS.Keyboard)InputManager.CreateInputObject(MOIS.Type.OISKeyboard, true); Mouse = (MOIS.Mouse)InputManager.CreateInputObject(MOIS.Type.OISMouse, true); NewtonWorld = new World(); NewtonDebugger = new Debugger(NewtonWorld); NewtonDebugger.Init(SceneManager); GameCamera = new GameCamera(); ObjectManager = new ObjectManager(); MaterialManager = new MaterialManager(); MaterialManager.Initialise(); Items = new Items(); PrizeManager = new PrizeManager(); //////////////////// @@ Brand nju staff. Nawet trochę działa :Δ CharacterProfileManager = new CharacterProfileManager(); Quests = new Quests(); NPCManager = new NPCManager(); Labeler = new TextLabeler(5); Random = new Random(); HumanController = new HumanController(); TypedInput = new TypedInput(); SoundManager = new SoundManager(); Dialog = new Dialog(); Mysz = new MOIS.MouseState_NativePtr(); Conversations = new Conversations(); TriggerManager = new TriggerManager(); Engine.Singleton.Keyboard.KeyPressed += new MOIS.KeyListener.KeyPressedHandler(TypedInput.onKeyPressed); Mouse.MouseReleased += new MOIS.MouseListener.MouseReleasedHandler(MouseReleased); IngameConsole = new IngameConsole(); IngameConsole.Init(); IngameConsole.AddCommand("dupa", "soundOddawajPiec"); IngameConsole.AddCommand("tp", "ZejscieDoPiwnicy"); IngameConsole.AddCommand("exit", "Exit", "Wychodzi z gry. Ale odkrywcze. Super. Musze sprawdzic jak sie zachowa konsola przy duzej dlugosci linii xD llllllllllllllllllllllllllllllllllllllllllllmmmmmmmmmmmmmmmmmmmmmiiiiiiiiiiiiiiii"); IngameConsole.AddCommand("play", "playSound", "Odtwarza dzwiek. Skladnia: play <sciezka do pliku>. Np. play other/haa.mp3"); IngameConsole.AddCommand("map", "ChangeMap"); IngameConsole.AddCommand("save", "SaveGame"); IngameConsole.AddCommand("load", "LoadGame"); IngameConsole.AddCommand("help", "ConsoleHelp"); IngameConsole.AddCommand("h", "CommandHelp"); }
public void Initialise() { Root = new Root(); ConfigFile cf = new ConfigFile(); cf.Load("Resources.cfg", "\t:=", true); ConfigFile.SectionIterator seci = cf.GetSectionIterator(); while (seci.MoveNext()) { ConfigFile.SettingsMultiMap settings = seci.Current; foreach (KeyValuePair <string, string> pair in settings) { ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey); } } if (!Root.RestoreConfig()) { if (!Root.ShowConfigDialog()) { return; } } Root.RenderSystem.SetConfigOption("VSync", "Yes"); RenderWindow = Root.Initialise(true, "WorldCreator"); // @@@@@@@@@@@@@@@ Nazwa okna gry. ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); SceneManager = Root.CreateSceneManager(SceneType.ST_GENERIC); Camera = SceneManager.CreateCamera("MainCamera"); Viewport = RenderWindow.AddViewport(Camera); Camera.NearClipDistance = 0.1f; Camera.FarClipDistance = 1000.0f; Camera.AspectRatio = ((float)RenderWindow.Width / (float)RenderWindow.Height); MOIS.ParamList pl = new MOIS.ParamList(); IntPtr windowHnd; RenderWindow.GetCustomAttribute("WINDOW", out windowHnd); pl.Insert("WINDOW", windowHnd.ToString()); InputManager = MOIS.InputManager.CreateInputSystem(pl); Keyboard = (MOIS.Keyboard)InputManager.CreateInputObject(MOIS.Type.OISKeyboard, false); Mouse = (MOIS.Mouse)InputManager.CreateInputObject(MOIS.Type.OISMouse, false); NewtonWorld = new World(); NewtonDebugger = new Debugger(NewtonWorld); NewtonDebugger.Init(SceneManager); ObjectManager = new ObjectManager(); MaterialManager = new MaterialManager(); MaterialManager.Initialise(); //CharacterProfileManager = new CharacterProfileManager(); Items = new Items(); //PrizeManager = new PrizeManager(); //////////////////// @@ Brand nju staff. Nawet trochę działa :Δ //Quests = new Quests(); //NPCManager = new NPCManager(); Labeler = new TextLabeler(5); User = new Player(); CharacterProfileManager = new CharacterProfileManager(); NPCManager = new NPCManager(); HumanController = new HumanController(); TypedInput = new TypedInput(); //SoundManager = new SoundManager(); }
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 void Initialise() { Root = new Root(); ConfigFile cf = new ConfigFile(); cf.Load("Resources.cfg", "\t:=", true); ConfigFile.SectionIterator seci = cf.GetSectionIterator(); while (seci.MoveNext()) { ConfigFile.SettingsMultiMap settings = seci.Current; foreach (KeyValuePair<string, string> pair in settings) ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey); } if (!Root.RestoreConfig()) if (!Root.ShowConfigDialog()) return; Root.RenderSystem.SetConfigOption("VSync", "Yes"); RenderWindow = Root.Initialise(true, "WorldCreator"); // @@@@@@@@@@@@@@@ Nazwa okna gry. ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); SceneManager = Root.CreateSceneManager(SceneType.ST_GENERIC); Camera = SceneManager.CreateCamera("MainCamera"); Viewport = RenderWindow.AddViewport(Camera); Camera.NearClipDistance = 0.1f; Camera.FarClipDistance = 1000.0f; Camera.AspectRatio = ((float)RenderWindow.Width / (float)RenderWindow.Height); MOIS.ParamList pl = new MOIS.ParamList(); IntPtr windowHnd; RenderWindow.GetCustomAttribute("WINDOW", out windowHnd); pl.Insert("WINDOW", windowHnd.ToString()); InputManager = MOIS.InputManager.CreateInputSystem(pl); Keyboard = (MOIS.Keyboard)InputManager.CreateInputObject(MOIS.Type.OISKeyboard, false); Mouse = (MOIS.Mouse)InputManager.CreateInputObject(MOIS.Type.OISMouse, false); NewtonWorld = new World(); NewtonDebugger = new Debugger(NewtonWorld); NewtonDebugger.Init(SceneManager); ObjectManager = new ObjectManager(); MaterialManager = new MaterialManager(); MaterialManager.Initialise(); //CharacterProfileManager = new CharacterProfileManager(); Items = new Items(); //PrizeManager = new PrizeManager(); //////////////////// @@ Brand nju staff. Nawet trochę działa :Δ //Quests = new Quests(); //NPCManager = new NPCManager(); Labeler = new TextLabeler(5); User = new Player(); CharacterProfileManager = new CharacterProfileManager(); NPCManager = new NPCManager(); HumanController = new HumanController(); TypedInput = new TypedInput(); //SoundManager = new SoundManager(); }
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); }
private bool InitRender(string wndTitle, ref Dictionary <string, string> 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 = new Dictionary <string, string>(); IniConfigFile cf = (IniConfigFile)parser.Load("Game.cfg"); var sections = cf.Sections; foreach (var section in sections) { foreach (var kpl in section.KeyValuePairs) { gameOptions.Add(kpl.Key, kpl.Value); } } cf = (IniConfigFile)parser.Load("ogre.cfg"); sections = cf.Sections; string renderSystem = null; foreach (var section in sections) { if (section.Name == "") { foreach (var kpl in section.KeyValuePairs) { renderSystem = kpl.Value; gameOptions.Add(kpl.Key, kpl.Value); } } else if (section.Name == renderSystem) { foreach (var kpl in section.KeyValuePairs) { gameOptions.Add("Render Params_" + kpl.Key, kpl.Value); } } } } defaultRenderSystemName = gameOptions.Where(o => o.Key == "Render System").First().Value; var renderParams = gameOptions.Where(o => o.Key.StartsWith("Render Params")); if (!string.IsNullOrEmpty(defaultRenderSystemName)) { var videModeRenderParam = renderParams.Where(o => o.Key == "Render Params_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.Key.Split('_')[1]; 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); 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 = InputManager.CreateInputSystem((uint)hWnd); keyboard = (Keyboard)inputMgr.CreateInputObject(MOIS.Type.OISKeyboard, true); mouse = (Mouse)inputMgr.CreateInputObject(MOIS.Type.OISMouse, true); mouse.MouseMoved += new MouseListener.MouseMovedHandler(mouseMoved); mouse.MousePressed += new MouseListener.MousePressedHandler(mousePressed); mouse.MouseReleased += new MouseListener.MouseReleasedHandler(mouseReleased); keyboard.KeyPressed += new KeyListener.KeyPressedHandler(keyPressed); keyboard.KeyReleased += new KeyListener.KeyReleasedHandler(keyReleased); MouseState_NativePtr mouseState = mouse.MouseState; mouseState.width = viewport.ActualWidth; mouseState.height = viewport.ActualHeight; string secName, typeName, archName; IniConfigFile conf = new IniConfigFile(); conf = (IniConfigFile)parser.Load("resources.cfg"); for (int i = 0; i < conf.Sections.Count; i++) { secName = conf.Sections[i].Name; for (int j = 0; j < conf.Sections[i].KeyValuePairs.Count; j++) { typeName = conf.Sections[i].KeyValuePairs[j].Key; archName = conf.Sections[i].KeyValuePairs[j].Value; ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName); } } if (!LocateSystem.Singleton.IsInit) { LocateSystem.Singleton.InitLocateSystem(LocateSystem.Singleton.ConvertLocateShortStringToLocateInfo(gameOptions.Where(o => o.Key == "CurrentLocate").First().Value)); } ResourceGroupManager.Singleton.AddResourceLocation( string.Format("./Media/Engine/Fonts/{0}/", LocateSystem.Singleton.Locate.ToString()), "FileSystem", "General"); TextureManager.Singleton.DefaultNumMipmaps = 5; ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); trayMgr = new SdkTrayManager("AMOFTrayMgr", renderWindow, mouse, new SdkTrayListener()); timer = new Timer(); timer.Reset(); renderWindow.IsActive = true; this.gameOptions = gameOptions; log.LogMessage("Game Started!"); return(true); }
public void Initialise() { Root = new Root(); ConfigFile cf = new ConfigFile(); cf.Load("Resources.cfg", "\t:=", true); ConfigFile.SectionIterator seci = cf.GetSectionIterator(); while (seci.MoveNext()) { ConfigFile.SettingsMultiMap settings = seci.Current; foreach (KeyValuePair<string, string> pair in settings) ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey); } if (!Root.RestoreConfig()) if (!Root.ShowConfigDialog()) return; Root.RenderSystem.SetConfigOption("VSync", "Yes"); RenderWindow = Root.Initialise(true, "Kolejny epicki erpeg"); // @@@@@@@@@@@@@@@ Nazwa okna gry. ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); SceneManager = Root.CreateSceneManager(SceneType.ST_GENERIC); Camera = SceneManager.CreateCamera("MainCamera"); Viewport = RenderWindow.AddViewport(Camera); Camera.NearClipDistance = 0.1f; Camera.FarClipDistance = 1000.0f; Camera.AspectRatio = ((float)RenderWindow.Width / (float)RenderWindow.Height); MOIS.ParamList pl = new MOIS.ParamList(); IntPtr windowHnd; RenderWindow.GetCustomAttribute("WINDOW", out windowHnd); pl.Insert("WINDOW", windowHnd.ToString()); InputManager = MOIS.InputManager.CreateInputSystem(pl); Keyboard = (MOIS.Keyboard)InputManager.CreateInputObject(MOIS.Type.OISKeyboard, true); Mouse = (MOIS.Mouse)InputManager.CreateInputObject(MOIS.Type.OISMouse, true); NewtonWorld = new World(); NewtonDebugger = new Debugger(NewtonWorld); NewtonDebugger.Init(SceneManager); GameCamera = new GameCamera(); ObjectManager = new ObjectManager(); MaterialManager = new MaterialManager(); MaterialManager.Initialise(); Items = new Items(); PrizeManager = new PrizeManager(); //////////////////// @@ Brand nju staff. Nawet trochę działa :Δ CharacterProfileManager = new CharacterProfileManager(); Quests = new Quests(); NPCManager = new NPCManager(); Labeler = new TextLabeler(5); Random = new Random(); HumanController = new HumanController(); TypedInput = new TypedInput(); SoundManager = new SoundManager(); Dialog = new Dialog(); Mysz = new MOIS.MouseState_NativePtr(); Conversations = new Conversations(); TriggerManager = new TriggerManager(); Engine.Singleton.Keyboard.KeyPressed += new MOIS.KeyListener.KeyPressedHandler(TypedInput.onKeyPressed); Mouse.MouseReleased += new MOIS.MouseListener.MouseReleasedHandler(MouseReleased); IngameConsole = new IngameConsole(); IngameConsole.Init(); IngameConsole.AddCommand("dupa", "soundOddawajPiec"); IngameConsole.AddCommand("tp", "ZejscieDoPiwnicy"); IngameConsole.AddCommand("exit", "Exit", "Wychodzi z gry. Ale odkrywcze. Super. Musze sprawdzic jak sie zachowa konsola przy duzej dlugosci linii xD llllllllllllllllllllllllllllllllllllllllllllmmmmmmmmmmmmmmmmmmmmmiiiiiiiiiiiiiiii"); IngameConsole.AddCommand("play", "playSound", "Odtwarza dzwiek. Skladnia: play <sciezka do pliku>. Np. play other/haa.mp3"); IngameConsole.AddCommand("map", "ChangeMap"); IngameConsole.AddCommand("save", "SaveGame"); IngameConsole.AddCommand("load", "LoadGame"); IngameConsole.AddCommand("help", "ConsoleHelp"); IngameConsole.AddCommand("h", "CommandHelp"); }