mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
feat(tracker): do not wrap around when playing or moving cursor
The wrapping was usually unwanted behaviour. The user can use the looping (Ctrl-L) to loop the song forever if this is really desired.
This commit is contained in:
parent
5e65410d27
commit
877556b428
@ -24,6 +24,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
disabled ([#139][i139])
|
disabled ([#139][i139])
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
- Do not automatically wrap around the song when playing as it was usually
|
||||||
|
unwanted behaviour. There is already the looping mechanism if the user really
|
||||||
|
wants to loop the song forever.
|
||||||
- Moved the error and warning popups slightly up so they don't block the unit
|
- Moved the error and warning popups slightly up so they don't block the unit
|
||||||
control buttons ([#142][i142])
|
control buttons ([#142][i142])
|
||||||
|
|
||||||
|
@ -220,8 +220,8 @@ func (m *Model) change(kind string, t ChangeType, severity ChangeSeverity) func(
|
|||||||
m.d.ChangedSinceRecovery = true
|
m.d.ChangedSinceRecovery = true
|
||||||
if m.changeType&ScoreChange != 0 {
|
if m.changeType&ScoreChange != 0 {
|
||||||
m.updatePatternUseCount()
|
m.updatePatternUseCount()
|
||||||
m.d.Cursor.SongPos = m.d.Song.Score.Wrap(m.d.Cursor.SongPos)
|
m.d.Cursor.SongPos = m.d.Song.Score.Clamp(m.d.Cursor.SongPos)
|
||||||
m.d.Cursor2.SongPos = m.d.Song.Score.Wrap(m.d.Cursor2.SongPos)
|
m.d.Cursor2.SongPos = m.d.Song.Score.Clamp(m.d.Cursor2.SongPos)
|
||||||
m.send(m.d.Song.Score.Copy())
|
m.send(m.d.Song.Score.Copy())
|
||||||
}
|
}
|
||||||
if m.changeType&PatchChange != 0 {
|
if m.changeType&PatchChange != 0 {
|
||||||
@ -353,6 +353,8 @@ func (m *Model) ProcessPlayerMessage(msg PlayerMsg) {
|
|||||||
m.instrEnlarged = false
|
m.instrEnlarged = false
|
||||||
case Alert:
|
case Alert:
|
||||||
m.Alerts().AddAlert(e)
|
m.Alerts().AddAlert(e)
|
||||||
|
case IsPlayingMsg:
|
||||||
|
m.playing = e.bool
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,12 +192,21 @@ func (p *Player) advanceRow() {
|
|||||||
if p.song.Score.Length == 0 || p.song.Score.RowsPerPattern == 0 {
|
if p.song.Score.Length == 0 || p.song.Score.RowsPerPattern == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
origPos := p.songPos
|
||||||
p.songPos.PatternRow++ // advance row (this is why we subtracted one in Play())
|
p.songPos.PatternRow++ // advance row (this is why we subtracted one in Play())
|
||||||
if p.loop.Length > 0 && p.songPos.PatternRow >= p.song.Score.RowsPerPattern && p.songPos.OrderRow == p.loop.Start+p.loop.Length-1 {
|
if p.loop.Length > 0 && p.songPos.PatternRow >= p.song.Score.RowsPerPattern && p.songPos.OrderRow == p.loop.Start+p.loop.Length-1 {
|
||||||
p.songPos.PatternRow = 0
|
p.songPos.PatternRow = 0
|
||||||
p.songPos.OrderRow = p.loop.Start
|
p.songPos.OrderRow = p.loop.Start
|
||||||
}
|
}
|
||||||
p.songPos = p.song.Score.Wrap(p.songPos)
|
p.songPos = p.song.Score.Clamp(p.songPos)
|
||||||
|
if p.songPos == origPos {
|
||||||
|
p.send(IsPlayingMsg{bool: false})
|
||||||
|
p.playing = false
|
||||||
|
for i := range p.song.Score.Tracks {
|
||||||
|
p.releaseTrack(i)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
p.send(nil) // just send volume and song row information
|
p.send(nil) // just send volume and song row information
|
||||||
lastVoice := 0
|
lastVoice := 0
|
||||||
for i, t := range p.song.Score.Tracks {
|
for i, t := range p.song.Score.Tracks {
|
||||||
|
@ -410,7 +410,7 @@ func (m *Notes) Cursor2() Point {
|
|||||||
|
|
||||||
func (v *Notes) SetCursor(p Point) {
|
func (v *Notes) SetCursor(p Point) {
|
||||||
v.d.Cursor.Track = intMax(intMin(p.X, len(v.d.Song.Score.Tracks)-1), 0)
|
v.d.Cursor.Track = intMax(intMin(p.X, len(v.d.Song.Score.Tracks)-1), 0)
|
||||||
newPos := v.d.Song.Score.Wrap(sointu.SongPos{PatternRow: p.Y})
|
newPos := v.d.Song.Score.Clamp(sointu.SongPos{PatternRow: p.Y})
|
||||||
if newPos != v.d.Cursor.SongPos {
|
if newPos != v.d.Cursor.SongPos {
|
||||||
v.noteTracking = false
|
v.noteTracking = false
|
||||||
}
|
}
|
||||||
@ -419,7 +419,7 @@ func (v *Notes) SetCursor(p Point) {
|
|||||||
|
|
||||||
func (v *Notes) SetCursor2(p Point) {
|
func (v *Notes) SetCursor2(p Point) {
|
||||||
v.d.Cursor2.Track = intMax(intMin(p.X, len(v.d.Song.Score.Tracks)-1), 0)
|
v.d.Cursor2.Track = intMax(intMin(p.X, len(v.d.Song.Score.Tracks)-1), 0)
|
||||||
v.d.Cursor2.SongPos = v.d.Song.Score.Wrap(sointu.SongPos{PatternRow: p.Y})
|
v.d.Cursor2.SongPos = v.d.Song.Score.Clamp(sointu.SongPos{PatternRow: p.Y})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Notes) Width() int {
|
func (v *Notes) Width() int {
|
||||||
|
Loading…
Reference in New Issue
Block a user