void CMouseHandler::ToggleState(bool shift) { if(!shift){ if(locked){ locked=false; ShowMouse(); } else { locked=true; HideMouse(); } } else { CameraTransition(1.0f); CCameraController* oldc=currentCamController; currentCamControllerNum++; if(currentCamControllerNum>=camControllers.size()) currentCamControllerNum=0; int a=0; while(a<4 && !camControllers[currentCamControllerNum]->enabled){ currentCamControllerNum++; if(currentCamControllerNum>=camControllers.size()) currentCamControllerNum=0; a++; } currentCamController=camControllers[currentCamControllerNum]; currentCamController->SetPos(oldc->SwitchFrom()); currentCamController->SwitchTo(); } }
bool CMouseHandler::LoadView(const std::string& name) { if (name.empty()) { return false; } std::map<std::string, ViewData>::const_iterator it = views.find(name); if (it == views.end()) { return false; } const ViewData& saved = it->second; ViewData current; current.state = currentCamController->GetState(); if (currentCamController == overviewController) { current.mode = -1; } else { current.mode = currentCamControllerNum; } for (it = views.begin(); it != views.end(); ++it) { if (it->second == current) { break; } } if (it == views.end()) { tmpView = current; } ViewData effective; if (saved == current) { effective = tmpView; } else { effective = saved; } if (effective.state.size() <= 0) { return false; } if ((effective.mode == -1) || ((effective.mode >= 0) && (effective.mode < camControllers.size()) && camControllers[effective.mode]->enabled)) { const float3 dummy = currentCamController->SwitchFrom(); if (effective.mode >= 0) { currentCamControllerNum = effective.mode; currentCamController = camControllers[effective.mode]; } else { currentCamController = overviewController; } const bool showMode = (current.mode != effective.mode); currentCamController->SwitchTo(showMode); CameraTransition(1.0f); } return currentCamController->SetState(effective.state);; }
void CCameraHandler::ToggleOverviewCamera() { CameraTransition(1.0f); if (controllerStack.empty()) { PushMode(); SetCameraMode(CAMERA_MODE_OVERVIEW); } else { PopMode(); } }
void CMouseHandler::ToggleOverviewCamera(void) { if(currentCamController==overviewController){ float3 pos=overviewController->SwitchFrom(); currentCamController=camControllers[currentCamControllerNum]; currentCamController->SwitchTo(false); currentCamController->SetPos(pos); } else { currentCamController=overviewController; overviewController->SwitchTo(false); } CameraTransition(1.0f); }
void CCameraHandler::SetCameraMode(unsigned int mode) { if ((mode >= camControllers.size()) || (mode == static_cast<unsigned int>(currCamCtrlNum))) { return; } CameraTransition(1.0f); CCameraController* oldCamCtrl = currCamCtrl; currCamCtrlNum = mode; currCamCtrl = camControllers[mode]; currCamCtrl->SetPos(oldCamCtrl->SwitchFrom()); currCamCtrl->SwitchTo(); }
void CCameraHandler::SetCameraMode(unsigned int newMode) { if ((newMode >= camControllers.size()) || (newMode == currCamCtrlNum)) return; CameraTransition(1.0f); const unsigned int oldMode = currCamCtrlNum; CCameraController* oldCamCtrl = camControllers[currCamCtrlNum ]; CCameraController* newCamCtrl = camControllers[currCamCtrlNum = newMode]; newCamCtrl->SetPos(oldCamCtrl->SwitchFrom()); newCamCtrl->SwitchTo(oldMode); newCamCtrl->Update(); }
void CMouseHandler::SetCameraMode(int mode) { if ((mode < 0) || (mode >= camControllers.size()) || (mode == currentCamControllerNum) || (!camControllers[currentCamControllerNum]->enabled)) { return; } currentCamControllerNum = mode; CameraTransition(1.0f); CCameraController* oldc = currentCamController; currentCamController = camControllers[currentCamControllerNum]; currentCamController->SetPos(oldc->SwitchFrom()); currentCamController->SwitchTo(); }
bool CCameraHandler::SetState(const CCameraController::StateMap& sm) { CCameraController::StateMap::const_iterator it = sm.find("mode"); if (it != sm.end()) { const unsigned int camMode = (unsigned int)it->second; if (camMode >= camControllers.size()) { return false; } if (camMode != currCamCtrlNum) { CameraTransition(1.0f); currCamCtrlNum = camMode; currCamCtrl = camControllers[camMode]; currCamCtrl->SwitchTo(); } } return currCamCtrl->SetState(sm); }
bool CCameraHandler::LoadViewData(const ViewData& vd) { if (vd.empty()) return false; const auto it = vd.find("mode"); if (it != vd.end()) { const unsigned int camMode = it->second; const unsigned int curMode = currCamCtrlNum; if (camMode >= camControllers.size()) return false; if (camMode != currCamCtrlNum) { CameraTransition(1.0f); camControllers[currCamCtrlNum = camMode]->SwitchTo(curMode, camMode != curMode); } } return camControllers[currCamCtrlNum]->SetState(vd); }
bool CCameraHandler::LoadViewData(const ViewData& vd) { if (vd.empty()) { return false; } ViewData::const_iterator it = vd.find("mode"); if (it != vd.end()) { const unsigned int camMode = (unsigned int)it->second; if (camMode >= camControllers.size()) { return false; } const unsigned int currentMode = currCamCtrlNum; if (camMode != currCamCtrlNum) { currCamCtrlNum = camMode; currCamCtrl = camControllers[camMode]; const bool showMode = (camMode != currentMode); currCamCtrl->SwitchTo(showMode); CameraTransition(1.0f); } } return currCamCtrl->SetState(vd); }
void CCameraHandler::ToggleState() { CameraTransition(1.0f); CCameraController* oldCamCtrl = currCamCtrl; currCamCtrlNum++; if (currCamCtrlNum >= camControllers.size()) { currCamCtrlNum = 0; } int a = 0; const int maxTries = camControllers.size() - 1; while ((a < maxTries) && !camControllers[currCamCtrlNum]->enabled) { currCamCtrlNum++; if (currCamCtrlNum >= camControllers.size()) { currCamCtrlNum = 0; } a++; } currCamCtrl = camControllers[currCamCtrlNum]; currCamCtrl->SetPos(oldCamCtrl->SwitchFrom()); currCamCtrl->SwitchTo(); }