Commit 10aade720c4232e9fe85b917cc534a783ab23189

Authored by Carlos Picanco
1 parent 17c83cac
Exists in master

gui incremental work

1 */backup/* 1 */backup/*
2 id 2 id
3 /P*/* 3 /P*/*
4 -*.zip  
5 \ No newline at end of file 4 \ No newline at end of file
  5 +*.zip
  6 +*.ini
6 \ No newline at end of file 7 \ No newline at end of file
experiment_designer/form_main.lfm
1 object FormDesigner: TFormDesigner 1 object FormDesigner: TFormDesigner
2 - Left = 180 2 + Left = 469
3 Height = 635 3 Height = 635
4 - Top = 54 4 + Top = 57
5 Width = 656 5 Width = 656
6 HorzScrollBar.Page = 387 6 HorzScrollBar.Page = 387
7 VertScrollBar.Page = 482 7 VertScrollBar.Page = 482
@@ -12,7 +12,8 @@ object FormDesigner: TFormDesigner @@ -12,7 +12,8 @@ object FormDesigner: TFormDesigner
12 Menu = MainMenu1 12 Menu = MainMenu1
13 OnCreate = FormCreate 13 OnCreate = FormCreate
14 OnDestroy = FormDestroy 14 OnDestroy = FormDestroy
15 - SessionProperties = 'Caption;ComboCurrentCondition.ItemIndex;ComboCurrentCondition.Items;ComboCurrentContingency.ItemIndex;ComboCurrentContingency.Items;Height;Left;PageControl.TabIndex;Top;Width;WindowState;LabelIf.Caption' 15 + SessionProperties = 'Caption;ComboCurrentCondition.ItemIndex;ComboCurrentCondition.Items;ComboCurrentContingency.ItemIndex;ComboCurrentContingency.Items;Height;LabelIf.Caption;Left;PageControl.TabIndex;Top;Width;WindowState;ComboCurrentCondition.Text;ComboCurrentContingency.Text'
  16 + ShowHint = True
16 LCLVersion = '1.6.2.0' 17 LCLVersion = '1.6.2.0'
17 object PageControl: TPageControl 18 object PageControl: TPageControl
18 Left = 0 19 Left = 0
@@ -559,6 +560,7 @@ object FormDesigner: TFormDesigner @@ -559,6 +560,7 @@ object FormDesigner: TFormDesigner
559 Top = 10 560 Top = 10
560 Width = 650 561 Width = 650
561 ItemHeight = 0 562 ItemHeight = 0
  563 + OnChange = ComboCurrentContingencyChange
562 Style = csDropDownList 564 Style = csDropDownList
563 TabOrder = 0 565 TabOrder = 0
564 end 566 end
@@ -590,6 +592,7 @@ object FormDesigner: TFormDesigner @@ -590,6 +592,7 @@ object FormDesigner: TFormDesigner
590 Top = 0 592 Top = 0
591 Width = 163 593 Width = 163
592 Caption = 'Remover' 594 Caption = 'Remover'
  595 + OnClick = BtnRemoveContingencyClick
593 TabOrder = 1 596 TabOrder = 1
594 end 597 end
595 object BtnReorderContingency: TButton 598 object BtnReorderContingency: TButton
@@ -623,6 +626,7 @@ object FormDesigner: TFormDesigner @@ -623,6 +626,7 @@ object FormDesigner: TFormDesigner
623 Height = 25 626 Height = 25
624 Top = 119 627 Top = 119
625 Width = 650 628 Width = 650
  629 + OnEditingDone = EditContingencyNameEditingDone
626 TabOrder = 3 630 TabOrder = 3
627 end 631 end
628 object RGContingencyStyle: TRadioGroup 632 object RGContingencyStyle: TRadioGroup
@@ -735,6 +739,7 @@ object FormDesigner: TFormDesigner @@ -735,6 +739,7 @@ object FormDesigner: TFormDesigner
735 Top = 15 739 Top = 15
736 Width = 154 740 Width = 154
737 ItemHeight = 0 741 ItemHeight = 0
  742 + OnChange = CBPointsTypeChange
738 Style = csDropDownList 743 Style = csDropDownList
739 TabOrder = 4 744 TabOrder = 4
740 end 745 end
@@ -782,10 +787,11 @@ object FormDesigner: TFormDesigner @@ -782,10 +787,11 @@ object FormDesigner: TFormDesigner
782 object EditMessSufix: TEdit 787 object EditMessSufix: TEdit
783 Left = 392 788 Left = 392
784 Height = 27 789 Height = 27
  790 + Hint = 'singular|plural'
785 Top = 15 791 Top = 15
786 Width = 134 792 Width = 134
787 TabOrder = 1 793 TabOrder = 1
788 - Text = 'ponto.' 794 + Text = 'ponto.|pontos.'
789 end 795 end
790 object LabelC5: TLabel 796 object LabelC5: TLabel
791 Left = 526 797 Left = 526
experiment_designer/form_main.pas
@@ -96,15 +96,19 @@ type @@ -96,15 +96,19 @@ type
96 procedure BtnAppendCondClick(Sender: TObject); 96 procedure BtnAppendCondClick(Sender: TObject);
97 procedure BtnAppendContingencyClick(Sender: TObject); 97 procedure BtnAppendContingencyClick(Sender: TObject);
98 procedure BtnRemoveCondClick(Sender: TObject); 98 procedure BtnRemoveCondClick(Sender: TObject);
  99 + procedure BtnRemoveContingencyClick(Sender: TObject);
  100 + procedure CBPointsTypeChange(Sender: TObject);
99 procedure CGQuestionItemClick(Sender: TObject; Index: integer); 101 procedure CGQuestionItemClick(Sender: TObject; Index: integer);
100 procedure CheckBoxBroadcastChange(Sender: TObject); 102 procedure CheckBoxBroadcastChange(Sender: TObject);
101 procedure CheckBoxIsMetaChange(Sender: TObject); 103 procedure CheckBoxIsMetaChange(Sender: TObject);
  104 + procedure CheckBoxColorsRowsChange(Sender: TObject);
102 procedure CheckBoxShouldAskQuestionChange(Sender: TObject); 105 procedure CheckBoxShouldAskQuestionChange(Sender: TObject);
103 procedure ChkCleanDotsChange(Sender: TObject); 106 procedure ChkCleanDotsChange(Sender: TObject);
104 procedure ChkDotsChange(Sender: TObject); 107 procedure ChkDotsChange(Sender: TObject);
105 procedure ComboCurrentConditionChange(Sender: TObject); 108 procedure ComboCurrentConditionChange(Sender: TObject);
106 - procedure EditConditionNameChange(Sender: TObject); 109 + procedure ComboCurrentContingencyChange(Sender: TObject);
107 procedure EditConditionNameEditingDone(Sender: TObject); 110 procedure EditConditionNameEditingDone(Sender: TObject);
  111 + procedure EditContingencyNameEditingDone(Sender: TObject);
108 procedure EditQuestionChange(Sender: TObject); 112 procedure EditQuestionChange(Sender: TObject);
109 procedure EditQuestionEditingDone(Sender: TObject); 113 procedure EditQuestionEditingDone(Sender: TObject);
110 procedure FormCreate(Sender: TObject); 114 procedure FormCreate(Sender: TObject);
@@ -135,8 +139,9 @@ type @@ -135,8 +139,9 @@ type
135 procedure SaveSectionExperiment; 139 procedure SaveSectionExperiment;
136 procedure SaveSectionCondition(LS: string); 140 procedure SaveSectionCondition(LS: string);
137 procedure SaveContingency(LS, LC: string); 141 procedure SaveContingency(LS, LC: string);
  142 + procedure EraseContingency(LS, LC : string);
138 private 143 private
139 - function GetLC(IsMeta:Boolean):string; 144 + function GetLC(IsMeta:Boolean; MustIncrement:Boolean=True):string;
140 function GetConsequenceStyle: string; 145 function GetConsequenceStyle: string;
141 function GetContingencyCriteria: string; 146 function GetContingencyCriteria: string;
142 function GetEndCriteriaPorcentage: string; 147 function GetEndCriteriaPorcentage: string;
@@ -147,6 +152,8 @@ type @@ -147,6 +152,8 @@ type
147 procedure SetCGQuestion(AQuestionStyle: string); 152 procedure SetCGQuestion(AQuestionStyle: string);
148 procedure SetRGEndCriteriaStyle(AStyle: string); 153 procedure SetRGEndCriteriaStyle(AStyle: string);
149 procedure SetContingencyCriteria(S: string); 154 procedure SetContingencyCriteria(S: string);
  155 + procedure SetConsequenceStyle(S:string);
  156 + procedure SetContingencyStyle(S:string);
150 public 157 public
151 { public declarations } 158 { public declarations }
152 end; 159 end;
@@ -374,20 +381,14 @@ begin @@ -374,20 +381,14 @@ begin
374 381
375 if ComboCurrentCondition.ItemIndex <> -1 then 382 if ComboCurrentCondition.ItemIndex <> -1 then
376 begin 383 begin
377 - LS := SEC_CONDITION + IntToStr(ComboCurrentCondition.ItemIndex + 1); 384 + LS := ExtractDelimited(1,ComboCurrentCondition.Text,['|']);
378 LoadSectionCondition(LS); 385 LoadSectionCondition(LS);
379 if ComboCurrentContingency.ItemIndex <> -1 then 386 if ComboCurrentContingency.ItemIndex <> -1 then
380 - begin  
381 - LC := Delimited(1, ComboCurrentContingency.Items[ComboCurrentContingency.ItemIndex]);  
382 - LoadContingency(LS, LC);  
383 - end; 387 + begin
  388 + LC := ExtractDelimited(1, ComboCurrentContingency.Text,['|']);
  389 + LoadContingency(LS, LC);
  390 + end;
384 end; 391 end;
385 - //if NamesOnly then  
386 - // begin  
387 - // ListBoxConditions.Items.Append(LS+'|'+EditConditionName.Text);  
388 - // ComboCurrentCondition.Items.Append(LS+'|'+EditConditionName.Text);  
389 - // Exit;  
390 - // end;  
391 end; 392 end;
392 393
393 procedure TFormDesigner.SaveExperiment; 394 procedure TFormDesigner.SaveExperiment;
@@ -397,11 +398,11 @@ begin @@ -397,11 +398,11 @@ begin
397 SaveSectionExperiment; 398 SaveSectionExperiment;
398 if ComboCurrentCondition.ItemIndex <> -1 then 399 if ComboCurrentCondition.ItemIndex <> -1 then
399 begin 400 begin
400 - LS := SEC_CONDITION + IntToStr(ComboCurrentCondition.ItemIndex + 1); 401 + LS := ExtractDelimited(1,ComboCurrentCondition.Text,['|']);
401 SaveSectionCondition(LS); 402 SaveSectionCondition(LS);
402 if ComboCurrentContingency.ItemIndex <> -1 then 403 if ComboCurrentContingency.ItemIndex <> -1 then
403 begin 404 begin
404 - LC := Delimited(1, ComboCurrentContingency.Items[ComboCurrentContingency.ItemIndex]); 405 + LC := ExtractDelimited(1,ComboCurrentContingency.Text,['|']);
405 SaveContingency(LS, LC); 406 SaveContingency(LS, LC);
406 end; 407 end;
407 end; 408 end;
@@ -500,18 +501,18 @@ var @@ -500,18 +501,18 @@ var
500 begin 501 begin
501 for i := 0 to GBContingencyRows.ComponentCount - 1 do 502 for i := 0 to GBContingencyRows.ComponentCount - 1 do
502 case GBContingencyRows.Components[i].Name of 503 case GBContingencyRows.Components[i].Name of
503 - 'Chk1': TCheckBox(GBContingencyColors.Components[i]).Checked := grOne in GR;  
504 - 'Chk2': TCheckBox(GBContingencyColors.Components[i]).Checked := grTwo in GR;  
505 - 'Chk3': TCheckBox(GBContingencyColors.Components[i]).Checked := grThree in GR;  
506 - 'Chk4': TCheckBox(GBContingencyColors.Components[i]).Checked := grFour in GR;  
507 - 'Chk5': TCheckBox(GBContingencyColors.Components[i]).Checked := grFive in GR;  
508 - 'Chk6': TCheckBox(GBContingencyColors.Components[i]).Checked := grSix in GR;  
509 - 'Chk7': TCheckBox(GBContingencyColors.Components[i]).Checked := grSeven in GR;  
510 - 'Chk8': TCheckBox(GBContingencyColors.Components[i]).Checked := grEight in GR;  
511 - 'Chk9': TCheckBox(GBContingencyColors.Components[i]).Checked := grNine in GR;  
512 - 'Chk10': TCheckBox(GBContingencyColors.Components[i]).Checked := grTen in GR;  
513 - 'ChkEven': TCheckBox(GBContingencyColors.Components[i]).Checked := grEven in GR;  
514 - 'ChkOdd': TCheckBox(GBContingencyColors.Components[i]).Checked := grOdd in GR; 504 + 'Chk1': TCheckBox(GBContingencyRows.Components[i]).Checked := grOne in GR;
  505 + 'Chk2': TCheckBox(GBContingencyRows.Components[i]).Checked := grTwo in GR;
  506 + 'Chk3': TCheckBox(GBContingencyRows.Components[i]).Checked := grThree in GR;
  507 + 'Chk4': TCheckBox(GBContingencyRows.Components[i]).Checked := grFour in GR;
  508 + 'Chk5': TCheckBox(GBContingencyRows.Components[i]).Checked := grFive in GR;
  509 + 'Chk6': TCheckBox(GBContingencyRows.Components[i]).Checked := grSix in GR;
  510 + 'Chk7': TCheckBox(GBContingencyRows.Components[i]).Checked := grSeven in GR;
  511 + 'Chk8': TCheckBox(GBContingencyRows.Components[i]).Checked := grEight in GR;
  512 + 'Chk9': TCheckBox(GBContingencyRows.Components[i]).Checked := grNine in GR;
  513 + 'Chk10': TCheckBox(GBContingencyRows.Components[i]).Checked := grTen in GR;
  514 + 'ChkEven': TCheckBox(GBContingencyRows.Components[i]).Checked := grEven in GR;
  515 + 'ChkOdd': TCheckBox(GBContingencyRows.Components[i]).Checked := grOdd in GR;
515 end; 516 end;
516 end; 517 end;
517 518
@@ -528,7 +529,7 @@ var @@ -528,7 +529,7 @@ var
528 'ChkR': TCheckBox(GBContingencyColors.Components[i]).Checked := gcRed in GC; 529 'ChkR': TCheckBox(GBContingencyColors.Components[i]).Checked := gcRed in GC;
529 'ChkM': TCheckBox(GBContingencyColors.Components[i]).Checked := gcMagenta in GC; 530 'ChkM': TCheckBox(GBContingencyColors.Components[i]).Checked := gcMagenta in GC;
530 'ChkB': TCheckBox(GBContingencyColors.Components[i]).Checked := gcBlue in GC; 531 'ChkB': TCheckBox(GBContingencyColors.Components[i]).Checked := gcBlue in GC;
531 - 'ChkG': TCheckBox(GBContingencyColors.Components[i]).Checked := gcDiff in GC; 532 + 'ChkG': TCheckBox(GBContingencyColors.Components[i]).Checked := gcGreen in GC;
532 end; 533 end;
533 end; 534 end;
534 535
@@ -561,6 +562,49 @@ begin @@ -561,6 +562,49 @@ begin
561 end; 562 end;
562 end; 563 end;
563 564
  565 +procedure TFormDesigner.SetConsequenceStyle(S: string);
  566 +var
  567 + CS : TConsequenceStyle;
  568 + //LVariation : integer;
  569 + SCode,
  570 + SPoints : string;
  571 + LPoints : integer;
  572 +begin
  573 + SPoints := ExtractDelimited(1,S,['|']);
  574 + LPoints := StrToInt(ExtractDelimited(1,SPoints,[',']));
  575 + //LVariation := StrToInt(ExtractDelimited(2,SPoints,[',']));
  576 + SpinEditContingencyPoints.Value := LPoints;
  577 +
  578 + SCode := ExtractDelimited(2,S,['|']);
  579 + CS := GetConsequenceStylesFromString(SCode);
  580 + case RGPoints.ItemIndex of
  581 + 0: { A & B }
  582 + begin
  583 + if gscA in CS then CBPointsType.ItemIndex := 0;
  584 + if gscB in CS then CBPointsType.ItemIndex := 1;
  585 + if gscG in CS then CBPointsType.ItemIndex := 2;
  586 + end;
  587 + 1: { I }
  588 + begin
  589 + if gscI in CS then CBPointsType.ItemIndex := 0;
  590 + if gscG in CS then CBPointsType.ItemIndex := 1;
  591 + end;
  592 + end;
  593 + CBPointsType.Text := CBPointsType.Items[CBPointsType.ItemIndex];
  594 + CheckBoxBroadcast.State := cbUnchecked;
  595 +
  596 + if gscBroadcastMessage in CS then
  597 + CheckBoxBroadcast.State := cbChecked;
  598 +
  599 + if gscMessage in CS then
  600 + CheckBoxBroadcast.State := cbGrayed;
  601 +end;
  602 +
  603 +procedure TFormDesigner.SetContingencyStyle(S: string);
  604 +begin
  605 +
  606 +end;
  607 +
564 procedure TFormDesigner.SaveSectionExperiment; 608 procedure TFormDesigner.SaveSectionExperiment;
565 begin 609 begin
566 with FExperiment do 610 with FExperiment do
@@ -620,54 +664,98 @@ procedure TFormDesigner.SaveContingency(LS, LC: string); @@ -620,54 +664,98 @@ procedure TFormDesigner.SaveContingency(LS, LC: string);
620 begin 664 begin
621 with FExperiment do 665 with FExperiment do
622 begin 666 begin
623 - WriteString(LS, LC + KEY_NAME, EditContingencyName.Text); 667 + WriteString(LS, LC + KEY_CONT_NAME, EditContingencyName.Text);
624 WriteString(LS, LC + KEY_CRITERIA, GetContingencyCriteria); 668 WriteString(LS, LC + KEY_CRITERIA, GetContingencyCriteria);
625 WriteString(LS, LC + KEY_CONSEQUE, GetConsequenceStyle); 669 WriteString(LS, LC + KEY_CONSEQUE, GetConsequenceStyle);
626 - WriteString(LS, LC + KEY_CONSEQUE_MESSAGE_APPENDP,{todo: consequence sufix plural}'');  
627 - WriteString(LS, LC + KEY_CONSEQUE_MESSAGE_APPENDS, EditMessSufix.Text);  
628 WriteString(LS, LC + KEY_CONSEQUE_MESSAGE_PREPEND, EditMessPrefix.Text); 670 WriteString(LS, LC + KEY_CONSEQUE_MESSAGE_PREPEND, EditMessPrefix.Text);
  671 + try
  672 + WriteString(LS, LC + KEY_CONSEQUE_MESSAGE_APPENDS, ExtractDelimited(1,EditMessSufix.Text,['|']));
  673 + WriteString(LS, LC + KEY_CONSEQUE_MESSAGE_APPENDP, ExtractDelimited(2,EditMessSufix.Text,['|']));
  674 + except
  675 + on E: Exception do
  676 + Exit;
  677 + //if E.Message = 'E';
  678 +
  679 + end;
629 end; 680 end;
630 end; 681 end;
631 682
632 -function TFormDesigner.GetLC(IsMeta: Boolean): string; 683 +procedure TFormDesigner.EraseContingency(LS, LC: string);
  684 +begin
  685 + with FExperiment do
  686 + begin
  687 + DeleteKey(LS, LC + KEY_CONT_NAME);
  688 + DeleteKey(LS, LC + KEY_CRITERIA);
  689 + DeleteKey(LS, LC + KEY_CONSEQUE);
  690 + DeleteKey(LS, LC + KEY_CONSEQUE_MESSAGE_PREPEND);
  691 + DeleteKey(LS, LC + KEY_CONSEQUE_MESSAGE_APPENDS);
  692 + DeleteKey(LS, LC + KEY_CONSEQUE_MESSAGE_APPENDP);
  693 + end;
  694 +end;
  695 +
  696 +function TFormDesigner.GetLC(IsMeta: Boolean; MustIncrement: Boolean): string;
633 var 697 var
634 LCount, 698 LCount,
635 i : integer; 699 i : integer;
636 S : string; 700 S : string;
637 Extension : string; 701 Extension : string;
638 - ContingencyKey : string; 702 + ContingencyKey: string;
639 begin 703 begin
640 if ComboCurrentContingency.Items.Count > 0 then 704 if ComboCurrentContingency.Items.Count > 0 then
641 - for i := ComboCurrentContingency.Items.Count-1 downto 0 do  
642 - begin  
643 - S := ExtractDelimited(1,ComboCurrentContingency.Items[i],['|']);  
644 - ContingencyKey := ExtractFileNameWithoutExt(S);  
645 -  
646 - if IsMeta then  
647 - begin  
648 - if ContingencyKey = KEY_METACONTINGENCY[16] then  
649 - begin  
650 - Result := KEY_METACONTINGENCY;  
651 - Extension := ExtractFileExt(S);  
652 - LCount := StrToInt(Extension);  
653 - Inc(LCount);  
654 - Result += IntToStr(LCount);  
655 - Break;  
656 - end;  
657 - end  
658 - else  
659 - begin  
660 - if ContingencyKey = KEY_CONTINGENCY[12] then  
661 - begin  
662 - Result := KEY_CONTINGENCY;  
663 - Extension := ExtractFileExt(S);  
664 - Lcount := StrToInt(Extension);  
665 - Inc(LCount);  
666 - Result += IntToStr(LCount);  
667 - Break;  
668 - end;  
669 - end;  
670 - end 705 + begin
  706 + for i := ComboCurrentContingency.Items.Count-1 downto 0 do
  707 + begin
  708 + S := ExtractDelimited(1,ComboCurrentContingency.Items[i],['|']);
  709 + ContingencyKey := ExtractFileNameWithoutExt(S);
  710 +
  711 + if IsMeta then
  712 + begin
  713 + if ContingencyKey = ExtractFileNameWithoutExt(KEY_METACONTINGENCY) then
  714 + begin
  715 + Result := KEY_METACONTINGENCY;
  716 + Extension := ExtractFileExt(S);
  717 + Delete(Extension,1,1);
  718 + LCount := StrToInt(Extension);
  719 + if MustIncrement then
  720 + Inc(LCount);
  721 + Result += IntToStr(LCount);
  722 + Break;
  723 + end
  724 + else
  725 + begin
  726 + if i = 0 then
  727 + begin
  728 + Result := KEY_METACONTINGENCY+'1';
  729 + Exit;
  730 + end;
  731 + Continue;
  732 + end;
  733 + end
  734 + else
  735 + begin
  736 + if ContingencyKey = ExtractFileNameWithoutExt(KEY_CONTINGENCY) then
  737 + begin
  738 + Result := KEY_CONTINGENCY;
  739 + Extension := ExtractFileExt(S);
  740 + Delete(Extension,1,1);
  741 + LCount := StrToInt(Extension);
  742 + if MustIncrement then
  743 + Inc(LCount);
  744 + Result += IntToStr(LCount);
  745 + Break;
  746 + end
  747 + else
  748 + begin
  749 + if i = 0 then
  750 + begin
  751 + Result := KEY_CONTINGENCY+'1';
  752 + Exit;
  753 + end;
  754 + Continue;
  755 + end;
  756 + end;
  757 + end;
  758 + end
671 else 759 else
672 if IsMeta then 760 if IsMeta then
673 Result := KEY_METACONTINGENCY+'1' 761 Result := KEY_METACONTINGENCY+'1'
@@ -700,12 +788,84 @@ begin @@ -700,12 +788,84 @@ begin
700 cbGrayed: CS -= [gscMessage]; 788 cbGrayed: CS -= [gscMessage];
701 end; 789 end;
702 790
703 - Result := GetConsequenceStylesString(CS); 791 + Result := IntToStr(SpinEditContingencyPoints.Value)+',0|';
  792 + Result += GetConsequenceStylesString(CS);
704 end; 793 end;
705 794
706 function TFormDesigner.GetContingencyCriteria: string; 795 function TFormDesigner.GetContingencyCriteria: string;
707 -begin 796 +var
  797 + C: TCriteria;
  798 +
  799 + function GetContingencyRows: TGameRows;
  800 + var
  801 + i: integer;
  802 + begin
  803 + Result := [];
  804 + for i := 0 to GBContingencyRows.ComponentCount - 1 do
  805 + case GBContingencyRows.Components[i].Name of
  806 + 'Chk1': if TCheckBox(GBContingencyRows.Components[i]).Checked then Result += [grOne];
  807 + 'Chk2': if TCheckBox(GBContingencyRows.Components[i]).Checked then Result += [grTwo];
  808 + 'Chk3': if TCheckBox(GBContingencyRows.Components[i]).Checked then Result += [grThree];
  809 + 'Chk4': if TCheckBox(GBContingencyRows.Components[i]).Checked then Result += [grFour];
  810 + 'Chk5': if TCheckBox(GBContingencyRows.Components[i]).Checked then Result += [grFive];
  811 + 'Chk6': if TCheckBox(GBContingencyRows.Components[i]).Checked then Result += [grSix];
  812 + 'Chk7': if TCheckBox(GBContingencyRows.Components[i]).Checked then Result += [grSeven];
  813 + 'Chk8': if TCheckBox(GBContingencyRows.Components[i]).Checked then Result += [grEight];
  814 + 'Chk9': if TCheckBox(GBContingencyRows.Components[i]).Checked then Result += [grNine];
  815 + 'Chk10': if TCheckBox(GBContingencyRows.Components[i]).Checked then Result += [grTen];
  816 + 'ChkEven': if TCheckBox(GBContingencyRows.Components[i]).Checked then Result += [grEven];
  817 + 'ChkOdd': if TCheckBox(GBContingencyRows.Components[i]).Checked then Result += [grOdd];
  818 + end;
  819 + end;
  820 +
  821 + function GetContingencyColors: TGameColors;
  822 + var
  823 + i: integer;
  824 + begin
  825 + Result := [];
  826 + for i := 0 to GBContingencyColors.ComponentCount - 1 do
  827 + case GBContingencyColors.Components[i].Name of
  828 + 'ChkEqual': if TCheckBox(GBContingencyColors.Components[i]).Checked then Result += [gcEqual];
  829 + 'ChkDiff': if TCheckBox(GBContingencyColors.Components[i]).Checked then Result += [gcDiff];
  830 + 'ChkNot': if TCheckBox(GBContingencyColors.Components[i]).Checked then Result += [gcNot];
  831 + 'ChkY': if TCheckBox(GBContingencyColors.Components[i]).Checked then Result += [gcYellow];
  832 + 'ChkR': if TCheckBox(GBContingencyColors.Components[i]).Checked then Result += [gcRed];
  833 + 'ChkM': if TCheckBox(GBContingencyColors.Components[i]).Checked then Result += [gcMagenta];
  834 + 'ChkB': if TCheckBox(GBContingencyColors.Components[i]).Checked then Result += [gcBlue];
  835 + 'ChkG': if TCheckBox(GBContingencyColors.Components[i]).Checked then Result += [gcGreen];
  836 + end;
  837 + end;
708 838
  839 +begin
  840 + C.Style := gtNone;
  841 + C.Rows := [];
  842 + C.Colors := [];
  843 + case RGContingencyStyle.ItemIndex of
  844 + 0: { do nothing };
  845 + 1:
  846 + begin
  847 + C.Style := gtRowsOnly;
  848 + C.Rows := GetContingencyRows;
  849 + end;
  850 + 2:
  851 + begin
  852 + C.Style := gtColorsOnly;
  853 + C.Colors := GetContingencyColors;
  854 + end;
  855 + 3:
  856 + begin
  857 + C.Style := gtRowsAndColors;
  858 + C.Rows := GetContingencyRows;
  859 + C.Colors := GetContingencyColors;
  860 + end;
  861 + 4:
  862 + begin
  863 + C.Style := gtRowsOrColors;
  864 + C.Rows := GetContingencyRows;
  865 + C.Colors := GetContingencyColors;
  866 + end;
  867 + end;
  868 + Result := GetCriteriaString(C);
709 end; 869 end;
710 870
711 procedure TFormDesigner.LoadSectionCondition(LS: string); 871 procedure TFormDesigner.LoadSectionCondition(LS: string);
@@ -737,18 +897,20 @@ end; @@ -737,18 +897,20 @@ end;
737 897
738 procedure TFormDesigner.LoadContingency(LS, LC: string); 898 procedure TFormDesigner.LoadContingency(LS, LC: string);
739 begin 899 begin
740 - if Pos('Metacontingency', LC) > 0 then 900 + if Pos(KEY_METACONTINGENCY, LC) > 0 then
741 CheckBoxIsMeta.Checked := True 901 CheckBoxIsMeta.Checked := True
742 else 902 else
743 CheckBoxIsMeta.Checked := False; 903 CheckBoxIsMeta.Checked := False;
744 904
745 with FExperiment do 905 with FExperiment do
746 if ValueExists(LS, LC + KEY_CONSEQUE) and ValueExists(LS, LC + KEY_CRITERIA) then 906 if ValueExists(LS, LC + KEY_CONSEQUE) and ValueExists(LS, LC + KEY_CRITERIA) then
747 - begin  
748 - EditContingencyName.Text := ReadString(LS, LC + KEY_NAME, '');  
749 - SetContingencyCriteria(ReadString(LS, LC + KEY_CRITERIA, ''));  
750 - ReadString(LS, LC + KEY_CONSEQUE, '');  
751 - end; 907 + begin
  908 + EditContingencyName.Text := ReadString(LS, LC + KEY_CONT_NAME, '');
  909 + SetContingencyCriteria(ReadString(LS, LC + KEY_CRITERIA, ''));
  910 + SetContingencyStyle(ReadString(LS, LC + KEY_CONSEQUE, ''));
  911 + EditMessPrefix.Text := ReadString(LS, LC + KEY_CONSEQUE_MESSAGE_PREPEND,'');
  912 + EditMessSufix.Text := ReadString(LS, LC + KEY_CONSEQUE_MESSAGE_APPENDS,'')+'|'+ReadString(LS, LC + KEY_CONSEQUE_MESSAGE_APPENDP,'');
  913 + end;
752 end; 914 end;
753 915
754 function TFormDesigner.GetEndCriteriaPorcentage: string; 916 function TFormDesigner.GetEndCriteriaPorcentage: string;
@@ -823,9 +985,9 @@ begin @@ -823,9 +985,9 @@ begin
823 LoadSectionCondition(SEC_CONDITION + IntToStr(ComboCurrentCondition.ItemIndex + 1)); 985 LoadSectionCondition(SEC_CONDITION + IntToStr(ComboCurrentCondition.ItemIndex + 1));
824 end; 986 end;
825 987
826 -procedure TFormDesigner.EditConditionNameChange(Sender: TObject); 988 +procedure TFormDesigner.ComboCurrentContingencyChange(Sender: TObject);
827 begin 989 begin
828 - 990 + LoadContingency(ExtractDelimited(1,ComboCurrentCondition.Text,['|']),ExtractDelimited(1,ComboCurrentContingency.Text,['|']));
829 end; 991 end;
830 992
831 procedure TFormDesigner.EditConditionNameEditingDone(Sender: TObject); 993 procedure TFormDesigner.EditConditionNameEditingDone(Sender: TObject);
@@ -843,6 +1005,22 @@ begin @@ -843,6 +1005,22 @@ begin
843 end; 1005 end;
844 end; 1006 end;
845 1007
  1008 +procedure TFormDesigner.EditContingencyNameEditingDone(Sender: TObject);
  1009 +var
  1010 + LS, LC: string;
  1011 +begin
  1012 + with FExperiment do
  1013 + if ComboCurrentContingency.ItemIndex <> -1 then
  1014 + begin
  1015 + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1);
  1016 + LC := ExtractDelimited(1,ComboCurrentContingency.Text,['|']);
  1017 + WriteString(LS, LC+ KEY_CONT_NAME, EditContingencyName.Text);
  1018 + ComboCurrentContingency.Items[ComboCurrentContingency.ItemIndex] :=
  1019 + LC + '|' + EditContingencyName.Text;
  1020 + ListBoxContingencies.Items.Text := ComboCurrentContingency.Items.Text;
  1021 + end;
  1022 +end;
  1023 +
846 procedure TFormDesigner.EditQuestionChange(Sender: TObject); 1024 procedure TFormDesigner.EditQuestionChange(Sender: TObject);
847 begin 1025 begin
848 1026
@@ -887,9 +1065,9 @@ var @@ -887,9 +1065,9 @@ var
887 LS, LC : string; 1065 LS, LC : string;
888 1066
889 begin 1067 begin
890 - i := ComboCurrentContingency.Items.Add('');  
891 LS := ExtractDelimited(1,ComboCurrentCondition.Items[ComboCurrentCondition.ItemIndex],['|']); 1068 LS := ExtractDelimited(1,ComboCurrentCondition.Items[ComboCurrentCondition.ItemIndex],['|']);
892 LC := GetLC(CheckBoxIsMeta.Checked); 1069 LC := GetLC(CheckBoxIsMeta.Checked);
  1070 + i := ComboCurrentContingency.Items.Add('');
893 ComboCurrentContingency.Items[i] := 1071 ComboCurrentContingency.Items[i] :=
894 LC + '|' + EditContingencyName.Text; 1072 LC + '|' + EditContingencyName.Text;
895 ComboCurrentContingency.ItemIndex := i; 1073 ComboCurrentContingency.ItemIndex := i;
@@ -904,27 +1082,30 @@ var @@ -904,27 +1082,30 @@ var
904 1082
905 procedure Reorder(index : integer); 1083 procedure Reorder(index : integer);
906 var 1084 var
907 - j, i: integer; 1085 + i: integer;
908 Section: TStringList; 1086 Section: TStringList;
909 KeyName,Line,SectionName: string; 1087 KeyName,Line,SectionName: string;
910 begin 1088 begin
911 Section := TStringList.Create; 1089 Section := TStringList.Create;
912 with FExperiment do 1090 with FExperiment do
913 for i := index to ComboCurrentCondition.Items.Count - 1 do 1091 for i := index to ComboCurrentCondition.Items.Count - 1 do
914 - begin  
915 - SectionName := ExtractDelimited(1, ComboCurrentCondition.Items[i], ['|']);  
916 - ReadSectionValues(SectionName, Section);  
917 - EraseSection(SectionName);  
918 - SectionName := SEC_CONDITION + IntToStr(i + 1);  
919 - for Line in Section do  
920 - begin  
921 - KeyName := Section.ExtractName(Line);  
922 - WriteString(SectionName, KeyName, Section.Values[KeyName]);  
923 - end;  
924 - Section.Clear;  
925 - ComboCurrentCondition.Items[i] :=  
926 - SectionName + '|' + ExtractDelimited(2, ComboCurrentCondition.Items[i], ['|']);  
927 - end; 1092 + begin
  1093 + // whatever the section name is, save and erase section
  1094 + SectionName := ExtractDelimited(1, ComboCurrentCondition.Items[i], ['|']);
  1095 + ReadSectionValues(SectionName, Section);
  1096 + EraseSection(SectionName);
  1097 +
  1098 + // then rename and rewrite section
  1099 + SectionName := SEC_CONDITION + IntToStr(i + 1);
  1100 + for Line in Section do
  1101 + begin
  1102 + KeyName := Section.ExtractName(Line);
  1103 + WriteString(SectionName, KeyName, Section.Values[KeyName]);
  1104 + end;
  1105 + Section.Clear;
  1106 + ComboCurrentCondition.Items[i] :=
  1107 + SectionName + '|' + ExtractDelimited(2, ComboCurrentCondition.Items[i], ['|']);
  1108 + end;
928 Section.Free; 1109 Section.Free;
929 end; 1110 end;
930 1111
@@ -942,9 +1123,80 @@ begin @@ -942,9 +1123,80 @@ begin
942 else 1123 else
943 ComboCurrentCondition.ItemIndex := i -1; 1124 ComboCurrentCondition.ItemIndex := i -1;
944 end; 1125 end;
945 - ListBoxConditions.Items.Text := ComboCurrentCondition.Items.Text; 1126 + ListBoxContingencies.Items.Text := ComboCurrentCondition.Items.Text;
  1127 +end;
  1128 +
  1129 +procedure TFormDesigner.BtnRemoveContingencyClick(Sender: TObject);
  1130 +var
  1131 + i: integer;
  1132 + MustReorder: boolean;
  1133 +
  1134 + procedure ReadContingencyValuesInSection(LS,LC : string; var Keys : TStringList);
  1135 + begin
  1136 + Keys.BeginUpdate;
  1137 + with FExperiment do
  1138 + begin
  1139 + Keys.Values[LC + KEY_NAME] := ReadString(LS,LC+KEY_NAME,'');
  1140 + Keys.Values[LC + KEY_CRITERIA] := ReadString(LS, LC + KEY_CRITERIA,'');
  1141 + Keys.Values[LC + KEY_CONSEQUE] := ReadString(LS, LC + KEY_CONSEQUE,'');
  1142 + Keys.Values[LC + KEY_CONSEQUE_MESSAGE_PREPEND] := ReadString(LS, LC + KEY_CONSEQUE_MESSAGE_PREPEND,'');
  1143 + Keys.Values[LC + KEY_CONSEQUE_MESSAGE_APPENDS] := ReadString(LS, LC + KEY_CONSEQUE_MESSAGE_APPENDS,'');
  1144 + Keys.Values[LC + KEY_CONSEQUE_MESSAGE_APPENDP] := ReadString(LS, LC + KEY_CONSEQUE_MESSAGE_APPENDP,'');
  1145 + end;
  1146 + Keys.EndUpdate;
  1147 + end;
  1148 +
  1149 + procedure Reorder(index : integer);
  1150 + var
  1151 + i: integer;
  1152 + SectionKeys: TStringList;
  1153 + KeyName,Line,SectionName: string;
  1154 + begin
  1155 + SectionKeys := TStringList.Create;
  1156 + with FExperiment do
  1157 + for i := index to ComboCurrentContingency.Items.Count - 1 do
  1158 + begin
  1159 + SectionName := ExtractDelimited(1, ComboCurrentCondition.Items[ComboCurrentCondition.ItemIndex], ['|']);
  1160 + KeyName := ExtractDelimited(1, ComboCurrentContingency.Items[i], ['|']);
  1161 + ReadContingencyValuesInSection(SectionName,KeyName, SectionKeys);
  1162 + EraseContingency(SectionName,KeyName);
  1163 + // todo: contingencies on top, meta on bootom...
  1164 + KeyName := GetLC(ExtractFileNameWithoutExt(KeyName) = ExtractFileNameWithoutExt(KEY_METACONTINGENCY));
  1165 + for Line in SectionKeys do
  1166 + begin
  1167 + KeyName := SectionKeys.ExtractName(Line);
  1168 + WriteString(SectionName, KeyName, SectionKeys.Values[KeyName]);
  1169 + end;
  1170 + SectionKeys.Clear;
  1171 + ComboCurrentContingency.Items[i] :=
  1172 + KeyName + '|' + ExtractDelimited(2, ComboCurrentContingency.Items[i], ['|']);
  1173 + end;
  1174 + SectionKeys.Free;
  1175 + end;
  1176 +
  1177 +begin
  1178 + i := ComboCurrentContingency.ItemIndex;
  1179 + MustReorder := i < ComboCurrentContingency.Items.Count - 1;
  1180 + ComboCurrentContingency.Items.Delete(i);
  1181 + if MustReorder then
  1182 + Reorder(i);
  1183 + case ComboCurrentContingency.Items.Count of
  1184 + 0: {do nothing};
  1185 + 1..MaxInt:
  1186 + if i = 1 then
  1187 + ComboCurrentContingency.ItemIndex := i
  1188 + else
  1189 + ComboCurrentContingency.ItemIndex := i -1;
  1190 + end;
  1191 + ListBoxContingencies.Items.Text := ComboCurrentContingency.Items.Text;
  1192 +end;
  1193 +
  1194 +procedure TFormDesigner.CBPointsTypeChange(Sender: TObject);
  1195 +begin
  1196 +
946 end; 1197 end;
947 1198
  1199 +
948 procedure TFormDesigner.CGQuestionItemClick(Sender: TObject; Index: integer); 1200 procedure TFormDesigner.CGQuestionItemClick(Sender: TObject; Index: integer);
949 var 1201 var
950 LS: String; 1202 LS: String;
@@ -961,6 +1213,7 @@ procedure TFormDesigner.CheckBoxIsMetaChange(Sender: TObject); @@ -961,6 +1213,7 @@ procedure TFormDesigner.CheckBoxIsMetaChange(Sender: TObject);
961 var 1213 var
962 i: integer; 1214 i: integer;
963 CH: TCheckBox; 1215 CH: TCheckBox;
  1216 + LS,LC : string;
964 1217
965 procedure CreateChkBox(N, C: string; AOwner: TWinControl); 1218 procedure CreateChkBox(N, C: string; AOwner: TWinControl);
966 begin 1219 begin
@@ -968,6 +1221,9 @@ var @@ -968,6 +1221,9 @@ var
968 CH.Name := N; 1221 CH.Name := N;
969 CH.Caption := C; 1222 CH.Caption := C;
970 CH.Parent := AOwner; 1223 CH.Parent := AOwner;
  1224 + CH.ShowHint := True;
  1225 + CH.Hint := C;
  1226 + CH.OnChange := @CheckBoxColorsRowsChange;
971 end; 1227 end;
972 1228
973 begin 1229 begin
@@ -1002,6 +1258,48 @@ begin @@ -1002,6 +1258,48 @@ begin
1002 CreateChkBox('ChkG', 'VERDE', GBContingencyColors); 1258 CreateChkBox('ChkG', 'VERDE', GBContingencyColors);
1003 LabelIf.Caption := 'SE O PARTICIPANTE ESCOLHER'; 1259 LabelIf.Caption := 'SE O PARTICIPANTE ESCOLHER';
1004 end; 1260 end;
  1261 +
  1262 +
  1263 + if Sender = CheckBoxIsMeta then
  1264 + if ComboCurrentCondition.Items.Count > 0 then
  1265 + if ComboCurrentContingency.Items.Count > 0 then
  1266 + begin
  1267 + LS := ExtractDelimited(1,ComboCurrentCondition.Text,['|']);
  1268 + LC := ExtractDelimited(1, ComboCurrentContingency.Text,['|']);
  1269 + EraseContingency(LS,LC);
  1270 + LC := GetLC(TCheckBox(Sender).Checked,False);
  1271 + SaveContingency(LS,LC);
  1272 + ComboCurrentContingency.Items[ComboCurrentContingency.ItemIndex] := LC +'|'+ EditContingencyName.Text;
  1273 + ListBoxContingencies.Items.Text := ComboCurrentContingency.Items.Text;
  1274 + end;
  1275 +end;
  1276 +
  1277 +procedure TFormDesigner.CheckBoxColorsRowsChange(Sender: TObject);
  1278 +var
  1279 + LS, LC : String;
  1280 +
  1281 + procedure UncheckBox(ACheckBoxName : string);
  1282 + var i : integer;
  1283 + begin
  1284 + for i := 0 to TCheckBox(Sender).Owner.ComponentCount -1 do
  1285 + if TCheckBox(Sender).Owner.Components[i].Name = ACheckBoxName then
  1286 + TCheckBox(TCheckBox(Sender).Owner.Components[i]).Checked := not TCheckBox(Sender).Checked;
  1287 + end;
  1288 +
  1289 +begin
  1290 + LS := ExtractDelimited(1,ComboCurrentCondition.Text,['|']);
  1291 + LC := ExtractDelimited(1,ComboCurrentContingency.Text,['|']);
  1292 + with FExperiment do
  1293 + WriteString(LS, LC + KEY_CRITERIA, GetContingencyCriteria);
  1294 +
  1295 + if TCheckBox(Sender).Name = 'ChkEqual' then
  1296 + if TCheckBox(Sender).Checked then
  1297 + UncheckBox('ChkDiff');
  1298 +
  1299 + if TCheckBox(Sender).Name = 'ChkDiff' then
  1300 + if TCheckBox(Sender).Checked then
  1301 + UncheckBox('ChkEqual');
  1302 +
1005 end; 1303 end;
1006 1304
1007 end. 1305 end.
units/game_resources.pas
@@ -70,6 +70,7 @@ resourcestring @@ -70,6 +70,7 @@ resourcestring
70 KEY_METACONTINGENCY = 'Metacontingência.'; 70 KEY_METACONTINGENCY = 'Metacontingência.';
71 71
72 // ROW,COLOR,OPCODE 72 // ROW,COLOR,OPCODE
  73 + KEY_CONT_NAME = '.Nome';
73 KEY_CRITERIA = '.Resposta'; 74 KEY_CRITERIA = '.Resposta';
74 KEY_CONSEQUE = '.Consequência'; // A,B,G,CSQCODE 75 KEY_CONSEQUE = '.Consequência'; // A,B,G,CSQCODE
75 KEY_CONSEQUE_MESSAGE_PREPEND = '.Consequência.Mensagem.Prefixo'; 76 KEY_CONSEQUE_MESSAGE_PREPEND = '.Consequência.Mensagem.Prefixo';
units/gui_file_methods.pas
@@ -1,15 +0,0 @@ @@ -1,15 +0,0 @@
1 -unit gui_file_methods;  
2 -  
3 -{$mode objfpc}{$H+}  
4 -  
5 -interface  
6 -  
7 -uses  
8 - Classes, SysUtils, IniFiles;  
9 -  
10 -  
11 -  
12 -implementation  
13 -  
14 -end.  
15 -  
units/string_methods.pas
@@ -135,6 +135,7 @@ end; @@ -135,6 +135,7 @@ end;
135 135
136 function GetRowString(ARow: TGameRow): string; 136 function GetRowString(ARow: TGameRow): string;
137 begin 137 begin
  138 + Result := '';
138 case ARow of 139 case ARow of
139 grNone : Result := '0'; 140 grNone : Result := '0';
140 grOne : Result := '1'; 141 grOne : Result := '1';
@@ -155,7 +156,7 @@ end; @@ -155,7 +156,7 @@ end;
155 function GetRowFromString(S: string): TGameRow; 156 function GetRowFromString(S: string): TGameRow;
156 begin 157 begin
157 case UpperCase(S) of 158 case UpperCase(S) of
158 - 'NA', '.' , '0', 'NONE' : Result := grNone; 159 + 'NA', '.' , '0', 'NONE' : Result := grNone;
159 '01', '1', 'UM', 'ONE' : Result := grOne; 160 '01', '1', 'UM', 'ONE' : Result := grOne;
160 '02', '2', 'DOIS', 'TWO' : Result := grTwo; 161 '02', '2', 'DOIS', 'TWO' : Result := grTwo;
161 '03', '3', 'TRÊS', 'THREE' : Result := grThree; 162 '03', '3', 'TRÊS', 'THREE' : Result := grThree;
@@ -173,6 +174,7 @@ end; @@ -173,6 +174,7 @@ end;
173 174
174 function GetColorString(AColor: TGameColor): string; 175 function GetColorString(AColor: TGameColor): string;
175 begin 176 begin
  177 + Result := '';
176 case AColor of 178 case AColor of
177 gcNone :Result := 'INDIFERENTE'; 179 gcNone :Result := 'INDIFERENTE';
178 gcYellow :Result := 'AMARELO'; 180 gcYellow :Result := 'AMARELO';
@@ -202,7 +204,6 @@ end; @@ -202,7 +204,6 @@ end;
202 204
203 function GetGamePromptStyleFromString(S: string): TGamePromptStyle; 205 function GetGamePromptStyleFromString(S: string): TGamePromptStyle;
204 begin 206 begin
205 - // todos,sim,metacontingência,recuperar pontos,  
206 case UpperCase(S) of 207 case UpperCase(S) of
207 //'NENHUM','NONE': Result:=[gsNone]; 208 //'NENHUM','NONE': Result:=[gsNone];
208 'TODOS', 'ALL' : Result := gsAll; 209 'TODOS', 'ALL' : Result := gsAll;
@@ -249,6 +250,7 @@ end; @@ -249,6 +250,7 @@ end;
249 250
250 function GetConsequenceStyleString(AStyle: TGameConsequenceStyle): string; 251 function GetConsequenceStyleString(AStyle: TGameConsequenceStyle): string;
251 begin 252 begin
  253 + Result := '';
252 case AStyle of 254 case AStyle of
253 gscNone : Result:= 'NADA'; 255 gscNone : Result:= 'NADA';
254 gscMessage : Result:= 'MENSAGEM' ; 256 gscMessage : Result:= 'MENSAGEM' ;
@@ -266,6 +268,7 @@ function GetCriteriaString(ACriteria: TCriteria): string; @@ -266,6 +268,7 @@ function GetCriteriaString(ACriteria: TCriteria): string;
266 var R : TGameRow; 268 var R : TGameRow;
267 C : TGameColor; 269 C : TGameColor;
268 begin 270 begin
  271 + Result := '';
269 for R in ACriteria.Rows do 272 for R in ACriteria.Rows do
270 Result += GetRowString(R) + VV_SEP; 273 Result += GetRowString(R) + VV_SEP;
271 Result += '|'; 274 Result += '|';