Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Source.Common/Platform.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Source.Common;

using System.Diagnostics;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

Expand Down Expand Up @@ -48,6 +49,13 @@ public static unsafe void DebugString(ReadOnlySpan<char> buf) {
}

public static void Initialize() {
// Source's data files (KeyValues, .res, .vmt, convar values) are always en-US formatted, so the
// process must not follow the user's locale - float.Parse("0.25") throws under fr-FR otherwise.
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

ThreadUtils.SetMainThread();
}
}
4 changes: 3 additions & 1 deletion Source.GUI.Controls/PropertySheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Source.Common.GUI;
using Source.Common.Input;

using System.Globalization;

namespace Source.GUI.Controls;

class ContextLabel : Label
Expand Down Expand Up @@ -534,7 +536,7 @@ public override void ApplySchemeSettings(IScheme scheme) {
Border = scheme.GetBorder("RaisedBorder")!;

SetBorder(Border);
PageTransitionEffectTime = float.Parse(scheme.GetResourceString("PropertySheet.TransitionEffectTime"));
PageTransitionEffectTime = float.TryParse(scheme.GetResourceString("PropertySheet.TransitionEffectTime"), NumberStyles.Float, CultureInfo.InvariantCulture, out float transitionTime) ? transitionTime : 0;
TabFont = scheme.GetFont(SmallTabs ? "DefaultVerySmall" : "DefaultSmall")!;

if (TabKV != null)
Expand Down