Commit 17c83cacbb88d836fb8a676faf3c51fcbe6b4944

Authored by Carlos Picanco
1 parent 86db5e0b
Exists in master

gui incremental work

experiment_designer/experiment_designer.lpi
@@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
32 <PackageName Value="LCL"/> 32 <PackageName Value="LCL"/>
33 </Item1> 33 </Item1>
34 </RequiredPackages> 34 </RequiredPackages>
35 - <Units Count="3"> 35 + <Units Count="4">
36 <Unit0> 36 <Unit0>
37 <Filename Value="experiment_designer.lpr"/> 37 <Filename Value="experiment_designer.lpr"/>
38 <IsPartOfProject Value="True"/> 38 <IsPartOfProject Value="True"/>
@@ -48,6 +48,10 @@ @@ -48,6 +48,10 @@
48 <Filename Value="../units/game_actors_helpers.pas"/> 48 <Filename Value="../units/game_actors_helpers.pas"/>
49 <IsPartOfProject Value="True"/> 49 <IsPartOfProject Value="True"/>
50 </Unit2> 50 </Unit2>
  51 + <Unit3>
  52 + <Filename Value="../units/gui_file_methods.pas"/>
  53 + <IsPartOfProject Value="True"/>
  54 + </Unit3>
51 </Units> 55 </Units>
52 </ProjectOptions> 56 </ProjectOptions>
53 <CompilerOptions> 57 <CompilerOptions>
@@ -57,7 +61,7 @@ @@ -57,7 +61,7 @@
57 </Target> 61 </Target>
58 <SearchPaths> 62 <SearchPaths>
59 <IncludeFiles Value="$(ProjOutDir)"/> 63 <IncludeFiles Value="$(ProjOutDir)"/>
60 - <OtherUnitFiles Value="../units"/> 64 + <OtherUnitFiles Value="../units;../../../units"/>
61 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> 65 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
62 </SearchPaths> 66 </SearchPaths>
63 <Linking> 67 <Linking>
experiment_designer/form_main.lfm
1 object FormDesigner: TFormDesigner 1 object FormDesigner: TFormDesigner
2 - Left = 114 2 + Left = 180
3 Height = 635 3 Height = 635
4 - Top = 53 4 + Top = 54
5 Width = 656 5 Width = 656
6 - HorzScrollBar.Page = 521  
7 - VertScrollBar.Page = 616 6 + HorzScrollBar.Page = 387
  7 + VertScrollBar.Page = 482
8 AutoScroll = True 8 AutoScroll = True
9 Caption = 'Planejar Experimento' 9 Caption = 'Planejar Experimento'
10 ClientHeight = 616 10 ClientHeight = 616
11 - ClientWidth = 646 11 + ClientWidth = 656
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' 15 + SessionProperties = 'Caption;ComboCurrentCondition.ItemIndex;ComboCurrentCondition.Items;ComboCurrentContingency.ItemIndex;ComboCurrentContingency.Items;Height;Left;PageControl.TabIndex;Top;Width;WindowState;LabelIf.Caption'
16 LCLVersion = '1.6.2.0' 16 LCLVersion = '1.6.2.0'
17 object PageControl: TPageControl 17 object PageControl: TPageControl
18 Left = 0 18 Left = 0
19 - Height = 711 19 + Height = 616
20 Top = 0 20 Top = 0
21 - Width = 646  
22 - ActivePage = TabSheetConditions 21 + Width = 656
  22 + ActivePage = TabSheetContingencies
23 Align = alClient 23 Align = alClient
24 - TabIndex = 1 24 + TabIndex = 2
25 TabOrder = 0 25 TabOrder = 0
26 object TabSheetExperiment: TTabSheet 26 object TabSheetExperiment: TTabSheet
27 Caption = 'Experimento' 27 Caption = 'Experimento'
@@ -30,13 +30,13 @@ object FormDesigner: TFormDesigner @@ -30,13 +30,13 @@ object FormDesigner: TFormDesigner
30 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize 30 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
31 ChildSizing.Layout = cclLeftToRightThenTopToBottom 31 ChildSizing.Layout = cclLeftToRightThenTopToBottom
32 ChildSizing.ControlsPerLine = 1 32 ChildSizing.ControlsPerLine = 1
33 - ClientHeight = 678  
34 - ClientWidth = 640 33 + ClientHeight = 583
  34 + ClientWidth = 650
