Skip to content

Commit

Permalink
Stop rendering focus branches that are replaced by DLCs
Browse files Browse the repository at this point in the history
  • Loading branch information
malashin committed Dec 7, 2019
1 parent 3b961f9 commit a7ee932
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
5 changes: 4 additions & 1 deletion misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,19 @@ func fillFocusChildAndParentData() {

for _, p := range focusMap {
for i, child := range p.Children {

c := focusMap[child.ID]

if c.In == nil {
m := make(map[int]FocusLine)
c.In = m
}

if !c.AllowBranch {
continue
}

a := c.In[p.Y]

if child.Solid {
a.Set(S)
p.Out.Set(S)
Expand Down
14 changes: 14 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,20 @@ func traverseFocus(root *ptool.TNode) error {
f.AllowBranch = false
}
}
case "declrScope":
switch strings.ToLower(link.Links[0].Value) {
case "not":
for _, link := range link.Links {
nodeType := pdx.ByID(link.Type)
switch nodeType {
case "declr":
switch strings.ToLower(link.Links[0].Value) {
case "has_dlc":
f.AllowBranch = false
}
}
}
}
}
}
case "available":
Expand Down
31 changes: 13 additions & 18 deletions render.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,28 +260,22 @@ func renderLines(dst *image.RGBA) error {
y += UD.Bounds().Max.Y

// First corner (out).
renderFirstCorner := true
for _, c := range p.Children {
c := focusMap[c.ID]
if c.X == p.X && c.Y == p.Y+1 {
renderFirstCorner = false
}
}
if renderFirstCorner {
img = p.Out.Get()
draw.Draw(dst,
image.Rectangle{
image.Point{x, y},
image.Point{x + img.Bounds().Max.X, y + img.Bounds().Max.Y}},
img,
image.ZP,
draw.Over)
}
img = p.Out.Get()
draw.Draw(dst,
image.Rectangle{
image.Point{x, y},
image.Point{x + img.Bounds().Max.X, y + img.Bounds().Max.Y}},
img,
image.ZP,
draw.Over)
drawnCoords = append(drawnCoords, image.Point{x, y})

cornerXvalues := []int{x}
for _, c := range p.Children {
c := focusMap[c.ID]
cornerXvalues = append(cornerXvalues, c.X*gui.FocusSpacing.X+gui.NationalFocusLink.Position.X+gui.LinkBegin.X+gui.LinkOffsets.X+spacingX)
if c.AllowBranch {
cornerXvalues = append(cornerXvalues, c.X*gui.FocusSpacing.X+gui.NationalFocusLink.Position.X+gui.LinkBegin.X+gui.LinkOffsets.X+spacingX)
}
}

var isPrevSolid bool
Expand All @@ -306,6 +300,7 @@ func renderLines(dst *image.RGBA) error {
}
}
}

x := c.X*gui.FocusSpacing.X + gui.NationalFocusLink.Position.X + gui.LinkBegin.X + gui.LinkOffsets.X + spacingX

length := int(math.Abs(float64(c.X-p.X)))*gui.FocusSpacing.Y + gui.LinkBegin.X + gui.LinkOffsets.X + spacingX
Expand Down

0 comments on commit a7ee932

Please sign in to comment.