@@ -38,26 +38,18 @@ private void DisposeCheevoForms()
3838
3939 public void Restart ( IEnumerable < RCheevos . Cheevo > cheevos , Func < uint , string > getCheevoProgress , Func < bool > isHardcodeMode )
4040 {
41+ _cheevos = cheevos . ToArray ( ) ;
4142 _getCheevoProgress = getCheevoProgress ;
4243 _isHardcodeMode = isHardcodeMode ;
43- flowLayoutPanel1 . Controls . Clear ( ) ;
44- DisposeCheevoForms ( ) ;
45- _cheevos = cheevos . ToArray ( ) ;
46- _cheevoForms = new RCheevosAchievementForm [ DisplayedItems ( ) ] ;
47- for ( int i = 0 ; i < DisplayedItems ( ) ; i ++ )
48- {
49- _cheevoForms [ i ] = new RCheevosAchievementForm ( getCheevoProgress ) ;
50- }
51- flowLayoutPanel1 . Controls . AddRange ( _cheevoForms ) ;
52- vScrollBar1 . Maximum = _controlHeight * _cheevos . Length ;
44+
45+ RCheevosAchievementListForm_SizeChanged ( this , EventArgs . Empty ) ;
5346 vScrollBar1 . Value = 0 ;
54- UpdateForms ( ) ;
47+ vScrollBar1 . Maximum = _controlHeight * _cheevos . Length ;
5548 }
5649
5750 public void OnFrameAdvance ( bool hardcore )
5851 {
59- var reorderedCheevos = _cheevos . OrderByDescending ( f => f . OrderByKey ( _getCheevoProgress ) ) . ToArray ( ) ;
60- _cheevos = reorderedCheevos ;
52+ _cheevos = _cheevos . OrderByDescending ( f => f . OrderByKey ( _getCheevoProgress ) ) . ToArray ( ) ;
6153
6254 UpdateForms ( ) ;
6355
@@ -109,6 +101,24 @@ private int DisplayedItems()
109101 {
110102 return Math . Min ( ( int ) Math . Ceiling ( ( double ) flowLayoutPanel1 . Height / _controlHeight ) + 1 , _cheevos . Length ) ;
111103 }
104+
105+ private void RCheevosAchievementListForm_SizeChanged ( object sender , EventArgs e )
106+ {
107+ vScrollBar1 . LargeChange = vScrollBar1 . Size . Height ;
108+ if ( flowLayoutPanel1 . Controls . Count != DisplayedItems ( ) )
109+ {
110+ flowLayoutPanel1 . Controls . Clear ( ) ;
111+ DisposeCheevoForms ( ) ;
112+ _cheevoForms = new RCheevosAchievementForm [ DisplayedItems ( ) ] ;
113+ for ( int i = 0 ; i < DisplayedItems ( ) ; i ++ )
114+ {
115+ _cheevoForms [ i ] = new RCheevosAchievementForm ( _getCheevoProgress ) ;
116+ }
117+ flowLayoutPanel1 . Controls . AddRange ( _cheevoForms ) ;
118+ }
119+
120+ UpdateForms ( ) ;
121+ }
112122 }
113123
114124 public class DoubleBufferedFlowLayoutPanel : FlowLayoutPanel
0 commit comments