近期在 MyCard 项目中尝试了自动化编译 YGOPro,发现官方采用 premake 生成项目文件,但并没有给出具体方法。故在此记录下折腾的成果。
本笔记基本上是参考了 DailyShana 的 build 分支写成,感谢 soarqin 和 DailyShana 的工作。
本笔记的操作在 Windows 7 和 Visual Studio Community 2015 上测试通过,理论上也可以适用于XP之后的系统。

2017-03-13 更新部分文件。

0. 准备

必须下载:

建议下载:

  • Git for Windows
    用于自动获取和更新 YGOPro 的源码。此外其包含了 MSYS2,提供后文需要用到的 patch 工具。
    如果不使用 git,你将需要手动下载 YGOPro 的子模块。此外,在上游和你都对源码做出修改后,你需要手动合并代码。
    本文默认你已经安装了 Git for Windows,并且设置了账号和 GitHub 的 ssh 公钥。
  • DirectX SDK
    让 YGOPro 支持 Direct3D 模式的必备组件。
    如果不安装 DirectX SDK,你将需要更改 Irrlicht 的配置文件,并且编译出的 YGOPro 将只能支持 OpenGL 模式。
  • Visual Studio Community 2015
    免费的正版Visual Studio,功能完全满足业余开发者的需求。

1. 获取 YGOPro 源码

YGOPro 以 GPL 协议开源,托管在 GitHub,用 git clone 即可获得。clone 时用 --recursive 来同时克隆子模块。

git clone https://github.com/Fluorohydride/ygopro.git --recursive

子模块的引用往往不是最新的,需要 git checkout master

cd ygopro/
cd ocgcore/
git checkout master
cd ../script/
git checkout master
cd ..

2. Premake 简介

Premake 是一个命令行工具,用脚本定义软件工程,然后根据脚本为 Visual Studio, Xcode, 或 GNU Make 等工具生成项目文件。1
Premake 的脚本采用 lua 语言,十分简洁易懂,参考 premake4.luaocgcore\premake4.lua 即可略知一二。
于是,我们要做的就是给 libeventFreeTypeIrrlichtLuaSQLite 写 premake 文件,并最后用 Premake 生成 Visual Studio 的项目文件(解决方案)。

3. 配置 libevent

解压 libevent-2.0.22-stable.tar.gz 到项目目录,将文件夹重命名为 event
为兼容 YGOPro 源码,将 WIN32-Code 文件夹里的文件全部移动到 include 文件夹。
根据 libevent 的 Makefile,得到如下 premake4.lua,放到 event 文件夹里。

project "event"
kind "StaticLib"

includedirs { "include", "compat" }

files { "event.c", "evthread.c", "buffer.c", "bufferevent.c", "bufferevent_sock.c",
"bufferevent_filter.c", "bufferevent_pair.c", "listener.c", "bufferevent_ratelim.c",
"evmap.c", "log.c", "evutil.c", "evutil_rand.c", "strlcpy.c", "signal.c",
"event_tagging.c", "http.c", "evdns.c", "evrpc.c" }

configuration "windows"
files { "win32select.c", "evthread_win32.c", "buffer_iocp.c", "event_iocp.c", "bufferevent_async.c" }

4. 配置 FreeType

解压 freetype-2.7.1.tar.bz2 到项目目录,将文件夹重命名为 freetype
根据 freetype 的 vcxproj,得到如下 premake4.lua,放到 freetype 文件夹里。

project "freetype"
kind "StaticLib"

includedirs { "include" }
defines { "FT2_BUILD_LIBRARY" }

files { "src/autofit/autofit.c", "src/bdf/bdf.c", "src/cff/cff.c", "src/base/ftbase.c",
"src/base/ftbitmap.c", "src/cache/ftcache.c", "src/base/ftfstype.c", "src/base/ftgasp.c",
"src/base/ftglyph.c", "src/gzip/ftgzip.c", "src/base/ftinit.c", "src/lzw/ftlzw.c",
"src/base/ftstroke.c", "src/base/ftsystem.c", "src/smooth/smooth.c", "src/base/ftbbox.c",
"src/base/ftfntfmt.c", "src/base/ftmm.c", "src/base/ftpfr.c", "src/base/ftsynth.c",
"src/base/fttype1.c", "src/base/ftwinfnt.c", "src/base/ftlcdfil.c", "src/base/ftgxval.c",
"src/base/ftotval.c", "src/base/ftpatent.c", "src/pcf/pcf.c", "src/pfr/pfr.c",
"src/psaux/psaux.c", "src/pshinter/pshinter.c", "src/psnames/psmodule.c",
"src/raster/raster.c", "src/sfnt/sfnt.c", "src/truetype/truetype.c",
"src/type1/type1.c", "src/cid/type1cid.c", "src/type42/type42.c", "src/winfonts/winfnt.c" }

