@@ -38,6 +38,7 @@ public partial class MainWindow : Window
38
38
private static string saveDirPath ;
39
39
private List < SaveBackup > listBackups ;
40
40
private Boolean suppressLog ;
41
+ private Color defaultTextColor ;
41
42
private FileSystemWatcher worldWatcher ;
42
43
private FileSystemWatcher charWatcher ;
43
44
@@ -120,11 +121,15 @@ public MainWindow()
120
121
{
121
122
InitializeComponent ( ) ;
122
123
suppressLog = false ;
123
- txtLog . Text = "Version " + typeof ( MainWindow ) . Assembly . GetName ( ) . Version ;
124
124
if ( Properties . Settings . Default . CreateLogFile )
125
125
{
126
- System . IO . File . WriteAllText ( "log.txt" , DateTime . Now . ToString ( ) + ": Version " + typeof ( MainWindow ) . Assembly . GetName ( ) . Version + " \r \n ") ;
126
+ System . IO . File . WriteAllText ( "log.txt" , " ") ;
127
127
}
128
+ defaultTextColor = ( ( SolidColorBrush ) txtLog . Foreground ) . Color ;
129
+ Debug . WriteLine ( defaultTextColor ) ;
130
+ txtLog . IsReadOnly = true ;
131
+ txtLog . Document . Blocks . Clear ( ) ;
132
+ logMessage ( $ "Version { typeof ( MainWindow ) . Assembly . GetName ( ) . Version } ") ;
128
133
logMessage ( "Loading..." ) ;
129
134
if ( Properties . Settings . Default . UpgradeRequired )
130
135
{
@@ -195,7 +200,8 @@ public MainWindow()
195
200
}
196
201
else
197
202
{
198
- logMessage ( $@ "Folder { saveDirPath } \characters does not exist. Please set the correct location of your save files.", LogType . Error ) ;
203
+ Directory . CreateDirectory ( $@ "{ saveDirPath } \characters") ;
204
+ //logMessage($@"Folder {saveDirPath}\characters does not exist. Please set the correct location of your save files.", LogType.Error);
199
205
}
200
206
201
207
// Watch for changes in LastWrite times.
@@ -338,19 +344,20 @@ private void loadBackups(Boolean verbose)
338
344
339
345
public void logMessage ( string msg )
340
346
{
341
- logMessage ( msg , Colors . White ) ;
347
+ logMessage ( msg , defaultTextColor ) ;
342
348
}
343
349
344
350
public void logMessage ( string msg , LogType lt )
345
351
{
346
- Color color = Colors . White ;
352
+ //Color color = Colors.White;
353
+ Color color = defaultTextColor ;
347
354
if ( lt == LogType . Success )
348
355
{
349
- color = Color . FromRgb ( 0 , 200 , 0 ) ;
356
+ color = Color . FromRgb ( 50 , 200 , 50 ) ;
350
357
}
351
358
else if ( lt == LogType . Error )
352
359
{
353
- color = Color . FromRgb ( 200 , 0 , 0 ) ;
360
+ color = Color . FromRgb ( 200 , 50 , 50 ) ;
354
361
}
355
362
logMessage ( msg , color ) ;
356
363
}
@@ -359,10 +366,15 @@ public void logMessage(string msg, Color color)
359
366
{
360
367
if ( ! suppressLog )
361
368
{
362
- txtLog . Text = txtLog . Text + Environment . NewLine + DateTime . Now . ToString ( ) + ": " + msg ;
369
+ //txtLog.Text = txtLog.Text + Environment.NewLine + DateTime.Now.ToString() + ": " + msg;
370
+ Run run = new Run ( DateTime . Now . ToString ( ) + ": " + msg ) ;
371
+ run . Foreground = new SolidColorBrush ( color ) ;
372
+ Paragraph paragraph = new Paragraph ( run ) ;
373
+ paragraph . Margin = new Thickness ( 0 ) ;
374
+ txtLog . Document . Blocks . Add ( paragraph ) ;
363
375
lblLastMessage . Content = msg ;
364
376
lblLastMessage . Foreground = new SolidColorBrush ( color ) ;
365
- if ( color . Equals ( Colors . White ) )
377
+ if ( color . Equals ( defaultTextColor ) )
366
378
{
367
379
lblLastMessage . FontWeight = FontWeights . Normal ;
368
380
}
@@ -386,6 +398,10 @@ private void BtnBackup_Click(object sender, RoutedEventArgs e)
386
398
{
387
399
doBackup ( save ) ;
388
400
}
401
+ if ( ! Directory . Exists ( $@ "{ saveDirPath } \characters") )
402
+ {
403
+ Directory . CreateDirectory ( $@ "{ saveDirPath } \characters") ;
404
+ }
389
405
string [ ] characters = Directory . GetFiles ( $@ "{ saveDirPath } \characters", "*.fch" ) ;
390
406
foreach ( string save in characters )
391
407
{
@@ -1103,12 +1119,16 @@ private void btnSaveFolder_Click(object sender, RoutedEventArgs e)
1103
1119
{
1104
1120
return ;
1105
1121
}
1106
- if ( ! Directory . Exists ( $@ "{ folderName } \worlds") || ! Directory . Exists ( $@ " { folderName } \characters" ) )
1122
+ if ( ! Directory . Exists ( $@ "{ folderName } \worlds") )
1107
1123
{
1108
1124
MessageBox . Show ( "Please select the folder where your Valheim save files are located. This folder should contain both a \" worlds\" and a \" characters\" folder.." ,
1109
1125
"Invalid Folder" , MessageBoxButton . OK , MessageBoxImage . Warning , MessageBoxResult . OK ) ;
1110
1126
return ;
1111
1127
}
1128
+ if ( ! Directory . Exists ( $@ "{ folderName } \characters") )
1129
+ {
1130
+ Directory . CreateDirectory ( $@ "{ folderName } \characters") ;
1131
+ }
1112
1132
txtSaveFolder . Text = folderName ;
1113
1133
saveDirPath = folderName ;
1114
1134
worldWatcher . Path = $@ "{ saveDirPath } \worlds";
0 commit comments