35 object LabelResearcherName: TLabel 35 object LabelResearcherName: TLabel
36 Left = 0 36 Left = 0
37 Height = 15 37 Height = 15
38 Top = 10 38 Top = 10
39 - Width = 619 39 + Width = 640
40 Caption = 'Nome do Pesquisador' 40 Caption = 'Nome do Pesquisador'
41 ParentColor = False 41 ParentColor = False
42 end 42 end
@@ -45,14 +45,14 @@ object FormDesigner: TFormDesigner @@ -45,14 +45,14 @@ object FormDesigner: TFormDesigner
45 Height = 25 45 Height = 25
46 Hint = 'Uma pasta será criada com o seu nome. Os seus experimentos serão salvos dentro dela.' 46 Hint = 'Uma pasta será criada com o seu nome. Os seus experimentos serão salvos dentro dela.'
47 Top = 30 47 Top = 30
48 - Width = 619 48 + Width = 640
49 TabOrder = 0 49 TabOrder = 0
50 end 50 end
51 object LabelExperimentName: TLabel 51 object LabelExperimentName: TLabel
52 Left = 0 52 Left = 0
53 Height = 15 53 Height = 15
54 Top = 60 54 Top = 60
55 - Width = 619 55 + Width = 640
56 Caption = 'Nome do Experimento' 56 Caption = 'Nome do Experimento'
57 ParentColor = False 57 ParentColor = False
58 end 58 end
@@ -61,23 +61,23 @@ object FormDesigner: TFormDesigner @@ -61,23 +61,23 @@ object FormDesigner: TFormDesigner
61 Height = 25 61 Height = 25
62 Hint = 'Uma pasta será criada com o nome do experimento. Os dados desse experimento serão salvos dentro dela.' 62 Hint = 'Uma pasta será criada com o nome do experimento. Os dados desse experimento serão salvos dentro dela.'
63 Top = 80 63 Top = 80
64 - Width = 619 64 + Width = 640
65 TabOrder = 1 65 TabOrder = 1
66 end 66 end
67 object GBExperimentAim: TGroupBox 67 object GBExperimentAim: TGroupBox
68 Left = 0 68 Left = 0
69 Height = 159 69 Height = 159
70 Top = 110 70 Top = 110
71 - Width = 619 71 + Width = 640
72 Caption = 'Objetivo do Experimento' 72 Caption = 'Objetivo do Experimento'
73 ClientHeight = 142 73 ClientHeight = 142
74 - ClientWidth = 615 74 + ClientWidth = 636
75 TabOrder = 2 75 TabOrder = 2
76 object MemoExperimentAim: TMemo 76 object MemoExperimentAim: TMemo
77 Left = 0 77 Left = 0
78 Height = 142 78 Height = 142
79 Top = 0 79 Top = 0
80 - Width = 615 80 + Width = 636
81 Align = alCustom 81 Align = alCustom
82 Anchors = [akTop, akLeft, akRight] 82 Anchors = [akTop, akLeft, akRight]
83 TabOrder = 0 83 TabOrder = 0
@@ -88,7 +88,7 @@ object FormDesigner: TFormDesigner @@ -88,7 +88,7 @@ object FormDesigner: TFormDesigner
88 Height = 113 88 Height = 113
89 Hint = 'Aplicáveis ao longo de todo o experimento' 89 Hint = 'Aplicáveis ao longo de todo o experimento'
90 Top = 274 90 Top = 274
91 - Width = 619 91 + Width = 640
92 AutoFill = True 92 AutoFill = True
93 Caption = 'Configurações globais' 93 Caption = 'Configurações globais'
94 ChildSizing.LeftRightSpacing = 6 94 ChildSizing.LeftRightSpacing = 6
@@ -100,7 +100,7 @@ object FormDesigner: TFormDesigner @@ -100,7 +100,7 @@ object FormDesigner: TFormDesigner
100 ChildSizing.Layout = cclLeftToRightThenTopToBottom 100 ChildSizing.Layout = cclLeftToRightThenTopToBottom
101 ChildSizing.ControlsPerLine = 1 101 ChildSizing.ControlsPerLine = 1
102 ClientHeight = 96 102 ClientHeight = 96
103 - ClientWidth = 615 103 + ClientWidth = 636
104 Items.Strings = ( 104 Items.Strings = (
105 'Enviar histórico do bate-papo a novos participantes' 105 'Enviar histórico do bate-papo a novos participantes'
106 'Gerar participantes automaticamente' 106 'Gerar participantes automaticamente'
@@ -116,7 +116,7 @@ object FormDesigner: TFormDesigner @@ -116,7 +116,7 @@ object FormDesigner: TFormDesigner
116 Left = 0 116 Left = 0
117 Height = 59 117 Height = 59
118 Top = 392 118 Top = 392
119 - Width = 619 119 + Width = 640
120 AutoFill = True 120 AutoFill = True
121 Caption = 'Tipo de pontuação' 121 Caption = 'Tipo de pontuação'
122 ChildSizing.LeftRightSpacing = 6 122 ChildSizing.LeftRightSpacing = 6
@@ -127,7 +127,7 @@ object FormDesigner: TFormDesigner @@ -127,7 +127,7 @@ object FormDesigner: TFormDesigner
127 ChildSizing.Layout = cclLeftToRightThenTopToBottom 127 ChildSizing.Layout = cclLeftToRightThenTopToBottom
128 ChildSizing.ControlsPerLine = 1 128 ChildSizing.ControlsPerLine = 1
129 ClientHeight = 42 129 ClientHeight = 42
130 - ClientWidth = 615 130 + ClientWidth = 636
131 ItemIndex = 0 131 ItemIndex = 0
132 Items.Strings = ( 132 Items.Strings = (
133 'A e B' 133 'A e B'
@@ -136,52 +136,84 @@ object FormDesigner: TFormDesigner @@ -136,52 +136,84 @@ object FormDesigner: TFormDesigner
136 OnClick = RGPointsClick 136 OnClick = RGPointsClick
137 TabOrder = 4 137 TabOrder = 4
138 end 138 end
139 - object CGMatrix: TCheckGroup 139 + object GBMatrix: TGroupBox
140 Left = 0 140 Left = 0
141 - Height = 134 141 + Height = 122
142 Top = 456 142 Top = 456
143 - Width = 619  
144 - AutoFill = True  
145 - Caption = 'Tipo da matrix'  
146 - ChildSizing.LeftRightSpacing = 6  
147 - ChildSizing.TopBottomSpacing = 6  
148 - ChildSizing.EnlargeHorizontal = crsHomogenousChildResize  
149 - ChildSizing.EnlargeVertical = crsHomogenousChildResize  
150 - ChildSizing.ShrinkHorizontal = crsScaleChilds  
151 - ChildSizing.ShrinkVertical = crsScaleChilds 143 + Width = 640
  144 + Caption = 'Tipo da Matrix'
  145 + ChildSizing.LeftRightSpacing = 5
152 ChildSizing.Layout = cclLeftToRightThenTopToBottom 146 ChildSizing.Layout = cclLeftToRightThenTopToBottom
153 ChildSizing.ControlsPerLine = 1 147 ChildSizing.ControlsPerLine = 1
154 - ClientHeight = 117  
155 - ClientWidth = 615  
156 - Items.Strings = (  
157 - '5 cores'  
158 - '10 Linhas'  
159 - '10 Colunas'  
160 - 'Círculos'  
161 - 'Círculos Vazados'  
162 - )  
163 - TabOrder = 5  
164 - Data = {  
165 - 050000000303020202  
166 - } 148 + ClientHeight = 105
  149 + ClientWidth = 636
  150 + TabOrder = 6
  151 + object ChkColors: TCheckBox
  152 + Left = 5
  153 + Height = 21
  154 + Top = 0
  155 + Width = 169
  156 + Caption = '5 cores'
  157 + Checked = True
  158 + Enabled = False
  159 + State = cbChecked
  160 + TabOrder = 0
  161 + end
  162 + object ChkRows: TCheckBox
  163 + Left = 5
  164 + Height = 21
  165 + Top = 21
  166 + Width = 169
  167 + Caption = '10 linhas'
  168 + Checked = True
  169 + Enabled = False
  170 + State = cbChecked
  171 + TabOrder = 1
  172 + end
  173 + object ChkCols: TCheckBox
  174 + Left = 5
  175 + Height = 21
  176 + Top = 42
  177 + Width = 169
  178 + Caption = '10 colunas'
  179 + TabOrder = 2
  180 + end
  181 + object ChkDots: TCheckBox
  182 + Left = 5
  183 + Height = 21
  184 + Top = 63
  185 + Width = 169
  186 + Caption = 'Com Círculos Preechidos'
  187 + OnChange = ChkDotsChange
  188 + TabOrder = 3
  189 + end
  190 + object ChkCleanDots: TCheckBox
  191 + Left = 5
  192 + Height = 21
  193 + Top = 84
  194 + Width = 169
  195 + Caption = 'Com Círculos Vazados'
  196 + OnChange = ChkCleanDotsChange
  197 + TabOrder = 4
  198 + end
167 end 199 end
168 object GBConditions: TGroupBox 200 object GBConditions: TGroupBox
169 Left = 0 201 Left = 0
170 Height = 97 202 Height = 97
171 - Top = 595  
172 - Width = 619 203 + Top = 583
  204 + Width = 640
173 Caption = 'Condições' 205 Caption = 'Condições'
174 ClientHeight = 80 206 ClientHeight = 80
175 - ClientWidth = 615  
176 - TabOrder = 6 207 + ClientWidth = 636
  208 + TabOrder = 5
177 object ListBoxConditions: TListBox 209 object ListBoxConditions: TListBox
178 Left = 0 210 Left = 0
179 Height = 80 211 Height = 80
180 Top = 0 212 Top = 0
181 - Width = 615 213 + Width = 636
182 Anchors = [akTop, akLeft, akRight] 214 Anchors = [akTop, akLeft, akRight]
183 ItemHeight = 0 215 ItemHeight = 0
184 - ScrollWidth = 613 216 + ScrollWidth = 634
185 TabOrder = 0 217 TabOrder = 0
186 TopIndex = -1 218 TopIndex = -1
187 end 219 end
@@ -194,14 +226,15 @@ object FormDesigner: TFormDesigner @@ -194,14 +226,15 @@ object FormDesigner: TFormDesigner
194 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize 226 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
195 ChildSizing.Layout = cclLeftToRightThenTopToBottom 227 ChildSizing.Layout = cclLeftToRightThenTopToBottom
196 ChildSizing.ControlsPerLine = 1 228 ChildSizing.ControlsPerLine = 1
197 - ClientHeight = 678  
198 - ClientWidth = 640 229 + ClientHeight = 583
  230 + ClientWidth = 650
199 object ComboCurrentCondition: TComboBox 231 object ComboCurrentCondition: TComboBox
200 Left = 0 232 Left = 0
201 Height = 27 233 Height = 27
202 Top = 10 234 Top = 10
203 Width = 640 235 Width = 640
204 ItemHeight = 0 236 ItemHeight = 0
  237 + OnChange = ComboCurrentConditionChange
205 Style = csDropDownList 238 Style = csDropDownList
206 TabOrder = 0 239 TabOrder = 0
207 end 240 end
@@ -224,6 +257,7 @@ object FormDesigner: TFormDesigner @@ -224,6 +257,7 @@ object FormDesigner: TFormDesigner
224 Top = 0 257 Top = 0
225 Width = 162 258 Width = 162
226 Caption = 'Adicionar' 259 Caption = 'Adicionar'
  260 + OnClick = BtnAppendCondClick
227 TabOrder = 0 261 TabOrder = 0
228 end 262 end
229 object BtnRemoveCond: TButton 263 object BtnRemoveCond: TButton
@@ -232,6 +266,7 @@ object FormDesigner: TFormDesigner @@ -232,6 +266,7 @@ object FormDesigner: TFormDesigner
232 Top = 0 266 Top = 0
233 Width = 159 267 Width = 159
234 Caption = 'Remover' 268 Caption = 'Remover'
  269 + OnClick = BtnRemoveCondClick
235 TabOrder = 1 270 TabOrder = 1
236 end 271 end
237 object BtnReorderCond: TButton 272 object BtnReorderCond: TButton
@@ -257,6 +292,7 @@ object FormDesigner: TFormDesigner @@ -257,6 +292,7 @@ object FormDesigner: TFormDesigner
257 Height = 25 292 Height = 25
258 Top = 93 293 Top = 93
259 Width = 640 294 Width = 640
  295 + OnEditingDone = EditConditionNameEditingDone
260 TabOrder = 2 296 TabOrder = 2
261 end 297 end
262 object LabelTurnValue: TLabel 298 object LabelTurnValue: TLabel
@@ -274,31 +310,49 @@ object FormDesigner: TFormDesigner @@ -274,31 +310,49 @@ object FormDesigner: TFormDesigner
274 Width = 640 310 Width = 640
275 MaxValue = 5 311 MaxValue = 5
276 MinValue = 2 312 MinValue = 2
  313 + OnEditingDone = SpinEditTurnValueEditingDone
277 TabOrder = 3 314 TabOrder = 3
278 Value = 2 315 Value = 2
279 end 316 end
280 - object LabelCyclesValue: TLabel 317 + object LabelPointsOnConditionBegin: TLabel
281 Left = 0 318 Left = 0
282 Height = 15 319 Height = 15
283 Top = 173 320 Top = 173
284 Width = 640 321 Width = 640
  322 + Caption = 'Pontos ao início da Condição'
  323 + ParentColor = False
  324 + end
  325 + object SpinEditOnConditionBegin: TSpinEdit
  326 + Left = 0
  327 + Height = 25
  328 + Top = 193
  329 + Width = 640
  330 + MaxValue = 0
  331 + TabOrder = 9
  332 + end
  333 + object LabelCyclesValue: TLabel
  334 + Left = 0
  335 + Height = 15
  336 + Top = 223
  337 + Width = 640
285 Caption = 'Ciclos para mudança de geração / linhagem' 338 Caption = 'Ciclos para mudança de geração / linhagem'
286 ParentColor = False 339 ParentColor = False
287 end 340 end
288 object SpinEditCyclesValue: TSpinEdit 341 object SpinEditCyclesValue: TSpinEdit
289 Left = 0 342 Left = 0
290 Height = 25 343 Height = 25
291 - Top = 193 344 + Top = 243
292 Width = 640 345 Width = 640
293 MaxValue = 1000 346 MaxValue = 1000
294 MinValue = 1 347 MinValue = 1
  348 + OnEditingDone = SpinEditCyclesValueEditingDone
295 TabOrder = 4 349 TabOrder = 4
296 Value = 1 350 Value = 1
297 end 351 end
298 object GBQuestion: TGroupBox 352 object GBQuestion: TGroupBox
299 Left = 0 353 Left = 0
300 Height = 144 354 Height = 144
301 - Top = 223 355 + Top = 273
302 Width = 640 356 Width = 640
303 Caption = 'Apresentar pergunta ao final do ciclo' 357 Caption = 'Apresentar pergunta ao final do ciclo'
304 ChildSizing.LeftRightSpacing = 50 358 ChildSizing.LeftRightSpacing = 50
@@ -308,7 +362,7 @@ object FormDesigner: TFormDesigner @@ -308,7 +362,7 @@ object FormDesigner: TFormDesigner
308 ChildSizing.ControlsPerLine = 1 362 ChildSizing.ControlsPerLine = 1
309 ClientHeight = 127 363 ClientHeight = 127
310 ClientWidth = 636 364 ClientWidth = 636
311 - TabOrder = 8 365 + TabOrder = 5
312 object CheckBoxShouldAskQuestion: TCheckBox 366 object CheckBoxShouldAskQuestion: TCheckBox
313 Left = 50 367 Left = 50
314 Height = 21 368 Height = 21
@@ -323,6 +377,7 @@ object FormDesigner: TFormDesigner @@ -323,6 +377,7 @@ object FormDesigner: TFormDesigner
323 Height = 25 377 Height = 25
324 Top = 26 378 Top = 26
325 Width = 536 379 Width = 536
  380 + OnEditingDone = EditQuestionEditingDone
326 TabOrder = 1 381 TabOrder = 1
327 Text = 'Um item escolar foi perdido, desejam recuperá-lo gastando pontos do Tipo A?' 382 Text = 'Um item escolar foi perdido, desejam recuperá-lo gastando pontos do Tipo A?'
328 Visible = False 383 Visible = False
@@ -348,6 +403,7 @@ object FormDesigner: TFormDesigner @@ -348,6 +403,7 @@ object FormDesigner: TFormDesigner
348 'Reverter consequências das metacontingências e contingências' 403 'Reverter consequências das metacontingências e contingências'
349 'Inverter pontos A e B quando pontos B forem consequências' 404 'Inverter pontos A e B quando pontos B forem consequências'
350 ) 405 )
  406 + OnItemClick = CGQuestionItemClick
351 TabOrder = 2 407 TabOrder = 2
352 Visible = False 408 Visible = False
353 Data = { 409 Data = {
@@ -358,7 +414,7 @@ object FormDesigner: TFormDesigner @@ -358,7 +414,7 @@ object FormDesigner: TFormDesigner
358 object RGEndCriteriaStyle: TRadioGroup 414 object RGEndCriteriaStyle: TRadioGroup
359 Left = 0 415 Left = 0
360 Height = 80 416 Height = 80
361 - Top = 372 417 + Top = 422
362 Width = 640 418 Width = 640
363 AutoFill = True 419 AutoFill = True
364 Caption = 'Estilo do critério de finalização da condição' 420 Caption = 'Estilo do critério de finalização da condição'
@@ -383,7 +439,7 @@ object FormDesigner: TFormDesigner @@ -383,7 +439,7 @@ object FormDesigner: TFormDesigner
383 object GBEndCriteria: TGroupBox 439 object GBEndCriteria: TGroupBox
384 Left = 0 440 Left = 0
385 Height = 109 441 Height = 109
386 - Top = 457 442 + Top = 507
387 Width = 640 443 Width = 640
388 Caption = 'Valores do critério de finalização da condição' 444 Caption = 'Valores do critério de finalização da condição'
389 ChildSizing.LeftRightSpacing = 50 445 ChildSizing.LeftRightSpacing = 50
@@ -393,7 +449,7 @@ object FormDesigner: TFormDesigner @@ -393,7 +449,7 @@ object FormDesigner: TFormDesigner
393 ChildSizing.ControlsPerLine = 1 449 ChildSizing.ControlsPerLine = 1
394 ClientHeight = 92 450 ClientHeight = 92
395 ClientWidth = 636 451 ClientWidth = 636
396 - TabOrder = 5 452 + TabOrder = 7
397 object LabelEndCriteriaAbsCycles: TLabel 453 object LabelEndCriteriaAbsCycles: TLabel
398 Left = 50 454 Left = 50
399 Height = 15 455 Height = 15
@@ -408,6 +464,7 @@ object FormDesigner: TFormDesigner @@ -408,6 +464,7 @@ object FormDesigner: TFormDesigner
408 Top = 20 464 Top = 20
409 Width = 536 465 Width = 536
410 MaxValue = 1000 466 MaxValue = 1000
  467 + OnEditingDone = SpinEditEndCriteriaAbsCyclesEditingDone
411 TabOrder = 0 468 TabOrder = 0
412 Value = 20 469 Value = 20
413 end 470 end
@@ -428,6 +485,7 @@ object FormDesigner: TFormDesigner @@ -428,6 +485,7 @@ object FormDesigner: TFormDesigner
428 Height = 25 485 Height = 25
429 Top = 0 486 Top = 0
430 Width = 50 487 Width = 50
  488 + OnEditingDone = SpinEditEndCriteriaInterlockingEditingDone
431 TabOrder = 0 489 TabOrder = 0
432 Value = 80 490 Value = 80
433 end 491 end
@@ -448,6 +506,7 @@ object FormDesigner: TFormDesigner @@ -448,6 +506,7 @@ object FormDesigner: TFormDesigner
448 Width = 50 506 Width = 50
449 MaxValue = 1000 507 MaxValue = 1000
450 MinValue = 2 508 MinValue = 2
  509 + OnEditingDone = SpinEditEndCriteriaInterlockingEditingDone
451 TabOrder = 1 510 TabOrder = 1
452 Value = 10 511 Value = 10
453 end 512 end
@@ -466,12 +525,12 @@ object FormDesigner: TFormDesigner @@ -466,12 +525,12 @@ object FormDesigner: TFormDesigner
466 object GBContingencies: TGroupBox 525 object GBContingencies: TGroupBox
467 Left = 0 526 Left = 0
468 Height = 97 527 Height = 97
469 - Top = 571 528 + Top = 621
470 Width = 640 529 Width = 640
471 Caption = 'Contingências e Metacontingências' 530 Caption = 'Contingências e Metacontingências'
472 ClientHeight = 80 531 ClientHeight = 80
473 ClientWidth = 636 532 ClientWidth = 636
474 - TabOrder = 7 533 + TabOrder = 8
475 object ListBoxContingencies: TListBox 534 object ListBoxContingencies: TListBox
476 Left = 0 535 Left = 0
477 Height = 80 536 Height = 80
@@ -492,8 +551,8 @@ object FormDesigner: TFormDesigner @@ -492,8 +551,8 @@ object FormDesigner: TFormDesigner
492 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize 551 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
493 ChildSizing.Layout = cclLeftToRightThenTopToBottom 552 ChildSizing.Layout = cclLeftToRightThenTopToBottom
494 ChildSizing.ControlsPerLine = 1 553 ChildSizing.ControlsPerLine = 1
495 - ClientHeight = 678  
496 - ClientWidth = 640 554 + ClientHeight = 583
  555 + ClientWidth = 650
497 object ComboCurrentContingency: TComboBox 556 object ComboCurrentContingency: TComboBox
498 Left = 0 557 Left = 0
499 Height = 27 558 Height = 27
@@ -522,6 +581,7 @@ object FormDesigner: TFormDesigner @@ -522,6 +581,7 @@ object FormDesigner: TFormDesigner
522 Top = 0 581 Top = 0
523 Width = 166 582 Width = 166
524 Caption = 'Adicionar' 583 Caption = 'Adicionar'
  584 + OnClick = BtnAppendContingencyClick
525 TabOrder = 0 585 TabOrder = 0
526 end 586 end
527 object BtnRemoveContingency: TButton 587 object BtnRemoveContingency: TButton
@@ -598,55 +658,27 @@ object FormDesigner: TFormDesigner @@ -598,55 +658,27 @@ object FormDesigner: TFormDesigner
598 Top = 276 658 Top = 276
599 Width = 650 659 Width = 650
600 Alignment = taCenter 660 Alignment = taCenter
601 - Caption = 'SE' 661 + Caption = 'SE O PARTICIPANTE ESCOLHER'
602 ParentColor = False 662 ParentColor = False
603 Visible = False 663 Visible = False
604 end 664 end
605 object GBContingencyRows: TGroupBox 665 object GBContingencyRows: TGroupBox
606 Left = 0 666 Left = 0
607 - Height = 40 667 + Height = 17
608 Top = 296 668 Top = 296
609 Width = 650 669 Width = 650
610 Caption = 'Linhas' 670 Caption = 'Linhas'
  671 + ChildSizing.LeftRightSpacing = 5
611 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize 672 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
612 - ChildSizing.Layout = cclTopToBottomThenLeftToRight  
613 - ChildSizing.ControlsPerLine = 1  
614 - ClientHeight = 23  
615 - ClientWidth = 646 673 + ChildSizing.Layout = cclLeftToRightThenTopToBottom
  674 + ChildSizing.ControlsPerLine = 4
616 TabOrder = 5 675 TabOrder = 5
617 Visible = False 676 Visible = False
618 - object ComboBoxRows: TComboBox  
619 - Left = 0  
620 - Height = 23  
621 - Top = 0  
622 - Width = 646  
623 - ItemHeight = 0  
624 - ItemIndex = 0  
625 - Items.Strings = (  
626 - '1'  
627 - '2'  
628 - '3'  
629 - '4'  
630 - '5'  
631 - '6'  
632 - '7'  
633 - '8'  
634 - '9'  
635 - '10'  
636 - 'PARES'  
637 - 'IMPARES'  
638 - 'TUDO EXCETO PARES'  
639 - 'TUDO EXCETO IMPARES'  
640 - )  
641 - Style = csDropDownList  
642 - TabOrder = 0  
643 - Text = '1'  
644 - end  
645 end 677 end
646 object LabelOperator: TLabel 678 object LabelOperator: TLabel
647 Left = 0 679 Left = 0
648 Height = 15 680 Height = 15
649 - Top = 341 681 + Top = 318
650 Width = 650 682 Width = 650
651 Alignment = taCenter 683 Alignment = taCenter
652 Caption = 'E' 684 Caption = 'E'
@@ -655,39 +687,21 @@ object FormDesigner: TFormDesigner @@ -655,39 +687,21 @@ object FormDesigner: TFormDesigner
655 end 687 end
656 object GBContingencyColors: TGroupBox 688 object GBContingencyColors: TGroupBox
657 Left = 0 689 Left = 0
658 - Height = 40  
659 - Top = 361 690 + Height = 17
  691 + Top = 338
660 Width = 650 692 Width = 650
661 Caption = 'Cores' 693 Caption = 'Cores'
662 - ClientHeight = 23  
663 - ClientWidth = 646 694 + ChildSizing.HorizontalSpacing = 5
  695 + ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
  696 + ChildSizing.Layout = cclLeftToRightThenTopToBottom
  697 + ChildSizing.ControlsPerLine = 5
664 TabOrder = 6 698 TabOrder = 6
665 Visible = False 699 Visible = False
666 - object ComboBoxColors: TComboBox  
667 - Left = 0  
668 - Height = 27  
669 - Top = 0  
670 - Width = 641  
671 - ItemHeight = 0  
672 - ItemIndex = 5  
673 - Items.Strings = (  
674 - 'AMARELO'  
675 - 'VERMELHO'  
676 - 'ROXO'  
677 - 'AZUL'  
678 - 'VERDE'  
679 - 'DIFERENTES'  
680 - 'IGUAIS'  
681 - )  
682 - Style = csDropDownList  
683 - TabOrder = 0  
684 - Text = 'DIFERENTES'  
685 - end  
686 end 700 end
687 object LabelThen: TLabel 701 object LabelThen: TLabel
688 Left = 0 702 Left = 0
689 Height = 15 703 Height = 15
690 - Top = 406 704 + Top = 360
691 Width = 650 705 Width = 650
692 Alignment = taCenter 706 Alignment = taCenter
693 Caption = 'ENTÃO' 707 Caption = 'ENTÃO'
@@ -697,7 +711,7 @@ object FormDesigner: TFormDesigner @@ -697,7 +711,7 @@ object FormDesigner: TFormDesigner
697 object GBContingencyConsequence: TGroupBox 711 object GBContingencyConsequence: TGroupBox
698 Left = 0 712 Left = 0
699 Height = 59 713 Height = 59
700 - Top = 426 714 + Top = 380
701 Width = 650 715 Width = 650
702 Caption = 'Consequência' 716 Caption = 'Consequência'
703 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize 717 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
@@ -707,8 +721,25 @@ object FormDesigner: TFormDesigner @@ -707,8 +721,25 @@ object FormDesigner: TFormDesigner
707 ClientWidth = 646 721 ClientWidth = 646
708 TabOrder = 7 722 TabOrder = 7
709 Visible = False 723 Visible = False
710 - object LabelC1: TLabel 724 + object LabelC6: TLabel
  725 + Left = 0
  726 + Height = 15
  727 + Top = 0
  728 + Width = 154
  729 + Caption = 'do Tipo'
  730 + ParentColor = False
  731 + end
  732 + object CBPointsType: TComboBox
711 Left = 0 733 Left = 0
  734 + Height = 27
  735 + Top = 15
  736 + Width = 154
  737 + ItemHeight = 0
  738 + Style = csDropDownList
  739 + TabOrder = 4
  740 + end
  741 + object LabelC1: TLabel
  742 + Left = 154
712 Height = 15 743 Height = 15
713 Top = 0 744 Top = 0
714 Width = 134 745 Width = 134
@@ -716,7 +747,7 @@ object FormDesigner: TFormDesigner @@ -716,7 +747,7 @@ object FormDesigner: TFormDesigner
716 ParentColor = False 747 ParentColor = False
717 end 748 end
718 object EditMessPrefix: TEdit 749 object EditMessPrefix: TEdit
719 - Left = 0 750 + Left = 154
720 Height = 27 751 Height = 27
721 Top = 15 752 Top = 15
722 Width = 134 753 Width = 134
@@ -724,7 +755,7 @@ object FormDesigner: TFormDesigner @@ -724,7 +755,7 @@ object FormDesigner: TFormDesigner
724 Text = '$NICNAME produziu' 755 Text = '$NICNAME produziu'
725 end 756 end
726 object LabelC4: TLabel 757 object LabelC4: TLabel
727 - Left = 134 758 + Left = 288
728 Height = 15 759 Height = 15
729 Top = 0 760 Top = 0
730 Width = 104 761 Width = 104
@@ -732,31 +763,14 @@ object FormDesigner: TFormDesigner @@ -732,31 +763,14 @@ object FormDesigner: TFormDesigner
732 ParentColor = False 763 ParentColor = False
733 end 764 end
734 object SpinEditContingencyPoints: TSpinEdit 765 object SpinEditContingencyPoints: TSpinEdit
735 - Left = 134 766 + Left = 288
736 Height = 27 767 Height = 27
737 Top = 15 768 Top = 15
738 Width = 104 769 Width = 104
739 - MaxValue = 1000 770 + MaxValue = 0
740 TabOrder = 2 771 TabOrder = 2
741 Value = 1 772 Value = 1
742 end 773 end
743 - object LabelC6: TLabel  
744 - Left = 238  
745 - Height = 15  
746 - Top = 0  
747 - Width = 154  
748 - Caption = 'do Tipo'  
749 - ParentColor = False  
750 - end  
751 - object CBPointsType: TComboBox  
752 - Left = 238  
753 - Height = 27  
754 - Top = 15  
755 - Width = 154  
756 - ItemHeight = 0  
757 - Style = csDropDownList  
758 - TabOrder = 4  
759 - end  
760 object LabelC2: TLabel 774 object LabelC2: TLabel
761 Left = 392 775 Left = 392
762 Height = 15 776 Height = 15
@@ -786,6 +800,7 @@ object FormDesigner: TFormDesigner @@ -786,6 +800,7 @@ object FormDesigner: TFormDesigner
786 Height = 27 800 Height = 27
787 Top = 15 801 Top = 15
788 Width = 120 802 Width = 120
  803 + AllowGrayed = True
789 Caption = 'a todos' 804 Caption = 'a todos'
790 Checked = True 805 Checked = True
791 OnChange = CheckBoxBroadcastChange 806 OnChange = CheckBoxBroadcastChange
@@ -818,7 +833,13 @@ object FormDesigner: TFormDesigner @@ -818,7 +833,13 @@ object FormDesigner: TFormDesigner
818 top = 8 833 top = 8
819 end 834 end
820 object XMLPropStorage: TXMLPropStorage 835 object XMLPropStorage: TXMLPropStorage
821 - StoredValues = <> 836 + StoredValues = <
  837 + item
  838 + Name = 'FileName'
  839 + Value = 'persistence.ini'
  840 + OnSave = XMLPropStorageStoredValuesFileNameSave
  841 + OnRestore = XMLPropStorageStoredValuesFileNameRestore
  842 + end>
822 FileName = 'persistence.xml' 843 FileName = 'persistence.xml'
823 OnSavingProperties = XMLPropStorageSavingProperties 844 OnSavingProperties = XMLPropStorageSavingProperties
824 OnRestoreProperties = XMLPropStorageRestoreProperties 845 OnRestoreProperties = XMLPropStorageRestoreProperties
experiment_designer/form_main.pas
@@ -6,7 +6,7 @@ interface @@ -6,7 +6,7 @@ interface
6 6
7 uses 7 uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
9 - Menus, ExtCtrls, StdCtrls, XMLPropStorage, IniFiles, Spin; 9 + Menus, ExtCtrls, StdCtrls, XMLPropStorage, IniFiles, Spin, PropertyStorage;
10 10
11 type 11 type
12 12
@@ -20,13 +20,15 @@ type @@ -20,13 +20,15 @@ type
20 BtnReorderCond: TButton; 20 BtnReorderCond: TButton;
21 BtnReorderContingency: TButton; 21 BtnReorderContingency: TButton;
22 CGGlobal: TCheckGroup; 22 CGGlobal: TCheckGroup;
23 - CGMatrix: TCheckGroup; 23 + ChkColors: TCheckBox;
  24 + ChkRows: TCheckBox;
  25 + ChkCols: TCheckBox;
  26 + ChkDots: TCheckBox;
  27 + ChkCleanDots: TCheckBox;
24 CheckBoxBroadcast: TCheckBox; 28 CheckBoxBroadcast: TCheckBox;
25 CheckBoxIsMeta: TCheckBox; 29 CheckBoxIsMeta: TCheckBox;
26 CheckBoxShouldAskQuestion: TCheckBox; 30 CheckBoxShouldAskQuestion: TCheckBox;
27 CGQuestion: TCheckGroup; 31 CGQuestion: TCheckGroup;
28 - ComboBoxRows: TComboBox;  
29 - ComboBoxColors: TComboBox;  
30 CBPointsType: TComboBox; 32 CBPointsType: TComboBox;
31 ComboCurrentCondition: TComboBox; 33 ComboCurrentCondition: TComboBox;
32 ComboCurrentContingency: TComboBox; 34 ComboCurrentContingency: TComboBox;
@@ -46,6 +48,8 @@ type @@ -46,6 +48,8 @@ type
46 GBQuestion: TGroupBox; 48 GBQuestion: TGroupBox;
47 GBContingencyRows: TGroupBox; 49 GBContingencyRows: TGroupBox;
48 GBContingencyConsequence: TGroupBox; 50 GBContingencyConsequence: TGroupBox;
  51 + GBMatrix: TGroupBox;
  52 + LabelPointsOnConditionBegin: TLabel;
49 LabelC1: TLabel; 53 LabelC1: TLabel;
50 LabelC2: TLabel; 54 LabelC2: TLabel;
51 LabelC4: TLabel; 55 LabelC4: TLabel;
@@ -83,14 +87,26 @@ type @@ -83,14 +87,26 @@ type
83 SpinEditEndCriteriaLastCycles: TSpinEdit; 87 SpinEditEndCriteriaLastCycles: TSpinEdit;
84 SpinEditEndCriteriaAbsCycles: TSpinEdit; 88 SpinEditEndCriteriaAbsCycles: TSpinEdit;
85 SpinEditCyclesValue: TSpinEdit; 89 SpinEditCyclesValue: TSpinEdit;
  90 + SpinEditOnConditionBegin: TSpinEdit;
86 SpinEditTurnValue: TSpinEdit; 91 SpinEditTurnValue: TSpinEdit;
87 TabSheetContingencies: TTabSheet; 92 TabSheetContingencies: TTabSheet;
88 TabSheetConditions: TTabSheet; 93 TabSheetConditions: TTabSheet;
89 TabSheetExperiment: TTabSheet; 94 TabSheetExperiment: TTabSheet;
90 XMLPropStorage: TXMLPropStorage; 95 XMLPropStorage: TXMLPropStorage;
  96 + procedure BtnAppendCondClick(Sender: TObject);
  97 + procedure BtnAppendContingencyClick(Sender: TObject);
  98 + procedure BtnRemoveCondClick(Sender: TObject);
  99 + procedure CGQuestionItemClick(Sender: TObject; Index: integer);
91 procedure CheckBoxBroadcastChange(Sender: TObject); 100 procedure CheckBoxBroadcastChange(Sender: TObject);
92 procedure CheckBoxIsMetaChange(Sender: TObject); 101 procedure CheckBoxIsMetaChange(Sender: TObject);
93 procedure CheckBoxShouldAskQuestionChange(Sender: TObject); 102 procedure CheckBoxShouldAskQuestionChange(Sender: TObject);
  103 + procedure ChkCleanDotsChange(Sender: TObject);
  104 + procedure ChkDotsChange(Sender: TObject);
  105 + procedure ComboCurrentConditionChange(Sender: TObject);
  106 + procedure EditConditionNameChange(Sender: TObject);
  107 + procedure EditConditionNameEditingDone(Sender: TObject);
  108 + procedure EditQuestionChange(Sender: TObject);
  109 + procedure EditQuestionEditingDone(Sender: TObject);
94 procedure FormCreate(Sender: TObject); 110 procedure FormCreate(Sender: TObject);
95 procedure FormDestroy(Sender: TObject); 111 procedure FormDestroy(Sender: TObject);
96 procedure MenuItemExitClick(Sender: TObject); 112 procedure MenuItemExitClick(Sender: TObject);
@@ -98,10 +114,39 @@ type @@ -98,10 +114,39 @@ type
98 procedure RGContingencyStyleClick(Sender: TObject); 114 procedure RGContingencyStyleClick(Sender: TObject);
99 procedure RGEndCriteriaStyleClick(Sender: TObject); 115 procedure RGEndCriteriaStyleClick(Sender: TObject);
100 procedure RGPointsClick(Sender: TObject); 116 procedure RGPointsClick(Sender: TObject);
  117 + procedure SpinEditCyclesValueEditingDone(Sender: TObject);
  118 + procedure SpinEditEndCriteriaAbsCyclesEditingDone(Sender: TObject);
  119 + procedure SpinEditEndCriteriaInterlockingEditingDone(
  120 + Sender: TObject);
  121 + procedure SpinEditTurnValueEditingDone(Sender: TObject);
101 procedure XMLPropStorageRestoreProperties(Sender: TObject); 122 procedure XMLPropStorageRestoreProperties(Sender: TObject);
102 procedure XMLPropStorageSavingProperties(Sender: TObject); 123 procedure XMLPropStorageSavingProperties(Sender: TObject);
  124 + procedure XMLPropStorageStoredValuesFileNameRestore(Sender: TStoredValue;
  125 + var Value: TStoredType);
  126 + procedure XMLPropStorageStoredValuesFileNameSave(Sender: TStoredValue;
  127 + var Value: TStoredType);
103 private 128 private
104 - FExperiment : TIniFile; 129 + FExperiment: TIniFile;
  130 + procedure LoadExperiment;
  131 + procedure LoadSectionExperiment;
  132 + procedure LoadSectionCondition(LS: string);
  133 + procedure LoadContingency(LS, LC: string);
  134 + procedure SaveExperiment;
  135 + procedure SaveSectionExperiment;
  136 + procedure SaveSectionCondition(LS: string);
  137 + procedure SaveContingency(LS, LC: string);
  138 + private
  139 + function GetLC(IsMeta:Boolean):string;
  140 + function GetConsequenceStyle: string;
  141 + function GetContingencyCriteria: string;
  142 + function GetEndCriteriaPorcentage: string;
  143 + function GetEndCriteriaStyleFromRGEndCriteriaStyle: string;
  144 + function GetMatrixTypeStringFromCGMatrix: string;
  145 + function GetPromptQuestionStringFromCGQuestion: string;
  146 + procedure SetCGMatrix(AMatrixType: string);
  147 + procedure SetCGQuestion(AQuestionStyle: string);
  148 + procedure SetRGEndCriteriaStyle(AStyle: string);
  149 + procedure SetContingencyCriteria(S: string);
105 public 150 public
106 { public declarations } 151 { public declarations }
107 end; 152 end;
@@ -111,145 +156,614 @@ var @@ -111,145 +156,614 @@ var
111 156
112 implementation 157 implementation
113 158
114 -uses game_resources, game_file_methods; 159 +uses game_resources, game_actors, string_methods, strutils;
115 160
116 {$R *.lfm} 161 {$R *.lfm}
117 162
118 { TFormDesigner } 163 { TFormDesigner }
119 164
120 -  
121 procedure TFormDesigner.MenuItemOpenClick(Sender: TObject); 165 procedure TFormDesigner.MenuItemOpenClick(Sender: TObject);
122 begin 166 begin
123 if OpenDialog.Execute then 167 if OpenDialog.Execute then
124 - begin  
125 - if FExperiment.FileName = OpenDialog.FileName then Exit;  
126 - FExperiment := TIniFile.Create(OpenDialog.FileName);  
127 - end; 168 + begin
  169 + if FExperiment.FileName = OpenDialog.FileName then
  170 + Exit;
  171 + FExperiment.Free;
  172 + FExperiment := TIniFile.Create(OpenDialog.FileName);
  173 + XMLPropStorage.StoredValue['FileName'] := FExperiment.FileName;
  174 + end;
128 end; 175 end;
129 176
130 procedure TFormDesigner.RGContingencyStyleClick(Sender: TObject); 177 procedure TFormDesigner.RGContingencyStyleClick(Sender: TObject);
131 -var LVisible : Boolean; 178 +var
  179 + LVisible: boolean;
132 begin 180 begin
133 LVisible := True; 181 LVisible := True;
134 case TRadioGroup(Sender).ItemIndex of 182 case TRadioGroup(Sender).ItemIndex of
135 0: 183 0:
136 - begin  
137 - LabelIf.Visible:= not LVisible;  
138 - LabelThen.Visible:= not LVisible;  
139 - LabelOperator.Visible:= not LVisible;  
140 - GBContingencyRows.Visible:= not LVisible;  
141 - GBContingencyColors.Visible:= not LVisible;  
142 - GBContingencyConsequence.Visible:= not LVisible;  
143 - end; 184 + begin
  185 + LabelIf.Visible := not LVisible;
  186 + LabelThen.Visible := not LVisible;
  187 + LabelOperator.Visible := not LVisible;
  188 + GBContingencyRows.Visible := not LVisible;
  189 + GBContingencyColors.Visible := not LVisible;
  190 + GBContingencyConsequence.Visible := not LVisible;
  191 + end;
144 192
145 1: 193 1:
146 - begin  
147 - LabelIf.Visible:= LVisible;  
148 - LabelThen.Visible:= LVisible;  
149 - LabelOperator.Visible:= not LVisible;  
150 - GBContingencyRows.Visible:= LVisible;  
151 - GBContingencyColors.Visible:= not LVisible;  
152 - GBContingencyConsequence.Visible:= LVisible;  
153 - end; 194 + begin
  195 + LabelIf.Visible := LVisible;
  196 + LabelThen.Visible := LVisible;
  197 + LabelOperator.Visible := not LVisible;
  198 + GBContingencyRows.Visible := LVisible;
  199 + GBContingencyColors.Visible := not LVisible;
  200 + GBContingencyConsequence.Visible := LVisible;
  201 + end;
154 202
155 2: 203 2:
156 - begin  
157 - LabelIf.Visible:= LVisible;  
158 - LabelThen.Visible:= LVisible;  
159 - LabelOperator.Visible:= not LVisible;  
160 - GBContingencyRows.Visible:= not LVisible;  
161 - GBContingencyColors.Visible:= LVisible;  
162 - GBContingencyConsequence.Visible:= LVisible;  
163 - end; 204 + begin
  205 + LabelIf.Visible := LVisible;
  206 + LabelThen.Visible := LVisible;
  207 + LabelOperator.Visible := not LVisible;
  208 + GBContingencyRows.Visible := not LVisible;
  209 + GBContingencyColors.Visible := LVisible;
  210 + GBContingencyConsequence.Visible := LVisible;
  211 + end;
164 3: 212 3:
165 - begin  
166 - LabelIf.Visible:= LVisible;  
167 - LabelThen.Visible:= LVisible;  
168 - LabelOperator.Caption:='E';  
169 - LabelOperator.Visible:= LVisible;  
170 - GBContingencyRows.Visible:= LVisible;  
171 - GBContingencyColors.Visible:= LVisible;  
172 - GBContingencyConsequence.Visible:= LVisible;  
173 - end; 213 + begin
  214 + LabelIf.Visible := LVisible;
  215 + LabelThen.Visible := LVisible;
  216 + LabelOperator.Caption := 'E';
  217 + LabelOperator.Visible := LVisible;
  218 + GBContingencyRows.Visible := LVisible;
  219 + GBContingencyColors.Visible := LVisible;
  220 + GBContingencyConsequence.Visible := LVisible;
  221 + end;
174 4: 222 4:
175 - begin  
176 - LabelIf.Visible:= LVisible;  
177 - LabelThen.Visible:= LVisible;  
178 - LabelOperator.Caption:='OU';  
179 - LabelOperator.Visible:= LVisible;  
180 - GBContingencyRows.Visible:= LVisible;  
181 - GBContingencyColors.Visible:= LVisible;  
182 - GBContingencyConsequence.Visible:= LVisible;  
183 - end; 223 + begin
  224 + LabelIf.Visible := LVisible;
  225 + LabelThen.Visible := LVisible;
  226 + LabelOperator.Caption := 'OU';
  227 + LabelOperator.Visible := LVisible;
  228 + GBContingencyRows.Visible := LVisible;
  229 + GBContingencyColors.Visible := LVisible;
  230 + GBContingencyConsequence.Visible := LVisible;
  231 + end;
184 end; 232 end;
185 CheckBoxIsMetaChange(CheckBoxIsMeta); 233 CheckBoxIsMetaChange(CheckBoxIsMeta);
186 end; 234 end;
187 235
188 procedure TFormDesigner.RGEndCriteriaStyleClick(Sender: TObject); 236 procedure TFormDesigner.RGEndCriteriaStyleClick(Sender: TObject);
  237 +var
  238 + LS: String;
189 begin 239 begin
190 case TRadioGroup(Sender).ItemIndex of 240 case TRadioGroup(Sender).ItemIndex of
191 0: 241 0:
192 - begin  
193 - LabelEndCriteriaAbsCycles.Visible := True;  
194 - SpinEditEndCriteriaAbsCycles.Visible:= True;  
195 - GBEndCriteriaLastCycles.Visible:= False; 242 + begin
  243 + LabelEndCriteriaAbsCycles.Visible := True;
  244 + SpinEditEndCriteriaAbsCycles.Visible := True;
  245 + GBEndCriteriaLastCycles.Visible := False;
196 246
197 - end; 247 + end;
198 1: 248 1:
199 - begin  
200 - LabelEndCriteriaAbsCycles.Visible := False;  
201 - SpinEditEndCriteriaAbsCycles.Visible:= False;  
202 - GBEndCriteriaLastCycles.Visible:= True;  
203 - end; 249 + begin
  250 + LabelEndCriteriaAbsCycles.Visible := False;
  251 + SpinEditEndCriteriaAbsCycles.Visible := False;
  252 + GBEndCriteriaLastCycles.Visible := True;
  253 + end;
204 2: 254 2:
  255 + begin
  256 + LabelEndCriteriaAbsCycles.Visible := True;
  257 + SpinEditEndCriteriaAbsCycles.Visible := True;
  258 + GBEndCriteriaLastCycles.Visible := True;
  259 + end;
  260 + end;
  261 +
  262 + with FExperiment do
  263 + if ComboCurrentCondition.ItemIndex <> -1 then
205 begin 264 begin
206 - LabelEndCriteriaAbsCycles.Visible := True;  
207 - SpinEditEndCriteriaAbsCycles.Visible:= True;  
208 - GBEndCriteriaLastCycles.Visible:= True; 265 + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1);
  266 + WriteString(LS, KEY_ENDCRITERIA, GetEndCriteriaStyleFromRGEndCriteriaStyle);
209 end; 267 end;
210 - end;  
211 end; 268 end;
212 269
213 procedure TFormDesigner.RGPointsClick(Sender: TObject); 270 procedure TFormDesigner.RGPointsClick(Sender: TObject);
214 begin 271 begin
215 case TRadioGroup(Sender).ItemIndex of 272 case TRadioGroup(Sender).ItemIndex of
216 0: 273 0:
  274 + begin
  275 + CBPointsType.Items.Clear;
  276 + CBPointsType.Items.Append('Individual A');
  277 + CBPointsType.Items.Append('Individual B');
  278 + CBPointsType.Items.Append('Para o Grupo');
  279 + end;
  280 +
  281 + 1:
  282 + begin
  283 + CBPointsType.Items.Clear;
  284 + CBPointsType.Items.Append('Individual');
  285 + CBPointsType.Items.Append('Para o Grupo');
  286 + end;
  287 + end;
  288 +end;
  289 +
  290 +procedure TFormDesigner.SpinEditCyclesValueEditingDone(Sender: TObject);
  291 +var
  292 + LS: string;
  293 +begin
  294 + with FExperiment do
  295 + if ComboCurrentCondition.ItemIndex <> -1 then
  296 + begin
  297 + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1);
  298 + WriteInteger(LS, KEY_CYCLES_VALUE, SpinEditCyclesValue.Value);
  299 + end;
  300 +end;
  301 +
  302 +procedure TFormDesigner.SpinEditEndCriteriaAbsCyclesEditingDone(Sender: TObject
  303 + );
  304 +var
  305 + LS: String;
  306 +begin
  307 + with FExperiment do
  308 + if ComboCurrentCondition.ItemIndex <> -1 then
217 begin 309 begin
218 - CBPointsType.Items.Clear;  
219 - CBPointsType.Items.Append('Individual A');  
220 - CBPointsType.Items.Append('Individual B');  
221 - CBPointsType.Items.Append('Para o Grupo'); 310 + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1);
  311 + WriteInteger(LS, KEY_ENDCRITERIA_CYCLES, SpinEditEndCriteriaAbsCycles.Value);
222 end; 312 end;
  313 +end;
223 314
224 - 1: 315 +procedure TFormDesigner.SpinEditEndCriteriaInterlockingEditingDone(
  316 + Sender: TObject);
  317 +var
  318 + LS: string;
  319 +begin
  320 + with FExperiment do
  321 + if ComboCurrentCondition.ItemIndex <> -1 then
225 begin 322 begin
226 - CBPointsType.Items.Clear;  
227 - CBPointsType.Items.Append('Individual');  
228 - CBPointsType.Items.Append('Para o Grupo'); 323 + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1);
  324 + WriteString(LS, KEY_ENDCRITERIA_PORCENTAGE, GetEndCriteriaPorcentage);
  325 + end;
  326 +end;
  327 +
  328 +procedure TFormDesigner.SpinEditTurnValueEditingDone(Sender: TObject);
  329 +var
  330 + LS: string;
  331 +begin
  332 + with FExperiment do
  333 + if ComboCurrentCondition.ItemIndex <> -1 then
  334 + begin
  335 + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1);
  336 + WriteInteger(LS, KEY_TURN_VALUE, SpinEditTurnValue.Value);
