fix: assigned an image as audio track's instrument-preview background
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 571 KiB |
@@ -3,6 +3,7 @@ import './InstrumentSelection.css';
|
|||||||
import { useProjectStore } from '../stores/projectStore';
|
import { useProjectStore } from '../stores/projectStore';
|
||||||
import { INSTRUMENT_GROUPS, FLUIDR3_INSTRUMENT_MAP } from '../constants/generalMidiConstants';
|
import { INSTRUMENT_GROUPS, FLUIDR3_INSTRUMENT_MAP } from '../constants/generalMidiConstants';
|
||||||
import { KGMidiTrack, type InstrumentType } from '../core/track/KGMidiTrack';
|
import { KGMidiTrack, type InstrumentType } from '../core/track/KGMidiTrack';
|
||||||
|
import { KGAudioTrack } from '../core/track/KGAudioTrack';
|
||||||
|
|
||||||
const InstrumentSelection: React.FC = () => {
|
const InstrumentSelection: React.FC = () => {
|
||||||
const {
|
const {
|
||||||
@@ -53,14 +54,15 @@ const InstrumentSelection: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const previewImage = FLUIDR3_INSTRUMENT_MAP[currentInstrumentKey]?.image || 'piano.png';
|
const isAudioTrack = targetTrack instanceof KGAudioTrack;
|
||||||
const previewAlt = FLUIDR3_INSTRUMENT_MAP[currentInstrumentKey]?.displayName || currentInstrumentKey;
|
const previewImage = isAudioTrack ? 'speaker.png' : (FLUIDR3_INSTRUMENT_MAP[currentInstrumentKey]?.image || 'piano.png');
|
||||||
|
const previewAlt = isAudioTrack ? 'Audio Track' : (FLUIDR3_INSTRUMENT_MAP[currentInstrumentKey]?.displayName || currentInstrumentKey);
|
||||||
const hasTargetTrack = !!targetTrack;
|
const hasTargetTrack = !!targetTrack;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="instrument-selection">
|
<div className="instrument-selection">
|
||||||
<div className="instrument-selection-header">
|
<div className="instrument-selection-header">
|
||||||
<h3>{hasTargetTrack ? `${previewAlt.toString()}` : ''}</h3>
|
<h3>{hasTargetTrack ? previewAlt : ''}</h3>
|
||||||
<button className="instrument-selection-close-btn" onClick={closeInstrumentSelection}>✕</button>
|
<button className="instrument-selection-close-btn" onClick={closeInstrumentSelection}>✕</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="instrument-selection-top">
|
<div className="instrument-selection-top">
|
||||||
@@ -76,6 +78,7 @@ const InstrumentSelection: React.FC = () => {
|
|||||||
)}
|
)}
|
||||||
<div className="instrument-name-overlay">{hasTargetTrack ? targetTrack.getName() : ''}</div>
|
<div className="instrument-name-overlay">{hasTargetTrack ? targetTrack.getName() : ''}</div>
|
||||||
</div>
|
</div>
|
||||||
|
{!isAudioTrack && (
|
||||||
<div className="instrument-selection-bottom">
|
<div className="instrument-selection-bottom">
|
||||||
<div className="instrument-groups">
|
<div className="instrument-groups">
|
||||||
<div className="instrument-groups-list">
|
<div className="instrument-groups-list">
|
||||||
@@ -104,6 +107,7 @@ const InstrumentSelection: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -273,9 +273,12 @@ const TrackInfoItem: React.FC<TrackInfoItemProps> = ({
|
|||||||
<div className="track-name-and-volume">
|
<div className="track-name-and-volume">
|
||||||
<div className="instrument-image">
|
<div className="instrument-image">
|
||||||
{isAudioTrack ? (
|
{isAudioTrack ? (
|
||||||
<div style={{ width: 64, height: 64, display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: '28px', color: 'var(--text-secondary, #999)' }}>
|
<img
|
||||||
<FaFileAudio />
|
src={`${import.meta.env.BASE_URL}resources/instruments/speaker.png`}
|
||||||
</div>
|
alt="Audio Track"
|
||||||
|
width="64"
|
||||||
|
height="64"
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<img
|
<img
|
||||||
src={`${import.meta.env.BASE_URL}resources/instruments/${String(FLUIDR3_INSTRUMENT_MAP[currentInstrument as keyof typeof FLUIDR3_INSTRUMENT_MAP]?.image || 'piano.png')}`}
|
src={`${import.meta.env.BASE_URL}resources/instruments/${String(FLUIDR3_INSTRUMENT_MAP[currentInstrument as keyof typeof FLUIDR3_INSTRUMENT_MAP]?.image || 'piano.png')}`}
|
||||||
|
|||||||
Reference in New Issue
Block a user