Beispiel #1
0
        public void Read(AssetStream stream)
        {
            StyleName = stream.ReadStringAligned();
            Normal.Read(stream);
            Hover.Read(stream);
            Active.Read(stream);
            Focused.Read(stream);
            OnNormal.Read(stream);
            OnHover.Read(stream);
            OnActive.Read(stream);
            OnFocused.Read(stream);
            Border.Read(stream);
            Margin.Read(stream);
            Padding.Read(stream);
            Overflow.Read(stream);
            Font.Read(stream);
            FontSize  = stream.ReadInt32();
            FontStyle = stream.ReadInt32();
            Alignment = stream.ReadInt32();
            WordWrap  = stream.ReadBoolean();
            RichText  = stream.ReadBoolean();
            stream.AlignStream(AlignType.Align4);

            TextClipping  = stream.ReadInt32();
            ImagePosition = stream.ReadInt32();
            ContentOffset.Read(stream);
            FixedWidth    = stream.ReadSingle();
            FixedHeight   = stream.ReadSingle();
            StretchWidth  = stream.ReadBoolean();
            StretchHeight = stream.ReadBoolean();
            stream.AlignStream(AlignType.Align4);
        }
Beispiel #2
0
 public virtual void FocusOn(UIActionEvent e)
 {
     IsFocused = true;
     OnFocused?.Invoke(e, this);
     if (PropagationRule.HasFlag(PropagationFlags.FocusOn))
     {
         Parent?.FocusOn(e);
     }
 }
Beispiel #3
0
 public void ShowOptions(object sender, EventArgs e)
 {
     if (OptionsMenu == null)
     {
         OptionsMenu = OptionsPrefab;
         TriggerAreas.Add(OptionsMenu.TriggerAreas[0]);
         OnFocused?.Invoke(this, new NodeEventArgs(OptionsMenu));
         FocusedNode?.OnUnfocused?.Invoke(this, new NodeEventArgs(FocusedNode));
         TriggerAreas.Add(OptionsMenu.TriggerAreas[0]);
     }
     else
     {
         OnOptionsHide?.Invoke(this, e);
     }
 }
Beispiel #4
0
        public void Focus()
        {
            if (IsFocused)
            {
                return;
            }

            IsFocused = true;

            _focusableObjects.ForEach(o => o.Focus());

            OnFocused?.Invoke(this, null);

            SetFocusStyle();
        }
Beispiel #5
0
        private static void Update()
        {
            var isApplicationActive = InternalEditorUtility.isApplicationActive;

            if (!m_isFocused && isApplicationActive)
            {
                m_isFocused = true;
                OnFocused?.Invoke();
                ;
            }
            else if (m_isFocused && !isApplicationActive)
            {
                m_isFocused = false;
                OnUnfocused?.Invoke();
            }
        }
        /// <summary>
        /// Focus the given input focus target.
        /// </summary>
        public override void Focus(IInputFocus target)
        {
            if (target == CurrentInputFocus)
            {
                return;
            }

            CurrentInputFocus = target;
            if (string.IsNullOrEmpty(target.ActionMapName) == false)
            {
                playerInput.SwitchCurrentActionMap(target.ActionMapName);
            }

            target.OnFocus();
            OnFocused?.Invoke(this, new InputFocusEventArgs(target));
        }
Beispiel #7
0
        public void Write(AssetWriter writer)
        {
            writer.Write(Name);
            Normal.Write(writer);
            Hover.Write(writer);
            Active.Write(writer);
            Focused.Write(writer);
            OnNormal.Write(writer);
            OnHover.Write(writer);
            OnActive.Write(writer);
            OnFocused.Write(writer);
            Border.Write(writer);
            if (IsBuiltin(writer.Version))
            {
                Margin.Write(writer);
                Padding.Write(writer);
            }
            else
            {
                Padding.Write(writer);
                Margin.Write(writer);
            }
            Overflow.Write(writer);
            Font.Write(writer);

            if (IsBuiltin(writer.Version))
            {
                writer.Write(FontSize);
                writer.Write((int)FontStyle);
                writer.Write((int)Alignment);
                writer.Write(WordWrap);
                writer.Write(RichText);
                writer.AlignStream();

                writer.Write((int)TextClipping);
                writer.Write((int)ImagePosition);
                ContentOffset.Write(writer);
                writer.Write(FixedWidth);
                writer.Write(FixedHeight);
                writer.Write(StretchWidth);
                writer.Write(StretchHeight);
                writer.AlignStream();
            }
            else
            {
                writer.Write((int)ImagePosition);
                writer.Write((int)Alignment);
                writer.Write(WordWrap);
                writer.AlignStream();

                writer.Write((int)TextClipping);
                ContentOffset.Write(writer);
                ClipOffset.Write(writer);
                writer.Write(FixedWidth);
                writer.Write(FixedHeight);
                if (HasFontSize(writer.Version))
                {
                    writer.Write(FontSize);
                    writer.Write((int)FontStyle);
                }
                writer.Write(StretchWidth);
                writer.AlignStream();
                writer.Write(StretchHeight);
                writer.AlignStream();
            }
        }
Beispiel #8
0
 public virtual void Focus()
 {
     Focused = true;
     OnFocused?.Invoke(this);
     Parent?.Focus();
 }
Beispiel #9
0
 private void Tpanel_Enter(object sender, EventArgs e)
 {
     OnFocused?.Invoke(this);
 }
