Inheritance: SharpDXHost
コード例 #1
0
        public ToolTipService(MapControl3D control)
        {
            m_control       = control;
            m_hoverTileView = control.HoverTileView;

            m_content             = new TileToolTipControl();
            m_content.DataContext = m_hoverTileView;

            var popup = new ToolTip();

            popup.Content          = m_content;
            popup.Placement        = System.Windows.Controls.Primitives.PlacementMode.Right;
            popup.HorizontalOffset = 4;
            popup.PlacementTarget  = m_control;
            m_popup = popup;

            // Disable the animations, because we lose datacontext during fade-out animation.
            // We need to override the default values in the PlacementTarget control
            m_control.Resources.Add(SystemParameters.ToolTipAnimationKey, false);
            m_control.Resources.Add(SystemParameters.ToolTipFadeKey, false);
            m_control.Resources.Add(SystemParameters.ToolTipPopupAnimationKey, PopupAnimation.None);

            this.IsToolTipEnabled = true;

            m_control.GotMouseCapture  += (s, e) => this.IsToolTipEnabled = false;
            m_control.LostMouseCapture += (s, e) => this.IsToolTipEnabled = true;
        }
コード例 #2
0
ファイル: ToolTipService.cs プロジェクト: tomba/dwarrowdelf
        public ToolTipService(MapControl3D control)
        {
            m_control = control;
            m_hoverTileView = control.HoverTileView;

            m_content = new TileToolTipControl();
            m_content.DataContext = m_hoverTileView;

            var popup = new ToolTip();
            popup.Content = m_content;
            popup.Placement = System.Windows.Controls.Primitives.PlacementMode.Right;
            popup.HorizontalOffset = 4;
            popup.PlacementTarget = m_control;
            m_popup = popup;

            // Disable the animations, because we lose datacontext during fade-out animation.
            // We need to override the default values in the PlacementTarget control
            m_control.Resources.Add(SystemParameters.ToolTipAnimationKey, false);
            m_control.Resources.Add(SystemParameters.ToolTipFadeKey, false);
            m_control.Resources.Add(SystemParameters.ToolTipPopupAnimationKey, PopupAnimation.None);

            this.IsToolTipEnabled = true;

            m_control.GotMouseCapture += (s, e) => this.IsToolTipEnabled = false;
            m_control.LostMouseCapture += (s, e) => this.IsToolTipEnabled = true;
        }
コード例 #3
0
        public KeyboardHandler(MapControl3D mapControl)
        {
            mapControl.KeyDown   += this.OnKeyDown;
            mapControl.KeyUp     += this.OnKeyUp;
            mapControl.TextInput += this.OnTextInput;

            GameData.Data.GameModeChanged += (mode) =>
            {
                switch (mode)
                {
                case GameMode.Undefined:
                    this.Mode = KeyHandlerMode.None;
                    break;

                case GameMode.Adventure:
                    this.Mode = KeyHandlerMode.LivingControl;
                    break;

                case GameMode.Fortress:
                    this.Mode = KeyHandlerMode.FortressControl;
                    break;
                }
            };

            this.Mode = KeyHandlerMode.None;
        }
コード例 #4
0
        public CameraKeyHandler(MyGame game, MapControl3D control)
        {
            m_game    = game;
            m_control = control;

            control.TextInput         += OnTextInput;
            control.KeyDown           += OnKeyDown;
            control.KeyUp             += OnKeyUp;
            control.LostKeyboardFocus += OnLostKeyboardFocus;
        }
コード例 #5
0
ファイル: CameraKeyHandler.cs プロジェクト: tomba/dwarrowdelf
        public CameraKeyHandler(MyGame game, MapControl3D control)
        {
            m_game = game;
            m_control = control;

            control.TextInput += OnTextInput;
            control.KeyDown += OnKeyDown;
            control.KeyUp += OnKeyUp;
            control.LostKeyboardFocus += OnLostKeyboardFocus;
        }
