mirror of
https://github.com/ncblakely/GiantsTools
synced 2024-11-21 13:45:37 +01:00
Code cleanup, use constants for setting names in preparation for JSON settings. Move user-facing strings to resources.
This commit is contained in:
parent
582fe3e693
commit
9f1a059ab1
@ -10,21 +10,29 @@ namespace Giants.Launcher
|
||||
static class GameSettings
|
||||
{
|
||||
// Constants
|
||||
private const string REGISTRY_KEY = @"HKEY_CURRENT_USER\Software\PlanetMoon\Giants";
|
||||
private const int OPTIONS_VERSION = 3;
|
||||
private const string RegistryKey = @"HKEY_CURRENT_USER\Software\PlanetMoon\Giants";
|
||||
private const int OptionsVersion = 3;
|
||||
|
||||
private static readonly Dictionary<string, object> Settings = new Dictionary<string, object>();
|
||||
|
||||
// List of renderers compatible with the user's system.
|
||||
static public List<RendererInterop.Capabilities> CompatibleRenderers;
|
||||
public static List<RendererInterop.Capabilities> CompatibleRenderers;
|
||||
|
||||
public static T Get<T>(string settingName)
|
||||
{
|
||||
return (T)Get(settingName);
|
||||
}
|
||||
|
||||
public static object Get(string settingName)
|
||||
{
|
||||
if (Settings.ContainsKey(settingName))
|
||||
{
|
||||
return Settings[settingName];
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void Modify(string settingName, object settingValue)
|
||||
@ -35,17 +43,15 @@ namespace Giants.Launcher
|
||||
public static void SetDefaults(string gamePath)
|
||||
{
|
||||
// Set default settings:
|
||||
Settings["Renderer"] = "gg_dx7r.dll";
|
||||
Settings["Antialiasing"] = 0;
|
||||
Settings["AnisotropicFiltering"] = 0;
|
||||
Settings["VideoWidth"] = 640;
|
||||
Settings["VideoHeight"] = 480;
|
||||
Settings["VideoDepth"] = 32;
|
||||
Settings["Windowed"] = 0;
|
||||
Settings["BorderlessWindow"] = 0;
|
||||
Settings["VerticalSync"] = 1;
|
||||
Settings["TripleBuffering"] = 1;
|
||||
Settings["NoAutoUpdate"] = 0;
|
||||
Settings[SettingKeys.Renderer] = "gg_dx7r.dll";
|
||||
Settings[SettingKeys.Antialiasing] = 0;
|
||||
Settings[SettingKeys.AnisotropicFiltering] = 0;
|
||||
Settings[SettingKeys.VideoDepth] = 32;
|
||||
Settings[SettingKeys.Windowed] = 0;
|
||||
Settings[SettingKeys.BorderlessWindow] = 0;
|
||||
Settings[SettingKeys.VerticalSync] = 1;
|
||||
Settings[SettingKeys.TripleBuffering] = 1;
|
||||
Settings[SettingKeys.NoAutoUpdate] = 0;
|
||||
|
||||
// Get a list of renderers compatible with the user's system
|
||||
if (CompatibleRenderers == null)
|
||||
@ -54,44 +60,51 @@ namespace Giants.Launcher
|
||||
if (CompatibleRenderers.Count == 0)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Could not locate any renderers compatible with your system. " +
|
||||
"The most compatible renderer has been selected, but you may experience difficulty running the game.",
|
||||
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
text: Resources.ErrorNoRenderers,
|
||||
caption: Resources.Error,
|
||||
buttons: MessageBoxButtons.OK,
|
||||
icon: MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
// Select the highest priority renderer
|
||||
if (CompatibleRenderers.Count > 0)
|
||||
Settings["Renderer"] = Path.GetFileName(CompatibleRenderers.Max().FilePath);
|
||||
if (CompatibleRenderers.Any())
|
||||
{
|
||||
Settings[SettingKeys.Renderer] = Path.GetFileName(CompatibleRenderers.Max().FilePath);
|
||||
}
|
||||
|
||||
// Set the current desktop resolution, leaving bit depth at the default 32:
|
||||
Settings["VideoWidth"] = Screen.PrimaryScreen.Bounds.Width;
|
||||
Settings["VideoHeight"] = Screen.PrimaryScreen.Bounds.Height;
|
||||
Settings[SettingKeys.VideoWidth] = Screen.PrimaryScreen.Bounds.Width;
|
||||
Settings[SettingKeys.VideoHeight] = Screen.PrimaryScreen.Bounds.Height;
|
||||
}
|
||||
|
||||
public static void Load(string gamePath)
|
||||
{
|
||||
SetDefaults(gamePath);
|
||||
|
||||
if ((int)Registry.GetValue(REGISTRY_KEY, "GameOptionsVersion", 0) == OPTIONS_VERSION)
|
||||
if ((int)Registry.GetValue(RegistryKey, SettingKeys.GameOptionsVersion, 0) == OptionsVersion)
|
||||
{
|
||||
try
|
||||
{
|
||||
Settings["Renderer"] = RegistryExtensions.GetValue(REGISTRY_KEY, "Renderer", Settings["Renderer"], typeof(string));
|
||||
Settings["Antialiasing"] = RegistryExtensions.GetValue(REGISTRY_KEY, "Antialiasing", Settings["Antialiasing"], typeof(int));
|
||||
Settings["AnisotropicFiltering"] = RegistryExtensions.GetValue(REGISTRY_KEY, "AnisotropicFiltering", Settings["AnisotropicFiltering"], typeof(int));
|
||||
Settings["VideoWidth"] = RegistryExtensions.GetValue(REGISTRY_KEY, "VideoWidth", Settings["VideoWidth"], typeof(int));
|
||||
Settings["VideoHeight"] = RegistryExtensions.GetValue(REGISTRY_KEY, "VideoHeight", Settings["VideoHeight"], typeof(int));
|
||||
Settings["VideoDepth"] = RegistryExtensions.GetValue(REGISTRY_KEY, "VideoDepth", Settings["VideoDepth"], typeof(int));
|
||||
Settings["Windowed"] = RegistryExtensions.GetValue(REGISTRY_KEY, "Windowed", Settings["Windowed"], typeof(int));
|
||||
Settings["BorderlessWindow"] = RegistryExtensions.GetValue(REGISTRY_KEY, "BorderlessWindow", Settings["BorderlessWindow"], typeof(int));
|
||||
Settings["VerticalSync"] = RegistryExtensions.GetValue(REGISTRY_KEY, "VerticalSync", Settings["VerticalSync"], typeof(int));
|
||||
Settings["TripleBuffering"] = RegistryExtensions.GetValue(REGISTRY_KEY, "TripleBuffering", Settings["TripleBuffering"], typeof(int));
|
||||
Settings["NoAutoUpdate"] = RegistryExtensions.GetValue(REGISTRY_KEY, "NoAutoUpdate", Settings["NoAutoUpdate"], typeof(int));
|
||||
Settings[SettingKeys.Renderer] = RegistryExtensions.GetValue(RegistryKey, SettingKeys.Renderer, SettingKeys.Renderer, typeof(string));
|
||||
Settings[SettingKeys.Antialiasing] = RegistryExtensions.GetValue(RegistryKey, SettingKeys.Antialiasing, Settings[SettingKeys.Antialiasing], typeof(int));
|
||||
Settings[SettingKeys.AnisotropicFiltering] = RegistryExtensions.GetValue(RegistryKey, SettingKeys.AnisotropicFiltering, Settings[SettingKeys.AnisotropicFiltering], typeof(int));
|
||||
Settings[SettingKeys.VideoWidth] = RegistryExtensions.GetValue(RegistryKey, SettingKeys.VideoWidth, Settings[SettingKeys.VideoWidth], typeof(int));
|
||||
Settings[SettingKeys.VideoHeight] = RegistryExtensions.GetValue(RegistryKey, SettingKeys.VideoHeight, Settings[SettingKeys.VideoHeight], typeof(int));
|
||||
Settings[SettingKeys.VideoDepth] = RegistryExtensions.GetValue(RegistryKey, SettingKeys.VideoDepth, Settings[SettingKeys.VideoDepth], typeof(int));
|
||||
Settings[SettingKeys.Windowed] = RegistryExtensions.GetValue(RegistryKey, SettingKeys.Windowed, Settings[SettingKeys.Windowed], typeof(int));
|
||||
Settings[SettingKeys.BorderlessWindow] = RegistryExtensions.GetValue(RegistryKey, SettingKeys.BorderlessWindow, Settings[SettingKeys.BorderlessWindow], typeof(int));
|
||||
Settings[SettingKeys.VerticalSync] = RegistryExtensions.GetValue(RegistryKey, SettingKeys.VerticalSync, Settings[SettingKeys.VerticalSync], typeof(int));
|
||||
Settings[SettingKeys.TripleBuffering] = RegistryExtensions.GetValue(RegistryKey, SettingKeys.TripleBuffering, Settings[SettingKeys.TripleBuffering], typeof(int));
|
||||
Settings[SettingKeys.NoAutoUpdate] = RegistryExtensions.GetValue(RegistryKey, SettingKeys.NoAutoUpdate, Settings[SettingKeys.NoAutoUpdate], typeof(int));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(string.Format("Could not read game settings from registry!\n\nReason: {0}", ex.Message));
|
||||
MessageBox.Show(
|
||||
text: string.Format(Resources.ErrorSettingsLoad, ex.Message),
|
||||
caption: Resources.Error,
|
||||
buttons: MessageBoxButtons.OK,
|
||||
icon: MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -100,22 +113,26 @@ namespace Giants.Launcher
|
||||
{
|
||||
try
|
||||
{
|
||||
Registry.SetValue(REGISTRY_KEY, "GameOptionsVersion", 3, RegistryValueKind.DWord);
|
||||
Registry.SetValue(REGISTRY_KEY, "Renderer", Settings["Renderer"], RegistryValueKind.String);
|
||||
Registry.SetValue(REGISTRY_KEY, "Antialiasing", Settings["Antialiasing"], RegistryValueKind.DWord);
|
||||
Registry.SetValue(REGISTRY_KEY, "AnisotropicFiltering", Settings["AnisotropicFiltering"], RegistryValueKind.DWord);
|
||||
Registry.SetValue(REGISTRY_KEY, "VideoWidth", Settings["VideoWidth"], RegistryValueKind.DWord);
|
||||
Registry.SetValue(REGISTRY_KEY, "VideoHeight", Settings["VideoHeight"], RegistryValueKind.DWord);
|
||||
Registry.SetValue(REGISTRY_KEY, "VideoDepth", Settings["VideoDepth"], RegistryValueKind.DWord);
|
||||
Registry.SetValue(REGISTRY_KEY, "Windowed", Settings["Windowed"], RegistryValueKind.DWord);
|
||||
Registry.SetValue(REGISTRY_KEY, "BorderlessWindow", Settings["BorderlessWindow"], RegistryValueKind.DWord);
|
||||
Registry.SetValue(REGISTRY_KEY, "VerticalSync", Settings["VerticalSync"], RegistryValueKind.DWord);
|
||||
Registry.SetValue(REGISTRY_KEY, "TripleBuffering", Settings["TripleBuffering"], RegistryValueKind.DWord);
|
||||
Registry.SetValue(REGISTRY_KEY, "NoAutoUpdate", Settings["NoAutoUpdate"], RegistryValueKind.DWord);
|
||||
Registry.SetValue(RegistryKey, SettingKeys.GameOptionsVersion, OptionsVersion, RegistryValueKind.DWord);
|
||||
Registry.SetValue(RegistryKey, SettingKeys.Renderer, Settings[SettingKeys.Renderer], RegistryValueKind.String);
|
||||
Registry.SetValue(RegistryKey, SettingKeys.Antialiasing, Settings[SettingKeys.Antialiasing], RegistryValueKind.DWord);
|
||||
Registry.SetValue(RegistryKey, SettingKeys.AnisotropicFiltering, Settings[SettingKeys.AnisotropicFiltering], RegistryValueKind.DWord);
|
||||
Registry.SetValue(RegistryKey, SettingKeys.VideoWidth, Settings[SettingKeys.VideoWidth], RegistryValueKind.DWord);
|
||||
Registry.SetValue(RegistryKey, SettingKeys.VideoHeight, Settings[SettingKeys.VideoHeight], RegistryValueKind.DWord);
|
||||
Registry.SetValue(RegistryKey, SettingKeys.VideoDepth, Settings[SettingKeys.VideoDepth], RegistryValueKind.DWord);
|
||||
Registry.SetValue(RegistryKey, SettingKeys.Windowed, Settings[SettingKeys.Windowed], RegistryValueKind.DWord);
|
||||
Registry.SetValue(RegistryKey, SettingKeys.BorderlessWindow, Settings[SettingKeys.BorderlessWindow], RegistryValueKind.DWord);
|
||||
Registry.SetValue(RegistryKey, SettingKeys.VerticalSync, Settings[SettingKeys.VerticalSync], RegistryValueKind.DWord);
|
||||
Registry.SetValue(RegistryKey, SettingKeys.TripleBuffering, Settings[SettingKeys.TripleBuffering], RegistryValueKind.DWord);
|
||||
Registry.SetValue(RegistryKey, SettingKeys.NoAutoUpdate, Settings[SettingKeys.NoAutoUpdate], RegistryValueKind.DWord);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(string.Format("Could not save game settings to registry!\n\nReason: {0}", ex.Message));
|
||||
MessageBox.Show(
|
||||
text: string.Format(Resources.ErrorSettingsSave, ex.Message),
|
||||
caption: Resources.Error,
|
||||
buttons: MessageBoxButtons.OK,
|
||||
icon: MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ApplicationNames.cs" />
|
||||
<Compile Include="Native\Capabilities.cs" />
|
||||
<Compile Include="SettingKeys.cs" />
|
||||
<Compile Include="Updater\ApplicationType.cs" />
|
||||
<Compile Include="VersionHelper.cs" />
|
||||
<Compile Include="WindowType.cs" />
|
||||
|
@ -101,7 +101,7 @@ namespace Giants.Launcher
|
||||
// Read game settings from registry
|
||||
GameSettings.Load(this.gamePath);
|
||||
|
||||
if ((int)GameSettings.Get("NoAutoUpdate") == 0)
|
||||
if (GameSettings.Get<int>("NoAutoUpdate") == 0)
|
||||
{
|
||||
Version gameVersion = VersionHelper.GetGameVersion(this.gamePath);
|
||||
if (gameVersion == null)
|
||||
|
60
Giants.Launcher/Native/Capabilities.cs
Normal file
60
Giants.Launcher/Native/Capabilities.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Giants.Launcher
|
||||
{
|
||||
partial class RendererInterop
|
||||
{
|
||||
public class Capabilities : IComparable
|
||||
{
|
||||
[Flags]
|
||||
public enum RendererFlag
|
||||
{
|
||||
LowBitDepthAllowed = 0x1,
|
||||
|
||||
// Multisampling support flags:
|
||||
MSAA2x = 0x2,
|
||||
MSAA4x = 0x4,
|
||||
MSAA8x = 0x8,
|
||||
MSAA16x = 0x10,
|
||||
|
||||
// Other options:
|
||||
VSync = 0x20,
|
||||
TripleBuffer = 0x40,
|
||||
};
|
||||
|
||||
public Capabilities(string filePath, ref RendererInterop.GFXCapabilityInfo gfxCaps)
|
||||
{
|
||||
this.FilePath = filePath;
|
||||
this.FileName = Path.GetFileName(filePath);
|
||||
this.MaxAnisotropy = gfxCaps.maxAnisotropy;
|
||||
this.Flags = (RendererFlag)gfxCaps.flags;
|
||||
this.Priority = gfxCaps.priority;
|
||||
this.Name = gfxCaps.rendererName;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} ({1})", this.Name, Path.GetFileName(this.FilePath));
|
||||
}
|
||||
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
if (obj == null) return 1;
|
||||
|
||||
Capabilities other = obj as Capabilities;
|
||||
if (other != null)
|
||||
return this.Priority.CompareTo(other.Priority);
|
||||
else
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
public string FilePath { get; private set; }
|
||||
public string FileName { get; private set; }
|
||||
public int MaxAnisotropy { get; private set; }
|
||||
public RendererFlag Flags { get; private set; }
|
||||
public int Priority { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ using System.Windows.Forms;
|
||||
|
||||
namespace Giants.Launcher
|
||||
{
|
||||
class RendererInterop
|
||||
partial class RendererInterop
|
||||
{
|
||||
#pragma warning disable 649
|
||||
public struct GFXCapabilityInfo
|
||||
@ -48,9 +48,9 @@ namespace Giants.Launcher
|
||||
|
||||
public static List<Capabilities> GetCompatibleRenderers(string gamePath)
|
||||
{
|
||||
DirectoryInfo dir = new DirectoryInfo(Path.GetDirectoryName(gamePath));
|
||||
|
||||
List<Capabilities> Capabilities = new List<Capabilities>();
|
||||
var dir = new DirectoryInfo(
|
||||
Path.GetDirectoryName(gamePath));
|
||||
var capabilities = new List<Capabilities>();
|
||||
|
||||
// Search current directory for compatible renderers:
|
||||
foreach (FileInfo file in dir.GetFiles("gg_*.dll"))
|
||||
@ -58,82 +58,21 @@ namespace Giants.Launcher
|
||||
try
|
||||
{
|
||||
// Make interop call to native renderer DLLs to get capability info
|
||||
RendererInterop.GFXCapabilityInfo interopCaps = new RendererInterop.GFXCapabilityInfo();
|
||||
var interopCaps = new RendererInterop.GFXCapabilityInfo();
|
||||
string path = Path.Combine(file.DirectoryName, file.Name);
|
||||
if (RendererInterop.GetRendererCapabilities(path, ref interopCaps))
|
||||
if (GetRendererCapabilities(path, ref interopCaps))
|
||||
{
|
||||
|
||||
Capabilities caps = new Capabilities(path, ref interopCaps);
|
||||
Capabilities.Add(caps);
|
||||
//cmbRenderer.Items.Add(caps);
|
||||
capabilities.Add(caps);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show(ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
return Capabilities;
|
||||
|
||||
// Select highest priority renderer
|
||||
//cmbRenderer.SelectedItem = _RendererCaps.Max();
|
||||
}
|
||||
|
||||
public class Capabilities : IComparable
|
||||
{
|
||||
[Flags]
|
||||
public enum RendererFlag
|
||||
{
|
||||
LowBitDepthAllowed = 0x1,
|
||||
|
||||
// Multisampling support flags:
|
||||
MSAA2x = 0x2,
|
||||
MSAA4x = 0x4,
|
||||
MSAA8x = 0x8,
|
||||
MSAA16x = 0x10,
|
||||
|
||||
// Other options:
|
||||
VSync = 0x20,
|
||||
TripleBuffer = 0x40,
|
||||
|
||||
|
||||
};
|
||||
|
||||
public Capabilities(string filePath, ref RendererInterop.GFXCapabilityInfo gfxCaps)
|
||||
{
|
||||
this.FilePath = filePath;
|
||||
this.FileName = Path.GetFileName(filePath);
|
||||
this.MaxAnisotropy = gfxCaps.maxAnisotropy;
|
||||
this.Flags = (RendererFlag)gfxCaps.flags;
|
||||
this.Priority = gfxCaps.priority;
|
||||
this.Name = gfxCaps.rendererName;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} ({1})", this.Name, Path.GetFileName(this.FilePath));
|
||||
}
|
||||
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
if (obj == null) return 1;
|
||||
|
||||
Capabilities other = obj as Capabilities;
|
||||
if (other != null)
|
||||
return this.Priority.CompareTo(other.Priority);
|
||||
else
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
public string FilePath { get; private set; }
|
||||
public string FileName { get; private set; }
|
||||
public int MaxAnisotropy { get; private set; }
|
||||
public RendererFlag Flags { get; private set; }
|
||||
public int Priority { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
return capabilities;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,9 +28,13 @@ namespace Giants.Launcher
|
||||
this.cmbRenderer.Items.Clear();
|
||||
this.cmbRenderer.Items.AddRange(GameSettings.CompatibleRenderers.ToArray());
|
||||
|
||||
RendererInterop.Capabilities renderer = GameSettings.CompatibleRenderers.Find(r => StringComparer.OrdinalIgnoreCase.Compare(Path.GetFileName(r.FilePath), GameSettings.Get("Renderer")) == 0);
|
||||
RendererInterop.Capabilities renderer = GameSettings.CompatibleRenderers.Find(
|
||||
r => StringComparer.OrdinalIgnoreCase.Compare(Path.GetFileName(r.FilePath), GameSettings.Get<string>("Renderer")) == 0);
|
||||
|
||||
if (renderer != null)
|
||||
{
|
||||
this.cmbRenderer.SelectedItem = renderer;
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer = GameSettings.CompatibleRenderers.Find(r => r.Name == "DirectX 7");
|
||||
@ -57,21 +61,28 @@ namespace Giants.Launcher
|
||||
|
||||
private void PopulateAntialiasing()
|
||||
{
|
||||
List<KeyValuePair<string, int>> AntialiasingOptions = new List<KeyValuePair<string, int>>();
|
||||
|
||||
AntialiasingOptions.Add(new KeyValuePair<string, int>("None (Best performance)", 0));
|
||||
var antialiasingOptions = new List<KeyValuePair<string, int>>();
|
||||
antialiasingOptions.Add(new KeyValuePair<string, int>(Resources.OptionNone, 0));
|
||||
|
||||
var renderer = (RendererInterop.Capabilities)this.cmbRenderer.SelectedItem;
|
||||
if (renderer != null)
|
||||
{
|
||||
if ((renderer.Flags & RendererInterop.Capabilities.RendererFlag.MSAA2x) == RendererInterop.Capabilities.RendererFlag.MSAA2x)
|
||||
AntialiasingOptions.Add(new KeyValuePair<string, int>("2 Samples", 2));
|
||||
if ((renderer.Flags & RendererInterop.Capabilities.RendererFlag.MSAA4x) == RendererInterop.Capabilities.RendererFlag.MSAA4x)
|
||||
AntialiasingOptions.Add(new KeyValuePair<string, int>("4 Samples", 4));
|
||||
if ((renderer.Flags & RendererInterop.Capabilities.RendererFlag.MSAA8x) == RendererInterop.Capabilities.RendererFlag.MSAA8x)
|
||||
AntialiasingOptions.Add(new KeyValuePair<string, int>("8 Samples", 8));
|
||||
if ((renderer.Flags & RendererInterop.Capabilities.RendererFlag.MSAA16x) == RendererInterop.Capabilities.RendererFlag.MSAA16x)
|
||||
AntialiasingOptions.Add(new KeyValuePair<string, int>("16 Samples", 16));
|
||||
if (renderer.Flags.HasFlag(RendererInterop.Capabilities.RendererFlag.MSAA2x))
|
||||
{
|
||||
antialiasingOptions.Add(new KeyValuePair<string, int>(string.Format(Resources.OptionSamples, 2), 2));
|
||||
}
|
||||
if (renderer.Flags.HasFlag(RendererInterop.Capabilities.RendererFlag.MSAA4x))
|
||||
{
|
||||
antialiasingOptions.Add(new KeyValuePair<string, int>(string.Format(Resources.OptionSamples, 4), 4));
|
||||
}
|
||||
if (renderer.Flags.HasFlag(RendererInterop.Capabilities.RendererFlag.MSAA8x))
|
||||
{
|
||||
antialiasingOptions.Add(new KeyValuePair<string, int>(string.Format(Resources.OptionSamples, 8), 8));
|
||||
}
|
||||
if (renderer.Flags.HasFlag(RendererInterop.Capabilities.RendererFlag.MSAA16x))
|
||||
{
|
||||
antialiasingOptions.Add(new KeyValuePair<string, int>(string.Format(Resources.OptionSamples, 16), 16));
|
||||
}
|
||||
}
|
||||
|
||||
// Try to keep current selection when repopulating
|
||||
@ -81,7 +92,7 @@ namespace Giants.Launcher
|
||||
currentValue = (int)this.cmbAntialiasing.SelectedValue;
|
||||
}
|
||||
|
||||
this.cmbAntialiasing.DataSource = AntialiasingOptions;
|
||||
this.cmbAntialiasing.DataSource = antialiasingOptions;
|
||||
this.cmbAntialiasing.DisplayMember = "Key";
|
||||
this.cmbAntialiasing.ValueMember = "Value";
|
||||
|
||||
@ -101,7 +112,7 @@ namespace Giants.Launcher
|
||||
{
|
||||
List<KeyValuePair<string, int>> AnisotropyOptions = new List<KeyValuePair<string, int>>();
|
||||
|
||||
AnisotropyOptions.Add(new KeyValuePair<string, int>("None (Best performance)", 0));
|
||||
AnisotropyOptions.Add(new KeyValuePair<string, int>(Resources.OptionNone, 0));
|
||||
|
||||
var renderer = (RendererInterop.Capabilities)this.cmbRenderer.SelectedItem;
|
||||
if (renderer != null)
|
||||
@ -110,7 +121,7 @@ namespace Giants.Launcher
|
||||
{
|
||||
if (!this.IsPowerOfTwo(i)) continue;
|
||||
|
||||
AnisotropyOptions.Add(new KeyValuePair<string,int>(String.Format("{0} Samples", i), i));
|
||||
AnisotropyOptions.Add(new KeyValuePair<string,int>(string.Format(Resources.OptionSamples, i), i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,18 +37,26 @@ namespace Giants.Launcher
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
|
||||
Form form;
|
||||
try
|
||||
{
|
||||
Application.Run(new LauncherForm());
|
||||
form = new LauncherForm();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(
|
||||
text: $"Unable to start launcher: {ex.Message}",
|
||||
caption: "Fatal Error",
|
||||
text: string.Format(Resources.LauncherFatalError, ex.Message),
|
||||
caption: Resources.Error,
|
||||
buttons: MessageBoxButtons.OK,
|
||||
icon: MessageBoxIcon.Error);
|
||||
|
||||
Application.Exit();
|
||||
return;
|
||||
}
|
||||
|
||||
Application.Run(form);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
63
Giants.Launcher/Properties/Resources.Designer.cs
generated
63
Giants.Launcher/Properties/Resources.Designer.cs
generated
@ -88,6 +88,42 @@ namespace Giants.Launcher {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Error.
|
||||
/// </summary>
|
||||
internal static string Error {
|
||||
get {
|
||||
return ResourceManager.GetString("Error", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Could not locate any renderers compatible with your system. The most compatible renderer has been selected, but you may experience difficulty running the game..
|
||||
/// </summary>
|
||||
internal static string ErrorNoRenderers {
|
||||
get {
|
||||
return ResourceManager.GetString("ErrorNoRenderers", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Could not read game settings!\n\nReason: {0}.
|
||||
/// </summary>
|
||||
internal static string ErrorSettingsLoad {
|
||||
get {
|
||||
return ResourceManager.GetString("ErrorSettingsLoad", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Could not save game settings!\n\nReason: {0}.
|
||||
/// </summary>
|
||||
internal static string ErrorSettingsSave {
|
||||
get {
|
||||
return ResourceManager.GetString("ErrorSettingsSave", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
@ -136,6 +172,15 @@ namespace Giants.Launcher {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Unable to start launcher: {0}.
|
||||
/// </summary>
|
||||
internal static string LauncherFatalError {
|
||||
get {
|
||||
return ResourceManager.GetString("LauncherFatalError", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream.
|
||||
/// </summary>
|
||||
@ -154,6 +199,15 @@ namespace Giants.Launcher {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to None (Best performance).
|
||||
/// </summary>
|
||||
internal static string OptionNone {
|
||||
get {
|
||||
return ResourceManager.GetString("OptionNone", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
@ -164,6 +218,15 @@ namespace Giants.Launcher {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0} Samples.
|
||||
/// </summary>
|
||||
internal static string OptionSamples {
|
||||
get {
|
||||
return ResourceManager.GetString("OptionSamples", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
@ -112,12 +112,12 @@
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="backdrop" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\backdrop.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
@ -178,4 +178,25 @@
|
||||
<data name="DownloadProgress" xml:space="preserve">
|
||||
<value>Downloading - {0}% of {1} MB</value>
|
||||
</data>
|
||||
<data name="Error" xml:space="preserve">
|
||||
<value>Error</value>
|
||||
</data>
|
||||
<data name="ErrorNoRenderers" xml:space="preserve">
|
||||
<value>Could not locate any renderers compatible with your system. The most compatible renderer has been selected, but you may experience difficulty running the game.</value>
|
||||
</data>
|
||||
<data name="ErrorSettingsLoad" xml:space="preserve">
|
||||
<value>Could not read game settings!\n\nReason: {0}</value>
|
||||
</data>
|
||||
<data name="ErrorSettingsSave" xml:space="preserve">
|
||||
<value>Could not save game settings!\n\nReason: {0}</value>
|
||||
</data>
|
||||
<data name="LauncherFatalError" xml:space="preserve">
|
||||
<value>Unable to start launcher: {0}</value>
|
||||
</data>
|
||||
<data name="OptionNone" xml:space="preserve">
|
||||
<value>None (Best performance)</value>
|
||||
</data>
|
||||
<data name="OptionSamples" xml:space="preserve">
|
||||
<value>{0} Samples</value>
|
||||
</data>
|
||||
</root>
|
18
Giants.Launcher/SettingKeys.cs
Normal file
18
Giants.Launcher/SettingKeys.cs
Normal file
@ -0,0 +1,18 @@
|
||||
namespace Giants.Launcher
|
||||
{
|
||||
public class SettingKeys
|
||||
{
|
||||
public const string Antialiasing = "Antialiasing";
|
||||
public const string AnisotropicFiltering = "AnisotropicFiltering";
|
||||
public const string BorderlessWindow = "BorderlessWindow";
|
||||
public const string GameOptionsVersion = "GameOptionsVersion";
|
||||
public const string NoAutoUpdate = "NoAutoUpdate";
|
||||
public const string Renderer = "Renderer";
|
||||
public const string TripleBuffering = "TripleBuffering";
|
||||
public const string VerticalSync = "VerticalSync";
|
||||
public const string VideoWidth = "VideoWidth";
|
||||
public const string VideoHeight = "VideoHeight";
|
||||
public const string VideoDepth = "VideoDepth";
|
||||
public const string Windowed = "Windowed";
|
||||
}
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Giants.Launcher
|
||||
namespace Giants.Launcher
|
||||
{
|
||||
public class UpdateInfo
|
||||
{
|
||||
public int FileSize { get; set; }
|
||||
|
||||
public string FilePath { get; set; }
|
||||
|
||||
public ApplicationType ApplicationType { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Giants.Launcher
|
||||
namespace Giants.Launcher
|
||||
{
|
||||
public enum WindowType
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user