Beispiel #10
0
        public void Read(AssetReader reader)
        {
            GUIStyleLayout layout = reader.Layout.Serialized.GUIStyle;

            Name = reader.ReadString();
            Normal.Read(reader);
            Hover.Read(reader);
            Active.Read(reader);
            Focused.Read(reader);
            OnNormal.Read(reader);
            OnHover.Read(reader);
            OnActive.Read(reader);
            OnFocused.Read(reader);
            Border.Read(reader);
            if (layout.IsBuiltinFormat)
            {
                Margin.Read(reader);
                Padding.Read(reader);
            }
            else
            {
                Padding.Read(reader);
                Margin.Read(reader);
            }

            Overflow.Read(reader);
            Font.Read(reader);
            if (layout.IsBuiltinFormat)
            {
                FontSize  = reader.ReadInt32();
                FontStyle = (FontStyle)reader.ReadInt32();
                Alignment = (TextAnchor)reader.ReadInt32();
                WordWrap  = reader.ReadBoolean();
                RichText  = reader.ReadBoolean();
                reader.AlignStream();

                TextClipping  = (TextClipping)reader.ReadInt32();
                ImagePosition = (ImagePosition)reader.ReadInt32();
                ContentOffset.Read(reader);
                FixedWidth    = reader.ReadSingle();
                FixedHeight   = reader.ReadSingle();
                StretchWidth  = reader.ReadBoolean();
                StretchHeight = reader.ReadBoolean();
                reader.AlignStream();
            }
            else
            {
                ImagePosition = (ImagePosition)reader.ReadInt32();
                Alignment     = (TextAnchor)reader.ReadInt32();
                WordWrap      = reader.ReadBoolean();
                reader.AlignStream();

                TextClipping = (TextClipping)reader.ReadInt32();
                ContentOffset.Read(reader);
                ClipOffset.Read(reader);
                FixedWidth  = reader.ReadSingle();
                FixedHeight = reader.ReadSingle();
                if (layout.HasFontSize)
                {
                    FontSize  = reader.ReadInt32();
                    FontStyle = (FontStyle)reader.ReadInt32();
                }
                StretchWidth = reader.ReadBoolean();
                reader.AlignStream();
                StretchHeight = reader.ReadBoolean();
                reader.AlignStream();
            }
        }
Beispiel #11
0
        public YAMLNode ExportYAML(IExportContainer container)
        {
            YAMLMappingNode node   = new YAMLMappingNode();
            GUIStyleLayout  layout = container.ExportLayout.Serialized.GUIStyle;

            node.Add(layout.NameName, Name);
            node.Add(layout.NormalName, Normal.ExportYAML(container));
            node.Add(layout.HoverName, Hover.ExportYAML(container));
            node.Add(layout.ActiveName, Active.ExportYAML(container));
            node.Add(layout.FocusedName, Focused.ExportYAML(container));
            node.Add(layout.OnNormalName, OnNormal.ExportYAML(container));
            node.Add(layout.OnHoverName, OnHover.ExportYAML(container));
            node.Add(layout.OnActiveName, OnActive.ExportYAML(container));
            node.Add(layout.OnFocusedName, OnFocused.ExportYAML(container));
            node.Add(layout.BorderName, Border.ExportYAML(container));
            if (layout.IsBuiltinFormat)
            {
                node.Add(layout.MarginName, Margin.ExportYAML(container));
                node.Add(layout.PaddingName, Padding.ExportYAML(container));
            }
            else
            {
                node.Add(layout.PaddingName, Padding.ExportYAML(container));
                node.Add(layout.MarginName, Margin.ExportYAML(container));
            }

            node.Add(layout.OverflowName, Overflow.ExportYAML(container));
            node.Add(layout.FontName, Font.ExportYAML(container));
            if (layout.IsBuiltinFormat)
            {
                node.Add(layout.FontSizeName, FontSize);
                node.Add(layout.FontStyleName, (int)FontStyle);
                node.Add(layout.AlignmentName, (int)Alignment);
                node.Add(layout.WordWrapName, WordWrap);
                node.Add(layout.RichTextName, RichText);
                node.Add(layout.TextClippingName, (int)TextClipping);
                node.Add(layout.ImagePositionName, (int)ImagePosition);
                node.Add(layout.ContentOffsetName, ContentOffset.ExportYAML(container));
                node.Add(layout.FixedWidthName, FixedWidth);
                node.Add(layout.FixedHeightName, FixedHeight);
                node.Add(layout.StretchWidthName, StretchWidth);
                node.Add(layout.StretchHeightName, StretchHeight);
            }
            else
            {
                node.Add(layout.ImagePositionName, (int)ImagePosition);
                node.Add(layout.AlignmentName, (int)Alignment);
                node.Add(layout.WordWrapName, WordWrap);
                node.Add(layout.TextClippingName, (int)TextClipping);
                node.Add(layout.ContentOffsetName, ContentOffset.ExportYAML(container));
                node.Add(layout.ClipOffsetName, ClipOffset.ExportYAML(container));
                node.Add(layout.FixedWidthName, FixedWidth);
                node.Add(layout.FixedHeightName, FixedHeight);
                if (layout.HasFontSize)
                {
                    node.Add(layout.FontSizeName, FontSize);
                    node.Add(layout.FontStyleName, (int)FontStyle);
                }
                node.Add(layout.StretchWidthName, StretchWidth);
                node.Add(layout.StretchHeightName, StretchHeight);
            }
            return(node);
        }