-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.hx
105 lines (90 loc) · 2.68 KB
/
Main.hx
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
package;
import graphic.Button;
import graphic.DrawBackground;
import graphic.SignatureWriter;
import graphic.StringField;
import graphic.SignatureField;
import graphic.WriterToConsole;
import graphic.WriterToView;
import openfl.display.Sprite;
import openfl.events.KeyboardEvent;
import openfl.events.Event;
import openfl.Lib;
import openfl.text.TextFormat;
import parseLogic.ParseAlgo;
import reader.ReaderFromString;
import src.graphic.Writer;
import src.MainAlgo;
import reader.Reader;
import types.OperatorList;
import openfl.display.Bitmap;
import openfl.Assets;
/**
* ...
* @author Awe66
*/
class Main extends Sprite
{
public var background:DrawBackground;
private var stringField:StringField;
private var reader:Reader;
private var algo:MainAlgo;
private var writer:Writer;
public var symbolFormat:TextFormat = new TextFormat("Colibri", 50, 0x000000, true);
private var signatureField:SignatureField;
private var signatureWriter:SignatureWriter;
private var operatorList:OperatorList;
private var anewButton:Button = new Button(new Bitmap(Assets.getBitmapData('img/buttons/anewbutton.png')), 1, 1);
public function new()
{
super();
readSignature();
addChild(anewButton);
anewButton.addEventListener('click', onMouseClick);
return;
}
private function onStart(e:Event)
{
background = new DrawBackground();
writer = new WriterToView(background, symbolFormat);
reader = new ReaderFromString(stringField.readString(), operatorList);
algo = new MainAlgo(reader, writer);
signatureWriter = new SignatureWriter(operatorList, symbolFormat);
signatureWriter.x = 500;
signatureWriter.y = 400;
stringField.visible = false;
background.x = 45;
addChild(background);
addChild(algo);
Lib.current.stage.focus = algo;
addChild(signatureWriter);
algo.start();
}
private function inputStringField(e:Event)
{
removeChild(signatureField);
signatureField.removeEventListener('signature', inputStringField);
signatureField.removeEventListener('read me', readBlockOfOperators);
stringField = new StringField(symbolFormat);
stringField.x = 45;
addChild(stringField);
stringField.addEventListener("read me", onStart);
}
private function readSignature()
{
signatureField = new SignatureField(symbolFormat);
operatorList = new OperatorList(signatureField);
signatureField.x = 45;
addChild(signatureField);
signatureField.addEventListener('signature', inputStringField);
signatureField.addEventListener('read me', readBlockOfOperators);
}
//read next block of operators from signatureField
private function readBlockOfOperators(e:Event)
{
operatorList.readNext();
}
private function onMouseClick(e:Event){
readSignature();
}
}