Exemple #1
0
        private void requestTooltip(AGuiElement guiElement, Vector2 mousePosition)
        {
            if (this.tooltipSource == guiElement)
            {
                return;
            }

            if (this.tooltipSource != null)
            {
                if (this.tooltipGuiLayer.Contains(this.tooltipElement))
                {
                    this.tooltipGuiLayer.RemoveElement(this.tooltipElement);
                }

                this.tooltipSource  = null;
                this.tooltipElement = null;
            }

            if (guiElement == null)
            {
                return;
            }

            this.tooltipEta     = TooltipDelay;
            this.tooltipSource  = guiElement;
            this.tooltipElement = guiElement.Tooltip.Make();
            this.tooltipElement.Position.TooltipNear(mousePosition, 5, 5);
            this.tooltipMousePosition = mousePosition;
        }
Exemple #2
0
        protected AScene()
        {
            this.normalGuiLayer  = new GuiLayer(this.guiLayerThickness, this.guiLayerThickness / 2);
            this.tooltipGuiLayer = new GuiLayer(this.guiLayerThickness / 2, this.guiLayerThickness / 2);

            this.mouseHovered = this.normalGuiLayer.Root;
        }
Exemple #3
0
 public void HideElement(AGuiElement element)
 {
     if (this.normalGuiLayer.Contains(element))
     {
         this.RemoveElement(element);
     }
 }
        public OutsidePosition RelativeTo(AGuiElement anchor, float xPortionAnchor, float yPortionAnchor, float xPortionThis, float yPortionThis)
        {
            var positioner = new RelativeToPositioner(anchor, xPortionAnchor, yPortionAnchor, xPortionThis, yPortionThis);

            this.positioners.Add(positioner);

            return(new OutsidePosition(this, positioner));
        }
 public RelativeToPositioner(AGuiElement anchor, float xPortionAnchor, float yPortionAnchor, float xPortionThis, float yPortionThis)
 {
     this.anchor         = anchor;
     this.xPortionAnchor = xPortionAnchor;
     this.yPortionAnchor = yPortionAnchor;
     this.xPortionThis   = xPortionThis;
     this.yPortionThis   = yPortionThis;
 }
Exemple #6
0
        public void ShowElement(AGuiElement element)
        {
            if (this.normalGuiLayer.Contains(element))
            {
                return;
            }

            this.AddElement(element, element.Parent ?? this.normalGuiLayer.Root);
        }
Exemple #7
0
        public void AddElement(AGuiElement element, AGuiElement parent, AScene scene)
        {
            this.guiHierarchy[element] = new HashSet <AGuiElement>();
            this.guiHierarchy[parent].Add(element);

            element.Attach(scene, parent);
            this.updateGuiZ(element);
            element.RecalculatePosition(true);
        }
Exemple #8
0
        public GuiLayer(float z0, float layerThickness)
        {
            this.z0             = z0;
            this.layerThickness = layerThickness;
            this.Root           = new GuiPanel();

            this.guiHierarchy[this.Root] = new HashSet <AGuiElement>();
            this.Root.Position.FixedCenter(0, 0);
            this.Root.SetDepth(z0, layerThickness);
        }
Exemple #9
0
        public IEnumerable <AGuiElement> ElementChildren(AGuiElement element)
        {
            var layer = this.guiLayers().FirstOrDefault(x => x.Contains(element));

            if (layer == null)
            {
                return(new AGuiElement[0]);
            }

            return(layer.ElementChildren(element));
        }
Exemple #10
0
        public void AddElement(AGuiElement element, AGuiElement parent, AScene scene)
        {
            var treeRoot = element.Below ?? parent;

            this.guiHierarchy[element] = new HashSet <AGuiElement>();
            this.guiHierarchy[treeRoot].Add(element);

            element.SetDepth(treeRoot.Z0 - treeRoot.ZRange, treeRoot.ZRange);
            element.Attach(scene, parent);
            this.updateGuiZ(element);
            element.Position.Recalculate();
        }
Exemple #11
0
        public void ResetTooltipContents()
        {
            if (this.tooltipSource == null || !this.tooltipGuiLayer.Contains(this.tooltipElement))
            {
                return;
            }

            this.tooltipGuiLayer.RemoveElement(this.tooltipElement);
            this.tooltipElement = this.tooltipSource.Tooltip.Make();
            this.tooltipElement.Position.TooltipNear(this.tooltipMousePosition, 5, 5);
            this.tooltipGuiLayer.AddElement(this.tooltipElement, this);
            this.tooltipElement.Position.Recalculate();
        }
