mirror of
https://github.com/vsariola/sointu.git
synced 2025-11-08 02:45:24 -05:00
feat(tracker): allow instrument have no thread, but warn about it
This commit is contained in:
parent
05b64dadc8
commit
dafd45fd81
@ -83,6 +83,15 @@ func (m *Alerts) AddNamed(name, message string, priority AlertPriority) {
|
||||
})
|
||||
}
|
||||
|
||||
func (m *Alerts) ClearNamed(name string) {
|
||||
for i := range m.alerts {
|
||||
if n := m.alerts[i].Name; n != "" && n == name {
|
||||
m.alerts[i].Duration = 0
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Alerts) AddAlert(a Alert) {
|
||||
for i := range m.alerts {
|
||||
if n := m.alerts[i].Name; n != "" && n == a.Name {
|
||||
|
||||
@ -96,9 +96,10 @@ func (m *Model) setThreadsBit(bit int, value bool) {
|
||||
} else {
|
||||
mask &^= (1 << bit)
|
||||
}
|
||||
m.d.Song.Patch[m.d.InstrIndex].ThreadMaskM1 = max(mask-1, 0) // -1 would have all threads disabled, so make that 0 i.e. use at least thread 1
|
||||
m.d.Song.Patch[m.d.InstrIndex].ThreadMaskM1 = max(mask-1, -1) // -1 has all threads disabled, we warn about that
|
||||
m.warnAboutCrossThreadSends()
|
||||
m.warnNoMultithreadSupport()
|
||||
m.warnNoThread()
|
||||
}
|
||||
|
||||
func (m *Model) warnAboutCrossThreadSends() {
|
||||
@ -120,6 +121,7 @@ func (m *Model) warnAboutCrossThreadSends() {
|
||||
}
|
||||
}
|
||||
}
|
||||
m.Alerts().ClearNamed("CrossThreadSend")
|
||||
}
|
||||
|
||||
func (m *Model) warnNoMultithreadSupport() {
|
||||
@ -129,6 +131,18 @@ func (m *Model) warnNoMultithreadSupport() {
|
||||
return
|
||||
}
|
||||
}
|
||||
m.Alerts().ClearNamed("NoMultithreadSupport")
|
||||
}
|
||||
|
||||
func (m *Model) warnNoThread() {
|
||||
for i, instr := range m.d.Song.Patch {
|
||||
if instr.ThreadMaskM1 == -1 {
|
||||
m.Alerts().AddNamed("NoThread", fmt.Sprintf("Instrument %d '%s' is not rendered on any thread", i+1, instr.Name), Warning)
|
||||
return
|
||||
}
|
||||
}
|
||||
m.Alerts().ClearNamed("NoThread")
|
||||
|
||||
}
|
||||
|
||||
func (m *Model) Thread1() Bool { return MakeEnabledBool((*Thread1)(m)) }
|
||||
|
||||
Reference in New Issue
Block a user