-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathLauncherConfiguration.xaml.cs
266 lines (249 loc) · 11.4 KB
/
LauncherConfiguration.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
/*
* Author: © voc0der
* Project: NWNLogRotator
* GitHub: https://github.com/voc0der/NWNLogRotator
* Date: 3/3/2021
* License: MIT
* Purpose: This program is designed used alongside the Neverwinter Nights game, either Enhanced Edition, or 1.69.
* This program does not come with a warranty. Any support may be found on the GitHub page.
*/
using NWNLogRotator.Classes;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace NWNLogRotator
{
public partial class LauncherConfiguration : Window
{
public Settings _settings;
public bool _closed = true;
public LauncherConfiguration(Settings __settings)
{
InitializeComponent();
SetupApplication(Settings_Set(__settings));
}
/*
* Setters and Getters
*/
public Settings Settings_Get()
{
CurrentSettings_Get();
return _settings;
}
public Settings Settings_Set(Settings __settings)
{
_settings = __settings;
return _settings;
}
public bool Closed_Get()
{
return _closed;
}
public void ActivateDarkTheme()
{
/*
* Black -> Purple -> Black
*/
LinearGradientBrush myBrush = new LinearGradientBrush();
myBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0));
myBrush.GradientStops.Add(new GradientStop(Colors.Purple, 0.5));
myBrush.GradientStops.Add(new GradientStop(Colors.Black, 1.0));
Grid.Background = myBrush;
/*
* Background
*/
PathToClientTextBox.Background = Brushes.Black;
ServerAddressTextBox.Background = Brushes.Black;
ServerPasswordTextBox.Background = Brushes.Black;
SaveSettingsButton.Background = Brushes.Black;
/*
* Foreground
*/
PathToClientLabel.Foreground = new SolidColorBrush(Colors.White);
PathToClientTextBox.Foreground = new SolidColorBrush(Colors.White);
RunClientOnLaunchCheckBox.Foreground = new SolidColorBrush(Colors.White);
CloseAfterGenerationCheckBox.Foreground = new SolidColorBrush(Colors.White);
ServerAddressLabel.Foreground = new SolidColorBrush(Colors.White);
ServerAddressTextBox.Foreground = new SolidColorBrush(Colors.White);
ServerPasswordLabel.Foreground = new SolidColorBrush(Colors.White);
ServerPasswordTextBox.Foreground = new SolidColorBrush(Colors.White);
DMCheckBox.Foreground = new SolidColorBrush(Colors.White);
SaveSettingsButton.Foreground = new SolidColorBrush(Colors.White);
}
public void ActivateLightTheme()
{
/*
* Lavender -> White -> Light Gray
*/
LinearGradientBrush myBrush = new LinearGradientBrush();
myBrush.GradientStops.Add(new GradientStop(Colors.Lavender, 0.0));
myBrush.GradientStops.Add(new GradientStop(Colors.White, 0.5));
myBrush.GradientStops.Add(new GradientStop(Colors.LightGray, 1.0));
Grid.Background = myBrush;
/*
* Background
*/
PathToClientTextBox.Background = Brushes.White;
ServerAddressTextBox.Background = Brushes.White;
ServerPasswordTextBox.Background = Brushes.White;
SaveSettingsButton.Background = Brushes.White;
/*
* Foreground
*/
PathToClientLabel.Foreground = new SolidColorBrush(Colors.Black);
PathToClientTextBox.Foreground = new SolidColorBrush(Colors.Black);
RunClientOnLaunchCheckBox.Foreground = new SolidColorBrush(Colors.Black);
CloseAfterGenerationCheckBox.Foreground = new SolidColorBrush(Colors.Black);
ServerAddressLabel.Foreground = new SolidColorBrush(Colors.Black);
ServerAddressTextBox.Foreground = new SolidColorBrush(Colors.Black);
ServerPasswordLabel.Foreground = new SolidColorBrush(Colors.Black);
ServerPasswordTextBox.Foreground = new SolidColorBrush(Colors.Black);
DMCheckBox.Foreground = new SolidColorBrush(Colors.Black);
SaveSettingsButton.Foreground = new SolidColorBrush(Colors.Black);
}
private void LoadSettings_Handler(Settings _settings)
{
PathToClientTextBox.Text = _settings.PathToClient;
RunClientOnLaunchCheckBox.IsChecked = _settings.RunClientOnLaunch;
CloseAfterGenerationCheckBox.IsChecked = _settings.CloseOnLogGenerated;
ServerAddressTextBox.Text = _settings.ServerAddress;
ServerPasswordTextBox.Text = _settings.ServerPassword;
DMCheckBox.IsChecked = _settings.DM;
}
private Settings CurrentSettings_Get()
{
string OutputDirectory = _settings.OutputDirectory;
string PathToLog = _settings.PathToLog;
int MinimumRowsToInteger = _settings.MinimumRowsCount;
string ServerName = _settings.ServerName;
string ServerNameColor = _settings.ServerNameColor;
bool EventText = _settings.EventText;
bool CombatText = _settings.CombatText;
string UseTheme = _settings.UseTheme;
bool Silent = _settings.Silent;
bool Tray = _settings.Tray;
bool SaveBackup = _settings.SaveBackup;
bool SaveBackupOnly = _settings.SaveBackupOnly;
bool SaveOnLaunch = _settings.SaveOnLaunch;
bool Notifications = _settings.Notifications;
string OOCColor = _settings.OOCColor;
string FilterLines = _settings.FilterLines;
string PathToClient = PathToClientTextBox.Text;
bool RunClientOnLaunch = RunClientOnLaunchCheckBox.IsChecked.GetValueOrDefault();
bool CloseOnLogGenerated = CloseAfterGenerationCheckBox.IsChecked.GetValueOrDefault();
string ServerAddress = ServerAddressTextBox.Text;
string ServerPassword = ServerPasswordTextBox.Text;
bool DM = DMCheckBox.IsChecked.GetValueOrDefault();
bool ServerMode = _settings.ServerMode;
string BackgroundColor = _settings.BackgroundColor;
string TimestampColor = _settings.TimestampColor;
string DefaultColor = _settings.DefaultColor;
string ActorColor = _settings.ActorColor;
string PartyColor = _settings.PartyColor;
string EmoteColor = _settings.EmoteColor;
string ShoutColor = _settings.ShoutColor;
string TellColor = _settings.TellColor;
string WhisperColor = _settings.WhisperColor;
string MyColor = _settings.MyColor;
string MyCharacters = _settings.MyCharacters;
string FontName = _settings.FontName;
string FontSize = _settings.FontSize;
string CustomEmoteOne = _settings.CustomEmoteOne;
string CustomEmoteOneColor = _settings.CustomEmoteOneColor;
string CustomEmoteTwo = _settings.CustomEmoteTwo;
string CustomEmoteTwoColor = _settings.CustomEmoteTwoColor;
string CustomEmoteThree = _settings.CustomEmoteThree;
string CustomEmoteThreeColor = _settings.CustomEmoteThreeColor;
_settings = new Settings(OutputDirectory,
PathToLog,
MinimumRowsToInteger,
ServerName,
ServerNameColor,
EventText,
CombatText,
UseTheme,
Silent,
Tray,
SaveBackup,
SaveBackupOnly,
SaveOnLaunch,
Notifications,
OOCColor,
FilterLines,
PathToClient,
RunClientOnLaunch,
CloseOnLogGenerated,
ServerAddress,
ServerPassword,
DM,
ServerMode,
BackgroundColor,
TimestampColor,
DefaultColor,
ActorColor,
PartyColor,
EmoteColor,
ShoutColor,
TellColor,
WhisperColor,
MyColor,
MyCharacters,
FontName,
FontSize,
CustomEmoteOne,
CustomEmoteOneColor,
CustomEmoteTwo,
CustomEmoteTwoColor,
CustomEmoteThree,
CustomEmoteThreeColor
);
return _settings;
}
/*
* Functions
*/
private void SetupApplication(Settings _settings)
{
if (_settings.UseTheme == "light")
{
ActivateLightTheme();
}
else if (_settings.UseTheme == "dark")
{
ActivateDarkTheme();
}
LoadSettings_Handler(_settings);
}
/*
* Button Callbacks
*/
private void Button_Click_Save_Settings(object sender, RoutedEventArgs e)
{
_settings = CurrentSettings_Get();
_closed = false;
this.Close();
}
private void PathToClient_MouseDown(object sender, MouseButtonEventArgs e)
{
var fileDialog = new System.Windows.Forms.OpenFileDialog();
fileDialog.InitialDirectory = _settings.PathToLog;
fileDialog.Filter = "exe file (*.exe)|*.exe";
fileDialog.FilterIndex = 1;
fileDialog.RestoreDirectory = true;
var result = fileDialog.ShowDialog();
switch (result)
{
case System.Windows.Forms.DialogResult.OK:
var file = fileDialog.FileName;
PathToClientTextBox.Text = file;
PathToClientTextBox.ToolTip = file;
break;
case System.Windows.Forms.DialogResult.Cancel:
break;
default:
break;
}
}
}
}