229 end; 337 end;
230 - end;  
231 end; 338 end;
232 339
233 procedure TFormDesigner.XMLPropStorageRestoreProperties(Sender: TObject); 340 procedure TFormDesigner.XMLPropStorageRestoreProperties(Sender: TObject);
234 -//var  
235 -// i: Integer;  
236 begin 341 begin
237 - //for i := 0 to CGGlobal.Items.Count-1 do  
238 - // CGGlobal.Checked[i] := StrToBool(XMLPropStorage.StoredValue['CGGLobal.Checked'+IntToStr(i)]);  
239 - //  
240 - //for i := 0 to CGMatrix.Items.Count-1 do  
241 - // CGMatrix.Checked[i] := StrToBool(XMLPropStorage.StoredValue['CGMatrix.Checked'+IntToStr(i)]); 342 + LoadExperiment;
  343 + ListBoxConditions.Items.Text := ComboCurrentCondition.Items.Text;
  344 + ListBoxContingencies.Items.Text := ComboCurrentContingency.Items.Text;
  345 + RGPointsClick(RGPoints);
  346 + RGEndCriteriaStyleClick(RGEndCriteriaStyle);
242 end; 347 end;
243 348
244 procedure TFormDesigner.XMLPropStorageSavingProperties(Sender: TObject); 349 procedure TFormDesigner.XMLPropStorageSavingProperties(Sender: TObject);
245 -//var  
246 -// i: Integer;  
247 begin 350 begin
248 - //for i := 0 to CGGlobal.Items.Count-1 do  
249 - // XMLPropStorage.StoredValue['CGGLobal.Checked'+IntToStr(i)] := BoolToStr(CGGLobal.Checked[i]);  
250 - //  
251 - //for i := 0 to CGMatrix.Items.Count-1 do  
252 - // XMLPropStorage.StoredValue['CGMatrix.Checked'+IntToStr(i)] := BoolToStr(CGMatrix.Checked[i]); 351 + SaveExperiment;
  352 +end;
  353 +
  354 +
  355 +procedure TFormDesigner.XMLPropStorageStoredValuesFileNameRestore(Sender: TStoredValue;
  356 + var Value: TStoredType);
  357 +begin
  358 + FExperiment := TIniFile.Create(Value);
  359 +end;
  360 +
  361 +
  362 +procedure TFormDesigner.XMLPropStorageStoredValuesFileNameSave(Sender: TStoredValue;
  363 + var Value: TStoredType);
  364 +begin
  365 + Value := FExperiment.FileName;
  366 +end;
  367 +
  368 +procedure TFormDesigner.LoadExperiment;
  369 +var
  370 + LS: string;
  371 + LC: string;
  372 +begin
  373 + LoadSectionExperiment;
  374 +
  375 + if ComboCurrentCondition.ItemIndex <> -1 then
  376 + begin
  377 + LS := SEC_CONDITION + IntToStr(ComboCurrentCondition.ItemIndex + 1);
  378 + LoadSectionCondition(LS);
  379 + if ComboCurrentContingency.ItemIndex <> -1 then
  380 + begin
  381 + LC := Delimited(1, ComboCurrentContingency.Items[ComboCurrentContingency.ItemIndex]);
  382 + LoadContingency(LS, LC);
  383 + end;
  384 + 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 +
  393 +procedure TFormDesigner.SaveExperiment;
  394 +var
  395 + LS, LC: string;
  396 +begin
  397 + SaveSectionExperiment;
  398 + if ComboCurrentCondition.ItemIndex <> -1 then
  399 + begin
  400 + LS := SEC_CONDITION + IntToStr(ComboCurrentCondition.ItemIndex + 1);
  401 + SaveSectionCondition(LS);
  402 + if ComboCurrentContingency.ItemIndex <> -1 then
  403 + begin
  404 + LC := Delimited(1, ComboCurrentContingency.Items[ComboCurrentContingency.ItemIndex]);
  405 + SaveContingency(LS, LC);
  406 + end;
  407 + end;
  408 +end;
  409 +
  410 +function TFormDesigner.GetMatrixTypeStringFromCGMatrix: string;
  411 +begin
  412 + Result := '';
  413 + if ChkColors.Checked then
  414 + Result += 'CORES,';
  415 + if ChkRows.Checked then
  416 + Result += 'LINHAS,';
  417 + if ChkCols.Checked then
  418 + Result += 'COLUNAS,';
  419 + if ChkDots.Checked then
  420 + Result += 'CÍRCULOS PREENCHIDOS,';
  421 + if ChkCleanDots.Checked then
  422 + Result += 'CÍRCULOS VAZADOS,';
  423 +end;
  424 +
  425 +function TFormDesigner.GetPromptQuestionStringFromCGQuestion: string;
  426 +var
  427 + PS: TPromptStyle;
  428 +begin
  429 + PS := [];
  430 + if CGQuestion.Checked[0] then
  431 + PS += [gsAll, gsYes, gsMetacontingency, gsContingency, gsRevertPoints];
  432 +
  433 + if CGQuestion.Checked[1] then
  434 + PS += [gsBasA];
  435 +
  436 + Result := GetPromptStyleString(PS);
  437 +end;
  438 +
  439 +procedure TFormDesigner.SetCGMatrix(AMatrixType: string);
  440 +begin
  441 + if Pos('CORES', UpperCase(AMatrixType)) > 0 then
  442 + ChkColors.Checked := True
  443 + else
  444 + ChkColors.Checked := False;
  445 +
  446 + if Pos('LINHAS', UpperCase(AMatrixType)) > 0 then
  447 + ChkRows.Checked := True
  448 + else
  449 + ChkRows.Checked := False;
  450 +
  451 + if Pos('COLUNAS', UpperCase(AMatrixType)) > 0 then
  452 + ChkCols.Checked := True
  453 + else
  454 + ChkCols.Checked := False;
  455 +
  456 + if Pos('CÍRCULOS PREENCHIDOS', UpperCase(AMatrixType)) > 0 then
  457 + ChkDots.Checked := True
  458 + else
  459 + ChkDots.Checked := False;
  460 +
  461 + if Pos('CÍRCULOS VAZADOS', UpperCase(AMatrixType)) > 0 then
  462 + ChkCleanDots.Checked := True
  463 + else
  464 + ChkCleanDots.Checked := False;
  465 +end;
  466 +
  467 +procedure TFormDesigner.SetCGQuestion(AQuestionStyle: string);
  468 +var
  469 + PS: TPromptStyle;
  470 +begin
  471 + PS := GetPromptStyleFromString(AQuestionStyle);
  472 + if (gsAll in PS) and (gsYes in PS) and (gsMetacontingency in PS) and
  473 + (gsContingency in PS) and (gsRevertPoints in PS) then
  474 + CGQuestion.Checked[0] := True
  475 + else
  476 + CGQuestion.Checked[0] := False;
  477 +
  478 + if (gsBasA) in PS then
  479 + CGQuestion.Checked[1] := True
  480 + else
  481 + CGQuestion.Checked[1] := False;
  482 +end;
  483 +
  484 +procedure TFormDesigner.SetRGEndCriteriaStyle(AStyle: string);
  485 +begin
  486 + case UpperCase(AStyle) of
  487 + 'CICLOS': RGEndCriteriaStyle.ItemIndex := 0;
  488 + 'PORCENTAGEM': RGEndCriteriaStyle.ItemIndex := 1;
  489 + 'O QUE OCORRER PRIMEIRO': RGEndCriteriaStyle.ItemIndex := 2;
  490 + end;
  491 +end;
  492 +
  493 +procedure TFormDesigner.SetContingencyCriteria(S: string);
  494 +var
  495 + C: TCriteria;
  496 +
  497 + procedure SetContingencyRows(GR: TGameRows);
  498 + var
  499 + i: integer;
  500 + begin
  501 + for i := 0 to GBContingencyRows.ComponentCount - 1 do
  502 + 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;
  515 + end;
  516 + end;
  517 +
  518 + procedure SetContingencyColors(GC: TGameColors);
  519 + var
  520 + i: integer;
  521 + begin
  522 + for i := 0 to GBContingencyColors.ComponentCount - 1 do
  523 + case GBContingencyColors.Components[i].Name of
  524 + 'ChkEqual': TCheckBox(GBContingencyColors.Components[i]).Checked := gcEqual in GC;
  525 + 'ChkDiff': TCheckBox(GBContingencyColors.Components[i]).Checked := gcDiff in GC;
  526 + 'ChkNot': TCheckBox(GBContingencyColors.Components[i]).Checked := gcNot in GC;
  527 + 'ChkY': TCheckBox(GBContingencyColors.Components[i]).Checked := gcYellow in GC;
  528 + 'ChkR': TCheckBox(GBContingencyColors.Components[i]).Checked := gcRed in GC;
  529 + 'ChkM': TCheckBox(GBContingencyColors.Components[i]).Checked := gcMagenta in GC;
  530 + 'ChkB': TCheckBox(GBContingencyColors.Components[i]).Checked := gcBlue in GC;
  531 + 'ChkG': TCheckBox(GBContingencyColors.Components[i]).Checked := gcDiff in GC;
  532 + end;
  533 + end;
  534 +
  535 +begin
  536 + C := GetCriteriaFromString(S);
  537 + case C.Style of
  538 + gtNone: RGContingencyStyle.ItemIndex := 0;
  539 + gtRowsOnly:
  540 + begin
  541 + RGContingencyStyle.ItemIndex := 1;
  542 + SetContingencyRows(C.Rows);
  543 + end;
  544 + gtColorsOnly:
  545 + begin
  546 + RGContingencyStyle.ItemIndex := 2;
  547 + SetContingencyColors(C.Colors);
  548 + end;
  549 + gtRowsAndColors:
  550 + begin
  551 + RGContingencyStyle.ItemIndex := 3;
  552 + SetContingencyRows(C.Rows);
  553 + SetContingencyColors(C.Colors);
  554 + end;
  555 + gtRowsOrColors:
  556 + begin
  557 + RGContingencyStyle.ItemIndex := 4;
  558 + SetContingencyRows(C.Rows);
  559 + SetContingencyColors(C.Colors);
  560 + end;
  561 + end;
  562 +end;
  563 +
  564 +procedure TFormDesigner.SaveSectionExperiment;
  565 +begin
  566 + with FExperiment do
  567 + begin
  568 + WriteString(SEC_EXPERIMENT, KEY_RESEARCHER, EditResearcherName.Text);
  569 + WriteString(SEC_EXPERIMENT, KEY_NAME, EditExperimentName.Text);
  570 + WriteString(SEC_EXPERIMENT, KEY_AIM, MemoExperimentAim.Text);
  571 + WriteBool(SEC_EXPERIMENT, KEY_CHAT_HISTORY_FOR_NEW_PLAYERS, CGGlobal.Checked[0]);
  572 + WriteBool(SEC_EXPERIMENT, KEY_GEN_PLAYER_AS_NEEDED, CGGlobal.Checked[1]);
  573 + WriteBool(SEC_EXPERIMENT, KEY_RESEARCHER_CANPLAY, CGGlobal.Checked[2]);
  574 + WriteBool(SEC_EXPERIMENT, KEY_RESEARCHER_CANCHAT, CGGlobal.Checked[3]);
  575 + case RGPoints.ItemIndex of
  576 + 0: WriteBool(SEC_EXPERIMENT, KEY_POINTS_TYPE, True);
  577 + 1: WriteBool(SEC_EXPERIMENT, KEY_POINTS_TYPE, False);
  578 + end;
  579 + WriteString(SEC_EXPERIMENT, KEY_MATRIX_TYPE, GetMatrixTypeStringFromCGMatrix);
  580 + end;
  581 +end;
  582 +
  583 +procedure TFormDesigner.LoadSectionExperiment;
  584 +begin
  585 + with FExperiment do
  586 + begin
  587 + EditResearcherName.Text := ReadString(SEC_EXPERIMENT, KEY_RESEARCHER, '');
  588 + EditExperimentName.Text := ReadString(SEC_EXPERIMENT, KEY_NAME, '');
  589 + MemoExperimentAim.Text := ReadString(SEC_EXPERIMENT, KEY_AIM, '');
  590 + CGGlobal.Checked[0] :=
  591 + ReadBool(SEC_EXPERIMENT, KEY_CHAT_HISTORY_FOR_NEW_PLAYERS, False);
  592 + CGGlobal.Checked[1] := ReadBool(SEC_EXPERIMENT, KEY_GEN_PLAYER_AS_NEEDED, False);
  593 + CGGlobal.Checked[2] := ReadBool(SEC_EXPERIMENT, KEY_RESEARCHER_CANPLAY, False);
  594 + CGGlobal.Checked[3] := ReadBool(SEC_EXPERIMENT, KEY_RESEARCHER_CANCHAT, False);
  595 + if ReadBool(SEC_EXPERIMENT, KEY_POINTS_TYPE, True) then
  596 + RGPoints.ItemIndex := 0
  597 + else
  598 + RGPoints.ItemIndex := 1;
  599 + SetCGMatrix(ReadString(SEC_EXPERIMENT, KEY_MATRIX_TYPE, 'CORES,LINHAS'));
  600 + end;
  601 +end;
  602 +
  603 +procedure TFormDesigner.SaveSectionCondition(LS: string);
  604 +begin
  605 + with FExperiment do
  606 + begin
  607 + WriteString(LS, KEY_COND_NAME, EditConditionName.Text);
  608 + WriteInteger(LS, KEY_TURN_VALUE, SpinEditTurnValue.Value);
  609 + WriteInteger(LS, KEY_POINTS_ONSTART,SpinEditOnConditionBegin.Value);
  610 + WriteInteger(LS, KEY_CYCLES_VALUE, SpinEditCyclesValue.Value);
  611 + WriteString(LS, KEY_PROMPT_MESSAGE, EditQuestion.Text);
  612 + WriteString(LS, KEY_PROMPT_STYLE, GetPromptQuestionStringFromCGQuestion);
  613 + WriteString(LS, KEY_ENDCRITERIA, GetEndCriteriaStyleFromRGEndCriteriaStyle);
  614 + WriteInteger(LS, KEY_ENDCRITERIA_CYCLES, SpinEditEndCriteriaAbsCycles.Value);
  615 + WriteString(LS, KEY_ENDCRITERIA_PORCENTAGE, GetEndCriteriaPorcentage);
  616 + end;
  617 +end;
  618 +
  619 +procedure TFormDesigner.SaveContingency(LS, LC: string);
  620 +begin
  621 + with FExperiment do
  622 + begin
  623 + WriteString(LS, LC + KEY_NAME, EditContingencyName.Text);
  624 + WriteString(LS, LC + KEY_CRITERIA, GetContingencyCriteria);
  625 + 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);
  629 + end;
  630 +end;
  631 +
  632 +function TFormDesigner.GetLC(IsMeta: Boolean): string;
  633 +var
  634 + LCount,
  635 + i : integer;
  636 + S : string;
  637 + Extension : string;
  638 + ContingencyKey : string;
  639 +begin
  640 + 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
  671 + else
  672 + if IsMeta then
  673 + Result := KEY_METACONTINGENCY+'1'
  674 + else
  675 + Result := KEY_CONTINGENCY+'1';
  676 +end;
  677 +
  678 +function TFormDesigner.GetConsequenceStyle: string;
  679 +var
  680 + CS : TConsequenceStyle;
  681 +begin
  682 + CS := [gscMessage,gscPoints];
  683 + case RGPoints.ItemIndex of
  684 + 0: { A & B }
  685 + case CBPointsType.ItemIndex of
  686 + 0 {'Individual A'} : CS += [gscA];
  687 + 1 {'Individual B'} : CS += [gscB];
  688 + 2 {'Para o Grupo'} : CS += [gscG];
  689 + end;
  690 + 1: { I }
  691 + case CBPointsType.ItemIndex of
  692 + 0 {'Individual'} : CS += [gscI];
  693 + 1 {'Para o Grupo'} : CS += [gscG];
  694 + end;
  695 + end;
  696 +
  697 + case CheckBoxBroadcast.State of
  698 + cbChecked : CS += [gscBroadcastMessage];
  699 + cbUnchecked: { do nothing };
  700 + cbGrayed: CS -= [gscMessage];
  701 + end;
  702 +
  703 + Result := GetConsequenceStylesString(CS);
  704 +end;
  705 +
  706 +function TFormDesigner.GetContingencyCriteria: string;
  707 +begin
  708 +
  709 +end;
  710 +
  711 +procedure TFormDesigner.LoadSectionCondition(LS: string);
  712 +begin
  713 + with FExperiment do
  714 + begin
  715 + EditConditionName.Text := ReadString(LS, KEY_COND_NAME, LS);
  716 + SpinEditTurnValue.Value := ReadInteger(LS, KEY_TURN_VALUE, 2);
  717 + SpinEditOnConditionBegin.Value := ReadInteger(LS, KEY_POINTS_ONSTART,0);
  718 + SpinEditCyclesValue.Value := ReadInteger(LS, KEY_CYCLES_VALUE, 2);
  719 +
  720 + CheckBoxShouldAskQuestion.Checked := False;
  721 + if ValueExists(LS, KEY_PROMPT_STYLE) and ValueExists(LS, KEY_PROMPT_MESSAGE) then
  722 + begin
  723 + EditQuestion.Text := ReadString(LS, KEY_PROMPT_MESSAGE, '');
  724 + SetCGQuestion(ReadString(LS, KEY_PROMPT_STYLE, ''));
  725 + if (EditQuestion.Text <> '') or (ReadString(LS, KEY_PROMPT_STYLE, '') <> '') then
  726 + CheckBoxShouldAskQuestion.Checked := True;
  727 + end;
  728 +
  729 + SetRGEndCriteriaStyle(ReadString(LS, KEY_ENDCRITERIA, 'O QUE OCORRER PRIMEIRO'));
  730 + SpinEditEndCriteriaAbsCycles.Value := ReadInteger(LS, KEY_ENDCRITERIA_CYCLES, 20);
  731 + SpinEditEndCriteriaLastCycles.Value :=
  732 + GetEndCriteriaLastCyclesFromString(ReadString(LS, KEY_ENDCRITERIA_PORCENTAGE, '80,20'));
  733 + SpinEditEndCriteriaInterlockingPorcentage.Value :=
  734 + GetEndCriteriaPorcentageFromString(ReadString(LS, KEY_ENDCRITERIA_PORCENTAGE, '80,20'));
  735 + end;
  736 +end;
  737 +
  738 +procedure TFormDesigner.LoadContingency(LS, LC: string);
  739 +begin
  740 + if Pos('Metacontingency', LC) > 0 then
  741 + CheckBoxIsMeta.Checked := True
  742 + else
  743 + CheckBoxIsMeta.Checked := False;
  744 +
  745 + with FExperiment do
  746 + 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;
  752 +end;
  753 +
  754 +function TFormDesigner.GetEndCriteriaPorcentage: string;
  755 +begin
  756 + Result := IntToStr(SpinEditEndCriteriaInterlockingPorcentage.Value) + ',' +
  757 + IntToStr(SpinEditEndCriteriaLastCycles.Value);
  758 +end;
  759 +
  760 +function TFormDesigner.GetEndCriteriaStyleFromRGEndCriteriaStyle: string;
  761 +begin
  762 + case RGEndCriteriaStyle.ItemIndex of
  763 + 0: Result := 'CICLOS';
  764 + 1: Result := 'PORCENTAGEM';
  765 + 2: Result := 'O QUE OCORRER PRIMEIRO';
  766 + end;
