From 7c035c63ed464c9c1ec732391c9c62cab447cb43 Mon Sep 17 00:00:00 2001 From: Nomango <569629550@qq.com> Date: Sat, 9 Dec 2017 15:51:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E4=BA=86EApp::init=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E7=9A=84=E4=B8=80=E4=B8=AA=E9=87=8D=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Easy2D/Base/EApp.cpp | 24 ++++++++++++------------ Easy2D/Easy2D.vcxproj | 6 +++--- Easy2D/Easy2D.vcxproj.filters | 21 ++++++++++++--------- Easy2D/{Common => Msg}/EKeyboardMsg.cpp | 0 Easy2D/{Common => Msg}/EMouseMsg.cpp | 0 Easy2D/{Common => Msg}/EPhysicsMsg.cpp | 0 Easy2D/ebase.h | 14 +++++--------- 7 files changed, 32 insertions(+), 33 deletions(-) rename Easy2D/{Common => Msg}/EKeyboardMsg.cpp (100%) rename Easy2D/{Common => Msg}/EMouseMsg.cpp (100%) rename Easy2D/{Common => Msg}/EPhysicsMsg.cpp (100%) diff --git a/Easy2D/Base/EApp.cpp b/Easy2D/Base/EApp.cpp index a7540dcf..ef2d431e 100644 --- a/Easy2D/Base/EApp.cpp +++ b/Easy2D/Base/EApp.cpp @@ -25,7 +25,6 @@ e2d::EApp::EApp() : m_bEnd(false) , m_bPaused(false) , m_bManualPaused(false) - , m_bTopMost(false) , m_bShowConsole(false) , m_nAnimationInterval(17LL) , m_ClearColor(EColor::BLACK) @@ -53,17 +52,17 @@ e2d::EApp * e2d::EApp::getInstance() return s_pInstance; // 获取 EApp 的唯一实例 } -bool e2d::EApp::init(const EString &title, UINT32 width, UINT32 height) -{ - return init(title, width, height, EWindowStyle()); -} - -bool e2d::EApp::init(const EString &title, UINT32 width, UINT32 height, EWindowStyle wStyle) +bool e2d::EApp::init(const EString &title, UINT32 width, UINT32 height, const EWindowStyle &wStyle /* = nullptr */) { CoInitialize(NULL); HRESULT hr; + // 保存窗口样式 + EApp::getInstance()->m_WindowStyle = wStyle; + // 保存窗口名称 + EApp::getInstance()->m_sTitle = title; + // 注册窗口类 WNDCLASSEX wcex = { sizeof(WNDCLASSEX) }; wcex.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; @@ -119,10 +118,6 @@ bool e2d::EApp::init(const EString &title, UINT32 width, UINT32 height, EWindowS { dwStyle |= WS_MINIMIZEBOX; } - // 保存窗口是否置顶显示 - EApp::getInstance()->m_bTopMost = wStyle.m_bTopMost; - // 保存窗口名称 - EApp::getInstance()->m_sTitle = title; // 创建窗口 GetHWnd() = CreateWindow( L"Easy2DApp", @@ -177,7 +172,7 @@ int e2d::EApp::run() ShowWindow(GetHWnd(), SW_SHOWNORMAL); UpdateWindow(GetHWnd()); // 设置窗口置顶 - if (pApp->m_bTopMost) + if (pApp->m_WindowStyle.m_bTopMost) { SetWindowPos(GetHWnd(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } @@ -566,6 +561,11 @@ HWND e2d::EApp::getHWnd() return GetHWnd(); } +e2d::EWindowStyle e2d::EApp::getWindowStyle() +{ + return getInstance()->m_WindowStyle; +} + LONGLONG e2d::EApp::getTotalDurationFromStart() { return GetInterval(s_tStart); diff --git a/Easy2D/Easy2D.vcxproj b/Easy2D/Easy2D.vcxproj index d7c5eab3..eeec2dec 100644 --- a/Easy2D/Easy2D.vcxproj +++ b/Easy2D/Easy2D.vcxproj @@ -210,10 +210,7 @@ - - - @@ -235,6 +232,9 @@ + + + diff --git a/Easy2D/Easy2D.vcxproj.filters b/Easy2D/Easy2D.vcxproj.filters index fc324afd..a603ca5d 100644 --- a/Easy2D/Easy2D.vcxproj.filters +++ b/Easy2D/Easy2D.vcxproj.filters @@ -31,6 +31,9 @@ {be5d9314-b00a-4f11-bd2a-1f720dc32407} + + {3c524aef-fb91-4f44-a3dc-bff34de229eb} + @@ -153,12 +156,6 @@ Geometry - - Common - - - Common - Manager @@ -204,9 +201,6 @@ Node - - Common - Common @@ -216,6 +210,15 @@ Transition + + Msg + + + Msg + + + Msg + diff --git a/Easy2D/Common/EKeyboardMsg.cpp b/Easy2D/Msg/EKeyboardMsg.cpp similarity index 100% rename from Easy2D/Common/EKeyboardMsg.cpp rename to Easy2D/Msg/EKeyboardMsg.cpp diff --git a/Easy2D/Common/EMouseMsg.cpp b/Easy2D/Msg/EMouseMsg.cpp similarity index 100% rename from Easy2D/Common/EMouseMsg.cpp rename to Easy2D/Msg/EMouseMsg.cpp diff --git a/Easy2D/Common/EPhysicsMsg.cpp b/Easy2D/Msg/EPhysicsMsg.cpp similarity index 100% rename from Easy2D/Common/EPhysicsMsg.cpp rename to Easy2D/Msg/EPhysicsMsg.cpp diff --git a/Easy2D/ebase.h b/Easy2D/ebase.h index 9097db9b..a9bc132c 100644 --- a/Easy2D/ebase.h +++ b/Easy2D/ebase.h @@ -22,19 +22,12 @@ public: // 获取程序实例 static EApp * getInstance(); - // 初始化游戏界面 - static bool init( - const EString &title, /* 窗口标题 */ - UINT32 width, /* 窗口宽度 */ - UINT32 height /* 窗口高度 */ - ); - // 初始化游戏界面 static bool init( const EString &title, /* 窗口标题 */ UINT32 width, /* 窗口宽度 */ UINT32 height, /* 窗口高度 */ - EWindowStyle wStyle /* 窗口样式 */ + const EWindowStyle &wStyle = nullptr /* 窗口样式 */ ); // 启动程序 @@ -96,6 +89,9 @@ public: // 获取窗口句柄 static HWND getHWnd(); + // 获取窗口样式 + static EWindowStyle getWindowStyle(); + // 获取从游戏开始到当前经过的毫秒数 static LONGLONG getTotalDurationFromStart(); @@ -175,7 +171,6 @@ private: bool m_bEnd; bool m_bPaused; bool m_bManualPaused; - bool m_bTopMost; bool m_bShowConsole; EString m_sTitle; EString m_sAppName; @@ -183,6 +178,7 @@ private: LONGLONG m_nAnimationInterval; EScene * m_pCurrentScene; EScene * m_pNextScene; + EWindowStyle m_WindowStyle; ETransition * m_pTransition; };