Closed Afireal closed 1 year ago
In theory, it should automatically switch to English And loading an empty language will not result in an error I will add an automatic switch to English in the next update if the current language is empty
I update a new version, can you open now?
I managed to compile latest VPet-Simulator.Windows and that's what I got. Localization is automaticlly switching to EN without latest changes (sorry). Fortunatly, I discovered why app crashes exactly on Core mod loading. There's an exception on food initializing.
case "food":
Tag.Add("food");
foreach (FileInfo fi in di.EnumerateFiles("*.lps"))
{
var tmp = new LpsDocument(File.ReadAllText(fi.FullName));
foreach (ILine li in tmp)
{
string tmps = li.Find("name").info;
mw.Foods.RemoveAll(x => x.Name == tmps);
mw.Foods.Add(LPSConvert.DeserializeObject<Food>(li));
}
}
break;
System.FormatException: Input string was not in a correct format.
on mw.Foods.Add(LPSConvert.DeserializeObject<Food>(li));
If I compile whole thing with american formats in Win settings, everything is fine. I don't really know much about dotnet, so no ideas.
Stack trace. But I don't think it's really helpful now
System.FormatException
HResult=0x80131537
Message=Входная строка имела неверный формат. <-- Input string was not in a correct format.
Source=mscorlib
StackTrace:
at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
at System.String.System.IConvertible.ToDouble(IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at LinePutScript.Converter.LPSConvert.GetStringObject(String value, Type type, ConvertType convtype, LineAttribute att)
at LinePutScript.Converter.LPSConvert.GetSubObject(ISub sub, Type type, ConvertType convtype, LineAttribute att)
at LinePutScript.Converter.LPSConvert.DeserializeObject[T](ISub value)
at VPet_Simulator.Windows.CoreMOD..ctor(DirectoryInfo directory, MainWindow mw) in E:\Git\VPet\VPet-Simulator.Windows\Function\CoreMOD.cs:line 137
at VPet_Simulator.Windows.MainWindow.<GameLoad>d__107.MoveNext() in E:\Git\VPet\VPet-Simulator.Windows\MainWindow.xaml.cs:line 208```
I think that's the real reason for the error report. I'll study how to solve it. Thank you for your feedback. It really helped a lot
That's so stupid, but it's real. This converter or smth else in the code can't accept a comma as a decimal separator. If I change it to point in Win Control Panel without completely switching to American standards, it will work. LMAO Looks like somewhere in the converter code, there is no lookup for system formats, but hardcoded point.
I'm sorry, I wrote this LinePutScript
I may find a solution and try to lock the language to en US
Convert.ChangeType(Sub.TextDeReplace(value), type, new CultureInfo("en-US"));
but I am not sure is that work, I will compile a beta version. Can you help me test it
ok, no problem
LinePutScript.zip
rereplace it with LinePutScript.dll
is game working?
Nope. Neither the steam version nor the compiled one
Can you use visual studio Reference this DLL and run again? I want to see is same error or different
Different one, but still the same exception. I will now send details
VPet-Simulator.Core/Graph/FoodAnimation.cs:151
if (strs.Length > 4)
{
Rotate = double.Parse(strs[4]);//Rotate
if (strs.Length > 5)
Opacity = double.Parse(strs[5]);//Opacity
}
Same System.FormatException: Input string was not in a correct format.
on double.Parse(strs[5])
Stack trace
System.FormatException
HResult=0x80131537
Message=Входная строка имела неверный формат.
Source=mscorlib
StackTrace:
at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
at System.Double.Parse(String s)
at VPet_Simulator.Core.FoodAnimation.Animation..ctor(FoodAnimation parent, ISub sub) in E:\Git\VPet\VPet-Simulator.Core\Graph\FoodAnimation.cs:line 149
at VPet_Simulator.Core.FoodAnimation..ctor(GraphCore graphCore, GraphInfo graphinfo, String front_Lay, String back_Lay, ILine animations, Boolean isLoop) in E:\Git\VPet\VPet-Simulator.Core\Graph\FoodAnimation.cs:line 45
at VPet_Simulator.Core.FoodAnimation.LoadGraph(GraphCore graph, FileSystemInfo path, ILine info) in E:\Git\VPet\VPet-Simulator.Core\Graph\FoodAnimation.cs:line 53
at VPet_Simulator.Core.PetLoader.LoadGraph(GraphCore graph, DirectoryInfo di, String startuppath) in E:\Git\VPet\VPet-Simulator.Core\Handle\PetLoader.cs:line 94
at VPet_Simulator.Core.PetLoader.LoadGraph(GraphCore graph, DirectoryInfo di, String startuppath) in E:\Git\VPet\VPet-Simulator.Core\Handle\PetLoader.cs:line 117
at VPet_Simulator.Core.PetLoader.Graph(Int32 Resolution) in E:\Git\VPet\VPet-Simulator.Core\Handle\PetLoader.cs:line 25
at VPet_Simulator.Windows.MainWindow.<>c__DisplayClass107_0.<GameLoad>b__7() in E:\Git\VPet\VPet-Simulator.Windows\MainWindow.xaml.cs:line 327
at System.Windows.Threading.DispatcherOperation.InvokeDelegateCore()
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
Can you add
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
at https://github.com/LorisYounger/VPet/blob/main/VPet-Simulator.Windows/MainWindow.xaml.cs#L43
public MainWindow()
{
LocalizeCore.StoreTranslation = true;
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
...
and try again?
Nothing has changed
How about
CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";
at https://github.com/LorisYounger/VPet/blob/main/VPet-Simulator.Windows/MainWindow.xaml.cs#L43
public MainWindow()
{
LocalizeCore.StoreTranslation = true;
CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";
System.InvalidOperationException on new line It's says that it's read-only value
CultureInfo.CurrentCulture = new CultureInfo(CultureInfo.CurrentCulture.Name);
CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator = ".";
This should be effective
LocalizeCore.StoreTranslation = true;
CultureInfo.CurrentCulture = new CultureInfo(CultureInfo.CurrentCulture.Name);
CultureInfo.CurrentCulture.NumberFormat = new CultureInfo("en-US").NumberFormat;
It's works!
Thanks for you help!
Should I close this issue or it's just a temporary solution?
Thank you again for your help, I will update fix to steam soon I will close when the update is complete
Seems like app just crashes on Core mod loading because of lack of a localization for system region. Setting it to
English (USA)
in Win settings fixes the issue but idk it's not really a nice way. How about automaticlly setting localization to EN if there is no lang files for system language?