253 end; 767 end;
254 768
255 procedure TFormDesigner.MenuItemExitClick(Sender: TObject); 769 procedure TFormDesigner.MenuItemExitClick(Sender: TObject);
@@ -258,80 +772,236 @@ begin @@ -258,80 +772,236 @@ begin
258 end; 772 end;
259 773
260 procedure TFormDesigner.FormCreate(Sender: TObject); 774 procedure TFormDesigner.FormCreate(Sender: TObject);
261 -//var  
262 -// LFileName: String;  
263 begin 775 begin
264 - //LFileName := 'default.txt';  
265 - //IPSExperiment.IniFileName := LFileName;  
266 //IPSExperiment.IniSection := SEC_EXPERIMENT; 776 //IPSExperiment.IniSection := SEC_EXPERIMENT;
267 - //IPSConditions.IniFileName := LFileName;  
268 //IPSConditions.IniSection := SEC_CONDITION; 777 //IPSConditions.IniSection := SEC_CONDITION;
269 - //IPSPlayers.IniFileName := LFileName;  
270 //IPSPlayers.IniSection := SEC_PLAYER; 778 //IPSPlayers.IniSection := SEC_PLAYER;
271 - RGPointsClick(RGPoints);  
272 - RGEndCriteriaStyleClick(RGEndCriteriaStyle);  
273 - FExperiment := TCIniFile.Create('default.txt');  
274 - //FExperiment.FileName; 779 +
275 end; 780 end;
276 781
277 procedure TFormDesigner.FormDestroy(Sender: TObject); 782 procedure TFormDesigner.FormDestroy(Sender: TObject);
278 begin 783 begin
279 - FExperiment.Destroy; 784 + FExperiment.Free;
280 end; 785 end;
281 786
282 procedure TFormDesigner.CheckBoxShouldAskQuestionChange(Sender: TObject); 787 procedure TFormDesigner.CheckBoxShouldAskQuestionChange(Sender: TObject);
  788 +var
  789 + LS: String;
