internal static void SubDispatch()
        {
            if (InputEvent != null)
            {
                if (!InputEvent.ReadOnly)
                {
                    if (!InputEvent.Pressed)
                    {
                        if (KeyPressed() == EditState.Continue)
                        {
                            if (Keyboard.InputChanged)
                            {
                                if (Keyboard.InputString == "")
                                {
                                    return;
                                }
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
                                if (Keyboard.Nokey())
                                {
                                    InputEvent.OnInputChanged(IME.CurrentCompStr());
                                }
                                else
                                {
                                    InputEvent.OnInputChanged(Keyboard.InputString);
                                }
#else
                                InputEvent.OnInputChanged(Keyboard.InputString);
#endif
                            }
                        }
                    }
                }
            }
        }
 private static void SoftwareKeyboard(UIElement focused, bool open)
 {
     if (TouchScreenKeyboard.isSupported)
     {
         if (open)
         {
             TouchKeyboard.Open(focused);
         }
         else
         {
             TouchKeyboard.Close();
         }
     }
     else if (focused is TextBox)
     {
         if (open)
         {
             IME.Open(focused);
         }
         else
         {
             IME.Close();
         }
     }
 }
Beispiel #3
0
        private void btnOpenFile_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog openDialog = new OpenFileDialog();
                DialogResult   result     = openDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    this.Text = "SE2GameForm " + openDialog.SafeFileName;

                    Type          moveLogic = null;
                    AI.IMoveLogic selected  = cmbAI.SelectedItem as AI.IMoveLogic;
                    if (selected != null)
                    {
                        moveLogic = selected.GetType();
                    }

                    World.Instance.Create(picGameWorld.ClientSize,
                                          Convert.ToInt32(nudEnemyCount.Value),
                                          moveLogic,
                                          true,
                                          openDialog.FileName);
                }
            }
            catch (InvalidMapException IME)
            {
                IME.GetType();
                MessageBox.Show(IME.Message, "Error Invalid Map", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                picGameWorld.Refresh();
            }
        }
        internal static void Dispatch()
        {
            if (InputEvent != null)
            {
                if (!InputEvent.ReadOnly)
                {
                    if (!InputEvent.Pressed)
                    {
#if UNITY_STANDALONE_WIN || UNITY_EDITOR
                        var state = KeyPressed();
                        if (state == EditState.Continue)
                        {
                            if (Keyboard.InputChanged)
                            {
                                if (Keyboard.InputString == "")
                                {
                                    return;
                                }
                                if (Keyboard.Nokey())
                                {
                                    InputEvent.OnInputChanged(IME.CurrentCompStr());
                                }
                                else
                                {
                                    InputEvent.OnInputChanged(Keyboard.InputString);
                                }
                            }
                        }
                        else if (state == EditState.Finish)
                        {
                            if (InputEvent.OnSubmit != null)
                            {
                                InputEvent.OnSubmit(InputEvent);
                            }
                        }
                        else if (state == EditState.NewLine)
                        {
                            InputEvent.OnInputChanged("\n");
                        }
#else
                        InputEvent.TouchInputChanged(Keyboard.TouchString);
                        if (Keyboard.status == TouchScreenKeyboard.Status.Done)
                        {
                            if (InputEvent.OnSubmit != null)
                            {
                                InputEvent.OnSubmit(InputEvent);
                            }
                            InputEvent.Refresh();
                            InputEvent = null;
                            return;
                        }
#endif
                    }
                }
                InputEvent.Refresh();
            }
        }
Beispiel #5
0
        internal static void SubDispatch()
        {
            if (InputEvent != null)
            {
                if (!InputEvent.ReadOnly)
                {
                    if (!InputEvent.Pressed)
                    {
                        var state = KeyPressed();
                        if (state == EditState.Continue)
                        {
                            if (Keyboard.InputChanged)
                            {
                                if (Keyboard.InputString == "")
                                {
                                    return;
                                }
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
                                if (Keyboard.Nokey())
                                {
                                    InputEvent.OnInputChanged(IME.CurrentCompStr());
                                }
                                else
                                {
                                    InputEvent.OnInputChanged(Keyboard.InputString);
                                }
#else
                                InputEvent.TouchInputChanged(Keyboard.InputString);
#endif
                            }
                        }
                        else if (state == EditState.Finish)
                        {
                            if (InputEvent.OnSubmit != null)
                            {
                                InputEvent.OnSubmit(InputEvent);
                            }
                        }
                        else if (state == EditState.NewLine)
                        {
                            InputEvent.OnInputChanged(Environment.NewLine);
                        }
                    }
                }
                if (InputEvent.textInfo.LineChange > 0)
                {
                    InputEvent.textInfo.LineChange = 0;
                    if (InputEvent.LineChanged != null)
                    {
                        InputEvent.LineChanged(InputEvent);
                    }
                }
            }
        }
