Skip to content

Zoom-in support & related map action - #2417

Open
FS-21 wants to merge 16 commits into
Phobos-developers:developfrom
FS-21:feature/zoom-in-support
Open

FS-21 wants to merge 16 commits into
Phobos-developers:developfrom
FS-21:feature/zoom-in-support

Conversation

@FS-21

@FS-21 FS-21 commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

What kind of change is this?

  • New feature, vanilla bugfix or enhancement of a released feature - changelog, docs and credits entries are needed.
  • Improvement to a new (unreleased) feature - docs and credits entries are needed; no changelog entry (Skip Changelog).
  • Bugfix to a new (unreleased) feature - credits entry is needed; no changelog or docs entries (Skip Changelog, Skip Docs).
  • Bugfix to an old (released) feature - changelog and credits entries are needed; no docs entry (Skip Docs).
  • Completely minor change (e.g. a typo fix) - no entries are needed (Skip Changelog, Skip Docs, Skip Credits).

Description

Tactical zoom

  • Magnifies the battlefield tactical view using mouse wheel (Ctrl + Wheel) and configurable keyboard hotkeys.
    • TacticalZoom enables or disables tactical zoom.
    • TacticalZoom.Scroll enables mouse wheel zooming (Ctrl + Wheel) and middle click zoom reset.
    • TacticalZoom.KeyEnabled enables keyboard commands.
    • TacticalZoom.Max sets the maximum zoom magnification (e.g. 2.5 allows zooming in up to 2.5x).
    • TacticalZoom.Step sets the zoom increment per wheel notch or hotkey press.
    • TacticalZoom.Smooth toggles smooth frame-by-frame interpolation between zoom levels.

In uimd.ini:

[TacticalZoom]
TacticalZoom=false          ; boolean
TacticalZoom.Scroll=true     ; boolean
TacticalZoom.KeyEnabled=true   ; boolean
TacticalZoom.Max=2.5        ; double
TacticalZoom.Step=0.15      ; double
TacticalZoom.Smooth=true    ; boolean

In RA2MD.INI:

[Phobos]
TacticalZoom=true          ; boolean
TacticalZoom.Smooth=true   ; boolean

Map Action 514 Set tactical zoom

  • Adjusts the tactical view magnification level with transition rate and resolution bounds.
    • Parameter 1 (Value): Zoom percentage above 100% base (0 = 1.0x / 100%, 50 = 1.5x, 100 = 2.0x, 150 = 2.5x).
    • Parameter 2 (Param3): Transition rate (0 = instant cut, >0 = smooth transition speed per frame).
    • Parameter 3 (Param4): Minimum visible screen width in pixels (0 = unconstrained).
    • Parameter 4 (Param5): Minimum visible screen height in pixels (0 = unconstrained).

In mycampaign.map:

[Actions]
...
ID=ActionCount,[Action1],514,0,0,[TransitionRate],[MinVisibleWidth],[MinVisibleHeight],0,A,[ZoomPercentage]
...

Note

  • Smooth transitions interpolate directly from the current view zoom without resetting to default first.
  • Player zoom controls are disabled while user input is locked (e.g. via map action) and re-enabled once unlocked. The view automatically returns to 100% unless a scripted zoom is specified.
  • Parameters 3 and 4 automatically clamp the requested zoom so the visible battlefield does not drop below the specified pixel dimensions on lower resolutions.

Hotkey Commands

[ ] Tactical Zoom Commands

  • Allows zooming in, zooming out, or resetting the battlefield view magnification. Configurable under Interface options.
  • Hotkeys are enabled when Tactical Zoom and hotkeys are enabled in uimd.ini.
  • For localization add TXT_ZOOM_IN, TXT_ZOOM_IN_DESC, TXT_ZOOM_OUT, TXT_ZOOM_OUT_DESC, TXT_RESET_ZOOM, and TXT_RESET_ZOOM_DESC into your .csf file.

FS-21 and others added 7 commits September 21, 2026 10:45
- Leverage Westwood's native TacticalClass::ZoomInFactor pipeline with smooth interpolation
- Add ZoomManager for bidirectional ScreenToTactical and TacticalToScreen coordinate transformations
- Hook mouse message dispatching to accurately translate click selection, rubberband dragging, hover, and building placement preview coordinates
- Add Ctrl+MouseWheel zooming and middle-click zoom reset
- Register configurable Zoom In, Zoom Out, and Reset Zoom commands
- Add INI options under [Phobos] in ra2md.ini
… zoom hotkey/wheel INI options