283 begin 790 begin
284 if TCheckBox(Sender).Checked then 791 if TCheckBox(Sender).Checked then
285 - TCheckBox(Sender).Caption := 'Sim' 792 + TCheckBox(Sender).Caption := 'Sim'
286 else 793 else
287 - TCheckBox(Sender).Caption := 'Não'; 794 + begin
  795 + TCheckBox(Sender).Caption := 'Não';
  796 + with FExperiment do
  797 + if ComboCurrentCondition.ItemIndex <> -1 then
  798 + begin
  799 + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1);
  800 + WriteString(LS, KEY_PROMPT_MESSAGE, '');
  801 + WriteString(LS, KEY_PROMPT_STYLE, '');
  802 + end;
  803 + end;
288 804
289 EditQuestion.Visible := CheckBoxShouldAskQuestion.Checked; 805 EditQuestion.Visible := CheckBoxShouldAskQuestion.Checked;
290 CGQuestion.Visible := CheckBoxShouldAskQuestion.Checked; 806 CGQuestion.Visible := CheckBoxShouldAskQuestion.Checked;
291 end; 807 end;
292 808
  809 +procedure TFormDesigner.ChkCleanDotsChange(Sender: TObject);
  810 +begin
  811 + if ChkCleanDots.Checked then
  812 + ChkDots.Checked := not ChkCleanDots.Checked;
  813 +end;
  814 +
  815 +procedure TFormDesigner.ChkDotsChange(Sender: TObject);
  816 +begin
  817 + if ChkDots.Checked then
  818 + ChkCleanDots.Checked := not ChkDots.Checked;
  819 +end;
  820 +
  821 +procedure TFormDesigner.ComboCurrentConditionChange(Sender: TObject);
  822 +begin
  823 + LoadSectionCondition(SEC_CONDITION + IntToStr(ComboCurrentCondition.ItemIndex + 1));
  824 +end;
  825 +
  826 +procedure TFormDesigner.EditConditionNameChange(Sender: TObject);
  827 +begin
  828 +
  829 +end;
  830 +
  831 +procedure TFormDesigner.EditConditionNameEditingDone(Sender: TObject);
  832 +var
  833 + LS: string;
  834 +begin
  835 + with FExperiment do
  836 + if ComboCurrentCondition.ItemIndex <> -1 then
  837 + begin
  838 + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1);
  839 + WriteString(LS, KEY_COND_NAME, EditConditionName.Text);
  840 + ComboCurrentCondition.Items[ComboCurrentCondition.ItemIndex] :=
  841 + SEC_CONDITION + IntToStr(ComboCurrentCondition.ItemIndex + 1) + '|' + EditConditionName.Text;
  842 + ListBoxConditions.Items.Text := ComboCurrentCondition.Items.Text;
  843 + end;
  844 +end;
  845 +
  846 +procedure TFormDesigner.EditQuestionChange(Sender: TObject);
  847 +begin
  848 +
  849 +end;
  850 +
  851 +procedure TFormDesigner.EditQuestionEditingDone(Sender: TObject);
  852 +var
  853 + LS: string;
  854 +begin
  855 + with FExperiment do
  856 + if ComboCurrentCondition.ItemIndex <> -1 then
  857 + begin
  858 + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1);
  859 + WriteString(LS, KEY_PROMPT_MESSAGE, EditQuestion.Text);
  860 + end;
  861 +end;
  862 +
