Interkarma / daggerfall-unity

Open source recreation of Daggerfall in the Unity engine
http://www.dfworkshop.net
MIT License
2.73k stars 331 forks source link

Control-U during character class creation resets bonus pool #2679

Closed petchema closed 3 weeks ago

petchema commented 3 months ago

Classic Daggerfall uses plain U key, but since in Daggerfall Unity the class name input field always has focus, that key would add an U character to the class name instead.

Remark: Under Linux, keyboard handling behaves a bit differently in the Unity Editor and in the Standalone Player: standalone player filters out control characters, while the editor does not, adding a "?" in the class name when Control-U is pressed. They could be filtered explicitly:

diff --git a/Assets/Scripts/Game/UserInterface/TextBox.cs b/Assets/Scripts/Game/UserInterface/TextBox.cs
index 9da458cef..6d660339f 100644
--- a/Assets/Scripts/Game/UserInterface/TextBox.cs +++ b/Assets/Scripts/Game/UserInterface/TextBox.cs @@ -453,6 +453,14 @@ namespace DaggerfallWorkshop.Game.UserInterface
                         }
                     }
                 }
+                else // !numeric
+                {
+                    // Filter control characters
+                    if ((int)character < 0x20)
+                    {
+                        return;
+                    }
+                }

                 // For upper only, force everything to caps
                 if (upperOnly)

but it seems less risky to just be aware of this small problem happening in the Editor only. (just tested that the problem doesn't occur under Windows).

petchema commented 3 weeks ago

Rereading the PR title, now I understand how confusing it was ;) Anyway, thanks for merge!