Skip to content
Permalink
Browse files

fix(inspectorEngine): need fix bug

  • Loading branch information...
AmyOrz committed Mar 26, 2019
1 parent 7cf4536 commit 192843c39172cd9983ac1ed2f524f10b3015209f
@@ -52,7 +52,7 @@ let render = ((uiState, dispatchFunc), addableComponentConfig, _self) => {
),
)
}
<canvas id="asset-canvas" key="assetCanvas" />
<canvas id="inspector-canvas" key="inspectorCanvas" />
</article>;
};

@@ -75,31 +75,31 @@ let make =
shouldUpdate,
render: self =>
render((uiState, dispatchFunc), addableComponentConfig, self),
didUpdate: self => {
let assetCanvas = DomHelper.getElementById("asset-canvas");
let editorState = StateEditorService.getState();
/* didUpdate: self => {
let inspectorCanvas = DomHelper.getElementById("inspector-canvas");
let editorState = StateEditorService.getState();
Js.log("did update");
Js.log("did update");
switch (
CurrentSelectSourceEditorService.getCurrentSelectSource(editorState)
) {
| None
| Some(SceneTree) => DomHelper.hideCanvas(assetCanvas)
| Some(Asset) =>
switch (OperateTreeAssetEditorService.getCurrentNode(editorState)) {
| None => DomHelper.hideCanvas(assetCanvas)
| Some(currentNode) =>
switch (currentNode) {
| TextureNode(nodeId, textureNodeData) =>
DomHelper.hideCanvas(assetCanvas)
| FolderNode(nodeId, folderNodeData, children) =>
DomHelper.hideCanvas(assetCanvas)
| MaterialNode(nodeId, materialNodeData) =>
DomHelper.showCanvas(assetCanvas)
| WDBNode(nodeId, wdbNodeData) => DomHelper.showCanvas(assetCanvas)
}
}
};
},
switch (
CurrentSelectSourceEditorService.getCurrentSelectSource(editorState)
) {
| None
| Some(SceneTree) => DomHelper.hideCanvas(inspectorCanvas)
| Some(Asset) =>
switch (OperateTreeAssetEditorService.getCurrentNode(editorState)) {
| None => DomHelper.hideCanvas(inspectorCanvas)
| Some(currentNode) =>
switch (currentNode) {
| TextureNode(nodeId, textureNodeData) =>
DomHelper.hideCanvas(inspectorCanvas)
| FolderNode(nodeId, folderNodeData, children) =>
DomHelper.hideCanvas(inspectorCanvas)
| MaterialNode(nodeId, materialNodeData) =>
DomHelper.showCanvas(inspectorCanvas)
| WDBNode(nodeId, wdbNodeData) => DomHelper.showCanvas(inspectorCanvas)
}
}
};
}, */
};
@@ -38,7 +38,13 @@ let _buildElementBeforeInitEngine = (uiState, dispatchFunc) =>
</div>
<div className="bottom-widget" />
</div>
<div key="rightComponent" className="right-component" />
<div key="rightComponent" className="right-component">
<div className="inline-component inspector-parent">
<article key="inspector" className="wonder-inspector-component">
<canvas id="inspector-canvas" key="inspectorCanvas" />
</article>
</div>
</div>
</article>;

let _buildElementAfterInitEngine = (uiState, dispatchFunc) =>
@@ -1,11 +1,20 @@
open Js.Promise;

