protected virtual IMyRenderWindow InitializeRenderThread() { Debug.Assert(MyPerGameSettings.GameIcon != null, "Set the game icon file in executable project."); DrawThread = Thread.CurrentThread; var form = new MySandboxForm(); WindowHandle = form.Handle; m_bufferedInputSource = form; m_windowCreatedEvent.Set(); form.Text = MyPerGameSettings.GameName; try { form.Icon = new System.Drawing.Icon(Path.Combine(MyFileSystem.ExePath, MyPerGameSettings.GameIcon)); } catch (System.IO.FileNotFoundException e) { form.Icon = null; } form.FormClosed += (o, e) => ExitThreadSafe(); Action showCursor = () => { if (!form.IsDisposed) form.ShowCursor = true; }; Action hideCursor = () => { if (!form.IsDisposed) form.ShowCursor = false; }; m_setMouseVisible = (b) => { // In case of crash, this may be null, don't want subsequent crash var component = GameRenderComponent; if (component != null) { var renderThread = component.RenderThread; if (renderThread != null) { renderThread.Invoke(b ? showCursor : hideCursor); } } }; return form; }
public MyXInputInput( IMyBufferedInputSource textInputBuffer, IMyControlNameLookup nameLookup, Dictionary<MyStringId, MyControl> gameControls, bool enableDevKeys) { m_bufferedInputSource = textInputBuffer; m_nameLookup = nameLookup; m_defaultGameControlsList = gameControls; m_gameControlsList = new Dictionary<MyStringId, MyControl>(MyStringId.Comparer); m_gameControlsSnapshot = new Dictionary<MyStringId, MyControl>(MyStringId.Comparer); CloneControls(m_defaultGameControlsList, m_gameControlsList); ENABLE_DEVELOPER_KEYS = enableDevKeys; }
protected virtual IMyRenderWindow InitializeRenderThread() { Debug.Assert(MyPerGameSettings.GameIcon != null, "Set the game icon file in executable project."); DrawThread = Thread.CurrentThread; #if XB1 var form = new XB1Interface.XB1GameWindow(); #else var form = new MySandboxForm(); WindowHandle = form.Handle; #endif m_bufferedInputSource = form; m_windowCreatedEvent.Set(); #if !XB1 form.Text = MyPerGameSettings.GameName; try { form.Icon = new System.Drawing.Icon(Path.Combine(MyFileSystem.ExePath, MyPerGameSettings.GameIcon)); } catch (System.IO.FileNotFoundException) { form.Icon = null; } #endif // !XB1 form.FormClosed += (o, e) => ExitThreadSafe(); #if !XB1 Action showCursor = () => { if (!form.IsDisposed) form.ShowCursor = true; }; Action hideCursor = () => { if (!form.IsDisposed) form.ShowCursor = false; }; m_setMouseVisible = (b) => { // In case of crash, this may be null, don't want subsequent crash var component = GameRenderComponent; if (component != null) { var renderThread = component.RenderThread; if (renderThread != null) { renderThread.Invoke(b ? showCursor : hideCursor); } } }; if (MySandboxGame.Config.SyncRendering) { VRageRender.MyViewport vp = new MyViewport(0, 0, (float)MySandboxGame.Config.ScreenWidth, (float)MySandboxGame.Config.ScreenHeight); RenderThread_SizeChanged((int)vp.Width, (int)vp.Height, vp); } #endif // !XB1 return form; }