configuration "windows"
files { "builds/windows/ftdebug.c" }

5. 配置 Irrlicht

解压 irrlicht-1.8.4.zip 到项目目录,将文件夹重命名为 irrlicht
为兼容 YGOPro 源码,将 source\Irrlicht 剪切到 irrlicht 文件夹,重命名为 src
Irrlicht 本身对中文显示和输入的支持存在问题,soarqin 和 DailyShana 给出了用于 Irrlicht 的中文支持。
将以下代码保存为 irrlicht.patch,在MSYS的命令行下用 patch 应用即可。

diff --git a/irrlicht/include/IOSOperator.h b/irrlicht/include/IOSOperator.h
index b5c6236..b2e864a 100644
--- a/irrlicht/include/IOSOperator.h
+++ b/irrlicht/include/IOSOperator.h
@@ -26,11 +26,11 @@ public:
}

//! Copies text to the clipboard
- virtual void copyToClipboard(const c8* text) const = 0;
+ virtual void copyToClipboard(const c16* text) const = 0;

//! Get text from the clipboard
/** \return Returns 0 if no string is in there. */
- virtual const c8* getTextFromClipboard() const = 0;
+ virtual const c16* getTextFromClipboard() const = 0;

//! Get the processor speed in megahertz
/** \param MHz The integer variable to store the speed in.
diff --git a/irrlicht/include/IrrCompileConfig.h b/irrlicht/include/IrrCompileConfig.h
index c2c5d12..7c44f0c 100644
--- a/irrlicht/include/IrrCompileConfig.h
+++ b/irrlicht/include/IrrCompileConfig.h
@@ -233,7 +233,9 @@ you will not be able to use anything provided by the GUI Environment, including
disable this feature, the engine behave as before (ansi). This is currently only supported
for Windows based systems. You also have to set #define UNICODE for this to compile.
*/
-//#define _IRR_WCHAR_FILESYSTEM
+#if defined(_IRR_WINDOWS_) && (defined(_UNICODE) || defined(UNICODE))
+#define _IRR_WCHAR_FILESYSTEM
+#endif
#ifdef NO_IRR_WCHAR_FILESYSTEM
#undef _IRR_WCHAR_FILESYSTEM
#endif
diff --git a/irrlicht/include/Keycodes.h b/irrlicht/include/Keycodes.h
index e56eca1..57ab312 100644
--- a/irrlicht/include/Keycodes.h
+++ b/irrlicht/include/Keycodes.h
@@ -89,7 +89,7 @@ namespace irr
KEY_KEY_X = 0x58, // X key
KEY_KEY_Y = 0x59, // Y key
KEY_KEY_Z = 0x5A, // Z key
- KEY_LWIN = 0x5B, // Left Windows key (Microsoft� Natural� keyboard)
+ KEY_LWIN = 0x5B, // Left Windows key (Microsoft® Natural® keyboard)
KEY_RWIN = 0x5C, // Right Windows key (Natural keyboard)
KEY_APPS = 0x5D, // Applications key (Natural keyboard)
KEY_SLEEP = 0x5F, // Computer Sleep key
diff --git a/irrlicht/include/irrTypes.h b/irrlicht/include/irrTypes.h
index cfeaf84..a656631 100644
--- a/irrlicht/include/irrTypes.h
+++ b/irrlicht/include/irrTypes.h
@@ -48,7 +48,9 @@ typedef __int16 s16;
typedef signed short s16;
#endif

-
+//! 16 bit character variable.
+/** This is a typedef for wchar_t, it ensures portability of the engine. */
+typedef wchar_t c16;

//! 32 bit unsigned variable.
/** This is a typedef for unsigned int, it ensures portability of the engine. */
diff --git a/irrlicht/src/CGUIEditBox.cpp b/irrlicht/src/CGUIEditBox.cpp
index f33b5a2..8375444 100644
--- a/irrlicht/src/CGUIEditBox.cpp
+++ b/irrlicht/src/CGUIEditBox.cpp
@@ -287,7 +287,7 @@ bool CGUIEditBox::processKey(const SEvent& event)
const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd;
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;

- core::stringc s;
+ core::stringw s;
s = Text.subString(realmbgn, realmend - realmbgn).c_str();
Operator->copyToClipboard(s.c_str());
}
@@ -300,7 +300,7 @@ bool CGUIEditBox::processKey(const SEvent& event)
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;

// copy
- core::stringc sc;
+ core::stringw sc;
sc = Text.subString(realmbgn, realmend - realmbgn).c_str();
Operator->copyToClipboard(sc.c_str());

@@ -330,16 +330,10 @@ bool CGUIEditBox::processKey(const SEvent& event)
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;

