Browse Source

cleaning more code

msDestiny14 4 years ago
parent
commit
336b6387e5

+ 5 - 10
guiEditor/public/index.js

@@ -27,19 +27,14 @@ var checkHash = function () {
                 xmlHttp.onreadystatechange = function () {
                     if (xmlHttp.readyState == 4) {
                         if (xmlHttp.status == 200) {
-                            var snippet = JSON.parse(JSON.parse(xmlHttp.responseText).jsonPayload);
-                            let serializationObject = JSON.parse(snippet);
-
-                            if (editorDisplayed) {
-                                customLoadObservable.notifyObservers(serializationObject);
-                            } else {
-                                //load from selization
-                                showEditor();
-                            }
+                            
+                            //TODO: Implement
+                            //var snippet = JSON.parse(JSON.parse(xmlHttp.responseText).jsonPayload);
+                            showEditor();
                         }
                     }
                 }
-                
+
                 var hash = location.hash.substr(1);
                 currentSnippetToken = hash.split("#")[0];
                 xmlHttp.open("GET", snippetUrl + "/" + hash.replace("#", "/"));

+ 3 - 4
guiEditor/src/components/log/logComponent.tsx

@@ -25,10 +25,9 @@ export class LogComponent extends React.Component<ILogComponentProps, { logs: Lo
 
     componentDidMount() {
         this.props.globalState.onLogRequiredObservable.add(log => {
-            let currentLogs = this.state.logs;
-            currentLogs.push(log);
-
-            this.setState({ logs: currentLogs });
+            let newLogArray = this.state.logs.map(number => number);
+            newLogArray.push(log);
+            this.setState({ logs: newLogArray });
         });
     }
 

+ 4 - 9
guiEditor/src/diagram/workbench.tsx

@@ -176,15 +176,10 @@ export class WorkbenchComponent extends React.Component<IWorkbenchComponentProps
         }, false);     
 
         // Store additional data to serialization object
-        this.props.globalState.storeEditorData = (editorData, graphFrame) => {
-            editorData.frames = [];
-            if (graphFrame) {
-                
-            } else {
-                editorData.x = this.x;
-                editorData.y = this.y;
-                editorData.zoom = this.zoom;
-            }
+        this.props.globalState.storeEditorData = (editorData) => {
+            editorData.x = this.x;
+            editorData.y = this.y;
+            editorData.zoom = this.zoom;
         }
         this.props.globalState.workbench = this;
     }

+ 4 - 13
guiEditor/src/globalState.ts

@@ -1,23 +1,22 @@
 import { Nullable } from "babylonjs/types";
 import { Observable } from "babylonjs/Misc/observable";
+import { LogEntry } from "./components/log/logComponent";
 import { DataStorage } from "babylonjs/Misc/dataStorage";
 import { Color4 } from "babylonjs/Maths/math.color";
 import { GUINode } from "./diagram/guiNode";
-import { FramePortData, WorkbenchComponent } from "./diagram/workbench";
+import { WorkbenchComponent } from "./diagram/workbench";
 import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
-import { LogEntry } from "./components/log/logComponent";
 
 export class GlobalState {
     guiTexture: AdvancedDynamicTexture;
     hostElement: HTMLElement;
     hostDocument: HTMLDocument;
     hostWindow: Window;
-    onSelectionChangedObservable = new Observable<Nullable<GUINode | FramePortData>>();
+    onSelectionChangedObservable = new Observable<Nullable<GUINode>>();
     onRebuildRequiredObservable = new Observable<void>();
     onBuiltObservable = new Observable<void>();
     onResetRequiredObservable = new Observable<void>();
     onUpdateRequiredObservable = new Observable<void>();
-    onZoomToFitRequiredObservable = new Observable<void>();
     onReOrganizedRequiredObservable = new Observable<void>();
     onLogRequiredObservable = new Observable<LogEntry>();
     onErrorMessageDialogRequiredObservable = new Observable<string>();
@@ -25,19 +24,11 @@ export class GlobalState {
     onSelectionBoxMoved = new Observable<ClientRect | DOMRect>();
     onGuiNodeRemovalObservable = new Observable<GUINode>();
     onGridSizeChanged = new Observable<void>();
-    listOfCustomPreviewFiles: File[] = [];
-    rotatePreview: boolean;
     backgroundColor: Color4;
-    backFaceCulling: boolean;
-    depthPrePass: boolean;
     blockKeyboardEvents = false;
-    hemisphericLight: boolean;
-    directionalLight0: boolean;
-    directionalLight1: boolean;
     controlCamera: boolean;
     workbench: WorkbenchComponent;
-    storeEditorData: (serializationObject: any, frame?: Nullable<null>) => void;
-
+    storeEditorData: (serializationObject: any) => void;
 
     customSave?: { label: string; action: (data: string) => Promise<void> };
 

+ 7 - 4
guiEditor/src/sharedComponents/floatLineComponent.tsx

@@ -24,15 +24,18 @@ export class FloatLineComponent extends React.Component<IFloatLineComponentProps
     private _localChange = false;
     private _store: number;
     private _regExp: RegExp;
-
+    private _digits: number;
     constructor(props: IFloatLineComponentProps) {
         super(props);
         let currentValue = this.props.target[this.props.propertyName];
-        this.state = { value: currentValue ? (this.props.isInteger ? currentValue.toFixed(0) : currentValue.toFixed(this.props.digits || 2)) : "0" };
+        
+        this._digits == this.props.digits == undefined ? 2 : this.props.digits;
+    
+        this.state = { value: currentValue ? (this.props.isInteger ? currentValue.toFixed(0) : currentValue.toFixed(this._digits)) : "0" };
         this._store = currentValue;
 
         let rexp = "(.*\\.";
-        let numDigits = this.props.digits || 2;
+        let numDigits = this._digits;
         while (numDigits--) {
             rexp += ".";
         }
@@ -48,7 +51,7 @@ export class FloatLineComponent extends React.Component<IFloatLineComponentProps
         }
 
         const newValue = nextProps.target[nextProps.propertyName];
-        const newValueString = newValue ? this.props.isInteger ? newValue.toFixed(0) : newValue.toFixed(this.props.digits || 2) : "0";
+        const newValueString = newValue ? this.props.isInteger ? newValue.toFixed(0) : newValue.toFixed(this._digits) : "0";
 
         if (newValueString !== nextState.value) {
             nextState.value = newValueString;