Exemple #12
0
        public void RemoveElement(AGuiElement element)
        {
            if (this.guiHierarchy.ContainsKey(element))
            {
                foreach (var child in this.guiHierarchy[element].ToList())
                {
                    this.RemoveElement(child);
                }
            }

            this.guiHierarchy[element.Parent].Remove(element);
            this.guiHierarchy.Remove(element);
            element.Detach();
        }
Exemple #13
0
        private IEnumerable <AGuiElement> enumeratePostfix(AGuiElement parent)
        {
            if (this.guiHierarchy.ContainsKey(parent))
            {
                foreach (var child in this.guiHierarchy[parent])
                {
                    foreach (var element in this.enumeratePostfix(child))
                    {
                        yield return(element);
                    }
                }
            }

            yield return(parent);
        }
Exemple #14
0
        public void HandleMouseMove(MouseEventArgs e, Keys modiferKeys)
        {
            if (this.mousePressed.Values.Any(x => x != null))
            {
                handleMouseDrag(e);
                return;
            }

            var         mouseGuiPoint = Vector4.Transform(this.mouseToView(e.X, e.Y), this.guiInvProjection).Xy;
            AGuiElement handler       = null;

            foreach (var element in this.eventHandlerSearch(mouseGuiPoint))
            {
                if (element.OnMouseMove(mouseGuiPoint, modiferKeys))
                {
                    handler = element;
                    break;
                }
            }

            if (handler == null)
            {
                this.onMouseMove(this.mouseToView(e.X, e.Y), modiferKeys);
                handler = this.normalGuiLayer.Root;
            }

            if (this.mouseHovered != handler)
            {
                if (this.mouseHovered != null)
                {
                    if (this.mouseHovered != this.normalGuiLayer.Root)
                    {
                        this.mouseHovered.OnMouseLeave();
                    }
                    else
                    {
                        this.onMouseLeave();
                    }
                }

                this.mouseHovered = handler;
            }

            this.requestTooltip(
                this.eventHandlerSearch(mouseGuiPoint).FirstOrDefault(x => x.Tooltip != null),
                mouseGuiPoint
                );
        }
Exemple #15
0
        private void updateGuiZ(AGuiElement element)
        {
            var layers     = 2;
            var subroot    = element;
            var treeParent = subroot.Below ?? subroot.Parent;

            while (treeParent != this.Root)
            {
                subroot    = treeParent;
                treeParent = subroot.Below ?? subroot.Parent;
                layers++;
            }

            var zRange = this.layerThickness / layers;

            if (subroot.ZRange <= zRange)
            {
                return;
            }

            /*
             * Updates Z ranges of a subtree, immediate child of layer root.
             * Other subtrees should not visually overlap so no update needed.
             */
            subroot.SetDepth(this.z0, zRange);
            var subtrees = new Queue <AGuiElement>();

            subtrees.Enqueue(subroot);

            while (subtrees.Count > 0)
            {
                subroot = subtrees.Dequeue();

                if (this.guiHierarchy[subroot].Any())
                {
                    foreach (var item in this.guiHierarchy[subroot])
                    {
                        item.SetDepth(subroot.Z0 - subroot.ZRange, subroot.ZRange);
                        subtrees.Enqueue(item);
                    }
                }
            }
        }
Exemple #16
0
        public void HandleMouseScroll(MouseEventArgs e)
        {
            var         mouseGuiPoint = Vector4.Transform(this.mouseToView(e.X, e.Y), this.guiInvProjection).Xy;
            AGuiElement handler       = null;

            foreach (var element in this.eventHandlerSearch(mouseGuiPoint))
            {
                if (element.OnMouseScroll(mouseGuiPoint, e.Delta))
                {
                    handler = element;
                    break;
                }
            }

            if (handler == null)
            {
                this.onMouseScroll(Vector4.Transform(this.mouseToView(e.X, e.Y), this.invProjection).Xy, e.Delta);
            }
        }
Exemple #17
0
 protected virtual void CleanupPopulationGuiElement(AGuiElement e) { }
Exemple #18
0
 protected virtual void CleanupCompositionGuiElement(AGuiElement e) { }
Exemple #19
0
 protected virtual void CleanupParticulatesGuiElement(AGuiElement e) { }
Exemple #20
0
 protected virtual void CleanupNetIncomeGuiElement(AGuiElement e) { }
Exemple #21
0
 protected virtual void CleanupScienceGuiElement(AGuiElement e) { }
Exemple #22
0
 protected virtual void CleanupDefensiveStrengthGuiElement(AGuiElement e) { }
Exemple #23
0
 protected virtual void CleanupLocationGuiElement(AGuiElement e) { }
