// ********************************************** void CToolPick::updateAfterRender() { //H_AUTO(R2_CToolPick_updateAfterRender) // See if the mouse is over a valid position _ValidPos = false; sint32 mouseX, mouseY; getMousePos(mouseX, mouseY); if (!isInScreen(mouseX, mouseY)) { getEditor().setFocusedInstance(NULL); setMouseCursor(_CursCannotPickPos); return; } _CandidateInstance = NULL; CInstance *instanceUnder = checkInstanceUnderMouse(); bool ignoreInstanceUnder = false; if(instanceUnder && _IgnoreInstances.size()>0) { for(uint i=0; i<_IgnoreInstances.size(); i++) { if(instanceUnder->isKindOf(_IgnoreInstances[i])) { ignoreInstanceUnder = true; break; } } } if (!instanceUnder || ignoreInstanceUnder) { if (isMouseOnUI() && !isMouseOnContainer()) { setMouseCursor(DEFAULT_CURSOR); } else { CTool::CWorldViewRay worldViewRay; computeWorldViewRay(mouseX, mouseY, worldViewRay); CVector inter; _ValidPos = (ValidPacsPos == computeLandscapeRayIntersection(worldViewRay, _Intersection)); setMouseCursor(_ValidPos ? _CursCanPickPos : _CursCannotPickPos); getEditor().setFocusedInstance(NULL); } return; } getEditor().setFocusedInstance(instanceUnder); if (canPick(*instanceUnder)) { _CandidateInstance = instanceUnder; setMouseCursor(_CursCanPickInstance); } else { setMouseCursor(_CursCannotPickInstance); } }
//*************************************************************** void CToolCreateEntity::updateBeforeRender() { //H_AUTO(R2_CToolCreateEntity_updateBeforeRender) if (_CreateState != DrawArray) { CToolChoosePos::updateBeforeRender(); _AutoGroup.update(_CreatePosition, _PaletteId, _Valid && !isCtrlDown()); setContextHelp(CI18N::get(_AutoGroup.getGroupingCandidate() ? "uiR2EDToolCreateEntityAutoGroup" : "uiR2EDToolCreateEntity")); return; } setContextHelp(CI18N::get("uiR2EDDrawArrayContextHelp")); // update for array mode bool valid = true; sint32 mouseX, mouseY; getMousePos(mouseX, mouseY); if (!isInScreen(mouseX, mouseY) || (isMouseOnUI() && !isMouseOnWorldMap())) { valid = false; _ArrayEnd = _ArrayOrigin; } // CTool::CWorldViewRay worldViewRay; computeWorldViewRay(mouseX, mouseY, worldViewRay); // CVector entityPos; // the pos where the ghost will be shown CVector inter; // intersection of view ray with landscape _ValidArray = true; TRayIntersectionType rayIntersectionType = computeLandscapeRayIntersection(worldViewRay, inter); switch(rayIntersectionType) { case NoIntersection: _ValidArray = false; _ArrayEnd = _ArrayOrigin; break; case ValidPacsPos: case InvalidPacsPos: _ArrayEnd = inter; break; } for (uint k = 0; valid && k < _ArrayElements.size(); ++k) { if (_ArrayElements[k]) { if (_ArrayElements[k]->getDisplayFlag(CDisplayerVisual::FlagBadPos)) { _ValidArray = false; } } } CGroupMap *worldMap = getWorldMap(); if (worldMap) worldMap->setSelectionAxis(_ValidArray); setMouseCursor(_ValidArray ? _CursValid.c_str() : _CursInvalid.c_str()); }