forked from bsondermann/BlackboxSticksExporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RenderManager.pde
97 lines (97 loc) · 2.51 KB
/
RenderManager.pde
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
class RenderManager extends Thread{
boolean rendering=false;
File files[];
Renderer renderers[];
String[]renderSettings;
int simultRenderNum;
int activeRenderers;
int indexRenderer=0;
Selection s;
RenderManager(File[] f,String[]set,Selection s){
this.s=s;
simultRenderNum=Integer.parseInt(set[12]);
renderSettings=set;
filterFiles(f);
initRenderers();
start();
}
@Override void run(){
rendering=true;
while(indexRenderer<renderers.length){
if(activeRenderers<simultRenderNum){
renderers[indexRenderer].startRender();
activeRenderers++;
indexRenderer++;
}
for(int i = 0; i<indexRenderer;i++){
if(renderers[i].currentState.equals("Done")){
renderers[i].currentState=lang.getTranslation("rendererStateDone");
activeRenderers--;
}
}
}
boolean done = false;
while(!done){
done = true;
for(int i = 0; i<renderers.length;i++){
if(renderers[i].running){
done = false;
}
if(renderers[i].currentState.equals("Done")){
renderers[i].currentState=lang.getTranslation("rendererStateDone");
}
}
}
s.doneRendering();
}
void initRenderers(){
renderers = new Renderer[files.length];
for(int i = 0; i<renderers.length; i++){
renderers[i] = new Renderer(files[i],renderSettings,i);
}
}
void filterFiles(File[]f){
int filenum =0;
for(int i = 0; i< f.length;i++){
if(f[i].getName().contains(".BFL")||f[i].getName().contains(".bbl")){
filenum++;
}
else if(f[i].getName().contains(".TXT")){
String []s = loadStrings(f[i]);
if(s.length>0){
if(s[0].equals("H Product:Blackbox flight data recorder by Nicholas Sherlock")){
filenum++;
}
}
}
}
files= new File[filenum];
int index=0;
for(int i = 0; i< f.length;i++){
if(f[i].getName().contains(".BFL")||f[i].getName().contains(".bbl")){
files[index]=f[i];
index++;
}
else if(f[i].getName().contains(".TXT")){
String []s = loadStrings(f[i]);
if(s.length>0){
if(s[0].equals("H Product:Blackbox flight data recorder by Nicholas Sherlock")){
files[index]=f[i];
index++;
}
}
}
}
}
Renderer[] getRenderers(){
return renderers;
}
void stopRender(){
if(rendering){
for(int i = 0; i< renderers.length;i++){
renderers[i].stopRender();
}
rendering=false;
}
}
}