Skip to content

Commit

Permalink
Fixed entity ref still displayed while disabled (#1000, #759)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepnight committed Dec 28, 2023
1 parent 850ca2d commit f5cc7a2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/electron.renderer/data/def/FieldDef.hx
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,15 @@ class FieldDef {
}


public function refLinkIsDisplayed() {
return switch editorDisplayMode {
case RefLinkBetweenPivots: true;
case RefLinkBetweenCenters: true;
case _: false;
}
}


public function acceptsEntityRefTo(sourceEi:data.inst.EntityInstance, targetEd:data.def.EntityDef, targetLevel:Level) {
if( type!=F_EntityRef || sourceEi==null || targetEd==null || targetLevel==null )
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/electron.renderer/data/inst/EntityInstance.hx
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ class EntityInstance {
return null;

for(i in 0...fi.getArrayLength())
if( fi.getEntityRefIid(i)==targetEi.iid && ( !onlyIfLinkIsDisplayed || fi.def.editorDisplayMode==RefLinkBetweenCenters || fi.def.editorDisplayMode==RefLinkBetweenPivots ) )
if( fi.getEntityRefIid(i)==targetEi.iid && ( !onlyIfLinkIsDisplayed || fi.def.refLinkIsDisplayed() ) )
return fi;
}
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/electron.renderer/display/EntityRender.hx
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class EntityRender extends dn.Process {
continue;

var fi = refEi.getEntityRefFieldTo(ei,true);
if( fi==null )
if( fi==null || !fi.def.refLinkIsDisplayed() )
continue;

var col = refEi.getSmartColor(false);
Expand Down

0 comments on commit f5cc7a2

Please sign in to comment.