1
- using ARKBreedingStats . Library ;
1
+ using System ;
2
+ using ARKBreedingStats . Library ;
2
3
using ARKBreedingStats . species ;
3
4
using ARKBreedingStats . values ;
4
5
using System . Collections . Generic ;
@@ -12,8 +13,12 @@ namespace ARKBreedingStats.uiControls
12
13
internal static class LibraryInfo
13
14
{
14
15
private static Species _infoForSpecies ;
16
+ private static bool _libraryFilterConsidered ;
15
17
private static string _speciesInfo ;
16
18
19
+ /// <summary>
20
+ /// Clear the cached information.
21
+ /// </summary>
17
22
internal static void ClearInfo ( )
18
23
{
19
24
_infoForSpecies = null ;
@@ -25,16 +30,20 @@ internal static void ClearInfo()
25
30
/// <summary>
26
31
/// Returns information about what color ids exist in which regions of the creatures of a species.
27
32
/// </summary>
28
- internal static bool SetColorInfo ( Species species , IList < Creature > creatures , TableLayoutPanel tlp = null )
33
+ internal static bool SetColorInfo ( Species species , IList < Creature > creatures , bool libraryFilterConsidered , TableLayoutPanel tlp = null )
29
34
{
30
35
if ( species == null || creatures == null ) return false ;
31
- if ( species == _infoForSpecies ) return true ;
36
+ if ( species == _infoForSpecies
37
+ && _libraryFilterConsidered == libraryFilterConsidered
38
+ && _infoForSpecies != null ) return true ;
32
39
33
40
_infoForSpecies = species ;
41
+ _libraryFilterConsidered = libraryFilterConsidered ;
34
42
if ( tlp != null )
35
43
{
36
- // remove all controls except copy to clipboard button
37
- for ( int i = tlp . Controls . Count - 1 ; i > 0 ; i -- )
44
+ tlp . SuspendLayout ( ) ;
45
+ // remove all controls except copy to clipboard button and filter checkbox
46
+ for ( int i = tlp . Controls . Count - 1 ; i > 1 ; i -- )
38
47
tlp . Controls . RemoveAt ( i ) ;
39
48
}
40
49
@@ -47,38 +56,66 @@ internal static bool SetColorInfo(Species species, IList<Creature> creatures, Ta
47
56
colorsDontExistPerRegion [ i ] = new HashSet < byte > ( allAvailableColorIds ) ;
48
57
}
49
58
59
+ var properties = new Dictionary < CreatureFlags , int > ( ) ;
60
+ var flags = ( ( CreatureFlags [ ] ) Enum . GetValues ( typeof ( CreatureFlags ) ) ) . Where ( f => f != CreatureFlags . None ) . ToArray ( ) ;
61
+ foreach ( var flag in flags )
62
+ properties [ flag ] = 0 ;
63
+ var creatureCount = 0 ;
64
+
50
65
foreach ( var cr in creatures )
51
66
{
52
67
if ( cr . speciesBlueprint != species . blueprintPath
53
- || cr . colors == null )
68
+ || cr . flags . HasFlag ( CreatureFlags . Placeholder )
69
+ || cr . colors == null )
54
70
continue ;
55
71
72
+ creatureCount ++ ;
56
73
for ( var ci = 0 ; ci < Ark . ColorRegionCount ; ci ++ )
57
74
{
58
75
var co = cr . colors [ ci ] ;
59
76
if ( colorsExistPerRegion [ ci ] . Contains ( co ) ) continue ;
60
77
colorsExistPerRegion [ ci ] . Add ( co ) ;
61
78
colorsDontExistPerRegion [ ci ] . Remove ( co ) ;
62
79
}
80
+
81
+ foreach ( var flag in flags )
82
+ {
83
+ if ( cr . flags . HasFlag ( flag ) )
84
+ properties [ flag ] ++ ;
85
+ }
63
86
}
64
87
65
88
var sb = new StringBuilder ( ) ;
66
89
var tableRow = 1 ;
67
90
68
- void AddParagraph ( string text , string appendToPlainText = null , bool bold = false , float relativeFontSize = 1 )
91
+ void AddParagraph ( string text , string suffixForPlainText = null , bool bold = false , float relativeFontSize = 1 )
69
92
{
70
- tlp ? . RowStyles . Add ( new RowStyle ( SizeType . AutoSize ) ) ;
71
- tlp ? . Controls . Add ( new Label
93
+ if ( tlp != null )
72
94
{
73
- Text = text ,
74
- Font = bold || relativeFontSize != 1 ? new Font ( Control . DefaultFont . FontFamily , Control . DefaultFont . Size * relativeFontSize , bold ? FontStyle . Bold : FontStyle . Regular ) : Control . DefaultFont ,
75
- Margin = new Padding ( 3 , bold ? 8 : 3 , 3 , 3 ) ,
76
- AutoSize = true
77
- } , 0 , tableRow ++ ) ;
78
- sb . AppendLine ( text + appendToPlainText ) ;
95
+ while ( tlp . RowStyles . Count <= tableRow )
96
+ tlp . RowStyles . Add ( new RowStyle ( SizeType . AutoSize ) ) ;
97
+ var l = new Label
98
+ {
99
+ Text = text ,
100
+ Font = bold || relativeFontSize != 1
101
+ ? new Font ( Control . DefaultFont . FontFamily , Control . DefaultFont . Size * relativeFontSize ,
102
+ bold ? FontStyle . Bold : FontStyle . Regular )
103
+ : Control . DefaultFont ,
104
+ Margin = new Padding ( 3 , bold ? 8 : 3 , 3 , 3 ) ,
105
+ AutoSize = true
106
+ } ;
107
+ tlp . Controls . Add ( l , 0 , tableRow ++ ) ;
108
+ tlp . SetColumnSpan ( l , 2 ) ;
109
+ }
110
+
111
+ sb . AppendLine ( text + suffixForPlainText ) ;
79
112
}
80
113
81
- AddParagraph ( $ "Color information about { species . DescriptiveNameAndMod } ({ species . blueprintPath } )", "\n " , true , 1.5f ) ;
114
+ AddParagraph ( $ "Information about the { species . DescriptiveNameAndMod } in this library", "\n " , true , 1.5f ) ;
115
+ AddParagraph (
116
+ $ "{ creatureCount } creatures. { string . Join ( ", " , properties . Where ( p => p . Value > 0 ) . Select ( p => $ "{ Loc . S ( p . Key . ToString ( ) ) } : { p . Value } ") ) } ",
117
+ "\n " ) ;
118
+ AddParagraph ( $ "Color information", null , true , 1.3f ) ;
82
119
83
120
var rangeSb = new StringBuilder ( ) ;
84
121
for ( int i = 0 ; i < Ark . ColorRegionCount ; i ++ )
@@ -138,6 +175,7 @@ string CreateNumberRanges(HashSet<byte> numbers)
138
175
}
139
176
140
177
_speciesInfo = sb . ToString ( ) ;
178
+ tlp ? . ResumeLayout ( ) ;
141
179
return true ;
142
180
}
143
181
0 commit comments