|
@@ -1,54 +1,20 @@
|
|
|
-var __extends = (this && this.__extends) || (function () {
|
|
|
- var extendStatics = function (d, b) {
|
|
|
- extendStatics = Object.setPrototypeOf ||
|
|
|
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
|
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
|
- return extendStatics(d, b);
|
|
|
- };
|
|
|
- return function (d, b) {
|
|
|
- extendStatics(d, b);
|
|
|
- function __() { this.constructor = d; }
|
|
|
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
|
- };
|
|
|
-})();
|
|
|
-import { SGraphView } from '@saga-web/graph/lib';
|
|
|
-import { SMouseButton, SMouseEvent, SNetUtil } from '@saga-web/base/lib';
|
|
|
-import { SPoint } from '@saga-web/draw/lib';
|
|
|
-/**
|
|
|
- * 楼层场景
|
|
|
- *
|
|
|
- * @author 郝建龙
|
|
|
- */
|
|
|
-var FloorView = /** @class */ (function (_super) {
|
|
|
- __extends(FloorView, _super);
|
|
|
- function FloorView() {
|
|
|
- var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
|
- /** 鼠标左键键按下时位置 */
|
|
|
- _this._leftKeyPos = new SPoint();
|
|
|
- /** 空格是否被按下 */
|
|
|
- _this.spaceKey = false;
|
|
|
- return _this;
|
|
|
+import { SGraphView } from "@saga-web/graph/lib";
|
|
|
+import { SMouseButton, SMouseEvent, SNetUtil } from "@saga-web/base/lib";
|
|
|
+import { SPoint } from "@saga-web/draw/lib";
|
|
|
+export class FloorView extends SGraphView {
|
|
|
+ constructor() {
|
|
|
+ super(...arguments);
|
|
|
+ this._leftKeyPos = new SPoint();
|
|
|
+ this.spaceKey = false;
|
|
|
}
|
|
|
- /**
|
|
|
- * 保存底图json
|
|
|
- *
|
|
|
- * @param name 文件名
|
|
|
- */
|
|
|
- FloorView.prototype.saveFloorJson = function (name) {
|
|
|
- // @ts-ignore
|
|
|
+ saveFloorJson(name) {
|
|
|
if (!this.scene || !this.scene.json)
|
|
|
return;
|
|
|
- // @ts-ignore
|
|
|
- var url = URL.createObjectURL(new Blob([this.scene.json]));
|
|
|
+ let url = URL.createObjectURL(new Blob([this.scene.json]));
|
|
|
SNetUtil.downLoad(name, url);
|
|
|
- }; // Function saveSceneSvg()
|
|
|
- /**
|
|
|
- * 按键按下事件
|
|
|
- *
|
|
|
- * @param event 事件参数
|
|
|
- */
|
|
|
- FloorView.prototype.onKeyDown = function (event) {
|
|
|
- var keyCode = event.keyCode;
|
|
|
+ }
|
|
|
+ onKeyDown(event) {
|
|
|
+ let keyCode = event.keyCode;
|
|
|
this.spaceKey = false;
|
|
|
switch (keyCode) {
|
|
|
case 32:
|
|
@@ -67,52 +33,33 @@ var FloorView = /** @class */ (function (_super) {
|
|
|
this.origin.x -= 10;
|
|
|
break;
|
|
|
default:
|
|
|
- _super.prototype.onKeyDown.call(this, event);
|
|
|
+ super.onKeyDown(event);
|
|
|
break;
|
|
|
}
|
|
|
- this.update();
|
|
|
- }; // Function onKeyDown()
|
|
|
- /**
|
|
|
- * 按键松开事件
|
|
|
- *
|
|
|
- * @param event 事件参数
|
|
|
- */
|
|
|
- FloorView.prototype.onKeyUp = function (event) {
|
|
|
+ }
|
|
|
+ onKeyUp(event) {
|
|
|
this.spaceKey = false;
|
|
|
- _super.prototype.onKeyUp.call(this, event);
|
|
|
- }; // Function onKeyUp()
|
|
|
- /**
|
|
|
- * 鼠标按下事件
|
|
|
- *
|
|
|
- * @param event 事件参数
|
|
|
- */
|
|
|
- FloorView.prototype.onMouseDown = function (event) {
|
|
|
- var se = new SMouseEvent(event);
|
|
|
+ super.onKeyUp(event);
|
|
|
+ }
|
|
|
+ onMouseDown(event) {
|
|
|
+ let se = new SMouseEvent(event);
|
|
|
if (se.buttons & SMouseButton.LeftButton) {
|
|
|
this._leftKeyPos.x = se.x;
|
|
|
this._leftKeyPos.y = se.y;
|
|
|
}
|
|
|
- _super.prototype.onMouseDown.call(this, event);
|
|
|
- }; // Function onMouseDown()
|
|
|
- /**
|
|
|
- * 鼠标移动事件
|
|
|
- *
|
|
|
- * @param event 事件参数
|
|
|
- */
|
|
|
- FloorView.prototype.onMouseMove = function (event) {
|
|
|
- // 按左键移动
|
|
|
- var se = new SMouseEvent(event);
|
|
|
+ super.onMouseDown(event);
|
|
|
+ }
|
|
|
+ onMouseMove(event) {
|
|
|
+ let se = new SMouseEvent(event);
|
|
|
if (se.buttons & SMouseButton.LeftButton) {
|
|
|
- // if (this.spaceKey) {
|
|
|
- this.origin.x += se.x - this._leftKeyPos.x;
|
|
|
- this.origin.y += se.y - this._leftKeyPos.y;
|
|
|
- // }
|
|
|
+ if (this.spaceKey) {
|
|
|
+ this.origin.x += se.x - this._leftKeyPos.x;
|
|
|
+ this.origin.y += se.y - this._leftKeyPos.y;
|
|
|
+ }
|
|
|
this._leftKeyPos.x = se.x;
|
|
|
this._leftKeyPos.y = se.y;
|
|
|
this.update();
|
|
|
}
|
|
|
- _super.prototype.onMouseMove.call(this, event);
|
|
|
- }; // Function onMouseMove()
|
|
|
- return FloorView;
|
|
|
-}(SGraphView)); // Class FloorScene
|
|
|
-export { FloorView };
|
|
|
+ super.onMouseMove(event);
|
|
|
+ }
|
|
|
+}
|