示例#1
0
    //---------------------------------------------------------
    public virtual bool Callback(E_CallbackType type, object evt)
    {
        Debug.LogError(GetType().Name + "<" + this.GetFullName('.') + ">.Callback() :: This method should be overriden !!!");

        // if callback handles desired callback type - it should return 'true'
        return(false);
    }
示例#2
0
    //---------------------------------------------------------
    public override bool Callback(E_CallbackType type, object evt)
    {
        switch (type)
        {
        case E_CallbackType.E_CT_INIT:
            CustomInit();
            break;
        }

        return(true);
    }
示例#3
0
    /*public void Update()
     * {
     *      float scale = Mathf.Abs(Mathf.Sin(Time.timeSinceLevelLoad*0.5f+Mathf.PI*0.5f));
     *      transform.localScale = Vector3.one*scale;
     * }*/

    #endregion MoneBehaviourInterface

    // ==================================================================================================
    // === GUIBase_Wifget interaction ===================================================================

    #region GUIBase_Wifget interaction

    public override bool Callback(E_CallbackType type, object evt)
    {
        switch (type)
        {
        case E_CallbackType.E_CT_INIT:
        {
            m_Widget.ChangeMaterial(m_Font.fontMaterial);
            SetRegenerationNeeded();
        }
            return(true);
        }

        return(false);
    }
示例#4
0
    // GUIBASE_CALLBACK INTERFACE

    public override bool Callback(E_CallbackType type, object evt)
    {
        switch (type)
        {
        case E_CallbackType.E_CT_INIT:
            LateInit();
            break;

        case E_CallbackType.E_CT_SHOW:
            SetSelection(m_CurrentSelection, true);
            break;
        }

        return(true);
    }
示例#5
0
    //---------------------------------------------------------
    public override bool Callback(E_CallbackType type, object evt)
    {
        switch (type)
        {
        case E_CallbackType.E_CT_SHOW:
            ShowSwitchButton(true);
            break;

        case E_CallbackType.E_CT_HIDE:
            ShowSwitchButton(false);
            break;
        }

        return(true);
    }
示例#6
0
    //---------------------------------------------------------
    public override bool Callback(E_CallbackType type, object evt)
    {
        switch (type)
        {
        case E_CallbackType.E_CT_INIT:
            CustomInit();
            break;

        case E_CallbackType.E_CT_SHOW:
            SetNumber(m_Value, 999999, true);
            break;
        }

        return(true);
    }
示例#7
0
    // GUIBASE_CALLBACK INTERFACE

    public override bool Callback(E_CallbackType type, object evt)
    {
        switch (type)
        {
        case E_CallbackType.E_CT_INIT:
            m_IsDirty = true;
            return(true);

        case E_CallbackType.E_CT_SHOW:
            UpdateLabels();
            return(true);

        default:
            return(false);
        }
    }
示例#8
0
    // ==================================================================================================
    // === GUIBase_Wifget interaction ===================================================================

    #region GUIBase_Wifget interaction

    public override bool Callback(E_CallbackType type, object evt)
    {
        switch (type)
        {
        case E_CallbackType.E_CT_INIT:
        {
            if (m_FontName == "Default")
            {
                m_FontName = "NewFont";                 // HACK, Don't use old 'default' font
            }
            m_Widget.ChangeMaterial(font.fontMaterial);
            SetRegenerationNeeded();
        }
            return(true);
        }

        return(false);
    }
示例#9
0
    //---------------------------------------------------------
    public override bool Callback(E_CallbackType type, object evt)
    {
        switch (type)
        {
        case E_CallbackType.E_CT_INIT:
            CustomInit();
            break;

        case E_CallbackType.E_CT_ON_TOUCH_BEGIN:

            m_WasTouched = true;

            UpdateSlider();

            break;
        }

        return(true);
    }
示例#10
0
    // GUIBASE_CALLBACK INTERFACE

    public override bool Callback(E_CallbackType type, object evt)
    {
        switch (type)
        {
        case E_CallbackType.E_CT_ON_TOUCH_END:
            if (OnSelectRow != null)
            {
                TouchEvent touch = (TouchEvent)evt;
                Vector2    point = touch.Position;
                point.y = Screen.height - point.y;
                for (int idx = 0; idx < m_Lines.Length; ++idx)
                {
                    GUIBase_Widget row = m_Lines[idx];
                    if (row.Visible == false)
                    {
                        continue;
                    }
                    if (row.IsMouseOver(point) == false)
                    {
                        continue;
                    }

                    OnSelectRow(row, idx, m_ItemOffset + idx);
                    break;
                }
            }
            if (OnProcessInput != null)             //send the events to the parent
            {
                TouchEvent touch = (TouchEvent)evt;
                if (m_Scrollbar != null)               //this event probably comes from scrollbar (because scrollbar is catching all touch events)
                {
                    touch.Id = -1;                     //and it doesn't have proper begin, this marks the event as 'faked'
                }
                IInputEvent inputEvent = (IInputEvent)touch;
                return(OnProcessInput(ref inputEvent));
            }
            return(true);

        default:
            return(false);
        }
    }