293 procedure TFormDesigner.CheckBoxBroadcastChange(Sender: TObject); 863 procedure TFormDesigner.CheckBoxBroadcastChange(Sender: TObject);
294 begin 864 begin
295 - if TCheckBox(Sender).Checked then  
296 - TCheckBox(Sender).Caption := 'a todos'  
297 - else  
298 - TCheckBox(Sender).Caption := 'ao participante'; 865 + case TCheckBox(Sender).State of
  866 + cbChecked: TCheckBox(Sender).Caption := 'a todos';
  867 + cbUnchecked: TCheckBox(Sender).Caption := 'ao participante';
  868 + cbGrayed: TCheckBox(Sender).Caption := 'a ninguém';
  869 + end;
  870 +end;
  871 +
  872 +procedure TFormDesigner.BtnAppendCondClick(Sender: TObject);
  873 +var
  874 + i: integer;
  875 +begin
  876 + i := ComboCurrentCondition.Items.Add('');
  877 + ComboCurrentCondition.Items[i] :=
  878 + SEC_CONDITION + IntToStr(i + 1) + '|' + EditConditionName.Text;
  879 + ComboCurrentCondition.ItemIndex := i;
  880 + SaveSectionCondition(SEC_CONDITION + IntToStr(i + 1));
  881 + ListBoxConditions.Items.Text := ComboCurrentCondition.Items.Text;
  882 +end;
  883 +
  884 +procedure TFormDesigner.BtnAppendContingencyClick(Sender: TObject);
  885 +var
  886 + i: integer;
  887 + LS, LC : string;
  888 +
  889 +begin
  890 + i := ComboCurrentContingency.Items.Add('');
  891 + LS := ExtractDelimited(1,ComboCurrentCondition.Items[ComboCurrentCondition.ItemIndex],['|']);
  892 + LC := GetLC(CheckBoxIsMeta.Checked);
  893 + ComboCurrentContingency.Items[i] :=
  894 + LC + '|' + EditContingencyName.Text;
  895 + ComboCurrentContingency.ItemIndex := i;
  896 + SaveContingency(LS,LC);
  897 + ListBoxContingencies.Items.Text := ComboCurrentContingency.Items.Text;
  898 +end;
  899 +
  900 +procedure TFormDesigner.BtnRemoveCondClick(Sender: TObject);
  901 +var
  902 + i: integer;
  903 + MustReorder: boolean;
  904 +
  905 + procedure Reorder(index : integer);
  906 + var
  907 + j, i: integer;
  908 + Section: TStringList;
  909 + KeyName,Line,SectionName: string;
  910 + begin
  911 + Section := TStringList.Create;
  912 + with FExperiment do
  913 + 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;
  928 + Section.Free;
  929 + end;
  930 +
  931 +begin
  932 + i := ComboCurrentCondition.ItemIndex;
  933 + MustReorder := i < ComboCurrentCondition.Items.Count - 1;
  934 + ComboCurrentCondition.Items.Delete(i);
  935 + if MustReorder then
  936 + Reorder(i);
  937 + case ComboCurrentCondition.Items.Count of
  938 + 0: {do nothing};
  939 + 1..MaxInt:
  940 + if i = 1 then
  941 + ComboCurrentCondition.ItemIndex := i
  942 + else
  943 + ComboCurrentCondition.ItemIndex := i -1;
  944 + end;
  945 + ListBoxConditions.Items.Text := ComboCurrentCondition.Items.Text;
  946 +end;
