Exemple #1
0
    Color ColorForSelState(SelState sel)
    {
        switch (sel)
        {
        case SelState.NotSelected: return(Color.clear);

        case SelState.Hovering:    return(new Color(0.32f, 0.32f, 1, 0.5f));

        default:                   return(new Color(0.32f, 0.32f, 1));

        case SelState.Fixed:       return(new Color(0.64f, 1, 0.32f));
        }
    }
Exemple #2
0
        public SelState GetSelState()
        {
            switch (selState)
            {
            case SelState.SEL_AE_START:
            case SelState.SEL_AE_END:
                if (acp.Start == acp.End)
                {
                    selState = SelState.SEL_AE_NONE;
                }
                break;

            case SelState.SEL_AE_NONE:
                if (acp.Start != acp.End)
                {
                    selState = SelState.SEL_AE_START;
                }
                break;

            default:
                break;
            }
            return(selState);
        }
Exemple #3
0
        public new void RecieveSpecialInput(Keys key)//IME will handle key event first, so these method just for english input(if it is using IME, we need to notify TSF)
        {
            var shiftPressed = (ModEntry._helper.Input.IsDown(StardewModdingAPI.SButton.LeftShift) || ModEntry._helper.Input.IsDown(StardewModdingAPI.SButton.RightShift));

            switch (key)
            {
            case Keys.Left:
                if (acp.Start > 0 || acp.End > 0)
                {
                    switch (GetSelState())
                    {
                    case SelState.SEL_AE_START:
                        if (shiftPressed)
                        {
                            if (acp.End > 0)
                            {
                                acp.End--;
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            acp.End = acp.Start;
                        }
                        break;

                    case SelState.SEL_AE_END:
                        if (shiftPressed)
                        {
                            if (acp.Start > 0)
                            {
                                acp.Start--;
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            acp.End = acp.Start;
                        }
                        break;

                    case SelState.SEL_AE_NONE:
                        if (shiftPressed)
                        {
                            acp.Start--;
                            selState = SelState.SEL_AE_END;
                        }
                        else
                        {
                            acp.End = acp.Start = --acp.Start;
                        }
                        break;
                    }
                    return;
                }
                break;

            case Keys.Right:
                var len = GetTextLength();
                if (acp.Start < len || acp.End < len)
                {
                    switch (GetSelState())
                    {
                    case SelState.SEL_AE_START:
                        if (shiftPressed)
                        {
                            if (acp.End < len)
                            {
                                acp.End++;
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            acp.Start = acp.End;
                        }
                        break;

                    case SelState.SEL_AE_END:
                        if (shiftPressed)
                        {
                            if (acp.Start < len)
                            {
                                acp.Start++;
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            acp.Start = acp.End;
                        }
                        break;

                    case SelState.SEL_AE_NONE:
                        if (shiftPressed)
                        {
                            acp.End++;
                            selState = SelState.SEL_AE_START;
                        }
                        else
                        {
                            acp.End = acp.Start = ++acp.Start;
                        }
                        break;
                    }
                    return;
                }
                break;

            default:
                break;
            }
            return;
        }
Exemple #4
0
 public void SetSelState(SelState state)
 {
     selState = state;
 }
Exemple #5
0
        public virtual void RecieveSpecialInput(Keys key)//IME will handle key event first, so these method just for english input(if it is using IME, we need to notify TSF)
        {
            var shiftPressed = (Game1.input.GetKeyboardState().IsKeyDown(Keys.LeftShift) || Game1.GetKeyboardState().IsKeyDown(Keys.RightShift));

            switch (key)
            {
            case Keys.Left:
                if (acp.Start > 0 || acp.End > 0)
                {
                    switch (GetSelState())
                    {
                    case SelState.SEL_AE_START:
                        if (shiftPressed)
                        {
                            if (acp.End > 0)
                            {
                                acp.End--;
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            acp.End = acp.Start;
                        }
                        break;

                    case SelState.SEL_AE_END:
                        if (shiftPressed)
                        {
                            if (acp.Start > 0)
                            {
                                acp.Start--;
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            acp.End = acp.Start;
                        }
                        break;

                    case SelState.SEL_AE_NONE:
                        if (shiftPressed)
                        {
                            acp.Start--;
                            selState = SelState.SEL_AE_END;
                        }
                        else
                        {
                            acp.End = acp.Start = --acp.Start;
                        }
                        break;
                    }
                    goto HasUpdated;
                }
                break;

            case Keys.Right:
                var len = GetTextLength();
                if (acp.Start < len || acp.End < len)
                {
                    switch (GetSelState())
                    {
                    case SelState.SEL_AE_START:
                        if (shiftPressed)
                        {
                            if (acp.End < len)
                            {
                                acp.End++;
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            acp.Start = acp.End;
                        }
                        break;

                    case SelState.SEL_AE_END:
                        if (shiftPressed)
                        {
                            if (acp.Start < len)
                            {
                                acp.Start++;
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            acp.Start = acp.End;
                        }
                        break;

                    case SelState.SEL_AE_NONE:
                        if (shiftPressed)
                        {
                            acp.End++;
                            selState = SelState.SEL_AE_START;
                        }
                        else
                        {
                            acp.End = acp.Start = ++acp.Start;
                        }
                        break;
                    }
                    goto HasUpdated;
                }
                break;

            default:
                break;
            }
            return;

HasUpdated:
            {
#if TSF
                if (Game1.keyboardDispatcher.Subscriber == this)
                {
                    Game1.tsf.onSelChange();
                }
#endif
            }
        }