- Fix mouse desynchronization: eliminate Windows LPARAM mutations in ScrollClass::Message_Handler that corrupted WWMouseClass coordinates, keeping OS and game cursors 100% in sync
- Centralize coordinate mapping by hooking DisplayClass::ProcessClickCoords (0x692300) and DisplayClass::UpdateDragBand (0x4AC380)
- Add TacticalZoom.Wheel and TacticalZoom.Hotkeys configuration options in ra2md.ini and rulesmd.ini
- Make Zoom In, Zoom Out, and Reset Zoom commands dynamically registered for the Hotkeys menu under Interface
… native mouse handling

- Decouple ZoomManager from Westwood's global ZoomInFactor so PrimarySurface update stays 1:1

- Render tactical layers to Alternate and composite into ViewBounds, keeping UI regions crisp

- Maintain native cursor coordinates and use stack translation for tactical click targeting

- Align code with Phobos formatting guidelines and clean comments
Comment thread src/Phobos.INI.cpp Outdated
@github-actions

github-actions Bot commented Sep 22, 2026

Copy link
Copy Markdown

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

Comment thread docs/User-Interface.md Outdated
Comment thread src/Phobos.INI.cpp Outdated
Comment thread docs/User-Interface.md Outdated
- `TacticalZoom.Wheel` enables mouse wheel zooming (`Ctrl + Wheel`).
- `TacticalZoom.Hotkeys` enables keyboard commands.
- `TacticalZoom.Max` sets the maximum zoom magnification.
- `TacticalZoom.Step` sets the zoom increment per step.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should explain how these values reflect to actual operation ingame

@FS-21 FS-21 Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this? I updated the first message

  • TacticalZoom.Scroll enables mouse wheel zooming (Ctrl + Wheel) and middle click zoom reset.
  • TacticalZoom.KeyEnabled enables keyboard commands.
  • TacticalZoom.Max sets the maximum zoom magnification (e.g. 2.5 allows zooming in up to 2.5x).
  • TacticalZoom.Step sets the zoom increment per wheel notch or hotkey press.
  • TacticalZoom.Smooth toggles smooth frame-by-frame interpolation between zoom levels.

@DeathFishAtEase DeathFishAtEase added the ⚙️T1 T1 maintainer review is sufficient label Sep 22, 2026
@Coronia

Coronia commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

so far 2 problems in testing:
1 - the screen will shake during zoom in, neither can TacticalZoom.Smooth solve it
2 - when draging mouse selection box during zoom in, the box won't be completely inline with the mouse

also, is it possible to make it support zoom out as well?

- Ensure crop center parity in GetBlitRects to eliminate sub-pixel oscillation during zoom interpolation

- Avoid resetting camera position every frame, only re-clamping when map boundaries are violated

- Hook DisplayClass::Mouse_Left_Press (0x4AC310) to synchronize rubberband start coordinates

- Bind ScreenToTactical and TacticalToScreen to DSurface::ViewBounds dimensions
@FS-21

FS-21 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

so far 2 problems in testing: 1 - the screen will shake during zoom in, neither can TacticalZoom.Smooth solve it 2 - when draging mouse selection box during zoom in, the box won't be completely inline with the mouse

also, is it possible to make it support zoom out as well?

Unfortunately, one thing is the zoom-in (easy, is a simple crop of the visible area, native) and another thing is supporting a true zoom-out is not feasible with the current implementation because the map should be rendered much bigger and then downscale. You can try starting the game with a wider resolution and then zoom-in to your desired one, so not all computers should support that, I think.

Can you try if those 2 bugs are fixed?

@FS-21

FS-21 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Coronia, By the way, how works in newer c&c games this bug#2 ? Maybe making area selection and zoom mutually exclusive?

@Fryone

Fryone commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

I have tested the 11 hours ago build, with the selection box bug.
Should the superweapon timers dissapear when zoomed?

Also, maybe there could be default zoom value initially set between original and completely zoomed. To have "zoom out" ability from start.

Another suggestion to have mouse scroll only without "ctrl", but I don't know if it's possible to control mouse over sidebar vs mouse over render box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs testing ⚙️T1 T1 maintainer review is sufficient

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants