Skip to content

Commit

Permalink
9.24
Browse files Browse the repository at this point in the history
  • Loading branch information
imengyu committed Sep 24, 2020
1 parent 07e5068 commit 1710ebe
Show file tree
Hide file tree
Showing 25 changed files with 610 additions and 245 deletions.
8 changes: 8 additions & 0 deletions src/assets/images/dragger-bg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 25 additions & 1 deletion src/assets/sass/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@
}
}


//属性列表
.prop-host {
position: absolute;
Expand Down Expand Up @@ -384,6 +383,31 @@
background-color: rgba(255, 255, 255, 0.253);
}
}

}
.prop-list-dragger {
position: absolute;
left: 3px;
top: 50%;
margin-top: -18px;
cursor: move;
z-index: 1;
width: 45px;
height: 45px;
background-image: url(../images/dragger-bg.svg);
background-position: center;
background-size: 45px;
background-repeat: no-repeat;

i {
position: absolute;
top: 50%;
margin-top: -11px;
left: 5px;
width: 18px;
height: 18px;
font-size: 15px;
}
}

//添加单元浮动菜单
Expand Down
15 changes: 15 additions & 0 deletions src/components/BlockDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,21 @@ export default class BlockDrawer extends Vue {
element.updateAllPortElement();
});
this.connectors.sort((a, b) => {
if(a.flexableCoonIndex == b.flexableCoonIndex) return 0;
return a.flexableCoonIndex > b.flexableCoonIndex ? 1 : -1;
})
//刷新弹性端口的连接
setTimeout(() => {
for(let i = 0; i < this.connectors.length; i++) {
let connector = this.connectors[i];
if(connector.flexableCoonIndex > 0) {
this.editorWorker.flushConnectorFlexablePort(connector);
if(connector.flexableCoonIndex > ConnectorEditor.flexableCoonSource)
ConnectorEditor.flexableCoonSource = connector.flexableCoonIndex + 1;
}
}
}, 666);
//开始绘制
this.editorCanvas.draw();
Expand Down
14 changes: 13 additions & 1 deletion src/components/BlockEditorWorker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ export default class BlockEditorWorker extends Vue {
if(connector != null) {
connector.currentRunner = this.runner;
this.connectors.push(connector);
//更新弹性端口
if(startPort.direction == 'input')
connector.flexableCoonIndex = (<BlockEditor>startPort.parent).testAndChangeFlexablePortType(startPort, endPort) ? ConnectorEditor.flexableCoonSource++ : 0;
else if(endPort.direction == 'input')
connector.flexableCoonIndex = (<BlockEditor>endPort.parent).testAndChangeFlexablePortType(endPort, startPort) ? ConnectorEditor.flexableCoonSource++ : 0;
}
return connector;
Expand All @@ -398,6 +404,11 @@ export default class BlockEditorWorker extends Vue {
}
this.$emit('update-set-file-changed');
}
public flushConnectorFlexablePort(connector : ConnectorEditor) {
let startPort = connector.startPort;
let endPort = connector.endPort;
(<BlockEditor>endPort.parent).testAndChangeFlexablePortType(endPort, startPort);
}
public getCanConnect() {
return this.connectingCanConnect;
}
Expand Down Expand Up @@ -509,7 +520,8 @@ export default class BlockEditorWorker extends Vue {
if(this.currentHoverPort.parent == this.connectingStartPort.parent){
this.connectingCanConnect = false;
this.connectingFailedText = '不能连接同一个单元的节点';
}else{
}
else{
//方向必须不同才能链接
this.connectingCanConnect = this.currentHoverPort.direction != this.connectingStartPort.direction;
if(!this.connectingCanConnect)
Expand Down
48 changes: 43 additions & 5 deletions src/components/ChooseTypePanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<div v-if="allBaseTypes" class="block-list">
<div class="block-item" v-for="(item, index) in allBaseTypes" :key="'D'+index" @click="onItemClick(item)" v-show="searchValue==''||item.name.contains(searchValue)">
<i class="iconfont icon-yuan1" :style="{ marginRight: '5px', color: item.color }"></i>
{{ item.name }}
{{ item.nameForUser }}
</div>
<div class="block-item" v-for="(item, index) in allCustomTypes" :key="'C'+index" @click="onItemClick(item)" :title="item.name+'('+item.prototypeName+')'" v-show="searchValue==''||item.name.contains(searchValue)">
<div class="block-item" v-for="(item, index) in allCustomTypes" :key="'C'+index" @click="onItemClick(item)" v-show="searchValue==''||item.name.contains(searchValue)">
<i :class="'iconfont ' + (item.prototypeName == 'enum' ? 'icon-tx-fill-babianxing' : 'icon-search2')" :style="{ marginRight: '5px', color: item.color }"></i>
{{ item.name }}
{{ item.nameForUser }}
</div>
</div>

Expand All @@ -25,6 +25,7 @@ import { Component, Prop, Vue, Watch } from "vue-property-decorator";
import { Vector2 } from "../model/Vector2";
import { BlockParameterTypeRegData } from "../model/Define/BlockDef";
import ParamTypeServiceInstance from "../sevices/ParamTypeService";
import CommonUtils from "../utils/CommonUtils";
@Component({
name: 'ChooseTypePanel'
Expand Down Expand Up @@ -53,13 +54,50 @@ export default class ChooseTypePanel extends Vue {
@Prop({ default: null }) showPos : Vector2;
@Prop({ default: false }) show : boolean;
allCustomTypes : Map<string, BlockParameterTypeRegData> = null;
allCustomTypes = [];
allBaseTypes = [];
loadCustomTypes(act : 'full'|'add'|'remove', typeName ?: string, reg ?: BlockParameterTypeRegData) {
let map = ParamTypeServiceInstance.getAllCustomTypes();
if(act == 'full') {
this.allCustomTypes.empty();
map.forEach((value) => {
this.allCustomTypes.push({
nameForUser: CommonUtils.isNullOrEmpty(value.nameForUser) ? value.name : value.nameForUser,
name: value.name,
prototypeName: value.prototypeName,
color: ParamTypeServiceInstance.getTypeColor(value.name),
isBaseType: false,
})
});
}
else if(act == 'remove') {
for(let i = this.allCustomTypes.length - 1; i >= 0; i--) {
if(this.allCustomTypes[i].name == typeName) {
this.allCustomTypes.remove(i);
break;
}
}
}
else if(act == 'add') {
this.allCustomTypes.push({
nameForUser: CommonUtils.isNullOrEmpty(reg.nameForUser) ? reg.name : reg.nameForUser,
name: reg.name,
prototypeName: reg.prototypeName,
color: ParamTypeServiceInstance.getTypeColor(reg.name),
isBaseType: false,
})
}
}
mounted() {
this.allCustomTypes = ParamTypeServiceInstance.getAllCustomTypes();
setTimeout(() => this.loadCustomTypes('full'), 2000);
ParamTypeServiceInstance.onTypeChanged.addListener(this, (act, name, reg) => this.loadCustomTypes(act, name, reg));
ParamTypeServiceInstance.getAllBaseTypes().forEach(type => {
this.allBaseTypes.push({
nameForUser: ParamTypeServiceInstance.getTypeNameForUserMapping(type),
name: type,
color: ParamTypeServiceInstance.getTypeColor(type),
isBaseType: true,
Expand Down
Loading

0 comments on commit 1710ebe

Please sign in to comment.