From 1cb880a66e12f6f81f9d4ce23d925c95be802302 Mon Sep 17 00:00:00 2001 From: dean11 Date: Wed, 4 Dec 2013 15:59:44 +0100 Subject: [PATCH] GameLogic - Fixed the window class --- Code/DanBias.sln | 3 - Code/Game/DanBiasLauncher/Launcher.cpp | 4 +- Code/WindowManager/Example Usage.cpp | 41 ++++--------- Code/WindowManager/WindowManager.vcxproj | 16 +++-- .../WindowManager.vcxproj.filters | 10 ++++ Code/WindowManager/WindowShell.cpp | 21 +++---- Code/WindowManager/WindowShell.h | 59 +++++-------------- 7 files changed, 62 insertions(+), 92 deletions(-) diff --git a/Code/DanBias.sln b/Code/DanBias.sln index c5ca25f8..4b9ec79f 100644 --- a/Code/DanBias.sln +++ b/Code/DanBias.sln @@ -249,7 +249,4 @@ Global {52380DAA-0F4A-4D97-8E57-98DF39319CAF} = {20720CA7-795C-45AD-A302-9383A6DD503A} {8690FDDF-C5B7-4C42-A337-BD5243F29B85} = {20720CA7-795C-45AD-A302-9383A6DD503A} EndGlobalSection - GlobalSection(Performance) = preSolution - HasPerformanceSessions = true - EndGlobalSection EndGlobal diff --git a/Code/Game/DanBiasLauncher/Launcher.cpp b/Code/Game/DanBiasLauncher/Launcher.cpp index 0440d973..28b89485 100644 --- a/Code/Game/DanBiasLauncher/Launcher.cpp +++ b/Code/Game/DanBiasLauncher/Launcher.cpp @@ -4,8 +4,8 @@ #define NOMINMAX #include -//#define DANBIAS_SERVER -#define DANBIAS_CLIENT +#define DANBIAS_SERVER +//#define DANBIAS_CLIENT #if defined(DANBIAS_SERVER) diff --git a/Code/WindowManager/Example Usage.cpp b/Code/WindowManager/Example Usage.cpp index b9f46550..5b21c953 100644 --- a/Code/WindowManager/Example Usage.cpp +++ b/Code/WindowManager/Example Usage.cpp @@ -34,8 +34,14 @@ WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ((MINMAXINFO*)lParam)->ptMinTrackSize.y = 100; break; + case WM_KEYDOWN: + if(wParam == VK_ESCAPE) + PostQuitMessage(0); + break; + default: return DefWindowProc(hwnd, msg, wParam, lParam); + } return 0; } @@ -84,39 +90,18 @@ int WINAPI WinMain( HINSTANCE hInst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh { _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); - - /******************************************** * Description of a window * *******************************************/ - WindowShell::INIT_DESC_WINDOW wDesc; - wDesc.hInstance = hInst; - wDesc.windowName = L"Glare"; - wDesc.windowPosition = Point2D(50); - wDesc.windowSize = Point2D(1024, 800); + WindowShell::WINDOW_INIT_DESC wDesc; + //wDesc.hInstance = hInst; + wDesc.windowPosition.x = 50; + wDesc.windowPosition.y = 50; + wDesc.windowSize.x = 1024; + wDesc.windowSize.x = 800; wDesc.windowProcCallback = WndProc; - - -/******************************************** - * Description of a child window * - *******************************************/ - WindowShell::INIT_DESC_CHILD_WINDOW cDesc; - cDesc.name = L"Child"; - cDesc.style = WS_EX_RIGHTSCROLLBAR; - cDesc.topLeftPos = Point2D(); - cDesc.windowProcCallback = ChildWndProc; - cDesc.windowSize = Point2D(80); - - - -/************************************************************ - * Initializing main window and several children * - ************************************************************/ WindowShell::self()->createWin(wDesc); - WindowShell::self()->createChildWin(cDesc); - WindowShell::self()->createChildWin(cDesc); - WindowShell::self()->createChildWin(cDesc); @@ -134,7 +119,7 @@ int WINAPI WinMain( HINSTANCE hInst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh } else { - + } } diff --git a/Code/WindowManager/WindowManager.vcxproj b/Code/WindowManager/WindowManager.vcxproj index 1a193450..0acba3ad 100644 --- a/Code/WindowManager/WindowManager.vcxproj +++ b/Code/WindowManager/WindowManager.vcxproj @@ -24,30 +24,30 @@ - Application + StaticLibrary true v110 - MultiByte + Unicode - Application + StaticLibrary true v110 - MultiByte + Unicode StaticLibrary false v110 true - MultiByte + Unicode StaticLibrary false v110 true - MultiByte + Unicode @@ -138,6 +138,10 @@ + + + + diff --git a/Code/WindowManager/WindowManager.vcxproj.filters b/Code/WindowManager/WindowManager.vcxproj.filters index d7ef6a1a..a8263606 100644 --- a/Code/WindowManager/WindowManager.vcxproj.filters +++ b/Code/WindowManager/WindowManager.vcxproj.filters @@ -14,4 +14,14 @@ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + Source Files + + + + + Header Files + + \ No newline at end of file diff --git a/Code/WindowManager/WindowShell.cpp b/Code/WindowManager/WindowShell.cpp index 836a350c..7f8e1481 100644 --- a/Code/WindowManager/WindowShell.cpp +++ b/Code/WindowManager/WindowShell.cpp @@ -56,7 +56,7 @@ WindowShell::~WindowShell() -bool WindowShell::createWin(INIT_DESC_WINDOW &desc) +bool WindowShell::createWin(WINDOW_INIT_DESC &desc) { if(pData->hWnd) { @@ -68,14 +68,15 @@ bool WindowShell::createWin(INIT_DESC_WINDOW &desc) MessageBox(0, L"No callback function for window messages was found!" ,L"Error", 0); return false; } - if(!desc.hInstance) - { - MessageBox(0, L"No HINSTANCE was specified!" ,L"Error", 0); - return false; - } - if(desc.windowSize < 0) + if(desc.windowSize.x < 0 || desc.windowSize.y < 0) { MessageBox(0, L"Size specified for window is invalid!" ,L"Error", 0); + return false; + } + + if(!desc.hInstance) + { + desc.hInstance = GetModuleHandle(0); } @@ -87,7 +88,7 @@ bool WindowShell::createWin(INIT_DESC_WINDOW &desc) WNDCLASSEX wc; wc.cbSize = sizeof(WNDCLASSEX); wc.hIconSm = NULL; - wc.style = CS_HREDRAW | CS_VREDRAW; + wc.style = desc.windowClassStyle; wc.lpfnWndProc = desc.windowProcCallback; wc.cbClsExtra = 0; wc.cbWndExtra = 0; @@ -112,7 +113,7 @@ bool WindowShell::createWin(INIT_DESC_WINDOW &desc) pData->hWnd = CreateWindow( L"MainWindowClass" , desc.windowName.c_str(), - WS_OVERLAPPEDWINDOW, + desc.windowStyle, desc.windowPosition.x, desc.windowPosition.y, desc.windowSize.x, @@ -138,7 +139,7 @@ bool WindowShell::createWin(INIT_DESC_WINDOW &desc) return true; } -int WindowShell::createChildWin(INIT_DESC_CHILD_WINDOW &desc) +int WindowShell::createChildWin(CHILD_WINDOW_INIT_DESC &desc) { ChildWin win; diff --git a/Code/WindowManager/WindowShell.h b/Code/WindowManager/WindowShell.h index 267417be..d29a3666 100644 --- a/Code/WindowManager/WindowShell.h +++ b/Code/WindowManager/WindowShell.h @@ -5,72 +5,45 @@ #include -struct Point2D -{ - int x; - int y; - Point2D() - { - x = 0; - y = 0; - } - Point2D(int _x, int _y) - { - x = _x; - y = _y; - } - Point2D(int _p) - { - x = _p; - y = _p; - } - operator POINT() const - { - return Point2D(x, y); - } - bool operator<(int i) - { - bool a = x