Skip to content

Commit 07a8075

Browse files
committed
add settings view and open in editor
1 parent 2d793aa commit 07a8075

File tree

8 files changed

+360
-18
lines changed

8 files changed

+360
-18
lines changed

BlueprintExplorer/BubblePrints.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Drawing.Design;
35
using System.IO;
46
using System.Linq;
57
using System.Reflection;
68
using System.Text;
79
using System.Threading.Tasks;
810
using System.Windows.Forms;
11+
using System.Windows.Forms.Design;
912

1013
namespace BlueprintExplorer
1114
{
@@ -72,4 +75,47 @@ internal static void SetWrathPath()
7275
StoredWrathPath = path;
7376
}
7477
}
78+
79+
public class SettingsProxy
80+
{
81+
public void Sync()
82+
{
83+
var settings = Properties.Settings.Default;
84+
foreach (var p in GetType().GetProperties())
85+
{
86+
string prop = p.Name;
87+
settings.GetType().GetProperty(prop).SetValue(settings, p.GetValue(this));
88+
}
89+
}
90+
91+
public SettingsProxy()
92+
{
93+
var settings = Properties.Settings.Default;
94+
foreach (var p in GetType().GetProperties())
95+
{
96+
string prop = p.Name;
97+
p.SetValue(this, settings.GetType().GetProperty(prop).GetValue(settings));
98+
}
99+
}
100+
101+
[Description("Full path to your preferred text editor for viewing raw blueprints")]
102+
[DisplayName("External Editor")]
103+
[Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
104+
public string Editor { get; set; }
105+
106+
[Description("Full path to the blueprints.binz file, only edit this if you're sure what you're doing")]
107+
[DisplayName("Blueprints DB")]
108+
[Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
109+
public string BlueprintDBPath { get; set; }
110+
111+
[Description("Full path to your Wrath folder (i.e. the folder containing Wrath.exe")]
112+
[DisplayName("Wrath Install Folder")]
113+
[Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
114+
public string WrathPath { get; set; }
115+
116+
[Description("If set, clicking on a blueprint in the search results will automatically open it in the external editor")]
117+
[DisplayName("Always Open Externally")]
118+
public bool AlwaysOpenInEditor { get; set; }
119+
120+
}
75121
}

BlueprintExplorer/Form1.Designer.cs

Lines changed: 65 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BlueprintExplorer/Form1.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public Form1() {
3737
resultsGrid.RowHeadersVisible = false;
3838
bpProps.DisabledItemForeColor = Color.Black;
3939

40+
settingsButton.Click += (sender, evt) =>
41+
{
42+
new SettingsView().ShowDialog();
43+
};
44+
4045
//bpProps.Categor
4146

4247
bpProps.PropertySort = PropertySort.NoSort;
@@ -66,7 +71,7 @@ public Form1() {
6671
string fileToOpen = Path.Combine(userLocalFolder, CurrentView.Name + "_" + CurrentView.GuidText + ".json");
6772
if (!File.Exists(fileToOpen))
6873
File.WriteAllText(fileToOpen, CurrentView.Raw);
69-
Process.Start(@"C:\Program Files (x86)\Vim\vim82\gvim.exe", fileToOpen);
74+
Process.Start(Properties.Settings.Default.Editor, fileToOpen);
7075
}
7176
};
7277

@@ -502,6 +507,9 @@ private void ShowBlueprint(BlueprintHandle bp, bool updateHistory) {
502507

503508
if (updateHistory)
504509
PushHistory(bp);
510+
511+
if (updateHistory && Properties.Settings.Default.AlwaysOpenInEditor)
512+
openInEditor.PerformClick();
505513
}
506514

507515
private List<BlueprintHandle> resultsCache = new();

BlueprintExplorer/Properties/Settings.Designer.cs

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BlueprintExplorer/Properties/Settings.settings

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,11 @@
88
<Setting Name="WrathPath" Type="System.String" Scope="User">
99
<Value Profile="(Default)" />
1010
</Setting>
11+
<Setting Name="Editor" Type="System.String" Scope="User">
12+
<Value Profile="(Default)" />
13+
</Setting>
14+
<Setting Name="AlwaysOpenInEditor" Type="System.Boolean" Scope="User">
15+
<Value Profile="(Default)">False</Value>
16+
</Setting>
1117
</Settings>
1218
</SettingsFile>

0 commit comments

Comments
 (0)