コード例 #6
0
        public MyGame(MapControl3D mainHost)
        {
            //SharpDX.Configuration.EnableObjectTracking = true;

            this.Camera = new Camera();
            this.Camera.LookAt(new Vector3(4, 0, 0), new Vector3(0, 0, 0), Vector3.UnitZ);

            this.CameraMoveService = new CameraMoveService(this.Camera);
            base.Updatables.Add(this.CameraMoveService);

            this.ViewGridAdjusterService = new ViewGridAdjusterService(this, mainHost);
            base.Updatables.Add(this.ViewGridAdjusterService);

            this.ViewGridProvider = new ViewGridProvider(this);

            this.CameraKeyHandler = new CameraKeyHandler(this, mainHost);
            base.Updatables.Add(this.CameraKeyHandler);

            m_fpsCounter = new FPSCounter(this);
            base.Updatables.Add(m_fpsCounter);

            this.CursorService = new CursorService(this, mainHost);


            var mainView = new GameSurfaceView(this.GraphicsDevice)
            {
                Camera = this.Camera,
            };

            var axesView = new GameSurfaceView(this.GraphicsDevice)
            {
                Camera = this.Camera,
            };

            var surface = ToDispose(new GameSurface(this.GraphicsDevice, mainHost));

            surface.Views.Add(mainView);
            surface.Views.Add(axesView);

            surface.SizeChanged += (w, h) =>
            {
                var vp = new ViewportF(0, 0, w, h);
                mainView.ViewPort = vp;
                mainView.Camera.SetAspect(vp.AspectRatio);

                axesView.ViewPort = new ViewportF(0, 0, 50, 50);
            };

            base.Surfaces.Add(surface);

            this.MousePositionService = new MousePositionService(this, mainHost, mainView);
            base.Updatables.Add(this.MousePositionService);

            this.SelectionService = new Client.SelectionService(this, mainHost, this.Camera);

            this.TerrainRenderer = ToDispose(new TerrainRenderer(this, this.Camera, this.ViewGridProvider));
            base.Updatables.Add(this.TerrainRenderer);
            mainView.Drawables.Add(this.TerrainRenderer);

            m_symbolRenderer = ToDispose(new SymbolRenderer(this, this.ViewGridProvider));
            base.Updatables.Add(m_symbolRenderer);
            mainView.Drawables.Add(m_symbolRenderer);

            m_selectionRenderer = ToDispose(new SelectionRenderer(this));
            base.Updatables.Add(m_selectionRenderer);
            mainView.Drawables.Add(m_selectionRenderer);

            m_designationRenderer = ToDispose(new DesignationRenderer(this));
            base.Updatables.Add(m_designationRenderer);
            mainView.Drawables.Add(m_designationRenderer);

            m_debugAxesRenderer = ToDispose(new DebugAxesRenderer(this));
            base.Updatables.Add(m_debugAxesRenderer);
            axesView.Drawables.Add(m_debugAxesRenderer);

#if OUTLINERENDERER
            m_outlineRenderer = ToDispose(new ChunkOutlineRenderer(this, this.TerrainRenderer.ChunkManager));
            base.Updatables.Add(m_outlineRenderer);
            mainView.Drawables.Add(m_outlineRenderer);
#endif

#if TESTCUBERENDERER
            m_testCubeRenderer = ToDispose(new TestCubeRenderer(this));
            base.Updatables.Add(m_testCubeRenderer);
            mainView.Drawables.Add(m_testCubeRenderer);
#endif

            this.RasterizerState = this.GraphicsDevice.RasterizerStates.CullBack;
        }
コード例 #7
0
 public ViewGridAdjusterService(MyGame game, MapControl3D control)
 {
     m_game = game;
     m_control = control;
 }
コード例 #8
0
ファイル: KeyboardHandler.cs プロジェクト: tomba/dwarrowdelf
        public KeyboardHandler(MapControl3D mapControl)
        {
            mapControl.KeyDown += this.OnKeyDown;
            mapControl.KeyUp += this.OnKeyUp;
            mapControl.TextInput += this.OnTextInput;

            GameData.Data.GameModeChanged += (mode) =>
            {
                switch (mode)
                {
                    case GameMode.Undefined:
                        this.Mode = KeyHandlerMode.None;
                        break;

                    case GameMode.Adventure:
                        this.Mode = KeyHandlerMode.LivingControl;
                        break;

                    case GameMode.Fortress:
                        this.Mode = KeyHandlerMode.FortressControl;
                        break;
                }
            };

            this.Mode = KeyHandlerMode.None;
        }
