Merge branch 'LLK/master'
This commit is contained in:
commit
ba40cd3396
24 changed files with 764 additions and 698 deletions
js
45
js/IO.js
45
js/IO.js
|
@ -27,26 +27,24 @@ var IO = function() {
|
|||
// In production, simply use the local path (no proxy)
|
||||
// since we won't be hampered by the same-origin policy.
|
||||
this.base = 'proxy.php?resource=internalapi/';
|
||||
this.project_base = this.base + 'project/';
|
||||
this.project_base = this.base + 'project/';
|
||||
this.project_suffix = '/get/';
|
||||
this.asset_base = this.base + 'asset/';
|
||||
this.asset_suffix = '/get/';
|
||||
this.soundbank_base = 'soundbank/';
|
||||
this.spriteLayerCount = 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
IO.prototype.loadProject = function(project_id) {
|
||||
var runningIO = this;
|
||||
$.getJSON(this.project_base + project_id + this.project_suffix,
|
||||
function(data) {
|
||||
runningIO.data = data;
|
||||
runningIO.makeObjects();
|
||||
runningIO.loadThreads();
|
||||
runningIO.loadNotesDrums();
|
||||
runtime.loadStart(); // Try to run the project.
|
||||
}
|
||||
);
|
||||
}
|
||||
$.getJSON(this.project_base + project_id + this.project_suffix, function(data) {
|
||||
runningIO.data = data;
|
||||
runningIO.makeObjects();
|
||||
runningIO.loadThreads();
|
||||
runningIO.loadNotesDrums();
|
||||
runtime.loadStart(); // Try to run the project.
|
||||
});
|
||||
};
|
||||
|
||||
IO.prototype.soundRequest = function(sound, sprite) {
|
||||
var request = new XMLHttpRequest();
|
||||
|
@ -63,9 +61,9 @@ IO.prototype.soundRequest = function(sound, sprite) {
|
|||
data[i] = samples[i];
|
||||
}
|
||||
sprite.soundsLoaded++;
|
||||
}
|
||||
};
|
||||
request.send();
|
||||
}
|
||||
};
|
||||
|
||||
IO.prototype.loadNotesDrums = function() {
|
||||
var self = this;
|
||||
|
@ -81,18 +79,17 @@ IO.prototype.loadNotesDrums = function() {
|
|||
var soundBuffer = waveData.readBytes(2 * info.sampleCount);
|
||||
Instr.samples[name] = soundBuffer;
|
||||
Instr.wavsLoaded++;
|
||||
}
|
||||
};
|
||||
request.send();
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
IO.prototype.makeObjects = function() {
|
||||
// Create the stage
|
||||
runtime.stage = new Stage(this.data);
|
||||
runtime.stage.attach(runtime.scene);
|
||||
runtime.stage.attachPenLayer(runtime.scene);
|
||||
runtime.stage.loadSounds();
|
||||
|
||||
// Create the sprites and watchers
|
||||
$.each(this.data.children.concat(this.data.lists), function i(index, obj) {
|
||||
var newSprite;
|
||||
|
@ -111,8 +108,8 @@ IO.prototype.makeObjects = function() {
|
|||
if (!obj.cmd && !obj.listName)
|
||||
newSprite.loadSounds();
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
IO.prototype.loadThreads = function() {
|
||||
var target = runtime.stage;
|
||||
var scripts = target.data.scripts;
|
||||
|
@ -127,9 +124,9 @@ IO.prototype.loadThreads = function() {
|
|||
$.each(target.data.scripts, function(j, s) {
|
||||
target.stacks.push(interp.makeBlockList(s[2]));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Returns the number sprite we are rendering
|
||||
// used for initial layering assignment
|
||||
|
@ -137,4 +134,4 @@ IO.prototype.getCount = function() {
|
|||
var rv = this.spriteLayerCount;
|
||||
this.spriteLayerCount++;
|
||||
return rv;
|
||||
}
|
||||
};
|
||||
|
|
Reference in a new issue