1
0
mirror of https://github.com/ncblakely/GiantsTools synced 2024-11-23 14:45:37 +01:00

Merge pull request #21 from ncblakely/features/d3d11

Merge D3D11 feature branch.
This commit is contained in:
ncblakely 2022-11-09 18:54:34 -08:00 committed by GitHub
commit 8d918dcaf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 140 additions and 83 deletions

View File

@ -31,7 +31,9 @@
this.cmbRenderer = new System.Windows.Forms.ComboBox(); this.cmbRenderer = new System.Windows.Forms.ComboBox();
this.cmbResolution = new System.Windows.Forms.ComboBox(); this.cmbResolution = new System.Windows.Forms.ComboBox();
this.cmbAntialiasing = new System.Windows.Forms.ComboBox(); this.cmbAntialiasing = new System.Windows.Forms.ComboBox();
this.cmbAnisotropy = new System.Windows.Forms.ComboBox();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
@ -43,13 +45,12 @@
this.btnCancel = new System.Windows.Forms.Button(); this.btnCancel = new System.Windows.Forms.Button();
this.btnResetDefaults = new System.Windows.Forms.Button(); this.btnResetDefaults = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox(); this.groupBox3 = new System.Windows.Forms.GroupBox();
this.chkUpdates = new System.Windows.Forms.CheckBox(); this.label5 = new System.Windows.Forms.Label();
this.cmbBranch = new System.Windows.Forms.ComboBox(); this.cmbBranch = new System.Windows.Forms.ComboBox();
this.BranchGroupBox = new System.Windows.Forms.GroupBox(); this.chkUpdates = new System.Windows.Forms.CheckBox();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout(); this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout(); this.groupBox3.SuspendLayout();
this.BranchGroupBox.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// cmbRenderer // cmbRenderer
@ -83,11 +84,22 @@
this.cmbAntialiasing.Size = new System.Drawing.Size(335, 24); this.cmbAntialiasing.Size = new System.Drawing.Size(335, 24);
this.cmbAntialiasing.TabIndex = 2; this.cmbAntialiasing.TabIndex = 2;
// //
// cmbAnisotropy
//
this.cmbAnisotropy.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbAnisotropy.FormattingEnabled = true;
this.cmbAnisotropy.Location = new System.Drawing.Point(165, 133);
this.cmbAnisotropy.Name = "cmbAnisotropy";
this.cmbAnisotropy.Size = new System.Drawing.Size(335, 24);
this.cmbAnisotropy.TabIndex = 3;
//
// groupBox1 // groupBox1
// //
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label3); this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label2); this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1); this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.cmbAnisotropy);
this.groupBox1.Controls.Add(this.cmbRenderer); this.groupBox1.Controls.Add(this.cmbRenderer);
this.groupBox1.Controls.Add(this.cmbResolution); this.groupBox1.Controls.Add(this.cmbResolution);
this.groupBox1.Controls.Add(this.cmbAntialiasing); this.groupBox1.Controls.Add(this.cmbAntialiasing);
@ -95,11 +107,20 @@
this.groupBox1.Margin = new System.Windows.Forms.Padding(4); this.groupBox1.Margin = new System.Windows.Forms.Padding(4);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(4); this.groupBox1.Padding = new System.Windows.Forms.Padding(4);
this.groupBox1.Size = new System.Drawing.Size(509, 143); this.groupBox1.Size = new System.Drawing.Size(509, 176);
this.groupBox1.TabIndex = 4; this.groupBox1.TabIndex = 4;
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "Graphics Settings"; this.groupBox1.Text = "Graphics Settings";
// //
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(26, 138);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(127, 16);
this.label4.TabIndex = 7;
this.label4.Text = "Anisotropic Filtering:";
//
// label3 // label3
// //
this.label3.AutoSize = true; this.label3.AutoSize = true;
@ -135,7 +156,7 @@
this.groupBox2.Controls.Add(this.cmbMode); this.groupBox2.Controls.Add(this.cmbMode);
this.groupBox2.Controls.Add(this.chkTripleBuffering); this.groupBox2.Controls.Add(this.chkTripleBuffering);
this.groupBox2.Controls.Add(this.chkVSync); this.groupBox2.Controls.Add(this.chkVSync);
this.groupBox2.Location = new System.Drawing.Point(16, 170); this.groupBox2.Location = new System.Drawing.Point(16, 199);
this.groupBox2.Margin = new System.Windows.Forms.Padding(4); this.groupBox2.Margin = new System.Windows.Forms.Padding(4);
this.groupBox2.Name = "groupBox2"; this.groupBox2.Name = "groupBox2";
this.groupBox2.Padding = new System.Windows.Forms.Padding(4); this.groupBox2.Padding = new System.Windows.Forms.Padding(4);
@ -160,8 +181,8 @@
// //
// chkTripleBuffering // chkTripleBuffering
// //
this.chkTripleBuffering.AutoSize = true; this.chkTripleBuffering.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.chkTripleBuffering.Location = new System.Drawing.Point(16, 79); this.chkTripleBuffering.Location = new System.Drawing.Point(13, 79);
this.chkTripleBuffering.Margin = new System.Windows.Forms.Padding(4); this.chkTripleBuffering.Margin = new System.Windows.Forms.Padding(4);
this.chkTripleBuffering.Name = "chkTripleBuffering"; this.chkTripleBuffering.Name = "chkTripleBuffering";
this.chkTripleBuffering.Size = new System.Drawing.Size(119, 20); this.chkTripleBuffering.Size = new System.Drawing.Size(119, 20);
@ -171,18 +192,18 @@
// //
// chkVSync // chkVSync
// //
this.chkVSync.AutoSize = true; this.chkVSync.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.chkVSync.Location = new System.Drawing.Point(16, 53); this.chkVSync.Location = new System.Drawing.Point(13, 53);
this.chkVSync.Margin = new System.Windows.Forms.Padding(4); this.chkVSync.Margin = new System.Windows.Forms.Padding(4);
this.chkVSync.Name = "chkVSync"; this.chkVSync.Name = "chkVSync";
this.chkVSync.Size = new System.Drawing.Size(107, 20); this.chkVSync.Size = new System.Drawing.Size(119, 20);
this.chkVSync.TabIndex = 1; this.chkVSync.TabIndex = 1;
this.chkVSync.Text = "Vertical Sync"; this.chkVSync.Text = "Vertical Sync";
this.chkVSync.UseVisualStyleBackColor = true; this.chkVSync.UseVisualStyleBackColor = true;
// //
// btnOK // btnOK
// //
this.btnOK.Location = new System.Drawing.Point(317, 272); this.btnOK.Location = new System.Drawing.Point(317, 304);
this.btnOK.Margin = new System.Windows.Forms.Padding(4); this.btnOK.Margin = new System.Windows.Forms.Padding(4);
this.btnOK.Name = "btnOK"; this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(100, 28); this.btnOK.Size = new System.Drawing.Size(100, 28);
@ -194,7 +215,7 @@
// btnCancel // btnCancel
// //
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(425, 272); this.btnCancel.Location = new System.Drawing.Point(425, 304);
this.btnCancel.Margin = new System.Windows.Forms.Padding(4); this.btnCancel.Margin = new System.Windows.Forms.Padding(4);
this.btnCancel.Name = "btnCancel"; this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(100, 28); this.btnCancel.Size = new System.Drawing.Size(100, 28);
@ -205,7 +226,7 @@
// //
// btnResetDefaults // btnResetDefaults
// //
this.btnResetDefaults.Location = new System.Drawing.Point(400, 170); this.btnResetDefaults.Location = new System.Drawing.Point(400, 205);
this.btnResetDefaults.Margin = new System.Windows.Forms.Padding(4); this.btnResetDefaults.Margin = new System.Windows.Forms.Padding(4);
this.btnResetDefaults.Name = "btnResetDefaults"; this.btnResetDefaults.Name = "btnResetDefaults";
this.btnResetDefaults.Size = new System.Drawing.Size(125, 28); this.btnResetDefaults.Size = new System.Drawing.Size(125, 28);
@ -216,46 +237,46 @@
// //
// groupBox3 // groupBox3
// //
this.groupBox3.Controls.Add(this.label5);
this.groupBox3.Controls.Add(this.cmbBranch);
this.groupBox3.Controls.Add(this.chkUpdates); this.groupBox3.Controls.Add(this.chkUpdates);
this.groupBox3.Location = new System.Drawing.Point(181, 167); this.groupBox3.Location = new System.Drawing.Point(181, 199);
this.groupBox3.Margin = new System.Windows.Forms.Padding(4); this.groupBox3.Margin = new System.Windows.Forms.Padding(4);
this.groupBox3.Name = "groupBox3"; this.groupBox3.Name = "groupBox3";
this.groupBox3.Padding = new System.Windows.Forms.Padding(4); this.groupBox3.Padding = new System.Windows.Forms.Padding(4);
this.groupBox3.Size = new System.Drawing.Size(169, 54); this.groupBox3.Size = new System.Drawing.Size(211, 97);
this.groupBox3.TabIndex = 6; this.groupBox3.TabIndex = 6;
this.groupBox3.TabStop = false; this.groupBox3.TabStop = false;
this.groupBox3.Text = "Other"; this.groupBox3.Text = "Updates";
// //
// chkUpdates // label5
// //
this.chkUpdates.AutoSize = true; this.label5.AutoSize = true;
this.chkUpdates.Location = new System.Drawing.Point(11, 24); this.label5.Location = new System.Drawing.Point(8, 54);
this.chkUpdates.Margin = new System.Windows.Forms.Padding(4); this.label5.Name = "label5";
this.chkUpdates.Name = "chkUpdates"; this.label5.Size = new System.Drawing.Size(52, 16);
this.chkUpdates.Size = new System.Drawing.Size(140, 20); this.label5.TabIndex = 10;
this.chkUpdates.TabIndex = 1; this.label5.Text = "Branch:";
this.chkUpdates.Text = "Check for Updates";
this.chkUpdates.UseVisualStyleBackColor = true;
// //
// cmbBranch // cmbBranch
// //
this.cmbBranch.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbBranch.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbBranch.FormattingEnabled = true; this.cmbBranch.FormattingEnabled = true;
this.cmbBranch.Location = new System.Drawing.Point(27, 17); this.cmbBranch.Location = new System.Drawing.Point(66, 49);
this.cmbBranch.Name = "cmbBranch"; this.cmbBranch.Name = "cmbBranch";
this.cmbBranch.Size = new System.Drawing.Size(124, 24); this.cmbBranch.Size = new System.Drawing.Size(124, 24);
this.cmbBranch.TabIndex = 9; this.cmbBranch.TabIndex = 9;
// //
// BranchGroupBox // chkUpdates
// //
this.BranchGroupBox.Controls.Add(this.cmbBranch); this.chkUpdates.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.BranchGroupBox.Location = new System.Drawing.Point(181, 222); this.chkUpdates.Location = new System.Drawing.Point(8, 25);
this.BranchGroupBox.Name = "BranchGroupBox"; this.chkUpdates.Margin = new System.Windows.Forms.Padding(4);
this.BranchGroupBox.Size = new System.Drawing.Size(169, 49); this.chkUpdates.Name = "chkUpdates";
this.BranchGroupBox.TabIndex = 10; this.chkUpdates.Size = new System.Drawing.Size(182, 20);
this.BranchGroupBox.TabStop = false; this.chkUpdates.TabIndex = 1;
this.BranchGroupBox.Text = "Branch"; this.chkUpdates.Text = "Check for Updates";
this.BranchGroupBox.Visible = false; this.chkUpdates.UseVisualStyleBackColor = true;
// //
// OptionsForm // OptionsForm
// //
@ -264,9 +285,8 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true; this.AutoSize = true;
this.CancelButton = this.btnCancel; this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(541, 316); this.ClientSize = new System.Drawing.Size(541, 346);
this.ControlBox = false; this.ControlBox = false;
this.Controls.Add(this.BranchGroupBox);
this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox3);
this.Controls.Add(this.btnResetDefaults); this.Controls.Add(this.btnResetDefaults);
this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnCancel);
@ -286,10 +306,8 @@
this.groupBox1.ResumeLayout(false); this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout(); this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false); this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false); this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout(); this.groupBox3.PerformLayout();
this.BranchGroupBox.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -299,7 +317,9 @@
private System.Windows.Forms.ComboBox cmbRenderer; private System.Windows.Forms.ComboBox cmbRenderer;
private System.Windows.Forms.ComboBox cmbResolution; private System.Windows.Forms.ComboBox cmbResolution;
private System.Windows.Forms.ComboBox cmbAntialiasing; private System.Windows.Forms.ComboBox cmbAntialiasing;
private System.Windows.Forms.ComboBox cmbAnisotropy;
private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
@ -313,6 +333,6 @@
private System.Windows.Forms.CheckBox chkUpdates; private System.Windows.Forms.CheckBox chkUpdates;
private System.Windows.Forms.ComboBox cmbMode; private System.Windows.Forms.ComboBox cmbMode;
private System.Windows.Forms.ComboBox cmbBranch; private System.Windows.Forms.ComboBox cmbBranch;
private System.Windows.Forms.GroupBox BranchGroupBox; private System.Windows.Forms.Label label5;
} }
} }

