Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IME Support for DX and XNA #32

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

frg2089
Copy link
Contributor

@frg2089 frg2089 commented Mar 12, 2024

Forgive me, my English is really bad, but this PR is so important that I had to use Microsoft Copilot to generate a paragraph describing its importance.

The addition of Input Method Editor (IME) support in this pull request is a significant enhancement for CJK (Chinese, Japanese, Korean) users.
It allows for seamless integration of native language input within the Rampastring.XNAUI framework, which is crucial for applications targeting audiences in these regions.
This improvement not only enhances user experience by facilitating easier text input in CJK characters but also broadens the accessibility of the application to a wider demographic, ensuring that CJK users can interact with the UI in their preferred language without barriers.

I have provided IME support for DX and XNA. However, it’s not possible to support GL as MonoGame does not offer an API to hook into the external SDL2 message loop.


Perfect IME support for DX and XNA (WinForms based).
IME support for GL (SDL2 based) to make it barely work.
I dropped IME support for SDL2. Unless MonoGame provides support.

Reference #11
Code copied from ryancheung/MonoGame.IMEHelper.
new package reference ImeSharp (for WinForms base).

LICENSE.md Outdated Show resolved Hide resolved
frg2089 added 2 commits March 14, 2024 13:51
Provide by ImeSharp

Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
@frg2089 frg2089 changed the title IME Support Add IME Support for DX and XNA Mar 14, 2024
@SadPencil
Copy link
Contributor

Note that many Chinese mods that use forks of xna-cncnet-client have already shipped with IME support for about 2 or 3 years, to meet the huge need of numerous players. Thus I think we should merge this PR and thus officially provide IME support before releasing a stable release of xna-cncnet-client -- if not, these users might have to seek for an unstable release just in order to type words.

frg2089 added 2 commits March 15, 2024 21:12
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
@frg2089
Copy link
Contributor Author

frg2089 commented Mar 16, 2024

@Rampastring I think the PR is ready to be reviewed.

Input/IME/WinForms/WinFormsIMEHandler.cs Outdated Show resolved Hide resolved
Input/IME/WinForms/WinFormsIMEHandler.cs Outdated Show resolved Hide resolved
XNAControls/XNATextBox.cs Outdated Show resolved Hide resolved
Input/IME/Sdl/SdlIMEHandler.cs Outdated Show resolved Hide resolved
Input/IME/IMEHandler.cs Outdated Show resolved Hide resolved
@linghengqian
Copy link

Note that many Chinese mods that use forks of xna-cncnet-client have already shipped with IME support for about 2 or 3 years, to meet the huge need of numerous players. Thus I think we should merge this PR and thus officially provide IME support before releasing a stable release of xna-cncnet-client -- if not, these users might have to seek for an unstable release just in order to type words.

  • @SadPencil Is there something preventing further review? Or is it because the current PR is missing unit tests?

@SadPencil
Copy link
Contributor

Note that many Chinese mods that use forks of xna-cncnet-client have already shipped with IME support for about 2 or 3 years, to meet the huge need of numerous players. Thus I think we should merge this PR and thus officially provide IME support before releasing a stable release of xna-cncnet-client -- if not, these users might have to seek for an unstable release just in order to type words.

* @SadPencil Is there something preventing further review? Or is it because the current PR is missing unit tests?

@linghengqian I don't think unit tests are helpful for windows UI related stuffs. Just waiting a review from the maintainer.

@enderseven1
Copy link

There is a bug in IME, when i enter an error charactor in IME, if i backspace it, the charactor in IME and another in Textbox also be deleted. Even the backspace key sometimes doesn't work once need pressing it again.

你那个IME有个bug,如果输入错了某个字母,我退格,不仅输入法里的被删就连文本框里的也会被删,不知道什么原因

@frg2089
Copy link
Contributor Author

frg2089 commented Aug 28, 2024

There is a bug in IME, when i enter an error charactor in IME, if i backspace it, the charactor in IME and another in Textbox also be deleted. Even the backspace key sometimes doesn't work once need pressing it again.

