更新 e2dmacros.h

This commit is contained in:
Nomango 2018-04-23 00:05:57 +08:00
parent 8439c09976
commit 927d019838
3 changed files with 30 additions and 33 deletions

View File

@ -64,7 +64,7 @@ void e2d::Action::setName(String name)
e2d::Action * e2d::Action::reverse() const e2d::Action * e2d::Action::reverse() const
{ {
ASSERT(false, "Action cannot be reversed!"); WARN_IF(true, "Action cannot be reversed!");
return nullptr; return nullptr;
} }

View File

@ -59,20 +59,20 @@ bool Music::open(String strFileName)
{ {
if (m_bOpened) if (m_bOpened)
{ {
WARN_IF(true, L"Music can be opened only once!"); WARN_IF(true, "Music can be opened only once!");
return false; return false;
} }
if (strFileName.isEmpty()) if (strFileName.isEmpty())
{ {
WARN_IF(true, L"Music::open Invalid file name."); WARN_IF(true, "Music::open Invalid file name.");
return false; return false;
} }
IXAudio2 * pXAudio2 = MusicManager::getIXAudio2(); IXAudio2 * pXAudio2 = MusicManager::getIXAudio2();
if (!pXAudio2) if (!pXAudio2)
{ {
WARN_IF(true, L"IXAudio2 nullptr pointer error!"); WARN_IF(true, "IXAudio2 nullptr pointer error!");
return false; return false;
} }
@ -80,7 +80,7 @@ bool Music::open(String strFileName)
wchar_t strFilePath[MAX_PATH]; wchar_t strFilePath[MAX_PATH];
if (!_findMediaFileCch(strFilePath, MAX_PATH, strFileName)) if (!_findMediaFileCch(strFilePath, MAX_PATH, strFileName))
{ {
WARN_IF(true, L"Failed to find media file: %s", (const wchar_t*)strFileName); WARN_IF(true, "Failed to find media file: %s", (const wchar_t*)strFileName);
return false; return false;
} }
@ -118,7 +118,7 @@ bool Music::open(String strFileName)
HRESULT hr; HRESULT hr;
if (FAILED(hr = pXAudio2->CreateSourceVoice(&m_pSourceVoice, m_pwfx))) if (FAILED(hr = pXAudio2->CreateSourceVoice(&m_pSourceVoice, m_pwfx)))
{ {
TraceError(L"Error %#X creating source voice", hr); TraceError(L"Create source voice error", hr);
SAFE_DELETE_ARRAY(m_pbWaveData); SAFE_DELETE_ARRAY(m_pbWaveData);
return false; return false;
} }
@ -160,7 +160,7 @@ bool Music::play(int nLoopCount)
HRESULT hr; HRESULT hr;
if (FAILED(hr = m_pSourceVoice->SubmitSourceBuffer(&buffer))) if (FAILED(hr = m_pSourceVoice->SubmitSourceBuffer(&buffer)))
{ {
TraceError(L"Error %#X submitting source buffer", hr); TraceError(L"Submitting source buffer error", hr);
m_pSourceVoice->DestroyVoice(); m_pSourceVoice->DestroyVoice();
SAFE_DELETE_ARRAY(m_pbWaveData); SAFE_DELETE_ARRAY(m_pbWaveData);
return false; return false;

View File

@ -1,14 +1,11 @@
#pragma once #pragma once
#ifndef WINVER
// Modify the following defines if you have to target a platform prior to the ones specified below. #define WINVER 0x0700 // Allow use of features specific to Windows 7 or later
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows 7 or later.
#define WINVER 0x0700 // Change this to the appropriate value to target other versions of Windows.
#endif #endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows 7 or later. #ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0700 // Change this to the appropriate value to target other versions of Windows. #define _WIN32_WINNT 0x0700 // Allow use of features specific to Windows 7 or later
#endif #endif
#ifndef NTDDI_VERSION #ifndef NTDDI_VERSION
@ -19,7 +16,7 @@
#define UNICODE #define UNICODE
#endif #endif
// Exclude rarely-used items from Windows headers. // Exclude rarely-used items from Windows headers
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#endif #endif
@ -30,6 +27,19 @@
#define INITGUID #define INITGUID
#if _MSC_VER > 1700
#define HIGHER_THAN_VS2012 1
#else
#define HIGHER_THAN_VS2012 0
#endif
#if _MSC_VER > 1600
#define HIGHER_THAN_VS2010 1
#else
#define HIGHER_THAN_VS2010 0
#endif
// Windows Header Files // Windows Header Files
#include <windows.h> #include <windows.h>
#include <wincodec.h> #include <wincodec.h>
@ -49,9 +59,11 @@
#pragma comment(lib, "windowscodecs.lib") #pragma comment(lib, "windowscodecs.lib")
#pragma comment(lib, "winmm.lib") #pragma comment(lib, "winmm.lib")
#if _MSC_VER > 1600 #if HIGHER_THAN_VS2010
#include <xaudio2.h> #include <xaudio2.h>
#pragma comment(lib, "xaudio2.lib") #pragma comment(lib, "xaudio2.lib")
#elif
#define MUSIC_CLASS_NAME L"Easy2DMusicCallbackWnd"
#endif #endif
@ -60,28 +72,13 @@ EXTERN_C IMAGE_DOS_HEADER __ImageBase;
#define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase) #define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
#endif #endif
#define MUSIC_CLASS_NAME L"Easy2DMusicCallbackWnd"
#if _MSC_VER > 1700
#define HIGHER_THAN_VS2012 1
#else
#define HIGHER_THAN_VS2012 0
#endif
#if _MSC_VER > 1600
#define HIGHER_THAN_VS2010 1
#else
#define HIGHER_THAN_VS2010 0
#endif
#ifndef ASSERT #ifndef ASSERT
#if defined( DEBUG ) || defined( _DEBUG ) #if defined( DEBUG ) || defined( _DEBUG )
#define ASSERT(expression, message, ...) do {if (!(expression)) { fwprintf(stderr, L"Assert: " _CRT_WIDE(#message) L"\n", __VA_ARGS__); abort(); }} while(0) #define ASSERT(expression, message, ...) do {if (!(expression)) { fwprintf(stderr, L"Assert: " _CRT_WIDE(#message) L"\n", __VA_ARGS__); abort(); }} while(0)
#else #else
#define ASSERT(expression, message, ...) ((void)0) #define ASSERT(expression, message, ...) ((void)0)
#endif //DEBUG || _DEBUG #endif
#endif #endif
#ifndef WARN_IF #ifndef WARN_IF
@ -89,7 +86,7 @@ EXTERN_C IMAGE_DOS_HEADER __ImageBase;
#define WARN_IF(expression, message, ...) do {if (expression) { fwprintf(stderr, L"Warning: " _CRT_WIDE(#message) L"\n", __VA_ARGS__); }} while(0) #define WARN_IF(expression, message, ...) do {if (expression) { fwprintf(stderr, L"Warning: " _CRT_WIDE(#message) L"\n", __VA_ARGS__); }} while(0)
#else #else
#define WARN_IF(expression, message, ...) ((void)0) #define WARN_IF(expression, message, ...) ((void)0)
#endif //DEBUG || _DEBUG #endif
#endif #endif