Exemplo n.º 1
0
 public UIButton(Vector2f position, Vector2f size, Color color, string text, Vector2f margin, string icon = "", OnClickDel onClickFunction = null) : base(position, size, color)
 {
     Margin = margin;
     if (icon != "")
     {
         LoadIcon(icon);
     }
     OnClickFunction      = onClickFunction;
     Text.DisplayedString = text;
     Text.Font            = new Font("../../../Resources/Fonts/Roboto-Bold.ttf");
     Text.CharacterSize   = (uint)(Size.Y + Margin.Y) / 3;
     if (Icon != null)
     {
         while (Text.GetLocalBounds().Width > Size.X - Margin.X * 3 - Icon.GetGlobalBounds().Width)
         {
             Text.CharacterSize--;
         }
         Vector2f padding = new Vector2f((Size.X - Text.GetGlobalBounds().Width + Icon.GetGlobalBounds().Width + Margin.X) / 2, (Size.Y - Text.CharacterSize) / 2);
         Text.Position = new Vector2f(Position.X + padding.X, Position.Y + padding.Y);
     }
     else
     {
         while (Text.GetLocalBounds().Width > Size.X - Margin.X)
         {
             Text.CharacterSize--;
         }
         Vector2f padding = new Vector2f((Size.X - Text.GetLocalBounds().Width) / 2, (Size.Y - Text.CharacterSize) / 2);
         Text.Position = new Vector2f(Position.X + padding.X, Position.Y + padding.Y);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 清理上一次引导的内容
        /// </summary>
        private void CleanupLastGuide()
        {
            OnClickListener = null;
            ClearTargetObjEvent();

            if (m_GuideObject != null)
            {
                m_GuideObject.Cleanup();
                m_GuideObject = null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 设置ui的通用事件监听器
        /// </summary>
        private void SetupGenericEventListener(GameObject target_object, OnClickDel click_handle)
        {
            if (mUIObject == null)
            {
                return;
            }

            // 如果没有目标物体的监听事件,则使用GuideWindow来进行监听
            if (target_object != null)
            {
                var event_listen = EventTriggerListener.GetListener(target_object);
                event_listen.onPointerClick += OnClick;
            }
            else
            {
                var event_listen = EventTriggerListener.GetListener(m_EventMask);
                event_listen.onPointerClick += OnClick;
            }

            OnClickListener = click_handle;
        }
Exemplo n.º 4
0
 public ChartIconCheckBox(OnClickDel clickHandler)
     : base((sender, args) => { })
 {
     this.clickHandler = clickHandler;
 }
Exemplo n.º 5
0
 public ChartIconCheckBox(OnClickDel clickHandler)
     : base((sender, args) => { })
 {
     this.clickHandler = clickHandler;
 }