From: <sv...@op...> - 2024-11-10 13:47:47
|
Author: sagamusix Date: Sun Nov 10 14:47:34 2024 New Revision: 22138 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22138 Log: [Imp] Pattern tab: In sample mode, show default volume also for note-less instruments (adapted from https://github.com/OpenMPT/openmpt/pull/29). Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/View_pat.h Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp Sun Nov 10 13:03:23 2024 (r22137) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp Sun Nov 10 14:47:34 2024 (r22138) @@ -986,13 +986,13 @@ 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; @@ -1219,6 +1219,27 @@ } +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) Modified: trunk/OpenMPT/mptrack/View_pat.h ============================================================================== --- trunk/OpenMPT/mptrack/View_pat.h Sun Nov 10 13:03:23 2024 (r22137) +++ trunk/OpenMPT/mptrack/View_pat.h Sun Nov 10 14:47:34 2024 (r22138) @@ -301,7 +301,7 @@ 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); |