Fix anti-aliasing selection being lost on form load.

This commit is contained in:
Nick Blakely 2020-11-18 16:28:38 -08:00
parent e6747b0d3a
commit 6ecadc90c0
4 changed files with 27 additions and 15 deletions

View File

@ -22,6 +22,7 @@ namespace Giants.Launcher
{
// Must come first as other options depend on it
this.PopulateRenderers();
this.SetRenderer();
this.PopulateResolution();
this.PopulateAnisotropy();
@ -40,6 +41,24 @@ namespace Giants.Launcher
.ToArray());
}
private void SetRenderer()
{
string selectedRenderer = GameSettings.Get<string>(RegistryKeys.Renderer);
RendererInfo renderer =
GameSettings.CompatibleRenderers.Find(
r => Path.GetFileName(r.FilePath).Equals(selectedRenderer, StringComparison.OrdinalIgnoreCase));
if (renderer != null)
{
this.cmbRenderer.SelectedItem = renderer;
}
else
{
renderer = GameSettings.CompatibleRenderers.Find(r => r.FileName == "gg_dx7r.dll");
this.cmbRenderer.SelectedItem = renderer;
}
}
private void SetOptions()
{
var resolutions = (List<ScreenResolution>)this.cmbResolution.DataSource;
@ -53,19 +72,6 @@ namespace Giants.Launcher
this.cmbAntialiasing.SelectedIndex = 0;
this.chkUpdates.Checked = GameSettings.Get<int>(RegistryKeys.NoAutoUpdate) != 1;
RendererInfo renderer = GameSettings.CompatibleRenderers.Find(
r => StringComparer.OrdinalIgnoreCase.Compare(Path.GetFileName(r.FilePath), GameSettings.Get<string>(RegistryKeys.Renderer)) == 0);
if (renderer != null)
{
this.cmbRenderer.SelectedItem = renderer;
}
else
{
renderer = GameSettings.CompatibleRenderers.Find(r => r.FileName == "gg_dx7r.dll");
this.cmbRenderer.SelectedItem = renderer;
}
}
private void PopulateAntialiasing()

View File

@ -234,7 +234,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent Condition="'$(Configuration)' == 'Release'">xcopy /DY "$(TargetPath)" "$(GIANTS_PATH)\$(TargetFileName)*"</PostBuildEvent>
<PostBuildEvent Condition="'$(Configuration)' == 'ReleaseBeta'">xcopy /DY "$(TargetPath)" "$(GIANTS_PATH)\$(TargetFileName)*"</PostBuildEvent>
<PostBuildEvent Condition="'$(Configuration)' == 'ReleaseBeta'">xcopy /DY "$(TargetPath)" "$(GIANTS_PATH)\$(TargetFileName)*"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -6,9 +6,13 @@ namespace Giants.Launcher
{
static class NativeMethods
{
[DllImport("kernel32.dll")]
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetDllDirectory(string lpPathName);
[DllImport("kernel32.dll")]
public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName);

View File

@ -58,6 +58,8 @@ namespace Giants.Launcher
{
try
{
NativeMethods.SetDllDirectory(Environment.CurrentDirectory);
// Make interop call to native renderer DLLs to get capability info
var interopCaps = new RendererInterop.GFXCapabilityInfo();
string path = Path.Combine(file.DirectoryName, file.Name);