bool CAICheats::OnlyPassiveCheats() { return IsPassive(); }
void C4MouseControl::Move(int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyFlags, bool fCenter) { // Control state ControlDown=false; if (dwKeyFlags & MK_CONTROL) ControlDown=true; ShiftDown=false; if (dwKeyFlags & MK_SHIFT) ShiftDown=true; AltDown=false; if(dwKeyFlags & MK_ALT) AltDown=true; // Active if (!Active || !fMouseOwned) return; // Execute caption if (KeepCaption) KeepCaption--; else { Caption.Clear(); CaptionBottomY=0; } // Check player if (Player>NO_OWNER) { pPlayer=::Players.Get(Player); if (!pPlayer) { Active=false; return; } } else pPlayer = nullptr; // Check viewport if (!(Viewport=::Viewports.GetViewport(Player))) return; // get view position C4Rect rcViewport = Viewport->GetOutputRect(); fctViewport.Set(nullptr, rcViewport.x, rcViewport.y, rcViewport.Wdt, rcViewport.Hgt); ViewX=Viewport->GetViewX(); ViewY=Viewport->GetViewY(); fctViewportGame = Viewport->last_game_draw_cgo; fctViewportGUI = Viewport->last_gui_draw_cgo; // First time viewport attachment: center mouse #ifdef USE_WIN32_WINDOWS if (!InitCentered || fCenter) { iX = Viewport->ViewWdt/2; iY = Viewport->ViewHgt/2; if (!Application.isEditor) { int32_t iMidX = Viewport->OutX + iX; int32_t iMidY = Viewport->OutY + iY; RECT rtWindow; if (GetWindowRect(Application.pWindow->hWindow, &rtWindow)) { iMidX += rtWindow.left; iMidY += rtWindow.top; } SetCursorPos(iMidX, iMidY); } InitCentered = true; } #else if (!InitCentered || fCenter) { iX = Viewport->ViewWdt/2; iY = Viewport->ViewHgt/2; InitCentered = true; } #endif // passive mode: scrolling and player buttons only if (IsPassive()) { if (iButton != C4MC_Button_Wheel) { VpX=iX; VpY=iY; GameX=ViewX+VpX/Viewport->Zoom; GameY=ViewY+VpY/Viewport->Zoom; GuiX=float(VpX)/Viewport->GetGUIZoom(); GuiY=float(VpY)/Viewport->GetGUIZoom(); } UpdateScrolling(); if (iButton == C4MC_Button_LeftDown) LeftDown(); else if (iButton == C4MC_Button_LeftUp) LeftUp(); else UpdateCursorTarget(); return; } if (iButton != C4MC_Button_Wheel) { // Position VpX=iX; VpY=iY; GameX=ViewX+VpX/Viewport->Zoom; GameY=ViewY+VpY/Viewport->Zoom; GuiX=float(VpX)/Viewport->GetGUIZoom(); GuiY=float(VpY)/Viewport->GetGUIZoom(); // Scrolling UpdateScrolling(); // Fog of war UpdateFogOfWar(); // Blocked by fog of war: evaluate button up, dragging and region controls only if (FogOfWar && Drag == C4MC_Drag_None) { // Left button up if (iButton==C4MC_Button_LeftUp) { LeftButtonDown=false; // End any drag Drag=C4MC_Drag_None; } // Right button up if (iButton==C4MC_Button_RightUp) { RightButtonDown=false; } } } // Move execution by button/drag status switch (iButton) { //------------------------------------------------------------------------------------------ case C4MC_Button_None: switch (Drag) { case C4MC_Drag_Unhandled: break; // nothing to do case C4MC_Drag_None: DragNone(); break; case C4MC_Drag_Script: DragScript(); break; } break; //------------------------------------------------------------------------------------------ case C4MC_Button_LeftDown: LeftDown(); break; //------------------------------------------------------------------------------------------ case C4MC_Button_LeftUp: LeftUp(); break; //------------------------------------------------------------------------------------------ case C4MC_Button_LeftDouble: LeftDouble(); break; //------------------------------------------------------------------------------------------ case C4MC_Button_RightDown: RightDown(); break; //------------------------------------------------------------------------------------------ case C4MC_Button_RightUp: RightUp(); break; //------------------------------------------------------------------------------------------ case C4MC_Button_Wheel: Wheel(dwKeyFlags); break; } // are custom menus active? bool menuProcessed = false; if (pPlayer) // adjust by viewport X/Y because the GUI windows calculate their positions (and thus check input) based on that menuProcessed = ::Game.ScriptGuiRoot->MouseInput(iButton, iX, iY, dwKeyFlags); if (menuProcessed) Cursor = C4MC_Cursor_Select; // if not caught by a menu if (!menuProcessed) // script handling of mouse control for everything but regular movement (which is sent at control frame intervals only) if (iButton != C4MC_Button_None) // not if blocked by selection object if (!TargetObject) // safety (can't really happen in !IsPassive, but w/e if (pPlayer && pPlayer->ControlSet) { if (!menuProcessed && pPlayer->ControlSet->IsMouseControlAssigned(iButton)) { int wheel_dir = 0; if (iButton == C4MC_Button_Wheel) wheel_dir = (short)(dwKeyFlags >> 16); pPlayer->Control.DoMouseInput(0 /* only 1 mouse supported so far */, iButton, GameX, GameY, GuiX, GuiY, (dwKeyFlags & MK_CONTROL) != 0, (dwKeyFlags & MK_SHIFT) != 0, (dwKeyFlags & MK_ALT) != 0, wheel_dir); } }