Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gro-ove committed Oct 4, 2018
1 parent 405b59a commit 8c22503
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 22 deletions.
6 changes: 3 additions & 3 deletions AcManager.Controls/ControlsStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions AcManager.Controls/UserControls/Cef/AcApiHandlerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ private class Registered {

public readonly Func<string, string> Callback;

public Registered(WeakReference<IWebBrowser> webBrowser, string[] allowedHosts, Func<string, string> callback) {
public Registered([CanBeNull] WeakReference<IWebBrowser> webBrowser, string[] allowedHosts, Func<string, string> callback) {
WebBrowser = webBrowser;
AllowedHosts = allowedHosts;
Callback = callback;
Identifier = Lazier.Create(() => WebBrowser.TryGetTarget(out var targetBrowser) ? targetBrowser.GetBrowser().Identifier : -1);
Identifier = Lazier.Create(() => WebBrowser != null && WebBrowser.TryGetTarget(out var targetBrowser)
? targetBrowser.GetBrowser()?.Identifier ?? -1 : -1);
}
}

Expand Down Expand Up @@ -117,8 +118,8 @@ bool IResourceHandler.ReadResponse(Stream dataOut, out int bytesRead, ICallback

bool IResourceHandler.CanGetCookie(Cookie cookie) => true;
bool IResourceHandler.CanSetCookie(Cookie cookie) => true;
void IResourceHandler.Cancel() {}
void IDisposable.Dispose() {}
void IResourceHandler.Cancel() { }
void IDisposable.Dispose() { }
}
}
}
1 change: 1 addition & 0 deletions AcManager.Tools/AcManager.Tools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@
<Compile Include="GameProperties\ReplayCommandExecutor.cs" />
<Compile Include="GameProperties\RsrMark.cs" />
<Compile Include="GameProperties\SrsMark.cs" />
<Compile Include="GameProperties\WeatherSpecific\CustomTrackPropertiesHelper.cs" />
<Compile Include="GameProperties\WeatherSpecific\IWeatherSpecificReplacement.cs" />
<Compile Include="GameProperties\WeatherSpecific\WeatherProceduralHelper.cs" />
<Compile Include="GameProperties\WeatherSpecific\WeatherProceduralHelper.Data.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using AcTools.DataFile;
using AcTools.Processes;
using JetBrains.Annotations;

namespace AcManager.Tools.GameProperties.WeatherSpecific {
public class CustomTrackPropertiesHelper : Game.RaceIniProperties {
[NotNull]
public string Filename { get; }

public CustomTrackPropertiesHelper([NotNull] string filename) {
Filename = filename;
}

public override void Set(IniFile file) {
Game.TrackProperties.Load(new IniFile(Filename)["TRACK_STATE"])?.Set(file);
}
}
}
8 changes: 4 additions & 4 deletions AcManager.Tools/Helpers/SettingsHolder.Drive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -984,8 +984,8 @@ public DelayEntry RhmKeepAlivePeriod {
DialogFilterPiece.AllFiles,
},
Title = "Select Real Head Motion application",
InitialDirectory = Path.GetDirectoryName(RhmLocation) ?? "",
DefaultFileName = Path.GetFileName(RhmLocation),
InitialDirectory = FileUtils.GetDirectoryNameSafe(RhmLocation) ?? "",
DefaultFileName = FileUtils.GetFileNameSafe(RhmLocation),
}) ?? RhmLocation;
}));

Expand All @@ -1000,8 +1000,8 @@ public DelayEntry RhmKeepAlivePeriod {
DialogFilterPiece.AllFiles
},
Title = "Select Real Head Motion settings",
InitialDirectory = Path.GetDirectoryName(RhmSettingsLocation) ?? "",
DefaultFileName = Path.GetFileName(RhmSettingsLocation),
InitialDirectory = FileUtils.GetDirectoryNameSafe(RhmSettingsLocation) ?? "",
DefaultFileName = FileUtils.GetFileNameSafe(RhmSettingsLocation),
}) ?? RhmSettingsLocation;
}));

Expand Down
3 changes: 1 addition & 2 deletions AcManager.Tools/SemiGui/GameWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using AcManager.Tools.Managers;
using AcManager.Tools.Miscellaneous;
using AcManager.Tools.Starters;
using AcTools.DataFile;
using AcTools.Processes;
using AcTools.Utils;
using AcTools.Utils.Helpers;
Expand Down Expand Up @@ -176,7 +175,7 @@ private static void StartAsync_Prepare(Game.StartProperties properties) {
}

if (File.Exists(properties.GetAdditional<CustomTrackState>()?.Filename)) {
properties.TrackProperties = Game.TrackProperties.Load(new IniFile(properties.GetAdditional<CustomTrackState>()?.Filename)["TRACK_STATE"]);
properties.SetAdditional(new CustomTrackPropertiesHelper(properties.GetAdditional<CustomTrackState>()?.Filename ?? string.Empty));
}

if (SettingsHolder.Live.RsrEnabled && SettingsHolder.Live.RsrDisableAppAutomatically) {
Expand Down
6 changes: 3 additions & 3 deletions AcManager.Tools/ToolsStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions AcManager/AppStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions AcTools/Utils/FileUtils.Paths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,24 @@ public static string GetFullPath([NotNull] string filename, [NotNull] Func<strin
return Path.GetFullPath(Path.Combine(lazyRelativeTo(), filename));
}

[CanBeNull, Pure]
public static string GetFileNameSafe([CanBeNull] string filename) {
try {
return Path.GetFileName(filename);
} catch (ArgumentException) {
return null;
}
}

[CanBeNull, Pure]
public static string GetDirectoryNameSafe([CanBeNull] string filename) {
try {
return Path.GetDirectoryName(filename);
} catch (ArgumentException) {
return null;
}
}

/// <summary>
/// Might use “..” in the result.
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions FirstFloor.ModernUI/UiStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8c22503

Please sign in to comment.