示例#11
0
    // GUIBASE_CALLBACK INTERFACE

    public override bool Callback(E_CallbackType type, object evt)
    {
        switch (type)
        {
        case E_CallbackType.E_CT_SHOW:
            UpdateThumb();
            return(true);

        case E_CallbackType.E_CT_HIDE:
            m_FadeDuration = 0.0f;
            SetAlpha(0.0f);
            return(true);

        case E_CallbackType.E_CT_ON_TOUCH_BEGIN:
            if (m_DragStep != 0.0f)
            {
                TouchEvent touch = (TouchEvent)evt;
                m_DragStartPosition = touch.Position;
                m_DragStartValue    = m_Value;
            }
            return(true);

        case E_CallbackType.E_CT_ON_TOUCH_UPDATE:
        {
            if (evt is MouseEvent)
            {
                MouseEvent mEvt = (MouseEvent)evt;
                if (mEvt.ScrollWheel > 0)
                {
                    m_ParentWidget.ChildButtonPressed(-1);
                }
                else if (mEvt.ScrollWheel < 0)
                {
                    m_ParentWidget.ChildButtonPressed(1);
                }
            }
            else
            {
                TouchEvent touch = (TouchEvent)evt;
                if (m_DragStep != 0.0f)
                {
                    Vector2 diff      = touch.Position - m_DragStartPosition;
                    int     offset    = m_IsVertical ? Mathf.RoundToInt(diff.y / m_DragStep) : Mathf.RoundToInt(diff.x / m_DragStep);
                    int     dragValue = Mathf.Clamp(m_DragStartValue + offset, 0, Mathf.Max(0, m_MaxValue - m_MaxVisible));

                    int delta = dragValue - m_Value;

                    SetValue(dragValue);

                    if (m_ParentWidget != null)
                    {
                        m_ParentWidget.ChildButtonPressed(delta);
                    }

                    //Debug.Log(">>>> diff="+diff+", offset="+offset+", m_DragStartValue="+m_DragStartValue+", m_Value="+m_Value+", m_DragStep="+m_DragStep);
                }
            }
        }
            return(true);

        case E_CallbackType.E_CT_ON_TOUCH_END:
            if (m_ParentWidget != null)
            {
                // forward touch to parent if the begin and the end of touch is the same
                // so scrollbar can't handle it
                TouchEvent touch   = (TouchEvent)evt;
                Vector2    diff    = touch.Position - m_DragStartPosition;
                float      minDist = Mathf.Max(1.0f, Screen.height * 0.01f);
                if (                 /*(touch.EndTime - touch.StartTime) <= 0.1f &&*/
                    Mathf.Abs(touch.DeltaPosition.x) <= minDist &&
                    Mathf.Abs(touch.DeltaPosition.y) <= minDist &&
                    Mathf.Abs(diff.x) <= minDist &&
                    Mathf.Abs(diff.y) <= minDist)
                {
                    if (m_ParentWidget.TestFlag((int)E_CallbackType.E_CT_ON_TOUCH_BEGIN) == true)
                    {
                        TouchEvent touchBegin = new TouchEvent()
                        {
                            Id            = touch.Id,
                            Phase         = TouchPhase.Began,
                            Type          = touch.Type,
                            Position      = touch.Position,
                            StartPosition = m_DragStartPosition,
                            DeltaPosition = Vector2.zero,
                            StartTime     = touch.StartTime,
                            DeltaTime     = 0.0f,
                            EndTime       = 0.0f
                        };
                        m_ParentWidget.Callback(E_CallbackType.E_CT_ON_TOUCH_BEGIN, touchBegin);
                    }
                    if (m_ParentWidget.TestFlag((int)E_CallbackType.E_CT_ON_TOUCH_END) == true)
                    {
                        m_ParentWidget.Callback(E_CallbackType.E_CT_ON_TOUCH_END, touch);
                    }
                }
            }
            FadeOut();
            return(true);

        case E_CallbackType.E_CT_ON_TOUCH_END_OUTSIDE:
            FadeOut();
            return(true);

        default:
            return(false);
        }
    }