int Chkdraft::Run(LPSTR lpCmdLine, int nCmdShow) { if ( !CreateThis() ) return 1; scData.Load(); InitCommonControls(); ShowWindow(getHandle(), nCmdShow); UpdateWindow(); ParseCmdLine(lpCmdLine); GuiMap::SetAutoBackup(true); this->OnLoadTest(); MSG msg = {}; bool keepRunning = true; do { while ( ::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != 0 ) { if ( msg.message == WM_QUIT ) keepRunning = false; else { bool isDlgKey = DlgKeyListener(msg.hwnd, msg.message, msg.wParam, msg.lParam); if ( ::IsDialogMessage(currDialog, &msg) == FALSE ) { ::TranslateMessage(&msg); if ( !isDlgKey ) KeyListener(msg.hwnd, msg.message, msg.wParam, msg.lParam); ::DispatchMessage(&msg); } } } if ( CM != nullptr && ColorCycler::CycleColors(CM->getTileset()) ) CM->Redraw(false); std::this_thread::sleep_for(std::chrono::milliseconds(1)); // Avoid consuming a core } while ( keepRunning ); /*MSG msg; while ( GetMessage(&msg, NULL, 0, 0) > 0 ) { bool isDlgKey = DlgKeyListener(msg.hwnd, msg.message, msg.wParam, msg.lParam); if ( IsDialogMessage(currDialog, &msg) == FALSE && TranslateMDISysAccel(maps.getHandle(), &msg) == FALSE ) { TranslateMessage(&msg); if ( !isDlgKey ) KeyListener(msg.hwnd, msg.message, msg.wParam, msg.lParam); DispatchMessage(&msg); } }*/ return msg.wParam; }
/*=*/ GLvoid Scene::RenderContent(){ // Lighting _RenderLights(); // Fog _EnableFog(); // Sky Box _skyBox->ShowSky(); // Draw Land for(auto land: _mainLand){ land->DrawGLScene(); } for(auto enemy:enemies){ glPushMatrix(); glTranslatef((_mainCraft->modelPos.x-enemy->modelNewPos.x)/10, (_mainCraft->modelPos.y-enemy->modelNewPos.y)/10, (_mainCraft->modelPos.z-enemy->modelNewPos.z)/10); enemy->Render(false); glPopMatrix(); } for(auto plant:_plants){ plant->Render(false); } // Draw Lizard //_mainPlayer->DrawModel(); glEnable(GL_TEXTURE); _mainCraft->modelTexture->_BindTextures(); _mainCraft->Render(_isUseParticle); glDisable(GL_TEXTURE); // cout<<_mainCraft->modelPos.x<<","<<_mainCraft->modelPos.z<<endl; // Key Listener; KeyListener(); }
bool Chkdraft::DlgKeyListener(HWND hWnd, UINT &msg, WPARAM wParam, LPARAM lParam) { switch ( msg ) { case WM_KEYDOWN: { switch ( wParam ) { case VK_TAB: if ( GetParent(GetParent(hWnd)) == trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.getHandle() || GetParent(hWnd) == trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.getHandle() ) { msg = WM_NULL; // Dirty fix to prevent tabs from being focused trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.ProcessKeyDown(wParam, lParam); return true; } else if ( GetParent(GetParent(hWnd)) == trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.getHandle() || GetParent(hWnd) == trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.getHandle() ) { msg = WM_NULL; // Dirty fix to prevent tabs from being focused trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.ProcessKeyDown(wParam, lParam); return true; } break; case VK_RETURN: if ( GetParent(GetParent(hWnd)) == trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.getHandle() || GetParent(hWnd) == trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.getHandle() ) { trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.ProcessKeyDown(wParam, lParam); return true; } else if ( GetParent(GetParent(hWnd)) == trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.getHandle() || GetParent(hWnd) == trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.getHandle() ) { trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.ProcessKeyDown(wParam, lParam); return true; } if ( GetParent(hWnd) == unitWindow.getHandle() ) { unitWindow.DestroyThis(); return true; } else if ( GetParent(hWnd) == locationWindow.getHandle() ) { locationWindow.DestroyThis(); return true; } else if ( GetParent(hWnd) == enterPasswordWindow.getHandle()) { enterPasswordWindow.ButtonLogin(); return true; } break; case VK_DELETE: if ( GetParent(hWnd) == unitWindow.getHandle() ) { SendMessage(unitWindow.getHandle(), WM_COMMAND, MAKEWPARAM(IDC_BUTTON_DELETE, 0), 0); return true; } break; case 'Z': case 'Y': case 'X': case 'C': case 'V': if ( GetKeyState(VK_CONTROL) & 0x8000 ) { KeyListener(hWnd, msg, wParam, lParam); return true; } break; } } break; case WM_KEYUP: if ( wParam == VK_SPACE && CM != nullptr && maps.clipboard.isPasting() ) { UnlockCursor(); return true; } break; } return false; }