Пример #1
0
void CInstrumentEditDlg::SetCurrentInstrument(int Index)
{
	CFamiTrackerDoc *pDoc = CFamiTrackerDoc::GetDoc();
	std::shared_ptr<CInstrument> pInstrument = pDoc->GetInstrument(Index);
	int InstType = pInstrument->GetType();

	// Dialog title
	char Name[256];
	pDoc->GetInstrumentName(Index, Name);	
	CString Suffix;
	Suffix.Format(_T("%02X. %s (%s)"), Index, Name, CHIP_NAMES[InstType]);
	CString Title;
	AfxFormatString1(Title, IDS_INSTRUMENT_EDITOR_TITLE, Suffix);
	SetWindowText(Title);

	if (InstType != m_iSelectedInstType) {
		ShowWindow(SW_HIDE);
		ClearPanels();

		switch (InstType) {
			case INST_2A03: {
					int Channel = CFamiTrackerView::GetView()->GetSelectedChannel();
					int Type = pDoc->GetChannelType(Channel);
					bool bShowDPCM = (Type == CHANID_DPCM) || (std::static_pointer_cast<CInstrument2A03>(pInstrument)->AssignedSamples());
					InsertPane(new CInstrumentEditorSeq(NULL, _T("2A03 settings"), CInstrument2A03::SEQUENCE_NAME, 15, 3, INST_2A03), !bShowDPCM); // // //
					InsertPane(new CInstrumentEditorDPCM(), bShowDPCM);
				}
				break;
			case INST_VRC6:
				InsertPane(new CInstrumentEditorSeq(NULL, _T("Konami VRC6"), CInstrumentVRC6::SEQUENCE_NAME, 15, 7, INST_VRC6), true);
				break;
			case INST_VRC7:
				InsertPane(new CInstrumentEditorVRC7(), true);
				break;
			case INST_FDS:
				InsertPane(new CInstrumentEditorFDS(), true);
				InsertPane(new CInstrumentEditorFDSEnvelope(), false);
				break;
			case INST_N163:
				InsertPane(new CInstrumentEditorSeq(
					NULL, _T("Envelopes"), CInstrumentN163::SEQUENCE_NAME, 15, CInstrumentN163::MAX_WAVE_COUNT - 1, INST_N163
				), true);
				InsertPane(new CInstrumentEditorN163Wave(), false);
				break;
			case INST_S5B:
				InsertPane(new CInstrumentEditorSeq(NULL, _T("Sunsoft 5B"), CInstrumentS5B::SEQUENCE_NAME, 15, 255, INST_S5B), true);
				break;
		}

		m_iSelectedInstType = InstType;
	}

	for (int i = 0; i < PANEL_COUNT; ++i) {
		if (m_pPanels[i] != NULL) {
			m_pPanels[i]->SelectInstrument(pInstrument);
		}
	}

	ShowWindow(SW_SHOW);
	UpdateWindow();

	m_iSelectedInstType = InstType;
}
Пример #2
0
void CInstrumentEditDlg::SetCurrentInstrument(int Index)
{
    CFamiTrackerDoc *pDoc = CFamiTrackerDoc::GetDoc();
    CInstrumentContainer<CInstrument> instContainer(pDoc, Index);
    CInstrument *pInstrument = instContainer();
    int InstType = pInstrument->GetType();

    // Dialog title
    char Name[256];
    pDoc->GetInstrumentName(Index, Name);
    CString Suffix;
    Suffix.Format(_T("%02X. %s (%s)"), Index, Name, CHIP_NAMES[InstType]);
    CString Title;
    AfxFormatString1(Title, IDS_INSTRUMENT_EDITOR_TITLE, Suffix);
    SetWindowText(Title);

    if (InstType != m_iSelectedInstType) {
        ShowWindow(SW_HIDE);
        ClearPanels();

        switch (InstType) {
        case INST_2A03: {
            int Channel = CFamiTrackerView::GetView()->GetSelectedChannel();
            int Type = pDoc->GetChannelType(Channel);
            bool bShowDPCM = (Type == CHANID_DPCM) || (static_cast<CInstrument2A03*>(pInstrument)->AssignedSamples());
            InsertPane(new CInstrumentEditor2A03(), !bShowDPCM);
            InsertPane(new CInstrumentEditorDPCM(), bShowDPCM);
        }
        break;
        case INST_VRC6:
            InsertPane(new CInstrumentEditorVRC6(), true);
            break;
        case INST_VRC7:
            InsertPane(new CInstrumentEditorVRC7(), true);
            break;
        case INST_FDS:
            InsertPane(new CInstrumentEditorFDS(), true);
            InsertPane(new CInstrumentEditorFDSEnvelope(), false);
            break;
        case INST_N163:
            InsertPane(new CInstrumentEditorN163(), true);
            InsertPane(new CInstrumentEditorN163Wave(), false);
            break;
        case INST_S5B:
            InsertPane(new CInstrumentEditorS5B(), true);
            break;
        }

        m_iSelectedInstType = InstType;
    }

    for (int i = 0; i < PANEL_COUNT; ++i) {
        if (m_pPanels[i] != NULL) {
            m_pPanels[i]->SelectInstrument(Index);
        }
    }

    ShowWindow(SW_SHOW);
    UpdateWindow();

    m_iSelectedInstType = InstType;
}