1212namespace cs2
1313{
1414
15- struct LINUX_ONLY ([[gnu::packed]]) CStyleProperty {
16- const void * vmt;
17- CStyleSymbol m_symPropertyName;
18- bool m_bDisallowTransition;
15+ struct CStyleProperty {
1916};
2017
18+ #define BASE_STYLE_PROPERTY_FIELDS () \
19+ const void * vmt; \
20+ CStyleSymbol m_symPropertyName; \
21+ bool m_bDisallowTransition; \
22+ WIN64_ONLY (std::byte pad[6 ];)
23+
2124struct CStylePropertyWidth : CStyleProperty {
25+ BASE_STYLE_PROPERTY_FIELDS ();
2226 CUILength m_Length;
2327};
28+ static_assert (std::is_standard_layout_v<CStylePropertyWidth>);
29+ static_assert (sizeof (CStylePropertyWidth) == 24 );
30+ static_assert (offsetof(CStylePropertyWidth, m_Length) == WIN64_LINUX(16 , 12 ));
2431
2532struct CStylePropertyOpacity : CStyleProperty {
33+ BASE_STYLE_PROPERTY_FIELDS ();
2634 float opacity;
2735};
36+ static_assert (std::is_standard_layout_v<CStylePropertyOpacity>);
37+ static_assert (sizeof (CStylePropertyOpacity) == WIN64_LINUX(24 , 16 ));
38+ static_assert (offsetof(CStylePropertyOpacity, opacity) == WIN64_LINUX(16 , 12 ));
2839
2940struct CStylePropertyZIndex : CStyleProperty {
41+ BASE_STYLE_PROPERTY_FIELDS ();
3042 float zindex;
3143};
44+ static_assert (std::is_standard_layout_v<CStylePropertyZIndex>);
45+ static_assert (sizeof (CStylePropertyZIndex) == WIN64_LINUX(24 , 16 ));
46+ static_assert (offsetof(CStylePropertyZIndex, zindex) == WIN64_LINUX(16 , 12 ));
3247
3348struct CStylePropertyHeight : CStyleProperty {
49+ BASE_STYLE_PROPERTY_FIELDS ();
3450 CUILength m_Height;
3551};
52+ static_assert (std::is_standard_layout_v<CStylePropertyHeight>);
53+ static_assert (sizeof (CStylePropertyHeight) == 24 );
54+ static_assert (offsetof(CStylePropertyHeight, m_Height) == WIN64_LINUX(16 , 12 ));
3655
3756struct CStylePropertyImageShadow : CStyleProperty {
57+ BASE_STYLE_PROPERTY_FIELDS ();
3858 bool fullySet;
3959 CUILength horizontalOffset;
4060 CUILength verticalOffset;
4161 CUILength blurRadius;
4262 float strength;
4363 Color color;
4464};
65+ static_assert (std::is_standard_layout_v<CStylePropertyImageShadow>);
66+ static_assert (sizeof (CStylePropertyImageShadow) == WIN64_LINUX(56 , 48 ));
67+ static_assert (offsetof(CStylePropertyImageShadow, fullySet) == WIN64_LINUX(16 , 10 ));
68+ static_assert (offsetof(CStylePropertyImageShadow, horizontalOffset) == WIN64_LINUX(20 , 12 ));
69+ static_assert (offsetof(CStylePropertyImageShadow, verticalOffset) == WIN64_LINUX(28 , 20 ));
70+ static_assert (offsetof(CStylePropertyImageShadow, blurRadius) == WIN64_LINUX(36 , 28 ));
71+ static_assert (offsetof(CStylePropertyImageShadow, strength) == WIN64_LINUX(44 , 36 ));
72+ static_assert (offsetof(CStylePropertyImageShadow, color) == WIN64_LINUX(48 , 40 ));
4573
4674struct CStylePropertyPosition : CStyleProperty {
75+ BASE_STYLE_PROPERTY_FIELDS ();
4776 CUILength x;
4877 CUILength y;
4978 CUILength z;
5079};
80+ static_assert (std::is_standard_layout_v<CStylePropertyPosition>);
81+ static_assert (sizeof (CStylePropertyPosition) == 40 );
82+ static_assert (offsetof(CStylePropertyPosition, x) == WIN64_LINUX(16 , 12 ));
83+ static_assert (offsetof(CStylePropertyPosition, y) == WIN64_LINUX(24 , 20 ));
84+ static_assert (offsetof(CStylePropertyPosition, z) == WIN64_LINUX(32 , 28 ));
5185
5286struct CStylePropertyTransformOrigin : CStyleProperty {
87+ BASE_STYLE_PROPERTY_FIELDS ();
5388 CUILength x;
5489 CUILength y;
5590 bool m_bParentRelative;
5691};
92+ static_assert (std::is_standard_layout_v<CStylePropertyTransformOrigin>);
93+ static_assert (sizeof (CStylePropertyTransformOrigin) == WIN64_LINUX(40 , 32 ));
94+ static_assert (offsetof(CStylePropertyTransformOrigin, x) == WIN64_LINUX(16 , 12 ));
95+ static_assert (offsetof(CStylePropertyTransformOrigin, y) == WIN64_LINUX(24 , 20 ));
96+ static_assert (offsetof(CStylePropertyTransformOrigin, m_bParentRelative) == WIN64_LINUX(32 , 28 ));
5797
5898struct CStylePropertyAlign : CStyleProperty {
99+ BASE_STYLE_PROPERTY_FIELDS ();
59100 EHorizontalAlignment m_eHorizontalAlignment;
60101 EVerticalAlignment m_eVerticalAlignment;
61102};
103+ static_assert (std::is_standard_layout_v<CStylePropertyAlign>);
104+ static_assert (sizeof (CStylePropertyAlign) == WIN64_LINUX(24 , 16 ));
105+ static_assert (offsetof(CStylePropertyAlign, m_eHorizontalAlignment) == WIN64_LINUX(16 , 10 ));
106+ static_assert (offsetof(CStylePropertyAlign, m_eVerticalAlignment) == WIN64_LINUX(17 , 11 ));
62107
63108struct CStylePropertyWashColor : CStyleProperty {
109+ BASE_STYLE_PROPERTY_FIELDS ();
64110 Color color;
65111 bool fullySet;
66112};
113+ static_assert (std::is_standard_layout_v<CStylePropertyWashColor>);
114+ static_assert (sizeof (CStylePropertyWashColor) == WIN64_LINUX(24 , 16 ));
115+ static_assert (offsetof(CStylePropertyWashColor, color) == WIN64_LINUX(16 , 10 ));
116+ static_assert (offsetof(CStylePropertyWashColor, fullySet) == WIN64_LINUX(20 , 14 ));
67117
68118struct CStylePropertyFlowChildren : CStyleProperty {
119+ BASE_STYLE_PROPERTY_FIELDS ();
69120 EFlowDirection m_eFlowDirection;
70121};
122+ static_assert (std::is_standard_layout_v<CStylePropertyFlowChildren>);
123+ static_assert (sizeof (CStylePropertyFlowChildren) == WIN64_LINUX(24 , 16 ));
124+ static_assert (offsetof(CStylePropertyFlowChildren, m_eFlowDirection) == WIN64_LINUX(16 , 10 ));
71125
72126struct CStylePropertyFont : CStyleProperty {
127+ BASE_STYLE_PROPERTY_FIELDS ();
73128 CUtlString m_strFontFamily;
74129 float m_flFontSize;
75130 EFontStyle m_eFontStyle;
76131 EFontWeight m_eFontWeight;
77132 EFontStretch m_eFontStretch;
78133};
134+ static_assert (std::is_standard_layout_v<CStylePropertyFont>);
135+ static_assert (sizeof (CStylePropertyFont) == 32 );
136+ static_assert (offsetof(CStylePropertyFont, m_strFontFamily) == 16 );
137+ static_assert (offsetof(CStylePropertyFont, m_flFontSize) == 24 );
138+ static_assert (offsetof(CStylePropertyFont, m_eFontStyle) == 28 );
139+ static_assert (offsetof(CStylePropertyFont, m_eFontWeight) == 29 );
140+ static_assert (offsetof(CStylePropertyFont, m_eFontStretch) == 30 );
79141
80142struct CStylePropertyTextShadow : CStyleProperty {
143+ BASE_STYLE_PROPERTY_FIELDS ();
81144 bool fullySet;
82145 CUILength horizontalOffset;
83146 CUILength verticalOffset;
84147 CUILength blurRadius;
85148 float strength;
86149 Color color;
87150};
151+ static_assert (std::is_standard_layout_v<CStylePropertyTextShadow>);
152+ static_assert (sizeof (CStylePropertyTextShadow) == WIN64_LINUX(56 , 48 ));
153+ static_assert (offsetof(CStylePropertyTextShadow, fullySet) == WIN64_LINUX(16 , 10 ));
154+ static_assert (offsetof(CStylePropertyTextShadow, horizontalOffset) == WIN64_LINUX(20 , 12 ));
155+ static_assert (offsetof(CStylePropertyTextShadow, verticalOffset) == WIN64_LINUX(28 , 20 ));
156+ static_assert (offsetof(CStylePropertyTextShadow, blurRadius) == WIN64_LINUX(36 , 28 ));
157+ static_assert (offsetof(CStylePropertyTextShadow, strength) == WIN64_LINUX(44 , 36 ));
158+ static_assert (offsetof(CStylePropertyTextShadow, color) == WIN64_LINUX(48 , 40 ));
88159
89160struct CStylePropertyMixBlendMode : CStyleProperty {
161+ BASE_STYLE_PROPERTY_FIELDS ();
90162 EMixBlendMode m_eMixBlendMode;
91163 bool m_bSet;
92164};
165+ static_assert (std::is_standard_layout_v<CStylePropertyMixBlendMode>);
166+ static_assert (sizeof (CStylePropertyMixBlendMode) == WIN64_LINUX(24 , 16 ));
167+ static_assert (offsetof(CStylePropertyMixBlendMode, m_eMixBlendMode) == WIN64_LINUX(16 , 10 ));
168+ static_assert (offsetof(CStylePropertyMixBlendMode, m_bSet) == WIN64_LINUX(17 , 11 ));
93169
94170struct CStylePropertyTextAlign : CStyleProperty {
171+ BASE_STYLE_PROPERTY_FIELDS ();
95172 ETextAlign m_eAlign;
96173};
174+ static_assert (std::is_standard_layout_v<CStylePropertyTextAlign>);
175+ static_assert (sizeof (CStylePropertyTextAlign) == WIN64_LINUX(24 , 16 ));
176+ static_assert (offsetof(CStylePropertyTextAlign, m_eAlign) == WIN64_LINUX(16 , 10 ));
97177
98- struct CStylePropertyDimensionsBase : CStyleProperty {
178+ struct CStylePropertyMargin : CStyleProperty {
179+ BASE_STYLE_PROPERTY_FIELDS ();
99180 CUILength m_left;
100181 CUILength m_top;
101182 CUILength m_right;
102183 CUILength m_bottom;
103184};
104-
105- struct CStylePropertyMargin : CStylePropertyDimensionsBase {
106- };
185+ static_assert (std::is_standard_layout_v<CStylePropertyMargin>);
186+ static_assert (sizeof (CStylePropertyMargin) == 48 );
187+ static_assert (offsetof(CStylePropertyMargin, m_left) == WIN64_LINUX(16 , 12 ));
188+ static_assert (offsetof(CStylePropertyMargin, m_top) == WIN64_LINUX(24 , 20 ));
189+ static_assert (offsetof(CStylePropertyMargin, m_right) == WIN64_LINUX(32 , 28 ));
190+ static_assert (offsetof(CStylePropertyMargin, m_bottom) == WIN64_LINUX(40 , 36 ));
107191
108192struct CFillBrush {
109193 EStrokeType type;
@@ -118,25 +202,40 @@ static_assert(offsetof(CFillBrush, fillColor) == 8);
118202static_assert (sizeof (CFillBrush) == 24 );
119203
120204struct CStylePropertyFillColor : CStyleProperty {
121- LINUX_ONLY (std::byte pad[4 ];)
122- int numberOfFillBrushes;
205+ };
206+
207+ template <typename T>
208+ struct FixedGrowableVector {
209+ int numberOfElements;
123210 int growSize;
124211 union {
125- CFillBrush* fillBrushes ;
126- CFillBrush fillBrush ;
212+ T* elements ;
213+ T element ;
127214 };
128215};
129216
217+ #define STYLE_PROPERTY_FILLCOLOR_FIELDS () \
218+ BASE_STYLE_PROPERTY_FIELDS (); \
219+ FixedGrowableVector<CFillBrush> fillBrushes
220+
130221struct CStylePropertyForegroundColor : CStylePropertyFillColor {
222+ STYLE_PROPERTY_FILLCOLOR_FIELDS ();
131223};
224+ static_assert (std::is_standard_layout_v<CStylePropertyForegroundColor>);
132225static_assert (sizeof (CStylePropertyForegroundColor) == 48 );
226+ static_assert (offsetof(CStylePropertyForegroundColor, fillBrushes) == 16 );
133227
134228struct CStylePropertyBackgroundColor : CStylePropertyFillColor {
229+ STYLE_PROPERTY_FILLCOLOR_FIELDS ();
135230 float opacity;
136231};
232+ static_assert (std::is_standard_layout_v<CStylePropertyBackgroundColor>);
137233static_assert (sizeof (CStylePropertyBackgroundColor) == 56 );
234+ static_assert (offsetof(CStylePropertyBackgroundColor, fillBrushes) == 16 );
235+ static_assert (offsetof(CStylePropertyBackgroundColor, opacity) == 48 );
138236
139237struct CStylePropertyTransform3D : CStyleProperty {
238+ BASE_STYLE_PROPERTY_FIELDS ();
140239 CUtlVector<CTransform3D*> transforms;
141240 float cachedParentWidth;
142241 float cachedParentHeight;
@@ -145,21 +244,34 @@ struct CStylePropertyTransform3D : CStyleProperty {
145244 bool interpolated;
146245 bool fullySet;
147246};
247+ static_assert (std::is_standard_layout_v<CStylePropertyTransform3D>);
248+ static_assert (sizeof (CStylePropertyTransform3D) == 120 );
249+ static_assert (offsetof(CStylePropertyTransform3D, transforms) == 16 );
250+ static_assert (offsetof(CStylePropertyTransform3D, cachedParentWidth) == 40 );
251+ static_assert (offsetof(CStylePropertyTransform3D, cachedParentHeight) == 44 );
252+ static_assert (offsetof(CStylePropertyTransform3D, dirty) == 48 );
253+ static_assert (offsetof(CStylePropertyTransform3D, matrix) == 52 );
254+ static_assert (offsetof(CStylePropertyTransform3D, interpolated) == 116 );
255+ static_assert (offsetof(CStylePropertyTransform3D, fullySet) == 117 );
148256
149257struct CStylePropertyBorder : CStyleProperty {
258+ BASE_STYLE_PROPERTY_FIELDS ();
150259 EBorderStyle m_rgBorderStyle[4 ];
151260 CUILength m_rgBorderWidth[4 ];
152261 bool m_rgColorsSet[4 ];
153262 Color m_rgBorderColor[4 ];
154263};
264+ static_assert (std::is_standard_layout_v<CStylePropertyBorder>);
155265
156266struct CornerRadii_t {
157267 CUILength horizontalRadius;
158268 CUILength verticalRadius;
159269};
160270
161271struct CStylePropertyBorderRadius : CStyleProperty {
272+ BASE_STYLE_PROPERTY_FIELDS ();
162273 CornerRadii_t m_rgCornerRaddi[4 ];
163274};
275+ static_assert (std::is_standard_layout_v<CStylePropertyBorderRadius>);
164276
165277};
0 commit comments