forked from genstein/trizbort
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettings.cs
926 lines (835 loc) · 33.4 KB
/
Settings.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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
/*
Copyright (c) 2010 by Genstein
This file is (or was originally) part of Trizbort, the Interactive Fiction Mapper.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Globalization;
using System.Text;
using System.IO;
using System.Xml;
namespace Trizbort
{
internal static class Settings
{
static Settings()
{
Reset();
ResetApplicationSettings();
LoadApplicationSettings();
}
static void ResetApplicationSettings()
{
s_dontCareAboutVersion = new Version(0, 0, 0, 0);
s_automap = AutomapSettings.Default;
s_infiniteScrollBounds = false;
s_showMinimap = true;
s_recentProjects.Clear();
// TODO: add other application settings here
}
static void LoadApplicationSettings()
{
try
{
if (File.Exists(ApplicationSettingsPath))
{
var doc = new XmlDocument();
doc.Load(ApplicationSettingsPath);
var root = new XmlElementReader(doc.DocumentElement);
if (root.Name == "settings")
{
var versionText = root["dontCareAboutVersion"].Text;
if (!string.IsNullOrEmpty(versionText))
{
s_dontCareAboutVersion = new Version(versionText);
}
s_infiniteScrollBounds = root["infiniteScrollBounds"].ToBool(s_infiniteScrollBounds);
s_showMinimap = root["showMiniMap"].ToBool(s_showMinimap);
s_lastProjectFileName = root["lastProjectFileName"].Text;
s_lastExportImageFileName = root["lastExportedImageFileName"].Text;
s_lastExportInform7FileName = root["lastExportedInform7FileName"].Text;
s_lastExportInform6FileName = root["lastExportedInform6FileName"].Text;
s_lastExportTadsFileName = root["lastExportedTadsFileName"].Text;
var recentProjects = root["recentProjects"];
var fileName = string.Empty;
var index = 0;
do
{
fileName = recentProjects[string.Format("fileName{0}", index++)].Text;
if (!string.IsNullOrEmpty(fileName))
{
s_recentProjects.Append(fileName);
}
} while (!string.IsNullOrEmpty(fileName));
var automap = root["automap"];
s_automap.FileName = automap["transcriptFileName"].ToText(s_automap.FileName);
s_automap.VerboseTranscript = automap["verboseTranscript"].ToBool(s_automap.VerboseTranscript);
s_automap.AssumeRoomsWithSameNameAreSameRoom = automap["assumeRoomsWithSameNameAreSameRoom"].ToBool(s_automap.AssumeRoomsWithSameNameAreSameRoom);
s_automap.GuessExits = automap["guessExits"].ToBool(s_automap.GuessExits);
s_automap.AddObjectCommand = automap["addObjectCommand"].ToText(s_automap.AddObjectCommand);
}
}
}
catch (Exception)
{
}
}
static string ApplicationSettingsPath
{
get
{
return Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Genstein"), "Trizbort"), "Settings.xml");
}
}
public static void SaveApplicationSettings()
{
try
{
Directory.CreateDirectory(Path.GetDirectoryName(ApplicationSettingsPath));
using (var scribe = XmlScribe.Create(ApplicationSettingsPath))
{
scribe.StartElement("settings");
scribe.Element("dontCareAboutVersion", s_dontCareAboutVersion.ToString());
scribe.Element("infiniteScrollBounds", s_infiniteScrollBounds);
scribe.Element("showMiniMap", s_showMinimap);
scribe.Element("lastProjectFileName", s_lastProjectFileName);
scribe.Element("lastExportedImageFileName", s_lastExportImageFileName);
scribe.Element("lastExportedInform7FileName", s_lastExportInform7FileName);
scribe.Element("lastExportedInform6FileName", s_lastExportInform6FileName);
scribe.Element("lastExportedTadsFileName", s_lastExportTadsFileName);
scribe.StartElement("recentProjects");
var index = 0;
foreach (var fileName in s_recentProjects)
{
scribe.Element(string.Format("fileName{0}", index++), fileName);
}
scribe.EndElement();
scribe.StartElement("automap");
scribe.Element("transcriptFileName", s_automap.FileName);
scribe.Element("verboseTranscript", s_automap.VerboseTranscript);
scribe.Element("assumeRoomsWithSameNameAreSameRoom", s_automap.AssumeRoomsWithSameNameAreSameRoom);
scribe.Element("guessExits", s_automap.GuessExits);
scribe.Element("addObjectCommand", s_automap.AddObjectCommand);
scribe.EndElement();
}
}
catch (Exception)
{
}
}
public static ColorSettings Color
{
get { return s_colorSettings; }
}
public static Font LargeFont
{
get { return s_largeFont; }
set
{
if (s_largeFont != value)
{
s_largeFont = value;
RaiseChanged();
}
}
}
public static Font SmallFont
{
get { return s_smallFont; }
set
{
if (s_smallFont != value)
{
s_smallFont = value;
RaiseChanged();
}
}
}
public static Font LineFont
{
get { return s_lineFont; }
set
{
if (s_lineFont != value)
{
s_lineFont = value;
RaiseChanged();
}
}
}
public static bool HandDrawn
{
get { return s_handDrawn; }
set
{
if (s_handDrawn != value)
{
s_handDrawn = value;
RaiseChanged();
}
}
}
public static bool HandDrawnUnchecked
{
get { return s_handDrawn; }
set { s_handDrawn = value; }
}
public static float LineWidth
{
get { return s_lineWidth; }
set
{
if (s_lineWidth != value)
{
s_lineWidth = value;
RaiseChanged();
}
}
}
public static bool SnapToGrid
{
get { return s_snapToGrid; }
set
{
if (s_snapToGrid != value)
{
s_snapToGrid = value;
RaiseChanged();
}
}
}
public static float GridSize
{
get { return s_gridSize; }
set
{
if (s_gridSize != value)
{
s_gridSize = value;
RaiseChanged();
}
}
}
public static bool IsGridVisible
{
get { return s_isGridVisible; }
set
{
if (s_isGridVisible != value)
{
s_isGridVisible = value;
RaiseChanged();
}
}
}
public static bool ShowOrigin
{
get { return s_showOrigin; }
set
{
if (s_showOrigin != value)
{
s_showOrigin = value;
RaiseChanged();
}
}
}
public static float DarknessStripeSize
{
get { return s_darknessStripeSize; }
set
{
if (s_darknessStripeSize != value)
{
s_darknessStripeSize = value;
RaiseChanged();
}
}
}
public static float ObjectListOffsetFromRoom
{
get { return s_objectListOffsetFromRoom; }
set
{
if (s_objectListOffsetFromRoom != value)
{
s_objectListOffsetFromRoom = value;
RaiseChanged();
}
}
}
public static float HandleSize
{
get { return s_handleSize; }
set
{
if (s_handleSize != value)
{
s_handleSize = value;
RaiseChanged();
}
}
}
public static float SnapToElementSize
{
get { return s_snapToElementSize; }
set
{
if (s_snapToElementSize != value)
{
s_snapToElementSize = value;
RaiseChanged();
}
}
}
public static float DragDistanceToInitiateNewConnection
{
get { return s_dragDistanceToInitiateNewConnection; }
set
{
if (s_dragDistanceToInitiateNewConnection != value)
{
s_dragDistanceToInitiateNewConnection = value;
RaiseChanged();
}
}
}
public static float ConnectionStalkLength
{
get { return s_connectionStalkLength; }
set
{
if (s_connectionStalkLength != value)
{
s_connectionStalkLength = value;
RaiseChanged();
}
}
}
public static float PreferredDistanceBetweenRooms
{
get { return s_preferredDistanceBetweenRooms; }
set
{
if (s_preferredDistanceBetweenRooms != value)
{
s_preferredDistanceBetweenRooms = value;
RaiseChanged();
}
}
}
public static float TextOffsetFromConnection
{
get { return s_textOffsetFromConnection; }
set
{
if (s_textOffsetFromConnection != value)
{
s_textOffsetFromConnection = value;
RaiseChanged();
}
}
}
public static float ConnectionArrowSize
{
get { return s_connectionArrowSize; }
set
{
if (s_connectionArrowSize != value)
{
s_connectionArrowSize = value;
RaiseChanged();
}
}
}
/// <summary>
/// Get/set the modifier keys required, along with a numeric keypad key,
/// to create new rooms from the currently selected room.
/// </summary>
public static Keys KeypadNavigationCreationModifier
{
get { return s_keypadNavigationCreationModifier; }
set
{
if (s_keypadNavigationCreationModifier != value)
{
s_keypadNavigationCreationModifier = value;
RaiseChanged();
}
}
}
/// <summary>
/// Get/set the modifier keys required, along with a numeric keypad key,
/// to mark "unexplored" connections from the currently selected room.
/// </summary>
public static Keys KeypadNavigationUnexploredModifier
{
get { return s_keypadNavigationUnexploredModifier; }
set
{
if (s_keypadNavigationUnexploredModifier != value)
{
s_keypadNavigationUnexploredModifier = value;
RaiseChanged();
}
}
}
public static float Snap(float value)
{
float offset = 0;
while (value < GridSize)
{
value += GridSize;
offset += GridSize;
}
var mod = value % GridSize;
if (SnapToGrid && mod != 0)
{
if (mod < GridSize / 2)
{
value -= mod;
}
else
{
value = value + GridSize - mod;
}
}
return value - offset;
}
public static Vector Snap(Vector pos)
{
if (SnapToGrid)
{
pos.X = Snap(pos.X);
pos.Y = Snap(pos.Y);
}
return pos;
}
public static event EventHandler Changed;
private static void RaiseChanged()
{
var changed = Changed;
if (changed != null)
{
changed(null, EventArgs.Empty);
}
}
public static void ShowDialog()
{
using (var dialog = new SettingsDialog())
{
for (int index = 0; index < Colors.Count; ++index)
{
dialog.Color[index] = Color[index];
}
dialog.Title = Project.Current.Title;
dialog.Author = Project.Current.Author;
dialog.Description = Project.Current.Description;
dialog.History = Project.Current.History;
dialog.LargeFont = LargeFont;
dialog.SmallFont = SmallFont;
dialog.LineFont = LineFont;
dialog.HandDrawn = HandDrawn;
dialog.LineWidth = LineWidth;
dialog.SnapToGrid = SnapToGrid;
dialog.GridSize = GridSize;
dialog.IsGridVisible = IsGridVisible;
dialog.ShowOrigin = ShowOrigin;
dialog.DarknessStripeSize = DarknessStripeSize;
dialog.ObjectListOffsetFromRoom = ObjectListOffsetFromRoom;
dialog.ConnectionStalkLength = ConnectionStalkLength;
dialog.PreferredDistanceBetweenRooms = PreferredDistanceBetweenRooms;
dialog.TextOffsetFromConnection = TextOffsetFromConnection;
dialog.HandleSize = HandleSize;
dialog.SnapToElementSize = SnapToElementSize;
dialog.ConnectionArrowSize = ConnectionArrowSize;
if (dialog.ShowDialog() == DialogResult.OK)
{
for (int index = 0; index < Colors.Count; ++index)
{
Color[index] = dialog.Color[index];
}
Project.Current.Title = dialog.Title;
Project.Current.Author = dialog.Author;
Project.Current.Description = dialog.Description;
Project.Current.History = dialog.History;
LargeFont = dialog.LargeFont;
SmallFont = dialog.SmallFont;
LineFont = dialog.LineFont;
HandDrawn = dialog.HandDrawn;
LineWidth = dialog.LineWidth;
SnapToGrid = dialog.SnapToGrid;
GridSize = dialog.GridSize;
IsGridVisible = dialog.IsGridVisible;
ShowOrigin = dialog.ShowOrigin;
DarknessStripeSize = dialog.DarknessStripeSize;
ObjectListOffsetFromRoom = dialog.ObjectListOffsetFromRoom;
ConnectionStalkLength = dialog.ConnectionStalkLength;
PreferredDistanceBetweenRooms = dialog.PreferredDistanceBetweenRooms;
TextOffsetFromConnection = dialog.TextOffsetFromConnection;
HandleSize = dialog.HandleSize;
SnapToElementSize = dialog.SnapToElementSize;
ConnectionArrowSize = dialog.ConnectionArrowSize;
}
}
}
public static void Reset()
{
Color[Colors.Canvas] = System.Drawing.Color.White;
Color[Colors.Fill] = System.Drawing.Color.White;
Color[Colors.Border] = System.Drawing.Color.MidnightBlue;
Color[Colors.Line] = System.Drawing.Color.MidnightBlue;
Color[Colors.HoverLine] = System.Drawing.Color.DarkOrange;
Color[Colors.SelectedLine] = System.Drawing.Color.SteelBlue;
Color[Colors.LargeText] = System.Drawing.Color.MidnightBlue;
Color[Colors.SmallText] = System.Drawing.Color.MidnightBlue;
Color[Colors.LineText] = System.Drawing.Color.MidnightBlue;
Color[Colors.Grid] = Drawing.Mix(System.Drawing.Color.White, System.Drawing.Color.Black, 25, 1);
LargeFont = new Font("Comic Sans MS", 13.0f, FontStyle.Regular, GraphicsUnit.World);
SmallFont = new Font("Comic Sans MS", 11.0f, FontStyle.Regular, GraphicsUnit.World);
LineFont = new Font("Comic Sans MS", 9.0f, FontStyle.Regular, GraphicsUnit.World);
LineWidth = 2.0f;
HandDrawn = true;
SnapToGrid = true;
IsGridVisible = true;
GridSize = 32.0f;
ShowOrigin = true;
DarknessStripeSize = 24.0f;
ObjectListOffsetFromRoom = 4.0f;
ConnectionStalkLength = 32.0f;
PreferredDistanceBetweenRooms = ConnectionStalkLength * 2;
TextOffsetFromConnection = 4.0f;
HandleSize = 12.0f;
SnapToElementSize = 16.0f;
DragDistanceToInitiateNewConnection = 32f;
ConnectionArrowSize = 12.0f;
KeypadNavigationCreationModifier = Keys.Control;
KeypadNavigationUnexploredModifier = Keys.Alt;
}
public static void Save(XmlScribe scribe)
{
// save colors
scribe.StartElement("colors");
for (int index = 0; index < Colors.Count; ++index)
{
string colorName;
if (Colors.ToName(index, out colorName))
{
scribe.Element(colorName, Color[index]);
}
}
scribe.EndElement();
// save fonts
scribe.StartElement("fonts");
SaveFont(scribe, s_largeFont, "room");
SaveFont(scribe, s_smallFont, "object");
SaveFont(scribe, s_lineFont, "line");
scribe.EndElement();
scribe.StartElement("grid");
scribe.Element("snapTo", s_snapToGrid);
scribe.Element("visible", s_isGridVisible);
scribe.Element("showOrigin", s_showOrigin);
scribe.Element("size", s_gridSize);
scribe.EndElement();
scribe.StartElement("lines");
scribe.Element("width", s_lineWidth);
scribe.Element("handDrawn", s_handDrawn);
scribe.Element("arrowSize", s_connectionArrowSize);
scribe.Element("textOffset", s_textOffsetFromConnection);
scribe.EndElement();
scribe.StartElement("rooms");
scribe.Element("darknessStripeSize", s_darknessStripeSize);
scribe.Element("objectListOffset", s_objectListOffsetFromRoom);
scribe.Element("connectionStalkLength", s_connectionStalkLength);
scribe.Element("preferredDistanceBetweenRooms", s_preferredDistanceBetweenRooms);
scribe.EndElement();
scribe.StartElement("ui");
scribe.Element("handleSize", s_handleSize);
scribe.Element("snapToElementSize", s_snapToElementSize);
scribe.EndElement();
scribe.StartElement("keypadNavigation");
scribe.Element("creationModifier", ModifierKeysToString(s_keypadNavigationCreationModifier));
scribe.Element("unexploredModifier", ModifierKeysToString(s_keypadNavigationUnexploredModifier));
scribe.EndElement();
SaveApplicationSettings();
}
private static string ModifierKeysToString(Keys key)
{
var builder = new StringBuilder();
if ((key & Keys.Shift) == Keys.Shift)
{
if (builder.Length != 0)
builder.Append("|");
builder.Append("shift");
}
if ((key & Keys.Control) == Keys.Control)
{
if (builder.Length != 0)
builder.Append("|");
builder.Append("control");
}
if ((key & Keys.Alt) == Keys.Alt)
{
if (builder.Length != 0)
builder.Append("|");
builder.Append("alt");
}
if (builder.Length == 0)
{
builder.Append("none");
}
return builder.ToString();
}
private static Keys StringToModifierKeys(string text, Keys defaultValue)
{
if (string.IsNullOrEmpty(text))
{
return defaultValue;
}
Keys value = Keys.None;
foreach (var part in text.Split('|'))
{
if (StringComparer.InvariantCultureIgnoreCase.Compare(part, "shift") == 0)
{
value |= Keys.Shift;
}
else if (StringComparer.InvariantCultureIgnoreCase.Compare(part, "control") == 0)
{
value |= Keys.Control;
}
else if (StringComparer.InvariantCultureIgnoreCase.Compare(part, "alt") == 0)
{
value |= Keys.Alt;
}
// Note that "none" is also an allowed value.
}
return value;
}
private static void SaveFont(XmlScribe scribe, Font font, string name)
{
scribe.StartElement(name);
scribe.Attribute("size", font.Size);
if ((font.Style & FontStyle.Bold) == FontStyle.Bold)
{
scribe.Attribute("bold", true);
}
if ((font.Style & FontStyle.Italic) == FontStyle.Italic)
{
scribe.Attribute("italic", true);
}
if ((font.Style & FontStyle.Underline) == FontStyle.Underline)
{
scribe.Attribute("underline", true);
}
if ((font.Style & FontStyle.Strikeout) == FontStyle.Strikeout)
{
scribe.Attribute("strikeout", true);
}
scribe.Value(Drawing.FontName(font));
scribe.EndElement();
}
public static void Load(XmlElementReader element)
{
var colors = element["colors"];
foreach (var color in colors.Children)
{
int index;
if (Colors.FromName(color.Name, out index))
{
Color[index] = color.ToColor(Color[index]);
}
}
var fonts = element["fonts"];
foreach (var font in fonts.Children)
{
var style = FontStyle.Regular;
if (font.Attribute("bold").ToBool())
{
style |= FontStyle.Bold;
}
if (font.Attribute("italic").ToBool())
{
style |= FontStyle.Italic;
}
if (font.Attribute("underline").ToBool())
{
style |= FontStyle.Underline;
}
if (font.Attribute("strikeout").ToBool())
{
style |= FontStyle.Strikeout;
}
if (font.Name == "room")
{
LargeFont = new Font(font.ToText(LargeFont.Name), Numeric.Clamp(font.Attribute("size").ToFloat(LargeFont.Size), MinFontSize, MaxFontSize), style, GraphicsUnit.World);
}
else if (font.Name == "object")
{
SmallFont = new Font(font.ToText(SmallFont.Name), Numeric.Clamp(font.Attribute("size").ToFloat(SmallFont.Size), MinFontSize, MaxFontSize), style, GraphicsUnit.World);
}
else if (font.Name == "line")
{
LineFont = new Font(font.ToText(SmallFont.Name), Numeric.Clamp(font.Attribute("size").ToFloat(LineFont.Size), MinFontSize, MaxFontSize), style, GraphicsUnit.World);
}
}
SnapToGrid = element["grid"]["snapTo"].ToBool(s_snapToGrid);
IsGridVisible = element["grid"]["visible"].ToBool(s_isGridVisible);
GridSize = element["grid"]["size"].ToFloat(s_gridSize);
ShowOrigin = element["grid"]["showOrigin"].ToBool(s_showOrigin);
LineWidth = element["lines"]["width"].ToFloat(s_lineWidth);
HandDrawn = element["lines"]["handDrawn"].ToBool(s_handDrawn);
ConnectionArrowSize = element["lines"]["arrowSize"].ToFloat(s_connectionArrowSize);
TextOffsetFromConnection = element["lines"]["textOffset"].ToFloat(s_textOffsetFromConnection);
DarknessStripeSize = element["rooms"]["darknessStripeSize"].ToFloat(s_darknessStripeSize);
ObjectListOffsetFromRoom = element["rooms"]["objectListOffset"].ToFloat(s_objectListOffsetFromRoom);
ConnectionStalkLength = element["rooms"]["connectionStalkLength"].ToFloat(s_connectionStalkLength);
PreferredDistanceBetweenRooms = element["rooms"]["preferredDistanceBetweenRooms"].ToFloat(s_connectionStalkLength * 2); // introduced in v1.2, hence default based on existing setting
HandleSize = element["ui"]["handleSize"].ToFloat(s_handleSize);
SnapToElementSize = element["ui"]["snapToElementSize"].ToFloat(s_snapToElementSize);
KeypadNavigationCreationModifier = StringToModifierKeys(element["keypadNavigation"]["creationModifier"].Text, s_keypadNavigationCreationModifier);
KeypadNavigationUnexploredModifier = StringToModifierKeys(element["keypadNavigation"]["unexploredModifier"].Text, s_keypadNavigationUnexploredModifier);
}
public class ColorSettings
{
public Color this[int index]
{
get { return Settings.s_color[index]; }
set
{
if (Settings.s_color[index] != value)
{
Settings.s_color[index] = value;
Settings.RaiseChanged();
}
}
}
}
public static bool DebugShowFPS
{
get;
set;
}
public static bool DebugDisableTextRendering
{
get;
set;
}
public static bool DebugDisableLineRendering
{
get;
set;
}
public static bool DebugDisableElementRendering
{
get;
set;
}
public static bool DebugDisableGridPolyline
{
get;
set;
}
public static Version DontCareAboutVersion
{
get { return s_dontCareAboutVersion; }
set { s_dontCareAboutVersion = value; }
}
public static AutomapSettings Automap
{
get { return s_automap; }
set { s_automap = value; }
}
public static bool InfiniteScrollBounds
{
get { return s_infiniteScrollBounds; }
set { s_infiniteScrollBounds = value; }
}
public static bool ShowMiniMap
{
get { return s_showMinimap; }
set { s_showMinimap = value; }
}
public static string LastProjectFileName
{
get { return s_lastProjectFileName; }
set { s_lastProjectFileName = value; }
}
public static string LastExportImageFileName
{
get { return s_lastExportImageFileName; }
set { s_lastExportImageFileName = value; }
}
public static string LastExportInform7FileName
{
get { return s_lastExportInform7FileName; }
set { s_lastExportInform7FileName = value; }
}
public static string LastExportInform6FileName
{
get { return s_lastExportInform6FileName; }
set { s_lastExportInform6FileName = value; }
}
public static string LastExportTadsFileName
{
get { return s_lastExportTadsFileName; }
set { s_lastExportTadsFileName = value; }
}
public static MruList RecentProjects
{
get { return s_recentProjects; }
}
private static readonly float MinFontSize = 2;
private static readonly float MaxFontSize = 256;
// per-map settings, saved with the map
private static Color[] s_color = new Color[Colors.Count];
private static ColorSettings s_colorSettings = new ColorSettings();
private static Font s_largeFont;
private static Font s_smallFont;
private static Font s_lineFont;
private static float s_lineWidth;
private static bool s_handDrawn;
private static bool s_snapToGrid;
private static bool s_isGridVisible;
private static bool s_showOrigin;
private static float s_gridSize;
private static float s_darknessStripeSize;
private static float s_objectListOffsetFromRoom;
private static float s_connectionStalkLength;
private static float s_preferredDistanceBetweenRooms;
private static float s_textOffsetFromConnection;
private static float s_handleSize;
private static float s_snapToElementSize;
private static float s_dragDistanceToInitiateNewConnection;
private static float s_connectionArrowSize;
private static Keys s_keypadNavigationCreationModifier;
private static Keys s_keypadNavigationUnexploredModifier;
// application settings, saved for the user
private static Version s_dontCareAboutVersion;
private static AutomapSettings s_automap;
private static bool s_infiniteScrollBounds;
private static bool s_showMinimap;
private static string s_lastProjectFileName;
private static string s_lastExportImageFileName;
private static string s_lastExportInform7FileName;
private static string s_lastExportInform6FileName;
private static string s_lastExportTadsFileName;
private static MruList s_recentProjects = new MruList();
}
}