Skip to content

Commit dd738ff

Browse files
authored
feat: show var modifications under prefab name (#391)
1 parent b7a7dc5 commit dd738ff

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

internal/app/ui/cpprefabs/process.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package cpprefabs
22

33
import (
44
"fmt"
5+
"strings"
56

7+
"sdmm/internal/dmapi/dmvars"
68
w "sdmm/internal/imguiext/widget"
79

810
"github.com/SpaiR/imgui-go"
@@ -56,11 +58,34 @@ func (p *Prefabs) Process(int32) {
5658
imgui.SameLine()
5759

5860
imgui.BeginGroup()
61+
imgui.PushStyleVarVec2(imgui.StyleVarItemSpacing, imgui.Vec2{X: 0, Y: 0})
5962
imgui.Text(node.name)
63+
imgui.TextColored(imgui.Vec4{X: 0.6, Y: 0.6, Z: 0.6, W: 1}, describeVars(node.orig.Vars()))
64+
imgui.PopStyleVar()
6065
imgui.EndGroup()
6166

6267
imgui.EndGroup()
6368

6469
node.visHeight = imgui.ItemRectMax().Y - imgui.ItemRectMin().Y
6570
}
6671
}
72+
73+
func describeVars(variables *dmvars.Variables) string {
74+
// "name" is already plainly visible and can be skipped.
75+
// "icon", "icon_state", "dir", and "color" do affect the sprite, but are
76+
// included in the list in case the effect is not obvious.
77+
b := strings.Builder{}
78+
for _, key := range variables.Iterate() {
79+
if key == "name" {
80+
continue
81+
}
82+
if b.Len() > 0 {
83+
b.WriteString("; ")
84+
}
85+
b.WriteString(key)
86+
b.WriteString(" = ")
87+
value, _ := variables.Value(key)
88+
b.WriteString(value)
89+
}
90+
return b.String()
91+
}

0 commit comments

Comments
 (0)