你那个IME有个bug,如果输入错了某个字母,我退格,不仅输入法里的被删就连文本框里的也会被删,不知道什么原因

你可以检查一下打开的是不是 clientdx
如果出问题的不是 clientdx 那我也没办法解决这个问题

@enderseven1
Copy link

你可以检查一下打开的是不是 clientdx 如果出问题的不是 clientdx 那我也没办法解决这个问题

其他的不知道,我打开的一直是dx。还有一个问题,就是偶尔输入时会无响应然后卡崩,不过概率小,三天两头遇不到几回。
顺便补充一下这个帖子的代码。

ClientCrashLog_2024_08_28_15_02.txt

顺带崩端的日志,使用的客户端是我的开源库

@enderseven1
Copy link

就在刚刚我也出现了同样的打字无响应崩端的问题,但是我没有日志。我录了个视频表达我发现的bug:

  • 删除输入错误的字母时一并把文本框里的删了。
  • 输入法有字时按下回车理应是输入原字,但是却在输入原字后同时发送。
  • 退格键有时候要多按一下才会删字。
2024-08-28.153306.mp4

@SadPencil
Copy link
Contributor

SadPencil commented Aug 28, 2024

@frg2089 @enderseven1 I have to remind both of you that GitHub is a place where discussions are made public. This means you should always use English regardless of whether both of you participants prefer discussion in another language or not. Think about 3rd party audiences who try to review the PR quality through your discussion.

@enderseven1
Copy link

@SadPencil Okay, I understand. While i should use English but i need Chinese to read it easily. I can speak English and Chinese, but my English is bad. Can i use two languages at the same time?

@SadPencil
Copy link
Contributor

@SadPencil Okay, I understand. While i should use English but i need Chinese to read it easily. I can speak English and Chinese, but my English is bad. Can i use two languages at the same time?

Yeah, I guess so. You can utilize AI to provides others an English translation in parallel with your Chinese text.

@enderseven1
Copy link

The sender of this request and me are Chinese, it is ask for trouble if we talk in English. For example, I provide English translation in my first comment. But I really didn't take into account that this is a project with foreigners as the main contributors. So i'm sorry. I'll take notice.

And this bug of IME will be fixed by a Chinese, so i think English may not too important in this time, but i will take English translation in my every comment after this.

主要是楼主跟俺都是中国的,咱俩互相讲英文这不没事找事吗?不过我第一个评论是用了中英并行,但我确实忘了这个项目以外国人的贡献为主,抱歉我会注意的。

我寻思这bug也是国人修,英语没那么重要吧,我以后会带英文翻译的...

@frg2089
Copy link
Contributor Author

frg2089 commented Aug 28, 2024

就在刚刚我也出现了同样的打字无响应崩端的问题,但是我没有日志。我录了个视频表达我发现的bug:

  • 删除输入错误的字母时一并把文本框里的删了。
  • 输入法有字时按下回车理应是输入原字,但是却在输入原字后同时发送。
  • 退格键有时候要多按一下才会删字。

2024-08-28.153306.mp4

我看到了视频演示,你似乎在使用第三方输入法
请切换到 微软拼音 输入法然后观察是否依然存在这个现象

English (Machine Translate by DeepL)

I saw the video demo and you seem to be using a third party input method.
Please switch to Microsoft Pinyin and see if this still occurs

@enderseven1
Copy link

image
我使用的是Windows 11的预览版,这个版本每次更新都会给我带来惊喜,某天某日某月把我微软拼音更新没了……

English (Translated by my brain) I am using Windows 11 Preview, it gives me surprise in every update. The Microsoft Pinyin doesn't work in someone of updates.

@frg2089
Copy link
Contributor Author

frg2089 commented Aug 28, 2024

我使用的是Windows 11的预览版,这个版本每次更新都会给我带来惊喜,某天某日某月把我微软拼音更新没了……