View File

@ -38,10 +38,7 @@ namespace Giants.Launcher
this.config.TryGetBool(ConfigSections.Update, ConfigKeys.EnableBranchSelection, defaultValue: false, out bool enableBranchSelection); this.config.TryGetBool(ConfigSections.Update, ConfigKeys.EnableBranchSelection, defaultValue: false, out bool enableBranchSelection);
this.enableBranchSelection = enableBranchSelection; this.enableBranchSelection = enableBranchSelection;
}
private async void OptionsForm_Load(object sender, EventArgs e)
{
// Must come first as other options depend on it // Must come first as other options depend on it
this.PopulateRenderers(); this.PopulateRenderers();
this.SetRenderer(); this.SetRenderer();
@ -50,11 +47,14 @@ namespace Giants.Launcher
this.PopulateAnisotropy(); this.PopulateAnisotropy();
this.PopulateAntialiasing(); this.PopulateAntialiasing();
await this.PopulateBranches();
this.SetOptions(); this.SetOptions();
} }
private async void OptionsForm_Load(object sender, EventArgs e)
{
await this.PopulateBranches();
}
private async Task PopulateBranches() private async Task PopulateBranches()
{ {
if (this.enableBranchSelection) if (this.enableBranchSelection)
@ -66,8 +66,6 @@ namespace Giants.Launcher
cmbBranch.Items.AddRange(branches.ToArray()); cmbBranch.Items.AddRange(branches.ToArray());
cmbBranch.SelectedItem = this.currentBranchName; cmbBranch.SelectedItem = this.currentBranchName;
BranchGroupBox.Visible = true;
cmbBranch.Visible = true; cmbBranch.Visible = true;
} }
catch (Exception e) catch (Exception e)
@ -100,13 +98,15 @@ namespace Giants.Launcher
} }
else else
{ {
renderer = GameSettings.CompatibleRenderers.Find(r => r.FileName == "gg_dx7r.dll"); renderer = GameSettings.CompatibleRenderers.Find(r => r.FileName == "gg_dx9r.dll");
this.cmbRenderer.SelectedItem = renderer; this.cmbRenderer.SelectedItem = renderer;
} }
} }
private void SetOptions() private void SetOptions()
{ {
SetRenderer();
var resolutions = (List<ScreenResolution>)this.cmbResolution.DataSource; var resolutions = (List<ScreenResolution>)this.cmbResolution.DataSource;
this.cmbResolution.SelectedItem = resolutions.Find(r => r.Width == GameSettings.Get<int>(RegistryKeys.VideoWidth) && r.Height == GameSettings.Get<int>(RegistryKeys.VideoHeight)); this.cmbResolution.SelectedItem = resolutions.Find(r => r.Width == GameSettings.Get<int>(RegistryKeys.VideoWidth) && r.Height == GameSettings.Get<int>(RegistryKeys.VideoHeight));
if (this.cmbResolution.SelectedItem == null) if (this.cmbResolution.SelectedItem == null)
@ -117,6 +117,11 @@ namespace Giants.Launcher
if (this.cmbAntialiasing.SelectedItem == null) if (this.cmbAntialiasing.SelectedItem == null)
this.cmbAntialiasing.SelectedIndex = 0; this.cmbAntialiasing.SelectedIndex = 0;
var anisotropyOptions = (List<KeyValuePair<string, int>>)this.cmbAnisotropy.DataSource;
this.cmbAnisotropy.SelectedItem = anisotropyOptions.Find(o => o.Value == GameSettings.Get<int>(RegistryKeys.AnisotropicFiltering));
if (this.cmbAnisotropy.SelectedItem == null)
this.cmbAnisotropy.SelectedIndex = 0;
this.chkUpdates.Checked = GameSettings.Get<int>(RegistryKeys.NoAutoUpdate) != 1; this.chkUpdates.Checked = GameSettings.Get<int>(RegistryKeys.NoAutoUpdate) != 1;
if (this.enableBranchSelection) if (this.enableBranchSelection)
@ -191,6 +196,23 @@ namespace Giants.Launcher
anisotropyOptions.Add(new KeyValuePair<string,int>(string.Format(Resources.OptionSamples, i), i)); anisotropyOptions.Add(new KeyValuePair<string,int>(string.Format(Resources.OptionSamples, i), i));
} }
} }
// Try to keep current selection when repopulating
int? currentValue = null;
if (this.cmbAnisotropy.SelectedValue != null)
{
currentValue = (int)this.cmbAnisotropy.SelectedValue;
}
this.cmbAnisotropy.DataSource = anisotropyOptions;
this.cmbAnisotropy.DisplayMember = "Key";
this.cmbAnisotropy.ValueMember = "Value";
if (currentValue != null)
this.cmbAnisotropy.SelectedValue = currentValue;
if (this.cmbAnisotropy.SelectedValue == null)
this.cmbAnisotropy.SelectedIndex = 0;
} }
private void PopulateResolution() private void PopulateResolution()
@ -215,17 +237,7 @@ namespace Giants.Launcher
private void cmbRenderer_SelectedIndexChanged(object sender, EventArgs e) private void cmbRenderer_SelectedIndexChanged(object sender, EventArgs e)
{ {
bool windowed = GameSettings.Get<int>(RegistryKeys.Windowed) == 1; this.cmbMode.SelectedIndex = GameSettings.Get<int>(RegistryKeys.Windowed) == 1 ? 1 : 0;
if (windowed)
{
bool borderless = GameSettings.Get<int>(RegistryKeys.BorderlessWindow) == 1;
if (borderless)
this.cmbMode.SelectedIndex = 2;
else
this.cmbMode.SelectedIndex = 1;
}
else
this.cmbMode.SelectedIndex = 0;
var renderer = (RendererInfo)this.cmbRenderer.SelectedItem; var renderer = (RendererInfo)this.cmbRenderer.SelectedItem;
@ -271,10 +283,9 @@ namespace Giants.Launcher
} }
GameSettings.Modify(RegistryKeys.Antialiasing, this.cmbAntialiasing.SelectedValue); GameSettings.Modify(RegistryKeys.Antialiasing, this.cmbAntialiasing.SelectedValue);
bool windowed = (WindowType)this.cmbMode.SelectedIndex == WindowType.Windowed || (WindowType)this.cmbMode.SelectedIndex == WindowType.Borderless; GameSettings.Modify(RegistryKeys.AnisotropicFiltering, this.cmbAnisotropy.SelectedValue);
bool windowed = (WindowType)this.cmbMode.SelectedIndex == WindowType.Windowed;
GameSettings.Modify(RegistryKeys.Windowed, windowed == true ? 1 : 0); GameSettings.Modify(RegistryKeys.Windowed, windowed == true ? 1 : 0);
bool borderless = (WindowType)this.cmbMode.SelectedIndex == WindowType.Borderless;
GameSettings.Modify(RegistryKeys.BorderlessWindow, borderless == true ? 1 : 0);
GameSettings.Modify(RegistryKeys.VerticalSync, this.chkVSync.Checked == true ? 1 : 0); GameSettings.Modify(RegistryKeys.VerticalSync, this.chkVSync.Checked == true ? 1 : 0);
GameSettings.Modify(RegistryKeys.TripleBuffering, this.chkTripleBuffering.Checked == true ? 1 : 0); GameSettings.Modify(RegistryKeys.TripleBuffering, this.chkTripleBuffering.Checked == true ? 1 : 0);
GameSettings.Modify(RegistryKeys.NoAutoUpdate, this.chkUpdates.Checked == false ? 1 : 0); GameSettings.Modify(RegistryKeys.NoAutoUpdate, this.chkUpdates.Checked == false ? 1 : 0);

