void CLoader::LoadAll(const CHAR** pcPaths, UINT uCount) { UINT uType; if( ALCHEMY_GET_EVENT_TYPE(uType, LOAD_COMPLETE, CLoader) ) { CLoaderListener* pListener; if(m_uFreeListenerCount) pListener = m_FreeListeners[-- m_uFreeListenerCount]; else { ALCHEMY_DEBUG_NEW( pListener, CLoaderListener(*this) ); m_Listeners.Add(pListener); } pListener->Reset(pcPaths, uCount); AddEventListener(uType, *pListener); CMap<STRING, bool, STRINGLESS> PathMap; const CHAR* pcPath; bool* pbIsCommonPath; for(UINT i = 0; i < uCount; ++ i) { pcPath = pcPaths[i]; pbIsCommonPath = PathMap.Get(pcPath); if(!pbIsCommonPath) { PathMap.Insert(pcPath, true); Load(pcPath); } } } }
// Helper to retrieve info about a thread... static POSTABLETHREADINFO* GetThreadInfo(DWORD dwThread, bool bCreate) { CEnterCriticalSection ecs(&g_Section); POSTABLETHREADINFO* pti=g_ThreadInfos.Get(dwThread, NULL); if (pti || !bCreate) return pti; pti=new POSTABLETHREADINFO(); g_ThreadInfos.Add(dwThread, pti); return pti; }
LRESULT CALLBACK WndProc(HWND hWnd, alchemy::UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; LPWIN32WINDOW pWin32Window; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch (wmId) { default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; case WM_MOUSEMOVE: pWin32Window = g_WindowMap.Get(hWnd); if(pWin32Window && pWin32Window->pWindow && pWin32Window->uPointCount) { alchemy::UINT uType; if( ALCHEMY_GET_EVENT_TYPE(uType, POINT_MOVE, IWindow) ) { FLOAT2 Point[2]; FLOAT2& Source = Point[0]; Source.x = LOWORD(lParam); Source.y = HIWORD(lParam); if(pWin32Window->uPointCount > 1) { FLOAT2& Destination = Point[1]; Destination.x = 0.0f; Destination.y = 0.0f; } IWindow::CPointEvent Event(Point, pWin32Window->uPointCount, uType); pWin32Window->pWindow->DispatchEvent(Event); } } break; case WM_RBUTTONDOWN: pWin32Window = g_WindowMap.Get(hWnd); if(pWin32Window && pWin32Window->pWindow) { ++ pWin32Window->uPointCount; alchemy::UINT uType; if( ALCHEMY_GET_EVENT_TYPE(uType, POINT_ON, IWindow) ) { FLOAT2 Point; Point.x = 0.0f; Point.y = 0.0f; IWindow::CPointEvent Event(&Point, 1, uType); pWin32Window->pWindow->DispatchEvent(Event); } } break; case WM_RBUTTONUP: pWin32Window = g_WindowMap.Get(hWnd); if(pWin32Window && pWin32Window->pWindow) { -- pWin32Window->uPointCount; alchemy::UINT uType; if( ALCHEMY_GET_EVENT_TYPE(uType, POINT_OUT, IWindow) ) { FLOAT2 Point; Point.x = 0.0f; Point.y = 0.0f; IWindow::CPointEvent Event(&Point, 1, uType); pWin32Window->pWindow->DispatchEvent(Event); } } break; case WM_LBUTTONDOWN: pWin32Window = g_WindowMap.Get(hWnd); if(pWin32Window && pWin32Window->pWindow) { ++ pWin32Window->uPointCount; alchemy::UINT uType; if( ALCHEMY_GET_EVENT_TYPE(uType, POINT_ON, IWindow) ) { FLOAT2 Point; Point.x = LOWORD(lParam); Point.y = HIWORD(lParam); IWindow::CPointEvent Event(&Point, 1, uType); pWin32Window->pWindow->DispatchEvent(Event); } } break; case WM_LBUTTONUP: pWin32Window = g_WindowMap.Get(hWnd); if(pWin32Window && pWin32Window->pWindow) { -- pWin32Window->uPointCount; alchemy::UINT uType; if( ALCHEMY_GET_EVENT_TYPE(uType, POINT_OUT, IWindow) ) { FLOAT2 Point; Point.x = LOWORD(lParam); Point.y = HIWORD(lParam); IWindow::CPointEvent Event(&Point, 1, uType); pWin32Window->pWindow->DispatchEvent(Event); } } break; case WM_KEYDOWN: switch(wParam) { case VK_ESCAPE: PostQuitMessage(0); break; case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x46: case 0x47: case 0x48: case 0x49: case 0x4A: case 0x4B: case 0x4C: case 0x4E: case 0x4F: case 0x50: case 0x51: case 0x52: case 0x53: case 0x54: case 0x55: case 0x56: case 0x57: case 0x58: case 0x59: case 0x5A: pWin32Window = g_WindowMap.Get(hWnd); if(pWin32Window && pWin32Window->pWindow) { alchemy::UINT uType; if( ALCHEMY_GET_EVENT_TYPE(uType, KEY_DOWN, IWindow) ) { IWindow::CKeyEvent Event(static_cast<IWindow::KEYCODE>(wParam - 0x41 + IWindow::KEY_A), uType); pWin32Window->pWindow->DispatchEvent(Event); } } break; case VK_NUMPAD0: case VK_NUMPAD1: case VK_NUMPAD2: case VK_NUMPAD3: case VK_NUMPAD4: case VK_NUMPAD5: case VK_NUMPAD6: case VK_NUMPAD7: case VK_NUMPAD8: case VK_NUMPAD9: pWin32Window = g_WindowMap.Get(hWnd); if(pWin32Window && pWin32Window->pWindow) { alchemy::UINT uType; if( ALCHEMY_GET_EVENT_TYPE(uType, KEY_DOWN, IWindow) ) { IWindow::CKeyEvent Event(static_cast<IWindow::KEYCODE>(wParam - VK_NUMPAD0 + IWindow::KEY_0), uType); pWin32Window->pWindow->DispatchEvent(Event); } } break; default: break; } break; case WM_KEYUP: switch(wParam) { case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x46: case 0x47: case 0x48: case 0x49: case 0x4A: case 0x4B: case 0x4C: case 0x4E: case 0x4F: case 0x50: case 0x51: case 0x52: case 0x53: case 0x54: case 0x55: case 0x56: case 0x57: case 0x58: case 0x59: case 0x5A: pWin32Window = g_WindowMap.Get(hWnd); if(pWin32Window && pWin32Window->pWindow) { alchemy::UINT uType; if( ALCHEMY_GET_EVENT_TYPE(uType, KEY_UP, IWindow) ) { IWindow::CKeyEvent Event(static_cast<IWindow::KEYCODE>(wParam - 0x41 + IWindow::KEY_A), uType); pWin32Window->pWindow->DispatchEvent(Event); } } break; case VK_NUMPAD0: case VK_NUMPAD1: case VK_NUMPAD2: case VK_NUMPAD3: case VK_NUMPAD4: case VK_NUMPAD5: case VK_NUMPAD6: case VK_NUMPAD7: case VK_NUMPAD8: case VK_NUMPAD9: pWin32Window = g_WindowMap.Get(hWnd); if(pWin32Window && pWin32Window->pWindow) { alchemy::UINT uType; if( ALCHEMY_GET_EVENT_TYPE(uType, KEY_UP, IWindow) ) { IWindow::CKeyEvent Event(static_cast<IWindow::KEYCODE>(wParam - VK_NUMPAD0 + IWindow::KEY_0), uType); pWin32Window->pWindow->DispatchEvent(Event); } } break; default: break; } break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }