コード例 #1
0
ファイル: stat.cpp プロジェクト: m2osw/turnwatcher
/// \brief Loads info from a property bag
//
// We get out of the bag the stat, modifier and roll settings.
//
/// \param propBag	Bag containing properties to load
//
/// \sa LoadLegacy, Save
/// \return true if stat was found
//
bool Value::Load( moPropBagRef& propBag )
{
    moPropStringRef stat  ( f_statName  );
    moPropIntRef    mod   ( f_modName   );
    moPropIntRef    roll  ( f_rollName  );
    moPropStringRef notes ( f_notesName );
    //
    stat.Link( propBag );
    mod .Link( propBag );
    roll.Link( propBag );
    notes.Link( propBag );

    if( stat.HasProp() )
    {
        f_stat = StatManager::Instance().lock()->GetStat( static_cast<moName>(stat) );
        if( !f_stat )
        {
            return false;
        }
    }
    else
    {
        LoadLegacy( propBag );
    }
    //
    assert(f_stat);
    //
    if( mod.HasProp() )
    {
        f_mod = mod;
    }
    else
    {
        f_mod = 0;
    }
    //
    if( roll.HasProp() )
    {
        f_roll = roll;
    }
    else
    {
        f_roll = 0;
    }
    //
    if( notes.HasProp() )
    {
        f_notes = static_cast<moWCString>(notes).c_str();
    }
    else
    {
        f_notes = "";
    }

    return true;
}
コード例 #2
0
bool FxInternal::EffectLoad(LPCSTR filename, LPDXCCSHADERPROPERTIES pRestoreProps, LPCSTR RestoreMsg)
{
	HRESULT hr= S_OK;
	MStatus status= MStatus::kSuccess; 
	LPDIRECT3DDEVICE9 pDevice= NULL;
	LPD3DXBUFFER pErrors= NULL;
	LPD3DXEFFECT pTmpEffect= NULL;


	hr= g_PreviewPipeline.AccessEngine()->GetD3DDevice( &pDevice );
	if(DXCC_FAILED(hr))
		DXCC_GOTO_EXIT(e_Exit, TRUE);

	try
	{
		D3DXMACRO sas_present[2]= { {"SAS_PRESENT", "1"}, {NULL, NULL} };
		if(DXCC_SUCCEEDED(D3DXCreateEffectFromFileA(
				pDevice,
				filename,
				sas_present,
				&g_SasIncluder,
				NULL,
				NULL,
				&pTmpEffect,
				&pErrors)))
		{
			EffectUnload();
		
			pTmpEffect->AddRef();
			Effect= pTmpEffect;
			DXCC_RELEASE(pTmpEffect);

			FxAttributeCreator AttributesCreator;

			D3DXHANDLE hGlobal= Effect->GetParameterBySemantic(NULL, "SasGlobal");
			if(hGlobal == NULL)
			{
				MGlobal::displayWarning( "DirectXShader: File is not SAS compliant (missing SasGlobal) and may not render properly FILE: \"" + MString(filename) + "\"" );
			}
			else
			{
				D3DXHANDLE hVersion= Effect->GetAnnotationByName(hGlobal, "SasVersion");
				if(hVersion == NULL)
				{
					MGlobal::displayWarning( "DirectXShader: File is not SAS compliant (missing SAS version annotation) and may not render properly FILE:\"" + MString(filename) + "\"" );
				}
				else
				{
					INT SasVersion[3] = {0,0,0};
					if(DXCC_SUCCEEDED(Effect->GetIntArray( hVersion, SasVersion, 3)))
					{
						if(SasVersion[0] != 1 
							|| SasVersion[1] != 1 
							|| SasVersion[2] != 0 )
						{
							MGlobal::displayWarning( "DirectXShader: File does not match supported SAS version(1.1.0) and may not render properly FILE:\"" + MString(filename) + "\"" );
						}
					}
				}
			}

			if(DXCC_SUCCEEDED(  AttributesCreator.Run(this) ) )
			{
				FxAttributeFiller AttributesFiller;	

				hr= AttributesFiller.Run(this, pRestoreProps, RestoreMsg);
				if(DXCC_FAILED(hr))
					DXCC_GOTO_EXIT(e_Exit, TRUE);

				LoadLegacy();
			}
			else
			{
				MGlobal::displayWarning( "DirectXShader Load Error: Unable to convert parameters to attributes on Shader Node." );

				DXCC_STATUS_EXIT(hr, E_FAIL, e_Exit, FALSE);

			}
		}
		else
		{
			MGlobal::displayWarning( MString( "DirectXShader Load Error: Compiler Output - ") + MString( (LPCSTR) pErrors->GetBufferPointer() )  );

			DXCC_STATUS_EXIT(hr, E_FAIL, e_Exit, FALSE);
		}
	}
	catch (...)
	{
		MGlobal::displayWarning( MString( "DirectXShader Load Error: Unexpected runtime exception thrown by D3DXCreateEffectFromFileA" )  );

		DXCC_STATUS_EXIT(hr, E_FAIL, e_Exit, TRUE);
	}

e_Exit:

	DXCC_RELEASE(pTmpEffect);
	DXCC_RELEASE(pDevice);
	DXCC_RELEASE(pErrors);

	return DXCC_SUCCEEDED(hr);
}