Compare commits

...

2 commits

Author SHA1 Message Date
Ralph Sennhauser
df72c1aad1
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>
2026-08-10 09:00:07 +02:00
Dunedan
40ab70b804
Inline the pre-commit/action Github action
As the latest version of pre-commit is broken right now
(https://github.com/pre-commit/pre-commit/issues/3737) and the official
pre-commit Github action doesn't allow specifying an older pre-commit
version to use, this inlines the logic of the pre-commit action into our
action.
2026-08-09 07:20:49 +02:00
6 changed files with 68 additions and 13 deletions

View file

@ -3,22 +3,27 @@ name: pre-commit
on:
- push
- pull_request
env:
PRE_COMMIT_VERSION: 4.6.0
jobs:
build:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.11"
- id: restore-pip-cache
uses: actions/cache/restore@v6
- uses: actions/cache@v6
with:
key: pip-cache-v1-${{ github.workflow }}
key: pip-cache-v1-${{github.workflow}}-${{env.pythonLocation}}-${{env.PRE_COMMIT_VERSION}}
path: ~/.cache/pip
- uses: pre-commit/action@v3.0.1
- uses: actions/cache/save@v6
if: steps.restore-pip-cache.outcome == 'success'
- run: python -m pip install pre-commit=="${{ env.PRE_COMMIT_VERSION }}"
shell: bash
- run: python -m pip freeze --local
shell: bash
- uses: actions/cache@v6
with:
key: pip-cache-v1-${{ github.workflow }}
path: ~/.cache/pip
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- run: pre-commit run --show-diff-on-failure --color=always --all-files
shell: bash

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))