Skip to content

Commit

Permalink
Additional changes to support multiple games (In theory can read Morr…
Browse files Browse the repository at this point in the history
…owind,Oblivion,Fallout3,FalloutNV,Skyrim)

Decode more of Oblivion file into record structure.
Add ElementGroup information in HTML renderer (basically for repeat areas show as array index)
  • Loading branch information
figment committed Apr 23, 2014
1 parent 1364740 commit 60b32d2
Show file tree
Hide file tree
Showing 19 changed files with 1,595 additions and 198 deletions.
2 changes: 1 addition & 1 deletion Application/Properties/Settings.Designer.cs

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

2 changes: 1 addition & 1 deletion Application/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<Value Profile="(Default)" />
</Setting>
<Setting Name="DefaultDomain" Type="System.String" Scope="User">
<Value Profile="(Default)" />
<Value Profile="(Default)">Skyrim</Value>
</Setting>
</Settings>
</SettingsFile>
28 changes: 28 additions & 0 deletions Application/UI/Forms/MainView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,41 @@ public MainView()
BaseRecord.ChildListChanged += PluginList_ChildListChanged;

htmlContent.OnLinkClicked += htmlContent_OnLinkClicked;
InitializeGameOptions();
LocalizeApp();
PyInterpreter.InitPyInterpreter();
HtmlRenderer.Initialize();
mruMenu = new MruStripMenu(recentFilelToolStripMenuItem, OnMruFile,
mruRegKey + "\\MRU", true, 16);
}

private void InitializeGameOptions()
{
string defaultDomain = Properties.Settings.Default.DefaultDomain ?? "Skyrim";
defaultGameSettingsToolStripMenuItem.DropDownItems.Clear();
foreach (var domain in TESVSnip.Domain.Data.DomainDefinition.AllDomains())
{
var item = new ToolStripMenuItem
{
Name = domain.Name,
Text = string.IsNullOrWhiteSpace(domain.DisplayName) ? domain.Name : domain.DisplayName,
Visible = true,
Enabled = true,
Tag = domain.Name,
Checked = defaultDomain == domain.Name,
};
defaultGameSettingsToolStripMenuItem.DropDownItems.Add(item);
}
defaultGameSettingsToolStripMenuItem.DropDownItemClicked +=
delegate(object sender, ToolStripItemClickedEventArgs e)
{
Properties.Settings.Default.DefaultDomain = e.ClickedItem.Tag.ToString();
foreach (var item in defaultGameSettingsToolStripMenuItem.DropDownItems.OfType<ToolStripMenuItem>())
item.Checked = Properties.Settings.Default.DefaultDomain == item.Tag.ToString();
Options.Value.Reconfigure();
};
}

public static object Clipboard
{
get { return GetClipboardData(); }
Expand Down
10 changes: 9 additions & 1 deletion Application/UI/Forms/MainView.designer.cs

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

19 changes: 17 additions & 2 deletions Application/UI/Forms/MainView.resx
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,15 @@
<data name="resetSettingsToDefaultsToolStripMenuItem.Text" xml:space="preserve">
<value>Reset settings to defaults</value>
</data>
<data name="defaultGameSettingsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>208, 22</value>
</data>
<data name="defaultGameSettingsToolStripMenuItem.Text" xml:space="preserve">
<value>Default Game Settings</value>
</data>
<data name="defaultGameSettingsToolStripMenuItem.ToolTipText" xml:space="preserve">
<value>When Game context is not known, this game will be used as defaults.</value>
</data>
<data name="optionsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>61, 20</value>
</data>
Expand Down Expand Up @@ -805,7 +814,7 @@
<value>155, 17</value>
</metadata>
<data name="OpenModDialog.Filter" xml:space="preserve">
<value>Skyrim (*.esm, *.esp)|*.esm;*.esp|Skyrim plugin (*.esp)|*.esp|Skyrim Master file (*.esm)|*.esm|All (*.*)|*.*</value>
<value>All Files (*.esm, *.esp)|*.esm;*.esp|Plugin file (*.esp)|*.esp|Master file (*.esm)|*.esm|All (*.*)|*.*</value>
</data>
<data name="OpenModDialog.Title" xml:space="preserve">
<value>Select plugin(s) to open</value>
Expand All @@ -814,7 +823,7 @@
<value>17, 17</value>
</metadata>
<data name="SaveModDialog.Filter" xml:space="preserve">
<value>Skyrim (*.esm, *.esp)|*.esm;*.esp|Skyrim plugin (*.esp)|*.esp|Skyrim Master file (*.esm)|*.esm|All (*.*)|*.*</value>
<value>All Files (*.esm, *.esp)|*.esm;*.esp|Plugin file (*.esp)|*.esp|Master file (*.esm)|*.esm|All (*.*)|*.*</value>
</data>
<data name="SaveModDialog.Title" xml:space="preserve">
<value>Select path to save to</value>
Expand Down Expand Up @@ -2228,6 +2237,12 @@
<data name="&gt;&gt;toolStripIncrInvalidRecStatus.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;defaultGameSettingsToolStripMenuItem.Name" xml:space="preserve">
<value>defaultGameSettingsToolStripMenuItem</value>
</data>
<data name="&gt;&gt;defaultGameSettingsToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>MainView</value>
</data>
Expand Down
21 changes: 17 additions & 4 deletions Application/UI/Services/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ private Options(string[] args)
{
this.SettingsDirectory = Environment.CurrentDirectory;
this.ApplicationDirectory = Environment.CurrentDirectory;
this.SetupGameDirectory();
this.SetupApplicationDirectory();
this.SetupScriptHostDirectory();
Reconfigure();
SetupApplicationDirectory();
this.ParseCommandLine(args);
this.PrepareDirectories();
}

/// <summary>
Expand Down Expand Up @@ -83,6 +83,12 @@ public static void Initialize(string[] args)
_instance = new Options(args);
}