View File

@ -43,16 +43,20 @@ namespace Giants.Launcher
public static void SetDefaults(string gamePath) public static void SetDefaults(string gamePath)
{ {
// Set default settings: // Set default settings:
Settings[RegistryKeys.Renderer] = "gg_dx7r.dll"; Settings[RegistryKeys.Renderer] = "gg_dx9r.dll";
Settings[RegistryKeys.Antialiasing] = 0; Settings[RegistryKeys.Antialiasing] = 0;
Settings[RegistryKeys.AnisotropicFiltering] = 0; Settings[RegistryKeys.AnisotropicFiltering] = 0;
Settings[RegistryKeys.VideoDepth] = 32; Settings[RegistryKeys.VideoDepth] = 32;
Settings[RegistryKeys.Windowed] = 0; Settings[RegistryKeys.Windowed] = 1;
Settings[RegistryKeys.BorderlessWindow] = 0; Settings[RegistryKeys.BorderlessWindow] = 1;
Settings[RegistryKeys.VerticalSync] = 1; Settings[RegistryKeys.VerticalSync] = 1;
Settings[RegistryKeys.TripleBuffering] = 1; Settings[RegistryKeys.TripleBuffering] = 1;
Settings[RegistryKeys.NoAutoUpdate] = 0; Settings[RegistryKeys.NoAutoUpdate] = 0;
// Set the current desktop resolution, leaving bit depth at the default 32:
Settings[RegistryKeys.VideoWidth] = Screen.PrimaryScreen.Bounds.Width;
Settings[RegistryKeys.VideoHeight] = Screen.PrimaryScreen.Bounds.Height;
// Get a list of renderers compatible with the user's system // Get a list of renderers compatible with the user's system
if (!CompatibleRenderers.Any()) if (!CompatibleRenderers.Any())
{ {
@ -64,18 +68,16 @@ namespace Giants.Launcher
caption: Resources.Error, caption: Resources.Error,
buttons: MessageBoxButtons.OK, buttons: MessageBoxButtons.OK,
icon: MessageBoxIcon.Error); icon: MessageBoxIcon.Error);
return;
} }
} }
// Select the highest priority renderer // Select the highest priority renderer
if (CompatibleRenderers.Any()) var bestRenderer = CompatibleRenderers.Max();
{ Settings[RegistryKeys.Renderer] = Path.GetFileName(bestRenderer.FilePath);
Settings[RegistryKeys.Renderer] = Path.GetFileName(CompatibleRenderers.Max().FilePath); Settings[RegistryKeys.AnisotropicFiltering] = bestRenderer.MaxAnisotropy;
} Settings[RegistryKeys.Antialiasing] = bestRenderer.MaxAntialiasing;
// Set the current desktop resolution, leaving bit depth at the default 32:
Settings[RegistryKeys.VideoWidth] = Screen.PrimaryScreen.Bounds.Width;
Settings[RegistryKeys.VideoHeight] = Screen.PrimaryScreen.Bounds.Height;
} }
public static void Load(string gamePath) public static void Load(string gamePath)
@ -93,7 +95,6 @@ namespace Giants.Launcher
Settings[RegistryKeys.VideoHeight] = RegistryExtensions.GetValue(RegistryKey, RegistryKeys.VideoHeight, Settings[RegistryKeys.VideoHeight], typeof(int)); Settings[RegistryKeys.VideoHeight] = RegistryExtensions.GetValue(RegistryKey, RegistryKeys.VideoHeight, Settings[RegistryKeys.VideoHeight], typeof(int));
Settings[RegistryKeys.VideoDepth] = RegistryExtensions.GetValue(RegistryKey, RegistryKeys.VideoDepth, Settings[RegistryKeys.VideoDepth], typeof(int)); Settings[RegistryKeys.VideoDepth] = RegistryExtensions.GetValue(RegistryKey, RegistryKeys.VideoDepth, Settings[RegistryKeys.VideoDepth], typeof(int));
Settings[RegistryKeys.Windowed] = RegistryExtensions.GetValue(RegistryKey, RegistryKeys.Windowed, Settings[RegistryKeys.Windowed], typeof(int)); Settings[RegistryKeys.Windowed] = RegistryExtensions.GetValue(RegistryKey, RegistryKeys.Windowed, Settings[RegistryKeys.Windowed], typeof(int));
Settings[RegistryKeys.BorderlessWindow] = RegistryExtensions.GetValue(RegistryKey, RegistryKeys.BorderlessWindow, Settings[RegistryKeys.BorderlessWindow], typeof(int));
Settings[RegistryKeys.VerticalSync] = RegistryExtensions.GetValue(RegistryKey, RegistryKeys.VerticalSync, Settings[RegistryKeys.VerticalSync], typeof(int)); Settings[RegistryKeys.VerticalSync] = RegistryExtensions.GetValue(RegistryKey, RegistryKeys.VerticalSync, Settings[RegistryKeys.VerticalSync], typeof(int));
Settings[RegistryKeys.TripleBuffering] = RegistryExtensions.GetValue(RegistryKey, RegistryKeys.TripleBuffering, Settings[RegistryKeys.TripleBuffering], typeof(int)); Settings[RegistryKeys.TripleBuffering] = RegistryExtensions.GetValue(RegistryKey, RegistryKeys.TripleBuffering, Settings[RegistryKeys.TripleBuffering], typeof(int));
Settings[RegistryKeys.NoAutoUpdate] = RegistryExtensions.GetValue(RegistryKey, RegistryKeys.NoAutoUpdate, Settings[RegistryKeys.NoAutoUpdate], typeof(int)); Settings[RegistryKeys.NoAutoUpdate] = RegistryExtensions.GetValue(RegistryKey, RegistryKeys.NoAutoUpdate, Settings[RegistryKeys.NoAutoUpdate], typeof(int));

