|
@@ -1,36 +1,50 @@
|
|
|
import Text from "../Geometry/Text.js";
|
|
|
import { dataService } from "./DataService.js";
|
|
|
import { mathUtil } from "../Util/MathUtil.js";
|
|
|
-import Setting from "../Setting";
|
|
|
+import Settings from "../Settings";
|
|
|
import { coordinate } from "../Coordinate.js";
|
|
|
+import UIEvents from "../enum/UIEvents.js";
|
|
|
+import Constant from "../Constant.js";
|
|
|
|
|
|
export default class UIService {
|
|
|
constructor() {}
|
|
|
|
|
|
isBelongRoad(ui) {
|
|
|
- if (ui == "OneEdgeOneLanRoad") {
|
|
|
- this.setRoadLeftDrivewayCount(0);
|
|
|
- this.setRoadRightDrivewayCount(0);
|
|
|
+ if (ui == UIEvents.OneEdgeOneLanRoad) {
|
|
|
+ this.setWayType(Constant.oneWay);
|
|
|
+ this.setSingleRoadDrivewayCount(1);
|
|
|
+ this.setSingleRoadWidth(Settings.singleLaneWidth);
|
|
|
return true;
|
|
|
- } else if (ui == "OneEdgeTwoLanRoad") {
|
|
|
- this.setRoadLeftDrivewayCount(0);
|
|
|
- this.setRoadRightDrivewayCount(0);
|
|
|
+ } else if (ui == UIEvents.OneEdgeTwoLanRoad) {
|
|
|
+ this.setWayType(Constant.oneWay);
|
|
|
+ this.setSingleRoadDrivewayCount(2);
|
|
|
+ this.setSingleRoadWidth(Settings.singleLaneWidth * 2);
|
|
|
return true;
|
|
|
- } else if (ui == "OneEdgeThreeLanRoad") {
|
|
|
- this.setRoadLeftDrivewayCount(0);
|
|
|
- this.setRoadRightDrivewayCount(0);
|
|
|
+ } else if (ui == UIEvents.OneEdgeThreeLanRoad) {
|
|
|
+ this.setWayType(Constant.oneWay);
|
|
|
+ this.setSingleRoadDrivewayCount(3);
|
|
|
+ this.setSingleRoadWidth(Settings.singleLaneWidth * 3);
|
|
|
return true;
|
|
|
- } else if (ui == "TwoEdgeOneLanRoad") {
|
|
|
+ } else if (ui == UIEvents.TwoEdgeOneLanRoad) {
|
|
|
+ this.setWayType(Constant.twoWay);
|
|
|
this.setRoadLeftDrivewayCount(1);
|
|
|
this.setRoadRightDrivewayCount(1);
|
|
|
+ this.setLeftRoadWidth(Settings.singleLaneWidth);
|
|
|
+ this.setRightRoadWidth(Settings.singleLaneWidth);
|
|
|
return true;
|
|
|
- } else if (ui == "TwoEdgeTwoLanRoad") {
|
|
|
+ } else if (ui == UIEvents.TwoEdgeTwoLanRoad) {
|
|
|
+ this.setWayType(Constant.twoWay);
|
|
|
this.setRoadLeftDrivewayCount(2);
|
|
|
this.setRoadRightDrivewayCount(2);
|
|
|
+ this.setLeftRoadWidth(Settings.singleLaneWidth * 2);
|
|
|
+ this.setRightRoadWidth(Settings.singleLaneWidth * 2);
|
|
|
return true;
|
|
|
- } else if (ui == "TwoEdgeThreeLanRoad") {
|
|
|
+ } else if (ui == UIEvents.TwoEdgeThreeLanRoad) {
|
|
|
+ this.setWayType(Constant.twoWay);
|
|
|
this.setRoadLeftDrivewayCount(3);
|
|
|
this.setRoadRightDrivewayCount(3);
|
|
|
+ this.setLeftRoadWidth(Settings.singleLaneWidth * 3);
|
|
|
+ this.setRightRoadWidth(Settings.singleLaneWidth * 3);
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
@@ -41,27 +55,47 @@ export default class UIService {
|
|
|
this.setRoadLeftDrivewayCount(0);
|
|
|
this.setRoadRightDrivewayCount(0);
|
|
|
return true;
|
|
|
- } else if (ui == "OneEdgeOneLanRoad") {
|
|
|
+ } else if (ui == UIEvents.OneEdgeOneLanRoad) {
|
|
|
this.setRoadLeftDrivewayCount(0);
|
|
|
this.setRoadRightDrivewayCount(0);
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ setWayType(value) {
|
|
|
+ Settings.wayType = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ setSingleRoadDrivewayCount(value) {
|
|
|
+ Settings.singleRoadDrivewayCount = value;
|
|
|
+ }
|
|
|
+
|
|
|
setRoadLeftDrivewayCount(value) {
|
|
|
- Setting.roadLeftDrivewayCount = value;
|
|
|
+ Settings.roadLeftDrivewayCount = value;
|
|
|
}
|
|
|
|
|
|
setRoadRightDrivewayCount(value) {
|
|
|
- Setting.roadRightDrivewayCount = value;
|
|
|
+ Settings.roadRightDrivewayCount = value;
|
|
|
}
|
|
|
|
|
|
setCurveRoadLeftDrivewayCount(value) {
|
|
|
- Setting.curveRoadLeftDrivewayCount = value;
|
|
|
+ Settings.curveRoadLeftDrivewayCount = value;
|
|
|
}
|
|
|
|
|
|
setCurveRoadRightDrivewayCount(value) {
|
|
|
- Setting.curveRoadRightDrivewayCount = value;
|
|
|
+ Settings.curveRoadRightDrivewayCount = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ setSingleRoadWidth(value) {
|
|
|
+ Settings.singleRoadWidth = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ setLeftRoadWidth(value) {
|
|
|
+ Settings.leftRoadWidth = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ setRightRoadWidth(value) {
|
|
|
+ Settings.rightRoadWidth = value;
|
|
|
}
|
|
|
|
|
|
//如果position在屏幕左上角,返回的就朝向右下角,如果是右下角,则返回的是左上角。其他情况以此类推
|