mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-08-15 14:43:32 -07:00
Compare commits
2 commits
062ffeab5c
...
df72c1aad1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df72c1aad1 | ||
|
|
40ab70b804 |
6 changed files with 68 additions and 13 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -456,6 +456,10 @@ MESSAGE(RotateAround,
|
|||
((Position, pos))
|
||||
);
|
||||
|
||||
MESSAGE(RotateY,
|
||||
((float, angle))
|
||||
);
|
||||
|
||||
MESSAGE(LookAt,
|
||||
((int, view)) // eRenderView
|
||||
((Position, pos))
|
||||
|
|
|
|||
Loading…
Reference in a new issue