View File

@ -118,6 +118,7 @@
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Forms\OptionsForm.resx"> <EmbeddedResource Include="Forms\OptionsForm.resx">
<DependentUpon>OptionsForm.cs</DependentUpon> <DependentUpon>OptionsForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>

View File

@ -29,6 +29,10 @@ namespace Giants.Launcher
/// <returns>True if the given renderer is supported by the system.</returns> /// <returns>True if the given renderer is supported by the system.</returns>
public static bool GetRendererCapabilities(string dllPath, ref GFXCapabilityInfo capabilities) public static bool GetRendererCapabilities(string dllPath, ref GFXCapabilityInfo capabilities)
{ {
string currentDirectory = Directory.GetCurrentDirectory();
Directory.SetCurrentDirectory(Path.GetDirectoryName(dllPath));
bool rendererSupported = false; bool rendererSupported = false;
IntPtr pDll = NativeMethods.LoadLibrary(dllPath); IntPtr pDll = NativeMethods.LoadLibrary(dllPath);
if (pDll == IntPtr.Zero) if (pDll == IntPtr.Zero)
@ -43,6 +47,8 @@ namespace Giants.Launcher
NativeMethods.FreeLibrary(pDll); NativeMethods.FreeLibrary(pDll);
Directory.SetCurrentDirectory(currentDirectory);
return rendererSupported; return rendererSupported;
} }

