Support scroll-rotate in Atlas

Split mouse wheel scroll handling into horizontal and vertical. Keep
vertical scroll for zooming and use horizontal to rotate around the y
axis replicating the behaviour of the main game.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser 2026-07-18 06:03:11 +02:00
parent 40ab70b804
commit df72c1aad1
No known key found for this signature in database
5 changed files with 54 additions and 4 deletions

View file

@ -273,8 +273,16 @@ private:
if (evt.GetWheelRotation())
{
float speed = 16.f * ScenarioEditor::GetSpeedModifier();
POST_MESSAGE(SmoothZoom, (eRenderView::GAME, evt.GetWheelRotation() * speed / evt.GetWheelDelta()));
if (evt.GetWheelAxis() == wxMOUSE_WHEEL_VERTICAL)
{
float speed = 16.f * ScenarioEditor::GetSpeedModifier();
POST_MESSAGE(SmoothZoom, (eRenderView::GAME, evt.GetWheelRotation() * speed / evt.GetWheelDelta()));
}
else
{
float speed = ScenarioEditor::GetSpeedModifier();
POST_MESSAGE(RotateY, (evt.GetWheelRotation() * speed / evt.GetWheelDelta()));
}
}
else
{

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -41,7 +41,8 @@ struct GameLoopState
struct Input
{
float scrollSpeed[6]; // [fwd, bwd, left, right, cw-rotation, ccw-rotation]. 0.0f for disabled.
float zoomDelta;
float zoomDelta{0.f};
float rotateDelta{0.f};
} input;
};

View file

@ -199,6 +199,14 @@ MESSAGEHANDLER(RotateAround)
}
}
MESSAGEHANDLER(RotateY)
{
if (!g_Game || g_Game->GetView()->GetCinema()->IsPlaying())
return;
g_AtlasGameLoop->input.rotateDelta = msg->angle;
}
MESSAGEHANDLER(LookAt)
{
// TODO: different camera depending on msg->view

View file

@ -117,6 +117,35 @@ bool InputProcessor::ProcessInput(GameLoopState* state)
moved = true;
}
if (state->input.rotateDelta != 0.f)
{
float angle{4 * state->realFrameLength};
if (input.rotateDelta > 0 )
{
if (angle > input.rotateDelta)
{
angle = input.rotateDelta;
input.rotateDelta = 0.f;
}
else
input.rotateDelta -= angle;
}
else
{
angle *= -1;
if (angle < input.rotateDelta)
{
angle = input.rotateDelta;
input.rotateDelta = 0.f;
}
else
input.rotateDelta -= angle;
}
Rotate(camera, angle);
moved = true;
}
if (moved)
{
camera.UpdateFrustum();

View file

@ -456,6 +456,10 @@ MESSAGE(RotateAround,
((Position, pos))
);
MESSAGE(RotateY,
((float, angle))
);
MESSAGE(LookAt,
((int, view)) // eRenderView
((Position, pos))