⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d3dsettings.cpp

📁 game code对于游戏地图的编辑代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
void CD3DSettingsDialog::EditBoxSetText(Int32 id,TCHAR* text)
{
	HWND hwndctrl = GetDlgItem(m_hDlg,id);
	Edit_SetText(hwndctrl,text);
}

//-----------------------------------------------------------------------------
// Name: ShowDialog
// Desc: Show the D3D settings dialog.
//-----------------------------------------------------------------------------
INT_PTR CD3DSettingsDialog::ShowDialog(HINSTANCE hInst, HWND hwndParent )
{
    return DialogBox( hInst, MAKEINTRESOURCE( IDD_DIALOG_SELECTDEVICE ), 
        hwndParent, DialogProcHelper );
}




//-----------------------------------------------------------------------------
// Name: DialogProc
// Desc: Handle window messages in the dialog.
//-----------------------------------------------------------------------------
INT_PTR CD3DSettingsDialog::DialogProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
{
    UNREFERENCED_PARAMETER( lParam );

    switch( msg )
    {
    case WM_INITDIALOG:
        {
            m_hDlg = hDlg;

            // Fill adapter combo box.  Updating the selected adapter will trigger
            // updates of the rest of the dialog.
            for( Int32 iai = 0; iai < m_pEnumeration->GetAdapterNum(); iai++ )
            {
                D3DAdapterInfo& AdapterInfo = m_pEnumeration->GetAdapter(iai);
                TCHAR strDescription[512];
                DXUtil_ConvertAnsiStringToGeneric( strDescription, AdapterInfo.d3dAdapterIdentifier.Description, 512 );
                ComboBoxAdd( IDC_COMBO_Adapter, strDescription );
                if( iai == m_pEnumeration->GetCurrentAdapterIdx() )
                    ComboBoxSelectIndex( IDC_COMBO_Adapter, iai );
            }
            if( !ComboBoxSomethingSelected( IDC_COMBO_Adapter) &&
                ComboBoxCount( IDC_COMBO_Adapter ) > 0 )
            {
                ComboBoxSelectIndex( IDC_COMBO_Adapter, 0 );
            }
			D3DAdapterInfo &adapter = m_pEnumeration->GetCurrentAdapter();
			D3DDeviceInfo  &device  = adapter.devices[adapter.dwCurrentDevice];
            if( device.bWindowed )
				CheckDlgButton(m_hDlg,IDC_RADIO_WIN,TRUE);
			else
				CheckDlgButton(m_hDlg,IDC_RADIO_FULL,TRUE);
			if( m_pEnumeration->IsMixedVertexProcessing() )
				CheckDlgButton(m_hDlg,IDC_CHECK_USEMIXEDVP,TRUE);
        }
        return TRUE;

    case WM_COMMAND:
        switch( LOWORD(wParam) )
        {
        case IDOK:
            EndDialog( hDlg, IDOK );
            break;
        case IDCANCEL:
            EndDialog( hDlg, IDCANCEL );
            break;
        case IDC_COMBO_Adapter:
            if( CBN_SELCHANGE == HIWORD(wParam) )
                AdapterChanged();
            break;
        case IDC_COMBO_Device:
            if( CBN_SELCHANGE == HIWORD(wParam) )
                DeviceChanged();
            break;
		case IDC_COMBO_Mode:
			if( CBN_SELCHANGE == HIWORD(wParam) )
				ModeChanged();
			break;
		case IDC_RADIO_WIN:
		case IDC_RADIO_FULL:
			WindowedFullscreenChanged();
			break;
		case IDC_CHECK_ENABLEBUFFER:
			DepthStencilBufferChanged();
			break;
		case IDC_CHECK_USEMIXEDVP:
			MixedVPChanged();
			break;
        }
        return TRUE;

    default:
        return FALSE;
    }
}



//-----------------------------------------------------------------------------
// Name: AdapterChanged
// Desc: Respond to a change of selected adapter.
//-----------------------------------------------------------------------------
void CD3DSettingsDialog::AdapterChanged( void )
{
    Int32 AdapterIdx = ComboBoxSelected( IDC_COMBO_Adapter );
    if( AdapterIdx < 0 )
        return;

	m_pEnumeration->SetCurrentAdapterIdx(AdapterIdx);
	D3DAdapterInfo &AdapterInfo = m_pEnumeration->GetAdapter(AdapterIdx);

    // Update device combo box
    ComboBoxClear( IDC_COMBO_Device );
    for( UINT idi = 0; idi < AdapterInfo.dwNumDevices; idi++ )
    {
        D3DDeviceInfo& DeviceInfo = AdapterInfo.devices[idi];
        ComboBoxAdd( IDC_COMBO_Device,D3DDevTypeToString( DeviceInfo.DeviceType ) );
        if( idi==AdapterInfo.dwCurrentDevice )
            ComboBoxSelectIndex( IDC_COMBO_Device, idi);
    }
    if( !ComboBoxSomethingSelected( IDC_COMBO_Device ) &&
        ComboBoxCount( IDC_COMBO_Device ) > 0 )
    {
        ComboBoxSelectIndex( IDC_COMBO_Device, 0 );
    }
}




