Skip to content

Commit c08be78

Browse files
committed
Moved utils to typescript and implemeted more of the Display (Kagerou) API
1 parent f7d87d1 commit c08be78

26 files changed

Lines changed: 1626 additions & 516 deletions

src/scripting/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ clean:
44
rm -rf build
55
mkdir build
66

7+
definitions:
8+
tsc -d --target ES5 src/api/Runtime/Runtime.ts --out src/api/Runtime.d.ts
9+
tsc -d --target ES5 src/api/Player/Player.ts --out src/api/Player.d.ts
10+
711
compile:
812
tsc --target ES5 src/api/Display/Display.ts --out build/api/Display.js
913
tsc --target ES5 src/api/Runtime/Runtime.ts --out build/api/Runtime.js
1014
tsc --target ES5 src/api/Player/Player.ts --out build/api/Player.js
15+
tsc --target ES5 src/api/Utils/Utils.ts --out build/api/Utils.js
1116
cp src/*.js build/
1217
cp src/api/*.js build/api/
1318
cp src/api/Tween/Tween.js build/api/

src/scripting/build/Host.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,19 @@ var CCLScripting = function(workerUrl){
4646
this.deregisterObject = function(objectId){
4747
delete objects[objectId];
4848
};
49-
49+
this.updateProperty = function(objectId, propName, value){
50+
if(!objects[objectId]){
51+
scripter.logger.error("Object not found.");
52+
return;
53+
}
54+
if(!objects[objectId][propName]){
55+
scripter.logger.error("Property \"" + propName
56+
+ "\" not defined for object of type " +
57+
objects[objectId].getClass() +".");
58+
return;
59+
}
60+
objects[objectId][propName] = value;
61+
};
5062
this.callMethod = function(objectId, methodName, params){
5163
if(!objects[objectId]){
5264
scripter.logger.error("Object not found.");
@@ -260,6 +272,9 @@ var CCLScripting = function(workerUrl){
260272
this.addListener("Runtime:CallMethod", function(pl){
261273
self.getContext().callMethod(pl.id, pl.method, pl.params);
262274
});
275+
this.addListener("Runtime:UpdateProperty", function(pl){
276+
self.getContext().updateProperty(pl.id, pl.name, pl.value);
277+
});
263278
};
264279
/** This is the DOM Manipulation Library **/
265280
var _ = function (type, props, children, callback) {
@@ -295,7 +310,7 @@ var CCLScripting = function(workerUrl){
295310
};
296311
/** Define some unpackers **/
297312
var ScriptingContext = CCLScripting.prototype.ScriptingContext;
298-
ScriptingContext.prototype.Unpack.Comment = function(stage, data, ctx){
313+
ScriptingContext.prototype.Unpack.TextField = function(stage, data, ctx){
299314
this.DOM = _("div",{
300315
"style":{
301316
"position":"absolute",
@@ -579,7 +594,13 @@ var CCLScripting = function(workerUrl){
579594
applyStroke(e, this);
580595
defaultGroup.appendChild(e);
581596
};
582-
597+
this.__defineGetter__("filters", function(f){
598+
return [];
599+
});
600+
this.__defineSetter__("filters", function(f){
601+
console.log(f);
602+
this.setFilters([f]);
603+
});
583604
this.setFilters = function(params){
584605
var filters = params[0];
585606
//Remove old filters

0 commit comments

Comments
 (0)