let _getLoadData = () => {
let _getLoadEngineData = () => {
let engineConfigDir = "./config/engine/";

AssetEngineService.loadConfig(
[|"./config/engine/setting.json", engineConfigDir|],
StateDataEngineService.getEngineStateData(),
StateDataEngineService.getStateData(),
);
};

let _getLoadInspectorEngineData = () => {
let engineConfigDir = "./config/inspectorEngine/";

AssetEngineService.loadConfig(
[|"./config/inspectorEngine/setting.json", engineConfigDir|],
StateDataInspectorEngineService.getStateData(),
);
};

@@ -86,9 +95,21 @@ let _handleEngineState = engineState => {
|> StateEngineService.setState;
};

let _handleInspectorEngineState = inspectorEngineState => {
let inspectorEngineState = _registerJob(inspectorEngineState);

inspectorEngineState
|> DirectorEngineService.init
|> StateInspectorEngineService.setState;

Js.log(StateDataInspectorEngineService.getStateData());

StateInspectorEngineService.unsafeGetState() |> Js.log;
};

let initEngine = () =>
Wonderjs.StateDataMainType.(
_getLoadData()
_getLoadEngineData()
|> WonderBsMost.Most.flatMap(engineState =>
LoaderManagerEngineService.loadIMGUIAsset(
"./public/font/empty.fnt",
@@ -123,6 +144,26 @@ let initEngine = () =>
)
|> WonderBsMost.Most.fromPromise
)
|> WonderBsMost.Most.map(engineState => engineState |> _handleEngineState)
|> WonderBsMost.Most.tap(engineState => {
engineState |> _handleEngineState |> ignore;

();
})
|> WonderBsMost.Most.merge(
_getLoadInspectorEngineData()
|> WonderBsMost.Most.tap(inspectorEngineState => {
Js.log("inspctor data ");
Js.log((
inspectorEngineState,
StateDataInspectorEngineService.getStateData(),
));

inspectorEngineState |> _handleInspectorEngineState |> ignore;

();
}),
)
/* |> WonderBsMost.Most.flatMap(engineState =>
) */
|> WonderBsMost.Most.drain
);
@@ -102,7 +102,7 @@ let isViewSizeChange =
(_, _, gameViewWidth, gameViewHeight),
(canvasWidth, canvasHeight),
) =>
! isSizeEqual(getViewWidth(sceneViewWidth, gameViewWidth), canvasWidth)
!isSizeEqual(getViewWidth(sceneViewWidth, gameViewWidth), canvasWidth)
|| !
isSizeEqual(
getViewHeight(sceneViewHeight, gameViewHeight),
@@ -111,19 +111,23 @@ let isViewSizeChange =

let resizeScreen = () => {
let canvasParentSize = getCanvasParentSize();
let engineState = StateEngineService.unsafeGetState();
let inspectorEngineState = StateInspectorEngineService.unsafeGetState();

resizeCanvas(canvasParentSize);

DeviceManagerEngineService.getGl(StateEngineService.unsafeGetState())
|> Js.Option.isSome ?
engineState |> DeviceManagerEngineService.getGl |> Js.Option.isSome ?
{
updateViewRect(canvasParentSize)
|> StateLogicService.getAndSetEditorState;

StateEngineService.unsafeGetState()
engineState
|> resizeViewport(canvasParentSize)
|> StateLogicService.refreshEngineState
|> ignore;
} :
();

inspectorEngineState |> DeviceManagerEngineService.getGl |> Js.Option.isSome ?
inspectorEngineState |> StateLogicService.refreshEngineState |> ignore : ();
};
@@ -0,0 +1,5 @@
open Wonderjs;

open StateDataMainType;

let createStateData = () => {state: None, isDebug: false};
@@ -1,3 +1,3 @@
open Wonderjs;

let getEngineStateData = () => StateDataMain.stateData;
let getStateData = () => StateDataMain.stateData;
@@ -0,0 +1,10 @@
open Wonderjs;

let getStateData = () =>
CreateInspectorEngineStateDataService.createStateData();

let unsafeGetState = () =>
StateDataMainService.unsafeGetState(getStateData());

let setState = (state: StateDataMainType.state) =>
StateDataMainService.setState(getStateData(), state);
@@ -0,0 +1,13 @@
let deepCopyForRestore = Wonderjs.StateAPI.deepCopyForRestore;

let createState = Wonderjs.StateAPI.createState;

let createStateData = CreateInspectorEngineStateDataService.createStateData;

let getStateFromData = Wonderjs.StateAPI.getStateFromData;

let unsafeGetState = StateDataInspectorEngineService.unsafeGetState;

let setStateToData = Wonderjs.StateAPI.setStateToData;

let setState = StateDataInspectorEngineService.setState;

0 comments on commit 192843c

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