From 17c83cacbb88d836fb8a676faf3c51fcbe6b4944 Mon Sep 17 00:00:00 2001 From: cpicanco Date: Fri, 9 Dec 2016 12:23:59 -0300 Subject: [PATCH] gui incremental work --- experiment_designer/experiment_designer.lpi | 8 ++++++-- experiment_designer/form_main.lfm | 319 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------- experiment_designer/form_main.pas | 940 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------- experiment_designer/lib/x86_64-linux/experiment_designer.compiled | 2 +- 4 files changed, 982 insertions(+), 287 deletions(-) diff --git a/experiment_designer/experiment_designer.lpi b/experiment_designer/experiment_designer.lpi index 66578ef..a5f5de2 100644 --- a/experiment_designer/experiment_designer.lpi +++ b/experiment_designer/experiment_designer.lpi @@ -32,7 +32,7 @@ - + @@ -48,6 +48,10 @@ + + + + @@ -57,7 +61,7 @@ - + diff --git a/experiment_designer/form_main.lfm b/experiment_designer/form_main.lfm index 76b9d9c..7977b93 100644 --- a/experiment_designer/form_main.lfm +++ b/experiment_designer/form_main.lfm @@ -1,27 +1,27 @@ object FormDesigner: TFormDesigner - Left = 114 + Left = 180 Height = 635 - Top = 53 + Top = 54 Width = 656 - HorzScrollBar.Page = 521 - VertScrollBar.Page = 616 + HorzScrollBar.Page = 387 + VertScrollBar.Page = 482 AutoScroll = True Caption = 'Planejar Experimento' ClientHeight = 616 - ClientWidth = 646 + ClientWidth = 656 Menu = MainMenu1 OnCreate = FormCreate OnDestroy = FormDestroy - SessionProperties = 'Caption;ComboCurrentCondition.ItemIndex;ComboCurrentCondition.Items;ComboCurrentContingency.ItemIndex;ComboCurrentContingency.Items;Height;Left;PageControl.TabIndex;Top;Width;WindowState' + SessionProperties = 'Caption;ComboCurrentCondition.ItemIndex;ComboCurrentCondition.Items;ComboCurrentContingency.ItemIndex;ComboCurrentContingency.Items;Height;Left;PageControl.TabIndex;Top;Width;WindowState;LabelIf.Caption' LCLVersion = '1.6.2.0' object PageControl: TPageControl Left = 0 - Height = 711 + Height = 616 Top = 0 - Width = 646 - ActivePage = TabSheetConditions + Width = 656 + ActivePage = TabSheetContingencies Align = alClient - TabIndex = 1 + TabIndex = 2 TabOrder = 0 object TabSheetExperiment: TTabSheet Caption = 'Experimento' @@ -30,13 +30,13 @@ object FormDesigner: TFormDesigner ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 - ClientHeight = 678 - ClientWidth = 640 + ClientHeight = 583 + ClientWidth = 650 object LabelResearcherName: TLabel Left = 0 Height = 15 Top = 10 - Width = 619 + Width = 640 Caption = 'Nome do Pesquisador' ParentColor = False end @@ -45,14 +45,14 @@ object FormDesigner: TFormDesigner Height = 25 Hint = 'Uma pasta será criada com o seu nome. Os seus experimentos serão salvos dentro dela.' Top = 30 - Width = 619 + Width = 640 TabOrder = 0 end object LabelExperimentName: TLabel Left = 0 Height = 15 Top = 60 - Width = 619 + Width = 640 Caption = 'Nome do Experimento' ParentColor = False end @@ -61,23 +61,23 @@ object FormDesigner: TFormDesigner Height = 25 Hint = 'Uma pasta será criada com o nome do experimento. Os dados desse experimento serão salvos dentro dela.' Top = 80 - Width = 619 + Width = 640 TabOrder = 1 end object GBExperimentAim: TGroupBox Left = 0 Height = 159 Top = 110 - Width = 619 + Width = 640 Caption = 'Objetivo do Experimento' ClientHeight = 142 - ClientWidth = 615 + ClientWidth = 636 TabOrder = 2 object MemoExperimentAim: TMemo Left = 0 Height = 142 Top = 0 - Width = 615 + Width = 636 Align = alCustom Anchors = [akTop, akLeft, akRight] TabOrder = 0 @@ -88,7 +88,7 @@ object FormDesigner: TFormDesigner Height = 113 Hint = 'Aplicáveis ao longo de todo o experimento' Top = 274 - Width = 619 + Width = 640 AutoFill = True Caption = 'Configurações globais' ChildSizing.LeftRightSpacing = 6 @@ -100,7 +100,7 @@ object FormDesigner: TFormDesigner ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 ClientHeight = 96 - ClientWidth = 615 + ClientWidth = 636 Items.Strings = ( 'Enviar histórico do bate-papo a novos participantes' 'Gerar participantes automaticamente' @@ -116,7 +116,7 @@ object FormDesigner: TFormDesigner Left = 0 Height = 59 Top = 392 - Width = 619 + Width = 640 AutoFill = True Caption = 'Tipo de pontuação' ChildSizing.LeftRightSpacing = 6 @@ -127,7 +127,7 @@ object FormDesigner: TFormDesigner ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 ClientHeight = 42 - ClientWidth = 615 + ClientWidth = 636 ItemIndex = 0 Items.Strings = ( 'A e B' @@ -136,52 +136,84 @@ object FormDesigner: TFormDesigner OnClick = RGPointsClick TabOrder = 4 end - object CGMatrix: TCheckGroup + object GBMatrix: TGroupBox Left = 0 - Height = 134 + Height = 122 Top = 456 - Width = 619 - AutoFill = True - Caption = 'Tipo da matrix' - ChildSizing.LeftRightSpacing = 6 - ChildSizing.TopBottomSpacing = 6 - ChildSizing.EnlargeHorizontal = crsHomogenousChildResize - ChildSizing.EnlargeVertical = crsHomogenousChildResize - ChildSizing.ShrinkHorizontal = crsScaleChilds - ChildSizing.ShrinkVertical = crsScaleChilds + Width = 640 + Caption = 'Tipo da Matrix' + ChildSizing.LeftRightSpacing = 5 ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 - ClientHeight = 117 - ClientWidth = 615 - Items.Strings = ( - '5 cores' - '10 Linhas' - '10 Colunas' - 'Círculos' - 'Círculos Vazados' - ) - TabOrder = 5 - Data = { - 050000000303020202 - } + ClientHeight = 105 + ClientWidth = 636 + TabOrder = 6 + object ChkColors: TCheckBox + Left = 5 + Height = 21 + Top = 0 + Width = 169 + Caption = '5 cores' + Checked = True + Enabled = False + State = cbChecked + TabOrder = 0 + end + object ChkRows: TCheckBox + Left = 5 + Height = 21 + Top = 21 + Width = 169 + Caption = '10 linhas' + Checked = True + Enabled = False + State = cbChecked + TabOrder = 1 + end + object ChkCols: TCheckBox + Left = 5 + Height = 21 + Top = 42 + Width = 169 + Caption = '10 colunas' + TabOrder = 2 + end + object ChkDots: TCheckBox + Left = 5 + Height = 21 + Top = 63 + Width = 169 + Caption = 'Com Círculos Preechidos' + OnChange = ChkDotsChange + TabOrder = 3 + end + object ChkCleanDots: TCheckBox + Left = 5 + Height = 21 + Top = 84 + Width = 169 + Caption = 'Com Círculos Vazados' + OnChange = ChkCleanDotsChange + TabOrder = 4 + end end object GBConditions: TGroupBox Left = 0 Height = 97 - Top = 595 - Width = 619 + Top = 583 + Width = 640 Caption = 'Condições' ClientHeight = 80 - ClientWidth = 615 - TabOrder = 6 + ClientWidth = 636 + TabOrder = 5 object ListBoxConditions: TListBox Left = 0 Height = 80 Top = 0 - Width = 615 + Width = 636 Anchors = [akTop, akLeft, akRight] ItemHeight = 0 - ScrollWidth = 613 + ScrollWidth = 634 TabOrder = 0 TopIndex = -1 end @@ -194,14 +226,15 @@ object FormDesigner: TFormDesigner ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 - ClientHeight = 678 - ClientWidth = 640 + ClientHeight = 583 + ClientWidth = 650 object ComboCurrentCondition: TComboBox Left = 0 Height = 27 Top = 10 Width = 640 ItemHeight = 0 + OnChange = ComboCurrentConditionChange Style = csDropDownList TabOrder = 0 end @@ -224,6 +257,7 @@ object FormDesigner: TFormDesigner Top = 0 Width = 162 Caption = 'Adicionar' + OnClick = BtnAppendCondClick TabOrder = 0 end object BtnRemoveCond: TButton @@ -232,6 +266,7 @@ object FormDesigner: TFormDesigner Top = 0 Width = 159 Caption = 'Remover' + OnClick = BtnRemoveCondClick TabOrder = 1 end object BtnReorderCond: TButton @@ -257,6 +292,7 @@ object FormDesigner: TFormDesigner Height = 25 Top = 93 Width = 640 + OnEditingDone = EditConditionNameEditingDone TabOrder = 2 end object LabelTurnValue: TLabel @@ -274,31 +310,49 @@ object FormDesigner: TFormDesigner Width = 640 MaxValue = 5 MinValue = 2 + OnEditingDone = SpinEditTurnValueEditingDone TabOrder = 3 Value = 2 end - object LabelCyclesValue: TLabel + object LabelPointsOnConditionBegin: TLabel Left = 0 Height = 15 Top = 173 Width = 640 + Caption = 'Pontos ao início da Condição' + ParentColor = False + end + object SpinEditOnConditionBegin: TSpinEdit + Left = 0 + Height = 25 + Top = 193 + Width = 640 + MaxValue = 0 + TabOrder = 9 + end + object LabelCyclesValue: TLabel + Left = 0 + Height = 15 + Top = 223 + Width = 640 Caption = 'Ciclos para mudança de geração / linhagem' ParentColor = False end object SpinEditCyclesValue: TSpinEdit Left = 0 Height = 25 - Top = 193 + Top = 243 Width = 640 MaxValue = 1000 MinValue = 1 + OnEditingDone = SpinEditCyclesValueEditingDone TabOrder = 4 Value = 1 end object GBQuestion: TGroupBox Left = 0 Height = 144 - Top = 223 + Top = 273 Width = 640 Caption = 'Apresentar pergunta ao final do ciclo' ChildSizing.LeftRightSpacing = 50 @@ -308,7 +362,7 @@ object FormDesigner: TFormDesigner ChildSizing.ControlsPerLine = 1 ClientHeight = 127 ClientWidth = 636 - TabOrder = 8 + TabOrder = 5 object CheckBoxShouldAskQuestion: TCheckBox Left = 50 Height = 21 @@ -323,6 +377,7 @@ object FormDesigner: TFormDesigner Height = 25 Top = 26 Width = 536 + OnEditingDone = EditQuestionEditingDone TabOrder = 1 Text = 'Um item escolar foi perdido, desejam recuperá-lo gastando pontos do Tipo A?' Visible = False @@ -348,6 +403,7 @@ object FormDesigner: TFormDesigner 'Reverter consequências das metacontingências e contingências' 'Inverter pontos A e B quando pontos B forem consequências' ) + OnItemClick = CGQuestionItemClick TabOrder = 2 Visible = False Data = { @@ -358,7 +414,7 @@ object FormDesigner: TFormDesigner object RGEndCriteriaStyle: TRadioGroup Left = 0 Height = 80 - Top = 372 + Top = 422 Width = 640 AutoFill = True Caption = 'Estilo do critério de finalização da condição' @@ -383,7 +439,7 @@ object FormDesigner: TFormDesigner object GBEndCriteria: TGroupBox Left = 0 Height = 109 - Top = 457 + Top = 507 Width = 640 Caption = 'Valores do critério de finalização da condição' ChildSizing.LeftRightSpacing = 50 @@ -393,7 +449,7 @@ object FormDesigner: TFormDesigner ChildSizing.ControlsPerLine = 1 ClientHeight = 92 ClientWidth = 636 - TabOrder = 5 + TabOrder = 7 object LabelEndCriteriaAbsCycles: TLabel Left = 50 Height = 15 @@ -408,6 +464,7 @@ object FormDesigner: TFormDesigner Top = 20 Width = 536 MaxValue = 1000 + OnEditingDone = SpinEditEndCriteriaAbsCyclesEditingDone TabOrder = 0 Value = 20 end @@ -428,6 +485,7 @@ object FormDesigner: TFormDesigner Height = 25 Top = 0 Width = 50 + OnEditingDone = SpinEditEndCriteriaInterlockingEditingDone TabOrder = 0 Value = 80 end @@ -448,6 +506,7 @@ object FormDesigner: TFormDesigner Width = 50 MaxValue = 1000 MinValue = 2 + OnEditingDone = SpinEditEndCriteriaInterlockingEditingDone TabOrder = 1 Value = 10 end @@ -466,12 +525,12 @@ object FormDesigner: TFormDesigner object GBContingencies: TGroupBox Left = 0 Height = 97 - Top = 571 + Top = 621 Width = 640 Caption = 'Contingências e Metacontingências' ClientHeight = 80 ClientWidth = 636 - TabOrder = 7 + TabOrder = 8 object ListBoxContingencies: TListBox Left = 0 Height = 80 @@ -492,8 +551,8 @@ object FormDesigner: TFormDesigner ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 - ClientHeight = 678 - ClientWidth = 640 + ClientHeight = 583 + ClientWidth = 650 object ComboCurrentContingency: TComboBox Left = 0 Height = 27 @@ -522,6 +581,7 @@ object FormDesigner: TFormDesigner Top = 0 Width = 166 Caption = 'Adicionar' + OnClick = BtnAppendContingencyClick TabOrder = 0 end object BtnRemoveContingency: TButton @@ -598,55 +658,27 @@ object FormDesigner: TFormDesigner Top = 276 Width = 650 Alignment = taCenter - Caption = 'SE' + Caption = 'SE O PARTICIPANTE ESCOLHER' ParentColor = False Visible = False end object GBContingencyRows: TGroupBox Left = 0 - Height = 40 + Height = 17 Top = 296 Width = 650 Caption = 'Linhas' + ChildSizing.LeftRightSpacing = 5 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize - ChildSizing.Layout = cclTopToBottomThenLeftToRight - ChildSizing.ControlsPerLine = 1 - ClientHeight = 23 - ClientWidth = 646 + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 4 TabOrder = 5 Visible = False - object ComboBoxRows: TComboBox - Left = 0 - Height = 23 - Top = 0 - Width = 646 - ItemHeight = 0 - ItemIndex = 0 - Items.Strings = ( - '1' - '2' - '3' - '4' - '5' - '6' - '7' - '8' - '9' - '10' - 'PARES' - 'IMPARES' - 'TUDO EXCETO PARES' - 'TUDO EXCETO IMPARES' - ) - Style = csDropDownList - TabOrder = 0 - Text = '1' - end end object LabelOperator: TLabel Left = 0 Height = 15 - Top = 341 + Top = 318 Width = 650 Alignment = taCenter Caption = 'E' @@ -655,39 +687,21 @@ object FormDesigner: TFormDesigner end object GBContingencyColors: TGroupBox Left = 0 - Height = 40 - Top = 361 + Height = 17 + Top = 338 Width = 650 Caption = 'Cores' - ClientHeight = 23 - ClientWidth = 646 + ChildSizing.HorizontalSpacing = 5 + ChildSizing.EnlargeHorizontal = crsHomogenousChildResize + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 5 TabOrder = 6 Visible = False - object ComboBoxColors: TComboBox - Left = 0 - Height = 27 - Top = 0 - Width = 641 - ItemHeight = 0 - ItemIndex = 5 - Items.Strings = ( - 'AMARELO' - 'VERMELHO' - 'ROXO' - 'AZUL' - 'VERDE' - 'DIFERENTES' - 'IGUAIS' - ) - Style = csDropDownList - TabOrder = 0 - Text = 'DIFERENTES' - end end object LabelThen: TLabel Left = 0 Height = 15 - Top = 406 + Top = 360 Width = 650 Alignment = taCenter Caption = 'ENTÃO' @@ -697,7 +711,7 @@ object FormDesigner: TFormDesigner object GBContingencyConsequence: TGroupBox Left = 0 Height = 59 - Top = 426 + Top = 380 Width = 650 Caption = 'Consequência' ChildSizing.EnlargeHorizontal = crsHomogenousChildResize @@ -707,8 +721,25 @@ object FormDesigner: TFormDesigner ClientWidth = 646 TabOrder = 7 Visible = False - object LabelC1: TLabel + object LabelC6: TLabel + Left = 0 + Height = 15 + Top = 0 + Width = 154 + Caption = 'do Tipo' + ParentColor = False + end + object CBPointsType: TComboBox Left = 0 + Height = 27 + Top = 15 + Width = 154 + ItemHeight = 0 + Style = csDropDownList + TabOrder = 4 + end + object LabelC1: TLabel + Left = 154 Height = 15 Top = 0 Width = 134 @@ -716,7 +747,7 @@ object FormDesigner: TFormDesigner ParentColor = False end object EditMessPrefix: TEdit - Left = 0 + Left = 154 Height = 27 Top = 15 Width = 134 @@ -724,7 +755,7 @@ object FormDesigner: TFormDesigner Text = '$NICNAME produziu' end object LabelC4: TLabel - Left = 134 + Left = 288 Height = 15 Top = 0 Width = 104 @@ -732,31 +763,14 @@ object FormDesigner: TFormDesigner ParentColor = False end object SpinEditContingencyPoints: TSpinEdit - Left = 134 + Left = 288 Height = 27 Top = 15 Width = 104 - MaxValue = 1000 + MaxValue = 0 TabOrder = 2 Value = 1 end - object LabelC6: TLabel - Left = 238 - Height = 15 - Top = 0 - Width = 154 - Caption = 'do Tipo' - ParentColor = False - end - object CBPointsType: TComboBox - Left = 238 - Height = 27 - Top = 15 - Width = 154 - ItemHeight = 0 - Style = csDropDownList - TabOrder = 4 - end object LabelC2: TLabel Left = 392 Height = 15 @@ -786,6 +800,7 @@ object FormDesigner: TFormDesigner Height = 27 Top = 15 Width = 120 + AllowGrayed = True Caption = 'a todos' Checked = True OnChange = CheckBoxBroadcastChange @@ -818,7 +833,13 @@ object FormDesigner: TFormDesigner top = 8 end object XMLPropStorage: TXMLPropStorage - StoredValues = <> + StoredValues = < + item + Name = 'FileName' + Value = 'persistence.ini' + OnSave = XMLPropStorageStoredValuesFileNameSave + OnRestore = XMLPropStorageStoredValuesFileNameRestore + end> FileName = 'persistence.xml' OnSavingProperties = XMLPropStorageSavingProperties OnRestoreProperties = XMLPropStorageRestoreProperties diff --git a/experiment_designer/form_main.pas b/experiment_designer/form_main.pas index 9dc5483..6805d9f 100644 --- a/experiment_designer/form_main.pas +++ b/experiment_designer/form_main.pas @@ -6,7 +6,7 @@ interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, - Menus, ExtCtrls, StdCtrls, XMLPropStorage, IniFiles, Spin; + Menus, ExtCtrls, StdCtrls, XMLPropStorage, IniFiles, Spin, PropertyStorage; type @@ -20,13 +20,15 @@ type BtnReorderCond: TButton; BtnReorderContingency: TButton; CGGlobal: TCheckGroup; - CGMatrix: TCheckGroup; + ChkColors: TCheckBox; + ChkRows: TCheckBox; + ChkCols: TCheckBox; + ChkDots: TCheckBox; + ChkCleanDots: TCheckBox; CheckBoxBroadcast: TCheckBox; CheckBoxIsMeta: TCheckBox; CheckBoxShouldAskQuestion: TCheckBox; CGQuestion: TCheckGroup; - ComboBoxRows: TComboBox; - ComboBoxColors: TComboBox; CBPointsType: TComboBox; ComboCurrentCondition: TComboBox; ComboCurrentContingency: TComboBox; @@ -46,6 +48,8 @@ type GBQuestion: TGroupBox; GBContingencyRows: TGroupBox; GBContingencyConsequence: TGroupBox; + GBMatrix: TGroupBox; + LabelPointsOnConditionBegin: TLabel; LabelC1: TLabel; LabelC2: TLabel; LabelC4: TLabel; @@ -83,14 +87,26 @@ type SpinEditEndCriteriaLastCycles: TSpinEdit; SpinEditEndCriteriaAbsCycles: TSpinEdit; SpinEditCyclesValue: TSpinEdit; + SpinEditOnConditionBegin: TSpinEdit; SpinEditTurnValue: TSpinEdit; TabSheetContingencies: TTabSheet; TabSheetConditions: TTabSheet; TabSheetExperiment: TTabSheet; XMLPropStorage: TXMLPropStorage; + procedure BtnAppendCondClick(Sender: TObject); + procedure BtnAppendContingencyClick(Sender: TObject); + procedure BtnRemoveCondClick(Sender: TObject); + procedure CGQuestionItemClick(Sender: TObject; Index: integer); procedure CheckBoxBroadcastChange(Sender: TObject); procedure CheckBoxIsMetaChange(Sender: TObject); procedure CheckBoxShouldAskQuestionChange(Sender: TObject); + procedure ChkCleanDotsChange(Sender: TObject); + procedure ChkDotsChange(Sender: TObject); + procedure ComboCurrentConditionChange(Sender: TObject); + procedure EditConditionNameChange(Sender: TObject); + procedure EditConditionNameEditingDone(Sender: TObject); + procedure EditQuestionChange(Sender: TObject); + procedure EditQuestionEditingDone(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure MenuItemExitClick(Sender: TObject); @@ -98,10 +114,39 @@ type procedure RGContingencyStyleClick(Sender: TObject); procedure RGEndCriteriaStyleClick(Sender: TObject); procedure RGPointsClick(Sender: TObject); + procedure SpinEditCyclesValueEditingDone(Sender: TObject); + procedure SpinEditEndCriteriaAbsCyclesEditingDone(Sender: TObject); + procedure SpinEditEndCriteriaInterlockingEditingDone( + Sender: TObject); + procedure SpinEditTurnValueEditingDone(Sender: TObject); procedure XMLPropStorageRestoreProperties(Sender: TObject); procedure XMLPropStorageSavingProperties(Sender: TObject); + procedure XMLPropStorageStoredValuesFileNameRestore(Sender: TStoredValue; + var Value: TStoredType); + procedure XMLPropStorageStoredValuesFileNameSave(Sender: TStoredValue; + var Value: TStoredType); private - FExperiment : TIniFile; + FExperiment: TIniFile; + procedure LoadExperiment; + procedure LoadSectionExperiment; + procedure LoadSectionCondition(LS: string); + procedure LoadContingency(LS, LC: string); + procedure SaveExperiment; + procedure SaveSectionExperiment; + procedure SaveSectionCondition(LS: string); + procedure SaveContingency(LS, LC: string); + private + function GetLC(IsMeta:Boolean):string; + function GetConsequenceStyle: string; + function GetContingencyCriteria: string; + function GetEndCriteriaPorcentage: string; + function GetEndCriteriaStyleFromRGEndCriteriaStyle: string; + function GetMatrixTypeStringFromCGMatrix: string; + function GetPromptQuestionStringFromCGQuestion: string; + procedure SetCGMatrix(AMatrixType: string); + procedure SetCGQuestion(AQuestionStyle: string); + procedure SetRGEndCriteriaStyle(AStyle: string); + procedure SetContingencyCriteria(S: string); public { public declarations } end; @@ -111,145 +156,614 @@ var implementation -uses game_resources, game_file_methods; +uses game_resources, game_actors, string_methods, strutils; {$R *.lfm} { TFormDesigner } - procedure TFormDesigner.MenuItemOpenClick(Sender: TObject); begin if OpenDialog.Execute then - begin - if FExperiment.FileName = OpenDialog.FileName then Exit; - FExperiment := TIniFile.Create(OpenDialog.FileName); - end; + begin + if FExperiment.FileName = OpenDialog.FileName then + Exit; + FExperiment.Free; + FExperiment := TIniFile.Create(OpenDialog.FileName); + XMLPropStorage.StoredValue['FileName'] := FExperiment.FileName; + end; end; procedure TFormDesigner.RGContingencyStyleClick(Sender: TObject); -var LVisible : Boolean; +var + LVisible: boolean; begin LVisible := True; case TRadioGroup(Sender).ItemIndex of 0: - begin - LabelIf.Visible:= not LVisible; - LabelThen.Visible:= not LVisible; - LabelOperator.Visible:= not LVisible; - GBContingencyRows.Visible:= not LVisible; - GBContingencyColors.Visible:= not LVisible; - GBContingencyConsequence.Visible:= not LVisible; - end; + begin + LabelIf.Visible := not LVisible; + LabelThen.Visible := not LVisible; + LabelOperator.Visible := not LVisible; + GBContingencyRows.Visible := not LVisible; + GBContingencyColors.Visible := not LVisible; + GBContingencyConsequence.Visible := not LVisible; + end; 1: - begin - LabelIf.Visible:= LVisible; - LabelThen.Visible:= LVisible; - LabelOperator.Visible:= not LVisible; - GBContingencyRows.Visible:= LVisible; - GBContingencyColors.Visible:= not LVisible; - GBContingencyConsequence.Visible:= LVisible; - end; + begin + LabelIf.Visible := LVisible; + LabelThen.Visible := LVisible; + LabelOperator.Visible := not LVisible; + GBContingencyRows.Visible := LVisible; + GBContingencyColors.Visible := not LVisible; + GBContingencyConsequence.Visible := LVisible; + end; 2: - begin - LabelIf.Visible:= LVisible; - LabelThen.Visible:= LVisible; - LabelOperator.Visible:= not LVisible; - GBContingencyRows.Visible:= not LVisible; - GBContingencyColors.Visible:= LVisible; - GBContingencyConsequence.Visible:= LVisible; - end; + begin + LabelIf.Visible := LVisible; + LabelThen.Visible := LVisible; + LabelOperator.Visible := not LVisible; + GBContingencyRows.Visible := not LVisible; + GBContingencyColors.Visible := LVisible; + GBContingencyConsequence.Visible := LVisible; + end; 3: - begin - LabelIf.Visible:= LVisible; - LabelThen.Visible:= LVisible; - LabelOperator.Caption:='E'; - LabelOperator.Visible:= LVisible; - GBContingencyRows.Visible:= LVisible; - GBContingencyColors.Visible:= LVisible; - GBContingencyConsequence.Visible:= LVisible; - end; + begin + LabelIf.Visible := LVisible; + LabelThen.Visible := LVisible; + LabelOperator.Caption := 'E'; + LabelOperator.Visible := LVisible; + GBContingencyRows.Visible := LVisible; + GBContingencyColors.Visible := LVisible; + GBContingencyConsequence.Visible := LVisible; + end; 4: - begin - LabelIf.Visible:= LVisible; - LabelThen.Visible:= LVisible; - LabelOperator.Caption:='OU'; - LabelOperator.Visible:= LVisible; - GBContingencyRows.Visible:= LVisible; - GBContingencyColors.Visible:= LVisible; - GBContingencyConsequence.Visible:= LVisible; - end; + begin + LabelIf.Visible := LVisible; + LabelThen.Visible := LVisible; + LabelOperator.Caption := 'OU'; + LabelOperator.Visible := LVisible; + GBContingencyRows.Visible := LVisible; + GBContingencyColors.Visible := LVisible; + GBContingencyConsequence.Visible := LVisible; + end; end; CheckBoxIsMetaChange(CheckBoxIsMeta); end; procedure TFormDesigner.RGEndCriteriaStyleClick(Sender: TObject); +var + LS: String; begin case TRadioGroup(Sender).ItemIndex of 0: - begin - LabelEndCriteriaAbsCycles.Visible := True; - SpinEditEndCriteriaAbsCycles.Visible:= True; - GBEndCriteriaLastCycles.Visible:= False; + begin + LabelEndCriteriaAbsCycles.Visible := True; + SpinEditEndCriteriaAbsCycles.Visible := True; + GBEndCriteriaLastCycles.Visible := False; - end; + end; 1: - begin - LabelEndCriteriaAbsCycles.Visible := False; - SpinEditEndCriteriaAbsCycles.Visible:= False; - GBEndCriteriaLastCycles.Visible:= True; - end; + begin + LabelEndCriteriaAbsCycles.Visible := False; + SpinEditEndCriteriaAbsCycles.Visible := False; + GBEndCriteriaLastCycles.Visible := True; + end; 2: + begin + LabelEndCriteriaAbsCycles.Visible := True; + SpinEditEndCriteriaAbsCycles.Visible := True; + GBEndCriteriaLastCycles.Visible := True; + end; + end; + + with FExperiment do + if ComboCurrentCondition.ItemIndex <> -1 then begin - LabelEndCriteriaAbsCycles.Visible := True; - SpinEditEndCriteriaAbsCycles.Visible:= True; - GBEndCriteriaLastCycles.Visible:= True; + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1); + WriteString(LS, KEY_ENDCRITERIA, GetEndCriteriaStyleFromRGEndCriteriaStyle); end; - end; end; procedure TFormDesigner.RGPointsClick(Sender: TObject); begin case TRadioGroup(Sender).ItemIndex of 0: + begin + CBPointsType.Items.Clear; + CBPointsType.Items.Append('Individual A'); + CBPointsType.Items.Append('Individual B'); + CBPointsType.Items.Append('Para o Grupo'); + end; + + 1: + begin + CBPointsType.Items.Clear; + CBPointsType.Items.Append('Individual'); + CBPointsType.Items.Append('Para o Grupo'); + end; + end; +end; + +procedure TFormDesigner.SpinEditCyclesValueEditingDone(Sender: TObject); +var + LS: string; +begin + with FExperiment do + if ComboCurrentCondition.ItemIndex <> -1 then + begin + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1); + WriteInteger(LS, KEY_CYCLES_VALUE, SpinEditCyclesValue.Value); + end; +end; + +procedure TFormDesigner.SpinEditEndCriteriaAbsCyclesEditingDone(Sender: TObject + ); +var + LS: String; +begin + with FExperiment do + if ComboCurrentCondition.ItemIndex <> -1 then begin - CBPointsType.Items.Clear; - CBPointsType.Items.Append('Individual A'); - CBPointsType.Items.Append('Individual B'); - CBPointsType.Items.Append('Para o Grupo'); + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1); + WriteInteger(LS, KEY_ENDCRITERIA_CYCLES, SpinEditEndCriteriaAbsCycles.Value); end; +end; - 1: +procedure TFormDesigner.SpinEditEndCriteriaInterlockingEditingDone( + Sender: TObject); +var + LS: string; +begin + with FExperiment do + if ComboCurrentCondition.ItemIndex <> -1 then begin - CBPointsType.Items.Clear; - CBPointsType.Items.Append('Individual'); - CBPointsType.Items.Append('Para o Grupo'); + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1); + WriteString(LS, KEY_ENDCRITERIA_PORCENTAGE, GetEndCriteriaPorcentage); + end; +end; + +procedure TFormDesigner.SpinEditTurnValueEditingDone(Sender: TObject); +var + LS: string; +begin + with FExperiment do + if ComboCurrentCondition.ItemIndex <> -1 then + begin + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1); + WriteInteger(LS, KEY_TURN_VALUE, SpinEditTurnValue.Value); end; - end; end; procedure TFormDesigner.XMLPropStorageRestoreProperties(Sender: TObject); -//var -// i: Integer; begin - //for i := 0 to CGGlobal.Items.Count-1 do - // CGGlobal.Checked[i] := StrToBool(XMLPropStorage.StoredValue['CGGLobal.Checked'+IntToStr(i)]); - // - //for i := 0 to CGMatrix.Items.Count-1 do - // CGMatrix.Checked[i] := StrToBool(XMLPropStorage.StoredValue['CGMatrix.Checked'+IntToStr(i)]); + LoadExperiment; + ListBoxConditions.Items.Text := ComboCurrentCondition.Items.Text; + ListBoxContingencies.Items.Text := ComboCurrentContingency.Items.Text; + RGPointsClick(RGPoints); + RGEndCriteriaStyleClick(RGEndCriteriaStyle); end; procedure TFormDesigner.XMLPropStorageSavingProperties(Sender: TObject); -//var -// i: Integer; begin - //for i := 0 to CGGlobal.Items.Count-1 do - // XMLPropStorage.StoredValue['CGGLobal.Checked'+IntToStr(i)] := BoolToStr(CGGLobal.Checked[i]); - // - //for i := 0 to CGMatrix.Items.Count-1 do - // XMLPropStorage.StoredValue['CGMatrix.Checked'+IntToStr(i)] := BoolToStr(CGMatrix.Checked[i]); + SaveExperiment; +end; + + +procedure TFormDesigner.XMLPropStorageStoredValuesFileNameRestore(Sender: TStoredValue; + var Value: TStoredType); +begin + FExperiment := TIniFile.Create(Value); +end; + + +procedure TFormDesigner.XMLPropStorageStoredValuesFileNameSave(Sender: TStoredValue; + var Value: TStoredType); +begin + Value := FExperiment.FileName; +end; + +procedure TFormDesigner.LoadExperiment; +var + LS: string; + LC: string; +begin + LoadSectionExperiment; + + if ComboCurrentCondition.ItemIndex <> -1 then + begin + LS := SEC_CONDITION + IntToStr(ComboCurrentCondition.ItemIndex + 1); + LoadSectionCondition(LS); + if ComboCurrentContingency.ItemIndex <> -1 then + begin + LC := Delimited(1, ComboCurrentContingency.Items[ComboCurrentContingency.ItemIndex]); + LoadContingency(LS, LC); + end; + end; + //if NamesOnly then + // begin + // ListBoxConditions.Items.Append(LS+'|'+EditConditionName.Text); + // ComboCurrentCondition.Items.Append(LS+'|'+EditConditionName.Text); + // Exit; + // end; +end; + +procedure TFormDesigner.SaveExperiment; +var + LS, LC: string; +begin + SaveSectionExperiment; + if ComboCurrentCondition.ItemIndex <> -1 then + begin + LS := SEC_CONDITION + IntToStr(ComboCurrentCondition.ItemIndex + 1); + SaveSectionCondition(LS); + if ComboCurrentContingency.ItemIndex <> -1 then + begin + LC := Delimited(1, ComboCurrentContingency.Items[ComboCurrentContingency.ItemIndex]); + SaveContingency(LS, LC); + end; + end; +end; + +function TFormDesigner.GetMatrixTypeStringFromCGMatrix: string; +begin + Result := ''; + if ChkColors.Checked then + Result += 'CORES,'; + if ChkRows.Checked then + Result += 'LINHAS,'; + if ChkCols.Checked then + Result += 'COLUNAS,'; + if ChkDots.Checked then + Result += 'CÍRCULOS PREENCHIDOS,'; + if ChkCleanDots.Checked then + Result += 'CÍRCULOS VAZADOS,'; +end; + +function TFormDesigner.GetPromptQuestionStringFromCGQuestion: string; +var + PS: TPromptStyle; +begin + PS := []; + if CGQuestion.Checked[0] then + PS += [gsAll, gsYes, gsMetacontingency, gsContingency, gsRevertPoints]; + + if CGQuestion.Checked[1] then + PS += [gsBasA]; + + Result := GetPromptStyleString(PS); +end; + +procedure TFormDesigner.SetCGMatrix(AMatrixType: string); +begin + if Pos('CORES', UpperCase(AMatrixType)) > 0 then + ChkColors.Checked := True + else + ChkColors.Checked := False; + + if Pos('LINHAS', UpperCase(AMatrixType)) > 0 then + ChkRows.Checked := True + else + ChkRows.Checked := False; + + if Pos('COLUNAS', UpperCase(AMatrixType)) > 0 then + ChkCols.Checked := True + else + ChkCols.Checked := False; + + if Pos('CÍRCULOS PREENCHIDOS', UpperCase(AMatrixType)) > 0 then + ChkDots.Checked := True + else + ChkDots.Checked := False; + + if Pos('CÍRCULOS VAZADOS', UpperCase(AMatrixType)) > 0 then + ChkCleanDots.Checked := True + else + ChkCleanDots.Checked := False; +end; + +procedure TFormDesigner.SetCGQuestion(AQuestionStyle: string); +var + PS: TPromptStyle; +begin + PS := GetPromptStyleFromString(AQuestionStyle); + if (gsAll in PS) and (gsYes in PS) and (gsMetacontingency in PS) and + (gsContingency in PS) and (gsRevertPoints in PS) then + CGQuestion.Checked[0] := True + else + CGQuestion.Checked[0] := False; + + if (gsBasA) in PS then + CGQuestion.Checked[1] := True + else + CGQuestion.Checked[1] := False; +end; + +procedure TFormDesigner.SetRGEndCriteriaStyle(AStyle: string); +begin + case UpperCase(AStyle) of + 'CICLOS': RGEndCriteriaStyle.ItemIndex := 0; + 'PORCENTAGEM': RGEndCriteriaStyle.ItemIndex := 1; + 'O QUE OCORRER PRIMEIRO': RGEndCriteriaStyle.ItemIndex := 2; + end; +end; + +procedure TFormDesigner.SetContingencyCriteria(S: string); +var + C: TCriteria; + + procedure SetContingencyRows(GR: TGameRows); + var + i: integer; + begin + for i := 0 to GBContingencyRows.ComponentCount - 1 do + case GBContingencyRows.Components[i].Name of + 'Chk1': TCheckBox(GBContingencyColors.Components[i]).Checked := grOne in GR; + 'Chk2': TCheckBox(GBContingencyColors.Components[i]).Checked := grTwo in GR; + 'Chk3': TCheckBox(GBContingencyColors.Components[i]).Checked := grThree in GR; + 'Chk4': TCheckBox(GBContingencyColors.Components[i]).Checked := grFour in GR; + 'Chk5': TCheckBox(GBContingencyColors.Components[i]).Checked := grFive in GR; + 'Chk6': TCheckBox(GBContingencyColors.Components[i]).Checked := grSix in GR; + 'Chk7': TCheckBox(GBContingencyColors.Components[i]).Checked := grSeven in GR; + 'Chk8': TCheckBox(GBContingencyColors.Components[i]).Checked := grEight in GR; + 'Chk9': TCheckBox(GBContingencyColors.Components[i]).Checked := grNine in GR; + 'Chk10': TCheckBox(GBContingencyColors.Components[i]).Checked := grTen in GR; + 'ChkEven': TCheckBox(GBContingencyColors.Components[i]).Checked := grEven in GR; + 'ChkOdd': TCheckBox(GBContingencyColors.Components[i]).Checked := grOdd in GR; + end; + end; + + procedure SetContingencyColors(GC: TGameColors); + var + i: integer; + begin + for i := 0 to GBContingencyColors.ComponentCount - 1 do + case GBContingencyColors.Components[i].Name of + 'ChkEqual': TCheckBox(GBContingencyColors.Components[i]).Checked := gcEqual in GC; + 'ChkDiff': TCheckBox(GBContingencyColors.Components[i]).Checked := gcDiff in GC; + 'ChkNot': TCheckBox(GBContingencyColors.Components[i]).Checked := gcNot in GC; + 'ChkY': TCheckBox(GBContingencyColors.Components[i]).Checked := gcYellow in GC; + 'ChkR': TCheckBox(GBContingencyColors.Components[i]).Checked := gcRed in GC; + 'ChkM': TCheckBox(GBContingencyColors.Components[i]).Checked := gcMagenta in GC; + 'ChkB': TCheckBox(GBContingencyColors.Components[i]).Checked := gcBlue in GC; + 'ChkG': TCheckBox(GBContingencyColors.Components[i]).Checked := gcDiff in GC; + end; + end; + +begin + C := GetCriteriaFromString(S); + case C.Style of + gtNone: RGContingencyStyle.ItemIndex := 0; + gtRowsOnly: + begin + RGContingencyStyle.ItemIndex := 1; + SetContingencyRows(C.Rows); + end; + gtColorsOnly: + begin + RGContingencyStyle.ItemIndex := 2; + SetContingencyColors(C.Colors); + end; + gtRowsAndColors: + begin + RGContingencyStyle.ItemIndex := 3; + SetContingencyRows(C.Rows); + SetContingencyColors(C.Colors); + end; + gtRowsOrColors: + begin + RGContingencyStyle.ItemIndex := 4; + SetContingencyRows(C.Rows); + SetContingencyColors(C.Colors); + end; + end; +end; + +procedure TFormDesigner.SaveSectionExperiment; +begin + with FExperiment do + begin + WriteString(SEC_EXPERIMENT, KEY_RESEARCHER, EditResearcherName.Text); + WriteString(SEC_EXPERIMENT, KEY_NAME, EditExperimentName.Text); + WriteString(SEC_EXPERIMENT, KEY_AIM, MemoExperimentAim.Text); + WriteBool(SEC_EXPERIMENT, KEY_CHAT_HISTORY_FOR_NEW_PLAYERS, CGGlobal.Checked[0]); + WriteBool(SEC_EXPERIMENT, KEY_GEN_PLAYER_AS_NEEDED, CGGlobal.Checked[1]); + WriteBool(SEC_EXPERIMENT, KEY_RESEARCHER_CANPLAY, CGGlobal.Checked[2]); + WriteBool(SEC_EXPERIMENT, KEY_RESEARCHER_CANCHAT, CGGlobal.Checked[3]); + case RGPoints.ItemIndex of + 0: WriteBool(SEC_EXPERIMENT, KEY_POINTS_TYPE, True); + 1: WriteBool(SEC_EXPERIMENT, KEY_POINTS_TYPE, False); + end; + WriteString(SEC_EXPERIMENT, KEY_MATRIX_TYPE, GetMatrixTypeStringFromCGMatrix); + end; +end; + +procedure TFormDesigner.LoadSectionExperiment; +begin + with FExperiment do + begin + EditResearcherName.Text := ReadString(SEC_EXPERIMENT, KEY_RESEARCHER, ''); + EditExperimentName.Text := ReadString(SEC_EXPERIMENT, KEY_NAME, ''); + MemoExperimentAim.Text := ReadString(SEC_EXPERIMENT, KEY_AIM, ''); + CGGlobal.Checked[0] := + ReadBool(SEC_EXPERIMENT, KEY_CHAT_HISTORY_FOR_NEW_PLAYERS, False); + CGGlobal.Checked[1] := ReadBool(SEC_EXPERIMENT, KEY_GEN_PLAYER_AS_NEEDED, False); + CGGlobal.Checked[2] := ReadBool(SEC_EXPERIMENT, KEY_RESEARCHER_CANPLAY, False); + CGGlobal.Checked[3] := ReadBool(SEC_EXPERIMENT, KEY_RESEARCHER_CANCHAT, False); + if ReadBool(SEC_EXPERIMENT, KEY_POINTS_TYPE, True) then + RGPoints.ItemIndex := 0 + else + RGPoints.ItemIndex := 1; + SetCGMatrix(ReadString(SEC_EXPERIMENT, KEY_MATRIX_TYPE, 'CORES,LINHAS')); + end; +end; + +procedure TFormDesigner.SaveSectionCondition(LS: string); +begin + with FExperiment do + begin + WriteString(LS, KEY_COND_NAME, EditConditionName.Text); + WriteInteger(LS, KEY_TURN_VALUE, SpinEditTurnValue.Value); + WriteInteger(LS, KEY_POINTS_ONSTART,SpinEditOnConditionBegin.Value); + WriteInteger(LS, KEY_CYCLES_VALUE, SpinEditCyclesValue.Value); + WriteString(LS, KEY_PROMPT_MESSAGE, EditQuestion.Text); + WriteString(LS, KEY_PROMPT_STYLE, GetPromptQuestionStringFromCGQuestion); + WriteString(LS, KEY_ENDCRITERIA, GetEndCriteriaStyleFromRGEndCriteriaStyle); + WriteInteger(LS, KEY_ENDCRITERIA_CYCLES, SpinEditEndCriteriaAbsCycles.Value); + WriteString(LS, KEY_ENDCRITERIA_PORCENTAGE, GetEndCriteriaPorcentage); + end; +end; + +procedure TFormDesigner.SaveContingency(LS, LC: string); +begin + with FExperiment do + begin + WriteString(LS, LC + KEY_NAME, EditContingencyName.Text); + WriteString(LS, LC + KEY_CRITERIA, GetContingencyCriteria); + WriteString(LS, LC + KEY_CONSEQUE, GetConsequenceStyle); + WriteString(LS, LC + KEY_CONSEQUE_MESSAGE_APPENDP,{todo: consequence sufix plural}''); + WriteString(LS, LC + KEY_CONSEQUE_MESSAGE_APPENDS, EditMessSufix.Text); + WriteString(LS, LC + KEY_CONSEQUE_MESSAGE_PREPEND, EditMessPrefix.Text); + end; +end; + +function TFormDesigner.GetLC(IsMeta: Boolean): string; +var + LCount, + i : integer; + S : string; + Extension : string; + ContingencyKey : string; +begin + if ComboCurrentContingency.Items.Count > 0 then + for i := ComboCurrentContingency.Items.Count-1 downto 0 do + begin + S := ExtractDelimited(1,ComboCurrentContingency.Items[i],['|']); + ContingencyKey := ExtractFileNameWithoutExt(S); + + if IsMeta then + begin + if ContingencyKey = KEY_METACONTINGENCY[16] then + begin + Result := KEY_METACONTINGENCY; + Extension := ExtractFileExt(S); + LCount := StrToInt(Extension); + Inc(LCount); + Result += IntToStr(LCount); + Break; + end; + end + else + begin + if ContingencyKey = KEY_CONTINGENCY[12] then + begin + Result := KEY_CONTINGENCY; + Extension := ExtractFileExt(S); + Lcount := StrToInt(Extension); + Inc(LCount); + Result += IntToStr(LCount); + Break; + end; + end; + end + else + if IsMeta then + Result := KEY_METACONTINGENCY+'1' + else + Result := KEY_CONTINGENCY+'1'; +end; + +function TFormDesigner.GetConsequenceStyle: string; +var + CS : TConsequenceStyle; +begin + CS := [gscMessage,gscPoints]; + case RGPoints.ItemIndex of + 0: { A & B } + case CBPointsType.ItemIndex of + 0 {'Individual A'} : CS += [gscA]; + 1 {'Individual B'} : CS += [gscB]; + 2 {'Para o Grupo'} : CS += [gscG]; + end; + 1: { I } + case CBPointsType.ItemIndex of + 0 {'Individual'} : CS += [gscI]; + 1 {'Para o Grupo'} : CS += [gscG]; + end; + end; + + case CheckBoxBroadcast.State of + cbChecked : CS += [gscBroadcastMessage]; + cbUnchecked: { do nothing }; + cbGrayed: CS -= [gscMessage]; + end; + + Result := GetConsequenceStylesString(CS); +end; + +function TFormDesigner.GetContingencyCriteria: string; +begin + +end; + +procedure TFormDesigner.LoadSectionCondition(LS: string); +begin + with FExperiment do + begin + EditConditionName.Text := ReadString(LS, KEY_COND_NAME, LS); + SpinEditTurnValue.Value := ReadInteger(LS, KEY_TURN_VALUE, 2); + SpinEditOnConditionBegin.Value := ReadInteger(LS, KEY_POINTS_ONSTART,0); + SpinEditCyclesValue.Value := ReadInteger(LS, KEY_CYCLES_VALUE, 2); + + CheckBoxShouldAskQuestion.Checked := False; + if ValueExists(LS, KEY_PROMPT_STYLE) and ValueExists(LS, KEY_PROMPT_MESSAGE) then + begin + EditQuestion.Text := ReadString(LS, KEY_PROMPT_MESSAGE, ''); + SetCGQuestion(ReadString(LS, KEY_PROMPT_STYLE, '')); + if (EditQuestion.Text <> '') or (ReadString(LS, KEY_PROMPT_STYLE, '') <> '') then + CheckBoxShouldAskQuestion.Checked := True; + end; + + SetRGEndCriteriaStyle(ReadString(LS, KEY_ENDCRITERIA, 'O QUE OCORRER PRIMEIRO')); + SpinEditEndCriteriaAbsCycles.Value := ReadInteger(LS, KEY_ENDCRITERIA_CYCLES, 20); + SpinEditEndCriteriaLastCycles.Value := + GetEndCriteriaLastCyclesFromString(ReadString(LS, KEY_ENDCRITERIA_PORCENTAGE, '80,20')); + SpinEditEndCriteriaInterlockingPorcentage.Value := + GetEndCriteriaPorcentageFromString(ReadString(LS, KEY_ENDCRITERIA_PORCENTAGE, '80,20')); + end; +end; + +procedure TFormDesigner.LoadContingency(LS, LC: string); +begin + if Pos('Metacontingency', LC) > 0 then + CheckBoxIsMeta.Checked := True + else + CheckBoxIsMeta.Checked := False; + + with FExperiment do + if ValueExists(LS, LC + KEY_CONSEQUE) and ValueExists(LS, LC + KEY_CRITERIA) then + begin + EditContingencyName.Text := ReadString(LS, LC + KEY_NAME, ''); + SetContingencyCriteria(ReadString(LS, LC + KEY_CRITERIA, '')); + ReadString(LS, LC + KEY_CONSEQUE, ''); + end; +end; + +function TFormDesigner.GetEndCriteriaPorcentage: string; +begin + Result := IntToStr(SpinEditEndCriteriaInterlockingPorcentage.Value) + ',' + + IntToStr(SpinEditEndCriteriaLastCycles.Value); +end; + +function TFormDesigner.GetEndCriteriaStyleFromRGEndCriteriaStyle: string; +begin + case RGEndCriteriaStyle.ItemIndex of + 0: Result := 'CICLOS'; + 1: Result := 'PORCENTAGEM'; + 2: Result := 'O QUE OCORRER PRIMEIRO'; + end; end; procedure TFormDesigner.MenuItemExitClick(Sender: TObject); @@ -258,80 +772,236 @@ begin end; procedure TFormDesigner.FormCreate(Sender: TObject); -//var -// LFileName: String; begin - //LFileName := 'default.txt'; - //IPSExperiment.IniFileName := LFileName; //IPSExperiment.IniSection := SEC_EXPERIMENT; - //IPSConditions.IniFileName := LFileName; //IPSConditions.IniSection := SEC_CONDITION; - //IPSPlayers.IniFileName := LFileName; //IPSPlayers.IniSection := SEC_PLAYER; - RGPointsClick(RGPoints); - RGEndCriteriaStyleClick(RGEndCriteriaStyle); - FExperiment := TCIniFile.Create('default.txt'); - //FExperiment.FileName; + end; procedure TFormDesigner.FormDestroy(Sender: TObject); begin - FExperiment.Destroy; + FExperiment.Free; end; procedure TFormDesigner.CheckBoxShouldAskQuestionChange(Sender: TObject); +var + LS: String; begin if TCheckBox(Sender).Checked then - TCheckBox(Sender).Caption := 'Sim' + TCheckBox(Sender).Caption := 'Sim' else - TCheckBox(Sender).Caption := 'Não'; + begin + TCheckBox(Sender).Caption := 'Não'; + with FExperiment do + if ComboCurrentCondition.ItemIndex <> -1 then + begin + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1); + WriteString(LS, KEY_PROMPT_MESSAGE, ''); + WriteString(LS, KEY_PROMPT_STYLE, ''); + end; + end; EditQuestion.Visible := CheckBoxShouldAskQuestion.Checked; CGQuestion.Visible := CheckBoxShouldAskQuestion.Checked; end; +procedure TFormDesigner.ChkCleanDotsChange(Sender: TObject); +begin + if ChkCleanDots.Checked then + ChkDots.Checked := not ChkCleanDots.Checked; +end; + +procedure TFormDesigner.ChkDotsChange(Sender: TObject); +begin + if ChkDots.Checked then + ChkCleanDots.Checked := not ChkDots.Checked; +end; + +procedure TFormDesigner.ComboCurrentConditionChange(Sender: TObject); +begin + LoadSectionCondition(SEC_CONDITION + IntToStr(ComboCurrentCondition.ItemIndex + 1)); +end; + +procedure TFormDesigner.EditConditionNameChange(Sender: TObject); +begin + +end; + +procedure TFormDesigner.EditConditionNameEditingDone(Sender: TObject); +var + LS: string; +begin + with FExperiment do + if ComboCurrentCondition.ItemIndex <> -1 then + begin + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1); + WriteString(LS, KEY_COND_NAME, EditConditionName.Text); + ComboCurrentCondition.Items[ComboCurrentCondition.ItemIndex] := + SEC_CONDITION + IntToStr(ComboCurrentCondition.ItemIndex + 1) + '|' + EditConditionName.Text; + ListBoxConditions.Items.Text := ComboCurrentCondition.Items.Text; + end; +end; + +procedure TFormDesigner.EditQuestionChange(Sender: TObject); +begin + +end; + +procedure TFormDesigner.EditQuestionEditingDone(Sender: TObject); +var + LS: string; +begin + with FExperiment do + if ComboCurrentCondition.ItemIndex <> -1 then + begin + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1); + WriteString(LS, KEY_PROMPT_MESSAGE, EditQuestion.Text); + end; +end; + procedure TFormDesigner.CheckBoxBroadcastChange(Sender: TObject); begin - if TCheckBox(Sender).Checked then - TCheckBox(Sender).Caption := 'a todos' - else - TCheckBox(Sender).Caption := 'ao participante'; + case TCheckBox(Sender).State of + cbChecked: TCheckBox(Sender).Caption := 'a todos'; + cbUnchecked: TCheckBox(Sender).Caption := 'ao participante'; + cbGrayed: TCheckBox(Sender).Caption := 'a ninguém'; + end; +end; + +procedure TFormDesigner.BtnAppendCondClick(Sender: TObject); +var + i: integer; +begin + i := ComboCurrentCondition.Items.Add(''); + ComboCurrentCondition.Items[i] := + SEC_CONDITION + IntToStr(i + 1) + '|' + EditConditionName.Text; + ComboCurrentCondition.ItemIndex := i; + SaveSectionCondition(SEC_CONDITION + IntToStr(i + 1)); + ListBoxConditions.Items.Text := ComboCurrentCondition.Items.Text; +end; + +procedure TFormDesigner.BtnAppendContingencyClick(Sender: TObject); +var + i: integer; + LS, LC : string; + +begin + i := ComboCurrentContingency.Items.Add(''); + LS := ExtractDelimited(1,ComboCurrentCondition.Items[ComboCurrentCondition.ItemIndex],['|']); + LC := GetLC(CheckBoxIsMeta.Checked); + ComboCurrentContingency.Items[i] := + LC + '|' + EditContingencyName.Text; + ComboCurrentContingency.ItemIndex := i; + SaveContingency(LS,LC); + ListBoxContingencies.Items.Text := ComboCurrentContingency.Items.Text; +end; + +procedure TFormDesigner.BtnRemoveCondClick(Sender: TObject); +var + i: integer; + MustReorder: boolean; + + procedure Reorder(index : integer); + var + j, i: integer; + Section: TStringList; + KeyName,Line,SectionName: string; + begin + Section := TStringList.Create; + with FExperiment do + for i := index to ComboCurrentCondition.Items.Count - 1 do + begin + SectionName := ExtractDelimited(1, ComboCurrentCondition.Items[i], ['|']); + ReadSectionValues(SectionName, Section); + EraseSection(SectionName); + SectionName := SEC_CONDITION + IntToStr(i + 1); + for Line in Section do + begin + KeyName := Section.ExtractName(Line); + WriteString(SectionName, KeyName, Section.Values[KeyName]); + end; + Section.Clear; + ComboCurrentCondition.Items[i] := + SectionName + '|' + ExtractDelimited(2, ComboCurrentCondition.Items[i], ['|']); + end; + Section.Free; + end; + +begin + i := ComboCurrentCondition.ItemIndex; + MustReorder := i < ComboCurrentCondition.Items.Count - 1; + ComboCurrentCondition.Items.Delete(i); + if MustReorder then + Reorder(i); + case ComboCurrentCondition.Items.Count of + 0: {do nothing}; + 1..MaxInt: + if i = 1 then + ComboCurrentCondition.ItemIndex := i + else + ComboCurrentCondition.ItemIndex := i -1; + end; + ListBoxConditions.Items.Text := ComboCurrentCondition.Items.Text; +end; +procedure TFormDesigner.CGQuestionItemClick(Sender: TObject; Index: integer); +var + LS: String; +begin + with FExperiment do + if ComboCurrentCondition.ItemIndex <> -1 then + begin + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1); + WriteString(LS, KEY_PROMPT_STYLE, GetPromptQuestionStringFromCGQuestion); + end; end; procedure TFormDesigner.CheckBoxIsMetaChange(Sender: TObject); var - i: Integer; + i: integer; + CH: TCheckBox; + + procedure CreateChkBox(N, C: string; AOwner: TWinControl); + begin + CH := TCheckBox.Create(AOwner); + CH.Name := N; + CH.Caption := C; + CH.Parent := AOwner; + end; + begin + while GBContingencyRows.ComponentCount > 0 do + GBContingencyRows.Components[0].Free; + + while GBContingencyColors.ComponentCount > 0 do + GBContingencyColors.Components[0].Free; + if TCheckBox(Sender).Checked then - begin - ComboBoxRows.Items.Clear; - ComboBoxRows.Items.Append('PARES'); - ComboBoxRows.Items.Append('IMPARES'); - - ComboBoxColors.Items.Clear; - ComboBoxColors.Items.Append('CORES IGUAIS'); - ComboBoxColors.Items.Append('CORES DIFERENTES'); - ComboBoxColors.Items.Append('TUDO EXCETO CORES IGUAIS'); - ComboBoxColors.Items.Append('TUDO EXCETO CORES DIFERENTES'); - end - else begin - ComboBoxRows.Items.Clear; - for i:=0 to 9 do - ComboBoxRows.Items.Append(IntToStr(i+1)); - - ComboBoxRows.Items.Append('PAR'); - ComboBoxRows.Items.Append('IMPAR'); - - ComboBoxColors.Items.Clear; - ComboBoxColors.Items.Append('AMARELO'); - ComboBoxColors.Items.Append('VERMELHO'); - ComboBoxColors.Items.Append('ROXO'); - ComboBoxColors.Items.Append('AZUL'); - ComboBoxColors.Items.Append('VERDE'); + CreateChkBox('ChkEven', 'PARES', GBContingencyRows); + CreateChkBox('ChkOdd', 'IMPARES', GBContingencyRows); + + CreateChkBox('ChkNot', 'TUDO EXCETO', GBContingencyColors); + CreateChkBox('ChkEqual', 'CORES IGUAIS', GBContingencyColors); + CreateChkBox('ChkDiff', 'CORES DIFERENTES', GBContingencyColors); + LabelIf.Caption := 'SE OS PARTICIPANTES ESCOLHEREM'; end + else + begin + for i := 0 to 9 do + CreateChkBox('Chk' + IntToStr(i + 1), IntToStr(i + 1), GBContingencyRows); + + CreateChkBox('ChkEven', 'PAR', GBContingencyRows); + CreateChkBox('ChkOdd', 'IMPAR', GBContingencyRows); + + CreateChkBox('ChkY', 'AMARELO', GBContingencyColors); + CreateChkBox('ChkR', 'VERMELHO', GBContingencyColors); + CreateChkBox('ChkM', 'ROXO', GBContingencyColors); + CreateChkBox('ChkB', 'AZUL', GBContingencyColors); + CreateChkBox('ChkG', 'VERDE', GBContingencyColors); + LabelIf.Caption := 'SE O PARTICIPANTE ESCOLHER'; + end; end; end. - diff --git a/experiment_designer/lib/x86_64-linux/experiment_designer.compiled b/experiment_designer/lib/x86_64-linux/experiment_designer.compiled index e389ae3..66c6f20 100644 --- a/experiment_designer/lib/x86_64-linux/experiment_designer.compiled +++ b/experiment_designer/lib/x86_64-linux/experiment_designer.compiled @@ -1,5 +1,5 @@ - + -- libgit2 0.21.2