Skip to content

Commit d3a767d

Browse files
committed
Hotfix for different steamapps dir
1 parent b2deae3 commit d3a767d

31 files changed

+105
-49
lines changed

.vs/STARK/v14/.suo

13.5 KB
Binary file not shown.

STARK/CommandReader.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,22 @@ private void StartReadLoop() {
8989

9090
private void Setup(string path) {
9191
//makes a file if there is none
92-
if (!File.Exists(path)) File.CreateText(path).Close();
93-
var bufferedStream = new BufferedStream(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
94-
reader = new StreamReader(bufferedStream);
95-
//skips the lines that are in the file on load so we don't get historic commands
96-
reader.ReadToEnd();
92+
if (Directory.Exists(selectedGame.cfgDir)) {
93+
try {
94+
if (!File.Exists(path)) File.CreateText(path).Close();
95+
var bufferedStream = new BufferedStream(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
96+
reader = new StreamReader(bufferedStream);
97+
//skips the lines that are in the file on load so we don't get historic commands
98+
reader.ReadToEnd();
99+
}
100+
catch (IOException e) {
101+
102+
}
103+
} else {
104+
App.Current.Dispatcher.Invoke(delegate {
105+
(App.Current.MainWindow as MainWindow).setCmdReadertoNull();
106+
});
107+
}
97108
}
98109

99110
private bool ContainsCommand(string line, Command command) {

STARK/ConsoleUI.cs

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,21 @@ private void WriteToFiles() {
138138
}
139139

140140
public void DeleteFiles() {
141-
DeleteFile("s_help");
142-
DeleteFile("stark");
143-
DeleteFile("s_pause");
144-
DeleteFile("s_resume");
145-
DeleteFile("s_stop");
146-
DeleteFile("s_tracklist");
141+
if (Directory.Exists(game.cfgDir)) {
142+
DeleteFile("s_help");
143+
DeleteFile("stark");
144+
DeleteFile("s_pause");
145+
DeleteFile("s_resume");
146+
DeleteFile("s_stop");
147+
DeleteFile("s_tracklist");
147148

148-
if (tracks != null && tracks.Count > 0) {
149-
foreach (TrackListItem item in tracks) {
150-
DeleteFile(item.fileName);
149+
if (tracks != null && tracks.Count > 0) {
150+
foreach (TrackListItem item in tracks) {
151+
DeleteFile(item.fileName);
152+
}
151153
}
152154
}
155+
153156
}
154157

155158
private void DeleteFile(string fileName) {
@@ -165,20 +168,24 @@ private void DeleteFile(string fileName) {
165168
private void WriteToFile(string fileName, List<string> content) {
166169
string path = game.cfgDir + "\\" + fileName + ".cfg";
167170

168-
169-
if (!File.Exists(path)) {
170-
File.Create(path).Close();
171-
}
171+
try {
172+
if (!File.Exists(path)) {
173+
File.Create(path).Close();
174+
}
172175

173-
using (StreamWriter writer = new StreamWriter(File.Open(path, FileMode.Truncate, FileAccess.ReadWrite, FileShare.Delete))) {
174-
try {
175-
foreach (string line in content) {
176-
writer.WriteLine(line);
176+
using (StreamWriter writer = new StreamWriter(File.Open(path, FileMode.Truncate, FileAccess.ReadWrite, FileShare.Delete))) {
177+
try {
178+
foreach (string line in content) {
179+
writer.WriteLine(line);
180+
}
181+
} catch (IOException e) {
182+
177183
}
178-
} catch (IOException e) {
179-
MessageBox.Show(e.Message);
180-
}
181184

185+
}
186+
} catch (IOException e) {
187+
188+
mw.setConUItoNull();
182189
}
183190
}
184191

STARK/MainWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@
134134
<ComboBox x:Name="Setup_SynthesizerOnly" HorizontalAlignment="Left" Margin="10,80,0,0" VerticalAlignment="Top" Width="220" Height="25" SelectionChanged="Setup_SynthesizerOnly_SelectionChanged"/>
135135
<Label x:Name="Setup_SynthesizerOnlyLabel" Content="Loopback Output" HorizontalAlignment="Left" Margin="230,80,0,0" VerticalAlignment="Top"/>
136136
<TextBox x:Name="steamAppsFolderPath" HorizontalAlignment="Left" Height="23" Margin="10,111,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="220" UndoLimit="40" IsEnabled="False"/>
137-
<Label x:Name="Setup_steamAppsLabel" Content="SteamApps Folder (Looking - Open Steam)" HorizontalAlignment="Left" Margin="230,111,0,0" VerticalAlignment="Top"/>
138-
<Button x:Name="steamAppsFolderSelectButton" Content="..." HorizontalAlignment="Left" Margin="235,111,0,0" VerticalAlignment="Top" Width="30" Height="26" FontSize="14" Padding="5,4" Click="steamAppsFolderSelectButton_Click" IsHitTestVisible="False" IsEnabled="False" Visibility="Hidden"/>
137+
<Label x:Name="Setup_steamAppsLabel" Content="SteamApps Folder (Looking - Open Steam)" HorizontalAlignment="Left" Margin="270,110,0,0" VerticalAlignment="Top"/>
138+
<Button x:Name="steamAppsFolderSelectButton" Content="..." HorizontalAlignment="Left" Margin="235,111,0,0" VerticalAlignment="Top" Width="30" Height="26" FontSize="14" Padding="5,4" Click="steamAppsFolderSelectButton_Click" IsHitTestVisible="True"/>
139139

140140
<!--Game Selection-->
141141
<ComboBox x:Name="Setup_Game" DisplayMemberPath="name" HorizontalAlignment="Left" Margin="10,173,0,0" VerticalAlignment="Top" Width="220" Height="25" SelectionChanged="Setup_Game_SelectionChanged" />

STARK/MainWindow.xaml.cs

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ public partial class MainWindow : MetroWindow, IDisposable {
5555

5656
public MainWindow() {
5757
InitializeComponent();
58+
59+
//DEBUG CODE
60+
AppDomain currentDomain = AppDomain.CurrentDomain;
61+
currentDomain.UnhandledException += CurrentDomain_UnhandledException;
62+
63+
64+
//
5865
populateAccentComboBox();
5966
CommandManager.synthCmd.changeCommand(TTS_CommandTextBox.Text);
6067
mw = this;
@@ -91,6 +98,18 @@ public MainWindow() {
9198
loaded = true;
9299
}
93100

101+
//DEBUG
102+
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs args) {
103+
Exception e = (Exception)args.ExceptionObject;
104+
MessageBox.Show("Handler Caught: " + e.Message);
105+
MessageBox.Show("Stacktrace: " + e.StackTrace);
106+
if (e.InnerException != null) {
107+
MessageBox.Show("InnerException" + e.InnerException.Message);
108+
MessageBox.Show("IE ST: " + e.InnerException.StackTrace);
109+
}
110+
MessageBox.Show("Terminating: " + args.IsTerminating);
111+
}
112+
94113
private async void FindSteamApps() {
95114
if (string.IsNullOrWhiteSpace(PathManager.steamApps)) {
96115
//Finds all proccesses that have "Steam" in them
@@ -126,8 +145,10 @@ private async void FindSteamApps() {
126145
Setup_steamAppsLabel.Content = "SteamApps Folder (Found)";
127146

128147
//Init things that need the steamapps folder
129-
conUI = new ConsoleUI(game, ref afm, ref mw);
130-
cmdReader = new CommandReader(ref qss, ref ape, ref afm, game);
148+
if (!Directory.Exists(PathManager.steamApps + SourceGameManager.selectedGame.dir)) {
149+
conUI = new ConsoleUI(game, ref afm, ref mw);
150+
cmdReader = new CommandReader(ref qss, ref ape, ref afm, game);
151+
}
131152
}
132153
}
133154

@@ -610,21 +631,27 @@ private void Setup_SynthesizerOnly_SelectionChanged(object sender, SelectionChan
610631
}
611632

612633
private void steamAppsFolderSelectButton_Click(object sender, EventArgs e) {
613-
//var fbd = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog();
614-
////true if clicks OK, false otherwise
615-
//var result = fbd.ShowDialog();
634+
using (var fbd = new System.Windows.Forms.FolderBrowserDialog()) {
635+
fbd.ShowDialog();
636+
//true if clicks OK, false otherwise
637+
if (DialogResult ?? true) {
638+
if (!string.IsNullOrWhiteSpace(fbd.SelectedPath)) {
639+
PathManager.steamApps = fbd.SelectedPath;
640+
steamAppsFolderPath.Text = fbd.SelectedPath;
641+
642+
conUI = null;
643+
conUI = new ConsoleUI(SourceGameManager.selectedGame, ref afm, ref mw);
616644

617-
//if (result == true) {
618-
// if (!string.IsNullOrWhiteSpace(fbd.SelectedPath)) {
619-
// PathManager.steamApps = fbd.SelectedPath;
620-
// steamAppsFolderPath.Text = fbd.SelectedPath;
621-
// }
622-
//}
645+
cmdReader = null;
646+
cmdReader = new CommandReader(ref qss, ref ape, ref afm, SourceGameManager.selectedGame);
647+
}
648+
}
649+
}
623650
}
624651

625652
private void watchFolderSelectButton_Click(object sender, RoutedEventArgs e) {
626653
using (var fbd = new System.Windows.Forms.FolderBrowserDialog()) {
627-
var result = fbd.ShowDialog();
654+
fbd.ShowDialog();
628655

629656
if (DialogResult ?? true) {
630657
if (!string.IsNullOrWhiteSpace(fbd.SelectedPath)) {
@@ -692,5 +719,13 @@ protected virtual void Dispose(bool disposing) {
692719

693720
}
694721
#endregion
722+
723+
public void setConUItoNull() {
724+
conUI = null;
725+
}
726+
727+
public void setCmdReadertoNull() {
728+
cmdReader = null;
729+
}
695730
}
696731
}

STARK/bin/Debug/STARK.exe

558 KB
Binary file not shown.

STARK/bin/Debug/STARK.exe.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<value>0</value>
4545
</setting>
4646
<setting name="Interface_Theme_Accent" serializeAs="String">
47-
<value>4</value>
47+
<value>2</value>
4848
</setting>
4949
<setting name="Setup_SteamApps_Folder" serializeAs="String">
5050
<value />

STARK/bin/Debug/STARK.pdb

4 KB
Binary file not shown.

STARK/bin/Debug/STARK.vshost.exe.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<value>0</value>
4545
</setting>
4646
<setting name="Interface_Theme_Accent" serializeAs="String">
47-
<value>4</value>
47+
<value>2</value>
4848
</setting>
4949
<setting name="Setup_SteamApps_Folder" serializeAs="String">
5050
<value />

STARK/bin/Release/STARK.exe

1 KB
Binary file not shown.

STARK/bin/Release/STARK.pdb

2 KB
Binary file not shown.

STARK/obj/Debug/App.baml

-3 Bytes
Binary file not shown.

STARK/obj/Debug/App.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma checksum "..\..\App.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "7E711219D72DC81EFF758C66358C39F7"
1+
#pragma checksum "..\..\App.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "D853F960997B8B31F7B6E3483E5F1FA6"
22
//------------------------------------------------------------------------------
33
// <auto-generated>
44
// This code was generated by a tool.

STARK/obj/Debug/App.g.i.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma checksum "..\..\App.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "7E711219D72DC81EFF758C66358C39F7"
1+
#pragma checksum "..\..\App.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "D853F960997B8B31F7B6E3483E5F1FA6"
22
//------------------------------------------------------------------------------
33
// <auto-generated>
44
// This code was generated by a tool.

STARK/obj/Debug/MainWindow.baml

-158 Bytes
Binary file not shown.

STARK/obj/Debug/MainWindow.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "A0E54F4CDDBD8D025F2A4AE0EEC2C593"
1+
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "80C4F23595580142A1F9686E52107BE6"
22
//------------------------------------------------------------------------------
33
// <auto-generated>
44
// This code was generated by a tool.

STARK/obj/Debug/MainWindow.g.i.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "A0E54F4CDDBD8D025F2A4AE0EEC2C593"
1+
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "80C4F23595580142A1F9686E52107BE6"
22
//------------------------------------------------------------------------------
33
// <auto-generated>
44
// This code was generated by a tool.

STARK/obj/Debug/STARK.exe

558 KB
Binary file not shown.

STARK/obj/Debug/STARK.g.resources

459 KB
Binary file not shown.

STARK/obj/Debug/STARK.pdb

4 KB
Binary file not shown.
Binary file not shown.

STARK/obj/Release/MainWindow.baml

-20 Bytes
Binary file not shown.

STARK/obj/Release/MainWindow.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "E81FFA8E9152EFA619D156525E644200"
1+
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "80C4F23595580142A1F9686E52107BE6"
22
//------------------------------------------------------------------------------
33
// <auto-generated>
44
// This code was generated by a tool.

STARK/obj/Release/MainWindow.g.i.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "E81FFA8E9152EFA619D156525E644200"
1+
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "80C4F23595580142A1F9686E52107BE6"
22
//------------------------------------------------------------------------------
33
// <auto-generated>
44
// This code was generated by a tool.

STARK/obj/Release/STARK.csproj.FileListAbsolute.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,3 @@ F:\_Development\_Desktop\_Visual Studio\STARK\STARK\obj\Release\STARK.Properties
4848
F:\_Development\_Desktop\_Visual Studio\STARK\STARK\obj\Release\STARK.csproj.GenerateResource.Cache
4949
F:\_Development\_Desktop\_Visual Studio\STARK\STARK\obj\Release\STARK.exe
5050
F:\_Development\_Desktop\_Visual Studio\STARK\STARK\obj\Release\STARK.pdb
51-
F:\_Development\_Desktop\_Visual Studio\STARK\STARK\obj\Release\STARK.csprojResolveAssemblyReference.cache
Binary file not shown.

STARK/obj/Release/STARK.exe

1 KB
Binary file not shown.

STARK/obj/Release/STARK.g.resources

-20 Bytes
Binary file not shown.

STARK/obj/Release/STARK.pdb

2 KB
Binary file not shown.

STARK/obj/Release/STARK_MarkupCompile.i.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ F:\_Development\_Desktop\_Visual Studio\STARK\STARK\App.xaml
1616
18149226738
1717
MainWindow.xaml;Resources\Icons.xaml;Resources\IconsNonShared.xaml;
1818

19-
False
19+
True
2020

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+

2+
3+
FF:\_Development\_Desktop\_Visual Studio\STARK\STARK\MainWindow.xaml;;
4+

0 commit comments

Comments
 (0)