@@ -61,13 +61,15 @@ private InvalidOperationException CreateInvalidInputTypeException() =>
6161 Dock = Pos . Fill ,
6262 } ;
6363
64- var promptLabel = new Label ( inputPanel , name : nameof ( _promptLabel ) )
64+ var promptScroller = new ScrollControl ( inputPanel , name : nameof ( _promptScroller ) )
65+ {
66+ Dock = Pos . Fill ,
67+ } ;
68+
69+ var promptLabel = new RichLabel ( promptScroller , name : nameof ( _promptLabel ) )
6570 {
66- AutoSizeToContents = false ,
6771 Dock = Pos . Fill ,
6872 Font = _defaultFont ,
69- TextAlign = Pos . CenterH ,
70- WrappingBehavior = WrappingBehavior . Wrapped ,
7173 } ;
7274
7375 var buttonsPanel = new Panel ( this , name : nameof ( _buttonPanel ) )
@@ -103,13 +105,15 @@ private void OkayButtonOnClicked(Base @base, MouseButtonState mouseButtonState)
103105 Dock = Pos . Fill ,
104106 } ;
105107
106- var promptLabel = new Label ( inputPanel , name : nameof ( _promptLabel ) )
108+ var promptScroller = new ScrollControl ( inputPanel , name : nameof ( _promptScroller ) )
109+ {
110+ Dock = Pos . Fill ,
111+ } ;
112+
113+ var promptLabel = new RichLabel ( promptScroller , name : nameof ( _promptLabel ) )
107114 {
108- AutoSizeToContents = false ,
109115 Dock = Pos . Fill ,
110116 Font = _defaultFont ,
111- TextAlign = Pos . CenterH ,
112- WrappingBehavior = WrappingBehavior . Wrapped ,
113117 } ;
114118
115119 var buttonsPanel = new Panel ( this , name : nameof ( _buttonPanel ) )
@@ -151,13 +155,15 @@ private void OkayButtonOnClicked(Base @base, MouseButtonState mouseButtonState)
151155 Dock = Pos . Fill ,
152156 } ;
153157
154- var promptLabel = new Label ( inputPanel , name : nameof ( _promptLabel ) )
158+ var promptScroller = new ScrollControl ( inputPanel , name : nameof ( _promptScroller ) )
159+ {
160+ Dock = Pos . Fill ,
161+ } ;
162+
163+ var promptLabel = new RichLabel ( promptScroller , name : nameof ( _promptLabel ) )
155164 {
156- AutoSizeToContents = false ,
157165 Dock = Pos . Fill ,
158166 Font = _defaultFont ,
159- TextAlign = Pos . CenterH ,
160- WrappingBehavior = WrappingBehavior . Wrapped ,
161167 } ;
162168
163169 var buttonsPanel = new Panel ( this , name : nameof ( _buttonPanel ) )
@@ -223,20 +229,23 @@ private void NoButtonOnClicked(Base sender, MouseButtonState arguments)
223229 Dock = Pos . Fill ,
224230 } ;
225231
226- var promptLabel = new Label ( inputPanel , name : nameof ( _promptLabel ) )
232+ var promptScroller = new ScrollControl ( inputPanel , name : nameof ( _promptScroller ) )
233+ {
234+ Dock = Pos . Fill ,
235+ } ;
236+
237+ var promptLabel = new RichLabel ( promptScroller , name : nameof ( _promptLabel ) )
227238 {
228- AutoSizeToContents = false ,
229239 Dock = Pos . Fill ,
230240 Font = _defaultFont ,
231- TextAlign = Pos . CenterH ,
232- WrappingBehavior = WrappingBehavior . Wrapped ,
233241 } ;
234242
235243 var numericInput = new TextBoxNumeric ( inputPanel , name : nameof ( _numericInputTextbox ) )
236244 {
237245 AutoSizeToContents = false ,
238246 Dock = Pos . Bottom ,
239247 Font = _defaultFont ,
248+ Margin = new Margin ( 0 , 8 , 0 , 0 ) ,
240249 TextAlign = Pos . Left ,
241250 WrappingBehavior = WrappingBehavior . NoWrap ,
242251 } ;
@@ -288,20 +297,23 @@ private void NumericInputOnValueChanged(TextBoxNumeric sender, ValueChangedEvent
288297 Dock = Pos . Fill ,
289298 } ;
290299
291- var promptLabel = new Label ( inputPanel , name : nameof ( _promptLabel ) )
300+ var promptScroller = new ScrollControl ( inputPanel , name : nameof ( _promptScroller ) )
301+ {
302+ Dock = Pos . Fill ,
303+ } ;
304+
305+ var promptLabel = new RichLabel ( promptScroller , name : nameof ( _promptLabel ) )
292306 {
293- AutoSizeToContents = false ,
294307 Dock = Pos . Fill ,
295308 Font = _defaultFont ,
296- TextAlign = Pos . CenterH ,
297- WrappingBehavior = WrappingBehavior . Wrapped ,
298309 } ;
299310
300311 var numericSliderInput = new LabeledSlider ( inputPanel , name : nameof ( _numericInputSlider ) )
301312 {
302313 AutoSizeToContents = false ,
303314 Dock = Pos . Bottom ,
304315 Font = _defaultFont ,
316+ Margin = new Margin ( 0 , 8 , 0 , 0 ) ,
305317 Rounding = 0 ,
306318 } ;
307319 numericSliderInput . ValueChanged += NumericSliderInputOnValueChanged ;
@@ -348,20 +360,23 @@ private void NumericSliderInputOnValueChanged(Base sender, ValueChangedEventArgs
348360 Dock = Pos . Fill ,
349361 } ;
350362
351- var promptLabel = new Label ( inputPanel , name : nameof ( _promptLabel ) )
363+ var promptScroller = new ScrollControl ( inputPanel , name : nameof ( _promptScroller ) )
364+ {
365+ Dock = Pos . Fill ,
366+ } ;
367+
368+ var promptLabel = new RichLabel ( promptScroller , name : nameof ( _promptLabel ) )
352369 {
353- AutoSizeToContents = false ,
354370 Dock = Pos . Fill ,
355371 Font = _defaultFont ,
356- TextAlign = Pos . CenterH ,
357- WrappingBehavior = WrappingBehavior . Wrapped ,
358372 } ;
359373
360374 var stringInput = new TextBox ( inputPanel , name : nameof ( _stringInput ) )
361375 {
362376 AutoSizeToContents = false ,
363377 Dock = Pos . Bottom ,
364378 Font = _defaultFont ,
379+ Margin = new Margin ( 0 , 8 , 0 , 0 ) ,
365380 TextAlign = Pos . Left ,
366381 WrappingBehavior = WrappingBehavior . NoWrap ,
367382 } ;
@@ -417,7 +432,8 @@ private void StringInputOnTextChanged(TextBox sender, ValueChangedEventArgs<stri
417432 //
418433 // NumericSliderInput,
419434
420- private readonly Label _promptLabel ;
435+ private readonly ScrollControl _promptScroller ;
436+ private readonly RichLabel _promptLabel ;
421437
422438 private readonly LabeledSlider ? _numericInputSlider ;
423439 private readonly TextBoxNumeric ? _numericInputTextbox ;
@@ -453,6 +469,9 @@ public InputBox(
453469 {
454470 }
455471
472+ private int _initialScrollerInnerHeight ;
473+ private int _initialMinimumHeight ;
474+
456475 protected InputBox (
457476 string name ,
458477 string title ,
@@ -500,7 +519,10 @@ protected InputBox(
500519 _okayButton = _inputPanel . FindChildByName < Button > ( nameof ( _okayButton ) ) ;
501520 _yesButton = _inputPanel . FindChildByName < Button > ( nameof ( _yesButton ) ) ;
502521
503- _promptLabel = _inputPanel . FindChildByName < Label > ( nameof ( _promptLabel ) ) ??
522+ _promptScroller = _inputPanel . FindChildByName < ScrollControl > ( nameof ( _promptScroller ) ) ??
523+ throw new InvalidOperationException ( "Prompt scroller wasn't created" ) ;
524+
525+ _promptLabel = _promptScroller . FindChildByName < RichLabel > ( nameof ( _promptLabel ) ) ??
504526 throw new InvalidOperationException ( "Prompt label wasn't created" ) ;
505527
506528 _promptLabel . Text = prompt ;
@@ -612,6 +634,26 @@ protected override void EnsureInitialized()
612634 Name = $ "{ GetType ( ) . GetName ( qualified : false ) } _{ InputType } ";
613635 LoadJsonUi ( GameContentManager . UI . Shared , Graphics . Renderer ? . GetResolutionString ( ) ) ;
614636
637+ var promptScrollerInnerPanelPadding = _promptScroller . InnerPanel . Padding ;
638+ var promptScrollerInnerPanelPaddingV =
639+ promptScrollerInnerPanelPadding . Bottom + promptScrollerInnerPanelPadding . Top ;
640+ _initialScrollerInnerHeight = _promptScroller . InnerHeight - promptScrollerInnerPanelPaddingV ;
641+ _initialMinimumHeight = MinimumSize . Y ;
642+
643+ _promptLabel . Rebuilt += ( _ , _ ) =>
644+ {
645+ var newHeight = _promptLabel . Height ;
646+ newHeight = Math . Min ( 400 , newHeight ) ;
647+ var delta = newHeight - _initialScrollerInnerHeight ;
648+ MinimumSize = MinimumSize with
649+ {
650+ Y = _initialMinimumHeight + delta ,
651+ } ;
652+ SizeToChildren ( ) ;
653+ } ;
654+
655+ _promptLabel . ForceImmediateRebuild ( ) ;
656+
615657 Show ( ) ;
616658 Focus ( ) ;
617659 }
0 commit comments