MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / OnLButtonClick

Method OnLButtonClick

engine/Poseidon/UI/Map/UIMapExt.cpp:2489–2559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2487}
2488
2489void CStaticMapArcade::OnLButtonClick(float x, float y)
2490{
2491 auto& input = InputSubsystem::Instance();
2492 bool canSelectGroup = false;
2493 switch (_infoClickCandidate._type)
2494 {
2495 case signArcadeUnit:
2496 case signArcadeSensor:
2497 canSelectGroup = _infoClickCandidate._indexGroup >= 0;
2498 case signArcadeMarker:
2499 _infoClick = _infoClickCandidate;
2500 _dragging = input.IsMouseLeftDown() && HasFullRights();
2501 break;
2502 case signStatic:
2503 _infoClick = _infoClickCandidate;
2504 _dragging = false;
2505 break;
2506 case signArcadeWaypoint:
2507 _infoClick = _infoClickCandidate;
2508 _dragging = input.IsMouseLeftDown() && HasRight(_infoClick._indexGroup);
2509 canSelectGroup = true;
2510 {
2511 ArcadeGroupInfo& gInfo = _template->groups[_infoClick._indexGroup];
2512 ArcadeWaypointInfo& wInfo = gInfo.waypoints[_infoClick._index];
2513 if (wInfo.id >= 0)
2514 {
2515 int idGroup, idUnit;
2516 _template->FindUnit(wInfo.id, idGroup, idUnit);
2517 _infoClick._type = signArcadeUnit;
2518 _infoClick._indexGroup = idGroup;
2519 _infoClick._index = idUnit;
2520 }
2521 else if (wInfo.idStatic >= 0)
2522 {
2523 _dragging = false;
2524 }
2525 }
2526 break;
2527 case signNone:
2528 if (input.IsMouseLeftDown())
2529 {
2530 _dragging = false;
2531 _selecting = true;
2532 _special = _lastPos;
2533 return;
2534 }
2535 break;
2536 }
2537
2538 bool selected = IsSelected(_infoClickCandidate);
2539 if (!_dragging || !selected)
2540 {
2541 // change selection
2542 if (!input.IsKeyDown(SDL_SCANCODE_LCTRL) && !input.IsKeyDown(SDL_SCANCODE_RCTRL))
2543 {
2544 _template->ClearSelection();
2545 selected = false;
2546 }

Callers

nothing calls this directly

Calls 6

IsMouseLeftDownMethod · 0.80
IsKeyDownMethod · 0.80
ClearSelectionMethod · 0.80
SelectMethod · 0.80
FindUnitMethod · 0.45
GetKeyMethod · 0.45

Tested by

no test coverage detected