Beispiel #6
0
 void getKeyPress(object sender, TextInputEventArgs e)
 {
     if (keytimer.ElapsedMilliseconds < keyRepeatTime)
     {
         return;
     }
     //0x8 is backspace, handle this correctly
     if (e.Character != 0x8 && e.Key != Settings.IMEKey && !specialCharacters.Contains(e.Character))
     {
         text = IME.doIMEString(text, e.Character);
     }
     else if (text != "" && e.Character == 0x8)
     {
         text = text.Substring(0, text.Length - 1);
     }
     if (text == "のりば" || text == "きょう" || text == "はれ")
     {
         text = IME.blah(text);
     }
     keytimer.Restart();
 }
Beispiel #7
0
        private void CreateWorld(bool createNewMap)
        {
            try
            {
                // Variable to hold the type of AI to use
                Type moveLogic = null;

                // Variable to hold the selected item in the combobox. Note that,
                // as the selected item is cast to IMoveLogic, it might fail as the
                // combobox also contains a string. As the only string in the
                // combobox indicates a random AI, we can use that fact to differ
                // between a specific or any AI.
                AI.IMoveLogic selected = cmbAI.SelectedItem as AI.IMoveLogic;

                // Check if the cast succeeded
                if (selected != null)
                {
                    // If so, get the type of the selected movelogic
                    moveLogic = selected.GetType();
                }

                World.Instance.Create(picGameWorld.ClientSize,
                                      Convert.ToInt32(nudEnemyCount.Value),
                                      moveLogic,
                                      createNewMap,
                                      null);
            }
            catch (InvalidMapException IME)
            {
                IME.GetType();
                MessageBox.Show(IME.Message, "Error Invalid Map", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                picGameWorld.Refresh();
            }
        }
Beispiel #8
0
        /// <summary>
        /// 键盘信息收集
        /// </summary>
        public static void InfoCollection()
        {
#if UNITY_STANDALONE_WIN || UNITY_EDITOR
            IME.Update();
            TempStringChanged = IME.CompStringChanged;
#endif
            systemCopyBuffer = GUIUtility.systemCopyBuffer;
            if (keys == null)
            {
                if (Application.platform == RuntimePlatform.Android |
                    Application.platform == RuntimePlatform.IPhonePlayer
                    | Application.platform == RuntimePlatform.WSAPlayerARM
                    | Application.platform == RuntimePlatform.WSAPlayerX64
                    | Application.platform == RuntimePlatform.WSAPlayerX86
                    )
                {
                    _touch = true;
                }
                keys     = Enum.GetValues(typeof(KeyCode)) as KeyCode[];
                KeyPress = new List <KeyCode>();
                KeyUps   = new List <KeyCode>();
                KeyDowns = new List <KeyCode>();
            }
            KeyPress.Clear();
            KeyUps.Clear();
            KeyDowns.Clear();
            for (int i = 0; i < keys.Length; i++)
            {
                var key = keys[i];
                if (Input.GetKey(key))
                {
                    KeyDowns.Add(key);
                }
                if (Input.GetKeyDown(key))
                {
                    KeyPress.Add(key);
                }
                if (Input.GetKeyUp(key))
                {
                    KeyUps.Add(key);
                }
            }
            if (_touch)
            {
                if (m_touch != null)
                {
                    if (m_touch.active)
                    {
#if !UNITY_STANDALONE_WIN
                        targetDisplay = m_touch.targetDisplay;
                        type          = m_touch.type;
#endif
                        selection = m_touch.selection;
                        string str = m_touch.text;
                        InputChanged    = true;
                        TouchString     = str;
                        canGetSelection = m_touch.canGetSelection;
                        status          = m_touch.status;
                    }
                    else
                    {
                        status = TouchScreenKeyboard.Status.LostFocus;
                    }
                    active = m_touch.active;
                }
            }
            else
            {
                CompositionString = Input.compositionString;
#if UNITY_STANDALONE_WIN || UNITY_EDITOR
                if (IME.Inputing)
                {
                    TempString = IME.CompString;
                    Input.compositionCursorPos = CursorPos;
                }
                else if (IME.InputDone)
                {
                    TempString        = "";
                    InputString       = IME.ResultString;
                    InputChanged      = true;
                    CompositionString = "";
                }
                else
                {
                    if (InputString != Input.inputString)
                    {
                        InputChanged = true;
                    }
                    else
                    {
                        InputChanged = false;
                    }
                    InputString = Input.inputString;
                }
#else
                if (InputString != Input.inputString)
                {
                    InputChanged = true;
                }
                else
                {
                    InputChanged = false;
                }
                InputString = Input.inputString;
#endif
            }
        }