-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHadronStateLoad.sc
More file actions
119 lines (83 loc) · 2.53 KB
/
HadronStateLoad.sc
File metadata and controls
119 lines (83 loc) · 2.53 KB
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
HadronStateLoad
{
var parentApp, loadStage;
*new
{|argParentApp|
^super.new.init(argParentApp);
}
init
{|argParentApp|
parentApp = argParentApp;
loadStage = 0;
}
showLoad
{
File.openDialog("", {|aFile| parentApp.alivePlugs.size.do({ parentApp.alivePlugs[0].selfDestruct; }); this.loadState(aFile); });
}
loadState
{|argFile|
var contents;
var tempFile = File(argFile, "r");
contents = tempFile.readAllString().split($\n);
tempFile.close;
{//begin fork
contents.do
({|item|
if(item == "?EndPlugs", { loadStage = 3; Hadron.loadDelay.wait; });
if(item == "?EndConnections", { loadStage = 5; });
if(item == "?EndPlugParams", { loadStage = 7; });
if(item == "?EndSave", { loadStage = 8; });
if(loadStage == 2,
{
//item.postln;
item = item.split(31.asAscii);
parentApp.prAddPlugin(item[0].interpret, item[1], item[2].asInteger, item[3].interpret, item[4].interpret);
parentApp.idPlugDict.at(item[2].asInteger)
.outerWindow.bounds = item[5].interpret;
parentApp.idPlugDict.at(item[2].asInteger)
.oldWinBounds = item[6].interpret;
parentApp.idPlugDict.at(item[2].asInteger).isHidden = item[7].interpret;
});
if(loadStage == 4,
{
item = item.split(31.asAscii);
parentApp.idPlugDict.at(item[0].interpret).inConnections =
item[1].interpret.collect
({|inItem|
if(inItem[0] != nil,
{ [parentApp.idPlugDict.at(inItem[0]), inItem[1]]},
{ inItem; });
});
parentApp.idPlugDict.at(item[0].interpret).outConnections =
item[2].interpret.collect
({|outItem|
if(outItem[0] != nil,
{ [parentApp.idPlugDict.at(outItem[0]), outItem[1]]},
{ outItem; });
});
});
if(loadStage == 5,
{
parentApp.alivePlugs.do({|plug| plug.wakeConnections; });
parentApp.alivePlugs.do({|plug| plug.updateBusConnections; });
});
if(loadStage == 6,
{
item = item.split(31.asAscii);
parentApp.idPlugDict.at(item[0].interpret).injectSaveValues(item[1..]);
});
if(loadStage == 7,
{
parentApp.alivePlugs.do(_.wakeFromLoad);
parentApp.canvasObj.drawCables;
parentApp.isDirty = false;
parentApp.displayStatus("State loaded!", 1);
});
if(item == "?Hadron 1", { loadStage = 1; });
if(item == "?StartPlugs", { loadStage = 2; });
if(item == "?StartConnections", { loadStage = 4; });
if(item == "?StartPlugParams", { loadStage = 6; });
});
}.fork(AppClock);
}
}