コード例 #9
0
 public ViewGridAdjusterService(MyGame game, MapControl3D control)
 {
     m_game    = game;
     m_control = control;
 }
コード例 #10
0
ファイル: MyGame.cs プロジェクト: tomba/dwarrowdelf
        public MyGame(MapControl3D mainHost)
        {
            //SharpDX.Configuration.EnableObjectTracking = true;

            this.Camera = new Camera();
            this.Camera.LookAt(new Vector3(4, 0, 0), new Vector3(0, 0, 0), Vector3.UnitZ);

            this.CameraMoveService = new CameraMoveService(this.Camera);
            base.Updatables.Add(this.CameraMoveService);

            this.ViewGridAdjusterService = new ViewGridAdjusterService(this, mainHost);
            base.Updatables.Add(this.ViewGridAdjusterService);

            this.ViewGridProvider = new ViewGridProvider(this);

            this.CameraKeyHandler = new CameraKeyHandler(this, mainHost);
            base.Updatables.Add(this.CameraKeyHandler);

            m_fpsCounter = new FPSCounter(this);
            base.Updatables.Add(m_fpsCounter);

            this.CursorService = new CursorService(this, mainHost);

            var mainView = new GameSurfaceView(this.GraphicsDevice)
            {
                Camera = this.Camera,
            };

            var axesView = new GameSurfaceView(this.GraphicsDevice)
            {
                Camera = this.Camera,
            };

            var surface = ToDispose(new GameSurface(this.GraphicsDevice, mainHost));

            surface.Views.Add(mainView);
            surface.Views.Add(axesView);

            surface.SizeChanged += (w, h) =>
            {
                var vp = new ViewportF(0, 0, w, h);
                mainView.ViewPort = vp;
                mainView.Camera.SetAspect(vp.AspectRatio);

                axesView.ViewPort = new ViewportF(0, 0, 50, 50);
            };

            base.Surfaces.Add(surface);

            this.MousePositionService = new MousePositionService(this, mainHost, mainView);
            base.Updatables.Add(this.MousePositionService);

            this.SelectionService = new Client.SelectionService(this, mainHost, this.Camera);

            this.TerrainRenderer = ToDispose(new TerrainRenderer(this, this.Camera, this.ViewGridProvider));
            base.Updatables.Add(this.TerrainRenderer);
            mainView.Drawables.Add(this.TerrainRenderer);

            m_symbolRenderer = ToDispose(new SymbolRenderer(this, this.ViewGridProvider));
            base.Updatables.Add(m_symbolRenderer);
            mainView.Drawables.Add(m_symbolRenderer);

            m_selectionRenderer = ToDispose(new SelectionRenderer(this));
            base.Updatables.Add(m_selectionRenderer);
            mainView.Drawables.Add(m_selectionRenderer);

            m_designationRenderer = ToDispose(new DesignationRenderer(this));
            base.Updatables.Add(m_designationRenderer);
            mainView.Drawables.Add(m_designationRenderer);

            m_debugAxesRenderer = ToDispose(new DebugAxesRenderer(this));
            base.Updatables.Add(m_debugAxesRenderer);
            axesView.Drawables.Add(m_debugAxesRenderer);

            #if OUTLINERENDERER
            m_outlineRenderer = ToDispose(new ChunkOutlineRenderer(this, this.TerrainRenderer.ChunkManager));
            base.Updatables.Add(m_outlineRenderer);
            mainView.Drawables.Add(m_outlineRenderer);
            #endif

            #if TESTCUBERENDERER
            m_testCubeRenderer = ToDispose(new TestCubeRenderer(this));
            base.Updatables.Add(m_testCubeRenderer);
            mainView.Drawables.Add(m_testCubeRenderer);
            #endif

            this.RasterizerState = this.GraphicsDevice.RasterizerStates.CullBack;
        }