SetTooltip() 공개 메소드

public SetTooltip ( string tooltip ) : void
tooltip string
리턴 void
예제 #1
0
        public bool HandleMouseInput(MouseInput mi)
        {
            // Exclusively uses mouse wheel and both mouse buttons, but nothing else
            // Mouse move events are important for tooltips, so we always allow these through
            if ((mi.Button != MouseButton.Left && mi.Button != MouseButton.Right &&
                 mi.Event != MouseInputEvent.Move && mi.Event != MouseInputEvent.Scroll) ||
                mi.Event == MouseInputEvent.Down)
            {
                return(false);
            }

            worldPixel = worldRenderer.Viewport.ViewToWorldPx(mi.Location);
            var cell = worldRenderer.Viewport.ViewToWorld(mi.Location);

            var underCursor         = editorLayer.PreviewsAt(worldPixel).MinByOrDefault(CalculateActorSelectionPriority);
            var resourceUnderCursor = resourceLayer?.GetResource(cell).Type;

            if (underCursor != null)
            {
                editorWidget.SetTooltip(underCursor.Tooltip);
            }
            else if (resourceUnderCursor != null)
            {
                editorWidget.SetTooltip(resourceUnderCursor);
            }
            else
            {
                editorWidget.SetTooltip(null);
            }

            // Finished with mouse move events, so let them bubble up the widget tree
            if (mi.Event == MouseInputEvent.Move)
            {
                return(false);
            }

            if (mi.Button == MouseButton.Left)
            {
                editorWidget.SetTooltip(null);
                SelectedActor = underCursor;
            }

            if (mi.Button == MouseButton.Right)
            {
                editorWidget.SetTooltip(null);

                if (underCursor != null && underCursor != SelectedActor)
                {
                    editorActionManager.Add(new RemoveActorAction(editorLayer, underCursor));
                }

                if (resourceUnderCursor != null)
                {
                    editorActionManager.Add(new RemoveResourceAction(resourceLayer, cell, resourceUnderCursor));
                }
            }

            return(true);
        }
예제 #2
0
        public bool HandleMouseInput(MouseInput mi)
        {
            // Exclusively uses left and right mouse buttons, but nothing else
            // Mouse move events are important for tooltips, so we always allow these through
            if (mi.Button != MouseButton.Left && mi.Button != MouseButton.Right && mi.Event != MouseInputEvent.Move)
            {
                return(false);
            }

            var cell = worldRenderer.Viewport.ViewToWorld(mi.Location);

            if (mi.Event == MouseInputEvent.Up)
            {
                return(true);
            }

            var underCursor = editorLayer.PreviewsAt(worldRenderer.Viewport.ViewToWorldPx(mi.Location))
                              .FirstOrDefault();

            var          mapResources = world.Map.MapResources.Value;
            ResourceType type;

            if (underCursor != null)
            {
                editorWidget.SetTooltip(underCursor.Tooltip);
            }
            else if (mapResources.Contains(cell) && resources.TryGetValue(mapResources[cell].Type, out type))
            {
                editorWidget.SetTooltip(type.Info.Name);
            }
            else
            {
                editorWidget.SetTooltip(null);
            }

            // Finished with mouse move events, so let them bubble up the widget tree
            if (mi.Event == MouseInputEvent.Move)
            {
                return(false);
            }

            if (mi.Button == MouseButton.Right)
            {
                editorWidget.SetTooltip(null);

                if (underCursor != null)
                {
                    editorLayer.Remove(underCursor);
                }

                if (mapResources.Contains(cell) && mapResources[cell].Type != 0)
                {
                    mapResources[cell] = new ResourceTile();
                }
            }
            else if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down)
            {
                if (underCursor != null)
                {
                    // Test case / demonstration of how to edit an existing actor
                    var facing = underCursor.Init <FacingInit>();
                    if (facing != null)
                    {
                        underCursor.ReplaceInit(new FacingInit((facing.Value(world) + 32) % 256));
                    }
                    else if (underCursor.Info.Traits.WithInterface <UsesInit <FacingInit> >().Any())
                    {
                        underCursor.ReplaceInit(new FacingInit(32));
                    }

                    var turret = underCursor.Init <TurretFacingInit>();
                    if (turret != null)
                    {
                        underCursor.ReplaceInit(new TurretFacingInit((turret.Value(world) + 32) % 256));
                    }
                    else if (underCursor.Info.Traits.WithInterface <UsesInit <TurretFacingInit> >().Any())
                    {
                        underCursor.ReplaceInit(new TurretFacingInit(32));
                    }
                }
            }

            return(true);
        }
예제 #3
0
        public bool HandleMouseInput(MouseInput mi)
        {
            // Exclusively uses mouse wheel and both mouse buttons, but nothing else
            // Mouse move events are important for tooltips, so we always allow these through
            if ((mi.Button != MouseButton.Left && mi.Button != MouseButton.Right &&
                 mi.Event != MouseInputEvent.Move && mi.Event != MouseInputEvent.Scroll) ||
                mi.Event == MouseInputEvent.Down)
            {
                return(false);
            }

            worldPixel = worldRenderer.Viewport.ViewToWorldPx(mi.Location);
            var cell = worldRenderer.Viewport.ViewToWorld(mi.Location);

            var underCursor = editorLayer.PreviewsAt(worldPixel).MinByOrDefault(CalculateActorSelectionPriority);

            var          mapResources = world.Map.Resources;
            ResourceType type;

            if (underCursor != null)
            {
                editorWidget.SetTooltip(underCursor.Tooltip);
            }
            else if (mapResources.Contains(cell) && resources.TryGetValue(mapResources[cell].Type, out type))
            {
                editorWidget.SetTooltip(type.Info.Type);
            }
            else
            {
                editorWidget.SetTooltip(null);
            }

            // Finished with mouse move events, so let them bubble up the widget tree
            if (mi.Event == MouseInputEvent.Move)
            {
                return(false);
            }

            if (mi.Button == MouseButton.Left)
            {
                editorWidget.SetTooltip(null);
                SelectedActor = underCursor;
            }

            if (mi.Button == MouseButton.Right)
            {
                editorWidget.SetTooltip(null);

                if (underCursor != null && underCursor != SelectedActor)
                {
                    editorLayer.Remove(underCursor);
                }

                if (mapResources.Contains(cell) && mapResources[cell].Type != 0)
                {
                    mapResources[cell] = default(ResourceTile);
                }
            }

            return(true);
        }