Skip to content

Commit

Permalink
[Imp] Pattern tab: In sample mode, show default volume also for note-…
Browse files Browse the repository at this point in the history
…less instruments (adapted from #29).

git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@22138 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Nov 10, 2024
1 parent 7d39fa7 commit e6cb26b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions mptrack/Draw_pat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -986,13 +986,13 @@ void CViewPattern::DrawPatternData(HDC hdc, PATTERNINDEX nPattern, bool selEnabl
const ModCommand *m = pattern.GetpModCommand(row, static_cast<CHANNELINDEX>(col));

// Should empty volume commands be replaced with a volume command showing the default volume?
const bool drawDefaultVolume = DrawDefaultVolume(m);
const bool drawDefaultVolume = (patternSetupFlags & PATTERN_SHOWDEFAULTVOLUME) && DrawDefaultVolume(*m, sndFile);

DWORD dwSpeedUpMask = 0;
if(useSpeedUpMask && (m_chnState[col].selectedCols & COLUMN_BITS_SKIP) && (row))
{
const ModCommand *mold = m - ncols;
const bool drawOldDefaultVolume = DrawDefaultVolume(mold);
const bool drawOldDefaultVolume = (patternSetupFlags & PATTERN_SHOWDEFAULTVOLUME) && DrawDefaultVolume(*mold, sndFile);

if(m->note == mold->note || !m_visibleColumns[PatternCursor::noteColumn])
dwSpeedUpMask |= COLUMN_BITS_NOTE;
Expand Down Expand Up @@ -1219,6 +1219,27 @@ void CViewPattern::DrawPatternData(HDC hdc, PATTERNINDEX nPattern, bool selEnabl
}


bool CViewPattern::DrawDefaultVolume(const ModCommand &m, const CSoundFile &sndFile)
{
if(m.instr == 0 || m.volcmd != VOLCMD_NONE || m.command == CMD_VOLUME || m.command == CMD_VOLUME8)
return false;
// In instrument mode, we'd need to know the played for note-less instrument numbers
const bool hasNote = m.IsNote();
if(sndFile.GetNumInstruments() && !hasNote)
return false;
const SAMPLEINDEX smp = sndFile.GetSampleIndex(m.note, m.instr);
if(smp != 0)
{
const ModSample &sample = sndFile.GetSample(smp);
if(sample.uFlags[SMP_NODEFAULTVOLUME])
return false;
if(sndFile.GetType() == MOD_TYPE_S3M && !sample.HasSampleData())
return false;
}
return smp != 0;
}


void CViewPattern::DrawChannelVUMeter(HDC hdc, int x, int y, UINT nChn)
{
if(m_chnState[nChn].vuMeter == m_chnState[nChn].vuMeterOld)
Expand Down
2 changes: 1 addition & 1 deletion mptrack/View_pat.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class CViewPattern final : public CModScrollView
void DrawDragSel(HDC hdc);
void OnDrawDragSel();
// True if default volume should be drawn for a given cell.
static bool DrawDefaultVolume(const ModCommand *m) { return (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_SHOWDEFAULTVOLUME) && m->volcmd == VOLCMD_NONE && m->command != CMD_VOLUME && m->command != CMD_VOLUME8 && m->instr != 0 && m->IsNote(); }
static bool DrawDefaultVolume(const ModCommand &m, const CSoundFile &sndFile);

void CursorJump(int distance, bool snap);

Expand Down

0 comments on commit e6cb26b

Please sign in to comment.