refactor: put all info about different unit types into UnitTypes map

This commit is contained in:
5684185+vsariola@users.noreply.github.com
2026-03-15 10:29:24 +02:00
parent 8ea9d3a191
commit 6a331f7a57
8 changed files with 392 additions and 331 deletions

View File

@ -270,12 +270,7 @@ func (m *UnitModel) SetType(t string) {
for len(m.d.Song.Patch[m.d.InstrIndex].Units) <= m.d.UnitIndex {
m.d.Song.Patch[m.d.InstrIndex].Units = append(m.d.Song.Patch[m.d.InstrIndex].Units, sointu.Unit{})
}
unit, ok := defaultUnits[t]
if !ok { // if the type is invalid, we just set it to empty unit
unit = sointu.Unit{Parameters: make(map[string]int)}
} else {
unit = unit.Copy()
}
unit := sointu.MakeUnit(t)
oldUnit := m.d.Song.Patch[m.d.InstrIndex].Units[m.d.UnitIndex]
if oldUnit.Type == unit.Type {
return