View File

@ -4,7 +4,6 @@
{ {
public const string Antialiasing = "Antialiasing"; public const string Antialiasing = "Antialiasing";
public const string AnisotropicFiltering = "AnisotropicFiltering"; public const string AnisotropicFiltering = "AnisotropicFiltering";
public const string BorderlessWindow = "BorderlessWindow";
public const string GameOptionsVersion = "GameOptionsVersion"; public const string GameOptionsVersion = "GameOptionsVersion";
public const string NoAutoUpdate = "NoAutoUpdate"; public const string NoAutoUpdate = "NoAutoUpdate";
public const string Renderer = "Renderer"; public const string Renderer = "Renderer";

View File

@ -30,6 +30,23 @@ namespace Giants.Launcher
this.Flags = (RendererFlag)gfxCaps.flags; this.Flags = (RendererFlag)gfxCaps.flags;
this.Priority = gfxCaps.priority; this.Priority = gfxCaps.priority;
this.Name = gfxCaps.rendererName; this.Name = gfxCaps.rendererName;
if (this.Flags.HasFlag(RendererFlag.MSAA16x))
{
this.MaxAntialiasing = 16;
}
else if (this.Flags.HasFlag(RendererFlag.MSAA8x))
{
this.MaxAntialiasing = 8;
}
else if (this.Flags.HasFlag(RendererFlag.MSAA4x))
{
this.MaxAntialiasing = 4;
}
else if (this.Flags.HasFlag(RendererFlag.MSAA2x))
{
this.MaxAntialiasing = 2;
}
} }
public override string ToString() public override string ToString()
@ -54,6 +71,7 @@ namespace Giants.Launcher
this.FilePath == info.FilePath && this.FilePath == info.FilePath &&
this.FileName == info.FileName && this.FileName == info.FileName &&
this.MaxAnisotropy == info.MaxAnisotropy && this.MaxAnisotropy == info.MaxAnisotropy &&
this.MaxAntialiasing == info.MaxAntialiasing &&
this.Flags == info.Flags && this.Flags == info.Flags &&
this.Priority == info.Priority && this.Priority == info.Priority &&
this.Name == info.Name; this.Name == info.Name;
@ -65,6 +83,7 @@ namespace Giants.Launcher
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(this.FilePath); hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(this.FilePath);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(this.FileName); hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(this.FileName);
hashCode = hashCode * -1521134295 + this.MaxAnisotropy.GetHashCode(); hashCode = hashCode * -1521134295 + this.MaxAnisotropy.GetHashCode();
hashCode = hashCode * -1521134295 + this.MaxAntialiasing.GetHashCode();
hashCode = hashCode * -1521134295 + this.Flags.GetHashCode(); hashCode = hashCode * -1521134295 + this.Flags.GetHashCode();
hashCode = hashCode * -1521134295 + this.Priority.GetHashCode(); hashCode = hashCode * -1521134295 + this.Priority.GetHashCode();
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(this.Name); hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(this.Name);
@ -74,6 +93,7 @@ namespace Giants.Launcher
public string FilePath { get; private set; } public string FilePath { get; private set; }
public string FileName { get; private set; } public string FileName { get; private set; }
public int MaxAnisotropy { get; private set; } public int MaxAnisotropy { get; private set; }
public int MaxAntialiasing { get; private set; }
public RendererFlag Flags { get; private set; } public RendererFlag Flags { get; private set; }
public int Priority { get; private set; } public int Priority { get; private set; }
public string Name { get; set; } public string Name { get; set; }

View File

@ -4,6 +4,5 @@
{ {
Fullscreen = 0, Fullscreen = 0,
Windowed = 1, Windowed = 1,
Borderless = 2,
} }
} }