Add birds eye view toggle to View menu

On request by @nifa add a checked menu item to View menu to set birds eye view.

When game view is focused, the focus which it hogs almost always, then
'B' doesn't propagate properly so use Ctrl+B instead in line with other
main menu shortcuts.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser 2026-07-10 11:16:46 +02:00
parent abf444d91c
commit 16188c7305
No known key found for this signature in database
4 changed files with 25 additions and 16 deletions

View file

@ -173,12 +173,6 @@ private:
if (KeyScroll(evt, true))
return;
if (evt.GetKeyCode() == 'B')
{
POST_MESSAGE(ToggleBirdsEyeView, ());
return;
}
POST_MESSAGE(GuiKeyEvent, (GetSDLKeyFromWxKeyCode(evt.GetKeyCode()), evt.GetUnicodeKey(), true));
evt.Skip();
@ -372,6 +366,7 @@ enum
ID_Wireframe,
ID_SmoothFramerate,
ID_BirdsEyeView,
ID_CameraReset,
ID_MessageTrace,
@ -406,6 +401,7 @@ BEGIN_EVENT_TABLE(ScenarioEditor, wxFrame)
EVT_MENU(ID_Wireframe, ScenarioEditor::OnWireframe)
EVT_MENU(ID_SmoothFramerate, ScenarioEditor::OnSmoothFramerate)
EVT_MENU(ID_BirdsEyeView, ScenarioEditor::OnBirdsEyeView)
EVT_MENU(ID_CameraReset, ScenarioEditor::OnCameraReset)
EVT_MENU(ID_MessageTrace, ScenarioEditor::OnMessageTrace)
@ -523,6 +519,7 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent)
{
menuView->AppendCheckItem(ID_Wireframe, _("&Wireframe"));
menuView->AppendCheckItem(ID_SmoothFramerate, _("Smooth framerate"));
menuView->AppendCheckItem(ID_BirdsEyeView, _("&Birds Eye View\tCtrl+B"));
menuView->Append(ID_CameraReset, _("&Reset camera"));
}
@ -1001,6 +998,11 @@ void ScenarioEditor::OnSmoothFramerate(wxCommandEvent& event)
POST_MESSAGE(SetSmoothFramerate, (event.IsChecked()));
}
void ScenarioEditor::OnBirdsEyeView(wxCommandEvent& event)
{
POST_MESSAGE(SetBirdsEyeView, (event.IsChecked()));
}
void ScenarioEditor::OnDumpState(wxCommandEvent& event)
{
wxDateTime time = wxDateTime::Now();

View file

@ -60,12 +60,14 @@ public:
void OnPaste(wxCommandEvent& event);
void OnWireframe(wxCommandEvent& event);
void OnSmoothFramerate(wxCommandEvent& event);
void OnBirdsEyeView(wxCommandEvent& event);
void OnCameraReset(wxCommandEvent& event);
void OnMessageTrace(wxCommandEvent& event);
void OnScreenshot(wxCommandEvent& event);
void OnMediaPlayer(wxCommandEvent& event);
void OnJavaScript(wxCommandEvent& event);
void OnCameraReset(wxCommandEvent& event);
void OnSmoothFramerate(wxCommandEvent& event);
void OnDumpState(wxCommandEvent& event);
void OnSelectedObjectsChange(const std::vector<AtlasMessage::ObjectID>& selectedObjects);

View file

@ -39,7 +39,7 @@
namespace
{
bool g_BirdEyeView{false};
bool g_BirdsEyeView{false};
} // namespace
namespace AtlasMessage {
@ -66,7 +66,7 @@ MESSAGEHANDLER(CameraReset)
g_Game->GetView()->ResetCameraTarget(target);
g_BirdEyeView = false;
g_BirdsEyeView = false;
}
MESSAGEHANDLER(ScrollConstant)
@ -147,7 +147,7 @@ MESSAGEHANDLER(SmoothZoom)
MESSAGEHANDLER(RotateAround)
{
if (!g_Game || g_Game->GetView()->GetCinema()->IsPlaying() || g_BirdEyeView)
if (!g_Game || g_Game->GetView()->GetCinema()->IsPlaying() || g_BirdsEyeView)
return;
static CVector3D focusPos;
@ -269,8 +269,11 @@ MESSAGEHANDLER(SetView)
// TODO: Rotation
}
MESSAGEHANDLER(ToggleBirdsEyeView)
MESSAGEHANDLER(SetBirdsEyeView)
{
if (g_BirdsEyeView == msg->enabled)
return;
if (!g_Game || g_Game->GetView()->GetCinema()->IsPlaying())
return;
@ -280,7 +283,7 @@ MESSAGEHANDLER(ToggleBirdsEyeView)
CMatrix3D& orientation{camera.GetOrientation()};
const CVector3D focus{camera.GetFocus()};
if (!g_BirdEyeView)
if (!g_BirdsEyeView)
{
CVector3D in = orientation.GetIn();
declination = atan2(sqrt(in.X*in.X + in.Z*in.Z), in.Y) - std::numbers::pi_v<float> / 2.f;
@ -289,7 +292,7 @@ MESSAGEHANDLER(ToggleBirdsEyeView)
CQuaternion q;
// If really 90° then the camera movement bugs out as it has no clear
// forward anymore, so stick with 89°.
q.FromAxisAngle(orientation.GetLeft(), g_BirdEyeView ?
q.FromAxisAngle(orientation.GetLeft(), g_BirdsEyeView ?
DEGTORAD(89.f) - declination : DEGTORAD(-89.f) + declination);
CVector3D origin = orientation.GetTranslation();
@ -304,7 +307,7 @@ MESSAGEHANDLER(ToggleBirdsEyeView)
camera.UpdateFrustum();
g_Game->GetView()->SetCamera(camera);
g_BirdEyeView = !g_BirdEyeView;
g_BirdsEyeView = msg->enabled;
}
}

View file

@ -473,7 +473,9 @@ MESSAGE(SetView,
((sCameraInfo, info))
);
MESSAGE(ToggleBirdsEyeView, );
MESSAGE(SetBirdsEyeView,
((bool, enabled))
);
//////////////////////////////////////////////////////////////////////////