Repository navigation
Expand file tree
/
Copy pathControllor.cpp
More file actions
2344 lines (1434 loc) · 91 KB
/
Copy pathControllor.cpp
File metadata and controls
2344 lines (1434 loc) · 91 KB
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
/**
* @file Controllor.cpp
*
* @brief File containing source code of the Controllor class
*
*
* @author Hugo MARTIN
* Contact: hugo.martin.1@etu.univ-amu.fr
*
*/
#include "classes.h"
/** Constructor of the class Controllor.
*
* Modification of the constructor of Controllor
* Initialising all the elements to build the
* Graphical User Interface
*
*/
vampireGameproject::Controllor::Controllor():rulesGame(textParser), CharacterToCreate(textParser),
createResultsFile(CharacterToCreate){
/*Setting the title of the Window
Resizing the Window and Initialising labels */
graphicalUserinterface.set_title("Vampire Game Project");
graphicalUserinterface.resize(400, 300);
graphicalUserinterface.set_position(Gtk::WIN_POS_CENTER);
graphicalUserinterface.initialiseTableLabel();
graphicalUserinterface.setTableLabelAlign(0, "Name of the Vampire:");
graphicalUserinterface.setTableLabelAlign(1, "Player name:");
graphicalUserinterface.setTableLabelAlign(3, "Select a clan:");
graphicalUserinterface.setTableLabelAlign(4, "Select a Nature:");
graphicalUserinterface.setTableLabelAlign(5, "Select Attributes:");
graphicalUserinterface.setTableLabelAlign(6, "Select Abilities:");
graphicalUserinterface.setTableLabelAlign(7, "Select Disciplines:");
graphicalUserinterface.setTableLabelAlign(8, "Select Backgrounds:");
graphicalUserinterface.setTableLabelAlign(9, "Select Virtues:");
graphicalUserinterface.setTableLabelAlign(10, "Select Merits and Flaws:");
graphicalUserinterface.setTableLabelAlign(11, "Select Humanity Path:");
graphicalUserinterface.setTableLabelAlign(12, "Select WillPower:");
graphicalUserinterface.setTableLabelAlign(13, "Select Blood Pool:");
graphicalUserinterface.setTableLabelAlign(14, "Select Health:");
/*Placing labels on the Graphical User Interface*/
graphicalUserinterface.setTableLabelOnGrid(0, 0, 0, 1, 1);
graphicalUserinterface.setTableLabelOnGrid(1, 0, 1, 1, 1);
graphicalUserinterface.setTableLabelOnGrid(3, 0, 2, 1, 1);
graphicalUserinterface.setTableLabelOnGrid(4, 0, 3, 1, 1);
graphicalUserinterface.setTableLabelOnGrid(5, 0, 10, 1, 1);
graphicalUserinterface.setTableLabelOnGrid(6, 0, 16, 1, 1);
graphicalUserinterface.setTableLabelOnGrid(7, 0, 24, 1, 1);
graphicalUserinterface.setTableLabelOnGrid(8, 0, 31, 1, 1);
graphicalUserinterface.setTableLabelOnGrid(9, 0, 40, 1, 1);
graphicalUserinterface.setTableLabelOnGrid(10, 0, 49, 1, 1);
graphicalUserinterface.setTableLabelOnGrid(11, 0, 59, 1, 1);
graphicalUserinterface.setTableLabelOnGrid(12, 0, 60, 1, 1);
graphicalUserinterface.setTableLabelOnGrid(13, 0, 61, 1, 1);
graphicalUserinterface.setTableLabelOnGrid(14, 0, 62, 1, 1);
/*Initialising the Entry Widget
Initialising ComboBoxText which are not
a part of MultiInput objects*/
graphicalUserinterface.initialiseEntryName();
graphicalUserinterface.initialiseTableComboBox();
/*Initialising list of clans and list of
Nature*/
rulesGame.setVectorClans();
rulesGame.setVectorNature();
/*Initialising ComboBoxText not linked to MultiInput Object
with vector containing the associated text to display
in the ComboBoxText items*/
graphicalUserinterface.setTableComboBox(0, rulesGame.returnVectorClans());
graphicalUserinterface.setTableComboBox(1, rulesGame.returnVectorNature());
/*Placing ComboBoxTexts not linked to MultiInput Object
on the Graphical User Interface */
graphicalUserinterface.setTableComboBoxOnGrid(0, 3);
graphicalUserinterface.setTableComboBoxOnGrid(1, 4);
graphicalUserinterface.setTableComboBoxOnGrid(2, 14);
/*Setting the limit points to all the elements
in all the categories in the game to limit the user
to choose items in the game with a some limit points
for all the elements */
rulesGame.setLimitPointsAttributes(5, 5, 5, 13,
9, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 7, 7, 7,
5, 3, 3, 3, 3, 3, 3);
/*Initialising the NickNameLabel and all the
ButtonMultiInput and ButtonMultiInputOneComboBox
objects
Initialising SpinButton, Health ComboBoxText and submit button*/
initializeNicknameLabel();
initializeButtonMultiInput("attributes");
initializeButtonMultiInput("abilities");
initializeButtonMultiInput("disciplines");
initializeButtonMultiInputOneComboBox("backgrounds");
initializeButtonMultiInputOneComboBox("virtues");
initializeButtonMultiInput("MeritsFlaws");
initializeSpinButton("humanityPath");
initializeSpinButton("willPower");
initializeSpinButton("bloodPool");
initializeHealthComboBox();
initializeFinalButton();
/*Displaying all the elements on the interface*/
graphicalUserinterface.showAll();
}
/** Destructor of the class Controllor.
*
* Modification of the destructor of Controllor class*/
vampireGameproject::Controllor::~Controllor(){}
/** Implementation of the testInputsFirstComboBoxChangingItems method.
*
* Implementation of the testInputsFirstComboBoxChangingItems method
* Method unsetting the text of the Second Combo BoxText, if the
* item of the first comboBox is changed. If it's changed, so,
* the text of the second comboBox is clear and the spin score is clear too
* This method works with the MultiInputs composed of two comboBoxesText.
*
* @param ButtonMultiInputReference: Reference of the ButtonMultiInput object to retrieve
the MultiInput vector and clear the spin Button score and the text of the Second
Combo Box of the selected MultiInput present in the MultiInput Vector
* @param number: number of the MultiInput to select in the MultiInput Vector
*/
void vampireGameproject::Controllor::testInputsFirstComboBoxChangingItems(ButtonmultiInput& ButtonMultiInputReference, int number){
std::vector<MultiInput*> vectorMultiInput;
vectorMultiInput = ButtonMultiInputReference.returnVectorMultiInput();
if (vectorMultiInput[number]->returnTextComboBox("first") != ""){
/*If the first ComboBoxText is empty, we append an element to avoid
conflicts with the use of the gtkmm function when we clean all the
elements in the FirstComboBoxText*/
vectorMultiInput[number]->returnComboBox("second").append("test");
vectorMultiInput[number]->returnComboBox("second").remove_all();
}
vectorMultiInput[number]->unsetActiveText();
vectorMultiInput[number]->resetSpinScore();
}
/** Implementation of the testInputsFirstComboBoxChangingItemsOneComboBox method.
*
* Implementation of the testInputsFirstComboBoxChangingItemsOneComboBox method
* Method resetting the spin score associated to the selected MultiInputOneComboBox.
* This method works for the MultiInputOneComboBox composed of only one ComboBoxText
*
* @param ButtonmultiInputOneComboBoxReference: Reference of the ButtonMultiInputOneComboBox object
to retrieve the MultiInputOneComboBox vector to clear the spin Button score and the text of the
Combo BoxText of the selected MultiInputOneComboBox in the vector
* @param number: number of the MultiInputOneComboBox to select in the MultiInputOneComboBox vector
*/
void vampireGameproject::Controllor::testInputsFirstComboBoxChangeItemsOneComboBox(ButtonmultiInputOneComboBox& ButtonmultiInputOneComboBoxReference, int number){
std::vector<MultiInputOneComboBox*> vectorMultiInputOneComboBox;
vectorMultiInputOneComboBox = ButtonmultiInputOneComboBoxReference.returnVectorMultiInput();
vectorMultiInputOneComboBox[number]->resetSpinScore();
}
/** Implementation of the testInputsSecondComboBox method.
*
* Implementation of the testInputsSecondComboBox method
* Method setting the text in the secondComboBoxText, if the
* user already chose an item in the FirstComboBoxText,
* When the user chose an item in the secondcomboBox,
* this item can't be used by the others secondComboBox
*
* @param ButtonMultiInputReference: Reference of the ButtonMultiInput object
* @param number: number of the MultiInput to select in the vector
* @param categorieMultiInput: type of ButtonMultiInput alllowing to select the ButtonMutiInputobject to test SecondComboBoxText*/
void vampireGameproject::Controllor::testInputsSecondComboBox(ButtonmultiInput& ButtonMultiInputReference, int number, std::string categorieMultiInput){
/*Initialising vectors of selected inputs*/
ButtonMultiInputReference.setVectorSelectedInput();
std::vector<std::string> vectorFirstComboBox = ButtonMultiInputReference.returnVectorSelectedInput("first");
std::vector<std::string> vectorSecondComboBox = ButtonMultiInputReference.returnVectorSelectedInput("second");
/*Initialising a vector where are saved the parsed text corresponding to
the items of the second combotext for the text entered in the first comboBox*/
if (categorieMultiInput == "attributes"){
std::vector<std::string> vectorAttributesCategorie = textParser.parseAttributesCategorie(ButtonMultiInputReference.returnTextComboBox(number, "first"));
/*Initialising a vector to save all the MultiInputs objects*/
std::vector<MultiInput*> vectorMultiInputs = ButtonMultiInputReference.returnVectorMultiInput();
/*Iteration of elements already entered by the user
If a first ComboBoxText iterated element entered
by the user for a MultiInput object is detected somewhere else,
we look the iterated second item, if the iterated second item
corresponds with a second term present in the vector of selected
second items, then, it means it's the same MultiInput object
If it's not the case, the second term present in the vector
selected second item is deleted for this MultiInput object whose the choice
doesn't correspond to this second term*/
for(int iterator = 0; iterator < (int)vectorFirstComboBox.size(); iterator++){
if (vectorMultiInputs[number]->returnTextComboBox("first") == vectorFirstComboBox.at(iterator) &&
vectorMultiInputs[number]->returnTextComboBox("second") != vectorSecondComboBox.at(iterator)){
vectorAttributesCategorie.erase(std::remove(vectorAttributesCategorie.begin(),
vectorAttributesCategorie.end(), vectorSecondComboBox.at(iterator)),
vectorAttributesCategorie.end());
}
}
if (vectorMultiInputs[number]->returnTextComboBox("first") != ""){
ButtonMultiInputReference.setVectorComboBox(number, "second", vectorAttributesCategorie);
}
}
if (categorieMultiInput == "abilities"){
std::vector<std::string> vectorAbilitiesCategorie = textParser.parseAbilitiesCategorie(ButtonMultiInputReference.returnTextComboBox(number, "first"));
/*Initialising a vector to store all the MultiInputs*/
std::vector<MultiInput*> vectorMultiInputs = ButtonMultiInputReference.returnVectorMultiInput();
/*Iteration of elements already entered by the user
If a first ComboBoxText iterated element entered
by the user for a MultiInput is detected somewhere else,
we look the iterated second item, if the iterated second item
corresponds with a second term present in the vector of selected
second items, then, it means it's the same MultiInput
If it's not the case, the second term present in the vector
selected second item is deleted for this MultiInput whose the choice
doesn't correspond to this second term*/
for(int iterator = 0; iterator < (int)vectorFirstComboBox.size(); iterator++){
if (vectorMultiInputs[number]->returnTextComboBox("first") == vectorFirstComboBox.at(iterator) &&
vectorMultiInputs[number]->returnTextComboBox("second") != vectorSecondComboBox.at(iterator)){
vectorAbilitiesCategorie.erase(std::remove(vectorAbilitiesCategorie.begin(),
vectorAbilitiesCategorie.end(), vectorSecondComboBox.at(iterator)),
vectorAbilitiesCategorie.end());
}
}
if (vectorMultiInputs[number]->returnTextComboBox("first") != ""){
ButtonMultiInputReference.setVectorComboBox(number, "second", vectorAbilitiesCategorie);
}
}
if (categorieMultiInput == "disciplines"){
std::vector<std::string> vectorAttributesCategorie = textParser.parseClanDisciplinesCategorie(ButtonMultiInputReference.returnTextComboBox(number, "first"));
/*Initialising a vector to store all the MultiInputs*/
std::vector<MultiInput*> vectorMultiInputs = ButtonMultiInputReference.returnVectorMultiInput();
/*Iteration of elements already entered by the user
If a first ComboBoxText iterated element entered
by the user for a MultiInput is detected somewhere else,
we look the iterated second item, if the iterated second item
corresponds with a second term present in the vector of selected
second items, then, it means it's the same MultiInput
If it's not the case, the second term present in the vector
selected second item is deleted for this MultiInput whose the choice
doesn't correspond to this second term*/
for(int iterator = 0; iterator < (int)vectorFirstComboBox.size(); iterator++){
if (vectorMultiInputs[number]->returnTextComboBox("first") == vectorFirstComboBox.at(iterator) &&
vectorMultiInputs[number]->returnTextComboBox("second") != vectorSecondComboBox.at(iterator)){
vectorAttributesCategorie.erase(std::remove(vectorAttributesCategorie.begin(),
vectorAttributesCategorie.end(), vectorSecondComboBox.at(iterator)),
vectorAttributesCategorie.end());
}
}
if (vectorMultiInputs[number]->returnTextComboBox("first") != ""){
ButtonMultiInputReference.setVectorComboBox(number, "second", vectorAttributesCategorie);
}
}
if (categorieMultiInput == "MeritsFlaws"){
std::vector<std::string> vectorAttributesCategorie = textParser.parseMeritsFlawsCategorie(ButtonMultiInputReference.returnTextComboBox(number, "first"));
/*Initialising a vector to store all the MultiInputs*/
std::vector<MultiInput*> vectorMultiInputs = ButtonMultiInputReference.returnVectorMultiInput();
/*Iteration of elements already entered by the user
If a first ComboBoxText iterated element entered
by the user for a MultiInput is detected somewhere else,
we look the iterated second item, if the iterated second item
corresponds with a second term present in the vector of selected
second items, then, it means it's the same MultiInput
If it's not the case, the second term present in the vector
selected second item is deleted for this MultiInput whose the choice
doesn't correspond to this second term*/
for(int iterator = 0; iterator < (int)vectorFirstComboBox.size(); iterator++){
if (vectorMultiInputs[number]->returnTextComboBox("first") == vectorFirstComboBox.at(iterator) &&
vectorMultiInputs[number]->returnTextComboBox("second") != vectorSecondComboBox.at(iterator)){
vectorAttributesCategorie.erase(std::remove(vectorAttributesCategorie.begin(),
vectorAttributesCategorie.end(), vectorSecondComboBox.at(iterator)),
vectorAttributesCategorie.end());
}
}
if (vectorMultiInputs[number]->returnTextComboBox("first") != ""){
ButtonMultiInputReference.setVectorComboBox(number, "second", vectorAttributesCategorie);
}
}
}
/** Implementation of the testClanButton method.
*
* Implementation of the testClanButton method
* Method updating the text in the First ComboBoxText associated
* to the ButtonMultiInput object linked to disciplines when the user
* chooses a clan. If the user chooses another clan and fields exist
* in MultiInput ComboBoxes associated to disciplines of the old clan,
* then, these one are destroyed*/
void vampireGameproject::Controllor::testClanButton(){
/*Initialising ButtonMultiInput reference and vectorMultiInput*/
ButtonmultiInput& ButtonmultiInputReferenceDisciplines = graphicalUserinterface.returnDisciplinesInput();
std::vector<MultiInput*> vectorMultiInputDisciplines = ButtonmultiInputReferenceDisciplines.returnVectorMultiInput();
/*if the number of MultiInput in the vector is superior to one*/
if ((int)vectorMultiInputDisciplines.size() > 1){
/*Creation of a counter indicating the number of MultiInput present in the vector*/
int sizeOfTheVectorMultiInputs = (int)vectorMultiInputDisciplines.size();
/*while this numer is superior to 0, the last MultiInput
of the vector is destroyed*/
while(sizeOfTheVectorMultiInputs > 1){
deleteMultiInput("disciplines");
sizeOfTheVectorMultiInputs -= 1;
}
}
/*When only one MultiInput is present, we reset the spin score and the
First ComboBox and the Second ComboBox, then we update the FirstComboBox
with the new name of chosen clan. Then, the nickname of the Clan is updated. */
vectorMultiInputDisciplines[0]->resetSpinScore();
vectorMultiInputDisciplines[0]->unsetActiveText();
vectorMultiInputDisciplines[0]->returnComboBox("first").remove_all();
vectorMultiInputDisciplines[0]->returnComboBox("second").append("test");
vectorMultiInputDisciplines[0]->returnComboBox("second").remove_all();
testFirstComboBoxDisponibility("disciplines");
updateNicknameLabel();
}
/** Implementation of the testInputsFirstComboBoxForGui method.
*
* Implementation of the testInputsFirstComboBoxForGui method
* Method reseting the second ComboBoxText and the spin score
* and the Spin Button is tested such as we select a score available
* for the First ComboBoxText item. Then, the SecondComboBoxText is updated
* to make appear Second ComboBoxText items corresponding to the selected First
* ComboBoxText item
*
* @param number: number of the MultiInput to select in the MultiInput Vector
* @param categorieMultiInput: type of ButtonMultiInput alllowing to select the ButtonMutiInputobject
* to test SpinScore and Second ComboBoxText when it's available
*/
void vampireGameproject::Controllor::testInputFirstComboBoxForGui(int number, std::string categorieMultiInput){
if (categorieMultiInput == "attributes"){
ButtonmultiInput& ButtonMultiInputReference = graphicalUserinterface.returnAttributesInput();
testInputsFirstComboBoxChangingItems(ButtonMultiInputReference, number);
testInputSpinButton(ButtonMultiInputReference, number);
testInputsSecondComboBox(ButtonMultiInputReference, number, categorieMultiInput);
}
if (categorieMultiInput == "abilities"){
ButtonmultiInput& ButtonMultiInputReference = graphicalUserinterface.returnAbilitiesInput();
testInputsFirstComboBoxChangingItems(ButtonMultiInputReference, number);
testInputSpinButton(ButtonMultiInputReference, number);
testInputsSecondComboBox(ButtonMultiInputReference, number, categorieMultiInput);
}
if (categorieMultiInput == "disciplines"){
ButtonmultiInput& ButtonMultiInputReference = graphicalUserinterface.returnDisciplinesInput();
testInputsFirstComboBoxChangingItems(ButtonMultiInputReference, number);
testInputSpinButton(ButtonMultiInputReference, number);
testInputsSecondComboBox(ButtonMultiInputReference, number, categorieMultiInput);
}
if (categorieMultiInput == "backgrounds"){
ButtonmultiInputOneComboBox& ButtonmultiInputOneComboBoxReference = graphicalUserinterface.returnBackgroundsInput();
testInputsFirstComboBoxChangeItemsOneComboBox(ButtonmultiInputOneComboBoxReference, number);
testInputSpinButtonOneComboBox(ButtonmultiInputOneComboBoxReference, number);
}
if (categorieMultiInput == "virtues"){
ButtonmultiInputOneComboBox& ButtonmultiInputOneComboBoxReference = graphicalUserinterface.returnVirtuesInput();
testInputsFirstComboBoxChangeItemsOneComboBox(ButtonmultiInputOneComboBoxReference, number);
testInputSpinButtonOneComboBox(ButtonmultiInputOneComboBoxReference, number);
}
if (categorieMultiInput == "MeritsFlaws"){
ButtonmultiInput& ButtonmultiInputReference = graphicalUserinterface.returnMeritsFlawsInput();
testInputsFirstComboBoxChangingItems(ButtonmultiInputReference, number);
testInputSpinButton(ButtonmultiInputReference, number);
testInputsSecondComboBox(ButtonmultiInputReference, number, categorieMultiInput);
}
}
/** Implementation of the testInputSecondComboBoxForGui method.
*
* Implementation of the testInputSecondComboBoxForGui method
* Method updating the vectors of selected inputs
* And from that, updating the items of the Second ComboBoxes
* for all the Concerned MultiInputs. This methods works for
* MultiInputs composed of two ComboBoxesText
*
* @param number: number of the MultiInput to select in the MultiInput Vector
* @param categorieMultiInput: type of ButtonMultiInput alllowing to select the ButtonMutiInputobject to test Second ComboBox
*/
void vampireGameproject::Controllor::testInputSecondComboBoxForGui(int number, std::string categorieMultiInput){
if (categorieMultiInput == "attributes"){
ButtonmultiInput& ButtonMultiInputReference = graphicalUserinterface.returnAttributesInput();
testInputSecondComboBoxChosenItems(ButtonMultiInputReference, number, categorieMultiInput);
}
if (categorieMultiInput == "abilities"){
ButtonmultiInput& ButtonMultiInputReference = graphicalUserinterface.returnAbilitiesInput();
testInputSecondComboBoxChosenItems(ButtonMultiInputReference, number, categorieMultiInput);
}
if (categorieMultiInput == "disciplines"){
ButtonmultiInput& ButtonMultiInputReference = graphicalUserinterface.returnDisciplinesInput();
testInputSecondComboBoxChosenItems(ButtonMultiInputReference, number, categorieMultiInput);
}
if (categorieMultiInput == "MeritsFlaws"){
ButtonmultiInput& ButtonMultiInputReference = graphicalUserinterface.returnMeritsFlawsInput();
testInputSecondComboBoxChosenItems(ButtonMultiInputReference, number, categorieMultiInput);
}
}
/** Implementation of the testInputSpinButtonForGui method.
*
* Implementation of the testInputSpinButtonForGui method
* Method updating the spinScore and verifying the disponibility
* of the First ComboBox Item
*
* @param number: number of the MultiInput to select in the MultiInput Vector
* @param categorieMultiInput: MultiInput categorie to select
*/
void vampireGameproject::Controllor::testInputSpinButtonForGui(int number, std::string categorieMultiInput){
if (categorieMultiInput == "attributes"){
ButtonmultiInput& ButtonMultiInputReference = graphicalUserinterface.returnAttributesInput();
testInputSpinButton(ButtonMultiInputReference, number);
}
if (categorieMultiInput == "abilities"){
ButtonmultiInput& ButtonMultiInputReference = graphicalUserinterface.returnAbilitiesInput();
testInputSpinButton(ButtonMultiInputReference, number);
}
testFirstComboBoxDisponibility(categorieMultiInput);
}
/** Implementation of the testInputPlusButtonForGui method.
*
* Implementation of the testInputPlusButtonForGui method
* Method setting a new MultiInput and testing the First ComboBoxText
* items disponibility
*
* @param categorieMultiInput: type of ButtonMultiInput alllowing to select the ButtonMutiInputobject to test First ComboBoxText
*/
void vampireGameproject::Controllor::testInputPlusButtonForGui(std::string categorieMultiInput){
setMultiInput(categorieMultiInput);
testFirstComboBoxDisponibility(categorieMultiInput);
}
/** Implementation of the testInputMinusButtonForGui method.
*
* Implementation of the testInputMinusButtonForGui method
* Method deleting the last MultiInput and testing
* the Spin Score avaibility items disponibility and the
* First ComboBox items disponibility
*
* @param categorieMultiInput: type of ButtonMultiInput alllowing to select the ButtonMutiInputobject to test First ComboBoxText and Spin Button
*/
void vampireGameproject::Controllor::testInputMinusButtonForGui(std::string categorieMultiInput){
deleteMultiInput(categorieMultiInput);
if (categorieMultiInput != "backgrounds" && categorieMultiInput != "virtues"){
testInputSpinButtonWhenRemoved(categorieMultiInput);
}
testFirstComboBoxDisponibility(categorieMultiInput);
}
/** Implementation of the testInputSpinButtonWhenRemoved method.
*
* Implementation of the testInputSpinButtonWhenRemoved method
* Method updating the Spin Score when a MultiInput is deleted
* The Spin Score for all the others MultiInput is actualised
* in real time when an item is deleted
*
* @param categorieMultiInput: type of ButtonMultiInput alllowing to select the ButtonMutiInputobject to test Spin Button
*/
void vampireGameproject::Controllor::testInputSpinButtonWhenRemoved(std::string categorieMultiInput){
if (categorieMultiInput == "attributes"){
ButtonmultiInput& ButtonMultiInputReference = graphicalUserinterface.returnAttributesInput();
/*Updating the Dictionnary of Spin Score*/
ButtonMultiInputReference.setDicoScoreFirstComboBox();
/*Setting a variable to use the VectorMultiInput*/
std::vector<MultiInput*> vectorMultiInput = ButtonMultiInputReference.returnVectorMultiInput();
/*For all the MultiInputs, if the MultiInput has the same First ComboBox item
Than the MultiInput where the spin score has been updated. Then, we update
the spin score limit, this one is computed such as :
newSpinScore = oldSpinScore + ruledSpinScoreItem - ActualSpinScoreItem*/
for(int iterator = 0; iterator < (int)vectorMultiInput.size(); iterator++){
int newSpinButtonLimit = vectorMultiInput[iterator]->returnSpinScore() +
(rulesGame.returnLimitPointsAttributes()[vectorMultiInput[iterator]->returnTextComboBox("first")] -
ButtonMultiInputReference.returnDicoScoreFirstComboBox()[vectorMultiInput[iterator]->returnTextComboBox("first")]);
int spinScore = vectorMultiInput[iterator]->returnSpinScore();
vectorMultiInput[iterator]->setLimitSpinButton(newSpinButtonLimit);
vectorMultiInput[iterator]->returnSpinButton().set_value(spinScore);
}
}
if (categorieMultiInput == "abilities"){
ButtonmultiInput& ButtonMultiInputReference = graphicalUserinterface.returnAbilitiesInput();
/*Updating the Dictionnary of Spin Score*/
ButtonMultiInputReference.setDicoScoreFirstComboBox();
/*Setting a variable to use the VectorMultiInput*/
std::vector<MultiInput*> vectorMultiInput = ButtonMultiInputReference.returnVectorMultiInput();
/*For all the MultiInputs, if the MultiInput has the same First ComboBox item
Than the MultiInput where the spin score has been updated. Then, we update
the spin score limit, this one is computed such as :
newSpinScore = oldSpinScore + ruledSpinScoreItem - ActualSpinScoreItem*/
for(int iterator = 0; iterator < (int)vectorMultiInput.size(); iterator++){
int newSpinButtonLimit = vectorMultiInput[iterator]->returnSpinScore() +
(rulesGame.returnLimitPointsAttributes()[vectorMultiInput[iterator]->returnTextComboBox("first")] -
ButtonMultiInputReference.returnDicoScoreFirstComboBox()[vectorMultiInput[iterator]->returnTextComboBox("first")]);
int spinScore = vectorMultiInput[iterator]->returnSpinScore();
vectorMultiInput[iterator]->setLimitSpinButton(newSpinButtonLimit);
vectorMultiInput[iterator]->returnSpinButton().set_value(spinScore);
}
}
}
/** Implementation of the testInputSecondComboBoxChosenItems method.
*
* Implementation of the testInputSecondComboBoxChosenItems method
* Method detecting if in all the Second ComboBox of all MultiInput
* we dectect the last MultiInput modified, if it's not the case,
* we look if the item of the First Combo Box is the same
* of the item we choose for our Combo Box. If it's the case,
* we delete the chosen item for all the concerned MultiInput
* This methods works with MultiInput having two ComboBoxText
*
* @param ButtonMultiInputReference: Reference of the ButtonMultiInput object
* @param number: number of the MultiInput in the MultiInput Vector
* @param categorieMultiInput: type of ButtonMultiInput alllowing to select the ButtonMutiInputobject to test second ComboBox
*/
void vampireGameproject::Controllor::testInputSecondComboBoxChosenItems(ButtonmultiInput& ButtonMultiInputReference, int number, std::string categorieMultiInput){
/*Declaration of the vectorMultinput*/
std::vector<MultiInput*> vectorMultiInput;
/*Initialising the vectorMultiInput*/
vectorMultiInput = ButtonMultiInputReference.returnVectorMultiInput();
/*For all the elements of the vectorMultiInput, if the element
is not the chosen MultiInput and if the item of the first
Combo Box is the same than the chosen MultiInput
Then, we update the choices for the second ComboBox*/
for(int iterator = 0; iterator < (int)vectorMultiInput.size(); iterator++){
if (vectorMultiInput[iterator] != vectorMultiInput[number]){
if (vectorMultiInput[iterator]->returnTextComboBox("first") == vectorMultiInput[number]->returnTextComboBox("first")){
testInputsSecondComboBox(ButtonMultiInputReference, iterator, categorieMultiInput);
}
}
}
}
/** Implementation of the testFirstComboBoxDisponibility method.
*
* Implementation of the testFirstComboBoxDisponibility method
* Method verifying in all the MultiInput if the authorized Spin
* Score was been reached, if it's the case and if the actual
* value of the First ComboBoxText is not a value where the
* authorized Spin Score was reached, the element is deleted
* from the user proposed list in the others First Combo Box
*
* @param categorieMultiInput: type of ButtonMultiInput alllowing to select the ButtonMutiInputobject to test first ComboBox
*/
void vampireGameproject::Controllor::testFirstComboBoxDisponibility(std::string categorieMultiInput){
if (categorieMultiInput == "attributes"){
/*Initialising ButtonMultiInput Reference and VectorMultiInput */
ButtonmultiInput& ButtonMultiInputReference = graphicalUserinterface.returnAttributesInput();
std::vector<MultiInput*> vectorMultiInput;
vectorMultiInput = ButtonMultiInputReference.returnVectorMultiInput();
/*Setting the DicoScore for all the items of the FirstComboBox*/
ButtonMultiInputReference.setDicoScoreFirstComboBox();
std::map<std::string, int> dicoScoreFirstComboBox = ButtonMultiInputReference.returnDicoScoreFirstComboBox();
std::map<std::string, int> dicoScoreFirstComboBoxRules = rulesGame.returnLimitPointsAttributes();
std::vector<std::string> vectorFirstComboBoxOutsider;
std::map<std::string, int>::iterator iterator;
/*For all the elements in the dico Score, if the Spin Score max
was reached, then we register the element in a new vector*/
for (iterator = dicoScoreFirstComboBox.begin(); iterator != dicoScoreFirstComboBox.end(); iterator++){
if (iterator->first != ""){
if (dicoScoreFirstComboBoxRules.at(iterator->first) == iterator->second){
vectorFirstComboBoxOutsider.push_back(iterator->first);
}
}
}
/*For all the MultiInputs, we create the vector of First ComboBox Items,
Then, we iterate all the terms whose the score is equal to the limit
If the term is the active term of the First ComboBox of the iterated MultiInput
We don't delete the value in the list of the items proposed to the user
If it's not the case, the value is not proposed to the user anymore*/
std::vector<std::string> vectorFirstComboBoxChoices = textParser.parseAttributes();
for(int i = 0; i < (int)vectorFirstComboBoxOutsider.size(); i++){
std::cout << vectorFirstComboBoxOutsider.at(i) << std::endl;
}
for(int newIterator = 0; newIterator < (int)vectorMultiInput.size(); newIterator++){
std::vector<std::string> vectorFirstComboBoxChoicesCopy = vectorFirstComboBoxChoices;
if (!vectorFirstComboBoxOutsider.empty()){
for(int iterator2 = 0; iterator2 < (int)vectorFirstComboBoxOutsider.size(); iterator2++){
if (vectorMultiInput[newIterator]->returnTextComboBox("first") != vectorFirstComboBoxOutsider.at(iterator2)){
vectorFirstComboBoxChoicesCopy.erase(std::remove(vectorFirstComboBoxChoicesCopy.begin(),
vectorFirstComboBoxChoicesCopy.end(), vectorFirstComboBoxOutsider.at(iterator2)),
vectorFirstComboBoxChoicesCopy.end());
}
}
}
/*Saving the old value because the ComboBox items vector replacement
deletes spinScore and textActive in FirstComboBox and SecondComboBox.
After the replacement, the old values are set.*/
int spinScore = vectorMultiInput[newIterator]->returnSpinScore();
std::string textSetactiveFirstComboBox = vectorMultiInput[newIterator]->returnTextComboBox("first");
std::string textSetactiveSecondComboBox = vectorMultiInput[newIterator]->returnTextComboBox("second");
vectorMultiInput[newIterator]->returnComboBox("first").remove_all();
vectorMultiInput[newIterator]->setVectorComboBox(vectorFirstComboBoxChoicesCopy, "first");
vectorMultiInput[newIterator]->returnComboBox("first").set_active_text(textSetactiveFirstComboBox);
vectorMultiInput[newIterator]->returnComboBox("second").set_active_text(textSetactiveSecondComboBox);
vectorMultiInput[newIterator]->returnSpinButton().set_value(spinScore);
}
}
if (categorieMultiInput == "abilities"){
/*Initialising ButtonMultiInput Reference and VectorMultiInput */
ButtonmultiInput& ButtonMultiInputReference = graphicalUserinterface.returnAbilitiesInput();
std::vector<MultiInput*> vectorMultiInput;
vectorMultiInput = ButtonMultiInputReference.returnVectorMultiInput();
/*Setting the DicoScore for all the items of the FirstComboBox*/
ButtonMultiInputReference.setDicoScoreFirstComboBox();
std::map<std::string, int> dicoScoreFirstComboBox = ButtonMultiInputReference.returnDicoScoreFirstComboBox();
std::map<std::string, int> dicoScoreFirstComboBoxRules = rulesGame.returnLimitPointsAttributes();
std::vector<std::string> vectorFirstComboBoxOutsider;
std::map<std::string, int>::iterator iterator;
/*For all the elements in the dico Score, if the Spin Score max
was reached, then we register the element in a new vector*/
for (iterator = dicoScoreFirstComboBox.begin(); iterator != dicoScoreFirstComboBox.end(); iterator++){
if (iterator->first != ""){
if (dicoScoreFirstComboBoxRules.at(iterator->first) == iterator->second){
vectorFirstComboBoxOutsider.push_back(iterator->first);
}
}
}
/*For all the MultiInputs, we create the vector of First ComboBox Items,
Then, we iterate all the terms whose the score is equal to the limit
If the term is the active term of the First ComboBox of the iterated MultiInput
We don't delete the value in the list of the items proposed to the user
If it's not the case, the value is not proposed to the user anymore*/
std::vector<std::string> vectorFirstComboBoxChoices = textParser.parseAbilities();
for(int iterator = 0; iterator < (int)vectorMultiInput.size(); iterator++){
std::vector<std::string> vectorFirstComboBoxChoicesCopy = vectorFirstComboBoxChoices;
if (!vectorFirstComboBoxOutsider.empty()){
for(int iterator2 = 0; iterator2 < (int)vectorFirstComboBoxOutsider.size(); iterator2++){
if (vectorMultiInput[iterator]->returnTextComboBox("first") != vectorFirstComboBoxOutsider.at(iterator2)){
vectorFirstComboBoxChoicesCopy.erase(std::remove(vectorFirstComboBoxChoicesCopy.begin(),
vectorFirstComboBoxChoicesCopy.end(), vectorFirstComboBoxOutsider.at(iterator2)),
vectorFirstComboBoxChoicesCopy.end());
}
}
}
/*Saving the old value because the ComboBox items vector replacement
deletes spinScore and textActive in FirstComboBox and SecondComboBox.
After the replacement, the old values are set.*/
int spinScore = vectorMultiInput[iterator]->returnSpinScore();
std::string textSetactiveFirstComboBox = vectorMultiInput[iterator]->returnTextComboBox("first");
std::string textSetactiveSecondComboBox = vectorMultiInput[iterator]->returnTextComboBox("second");
vectorMultiInput[iterator]->returnComboBox("first").remove_all();
vectorMultiInput[iterator]->setVectorComboBox(vectorFirstComboBoxChoicesCopy, "first");
vectorMultiInput[iterator]->returnComboBox("first").set_active_text(textSetactiveFirstComboBox);
vectorMultiInput[iterator]->returnComboBox("second").set_active_text(textSetactiveSecondComboBox);
vectorMultiInput[iterator]->returnSpinButton().set_value(spinScore);
}
}
if (categorieMultiInput == "disciplines"){
/*Initialising ButtonMultiInput Reference and VectorMultiInput */
ButtonmultiInput& ButtonMultiInputReference = graphicalUserinterface.returnDisciplinesInput();
std::vector<MultiInput*> vectorMultiInput;
vectorMultiInput = ButtonMultiInputReference.returnVectorMultiInput();
/*Setting the DicoScore for all the items of the FirstComboBox*/
ButtonMultiInputReference.setDicoScoreFirstComboBox();
std::map<std::string, int> dicoScoreFirstComboBox = ButtonMultiInputReference.returnDicoScoreFirstComboBox();
std::map<std::string, int> dicoScoreFirstComboBoxRules = rulesGame.returnLimitPointsAttributes();
std::vector<std::string> vectorFirstComboBoxOutsider;
std::map<std::string, int>::iterator iterator;
/*For all the elements in the dico Score, if the Spin Score max
was reached, then we register the element in a new vector*/
for (iterator = dicoScoreFirstComboBox.begin(); iterator != dicoScoreFirstComboBox.end(); iterator++){
if (iterator->first != ""){
if (dicoScoreFirstComboBoxRules.at(iterator->first) == iterator->second){