//-----------------------------------------------------------------------------
// Name: DeviceChanged
// Desc: Respond to a change of selected device by resetting the 
//       fullscreen/windowed radio buttons.  Updating these buttons will 
//       trigger updates of the rest of the dialog.
//-----------------------------------------------------------------------------
void CD3DSettingsDialog::DeviceChanged( void )
{
    Int32 DeviceIdx= ComboBoxSelected( IDC_COMBO_Device );
    if( DeviceIdx < 0 )
        return;

	D3DAdapterInfo &CurrentAdapter = m_pEnumeration->GetCurrentAdapter();
	CurrentAdapter.dwCurrentDevice = DeviceIdx;
	D3DDeviceInfo &DeviceInfo = CurrentAdapter.devices[CurrentAdapter.dwCurrentDevice];

    // Update mode combo box
    ComboBoxClear( IDC_COMBO_Mode );
    for( UINT imi = 0; imi < DeviceInfo.dwNumModes; imi++ )
    {
        D3DModeInfo mode = DeviceInfo.modes[imi];
        ComboBoxAdd( IDC_COMBO_Mode,D3DModeTypeToString( mode ) );
        if( imi==DeviceInfo.dwCurrentMode )
            ComboBoxSelectIndex( IDC_COMBO_Mode, imi);
    }
    if( !ComboBoxSomethingSelected( IDC_COMBO_Mode ) &&
        ComboBoxCount( IDC_COMBO_Mode ) > 0 )
    {
        ComboBoxSelectIndex( IDC_COMBO_Mode, 0 );
    }
}

//-----------------------------------------------------------------------------
// Name: ModeChanged
// Desc: Respond to a change of selected mode
//-----------------------------------------------------------------------------
void CD3DSettingsDialog::ModeChanged(void)
{
	Int32 ModeIdx= ComboBoxSelected( IDC_COMBO_Mode );
	if( ModeIdx < 0 )
		return;

	D3DAdapterInfo &adapter = m_pEnumeration->GetCurrentAdapter();
	D3DDeviceInfo  &device  = adapter.devices[adapter.dwCurrentDevice];
	device.dwCurrentMode    = ModeIdx;
	D3DModeInfo    &mode    = device.modes[ModeIdx];

	if( m_pEnumeration->IsUseDepthStencilBuffer() )
	{
		CheckDlgButton(m_hDlg, IDC_CHECK_ENABLEBUFFER, 1);
		EditBoxSetText(IDC_EDIT_DEPTHANDSTENCILBUFFER,D3DUtil_D3DFormatToString(mode.DepthStencilFormat));
	}
	else
		EditBoxSetText(IDC_EDIT_DEPTHANDSTENCILBUFFER,TEXT("NotUsed"));

	EditBoxSetText(IDC_EDIT_VERTEXPROCESS,VPTypeToString(mode.dwBehavior));

	if( device.bCanDoWindowed && device.bWindowed )
	{
		EnableWindow(GetDlgItem(m_hDlg,IDC_RADIO_WIN),TRUE);
		CheckDlgButton(m_hDlg,IDC_RADIO_WIN,TRUE);
		EditBoxSetText(IDC_EDIT_BACKBUFFER,D3DUtil_D3DFormatToString(adapter.d3ddmDesktop.Format));
		EditBoxSetText(IDC_EDIT_MULTISAMPLETYPE,MultisampleTypeToString(device.MultiSampleTypeWindowed));
	}
	else
	{
		if( !device.bCanDoWindowed )
			EnableWindow(GetDlgItem(m_hDlg,IDC_RADIO_WIN),FALSE);
		CheckDlgButton(m_hDlg,IDC_RADIO_FULL,TRUE);
		EditBoxSetText(IDC_EDIT_BACKBUFFER,D3DUtil_D3DFormatToString(mode.Format));
		EditBoxSetText(IDC_EDIT_MULTISAMPLETYPE,MultisampleTypeToString(device.MultiSampleTypeFullscreen));
	}
}
//-----------------------------------------------------------------------------
// Name: WindowedFullscreenChanged
// Desc: Respond to a change of windowed/fullscreen state by rebuilding the
//       adapter format list, resolution list, and refresh rate list.
//       Updating the selected adapter format will trigger updates of the 
//       rest of the dialog.
//-----------------------------------------------------------------------------
void CD3DSettingsDialog::WindowedFullscreenChanged( void )
{
	D3DAdapterInfo& adapter = m_pEnumeration->GetCurrentAdapter();
	D3DDeviceInfo&  device  = adapter.devices[adapter.dwCurrentDevice];

	if( IsDlgButtonChecked(m_hDlg,IDC_RADIO_WIN) )
	{
		device.bWindowed = true;	
	}
	else
	{
		device.bWindowed = false;
	}	
	ModeChanged();
}




//-----------------------------------------------------------------------------
// Name: DepthStencilBufferFormatChanged
// Desc: Respond to a change of selected depth/stencil buffer format.
//-----------------------------------------------------------------------------
void CD3DSettingsDialog::DepthStencilBufferChanged( void )
{
	m_pEnumeration->UseDepthStencilBuffer( (Bool)IsDlgButtonChecked(m_hDlg,IDC_CHECK_ENABLEBUFFER) );
	m_pEnumeration->BuildDeviceList();
	DeviceChanged();
}
void CD3DSettingsDialog::MixedVPChanged(void )
{
	m_pEnumeration->UseMixedVertexProcessing( (Bool)IsDlgButtonChecked(m_hDlg,IDC_CHECK_USEMIXEDVP) );
	m_pEnumeration->BuildDeviceList();
	DeviceChanged();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -