forked from hkociemba/CubeExplorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
centers.pas
144 lines (128 loc) · 3.65 KB
/
centers.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
unit centers;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TCenterDlg = class(TForm)
Button1: TButton;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
GroupBox2: TGroupBox;
RadioButton5: TRadioButton;
RadioButton6: TRadioButton;
RadioButton7: TRadioButton;
RadioButton8: TRadioButton;
GroupBox3: TGroupBox;
RadioButton9: TRadioButton;
RadioButton10: TRadioButton;
RadioButton11: TRadioButton;
RadioButton12: TRadioButton;
GroupBox4: TGroupBox;
RadioButton13: TRadioButton;
RadioButton14: TRadioButton;
RadioButton15: TRadioButton;
RadioButton16: TRadioButton;
GroupBox5: TGroupBox;
RadioButton17: TRadioButton;
RadioButton18: TRadioButton;
RadioButton19: TRadioButton;
RadioButton20: TRadioButton;
GroupBox6: TGroupBox;
RadioButton21: TRadioButton;
RadioButton22: TRadioButton;
RadioButton23: TRadioButton;
RadioButton24: TRadioButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure UClick(Sender: TObject);
procedure RClick(Sender: TObject);
procedure FClick(Sender: TObject);
procedure DClick(Sender: TObject);
procedure LClick(Sender: TObject);
procedure BClick(Sender: TObject);
private
{ Private-Deklarationen }
public
procedure checkState;
end;
var
CenterDlg: TCenterDlg;
implementation
uses RubikMain, CubeDefs, CubiCube;
{$R *.dfm}
procedure TCenterDlg.Button1Click(Sender: TObject);
begin
with Form1 do
begin
ButtonU.Enabled:=true;ButtonR.Enabled:=true;ButtonF.Enabled:=true;
ButtonD.Enabled:=true;ButtonL.Enabled:=true;ButtonB.Enabled:=true;
ButtonAddSolve.Enabled:=true; ButtonAddGen.Enabled:=true;
end;
Hide;
end;
procedure TCenterDlg.checkState;
var cc: CubieCube;
allEdges,AllCorners: Boolean;
i: Corner; k: Edge;
begin
cc:= CubieCube.Create(fCube);
allCorners:=true;
for i:=URF to DRB do if cc.PCorn^[i].c=NNN then begin allCorners:=false;break; end;
allEdges:=true;
for k:=UR to BR do if cc.PEdge^[k].e=NN then begin allEdges:=false;break; end;
if allCorners then
begin
if cc.CornParityEven xor cc.CentParityEven
then Button1.Enabled:=false
else Button1.enabled:=true;
end
else if allEdges then
begin
if cc.EdgeParityEven xor cc.CentParityEven
then Button1.Enabled:=false
else Button1.Enabled:=true;
end
else Button1.Enabled:=true; //sowohl Ecken als auch Kanten unvollständig
cc.Free;
end;
procedure TCenterDlg.UClick(Sender: TObject);
begin
fCube.cenTwist[U]:=(Sender as TRadioButton).Tag;
checkState;
Form1.facePaint.Invalidate;
end;
procedure TCenterDlg.RClick(Sender: TObject);
begin
fCube.cenTwist[R]:=(Sender as TRadioButton).Tag;
checkState;
Form1.facePaint.Invalidate;
end;
procedure TCenterDlg.FClick(Sender: TObject);
begin
fCube.cenTwist[F]:=(Sender as TRadioButton).Tag;
checkState;
Form1.facePaint.Invalidate;
end;
procedure TCenterDlg.DClick(Sender: TObject);
begin
fCube.cenTwist[D]:=(Sender as TRadioButton).Tag;
checkState;
Form1.facePaint.Invalidate;
end;
procedure TCenterDlg.LClick(Sender: TObject);
begin
fCube.cenTwist[L]:=(Sender as TRadioButton).Tag;
checkState;
Form1.facePaint.Invalidate;
end;
procedure TCenterDlg.BClick(Sender: TObject);
begin
fCube.cenTwist[B]:=(Sender as TRadioButton).Tag;
checkState;
Form1.facePaint.Invalidate;
end;
end.