Skip to content
Permalink
Browse files

feat(script): ScriptAPI and ScriptAttributeAPI add more api

update wonder-commonlib version;
update wonder-imgui version;
  • Loading branch information...
yyc-git committed Mar 28, 2019
1 parent ee07749 commit 745cbd615086fb96f0b416c28dd45484b3244b73
@@ -58,16 +58,19 @@
var state =
api.setScriptAttributeFieldValue(
script,
"scriptAttribute1",
"a",
[
a + 1,
"scriptAttribute1",
"a",
a + 1
],
state
);
// var gameObject =
// api.unsafeGetScriptGameObject(
// script, state
@@ -186,7 +189,7 @@
var state =
wd.addScriptEventFunction(
wd.addScriptEventFunctionData(
scriptComponent,
"scriptEventFunctionData1",
scriptEventFunctionData1,
@@ -59,11 +59,14 @@
var state =
api.setScriptAttributeFieldValue(
script,
[
"scriptAttribute1",
"a",
a + 1,
],
state
@@ -187,7 +190,7 @@
var state =
wd.addScriptEventFunction(
wd.addScriptEventFunctionData(
scriptComponent,
"scriptEventFunctionData1",
scriptEventFunctionData1,
@@ -71,17 +71,17 @@
"bs-fetch": "^0.3.0",
"wonder-bs-json": "^0.0.1",
"wonder-bs-most": "^0.0.3",
"wonder-commonlib": "^0.2.28",
"wonder-imgui": "^0.0.33",
"wonder-commonlib": "^0.2.31",
"wonder-imgui": "^0.0.34",
"wonder-log": "^0.2.11",
"wonder-most-animation-frame": "0.0.3",
"wonder-webgl": "^0.0.7"
},
"resolutions": {
"wonder-log": "^0.2.11",
"wonder-webgl": "^0.0.7",
"wonder-commonlib": "0.2.28",
"wonder-commonlib": "0.2.31",
"wonder-bs-jest": "0.2.25",
"wonder-bs-puppeteer": "^0.1.6"
}
}
}
@@ -678,20 +678,40 @@ let getAmbientLightColor = SceneAPI.getAmbientLightColor;

let setScreenSize = ScreenAPI.setScreenSize;

let setScriptAttributeFieldDefaultValueAndValue = ScriptAPI.setScriptAttributeFieldDefaultValueAndValue;

let unsafeGetScriptAttribute = ScriptAPI.unsafeGetScriptAttribute;

let unsafeGetScriptAttributeEntries = ScriptAPI.unsafeGetScriptAttributeEntries;

let replaceScriptAttribute = ScriptAPI.replaceScriptAttribute;

let removeScriptAttribute = ScriptAPI.removeScriptAttribute;

let addScriptAttribute = ScriptAPI.addScriptAttribute;

let addScriptEventFunction = ScriptAPI.addScriptEventFunction;
let unsafeGetScriptEventFunctionDataEntries = ScriptAPI.unsafeGetScriptEventFunctionDataEntries;

let replaceScriptEventFunctionData = ScriptAPI.replaceScriptEventFunctionData;

let removeScriptEventFunctionData = ScriptAPI.removeScriptEventFunctionData;

let addScriptEventFunctionData = ScriptAPI.addScriptEventFunctionData;

let unsafeGetScriptGameObject = ScriptAPI.unsafeGetScriptGameObject;

let createScript = ScriptAPI.createScript;

let getScriptAttributeEntries = ScriptAttributeAPI.getScriptAttributeEntries;

let removeScriptAttributeField = ScriptAttributeAPI.removeScriptAttributeField;

let addScriptAttributeField = ScriptAttributeAPI.addScriptAttributeField;

let createScriptAttribute = ScriptAttributeAPI.createScriptAttribute;

let setScriptInitEventFunction = ScriptEventFunctionAPI.setScriptInitEventFunction;

let createScriptEventFunctionData = ScriptEventFunctionAPI.createScriptEventFunctionData;

let clearInitShaderCache = ShaderAPI.clearInitShaderCache;
@@ -1,13 +1,11 @@
/* TODO add removeXXX apis */

open StateDataMainType;

let createScript = state => CreateScriptMainService.create(state);

let unsafeGetScriptGameObject = (script, state) =>
GameObjectScriptMainService.unsafeGetGameObject(script, state.scriptRecord);

let addScriptEventFunction =
let addScriptEventFunctionData =
(script, scriptEventFunctionDataName, scriptEventFunctionData, state) =>
OperateScriptDataMainService.addScriptEventFunctionData(
script,
@@ -16,6 +14,29 @@ let addScriptEventFunction =
state,
);

let removeScriptEventFunctionData =
(script, scriptEventFunctionDataName, state) =>
OperateScriptDataMainService.removeScriptEventFunctionData(
script,
scriptEventFunctionDataName,
state,
);

let replaceScriptEventFunctionData =
(script, scriptEventFunctionDataName, scriptEventFunctionData, state) =>
OperateScriptDataMainService.replaceScriptEventFunctionData(
script,
scriptEventFunctionDataName,
scriptEventFunctionData,
state,
);

let unsafeGetScriptEventFunctionDataEntries = (script, state) =>
OperateScriptDataMainService.unsafeGetScriptEventFunctionDataEntries(
script,
state,
);

let addScriptAttribute = (script, scriptAttributeName, scriptAttribute, state) =>
OperateScriptDataMainService.addScriptAttribute(
script,
@@ -24,17 +45,36 @@ let addScriptAttribute = (script, scriptAttributeName, scriptAttribute, state) =
state,
);

let unsafeGetScriptAttribute = (script, attributeName, state) =>
OperateScriptDataMainService.unsafeGetScriptAttribute(
let removeScriptAttribute = (script, scriptAttributeName, state) =>
OperateScriptDataMainService.removeScriptAttribute(
script,
attributeName,
scriptAttributeName,
state,
);

/* let findScriptAttribute = (gameObjectName, state) => {
let replaceScriptAttribute =
(script, scriptAttributeName, scriptAttribute, state) =>
OperateScriptDataMainService.replaceScriptAttribute(
script,
scriptAttributeName,
scriptAttribute,
state,
);

}; */
let unsafeGetScriptAttributeEntries = (script, state) =>
OperateScriptDataMainService.unsafeGetScriptAttributeEntries(script, state);

/* let setScriptAttributeDefaultValue = (script, scriptAttributeJsObj, attributeName, defaultValue, state) => {
let unsafeGetScriptAttribute = (script, attributeName, state) =>
OperateScriptDataMainService.unsafeGetScriptAttribute(
script,
attributeName,
state,
);

}; */
let setScriptAttributeFieldDefaultValueAndValue =
(script, scriptAttributeName, fieldName, value, state) =>
OperateScriptDataMainService.setScriptAttributeFieldDefaultValueAndValue(
script,
(scriptAttributeName, fieldName, value),
state,
);
@@ -1,5 +1,3 @@
/* TODO add removeXXX apis */

let createScriptAttribute = () =>
OperateScriptAttributeDataMainService.createScriptAttribute();

@@ -10,39 +8,11 @@ let addScriptAttributeField = (fieldName, attributeFieldJsObj, attribute) =>
attribute,
);

/* let createScriptAttribute = () => {
}; */

/* let getScriptAttributeFieldValue = ( fieldName, scriptAttribute) => {
}; */

/* let setScriptAttributeFieldValue = (
script,
/* scriptAttribute, */
attributeName,
fieldName, value, state) => {
}; */

/* let getScriptAttributeFieldDefaultValue = (
script,
attributeName,
fieldName, state) => {
};
let setScriptAttributeFieldDefaultValue = (
script,
/* scriptAttribute, */
attributeName,
fieldName, defaultValue, state) => {
let removeScriptAttributeField = (fieldName, attribute) =>
OperateScriptAttributeDataMainService.removeScriptAttributeField(
fieldName,
attribute,
);

}; */
let getScriptAttributeEntries = attribute =>
OperateScriptAttributeDataMainService.getScriptAttributeEntries(attribute);
@@ -11,4 +11,12 @@ let createScriptEventFunctionData =
init: _createScriptEventFunction(jsObj##init),
update: _createScriptEventFunction(jsObj##update),
dispose: _createScriptEventFunction(jsObj##dispose),
};


let setScriptInitEventFunction =
(jsObj: eventFunctionDataJsObj, state) => {
/* init: _createScriptEventFunction(jsObj##init),
update: _createScriptEventFunction(jsObj##update),
dispose: _createScriptEventFunction(jsObj##dispose), */
};
@@ -4,7 +4,9 @@ type glslChunk = {
mutable varDeclare: string,
mutable funcDeclare: string,
mutable funcDefine: string,
mutable body: string
mutable body: string,
};

type glslChunkRecord = {chunkMap: Js.Dict.t(glslChunk)};
type glslChunkRecord = {
chunkMap: WonderCommonlib.MutableHashMapService.t(glslChunk),
};

This file was deleted.

@@ -1,10 +1,15 @@
type attributeLocationMap = WonderCommonlib.MutableSparseMapService.t(Js.Dict.t(int));
type attributeLocationMap =
WonderCommonlib.MutableSparseMapService.t(
WonderCommonlib.MutableHashMapService.t(int),
);

type uniformLocationMapOfShader = Js.Dict.t(WonderWebgl.GlType.uniformLocation);
type uniformLocationMapOfShader =
WonderCommonlib.MutableHashMapService.t(WonderWebgl.GlType.uniformLocation);

type uniformLocationMap = WonderCommonlib.MutableSparseMapService.t(uniformLocationMapOfShader);
type uniformLocationMap =
WonderCommonlib.MutableSparseMapService.t(uniformLocationMapOfShader);

type glslLocationRecord = {
attributeLocationMap,
uniformLocationMap
uniformLocationMap,
};
@@ -197,7 +197,11 @@ and scriptAPIJsObj = {
ScriptAttributeType.scriptAttributeValue,
"unsafeGetScriptGameObject": (int, state) => int,
"setScriptAttributeFieldValue":
(int, string, string, ScriptAttributeType.scriptAttributeValue, state) =>
(
int,
(string, string, ScriptAttributeType.scriptAttributeValue),
state
) =>
state,
"getTransformLocalPosition":
(transform, state) =>
@@ -351,6 +355,8 @@ and eventFunctionData = {
update: eventFunction,
dispose: eventFunction,
}
/* and scriptEventFunction =
WonderCommonlib.ImmutableHashMapService.t(eventFunction) */
and scriptRecord = {
index: int,
disposedIndexArray: array(ScriptType.script),
@@ -207,7 +207,8 @@ let create = () => {
touchDomEventDataArrMap:
WonderCommonlib.MutableSparseMapService.createEmpty(),
customGlobalEventArrMap: WonderCommonlib.MutableHashMapService.createEmpty(),
customGameObjectEventArrMap: WonderCommonlib.MutableHashMapService.createEmpty(),
customGameObjectEventArrMap:
WonderCommonlib.MutableHashMapService.createEmpty(),
mouseEventData: {
lastX: None,
lastY: None,
@@ -234,13 +235,13 @@ let _deepCopyDomEventArrMap = domEventArrMap =>

let _deepCopyCustomGlobalEventArrMap = customGlobalEventArrMap =>
customGlobalEventArrMap
|> Js.Dict.map((. arr) =>
|> WonderCommonlib.MutableHashMapService.map((. arr) =>
arr |> WonderCommonlib.MutableSparseMapService.copy
);

let _deepCopyCustomGameObjectEventArrMap = customGameObjectEventArrMap =>
customGameObjectEventArrMap
|> Js.Dict.map((. eventArrMap) =>
|> WonderCommonlib.MutableHashMapService.map((. eventArrMap) =>
eventArrMap
|> WonderCommonlib.MutableSparseMapService.copy
|> WonderCommonlib.MutableSparseMapService.mapValid((. arr) =>

0 comments on commit 745cbd6

Please sign in to comment.
You can’t perform that action at this time.