RonenNess / GeonBit.UI

UI system for MonoGame projects.
MIT License
478 stars 64 forks source link

Crash on initialization for people with the OS language set to Turkish #94

Closed SerialKicked closed 5 years ago

SerialKicked commented 5 years ago

Sorry again :)

This one took me quite a while to find (well, until i got a customer complaint), I however also found the reason for said crash.

Symptom: UserInterface.Initialize(Content, "skin") will crash immediately if the system language is Turkish (+variations)

StackTrace:

error: Could not find file '[...]GeonBit.UI\themes\AtC2\textures\cursor_ıbeam_md.xnb'.
System.IO.FileNotFoundException

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Microsoft.Xna.Framework.TitleContainer.PlatformOpenStream(String safeName)
at Microsoft.Xna.Framework.TitleContainer.OpenStream(String name)
at Microsoft.Xna.Framework.Content.ContentManager.OpenStream(String assetName)
at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject)
at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)
at GeonBit.UI.Resources.LoadContent(ContentManager content, String theme)
at GeonBit.UI.UserInterface.Initialize(ContentManager contentManager, String theme)

Cause:

A little background history about the unique particularity of the Turkish language page is needed here. This page explains it better than i could. But to put it bluntly, the uppercase I (i) translates to a lowercase dot-less "ı" instead of a "i" in Turkish.

Resources.cs : 267 string cursorName = cursor.ToString().ToLower(); -> cursor_ibeam became cursor_ıbeam which cause the content loader to crash because it cannot find the proper file.

That's the first occurrence, but all the ToLower() in your resource.cs will (granted the files have a "i" character) will get converted the wrong way.

I'm not sure what's the most efficient fix here. I mean the obvious solution seems to regex/string.replace all the "ı" into "i" before sending the string to the content loader.

(if it's any consolation, i have plenty of editing to do on my own program too for Turkish users, apparently)

RonenNess commented 5 years ago

@SerialKicked Thank you for the bug report, fixed :)