试着在 Windows 设置中加回来呢?
我同样有一个运行预览版 Windows 11 的设备,但没遇到输入法没了的情况

image
image

English (Machine Translate by DeepL)

What about trying to add it back in Windows settings?
I also have a device running Windows 11 Inside Preview and I'm not experiencing the loss of input method.

@enderseven1
Copy link

我重装一下试试,目前的情况是微软拼音没有第一个bug,但是第二个bug仍然存在。第三个bug有点迷,几率产生,尚不明确。
我原本用的是搜狗输入法。

2024-08-28.180936.mp4
English (Translated by my brain) Now, the first bug that deletes text in textbox with IME has fixed. But the second bug that sends text when i press enter key with IME still be. Third bug I don't know yet, because it not happens eveytime.

@frg2089
Copy link
Contributor Author

frg2089 commented Aug 28, 2024

我重装一下试试,目前的情况是微软拼音没有第一个bug,但是第二个bug仍然存在。第三个bug有点迷,几率产生,尚不明确。 我原本用的是搜狗输入法。

由于个人精力有限,这个PR只会处理微软输入法出现的问题
第三方的输入法我不会去主动支持

以及,我最近应该是没时间处理这些问题了,你如果感兴趣的话 可以看看 XNAControls/XNATextBox.cs 文件
第二条和第三条应该可以通过获取输入法合成状态来解决

English (Machine Translate by DeepL)

Due to personal limitations, this PR will only deal with issues that arise with Microsoft's input methods.
I'm not going to actively support third party input methods.

As well, I don't think I have time to deal with these issues lately, if you are interested, you can take a look at the XNAControls/XNATextBox.cs file.
The second and third items should be solved by getting the synthesis status of the input method.

@enderseven1
Copy link

@frg2089 虽然说第三方输入法的问题换输入法就能解决,但是回车直接发送的bug必须得修啊,退格偶尔失灵的问题没什么大不了,但还是影响体验。
目前确定的情况:退格失灵一般发生在本次启动客户端第一次使用Textbox时。
不受第一个bug影响的输入法(目前已知):微软拼音、小狼毫

2024-08-28.234632.mp4
English (Translate by Bing) Although the problem of the third-party input method can be solved by changing the input method,But the bug sent directly by the carriage enter must be repaired,The problem of occasional failure of backspace is not a big deal, But it still affects the experience. The situation that has been determined so far: backspace failure generally occurs when the client uses Textbox for the first time. Input methods that are not affected by the first bug (currently known): Microsoft Pinyin, Rime

@enderseven1
Copy link

根据我更加深入的测试,退格失灵只会发生在每次启动第一次被使用的SuggestionTextBox中,也就是说每个SuggestionTextBox都会触发一次这个问题,不是说我触发了一次后面就都不会有,换一个SuggestionTextBox一样会有,只是每次启动只会出现一次,我起初怀疑是内容里混入了某个零宽字符导致退格无明显现象,但是键盘左右键否定了我的猜想。

English (Translate by Bing) According to my more in-depth testing, the backspace failure will only occur in the first time for a SuggestionTextBox that is used every time after the client is started, that is to say, each SuggestionTextBox will trigger this problem once, not that I will not have it after I trigger it once, but it will also occur with a different SuggestionTextBox, but it will only appear once per startup, I initially suspected that the content was mixed with a zero-width character that caused the backspace to be insignificant, but the left and right keys on the keyboard negate my conjecture.

@enderseven1
Copy link

比如说局域网大厅的聊天框和房间里的地图搜索框都是SuggestionTextBox,它俩会各来一次。

English (Translate by Bing) For example, the chat box in the LAN lobby and the map search box in the room are both SuggestionTextBox, and they will each have this bug.

@frg2089
Copy link
Contributor Author

frg2089 commented Oct 27, 2024

Summary:
The Chinese comments mentioned above have no relation to this PR, and the issue raised cannot be reproduced on this PR. The maintainer can proceed with reviewing the code as usual.

fixed the backspace was not work on first time.

Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants