-
Notifications
You must be signed in to change notification settings - Fork 0
/
SceneCreator.cs
1033 lines (836 loc) · 40.1 KB
/
SceneCreator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SFML.System;
using SFML.Graphics;
using SFML.Window;
using TGUI;
using System.Globalization;
namespace SandySharp
{
class SceneCreator
{
RenderWindow window;
Scene scene;
//Лист, содержащий все добавленные пользователем симуляции
List<Simulation> simulations;
//LAYERS
Image image;
Image flame_field;
Image fire_field;
//UI
Panel originPanel;
Panel mainPanel;
Panel sandSimulationPanel;
Panel liquidSimulationPanel;
Panel fireSimulationPanel;
Panel flameSimulationPanel;
Panel lightningSimulationPanel;
Panel rainSimulationPanel;
Panel currentToolPanel;
ListBox AddedSimsList;
int colorNameIterator=0;
Label originLabel;
static SceneCreator Instance;
#region Singleton
public static SceneCreator instance()
{
if (Instance == null) Instance = new SceneCreator();
return Instance;
}
#endregion
public void start(RenderWindow _window)
{
window = _window;
mainPanel = new Panel();
originPanel = new Panel();
image = new Image(160, 120, Color.Transparent);
fire_field = new Image(160, 120, Color.Transparent);
flame_field = new Image(160, 120, Color.Transparent);
simulations = new List<Simulation>();
}
public Scene createScene()
{
bool sceneCreated = false;
//GUI
Gui SC_gui = new Gui(window);
mainPanel.Renderer.BackgroundColor = Color.Black;
mainPanel.Renderer.BorderColor = Color.White;
mainPanel.PositionLayout = new Layout2d("2.5%", "5%");
mainPanel.SizeLayout = new Layout2d("95%", "90%");
mainPanel.Renderer.Borders = new Outline(5, 5, 5, 5);
Button createButton = new Button("CREATE");
createButton.Clicked += (e, a) => { sceneCreated = true; };
createButton.PositionLayout = new Layout2d("80%", "90%");
mainPanel.Add(createButton);
SC_gui.Add(mainPanel);
//SIMULATIONS GUI
Panel simulationsPanel = new Panel();
simulationsPanel.Renderer.BackgroundColor = Color.Black;
simulationsPanel.Renderer.BorderColor = Color.White;
simulationsPanel.PositionLayout = new Layout2d("3%", "5%");
simulationsPanel.SizeLayout = new Layout2d("25%", "80%");
simulationsPanel.Renderer.Borders = new Outline(2, 2, 2, 2);
Panel AddedSimuationsPanel = new Panel(simulationsPanel);
AddedSimuationsPanel.PositionLayout = new Layout2d("73%", "5%");
//origin widgets
originPanel.Renderer.BackgroundColor = Color.Black;
originPanel.Renderer.BorderColor = Color.White;
originPanel.PositionLayout = new Layout2d("30.5%", "5%");
originPanel.SizeLayout = new Layout2d("40%", "80%");
originPanel.Renderer.Borders = new Outline(2, 2, 2, 2);
originLabel = new Label();
originLabel.Renderer.TextColor = Color.White;
Label SimulationsNote = new Label("Simulations: ");
SimulationsNote.Renderer = originLabel.Renderer;
SimulationsNote.PositionLayout = new Layout2d("3%", "1%");
Label AddedSimulationsNote = new Label("Added: ");
AddedSimulationsNote.Renderer = originLabel.Renderer;
AddedSimulationsNote.PositionLayout = new Layout2d("73%", "1%");
mainPanel.Add(SimulationsNote);
mainPanel.Add(AddedSimulationsNote);
mainPanel.Add(simulationsPanel);
mainPanel.Add(AddedSimuationsPanel);
/////LAYER CREATING/////////
image = Pixy.drawBorder(image);
RenderObject picture = new RenderObject(image);
RenderObject flame_picture = new RenderObject(flame_field);
RenderObject fire_picture = new RenderObject(fire_field);
Layer main_layer = new Layer(1, "main");
Layer Fire_layer = new Layer(2, "fire_layer");
Layer flame_layer = new Layer(3, "flame_layer");
scene = new Scene(window);
main_layer.setLayerRenderObject(picture);
Fire_layer.setLayerRenderObject(fire_picture);
flame_layer.setLayerRenderObject(flame_picture);
scene.AddLayer(main_layer);
scene.AddLayer(Fire_layer);
scene.AddLayer(flame_layer);
//SIMULATION CREATING PANELS
SandSimulationPanelInit();
LiquidSimulationPanelInit();
FireSimulationPanelInit();
flameSimulationPanelInit();
lightningSimulationPanelInit();
rainSimulationPanelInit();
AddedSimsList = new ListBox();
AddedSimsList.SizeLayout = new Layout2d("100%", "100%");
AddedSimuationsPanel.Add(AddedSimsList);
ListBox SimulationsList = new ListBox();
SimulationsList.AddItem("Sand Simulation", "Sand Simulation");
SimulationsList.AddItem("Liquid Simulation", "Liquid Simulation");
SimulationsList.AddItem("Fire Simulation", "Fire Simulation");
SimulationsList.AddItem("Flame Simulation", "Flame Simulation");
SimulationsList.AddItem("Lightning Simulation", "Lightning Simulation");
SimulationsList.AddItem("Rain Simulation", "Rain Simulation");
SimulationsList.ItemSelected += (e, a) =>
{
switch (SimulationsList.GetSelectedItemId())
{
case ("Sand Simulation"):
currentToolPanel.Visible = false;
currentToolPanel = sandSimulationPanel;
currentToolPanel.Visible = true;
break;
case ("Liquid Simulation"):
currentToolPanel.Visible = false;
currentToolPanel = liquidSimulationPanel;
currentToolPanel.Visible = true;
break;
case ("Fire Simulation"):
currentToolPanel.Visible = false;
currentToolPanel = fireSimulationPanel;
currentToolPanel.Visible = true;
break;
case ("Flame Simulation"):
currentToolPanel.Visible = false;
currentToolPanel = flameSimulationPanel;
currentToolPanel.Visible = true;
break;
case ("Lightning Simulation"):
currentToolPanel.Visible = false;
currentToolPanel = lightningSimulationPanel;
currentToolPanel.Visible = true;
break;
case ("Rain Simulation"):
currentToolPanel.Visible = false;
currentToolPanel = rainSimulationPanel;
currentToolPanel.Visible = true;
break;
}
};
simulationsPanel.Add(SimulationsList);
while (window.IsOpen && !sceneCreated)
{
window.DispatchEvents();
window.Clear(SFML.Graphics.Color.Black);
//Draw here
SC_gui.Draw();
window.Display();
}
//Scene created!
foreach(var obj in simulations)
{
scene.AddObject(obj);
}
SC_gui.RemoveAllWidgets();
return scene;
}
private void SandSimulationPanelInit()
{
sandSimulationPanel = new Panel(originPanel);
int r = 255, g = 255, b = 255;
Panel colorPick = new Panel();
colorPick.SizeLayout = new Layout2d("10%", "7%");
colorPick.PositionLayout = new Layout2d("80%", "5%");
EditBox red = new EditBox();
red.PositionLayout = new Layout2d("5%", "5%");
red.MaximumCharacters = 3;
red.SizeLayout = new Layout2d("20%", "7%");
red.DefaultText = "255";
EditBox green = new EditBox(red);
green.PositionLayout = new Layout2d("30%", "5%");
EditBox blue = new EditBox(red);
blue.PositionLayout = new Layout2d("55%", "5%");
EditBox Name = new EditBox();
Name.PositionLayout = new Layout2d("5%%", "18%");
Name.SizeLayout = new Layout2d("60%", "7%");
Name.Text = "SandSim";
Name.SetSelectedText(0, 0);
Name.MaximumCharacters = 10;
sandSimulationPanel.Add(Name);
red.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
green.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
blue.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
sandSimulationPanel.Add(red);
sandSimulationPanel.Add(green);
sandSimulationPanel.Add(blue);
sandSimulationPanel.Add(colorPick);
Button AddSandSim = new Button("Add");
AddSandSim.PositionLayout = new Layout2d("70%", "90%");
AddSandSim.Clicked += (e, a) => {
Color sandColor = new Color((byte)r, (byte)g, (byte)b);
Console.WriteLine(sandColor);
simulations.Add(new SandSimulation(sandColor, image, Name.Text));
scene.AddColor(Name.Text+(colorNameIterator++), sandColor);
updateSimsList();
};
sandSimulationPanel.Add(AddSandSim);
mainPanel.Add(sandSimulationPanel);
sandSimulationPanel.Visible = false;
currentToolPanel = sandSimulationPanel;
//notes
Label colorMainNote = new Label("Main color");
colorMainNote.Renderer = originLabel.Renderer;
colorMainNote.PositionLayout = new Layout2d("5%", "0%");
Label nameNote = new Label("Name");
nameNote.Renderer = originLabel.Renderer;
nameNote.PositionLayout = new Layout2d("5%", "13%");
sandSimulationPanel.Add(nameNote);
sandSimulationPanel.Add(colorMainNote);
}
private void LiquidSimulationPanelInit()
{
liquidSimulationPanel = new Panel(originPanel);
int r = 48, g = 158, b = 252;
Panel colorPick = new Panel();
colorPick.SizeLayout = new Layout2d("10%", "7%");
colorPick.PositionLayout = new Layout2d("80%", "5%");
EditBox red = new EditBox();
red.PositionLayout = new Layout2d("5%", "5%");
red.MaximumCharacters = 3;
red.SizeLayout = new Layout2d("20%", "7%");
red.DefaultText = "255";
EditBox green = new EditBox(red);
green.PositionLayout = new Layout2d("30%", "5%");
EditBox blue = new EditBox(red);
blue.PositionLayout = new Layout2d("55%", "5%");
EditBox Name = new EditBox();
Name.PositionLayout = new Layout2d("5%%", "18%");
Name.SizeLayout = new Layout2d("60%", "7%");
Name.Text = "LiqSim";
Name.SetSelectedText(0, 0);
Name.MaximumCharacters = 10;
liquidSimulationPanel.Add(Name);
red.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
green.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
blue.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
liquidSimulationPanel.Add(red);
liquidSimulationPanel.Add(green);
liquidSimulationPanel.Add(blue);
liquidSimulationPanel.Add(colorPick);
Button AddliquidSim = new Button("Add");
AddliquidSim.PositionLayout = new Layout2d("70%", "90%");
AddliquidSim.Clicked += (e, a) => {
Color liquidColor = new Color((byte)r, (byte)g, (byte)b);
Console.WriteLine("Simulation added with color: "+liquidColor);
simulations.Add(new LiquidSimulation(liquidColor, image, Name.Text));
scene.AddColor(Name.Text+(colorNameIterator++), liquidColor);
updateSimsList();
};
liquidSimulationPanel.Add(AddliquidSim);
mainPanel.Add(liquidSimulationPanel);
liquidSimulationPanel.Visible = false;
//notes
Label colorMainNote = new Label("Main color");
colorMainNote.Renderer = originLabel.Renderer;
colorMainNote.PositionLayout = new Layout2d("5%", "0%");
Label nameNote = new Label("Name");
nameNote.Renderer = originLabel.Renderer;
nameNote.PositionLayout = new Layout2d("5%", "13%");
liquidSimulationPanel.Add(nameNote);
liquidSimulationPanel.Add(colorMainNote);
}
private void FireSimulationPanelInit()
{
fireSimulationPanel = new Panel(originPanel);
////MAIN COLOR////
int r = 255, g = 123, b = 15;
Panel colorPick = new Panel();
colorPick.SizeLayout = new Layout2d("10%", "7%");
colorPick.PositionLayout = new Layout2d("80%", "5%");
EditBox red = new EditBox();
red.PositionLayout = new Layout2d("5%", "5%");
red.MaximumCharacters = 3;
red.SizeLayout = new Layout2d("20%", "7%");
red.DefaultText = "255";
EditBox green = new EditBox(red);
green.PositionLayout = new Layout2d("30%", "5%");
EditBox blue = new EditBox(red);
blue.PositionLayout = new Layout2d("55%", "5%");
///////////////////
red.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
green.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
blue.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
////WOOD COLOR/////
int r1 = 92, g1 = 35, b1 = 7;
Panel colorPick1 = new Panel();
colorPick1.SizeLayout = new Layout2d("10%", "7%");
colorPick1.PositionLayout = new Layout2d("80%", "18%");
EditBox red1 = new EditBox();
red1.PositionLayout = new Layout2d("5%", "18%");
red1.MaximumCharacters = 3;
red1.SizeLayout = new Layout2d("20%", "7%");
red1.DefaultText = "255";
EditBox green1 = new EditBox(red1);
green1.PositionLayout = new Layout2d("30%", "18%");
EditBox blue1 = new EditBox(red1);
blue1.PositionLayout = new Layout2d("55%", "18%");
///////////////////
red1.TextChanged += (e, a) => {
int.TryParse(red1.Text, out r1);
int.TryParse(blue1.Text, out b1);
int.TryParse(green1.Text, out g1);
colorPick1.Renderer.BackgroundColor = new Color((byte)r1, (byte)g1, (byte)b1);
};
green1.TextChanged += (e, a) => {
int.TryParse(red1.Text, out r1);
int.TryParse(blue1.Text, out b1);
int.TryParse(green1.Text, out g1);
colorPick1.Renderer.BackgroundColor = new Color((byte)r1, (byte)g1, (byte)b1);
};
blue1.TextChanged += (e, a) => {
int.TryParse(red1.Text, out r1);
int.TryParse(blue1.Text, out b1);
int.TryParse(green1.Text, out g1);
colorPick1.Renderer.BackgroundColor = new Color((byte)r1, (byte)g1, (byte)b1);
};
////WATER COLOR////
int r2 = 48, g2 = 158, b2 = 252;
Panel colorPick2 = new Panel();
colorPick2.SizeLayout = new Layout2d("10%", "7%");
colorPick2.PositionLayout = new Layout2d("80%", "31%");
EditBox red2 = new EditBox();
red2.PositionLayout = new Layout2d("5%", "31%");
red2.MaximumCharacters = 3;
red2.SizeLayout = new Layout2d("20%", "7%");
red2.DefaultText = "255";
EditBox green2 = new EditBox(red2);
green2.PositionLayout = new Layout2d("30%", "31%");
EditBox blue2 = new EditBox(red2);
blue2.PositionLayout = new Layout2d("55%", "31%");
///////////////////
red2.TextChanged += (e, a) => {
int.TryParse(red2.Text, out r2);
int.TryParse(blue2.Text, out b2);
int.TryParse(green2.Text, out g2);
colorPick2.Renderer.BackgroundColor = new Color((byte)r2, (byte)g2, (byte)b2);
};
green2.TextChanged += (e, a) => {
int.TryParse(red2.Text, out r2);
int.TryParse(blue2.Text, out b2);
int.TryParse(green2.Text, out g2);
colorPick2.Renderer.BackgroundColor = new Color((byte)r2, (byte)g2, (byte)b2);
};
blue2.TextChanged += (e, a) => {
int.TryParse(red2.Text, out r2);
int.TryParse(blue2.Text, out b2);
int.TryParse(green2.Text, out g2);
colorPick2.Renderer.BackgroundColor = new Color((byte)r2, (byte)g2, (byte)b2);
};
/////////////////////
EditBox Name = new EditBox();
Name.PositionLayout = new Layout2d("5%%", "50%");
Name.SizeLayout = new Layout2d("60%", "7%");
Name.Text = "FireSim";
Name.SetSelectedText(0, 0);
Name.MaximumCharacters = 10;
fireSimulationPanel.Add(Name);
fireSimulationPanel.Add(red);
fireSimulationPanel.Add(green);
fireSimulationPanel.Add(blue);
fireSimulationPanel.Add(colorPick);
fireSimulationPanel.Add(red1);
fireSimulationPanel.Add(green1);
fireSimulationPanel.Add(blue1);
fireSimulationPanel.Add(colorPick1);
fireSimulationPanel.Add(red2);
fireSimulationPanel.Add(green2);
fireSimulationPanel.Add(blue2);
fireSimulationPanel.Add(colorPick2);
Button AddfireSim = new Button("Add");
AddfireSim.PositionLayout = new Layout2d("70%", "90%");
AddfireSim.Clicked += (e, a) =>
{
Color fireColor = new Color((byte)r, (byte)g, (byte)b);
Color woodColor = new Color((byte)r1, (byte)g1, (byte)b1);
Color waterColor = new Color((byte)r2, (byte)g2, (byte)b2);
Console.WriteLine("Simulation added with color: " + fireColor);
simulations.Add(new FireSimulation(fireColor,40, woodColor,40, fire_field, image, waterColor,Name.Text));
scene.AddColor(Name.Text + (colorNameIterator++), fireColor);
scene.AddColor("Wood" + (colorNameIterator++), woodColor);
updateSimsList();
};
fireSimulationPanel.Add(AddfireSim);
mainPanel.Add(fireSimulationPanel);
fireSimulationPanel.Visible = false;
//notes
Label colorMainNote = new Label("Main color");
colorMainNote.Renderer = originLabel.Renderer;
colorMainNote.PositionLayout = new Layout2d("5%", "0%");
Label colorWoodNote = new Label("Wood color");
colorWoodNote.Renderer = originLabel.Renderer;
colorWoodNote.PositionLayout = new Layout2d("5%", "13%");
Label colorWaterNote = new Label("Water color");
colorWaterNote.Renderer = originLabel.Renderer;
colorWaterNote.PositionLayout = new Layout2d("5%", "26%");
Label nameNote = new Label("Name");
nameNote.Renderer = originLabel.Renderer;
nameNote.PositionLayout = new Layout2d("5%", "45%");
fireSimulationPanel.Add(nameNote);
fireSimulationPanel.Add(colorMainNote);
fireSimulationPanel.Add(colorWaterNote);
fireSimulationPanel.Add(colorWoodNote);
}
void flameSimulationPanelInit()
{
flameSimulationPanel = new Panel(originPanel);
////MAIN COLOR////
int r = 230, g = 100, b = 10;
Panel colorPick = new Panel();
colorPick.SizeLayout = new Layout2d("10%", "7%");
colorPick.PositionLayout = new Layout2d("80%", "5%");
EditBox red = new EditBox();
red.PositionLayout = new Layout2d("5%", "5%");
red.MaximumCharacters = 3;
red.SizeLayout = new Layout2d("20%", "7%");
red.DefaultText = "255";
EditBox green = new EditBox(red);
green.PositionLayout = new Layout2d("30%", "5%");
EditBox blue = new EditBox(red);
blue.PositionLayout = new Layout2d("55%", "5%");
///////////////////
red.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
green.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
blue.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
////TRIGGER COLOR/////
int r1 = 255, g1 = 123, b1 = 15;
Panel colorPick1 = new Panel();
colorPick1.SizeLayout = new Layout2d("10%", "7%");
colorPick1.PositionLayout = new Layout2d("80%", "18%");
EditBox red1 = new EditBox();
red1.PositionLayout = new Layout2d("5%", "18%");
red1.MaximumCharacters = 3;
red1.SizeLayout = new Layout2d("20%", "7%");
red1.DefaultText = "255";
EditBox green1 = new EditBox(red1);
green1.PositionLayout = new Layout2d("30%", "18%");
EditBox blue1 = new EditBox(red1);
blue1.PositionLayout = new Layout2d("55%", "18%");
///////////////////
red1.TextChanged += (e, a) => {
int.TryParse(red1.Text, out r1);
int.TryParse(blue1.Text, out b1);
int.TryParse(green1.Text, out g1);
colorPick1.Renderer.BackgroundColor = new Color((byte)r1, (byte)g1, (byte)b1);
};
green1.TextChanged += (e, a) => {
int.TryParse(red1.Text, out r1);
int.TryParse(blue1.Text, out b1);
int.TryParse(green1.Text, out g1);
colorPick1.Renderer.BackgroundColor = new Color((byte)r1, (byte)g1, (byte)b1);
};
blue1.TextChanged += (e, a) => {
int.TryParse(red1.Text, out r1);
int.TryParse(blue1.Text, out b1);
int.TryParse(green1.Text, out g1);
colorPick1.Renderer.BackgroundColor = new Color((byte)r1, (byte)g1, (byte)b1);
};
EditBox Name = new EditBox();
Name.PositionLayout = new Layout2d("5%%", "50%");
Name.SizeLayout = new Layout2d("60%", "7%");
Name.Text = "FlameSim";
Name.SetSelectedText(0, 0);
Name.MaximumCharacters = 10;
flameSimulationPanel.Add(Name);
flameSimulationPanel.Add(red);
flameSimulationPanel.Add(green);
flameSimulationPanel.Add(blue);
flameSimulationPanel.Add(colorPick);
flameSimulationPanel.Add(red1);
flameSimulationPanel.Add(green1);
flameSimulationPanel.Add(blue1);
flameSimulationPanel.Add(colorPick1);
Button AddflameSim = new Button("Add");
AddflameSim.PositionLayout = new Layout2d("70%", "90%");
AddflameSim.Clicked += (e, a) =>
{
Color flameColor = new Color((byte)r, (byte)g, (byte)b);
Color triggerColor = new Color((byte)r1, (byte)g1, (byte)b1);
Console.WriteLine("Simulation added with color: " + flameColor);
simulations.Add(new FlameSimulation(flameColor, triggerColor, fire_field, flame_field, Name.Text));
updateSimsList();
};
flameSimulationPanel.Add(AddflameSim);
mainPanel.Add(flameSimulationPanel);
flameSimulationPanel.Visible = false;
//notes
Label colorMainNote = new Label("Main color");
colorMainNote.Renderer = originLabel.Renderer;
colorMainNote.PositionLayout = new Layout2d("5%", "0%");
Label colorTriggerNote = new Label("Trigger color");
colorTriggerNote.Renderer = originLabel.Renderer;
colorTriggerNote.PositionLayout = new Layout2d("5%", "13%");
Label nameNote = new Label("Name");
nameNote.Renderer = originLabel.Renderer;
nameNote.PositionLayout = new Layout2d("5%", "45%");
flameSimulationPanel.Add(nameNote);
flameSimulationPanel.Add(colorMainNote);
flameSimulationPanel.Add(colorTriggerNote);
}
void lightningSimulationPanelInit()
{
lightningSimulationPanel = new Panel(originPanel);
////MAIN COLOR////
int r = 15, g = 247, b = 255;
Panel colorPick = new Panel();
colorPick.SizeLayout = new Layout2d("10%", "7%");
colorPick.PositionLayout = new Layout2d("80%", "5%");
EditBox red = new EditBox();
red.PositionLayout = new Layout2d("5%", "5%");
red.MaximumCharacters = 3;
red.SizeLayout = new Layout2d("20%", "7%");
red.DefaultText = "255";
EditBox green = new EditBox(red);
green.PositionLayout = new Layout2d("30%", "5%");
EditBox blue = new EditBox(red);
blue.PositionLayout = new Layout2d("55%", "5%");
///////////////////
red.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
green.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
blue.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
////TRIGGER COLOR/////
int r1 = 255, g1 = 123, b1 = 15;
Panel colorPick1 = new Panel();
colorPick1.SizeLayout = new Layout2d("10%", "7%");
colorPick1.PositionLayout = new Layout2d("80%", "18%");
EditBox red1 = new EditBox();
red1.PositionLayout = new Layout2d("5%", "18%");
red1.MaximumCharacters = 3;
red1.SizeLayout = new Layout2d("20%", "7%");
red1.DefaultText = "255";
EditBox green1 = new EditBox(red1);
green1.PositionLayout = new Layout2d("30%", "18%");
EditBox blue1 = new EditBox(red1);
blue1.PositionLayout = new Layout2d("55%", "18%");
///////////////////
red1.TextChanged += (e, a) => {
int.TryParse(red1.Text, out r1);
int.TryParse(blue1.Text, out b1);
int.TryParse(green1.Text, out g1);
colorPick1.Renderer.BackgroundColor = new Color((byte)r1, (byte)g1, (byte)b1);
};
green1.TextChanged += (e, a) => {
int.TryParse(red1.Text, out r1);
int.TryParse(blue1.Text, out b1);
int.TryParse(green1.Text, out g1);
colorPick1.Renderer.BackgroundColor = new Color((byte)r1, (byte)g1, (byte)b1);
};
blue1.TextChanged += (e, a) => {
int.TryParse(red1.Text, out r1);
int.TryParse(blue1.Text, out b1);
int.TryParse(green1.Text, out g1);
colorPick1.Renderer.BackgroundColor = new Color((byte)r1, (byte)g1, (byte)b1);
};
EditBox Name = new EditBox();
Name.PositionLayout = new Layout2d("5%%", "50%");
Name.SizeLayout = new Layout2d("60%", "7%");
Name.Text = "LightSim";
Name.SetSelectedText(0, 0);
Name.MaximumCharacters = 10;
lightningSimulationPanel.Add(Name);
lightningSimulationPanel.Add(red);
lightningSimulationPanel.Add(green);
lightningSimulationPanel.Add(blue);
flameSimulationPanel.Add(colorPick);
lightningSimulationPanel.Add(red1);
lightningSimulationPanel.Add(green1);
lightningSimulationPanel.Add(blue1);
lightningSimulationPanel.Add(colorPick1);
Button AddlightningSim = new Button("Add");
AddlightningSim.PositionLayout = new Layout2d("70%", "90%");
AddlightningSim.Clicked += (e, a) =>
{
Color lightningColor = new Color((byte)r, (byte)g, (byte)b);
Color triggerColor = new Color((byte)r1, (byte)g1, (byte)b1);
Console.WriteLine("Simulation added with color: " + triggerColor);
simulations.Add(new LightningSimulation(lightningColor, triggerColor, fire_field, image, Name.Text));
scene.AddColor(Name.Text + (colorNameIterator++), lightningColor);
updateSimsList();
};
lightningSimulationPanel.Add(AddlightningSim);
mainPanel.Add(lightningSimulationPanel);
lightningSimulationPanel.Visible = false;
//notes
Label colorMainNote = new Label("Main color");
colorMainNote.Renderer = originLabel.Renderer;
colorMainNote.PositionLayout = new Layout2d("5%", "0%");
Label colorTriggerNote = new Label("Trigger color");
colorTriggerNote.Renderer = originLabel.Renderer;
colorTriggerNote.PositionLayout = new Layout2d("5%", "13%");
Label nameNote = new Label("Name");
nameNote.Renderer = originLabel.Renderer;
nameNote.PositionLayout = new Layout2d("5%", "45%");
lightningSimulationPanel.Add(nameNote);
lightningSimulationPanel.Add(colorMainNote);
lightningSimulationPanel.Add(colorTriggerNote);
}
void rainSimulationPanelInit()
{
rainSimulationPanel = new Panel(originPanel);
////MAIN COLOR////
int r = 48, g = 158, b = 252;
Panel colorPick = new Panel();
colorPick.SizeLayout = new Layout2d("10%", "7%");
colorPick.PositionLayout = new Layout2d("80%", "5%");
EditBox red = new EditBox();
red.PositionLayout = new Layout2d("5%", "5%");
red.MaximumCharacters = 3;
red.SizeLayout = new Layout2d("20%", "7%");
red.DefaultText = "255";
EditBox green = new EditBox(red);
green.PositionLayout = new Layout2d("30%", "5%");
EditBox blue = new EditBox(red);
blue.PositionLayout = new Layout2d("55%", "5%");
///////////////////
red.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
green.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
blue.TextChanged += (e, a) => {
int.TryParse(red.Text, out r);
int.TryParse(blue.Text, out b);
int.TryParse(green.Text, out g);
colorPick.Renderer.BackgroundColor = new Color((byte)r, (byte)g, (byte)b);
};
////TRIGGER COLOR/////
int r1 = 15, g1 = 247, b1 = 255;
Panel colorPick1 = new Panel();
colorPick1.SizeLayout = new Layout2d("10%", "7%");
colorPick1.PositionLayout = new Layout2d("80%", "18%");
EditBox red1 = new EditBox();
red1.PositionLayout = new Layout2d("5%", "18%");
red1.MaximumCharacters = 3;
red1.SizeLayout = new Layout2d("20%", "7%");
red1.DefaultText = "255";
EditBox green1 = new EditBox(red1);
green1.PositionLayout = new Layout2d("30%", "18%");
EditBox blue1 = new EditBox(red1);
blue1.PositionLayout = new Layout2d("55%", "18%");
///////////////////
red1.TextChanged += (e, a) => {
int.TryParse(red1.Text, out r1);
int.TryParse(blue1.Text, out b1);
int.TryParse(green1.Text, out g1);
colorPick1.Renderer.BackgroundColor = new Color((byte)r1, (byte)g1, (byte)b1);
};
green1.TextChanged += (e, a) => {
int.TryParse(red1.Text, out r1);
int.TryParse(blue1.Text, out b1);
int.TryParse(green1.Text, out g1);
colorPick1.Renderer.BackgroundColor = new Color((byte)r1, (byte)g1, (byte)b1);
};
blue1.TextChanged += (e, a) => {
int.TryParse(red1.Text, out r1);
int.TryParse(blue1.Text, out b1);
int.TryParse(green1.Text, out g1);
colorPick1.Renderer.BackgroundColor = new Color((byte)r1, (byte)g1, (byte)b1);
};
EditBox Name = new EditBox();
Name.PositionLayout = new Layout2d("5%%", "50%");
Name.SizeLayout = new Layout2d("60%", "7%");
Name.Text = "RainSim";
Name.SetSelectedText(0, 0);
Name.MaximumCharacters = 10;
rainSimulationPanel.Add(Name);
rainSimulationPanel.Add(red);
rainSimulationPanel.Add(green);
rainSimulationPanel.Add(blue);
rainSimulationPanel.Add(colorPick);
rainSimulationPanel.Add(red1);
rainSimulationPanel.Add(green1);
rainSimulationPanel.Add(blue1);
rainSimulationPanel.Add(colorPick1);
double watChan=0.1f, lightChance=0.08f;
EditBox waterChance = new EditBox(red);
waterChance.PositionLayout = new Layout2d("5%", "34%");
waterChance.Text = "0.1";
waterChance.SetSelectedText(0, 0);
waterChance.MaximumCharacters = 6;
EditBox lightningChance = new EditBox(waterChance);
lightningChance.PositionLayout = new Layout2d("35%", "34%");
lightningChance.Text = "0.08";
lightningChance.SetSelectedText(0, 0);
rainSimulationPanel.Add(waterChance);
rainSimulationPanel.Add(lightningChance);
EditBox test = new EditBox();
Button AddrainSim = new Button("Add");
AddrainSim.PositionLayout = new Layout2d("70%", "90%");
AddrainSim.Clicked += (e, a) =>
{
Color rainColor = new Color((byte)r, (byte)g, (byte)b);
Color lightningColor = new Color((byte)r1, (byte)g1, (byte)b1);
Console.WriteLine("Simulation added with color: " + rainColor);
double.TryParse(waterChance.Text, NumberStyles.Float, CultureInfo.InvariantCulture, out watChan);
double.TryParse(lightningChance.Text, NumberStyles.Float, CultureInfo.InvariantCulture, out lightChance);
simulations.Add(new RainSimulation(rainColor, lightningColor, image, fire_field, (float)lightChance ,(float)watChan, Name.Text));
Console.WriteLine(watChan);
Console.WriteLine(lightChance);
updateSimsList();
};
rainSimulationPanel.Add(AddrainSim);
mainPanel.Add(rainSimulationPanel);
rainSimulationPanel.Visible = false;