Exemple #24
0
 private void InitializeScienceGuiElement(AGuiElement e) {
     _scienceLabel = GetLabel(e);
 }
 public StretchRightToPositioner(AGuiElement anchor, float xPortionAnchor, float marginX)
 {
     this.anchor         = anchor;
     this.xPortionAnchor = xPortionAnchor;
     this.marginX        = marginX;
 }
Exemple #26
0
 public IEnumerable <AGuiElement> ElementChildren(AGuiElement element)
 {
     return(this.guiHierarchy[element]);
 }
        public ElementPosition StretchRightTo(AGuiElement anchor, float xPortionAnchor, float marginX)
        {
            this.positioners.Add(new StretchRightToPositioner(anchor, xPortionAnchor, marginX));

            return(this);
        }
Exemple #28
0
 protected virtual void CleanupSpeedGuiElement(AGuiElement e) { }
Exemple #29
0
 public void AddElement(AGuiElement element)
 {
     this.normalGuiLayer.AddElement(element, this);
 }
Exemple #30
0
 private void InitializeStrategicResourcesGuiElement(AGuiElement e) {
     _resourcesElement = e as ResourcesGuiElement;
 }
Exemple #31
0
 protected virtual void CleanupHealthGuiElement(AGuiElement e) { }
Exemple #32
0
 private void InitializeOffensiveStrengthGuiElement(AGuiElement e) {
     _offensiveStrengthElement = e as StrengthGuiElement;
 }
Exemple #33
0
 protected virtual void CleanupStrategicResourcesGuiElement(AGuiElement e) { }
Exemple #34
0
 private void InitializeHealthGuiElement(AGuiElement e) {
     _healthElement = e as HealthGuiElement;
 }
Exemple #35
0
 protected virtual void CleanupCultureGuiElement(AGuiElement e) { }
Exemple #36
0
 private void InitializeHeroGuiElement(AGuiElement e) {
     _heroElement = e as HeroGuiElement;
 }
Exemple #37
0
 protected virtual void CleanupOrganicsGuiElement(AGuiElement e) { }
Exemple #38
0
 public void AddElement(AGuiElement element, AScene scene)
 {
     this.AddElement(element, this.Root, scene);
 }
Exemple #39
0
 protected virtual void CleanupEnergyGuiElement(AGuiElement e) { }
Exemple #40
0
 public void RemoveElement(AGuiElement element)
 {
     this.guiLayers().First(x => x.Contains(element)).RemoveElement(element);
 }
Exemple #41
0
 protected virtual void CleanupApprovalGuiElement(AGuiElement e) { }
 protected override void InitializeNameGuiElement(AGuiElement e) {
     base.InitializeNameGuiElement(e);
     MyEventListener.Get(e.gameObject).onDoubleClick += NameDoubleClickEventHandler;
 }
Exemple #43
0
 protected virtual void CleanupProductionGuiElement(AGuiElement e) { }
Exemple #44
0
 /// <summary>
 /// Returns the single UILabel sibling or child of the provided GuiElement.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <returns></returns>
 protected UILabel GetLabel(AGuiElement element) {
     return element.gameObject.GetSingleComponentInChildren<UILabel>();
 }
Exemple #45
0
 private void InitializeGuiElement(AGuiElement e) {
     switch (e.ElementID) {
         case GuiElementID.ItemNameLabel:
             InitializeNameGuiElement(e);
             break;
         case GuiElementID.Owner:
             InitializeOwnerGuiElement(e);
             break;
         case GuiElementID.Location:
             InitializeLocationGuiElement(e);
             break;
         case GuiElementID.Hero:
             InitializeHeroGuiElement(e);
             break;
         case GuiElementID.Health:
             InitializeHealthGuiElement(e);
             break;
         case GuiElementID.OffensiveStrength:
             InitializeOffensiveStrengthGuiElement(e);
             break;
         case GuiElementID.DefensiveStrength:
             InitializeDefensiveStrengthGuiElement(e);
             break;
         case GuiElementID.Resources:
             InitializeStrategicResourcesGuiElement(e);
             break;
         case GuiElementID.ScienceLabel:
             InitializeScienceGuiElement(e);
             break;
         case GuiElementID.CultureLabel:
             InitializeCultureGuiElement(e);
             break;
         case GuiElementID.NetIncome:
             InitializeNetIncomeGuiElement(e);
             break;
         case GuiElementID.OrganicsLabel:
             InitializeOrganicsGuiElement(e);
             break;
         case GuiElementID.ParticulatesLabel:
             InitializeParticulatesGuiElement(e);
             break;
         case GuiElementID.EnergyLabel:
             InitializeEnergyGuiElement(e);
             break;
         case GuiElementID.Composition:
             InitializeCompositionGuiElement(e);
             break;
         case GuiElementID.Approval:
             InitializeApprovalGuiElement(e);
             break;
         case GuiElementID.PopulationLabel:
             InitializePopulationGuiElement(e);
             break;
         case GuiElementID.Production:
             InitializeProductionGuiElement(e);
             break;
         case GuiElementID.SpeedLabel:
             InitializeSpeedGuiElement(e);
             break;
         default:
             throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(e.ElementID));
     }
 }