299 947
  948 +procedure TFormDesigner.CGQuestionItemClick(Sender: TObject; Index: integer);
  949 +var
  950 + LS: String;
  951 +begin
  952 + with FExperiment do
  953 + if ComboCurrentCondition.ItemIndex <> -1 then
  954 + begin
  955 + LS := SEC_CONDITION+IntToStr(ComboCurrentCondition.ItemIndex+1);
  956 + WriteString(LS, KEY_PROMPT_STYLE, GetPromptQuestionStringFromCGQuestion);
  957 + end;
300 end; 958 end;
301 959
302 procedure TFormDesigner.CheckBoxIsMetaChange(Sender: TObject); 960 procedure TFormDesigner.CheckBoxIsMetaChange(Sender: TObject);
303 var 961 var
304 - i: Integer; 962 + i: integer;
  963 + CH: TCheckBox;
  964 +
  965 + procedure CreateChkBox(N, C: string; AOwner: TWinControl);
  966 + begin
  967 + CH := TCheckBox.Create(AOwner);
  968 + CH.Name := N;
  969 + CH.Caption := C;
  970 + CH.Parent := AOwner;
  971 + end;
  972 +
305 begin 973 begin
  974 + while GBContingencyRows.ComponentCount > 0 do
  975 + GBContingencyRows.Components[0].Free;
  976 +
  977 + while GBContingencyColors.ComponentCount > 0 do
  978 + GBContingencyColors.Components[0].Free;
  979 +
