-
Notifications
You must be signed in to change notification settings - Fork 0
/
taskfinishedui.pas
105 lines (85 loc) · 3.15 KB
/
taskfinishedui.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
UNIT taskFinishedUi;
{$mode objfpc}{$H+}
INTERFACE
USES
Classes, sysutils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls;
TYPE
T_finishResponse=(fr_backToFreeEdit,fr_restartTask,fr_nextTask,fr_cancel);
{ TTaskFinishedDialog }
TTaskFinishedDialog = class(TForm)
Label1: TLabel;
Label2: TLabel;
NextChallengeLabel: TLabel;
CancelLabel: TLabel;
SetEditModeLabel: TLabel;
RestartChallengeLabel: TLabel;
SetEditModeShape: TShape;
RestartChallengeShape: TShape;
NextChallengeShape: TShape;
CancelShape: TShape;
PROCEDURE CancelShapeMouseDown(Sender: TObject; button: TMouseButton;
Shift: TShiftState; X, Y: integer);
PROCEDURE NextChallengeShapeMouseDown(Sender: TObject;
button: TMouseButton; Shift: TShiftState; X, Y: integer);
PROCEDURE RestartChallengeShapeMouseDown(Sender: TObject;
button: TMouseButton; Shift: TShiftState; X, Y: integer);
PROCEDURE SetEditModeShapeMouseDown(Sender: TObject; button: TMouseButton;
Shift: TShiftState; X, Y: integer);
private
public
FUNCTION showAfterTest(CONST success,furtherTasksAvailable:boolean):T_finishResponse;
end;
FUNCTION TaskFinishedDialog: TTaskFinishedDialog;
IMPLEMENTATION
USES visuals;
VAR
myTaskFinishedForm: TTaskFinishedDialog=nil;
FUNCTION TaskFinishedDialog: TTaskFinishedDialog;
begin
if myTaskFinishedForm=nil then myTaskFinishedForm:=TTaskFinishedDialog.create(nil);
result:=myTaskFinishedForm;
end;
{$R *.lfm}
{ TTaskFinishedDialog }
PROCEDURE TTaskFinishedDialog.SetEditModeShapeMouseDown(Sender: TObject; button: TMouseButton; Shift: TShiftState; X, Y: integer);
begin
ModalResult:=mrClose;
end;
PROCEDURE TTaskFinishedDialog.RestartChallengeShapeMouseDown(Sender: TObject; button: TMouseButton; Shift: TShiftState; X, Y: integer);
begin
ModalResult:=mrRetry;
end;
PROCEDURE TTaskFinishedDialog.NextChallengeShapeMouseDown(Sender: TObject; button: TMouseButton; Shift: TShiftState; X, Y: integer);
begin
ModalResult:=mrYes;
end;
PROCEDURE TTaskFinishedDialog.CancelShapeMouseDown(Sender: TObject; button: TMouseButton; Shift: TShiftState; X, Y: integer);
begin
ModalResult:=mrCancel;
end;
FUNCTION TTaskFinishedDialog.showAfterTest(CONST success, furtherTasksAvailable: boolean): T_finishResponse;
VAR
mr: integer;
begin
applyColorScheme(self);
if success then begin
Label1.caption:='✔';
Label2.caption:='✔';
Label1.Font.color:=colorScheme.CORRECT_COLOR;
Label2.Font.color:=colorScheme.SHADOW_COLOR;
end else begin
Label1.caption:='✘';
Label2.caption:='✘';
Label1.Font.color:=colorScheme.INCORRECT_COLOR;
Label2.Font.color:=colorScheme.SHADOW_COLOR;
end;
setEnableButton(NextChallengeShape,NextChallengeLabel,furtherTasksAvailable);
mr:=ShowModal;
result:=fr_cancel;
if mr=mrClose then result:=fr_backToFreeEdit;
if mr=mrRetry then result:=fr_restartTask;
if mr=mrYes then result:=fr_nextTask;
end;
FINALIZATION
if myTaskFinishedForm<>nil then FreeAndNil(myTaskFinishedForm);
end.