Exemple #46
0
 public void AddElement(AGuiElement element, AGuiElement parent)
 {
     this.guiLayers().First(x => x.Contains(parent)).AddElement(element, parent, this);
 }
 protected override void CleanupNameGuiElement(AGuiElement e) {
     base.CleanupNameGuiElement(e);
     MyEventListener.Get(e.gameObject).onDoubleClick -= NameDoubleClickEventHandler;
 }
 protected override void InitializeCompositionGuiElement(AGuiElement e) {
     base.InitializeCompositionGuiElement(e);
     _compositionElement = e as StarbaseCompositionGuiElement;
 }
Exemple #49
0
 private void InitializeLocationGuiElement(AGuiElement e) {
     _locationElement = e as LocationGuiElement;
 }
Exemple #50
0
 public void AddInsceneElement(AGuiElement element)
 {
     this.insceneGuiLayer.AddElement(element, this);
 }
Exemple #51
0
 private void InitializeOwnerGuiElement(AGuiElement e) {
     _ownerElement = e as OwnerGuiElement;
 }
Exemple #52
0
 protected virtual void InitializeNameGuiElement(AGuiElement e) {
     _nameLabel = GetLabel(e);
 }
Exemple #53
0
 public bool Contains(AGuiElement element)
 {
     return(this.guiHierarchy.ContainsKey(element));
 }
Exemple #54
0
 private void CleanupGuiElement(AGuiElement e) {
     switch (e.ElementID) {
         case GuiElementID.ItemNameLabel:
             CleanupNameGuiElement(e);
             break;
         case GuiElementID.Owner:
             CleanupOwnerGuiElement(e);
             break;
         case GuiElementID.Location:
             CleanupLocationGuiElement(e);
             break;
         case GuiElementID.Hero:
             CleanupHeroGuiElement(e);
             break;
         case GuiElementID.Health:
             CleanupHealthGuiElement(e);
             break;
         case GuiElementID.OffensiveStrength:
             CleanupOffensiveStrengthGuiElement(e);
             break;
         case GuiElementID.DefensiveStrength:
             CleanupDefensiveStrengthGuiElement(e);
             break;
         case GuiElementID.Resources:
             CleanupStrategicResourcesGuiElement(e);
             break;
         case GuiElementID.ScienceLabel:
             CleanupScienceGuiElement(e);
             break;
         case GuiElementID.CultureLabel:
             CleanupCultureGuiElement(e);
             break;
         case GuiElementID.NetIncome:
             CleanupNetIncomeGuiElement(e);
             break;
         case GuiElementID.OrganicsLabel:
             CleanupOrganicsGuiElement(e);
             break;
         case GuiElementID.ParticulatesLabel:
             CleanupParticulatesGuiElement(e);
             break;
         case GuiElementID.EnergyLabel:
             CleanupEnergyGuiElement(e);
             break;
         case GuiElementID.Composition:
             CleanupCompositionGuiElement(e);
             break;
         case GuiElementID.Approval:
             CleanupApprovalGuiElement(e);
             break;
         case GuiElementID.PopulationLabel:
             CleanupPopulationGuiElement(e);
             break;
         case GuiElementID.Production:
             CleanupProductionGuiElement(e);
             break;
         case GuiElementID.SpeedLabel:
             CleanupSpeedGuiElement(e);
             break;
         default:
             throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(e.ElementID));
     }
 }
Exemple #55
0
        public override void Attach(AScene scene, AGuiElement parent)
        {
            base.Attach(scene, parent);

            this.updateSliderVisibility();
        }
Exemple #56
0
 protected virtual void CleanupOwnerGuiElement(AGuiElement e) { }
Exemple #57
0
 private void addPlanetElement(AGuiElement element)
 {
     this.AddElement(element);
     this.otherPlanetElements.Add(element);
 }
Exemple #58
0
 public override void Attach(AScene scene, AGuiElement parent)
 {
     base.Attach(scene, parent);
     this.group.Add(this);
 }