306 if TCheckBox(Sender).Checked then 980 if TCheckBox(Sender).Checked then
307 - begin  
308 - ComboBoxRows.Items.Clear;  
309 - ComboBoxRows.Items.Append('PARES');  
310 - ComboBoxRows.Items.Append('IMPARES');  
311 -  
312 - ComboBoxColors.Items.Clear;  
313 - ComboBoxColors.Items.Append('CORES IGUAIS');  
314 - ComboBoxColors.Items.Append('CORES DIFERENTES');  
315 - ComboBoxColors.Items.Append('TUDO EXCETO CORES IGUAIS');  
316 - ComboBoxColors.Items.Append('TUDO EXCETO CORES DIFERENTES');  
317 - end  
318 - else  
319 begin 981 begin
320 - ComboBoxRows.Items.Clear;  
321 - for i:=0 to 9 do  
322 - ComboBoxRows.Items.Append(IntToStr(i+1));  
323 -  
324 - ComboBoxRows.Items.Append('PAR');  
325 - ComboBoxRows.Items.Append('IMPAR');  
326 -  
327 - ComboBoxColors.Items.Clear;  
328 - ComboBoxColors.Items.Append('AMARELO');  
329 - ComboBoxColors.Items.Append('VERMELHO');  
330 - ComboBoxColors.Items.Append('ROXO');  
331 - ComboBoxColors.Items.Append('AZUL');  
332 - ComboBoxColors.Items.Append('VERDE'); 982 + CreateChkBox('ChkEven', 'PARES', GBContingencyRows);
  983 + CreateChkBox('ChkOdd', 'IMPARES', GBContingencyRows);
  984 +
  985 + CreateChkBox('ChkNot', 'TUDO EXCETO', GBContingencyColors);
  986 + CreateChkBox('ChkEqual', 'CORES IGUAIS', GBContingencyColors);
  987 + CreateChkBox('ChkDiff', 'CORES DIFERENTES', GBContingencyColors);
  988 + LabelIf.Caption := 'SE OS PARTICIPANTES ESCOLHEREM';
333 end 989 end
  990 + else
  991 + begin
  992 + for i := 0 to 9 do
  993 + CreateChkBox('Chk' + IntToStr(i + 1), IntToStr(i + 1), GBContingencyRows);
  994 +
  995 + CreateChkBox('ChkEven', 'PAR', GBContingencyRows);
  996 + CreateChkBox('ChkOdd', 'IMPAR', GBContingencyRows);
  997 +
  998 + CreateChkBox('ChkY', 'AMARELO', GBContingencyColors);
  999 + CreateChkBox('ChkR', 'VERMELHO', GBContingencyColors);
  1000 + CreateChkBox('ChkM', 'ROXO', GBContingencyColors);
  1001 + CreateChkBox('ChkB', 'AZUL', GBContingencyColors);
  1002 + CreateChkBox('ChkG', 'VERDE', GBContingencyColors);
  1003 + LabelIf.Caption := 'SE O PARTICIPANTE ESCOLHER';
  1004 + end;
334 end; 1005 end;
335 1006
336 end. 1007 end.
337 -  
experiment_designer/lib/x86_64-linux/experiment_designer.compiled
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <CONFIG> 2 <CONFIG>
3 <Compiler Value="/usr/bin/fpc" Date="1449313866"/> 3 <Compiler Value="/usr/bin/fpc" Date="1449313866"/>
4 - <Params Value=" -MObjFPC -Scghi -Cg -O1 -g -gl -l -vewnhibq -Fi/home/rafael/git/stimulus_control/tests/lacs-matrix/experiment_designer/lib/x86_64-linux -Fl/opt/gnome/lib -Fu/home/rafael/git/stimulus_control/tests/lacs-matrix/units -Fu/usr/share/lazarus/1.6.2/lcl/units/x86_64-linux/gtk2 -Fu/usr/share/lazarus/1.6.2/lcl/units/x86_64-linux -Fu/usr/share/lazarus/1.6.2/components/lazutils/lib/x86_64-linux -Fu/usr/share/lazarus/1.6.2/packager/units/x86_64-linux -Fu/home/rafael/git/stimulus_control/tests/lacs-matrix/experiment_designer/ -FU/home/rafael/git/stimulus_control/tests/lacs-matrix/experiment_designer/lib/x86_64-linux/ -dLCL -dLCLgtk2 experiment_designer.lpr"/> 4 + <Params Value=" -MObjFPC -Scghi -Cg -O1 -g -gl -l -vewnhibq -Fi/home/rafael/git/stimulus_control/tests/lacs-matrix/experiment_designer/lib/x86_64-linux -Fl/opt/gnome/lib -Fu/home/rafael/git/stimulus_control/tests/lacs-matrix/units -Fu/home/rafael/git/stimulus_control/units -Fu/usr/share/lazarus/1.6.2/lcl/units/x86_64-linux/gtk2 -Fu/usr/share/lazarus/1.6.2/lcl/units/x86_64-linux -Fu/usr/share/lazarus/1.6.2/components/lazutils/lib/x86_64-linux -Fu/usr/share/lazarus/1.6.2/packager/units/x86_64-linux -Fu/home/rafael/git/stimulus_control/tests/lacs-matrix/experiment_designer/ -FU/home/rafael/git/stimulus_control/tests/lacs-matrix/experiment_designer/lib/x86_64-linux/ -dLCL -dLCLgtk2 experiment_designer.lpr"/>
5 </CONFIG> 5 </CONFIG>