Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
GamesWidget.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
5 public class GamesWidget : ContainerWidget {
6 public float m_spacing;
7 public float m_bevel;
8
9 public override void MeasureOverride(Vector2 parentAvailableSize) {
10 base.MeasureOverride(parentAvailableSize);
11 IsOverdrawRequired = Children.Count > 1;
12 }
13
14 public override void ArrangeOverride() {
15 float marginLeft = 0f;
16 float marginRight = 0f;
18 marginLeft = Window.DisplayCutoutInsets.X * ScreensManager.FinalUiScale;
19 marginRight = Window.DisplayCutoutInsets.Z * ScreensManager.FinalUiScale;
20 }
21 if (Children.Count == 1) {
24 && Children[0] is GameWidget gameWidget0) {
25 gameWidget0.LayoutTransform = Matrix.Identity;
27 ContainerWidget guiWidget = gameWidget0.GuiWidget;
28 guiWidget.MarginLeft = marginLeft;
29 guiWidget.MarginTop = 0f;
30 guiWidget.MarginRight = marginRight;
31 guiWidget.MarginBottom = 0f;
32 }
33 }
34 }
35 else if (Children.Count == 2) {
36 if (SettingsManager.ScreenLayout2 == ScreenLayout.DoubleVertical) {
37 m_spacing = 12f;
38 m_bevel = 3f;
39 float x = 0f;
40 float y = 0f;
41 float x2 = ActualSize.X / 2f + m_spacing / 2f;
42 float y2 = 0f;
43 float x3 = ActualSize.X / 2f - m_spacing / 2f;
44 float y3 = ActualSize.Y;
45 float num = 0.5f;
46 ArrangeChildWidgetInCell(new Vector2(x, y), new Vector2(x, y) + new Vector2(x3, y3) / num, Children[0]);
47 if (Children[0] is GameWidget gameWidget0) {
48 gameWidget0.LayoutTransform = Matrix.CreateScale(num, num, 1f);
49 ContainerWidget guiWidget = gameWidget0.GuiWidget;
50 guiWidget.MarginLeft = marginLeft / num;
51 guiWidget.MarginTop = 0f;
52 guiWidget.MarginRight = 0f;
53 guiWidget.MarginBottom = 0f;
54 }
55 ArrangeChildWidgetInCell(new Vector2(x2, y2), new Vector2(x2, y2) + new Vector2(x3, y3) / num, Children[1]);
56 if (Children[1] is GameWidget gameWidget1) {
57 gameWidget1.LayoutTransform = Matrix.CreateScale(num, num, 1f);
58 ContainerWidget guiWidget = gameWidget1.GuiWidget;
59 guiWidget.MarginLeft = 0f;
60 guiWidget.MarginTop = 0f;
61 guiWidget.MarginRight = marginRight / num;
62 guiWidget.MarginBottom = 0f;
63 }
64 }
65 if (SettingsManager.ScreenLayout2 == ScreenLayout.DoubleHorizontal) {
66 m_spacing = 12f;
67 m_bevel = 3f;
68 float x4 = 0f;
69 float y4 = 0f;
70 float x5 = 0f;
71 float y5 = ActualSize.Y / 2f + m_spacing / 2f;
72 float x6 = ActualSize.X;
73 float y6 = ActualSize.Y / 2f - m_spacing / 2f;
74 float num2 = 0.48f;
75 ArrangeChildWidgetInCell(new Vector2(x4, y4), new Vector2(x4, y4) + new Vector2(x6, y6) / num2, Children[0]);
76 if (Children[0] is GameWidget gameWidget0) {
77 gameWidget0.LayoutTransform = Matrix.CreateScale(num2, num2, 1f);
78 ContainerWidget guiWidget = gameWidget0.GuiWidget;
79 guiWidget.MarginLeft = marginLeft / num2;
80 guiWidget.MarginTop = 0f;
81 guiWidget.MarginRight = marginRight / num2;
82 guiWidget.MarginBottom = 0f;
83 }
84 ArrangeChildWidgetInCell(new Vector2(x5, y5), new Vector2(x5, y5) + new Vector2(x6, y6) / num2, Children[1]);
85 if (Children[1] is GameWidget gameWidget1) {
86 gameWidget1.LayoutTransform = Matrix.CreateScale(num2, num2, 1f);
87 ContainerWidget guiWidget = gameWidget1.GuiWidget;
88 guiWidget.MarginLeft = marginLeft / num2;
89 guiWidget.MarginTop = 0f;
90 guiWidget.MarginRight = marginRight / num2;
91 guiWidget.MarginBottom = 0f;
92 }
93 }
94 if (SettingsManager.ScreenLayout2 == ScreenLayout.DoubleOpposite) {
95 m_spacing = 20f;
96 m_bevel = 4f;
97 float x7 = 0f;
98 float y7 = 0f;
99 float x8 = ActualSize.X / 2f + m_spacing / 2f;
100 float y8 = 0f;
101 float x9 = ActualSize.X / 2f - m_spacing / 2f;
102 float y9 = ActualSize.Y;
103 float num3 = Window.Size.Y / (float)Window.Size.X;
104 ArrangeChildWidgetInCell(new Vector2(x7, y7), new Vector2(x7, y7) + new Vector2(x9, y9) / num3, Children[0]);
105 if (Children[0] is GameWidget gameWidget0) {
106 gameWidget0.LayoutTransform = new Matrix(
107 0f,
108 num3,
109 0f,
110 0f,
111 0f - num3,
112 0f,
113 0f,
114 0f,
115 0f,
116 0f,
117 1f,
118 0f,
119 0f,
120 0f,
121 0f,
122 1f
123 );
124 ContainerWidget guiWidget = gameWidget0.GuiWidget;
125 guiWidget.MarginLeft = 0f;
126 guiWidget.MarginTop = 0f;
127 guiWidget.MarginRight = 0f;
128 guiWidget.MarginBottom = marginLeft / num3;
129 }
130 ArrangeChildWidgetInCell(new Vector2(x8, y8), new Vector2(x8, y8) + new Vector2(x9, y9) / num3, Children[1]);
131 if (Children[1] is GameWidget gameWidget1) {
132 gameWidget1.LayoutTransform = new Matrix(
133 0f,
134 0f - num3,
135 0f,
136 0f,
137 num3,
138 0f,
139 0f,
140 0f,
141 0f,
142 0f,
143 1f,
144 0f,
145 0f,
146 0f,
147 0f,
148 1f
149 );
150 ContainerWidget guiWidget = gameWidget1.GuiWidget;
151 guiWidget.MarginLeft = 0f;
152 guiWidget.MarginTop = 0f;
153 guiWidget.MarginRight = 0f;
154 guiWidget.MarginBottom = marginRight / num3;
155 }
156 }
157 }
158 else if (Children.Count == 3) {
159 m_spacing = 12f;
160 m_bevel = 3f;
161 if (SettingsManager.ScreenLayout3 == ScreenLayout.TripleVertical) {
162 float x10 = 0f;
163 float y10 = 0f;
164 float x11 = ActualSize.X / 2f + m_spacing / 2f;
165 float y11 = 0f;
166 float x12 = ActualSize.X / 2f + m_spacing / 2f;
167 float y12 = ActualSize.Y / 2f + m_spacing / 2f;
168 float x13 = ActualSize.X / 2f - m_spacing / 2f;
169 float y13 = ActualSize.Y;
170 float y14 = ActualSize.Y / 2f - m_spacing / 2f;
171 float num4 = 0.5f;
172 ArrangeChildWidgetInCell(new Vector2(x10, y10), new Vector2(x10, y10) + new Vector2(x13, y13) / num4, Children[0]);
173 if (Children[0] is GameWidget gameWidget0) {
174 gameWidget0.LayoutTransform = Matrix.CreateScale(num4, num4, 1f);
175 ContainerWidget guiWidget = gameWidget0.GuiWidget;
176 guiWidget.MarginLeft = marginLeft / num4;
177 guiWidget.MarginTop = 0f;
178 guiWidget.MarginRight = 0f;
179 guiWidget.MarginBottom = 0f;
180 }
181 ArrangeChildWidgetInCell(new Vector2(x11, y11), new Vector2(x11, y11) + new Vector2(x13, y14) / num4, Children[1]);
182 if (Children[1] is GameWidget gameWidget1) {
183 gameWidget1.LayoutTransform = Matrix.CreateScale(num4, num4, 1f);
184 ContainerWidget guiWidget = gameWidget1.GuiWidget;
185 guiWidget.MarginLeft = 0f;
186 guiWidget.MarginTop = 0f;
187 guiWidget.MarginRight = marginRight / num4;
188 guiWidget.MarginBottom = 0f;
189 }
190 ArrangeChildWidgetInCell(new Vector2(x12, y12), new Vector2(x12, y12) + new Vector2(x13, y14) / num4, Children[2]);
191 if (Children[2] is GameWidget gameWidget2) {
192 gameWidget2.LayoutTransform = Matrix.CreateScale(num4, num4, 1f);
193 ContainerWidget guiWidget = gameWidget2.GuiWidget;
194 guiWidget.MarginLeft = 0f;
195 guiWidget.MarginTop = 0f;
196 guiWidget.MarginRight = marginRight / num4;
197 guiWidget.MarginBottom = 0f;
198 }
199 }
200 if (SettingsManager.ScreenLayout3 == ScreenLayout.TripleHorizontal) {
201 float x14 = 0f;
202 float y15 = 0f;
203 float x15 = 0f;
204 float y16 = ActualSize.Y / 2f + m_spacing / 2f;
205 float x16 = ActualSize.X / 2f + m_spacing / 2f;
206 float y17 = ActualSize.Y / 2f + m_spacing / 2f;
207 float x17 = ActualSize.X;
208 float x18 = ActualSize.X / 2f - m_spacing / 2f;
209 float y18 = ActualSize.Y / 2f - m_spacing / 2f;
210 float num5 = 0.5f;
211 ArrangeChildWidgetInCell(new Vector2(x14, y15), new Vector2(x14, y15) + new Vector2(x17, y18) / num5, Children[0]);
212 if (Children[0] is GameWidget gameWidget0) {
213 gameWidget0.LayoutTransform = Matrix.CreateScale(num5, num5, 1f);
214 ContainerWidget guiWidget = gameWidget0.GuiWidget;
215 guiWidget.MarginLeft = marginLeft / num5;
216 guiWidget.MarginTop = 0f;
217 guiWidget.MarginRight = marginRight / num5;
218 guiWidget.MarginBottom = 0f;
219 }
220 ArrangeChildWidgetInCell(new Vector2(x15, y16), new Vector2(x15, y16) + new Vector2(x18, y18) / num5, Children[1]);
221 if (Children[1] is GameWidget gameWidget1) {
222 gameWidget1.LayoutTransform = Matrix.CreateScale(num5, num5, 1f);
223 ContainerWidget guiWidget = gameWidget1.GuiWidget;
224 guiWidget.MarginLeft = marginLeft / num5;
225 guiWidget.MarginTop = 0f;
226 guiWidget.MarginRight = 0f;
227 guiWidget.MarginBottom = 0f;
228 }
229 ArrangeChildWidgetInCell(new Vector2(x16, y17), new Vector2(x16, y17) + new Vector2(x18, y18) / num5, Children[2]);
230 if (Children[2] is GameWidget gameWidget2) {
231 gameWidget2.LayoutTransform = Matrix.CreateScale(num5, num5, 1f);
232 ContainerWidget guiWidget = gameWidget2.GuiWidget;
233 guiWidget.MarginLeft = 0f;
234 guiWidget.MarginTop = 0f;
235 guiWidget.MarginRight = marginRight / num5;
236 guiWidget.MarginBottom = 0f;
237 }
238 }
239 if (SettingsManager.ScreenLayout3 == ScreenLayout.TripleEven) {
240 float x19 = 0f;
241 float y19 = 0f;
242 float x20 = ActualSize.X / 2f + m_spacing / 2f;
243 float y20 = 0f;
244 float x21 = ActualSize.X / 4f + m_spacing / 4f;
245 float y21 = ActualSize.Y / 2f + m_spacing / 2f;
246 float x22 = ActualSize.X / 2f - m_spacing / 2f;
247 float y22 = ActualSize.Y / 2f - m_spacing / 2f;
248 float num6 = 0.5f;
249 ArrangeChildWidgetInCell(new Vector2(x19, y19), new Vector2(x19, y19) + new Vector2(x22, y22) / num6, Children[0]);
250 if (Children[0] is GameWidget gameWidget0) {
251 gameWidget0.LayoutTransform = Matrix.CreateScale(num6, num6, 1f);
252 ContainerWidget guiWidget = gameWidget0.GuiWidget;
253 guiWidget.MarginLeft = marginLeft / num6;
254 guiWidget.MarginTop = 0f;
255 guiWidget.MarginRight = 0f;
256 guiWidget.MarginBottom = 0f;
257 }
258 ArrangeChildWidgetInCell(new Vector2(x20, y20), new Vector2(x20, y20) + new Vector2(x22, y22) / num6, Children[1]);
259 if (Children[1] is GameWidget gameWidget1) {
260 gameWidget1.LayoutTransform = Matrix.CreateScale(num6, num6, 1f);
261 ContainerWidget guiWidget = gameWidget1.GuiWidget;
262 guiWidget.MarginLeft = 0f;
263 guiWidget.MarginTop = 0f;
264 guiWidget.MarginRight = marginRight / num6;
265 guiWidget.MarginBottom = 0f;
266 }
267 ArrangeChildWidgetInCell(new Vector2(x21, y21), new Vector2(x21, y21) + new Vector2(x22, y22) / num6, Children[2]);
268 if (Children[2] is GameWidget gameWidget2) {
269 gameWidget2.LayoutTransform = Matrix.CreateScale(num6, num6, 1f);
270 ContainerWidget guiWidget = gameWidget2.GuiWidget;
271 guiWidget.MarginLeft = 0f;
272 guiWidget.MarginTop = 0f;
273 guiWidget.MarginRight = 0f;
274 guiWidget.MarginBottom = 0f;
275 }
276 }
277 if (SettingsManager.ScreenLayout3 == ScreenLayout.TripleOpposite) {
278 float x23 = 0f;
279 float y23 = 0f;
280 float x24 = ActualSize.X / 2f + m_spacing / 2f;
281 float y24 = 0f;
282 float x25 = ActualSize.X / 2f + m_spacing / 2f;
283 float y25 = ActualSize.Y / 2f + m_spacing / 2f;
284 float x26 = ActualSize.X / 2f - m_spacing / 2f;
285 float y26 = ActualSize.Y;
286 float y27 = ActualSize.Y / 2f - m_spacing / 2f;
287 float num7 = 0.5f;
288 ArrangeChildWidgetInCell(new Vector2(x23, y23), new Vector2(x23, y23) + new Vector2(x26, y26) / num7, Children[0]);
289 if (Children[0] is GameWidget gameWidget0) {
290 gameWidget0.LayoutTransform = new Matrix(
291 0f,
292 num7,
293 0f,
294 0f,
295 0f - num7,
296 0f,
297 0f,
298 0f,
299 0f,
300 0f,
301 1f,
302 0f,
303 0f,
304 0f,
305 0f,
306 1f
307 );
308 ContainerWidget guiWidget = gameWidget0.GuiWidget;
309 guiWidget.MarginLeft = 0f;
310 guiWidget.MarginTop = 0f;
311 guiWidget.MarginRight = 0f;
312 guiWidget.MarginBottom = marginLeft / num7;
313 }
314 ArrangeChildWidgetInCell(new Vector2(x24, y24), new Vector2(x24, y24) + new Vector2(x26, y27) / num7, Children[1]);
315 if (Children[1] is GameWidget gameWidget1) {
316 gameWidget1.LayoutTransform = new Matrix(
317 0f - num7,
318 0f,
319 0f,
320 0f,
321 0f,
322 0f - num7,
323 0f,
324 0f,
325 0f,
326 0f,
327 1f,
328 0f,
329 0f,
330 0f,
331 0f,
332 1f
333 );
334 ContainerWidget guiWidget = gameWidget1.GuiWidget;
335 guiWidget.MarginLeft = marginRight / num7;
336 guiWidget.MarginTop = 0f;
337 guiWidget.MarginRight = 0f;
338 guiWidget.MarginBottom = 0f;
339 }
340 ArrangeChildWidgetInCell(new Vector2(x25, y25), new Vector2(x25, y25) + new Vector2(x26, y27) / num7, Children[2]);
341 if (Children[2] is GameWidget gameWidget2) {
342 gameWidget2.LayoutTransform = new Matrix(
343 num7,
344 0f,
345 0f,
346 0f,
347 0f,
348 num7,
349 0f,
350 0f,
351 0f,
352 0f,
353 1f,
354 0f,
355 0f,
356 0f,
357 0f,
358 1f
359 );
360 ContainerWidget guiWidget = gameWidget2.GuiWidget;
361 guiWidget.MarginLeft = 0f;
362 guiWidget.MarginTop = 0f;
363 guiWidget.MarginRight = marginRight / num7;
364 guiWidget.MarginBottom = 0f;
365 }
366 }
367 }
368 else if (Children.Count == 4) {
369 if (SettingsManager.ScreenLayout4 == ScreenLayout.Quadruple) {
370 m_spacing = 12f;
371 m_bevel = 3f;
372 float x27 = 0f;
373 float y28 = 0f;
374 float x28 = ActualSize.X / 2f + m_spacing / 2f;
375 float y29 = 0f;
376 float x29 = 0f;
377 float y30 = ActualSize.Y / 2f + m_spacing / 2f;
378 float x30 = ActualSize.X / 2f + m_spacing / 2f;
379 float y31 = ActualSize.Y / 2f + m_spacing / 2f;
380 float x31 = ActualSize.X / 2f - m_spacing / 2f;
381 float y32 = ActualSize.Y / 2f - m_spacing / 2f;
382 float num8 = 0.5f;
383 ArrangeChildWidgetInCell(new Vector2(x27, y28), new Vector2(x27, y28) + new Vector2(x31, y32) / num8, Children[0]);
384 if (Children[0] is GameWidget gameWidget0) {
385 gameWidget0.LayoutTransform = Matrix.CreateScale(num8, num8, 1f);
386 ContainerWidget guiWidget = gameWidget0.GuiWidget;
387 guiWidget.MarginLeft = marginLeft / num8;
388 guiWidget.MarginTop = 0f;
389 guiWidget.MarginRight = 0f;
390 guiWidget.MarginBottom = 0f;
391 }
392 ArrangeChildWidgetInCell(new Vector2(x28, y29), new Vector2(x28, y29) + new Vector2(x31, y32) / num8, Children[1]);
393 if (Children[1] is GameWidget gameWidget1) {
394 gameWidget1.LayoutTransform = Matrix.CreateScale(num8, num8, 1f);
395 ContainerWidget guiWidget = gameWidget1.GuiWidget;
396 guiWidget.MarginLeft = 0f;
397 guiWidget.MarginTop = 0f;
398 guiWidget.MarginRight = marginRight / num8;
399 guiWidget.MarginBottom = 0f;
400 }
401 ArrangeChildWidgetInCell(new Vector2(x29, y30), new Vector2(x29, y30) + new Vector2(x31, y32) / num8, Children[2]);
402 if (Children[2] is GameWidget gameWidget2) {
403 gameWidget2.LayoutTransform = Matrix.CreateScale(num8, num8, 1f);
404 ContainerWidget guiWidget = gameWidget2.GuiWidget;
405 guiWidget.MarginLeft = marginLeft / num8;
406 guiWidget.MarginTop = 0f;
407 guiWidget.MarginRight = 0f;
408 guiWidget.MarginBottom = 0f;
409 }
410 ArrangeChildWidgetInCell(new Vector2(x30, y31), new Vector2(x30, y31) + new Vector2(x31, y32) / num8, Children[3]);
411 if (Children[3] is GameWidget gameWidget3) {
412 gameWidget3.LayoutTransform = Matrix.CreateScale(num8, num8, 1f);
413 ContainerWidget guiWidget = gameWidget3.GuiWidget;
414 guiWidget.MarginLeft = 0f;
415 guiWidget.MarginTop = 0f;
416 guiWidget.MarginRight = marginRight / num8;
417 guiWidget.MarginBottom = 0f;
418 }
419 }
420 if (SettingsManager.ScreenLayout4 == ScreenLayout.QuadrupleOpposite) {
421 m_spacing = 12f;
422 m_bevel = 3f;
423 float x32 = 0f;
424 float y33 = 0f;
425 float x33 = ActualSize.X / 2f + m_spacing / 2f;
426 float y34 = 0f;
427 float x34 = 0f;
428 float y35 = ActualSize.Y / 2f + m_spacing / 2f;
429 float x35 = ActualSize.X / 2f + m_spacing / 2f;
430 float y36 = ActualSize.Y / 2f + m_spacing / 2f;
431 float x36 = ActualSize.X / 2f - m_spacing / 2f;
432 float y37 = ActualSize.Y / 2f - m_spacing / 2f;
433 float num9 = 0.5f;
434 ArrangeChildWidgetInCell(new Vector2(x32, y33), new Vector2(x32, y33) + new Vector2(x36, y37) / num9, Children[0]);
435 if (Children[0] is GameWidget gameWidget0) {
436 gameWidget0.LayoutTransform = new Matrix(
437 0f - num9,
438 0f,
439 0f,
440 0f,
441 0f,
442 0f - num9,
443 0f,
444 0f,
445 0f,
446 0f,
447 1f,
448 0f,
449 0f,
450 0f,
451 0f,
452 1f
453 );
454 ContainerWidget guiWidget = gameWidget0.GuiWidget;
455 guiWidget.MarginLeft = 0f;
456 guiWidget.MarginTop = 0f;
457 guiWidget.MarginRight = marginLeft / num9;
458 guiWidget.MarginBottom = 0f;
459 }
460 ArrangeChildWidgetInCell(new Vector2(x33, y34), new Vector2(x33, y34) + new Vector2(x36, y37) / num9, Children[1]);
461 if (Children[1] is GameWidget gameWidget1) {
462 gameWidget1.LayoutTransform = new Matrix(
463 0f - num9,
464 0f,
465 0f,
466 0f,
467 0f,
468 0f - num9,
469 0f,
470 0f,
471 0f,
472 0f,
473 1f,
474 0f,
475 0f,
476 0f,
477 0f,
478 1f
479 );
480 ContainerWidget guiWidget = gameWidget1.GuiWidget;
481 guiWidget.MarginLeft = marginRight / num9;
482 guiWidget.MarginTop = 0f;
483 guiWidget.MarginRight = 0f;
484 guiWidget.MarginBottom = 0f;
485 }
486 ArrangeChildWidgetInCell(new Vector2(x34, y35), new Vector2(x34, y35) + new Vector2(x36, y37) / num9, Children[2]);
487 if (Children[2] is GameWidget gameWidget2) {
488 gameWidget2.LayoutTransform = new Matrix(
489 num9,
490 0f,
491 0f,
492 0f,
493 0f,
494 num9,
495 0f,
496 0f,
497 0f,
498 0f,
499 1f,
500 0f,
501 0f,
502 0f,
503 0f,
504 1f
505 );
506 ContainerWidget guiWidget = gameWidget2.GuiWidget;
507 guiWidget.MarginLeft = marginLeft / num9;
508 guiWidget.MarginTop = 0f;
509 guiWidget.MarginRight = 0f;
510 guiWidget.MarginBottom = 0f;
511 }
512 ArrangeChildWidgetInCell(new Vector2(x35, y36), new Vector2(x35, y36) + new Vector2(x36, y37) / num9, Children[3]);
513 if (Children[3] is GameWidget gameWidget3) {
514 gameWidget3.LayoutTransform = new Matrix(
515 num9,
516 0f,
517 0f,
518 0f,
519 0f,
520 num9,
521 0f,
522 0f,
523 0f,
524 0f,
525 1f,
526 0f,
527 0f,
528 0f,
529 0f,
530 1f
531 );
532 ContainerWidget guiWidget = gameWidget3.GuiWidget;
533 guiWidget.MarginLeft = 0f;
534 guiWidget.MarginTop = 0f;
535 guiWidget.MarginRight = marginRight / num9;
536 guiWidget.MarginBottom = 0f;
537 }
538 }
539 }
540 else if (Children.Count > SubsystemPlayers.MaxPlayers) {
541 throw new InvalidOperationException("Too many GameWidgets.");
542 }
543 }
544
545 public override void Overdraw(DrawContext dc) {
546 Color color = new Color(181, 172, 154) * GlobalColorTransform;
547 float num = 0.6f;
548 float directionalLight = 0.4f;
549 FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch();
550 int count = flatBatch2D.TriangleVertices.Count;
551 if (Children.Count == 2) {
552 if (SettingsManager.ScreenLayout2 == ScreenLayout.DoubleVertical
553 || SettingsManager.ScreenLayout2 == ScreenLayout.DoubleOpposite) {
554 Vector2 c = new(ActualSize.X / 2f - m_spacing / 2f, -100f);
555 Vector2 c2 = new(ActualSize.X / 2f + m_spacing / 2f, ActualSize.Y + 100f);
557 null,
558 flatBatch2D,
559 c,
560 c2,
561 0f,
562 m_bevel,
563 color,
564 color,
566 num,
567 directionalLight,
568 0f
569 );
570 }
571 if (SettingsManager.ScreenLayout2 == ScreenLayout.DoubleHorizontal) {
572 Vector2 c3 = new(-100f, ActualSize.Y / 2f - m_spacing / 2f);
573 Vector2 c4 = new(ActualSize.X + 100f, ActualSize.Y / 2f + m_spacing / 2f);
575 null,
576 flatBatch2D,
577 c3,
578 c4,
579 0f,
580 m_bevel,
581 color,
582 color,
584 num,
585 directionalLight,
586 0f
587 );
588 }
589 }
590 else if (Children.Count == 3) {
591 if (SettingsManager.ScreenLayout3 == ScreenLayout.TripleVertical
592 || SettingsManager.ScreenLayout3 == ScreenLayout.TripleOpposite) {
593 float x = -100f;
594 float x2 = ActualSize.X / 2f - m_spacing / 2f + m_bevel;
595 float x3 = ActualSize.X / 2f + m_spacing / 2f - m_bevel;
596 float x4 = ActualSize.X + 100f;
597 float y = -100f;
598 float y2 = ActualSize.Y / 2f - m_spacing / 2f + m_bevel;
599 float y3 = ActualSize.Y / 2f + m_spacing / 2f - m_bevel;
600 float y4 = ActualSize.Y + 100f;
602 null,
603 flatBatch2D,
604 new Vector2(x, y),
605 new Vector2(x2, y4),
606 0f,
607 0f - m_bevel,
609 color,
611 num,
612 directionalLight,
613 0f
614 );
616 null,
617 flatBatch2D,
618 new Vector2(x3, y),
619 new Vector2(x4, y2),
620 0f,
621 0f - m_bevel,
623 color,
625 num,
626 directionalLight,
627 0f
628 );
630 null,
631 flatBatch2D,
632 new Vector2(x3, y3),
633 new Vector2(x4, y4),
634 0f,
635 0f - m_bevel,
637 color,
639 num,
640 directionalLight,
641 0f
642 );
643 Color color2 = color * new Color(num, num, num, 1f);
644 flatBatch2D.QueueQuad(new Vector2(x2, y), new Vector2(x3, y4), 0f, color2);
645 flatBatch2D.QueueQuad(new Vector2(x3, y2), new Vector2(x4, y3), 0f, color2);
646 }
647 if (SettingsManager.ScreenLayout3 == ScreenLayout.TripleHorizontal) {
648 float x5 = -100f;
649 float x6 = ActualSize.X / 2f - m_spacing / 2f + m_bevel;
650 float x7 = ActualSize.X / 2f + m_spacing / 2f - m_bevel;
651 float x8 = ActualSize.X + 100f;
652 float y5 = -100f;
653 float y6 = ActualSize.Y / 2f - m_spacing / 2f + m_bevel;
654 float y7 = ActualSize.Y / 2f + m_spacing / 2f - m_bevel;
655 float y8 = ActualSize.Y + 100f;
657 null,
658 flatBatch2D,
659 new Vector2(x5, y5),
660 new Vector2(x8, y6),
661 0f,
662 0f - m_bevel,
664 color,
666 num,
667 directionalLight,
668 0f
669 );
671 null,
672 flatBatch2D,
673 new Vector2(x5, y7),
674 new Vector2(x6, y8),
675 0f,
676 0f - m_bevel,
678 color,
680 num,
681 directionalLight,
682 0f
683 );
685 null,
686 flatBatch2D,
687 new Vector2(x7, y7),
688 new Vector2(x8, y8),
689 0f,
690 0f - m_bevel,
692 color,
694 num,
695 directionalLight,
696 0f
697 );
698 Color color3 = color * new Color(num, num, num, 1f);
699 flatBatch2D.QueueQuad(new Vector2(x5, y6), new Vector2(x8, y7), 0f, color3);
700 flatBatch2D.QueueQuad(new Vector2(x6, y7), new Vector2(x7, y8), 0f, color3);
701 }
702 if (SettingsManager.ScreenLayout3 == ScreenLayout.TripleEven) {
703 float x9 = -100f;
704 float x10 = ActualSize.X / 2f - m_spacing / 2f + m_bevel;
705 float x11 = ActualSize.X / 2f + m_spacing / 2f - m_bevel;
706 float x12 = ActualSize.X + 100f;
707 float x13 = ActualSize.X / 4f;
708 float x14 = ActualSize.X * 3f / 4f;
709 float y9 = -100f;
710 float y10 = ActualSize.Y / 2f - m_spacing / 2f + m_bevel;
711 float y11 = ActualSize.Y / 2f + m_spacing / 2f - m_bevel;
712 float y12 = ActualSize.Y + 100f;
714 null,
715 flatBatch2D,
716 new Vector2(x9, y9),
717 new Vector2(x10, y10),
718 0f,
719 0f - m_bevel,
721 color,
723 num,
724 directionalLight,
725 0f
726 );
728 null,
729 flatBatch2D,
730 new Vector2(x11, y9),
731 new Vector2(x12, y10),
732 0f,
733 0f - m_bevel,
735 color,
737 num,
738 directionalLight,
739 0f
740 );
742 null,
743 flatBatch2D,
744 new Vector2(x13, y11),
745 new Vector2(x14, y12),
746 0f,
747 0f - m_bevel,
749 color,
751 num,
752 directionalLight,
753 0f
754 );
755 Color color4 = color * new Color(num, num, num, 1f);
756 flatBatch2D.QueueQuad(new Vector2(x10, y9), new Vector2(x11, y10), 0f, color4);
757 flatBatch2D.QueueQuad(new Vector2(x9, y10), new Vector2(x12, y11), 0f, color4);
758 flatBatch2D.QueueQuad(new Vector2(x9, y11), new Vector2(x13, y12), 0f, color4);
759 flatBatch2D.QueueQuad(new Vector2(x14, y11), new Vector2(x12, y12), 0f, color4);
760 }
761 }
762 else if (Children.Count == 4) {
763 float x15 = -100f;
764 float x16 = ActualSize.X / 2f - m_spacing / 2f + m_bevel;
765 float x17 = ActualSize.X / 2f + m_spacing / 2f - m_bevel;
766 float x18 = ActualSize.X + 100f;
767 float y13 = -100f;
768 float y14 = ActualSize.Y / 2f - m_spacing / 2f + m_bevel;
769 float y15 = ActualSize.Y / 2f + m_spacing / 2f - m_bevel;
770 float y16 = ActualSize.Y + 100f;
772 null,
773 flatBatch2D,
774 new Vector2(x15, y13),
775 new Vector2(x16, y14),
776 0f,
777 0f - m_bevel,
779 color,
781 num,
782 directionalLight,
783 0f
784 );
786 null,
787 flatBatch2D,
788 new Vector2(x17, y13),
789 new Vector2(x18, y14),
790 0f,
791 0f - m_bevel,
793 color,
795 num,
796 directionalLight,
797 0f
798 );
800 null,
801 flatBatch2D,
802 new Vector2(x15, y15),
803 new Vector2(x16, y16),
804 0f,
805 0f - m_bevel,
807 color,
809 num,
810 directionalLight,
811 0f
812 );
814 null,
815 flatBatch2D,
816 new Vector2(x17, y15),
817 new Vector2(x18, y16),
818 0f,
819 0f - m_bevel,
820 Children.Count == 3 ? color : Color.Transparent,
821 color,
823 num,
824 directionalLight,
825 0f
826 );
827 Color color5 = color * new Color(num, num, num, 1f);
828 flatBatch2D.QueueQuad(new Vector2(x16, y13), new Vector2(x17, y16), 0f, color5);
829 flatBatch2D.QueueQuad(new Vector2(x15, y14), new Vector2(x18, y15), 0f, color5);
830 }
831 else if (Children.Count > 4) {
832 throw new InvalidOperationException("Too many GameWidgets.");
833 }
834 flatBatch2D.TransformTriangles(GlobalTransform, count);
835 }
836 }
837}
Engine.Color Color
readonly DynamicArray< VertexPositionColor > TriangleVertices
void TransformTriangles(Matrix matrix, int start=0, int end=-1)
void QueueQuad(Vector2 corner1, Vector2 corner2, float depth, Color color)
FlatBatch2D FlatBatch(int layer=0, DepthStencilState depthStencilState=null, RasterizerState rasterizerState=null, BlendState blendState=null)
static Point2 Size
static void QueueBevelledRectangle(TexturedBatch2D texturedBatch, FlatBatch2D flatBatch, Vector2 c1, Vector2 c2, float depth, float bevelSize, Color color, Color bevelColor, Color shadowColor, float ambientLight, float directionalLight, float textureScale)
readonly WidgetsList Children
static void ArrangeChildWidgetInCell(Vector2 c1, Vector2 c2, Widget widget)
override void MeasureOverride(Vector2 parentAvailableSize)
override void ArrangeOverride()
override void Overdraw(DrawContext dc)
static ScreenLayout ScreenLayout2
static ScreenLayout ScreenLayout4
static ScreenLayout ScreenLayout3
static ScreenLayout ScreenLayout1
readonly PrimitivesRenderer2D PrimitivesRenderer2D
Color GlobalColorTransform
bool IsOverdrawRequired
Vector2 ActualSize
Matrix GlobalTransform
static Color Transparent
定义 Color.cs:5
static readonly Matrix Identity
static Matrix CreateScale(float scale)
static readonly Vector2 Zero