22using Intersect . Client . Core . Controls ;
33using Intersect . Client . Entities . Events ;
44using Intersect . Client . Framework . Content ;
5+ using Intersect . Client . Framework . Database ;
56using Intersect . Client . Framework . File_Management ;
67using Intersect . Client . Framework . Gwen . Control ;
78using Intersect . Client . General ;
89using Intersect . Client . Interface . Game . Typewriting ;
910using Intersect . Client . Localization ;
11+ using Intersect . Client . MonoGame . Database ;
1012using Intersect . Client . Networking ;
1113using Intersect . Configuration ;
1214using Intersect . Enums ;
@@ -28,7 +30,7 @@ public partial class EventWindow : ImagePanel
2830 private readonly Button _buttonEventResponse3 ;
2931 private readonly Button _buttonEventResponse4 ;
3032
31- private readonly Typewriter _writer ;
33+ private readonly Typewriter ? _writer ;
3234 private bool _isTypewriting = false ;
3335 private readonly long _typewriterResponseDelay = ClientConfiguration . Instance . TypewriterResponseDelay ;
3436
@@ -62,7 +64,7 @@ public EventWindow(Canvas gameCanvas) : base(gameCanvas, nameof(EventWindow))
6264 _buttonEventResponse4 = new Button ( this , "Response4Button" ) ;
6365 _buttonEventResponse4 . Clicked += ( s , e ) => CloseEventResponse ( EventResponseType . FourOption ) ;
6466
65- _writer = new Typewriter ( ) ;
67+ _writer = Globals . Database . TypewriterBehavior == TypewriterBehavior . Off ? default : new Typewriter ( ) ;
6668
6769 Clicked += ( s , e ) => SkipTypewriting ( ) ;
6870 Hide ( ) ;
@@ -93,15 +95,15 @@ public void Update()
9395 var voiceIdx = Randomization . Next ( 0 , ClientConfiguration . Instance . TypewriterSounds . Count ) ;
9496
9597 // Always show option 1 ("continue" if options empty)
96- _buttonEventResponse1 . IsHidden = ! _writer . IsDone ;
97- _buttonEventResponse2 . IsHidden = ! _writer . IsDone || string . IsNullOrEmpty ( CurrentDialog . Opt2 ) ;
98- _buttonEventResponse3 . IsHidden = ! _writer . IsDone || string . IsNullOrEmpty ( CurrentDialog . Opt3 ) ;
99- _buttonEventResponse4 . IsHidden = ! _writer . IsDone || string . IsNullOrEmpty ( CurrentDialog . Opt4 ) ;
98+ _buttonEventResponse1 . IsHidden = ! ( _writer ? . IsDone ?? true ) ;
99+ _buttonEventResponse2 . IsHidden = ! ( _writer ? . IsDone ?? true ) || string . IsNullOrEmpty ( CurrentDialog . Opt2 ) ;
100+ _buttonEventResponse3 . IsHidden = ! ( _writer ? . IsDone ?? true ) || string . IsNullOrEmpty ( CurrentDialog . Opt3 ) ;
101+ _buttonEventResponse4 . IsHidden = ! ( _writer ? . IsDone ?? true ) || string . IsNullOrEmpty ( CurrentDialog . Opt4 ) ;
100102
101- _writer . Write ( ClientConfiguration . Instance . TypewriterSounds . ElementAtOrDefault ( voiceIdx ) ) ;
102- if ( _writer . IsDone )
103+ _writer ? . Write ( ClientConfiguration . Instance . TypewriterSounds . ElementAtOrDefault ( voiceIdx ) ) ;
104+ if ( _writer ? . IsDone ?? true )
103105 {
104- var disableResponse = Timing . Global . MillisecondsUtc - _writer . DoneAtMilliseconds < _typewriterResponseDelay ;
106+ var disableResponse = _writer != default && Timing . Global . MillisecondsUtc - _writer . DoneAtMilliseconds < _typewriterResponseDelay ;
105107 _buttonEventResponse1 . IsDisabled = disableResponse ;
106108 _buttonEventResponse2 . IsDisabled = disableResponse ;
107109 _buttonEventResponse3 . IsDisabled = disableResponse ;
@@ -205,7 +207,7 @@ private void ShowDialog(RichLabel dialogLabel, Label dialogLabelTemplate, Scroll
205207 // Do this _after_ sizing so we have lines broken up
206208 if ( _isTypewriting )
207209 {
208- _writer . Initialize ( dialogLabel . FormattedLabels ) ;
210+ _writer ? . Initialize ( dialogLabel . FormattedLabels ) ;
209211 _buttonEventResponse1 . Hide ( ) ;
210212 _buttonEventResponse2 . Hide ( ) ;
211213 _buttonEventResponse3 . Hide ( ) ;
@@ -217,7 +219,7 @@ private void ShowDialog(RichLabel dialogLabel, Label dialogLabelTemplate, Scroll
217219
218220 public void CloseEventResponse ( EventResponseType response )
219221 {
220- if ( ! _writer . IsDone )
222+ if ( ! ( _writer ? . IsDone ?? true ) )
221223 {
222224 SkipTypewriting ( ) ;
223225 return ;
0 commit comments