public void Reconfigure()
{
this.SetupGameDirectory();
this.PrepareDirectories();
}

/// <summary>
/// Parse the command line <paramref name="args"/> array.
/// </summary>
Expand Down Expand Up @@ -198,12 +204,17 @@ private void SetupGameDirectory()
{
try
{
using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Bethesda Softworks\Skyrim"))
string defaultDomain = Properties.Settings.Default.DefaultDomain ?? "Skyrim";
var domain = TESVSnip.Domain.Data.DomainDefinition.Lookup(defaultDomain);
if (domain == null)
return;

using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\" + domain.RegistryKey))
{
//on 64bits
if (key == null)
{
using (var key2 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Bethesda Softworks\Skyrim"))
using (var key2 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\" + domain.RegistryKey))
{
//on 32bits
if (key2 == null) return;
Expand All @@ -217,6 +228,8 @@ private void SetupGameDirectory()
if (gameDirectory != null)
{
this.GameDataDirectory = Path.Combine(gameDirectory, "Data");
if ( !Directory.Exists(this.GameDataDirectory) )
this.GameDataDirectory = Path.Combine(gameDirectory, "Data files");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Application/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<value />
</setting>
<setting name="DefaultDomain" serializeAs="String">
<value />
<value>Skyrim</value>
</setting>
</TESVSnip.Properties.Settings>
</userSettings>
Expand Down
23 changes: 22 additions & 1 deletion Domain/Data/DomainDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public class DomainDefinition
public string[] AllESMRecords { get; private set; }
public string HEDRType { get; private set; }
public float HEDRVersion { get; private set; }
public int HEDROffset { get; private set; }
public int HEDRRecSize { get; private set; }
public int RecSize { get; private set; }

public Settings Settings { get; private set; }
public bool Loaded { get; private set; }
Expand All @@ -47,7 +50,7 @@ static DomainDefinition()
var iniFile = Path.Combine(Folders.SettingsDirectory, "Domains.ini");
foreach (var section in IniFile.GetSectionNames(iniFile))
{
var values = IniFile.GetPropertyValues(section);
var values = IniFile.GetPropertyValues(iniFile, section);
var define = new DomainDefinition(section);
define.DisplayName = GetValue(values, "Display", section);
define.Master = GetValue(values, "Master", section+".esm");
Expand All @@ -56,6 +59,9 @@ static DomainDefinition()
define.AllESMRecords = GetValue(values, "AllESMRecords", "").Split(';');
define.HEDRType = GetValue(values, "HEDRType", "TES4");
define.HEDRVersion = float.Parse(GetValue(values, "HEDRVersion", "1.0"));
define.HEDROffset = int.Parse(GetValue(values, "HEDROffset", "4"));
define.HEDRRecSize = int.Parse(GetValue(values, "HEDRRecSize", "2"));
define.RecSize = int.Parse(GetValue(values, "RecSize", "16"));
Domains[section] = define;
}
}
Expand All @@ -77,10 +83,23 @@ public DomainDefinition(string name)
}

public static IEnumerable<DomainDefinition> LoadedDomains()
{
return Domains.Values.Where(domain => domain.Loaded);
}

public static IEnumerable<DomainDefinition> AllDomains()
{
return Domains.Values;
}

public static DomainDefinition Lookup(string p)
{
DomainDefinition define;
if (Domains.TryGetValue(p, out define))
return define;
return null;
}

public static DomainDefinition Load(string p)
{
DomainDefinition define;
Expand Down Expand Up @@ -116,6 +135,8 @@ public static DomainDefinition DetectDefinitionFromVersion(string type, float ve
foreach (var domain in Domains.Values.Where(domain => type == domain.HEDRType
&& Math.Abs(version - domain.HEDRVersion) < EPSILON))
{
if (!domain.Loaded)
Load(domain.Name);
return domain;
}
throw new Exception("File is not a known TES4 file (Unexpected version)");
Expand Down
Loading

0 comments on commit 60b32d2

Please sign in to comment.