// add new character
- const c8* p = Operator->getTextFromClipboard();
+ const c16* p = Operator->getTextFromClipboard();
if (p)
{
- // TODO: we should have such a function in core::string
- size_t lenOld = strlen(p);
- wchar_t *ws = new wchar_t[lenOld + 1];
- size_t len = mbstowcs(ws,p,lenOld);
- ws[len] = 0;
- irr::core::stringw widep(ws);
- delete[] ws;
+ irr::core::stringw widep(p);

if (MarkBegin == MarkEnd)
{
diff --git a/irrlicht/src/CIrrDeviceWin32.cpp b/irrlicht/src/CIrrDeviceWin32.cpp
index f96c178..2e7a9ee 100644
--- a/irrlicht/src/CIrrDeviceWin32.cpp
+++ b/irrlicht/src/CIrrDeviceWin32.cpp
@@ -20,6 +20,8 @@
#include "COSOperator.h"
#include "dimension2d.h"
#include "IGUISpriteBank.h"
+#include "IGUIEnvironment.h"
+#include "IGUIElement.h"
#include <winuser.h>
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
#ifdef _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_
@@ -749,6 +751,26 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return 0;
}

+ {
+ dev = getDeviceFromHWnd(hWnd);
+ if (dev)
+ {
+ irr::gui::IGUIElement* ele = dev->getGUIEnvironment()->getFocus();
+ if (!ele || (ele->getType() != irr::gui::EGUIET_EDIT_BOX) || !ele->isEnabled())
+ {
+ HIMC hIMC = ImmGetContext(hWnd);
+ if (hIMC)
+ {
+ ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0);
+ ImmReleaseContext(hWnd, hIMC);
+ }
+ ImmAssociateContextEx(hWnd, NULL, 0);
+ }
+ else
+ ImmAssociateContextEx(hWnd, NULL, IACE_DEFAULT);
+ }
+ }
+
switch (message)
{
case WM_PAINT:
@@ -773,22 +795,21 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
event.KeyInput.Key = (irr::EKEY_CODE)wParam;
event.KeyInput.PressedDown = (message==WM_KEYDOWN || message == WM_SYSKEYDOWN);

- const UINT MY_MAPVK_VSC_TO_VK_EX = 3; // MAPVK_VSC_TO_VK_EX should be in SDK according to MSDN, but isn't in mine.
if ( event.KeyInput.Key == irr::KEY_SHIFT )
{
// this will fail on systems before windows NT/2000/XP, not sure _what_ will return there instead.
- event.KeyInput.Key = (irr::EKEY_CODE)MapVirtualKey( ((lParam>>16) & 255), MY_MAPVK_VSC_TO_VK_EX );
+ event.KeyInput.Key = (irr::EKEY_CODE)MapVirtualKey( ((lParam>>16) & 255), MAPVK_VSC_TO_VK_EX );
}
if ( event.KeyInput.Key == irr::KEY_CONTROL )
{
- event.KeyInput.Key = (irr::EKEY_CODE)MapVirtualKey( ((lParam>>16) & 255), MY_MAPVK_VSC_TO_VK_EX );
+ event.KeyInput.Key = (irr::EKEY_CODE)MapVirtualKey( ((lParam>>16) & 255), MAPVK_VSC_TO_VK_EX );
// some keyboards will just return LEFT for both - left and right keys. So also check extend bit.
if (lParam & 0x1000000)
event.KeyInput.Key = irr::KEY_RCONTROL;
}
if ( event.KeyInput.Key == irr::KEY_MENU )
{
- event.KeyInput.Key = (irr::EKEY_CODE)MapVirtualKey( ((lParam>>16) & 255), MY_MAPVK_VSC_TO_VK_EX );
+ event.KeyInput.Key = (irr::EKEY_CODE)MapVirtualKey( ((lParam>>16) & 255), MAPVK_VSC_TO_VK_EX );
if (lParam & 0x1000000)
event.KeyInput.Key = irr::KEY_RMENU;
}
@@ -904,6 +925,53 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
KEYBOARD_INPUT_HKL = GetKeyboardLayout(0);
KEYBOARD_INPUT_CODEPAGE = LocaleIdToCodepage( LOWORD(KEYBOARD_INPUT_HKL) );
return 0;
+
+ case WM_IME_STARTCOMPOSITION:
+ {
+ dev = getDeviceFromHWnd(hWnd);
+ irr::gui::IGUIElement* ele = dev->getGUIEnvironment()->getFocus();
+ if (!ele)
+ break;
+ irr::core::position2di pos = ele->getAbsolutePosition().UpperLeftCorner;
+ COMPOSITIONFORM CompForm = { CFS_POINT, { pos.X, pos.Y + ele->getAbsolutePosition().getHeight() } };
+ HIMC hIMC = ImmGetContext(hWnd);
+ ImmSetCompositionWindow(hIMC, &CompForm);
+ ImmReleaseContext(hWnd, hIMC);
+ }
+ break;
+
+ case WM_IME_CHAR:
+ event.EventType = irr::EET_KEY_INPUT_EVENT;
+ event.KeyInput.PressedDown = true;
+#ifdef _UNICODE
+ event.KeyInput.Char = wParam;
+#else
+ BYTE ch[3];
+ if(wParam >> 8) {
+ ch[0] = wParam >> 8;
+ ch[1] = wParam & 0xff;
+ ch[2] = 0;
+ } else {
+ ch[0] = wParam;
+ ch[1] = 0;
+ }
+ WORD unicodeChar;
+ MultiByteToWideChar(
+ KEYBOARD_INPUT_CODEPAGE,
+ MB_PRECOMPOSED, // default
+ (LPCSTR)ch,
+ sizeof(wParam),
+ (WCHAR*)&unicodeChar,
+ 1);
+ event.KeyInput.Char = unicodeChar;
+#endif
+ event.KeyInput.Key = irr::KEY_ACCEPT;
+ event.KeyInput.Shift = 0;
+ event.KeyInput.Control = 0;
+ dev = getDeviceFromHWnd(hWnd);
+ if (dev)
+ dev->postEventFromUser(event);
+ return 0;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
@@ -1797,8 +1865,8 @@ void CIrrDeviceWin32::handleSystemMessages()

while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
- // No message translation because we don't use WM_CHAR and it would conflict with our
- // deadkey handling.
+ // conflict with deadkey handling.
+ TranslateMessage(&msg);

if (ExternalWindow && msg.hwnd == HWnd)
WndProc(HWnd, msg.message, msg.wParam, msg.lParam);
diff --git a/irrlicht/src/COSOperator.cpp b/irrlicht/src/COSOperator.cpp
index 90e644d..1856c04 100644
--- a/irrlicht/src/COSOperator.cpp
+++ b/irrlicht/src/COSOperator.cpp
@@ -52,9 +52,9 @@ const core::stringc& COSOperator::getOperatingSystemVersion() const


//! copies text to the clipboard
-void COSOperator::copyToClipboard(const c8* text) const
+void COSOperator::copyToClipboard(const c16* text) const
{
- if (strlen(text)==0)
+ if (wcslen(text)==0)
return;

// Windows version
@@ -66,15 +66,15 @@ void COSOperator::copyToClipboard(const c8* text) const
EmptyClipboard();

HGLOBAL clipbuffer;
- char * buffer;
+ wchar_t * buffer;

- clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(text)+1);
- buffer = (char*)GlobalLock(clipbuffer);
+ clipbuffer = GlobalAlloc(GMEM_DDESHARE, sizeof(wchar_t) * (wcslen(text) + 1));
+ buffer = (wchar_t*)GlobalLock(clipbuffer);

- strcpy(buffer, text);
+ wcscpy(buffer, text);

GlobalUnlock(clipbuffer);
- SetClipboardData(CF_TEXT, clipbuffer);
+ SetClipboardData(CF_UNICODETEXT, clipbuffer);
CloseClipboard();

// MacOSX version
@@ -93,7 +93,7 @@ void COSOperator::copyToClipboard(const c8* text) const

//! gets text from the clipboard
//! \return Returns 0 if no string is in there.
-const c8* COSOperator::getTextFromClipboard() const
+const c16* COSOperator::getTextFromClipboard() const
{
#if defined(_IRR_XBOX_PLATFORM_)
return 0;
@@ -101,10 +101,10 @@ const c8* COSOperator::getTextFromClipboard() const
if (!OpenClipboard(NULL))
return 0;

- char * buffer = 0;
+ wchar_t * buffer = 0;

- HANDLE hData = GetClipboardData( CF_TEXT );
- buffer = (char*)GlobalLock( hData );
+ HANDLE hData = GetClipboardData( CF_UNICODETEXT );
+ buffer = (wchar_t*)GlobalLock( hData );
GlobalUnlock( hData );
CloseClipboard();
return buffer;
diff --git a/irrlicht/src/COSOperator.h b/irrlicht/src/COSOperator.h
index 3f633da..c0712df 100644
--- a/irrlicht/src/COSOperator.h
+++ b/irrlicht/src/COSOperator.h
@@ -27,11 +27,11 @@ public:
virtual const core::stringc& getOperatingSystemVersion() const;

//! copies text to the clipboard
- virtual void copyToClipboard(const c8* text) const;
+ virtual void copyToClipboard(const c16* text) const;

//! gets text from the clipboard
//! \return Returns 0 if no string is in there.
- virtual const c8* getTextFromClipboard() const;
+ virtual const c16* getTextFromClipboard() const;

//! gets the processor speed in megahertz
//! \param Mhz:
patch -p1 < irrlicht\irrlicht.patch

根据 irrlicht 的 vcxproj,得到如下 premake5.lua,放到 irrlicht 文件夹里。

project "Irrlicht"
kind "StaticLib"

includedirs { "include", "src", "src/jpeglib", "src/libpng", "src/zlib" }

defines { "_IRR_STATIC_LIB_" }
exceptionhandling "Off"
rtti "Off"

files { "src/CCgMaterialRenderer.cpp",
"src/CD3D9CgMaterialRenderer.cpp",
"src/CDefaultSceneNodeAnimatorFactory.cpp",
"src/CDefaultSceneNodeFactory.cpp",
"src/CGeometryCreator.cpp",
"src/CMeshCache.cpp",
"src/CMeshManipulator.cpp",
"src/COpenGLCgMaterialRenderer.cpp",
"src/CSceneManager.cpp",
"src/C3DSMeshFileLoader.cpp",
"src/CSMFMeshFileLoader.cpp",
"src/CAnimatedMeshHalfLife.cpp",
"src/CAnimatedMeshMD2.cpp",
"src/CAnimatedMeshMD3.cpp",
"src/CB3DMeshFileLoader.cpp",
"src/CBSPMeshFileLoader.cpp",
"src/CColladaFileLoader.cpp",
"src/CCSMLoader.cpp",
"src/CDMFLoader.cpp",
"src/CIrrMeshFileLoader.cpp",
"src/CLMTSMeshFileLoader.cpp",
"src/CLWOMeshFileLoader.cpp",
"src/CMD2MeshFileLoader.cpp",
"src/CMD3MeshFileLoader.cpp",
"src/CMS3DMeshFileLoader.cpp",
"src/CMY3DMeshFileLoader.cpp",
"src/COBJMeshFileLoader.cpp",
"src/COCTLoader.cpp",
"src/COgreMeshFileLoader.cpp",
"src/CPLYMeshFileLoader.cpp",
"src/CQ3LevelMesh.cpp",
"src/CSkinnedMesh.cpp",
"src/CSTLMeshFileLoader.cpp",
"src/CXMeshFileLoader.cpp",
"src/CAnimatedMeshSceneNode.cpp",
"src/CBillboardSceneNode.cpp",
"src/CBoneSceneNode.cpp",
"src/CCameraSceneNode.cpp",
"src/CCubeSceneNode.cpp",
"src/CDummyTransformationSceneNode.cpp",
"src/CEmptySceneNode.cpp",
"src/CLightSceneNode.cpp",
"src/CMeshSceneNode.cpp",
"src/COctreeSceneNode.cpp",
"src/CQuake3ShaderSceneNode.cpp",
"src/CShadowVolumeSceneNode.cpp",
"src/CSkyBoxSceneNode.cpp",
"src/CSkyDomeSceneNode.cpp",
"src/CSphereSceneNode.cpp",
"src/CTerrainSceneNode.cpp",
"src/CTextSceneNode.cpp",
"src/CVolumeLightSceneNode.cpp",
"src/CWaterSurfaceSceneNode.cpp",
"src/CParticleAnimatedMeshSceneNodeEmitter.cpp",
"src/CParticleAttractionAffector.cpp",
"src/CParticleBoxEmitter.cpp",
"src/CParticleCylinderEmitter.cpp",
"src/CParticleFadeOutAffector.cpp",
"src/CParticleGravityAffector.cpp",
"src/CParticleMeshEmitter.cpp",
"src/CParticlePointEmitter.cpp",
"src/CParticleRingEmitter.cpp",
"src/CParticleRotationAffector.cpp",
"src/CParticleScaleAffector.cpp",
"src/CParticleSphereEmitter.cpp",
"src/CParticleSystemSceneNode.cpp",
"src/CMetaTriangleSelector.cpp",
"src/COctreeTriangleSelector.cpp",
"src/CSceneCollisionManager.cpp",
"src/CTerrainTriangleSelector.cpp",
"src/CTriangleBBSelector.cpp",
"src/CTriangleSelector.cpp",
"src/CSceneLoaderIrr.cpp",
"src/CSceneNodeAnimatorCameraFPS.cpp",
"src/CSceneNodeAnimatorCameraMaya.cpp",
"src/CSceneNodeAnimatorCollisionResponse.cpp",
"src/CSceneNodeAnimatorDelete.cpp",
"src/CSceneNodeAnimatorFlyCircle.cpp",
"src/CSceneNodeAnimatorFlyStraight.cpp",
"src/CSceneNodeAnimatorFollowSpline.cpp",
"src/CSceneNodeAnimatorRotation.cpp",
"src/CSceneNodeAnimatorTexture.cpp",
"src/CColladaMeshWriter.cpp",
"src/CIrrMeshWriter.cpp",
"src/COBJMeshWriter.cpp",
"src/CPLYMeshWriter.cpp",
"src/CSTLMeshWriter.cpp",
"src/CVideoModeList.cpp",
"src/CSoftwareDriver.cpp",
"src/CSoftwareTexture.cpp",
"src/CTRFlat.cpp",
"src/CTRFlatWire.cpp",
"src/CTRGouraud.cpp",
"src/CTRGouraudWire.cpp",
"src/CTRTextureFlat.cpp",
"src/CTRTextureFlatWire.cpp",
"src/CTRTextureGouraud.cpp",
"src/CTRTextureGouraudAdd.cpp",
"src/CTRTextureGouraudNoZ.cpp",
"src/CTRTextureGouraudWire.cpp",
"src/CZBuffer.cpp",
"src/COpenGLDriver.cpp",
"src/COpenGLExtensionHandler.cpp",
"src/COpenGLNormalMapRenderer.cpp",
"src/COpenGLParallaxMapRenderer.cpp",
"src/COpenGLShaderMaterialRenderer.cpp",
"src/COpenGLSLMaterialRenderer.cpp",
"src/COpenGLTexture.cpp",
"src/CD3D8Driver.cpp",
"src/CD3D8NormalMapRenderer.cpp",
"src/CD3D8ParallaxMapRenderer.cpp",
"src/CD3D8ShaderMaterialRenderer.cpp",
"src/CD3D8Texture.cpp",
"src/CColorConverter.cpp",
"src/CFPSCounter.cpp",
"src/CImage.cpp",
"src/CNullDriver.cpp",
"src/CImageWriterBMP.cpp",
"src/CImageWriterJPG.cpp",
"src/CImageWriterPCX.cpp",
"src/CImageWriterPNG.cpp",
"src/CImageWriterPPM.cpp",
"src/CImageWriterPSD.cpp",
"src/CImageWriterTGA.cpp",
"src/CImageLoaderBMP.cpp",
"src/CImageLoaderDDS.cpp",
"src/CImageLoaderJPG.cpp",
"src/CImageLoaderPCX.cpp",
"src/CImageLoaderPNG.cpp",
"src/CImageLoaderPPM.cpp",
"src/CImageLoaderPSD.cpp",
"src/CImageLoaderRGB.cpp",
"src/CImageLoaderTGA.cpp",
"src/CImageLoaderWAL.cpp",
"src/CD3D9Driver.cpp",
"src/CD3D9HLSLMaterialRenderer.cpp",
"src/CD3D9NormalMapRenderer.cpp",
"src/CD3D9ParallaxMapRenderer.cpp",
"src/CD3D9ShaderMaterialRenderer.cpp",
"src/CD3D9Texture.cpp",
"src/CBurningShader_Raster_Reference.cpp",
"src/CDepthBuffer.cpp",
"src/CSoftwareDriver2.cpp",
"src/CSoftwareTexture2.cpp",
"src/CTRGouraud2.cpp",
"src/CTRGouraudAlpha2.cpp",
"src/CTRGouraudAlphaNoZ2.cpp",
"src/CTRNormalMap.cpp",
"src/CTRStencilShadow.cpp",
"src/CTRTextureBlend.cpp",
"src/CTRTextureDetailMap2.cpp",
"src/CTRTextureGouraud2.cpp",
"src/CTRTextureGouraudAdd2.cpp",
"src/CTRTextureGouraudAddNoZ2.cpp",
"src/CTRTextureGouraudAlpha.cpp",
"src/CTRTextureGouraudAlphaNoZ.cpp",
"src/CTRTextureGouraudNoZ2.cpp",
"src/CTRTextureGouraudVertexAlpha2.cpp",
"src/CTRTextureLightMap2_Add.cpp",
"src/CTRTextureLightMap2_M1.cpp",
"src/CTRTextureLightMap2_M2.cpp",
"src/CTRTextureLightMap2_M4.cpp",
"src/CTRTextureLightMapGouraud2_M4.cpp",
"src/CTRTextureWire2.cpp",
"src/IBurningShader.cpp",
"src/CLogger.cpp",
"src/COSOperator.cpp",
"src/Irrlicht.cpp",
"src/os.cpp",
"src/lzma/LzmaDec.c",
"src/zlib/adler32.c",
"src/zlib/compress.c",
"src/zlib/crc32.c",
"src/zlib/deflate.c",
"src/zlib/inffast.c",
"src/zlib/inflate.c",
"src/zlib/inftrees.c",
"src/zlib/trees.c",
"src/zlib/uncompr.c",
"src/zlib/zutil.c",
"src/jpeglib/jaricom.c",
"src/jpeglib/jcapimin.c",
"src/jpeglib/jcapistd.c",
"src/jpeglib/jcarith.c",
"src/jpeglib/jccoefct.c",
"src/jpeglib/jccolor.c",
"src/jpeglib/jcdctmgr.c",
"src/jpeglib/jchuff.c",
"src/jpeglib/jcinit.c",
"src/jpeglib/jcmainct.c",
"src/jpeglib/jcmarker.c",
"src/jpeglib/jcmaster.c",
"src/jpeglib/jcomapi.c",
"src/jpeglib/jcparam.c",
"src/jpeglib/jcprepct.c",
"src/jpeglib/jcsample.c",
"src/jpeglib/jctrans.c",
"src/jpeglib/jdapimin.c",
"src/jpeglib/jdapistd.c",
"src/jpeglib/jdarith.c",
"src/jpeglib/jdatadst.c",
"src/jpeglib/jdatasrc.c",
"src/jpeglib/jdcoefct.c",
"src/jpeglib/jdcolor.c",
"src/jpeglib/jddctmgr.c",
"src/jpeglib/jdhuff.c",
"src/jpeglib/jdinput.c",
"src/jpeglib/jdmainct.c",
"src/jpeglib/jdmarker.c",
"src/jpeglib/jdmaster.c",
"src/jpeglib/jdmerge.c",
"src/jpeglib/jdpostct.c",
"src/jpeglib/jdsample.c",
"src/jpeglib/jdtrans.c",
"src/jpeglib/jerror.c",
"src/jpeglib/jfdctflt.c",
"src/jpeglib/jfdctfst.c",
"src/jpeglib/jfdctint.c",
"src/jpeglib/jidctflt.c",
"src/jpeglib/jidctfst.c",
"src/jpeglib/jidctint.c",
"src/jpeglib/jmemmgr.c",
"src/jpeglib/jmemnobs.c",
"src/jpeglib/jquant1.c",
"src/jpeglib/jquant2.c",
"src/jpeglib/jutils.c",
"src/libpng/png.c",
"src/libpng/pngerror.c",
"src/libpng/pngget.c",
"src/libpng/pngmem.c",
"src/libpng/pngpread.c",
"src/libpng/pngread.c",
"src/libpng/pngrio.c",
"src/libpng/pngrtran.c",
"src/libpng/pngrutil.c",
"src/libpng/pngset.c",
"src/libpng/pngtrans.c",
"src/libpng/pngwio.c",
"src/libpng/pngwrite.c",
"src/libpng/pngwtran.c",
"src/libpng/pngwutil.c",
"src/aesGladman/aescrypt.cpp",
"src/aesGladman/aeskey.cpp",
"src/aesGladman/aestab.cpp",
"src/aesGladman/fileenc.cpp",
"src/aesGladman/hmac.cpp",
"src/aesGladman/prng.cpp",
"src/aesGladman/pwd2key.cpp",
"src/aesGladman/sha1.cpp",
"src/aesGladman/sha2.cpp",
"src/bzip2/blocksort.c",
"src/bzip2/bzcompress.c",
"src/bzip2/bzlib.c",
"src/bzip2/crctable.c",
"src/bzip2/decompress.c",
"src/bzip2/huffman.c",
"src/bzip2/randtable.c",
"src/CIrrDeviceConsole.cpp",
"src/CIrrDeviceFB.cpp",
"src/CIrrDeviceLinux.cpp",
"src/CIrrDeviceSDL.cpp",
"src/CIrrDeviceStub.cpp",
"src/CIrrDeviceWin32.cpp",
"src/CIrrDeviceWinCE.cpp",
"src/CAttributes.cpp",
"src/CFileList.cpp",
"src/CFileSystem.cpp",
"src/CLimitReadFile.cpp",
"src/CMemoryFile.cpp",
"src/CMountPointReader.cpp",
"src/CNPKReader.cpp",
"src/CPakReader.cpp",
"src/CReadFile.cpp",
"src/CTarReader.cpp",
"src/CWADReader.cpp",
"src/CWriteFile.cpp",
"src/CXMLReader.cpp",
"src/CXMLWriter.cpp",
"src/CZipReader.cpp",
"src/irrXML.cpp",
"src/CDefaultGUIElementFactory.cpp",
"src/CGUIButton.cpp",
"src/CGUICheckbox.cpp",
"src/CGUIColorSelectDialog.cpp",
"src/CGUIComboBox.cpp",
"src/CGUIContextMenu.cpp",
"src/CGUIEditBox.cpp",
"src/CGUIEnvironment.cpp",
"src/CGUIFileOpenDialog.cpp",
"src/CGUIFont.cpp",
"src/CGUIImage.cpp",
"src/CGUIImageList.cpp",
"src/CGUIInOutFader.cpp",
"src/CGUIListBox.cpp",
"src/CGUIMenu.cpp",
"src/CGUIMeshViewer.cpp",
"src/CGUIMessageBox.cpp",
"src/CGUIModalScreen.cpp",
"src/CGUIScrollBar.cpp",
"src/CGUISkin.cpp",
"src/CGUISpinBox.cpp",
"src/CGUISpriteBank.cpp",
"src/CGUIStaticText.cpp",
"src/CGUITabControl.cpp",
"src/CGUITable.cpp",
"src/CGUIToolBar.cpp",
"src/CGUITreeView.cpp",
"src/CGUIWindow.cpp" }

configuration { "vs*" }
includedirs { "$(DXSDK_DIR)include" }
libdirs { "$(DXSDK_DIR)Lib/x86" }

configuration { "windows" }
links { "imm32" }

5. 配置 Lua

解压 lua-5.2.4.tar.gz 到项目目录,将文件夹重命名为 lua
为兼容 YGOPro 源码,将 src 文件夹里除 Makefile 外的文件全部移动到 lua 文件夹。
Lua 源码的文件结构非常简单,直接把如下 premake4.lua 放到 lua 文件夹里即可。

project "lua"
kind "StaticLib"

files { "*.c", "*.h" }
removefiles { "luac.c" }

6. 配置 SQLite

解压 sqlite-amalgamation-3170000.zip 到项目目录,将文件夹重命名为 sqlite3
SQLite 源码的文件结构非常简单,直接把如下 premake4.lua 放到 sqlite3 文件夹里即可。

project "sqlite3"
kind "StaticLib"

files { "sqlite3.c", "sqlite3.h" }

7. 生成解决方案

在生成解决方案之前,我们还需要对 premake 做几个设置。
打开项目目录中的 premake4.lua,将其改为如下 premake5.lua

solution "ygo"
location "build"
language "C++"
objdir "obj"

configurations { "Debug", "Release" }

configuration "windows"
defines { "WIN32", "_WIN32", "WINVER=0x0501" }

configuration "bsd"
defines { "LUA_USE_POSIX" }
includedirs { "/usr/local/include" }
libdirs { "/usr/local/lib" }

configuration "macosx"
defines { "LUA_USE_MACOSX" }
includedirs { "/usr/local/include/*" }
libdirs { "/usr/local/lib", "/usr/X11/lib" }
buildoptions { "-stdlib=libc++" }
links { "OpenGL.framework", "Cocoa.framework", "IOKit.framework" }

configuration "linux"
defines { "LUA_USE_LINUX" }

configuration "Release"
flags { "OptimizeSpeed" }
targetdir "bin/release"

configuration "Debug"
symbols "On"
defines "_DEBUG"
targetdir "bin/debug"

configuration { "Release", "vs*" }
flags { "StaticRuntime", "LinkTimeOptimization" }
disablewarnings { "4244", "4267", "4838", "4577", "4819", "4018", "4996", "4477" }

configuration { "Release", "not vs*" }
symbols "On"
defines "NDEBUG"
buildoptions "-march=native"

configuration { "Debug", "vs*" }
defines { "_ITERATOR_DEBUG_LEVEL=0" }

configuration "vs*"
flags "EnableSSE2"
defines { "_CRT_SECURE_NO_WARNINGS" }

configuration "not vs*"
buildoptions { "-fno-strict-aliasing", "-Wno-multichar" }

configuration {"not vs*", "windows"}
buildoptions { "-static-libgcc" }

startproject "ygopro"

include "ocgcore"
include "gframe"
if os.is("windows") then
include "event"
include "freetype"
include "irrlicht"
include "lua"
include "sqlite3"
end

解压 premake-5.0.0-alpha11-windows.zip 到项目目录。
运行 premake5 vs2015 即可在 build 文件夹内生成sln文件。
程序还需要一个资源文件,把如下 ygopro.rcygopro.ico 放到 gframe 文件夹里。

1 ICON "ygopro.ico"

1 VERSIONINFO
FILEVERSION 1, 0, 33, 13
PRODUCTVERSION 1, 0, 33, 13
FILEOS 0x4
FILETYPE 0x1

BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080404b0"
BEGIN
VALUE "FileDescription", "YGOPro"
VALUE "InternalName", "YGOPro"
VALUE "LegalCopyright", "Copyright (C) 2017 Fluorohydride"
VALUE "OriginalFilename", "ygopro.exe"
VALUE "ProductName", "YGOPro"
VALUE "FileVersion", "1.033.D.233"
VALUE "ProductVersion", "1.033.D.233"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x804, 1200
END
END

8. 选项设置

完成了以上步骤后,我们的 ygo 项目已经可以用 VS2015 打开并编译了。
如需要程序支持XP,在 ygopro 的属性中将 平台工具集 设置为 Visual Studio 2015 - Windows XP (v140_xp)
别忘记把 解决方案配置 改成 Release