beyond-all-reason / spring

A powerful free cross-platform RTS game engine
https://beyond-all-reason.github.io/spring/
Other
219 stars 101 forks source link

Better control of minimap flipping #618

Open WatchTheFort opened 1 year ago

WatchTheFort commented 1 year ago

The config int MiniMapCanFlip controls whether or not the minimap automatically rotates 180° when the camera is rotated past the plane of 180°. This is wanted behaviour when using the camera flip command (the Ctrl-Shift-O cameraflip action in the game), but is unwanted when manually rotating the camera, due to breaking the cinematography 180° rule.

Is there a command available to manually flip the minimap, which could be invoked when calling cameraflip, but when MiniMapCanFlip is 0?

WatchTheFort commented 1 year ago

@badosu

sprunk commented 1 year ago

No engine change needed, the engine already exposes the tools. Do Spring.SetConfigInt("MiniMapCanFlip", 0) when enabling a free-rotation camera and Spring.SetConfigInt("MiniMapCanFlip", 1) when enabling the regular camera that can only flip. Alternatively, mark north on the minimap.

badosu commented 1 year ago

Yes, pretty much what @sprunk said. If the camera changes to whatever you don't want the minimap to flip on (say Spring camera), then disable MiniMapCanFlip.

Additionally, I think it makes sense to have a Callin for when camera controller changes, thoughts?

WatchTheFort commented 1 year ago

There shouldn't even be camera changes because there should only be one camera, but that's unrelated to this issue.

badosu commented 1 year ago

I don't necessarily disagree with that in some sense, but we gotta deal with things in retrocompatible and smooth ways.

badosu commented 1 year ago

I can expose Spring.SetMiniMapRotation, which was planned for the general behavior and gracefully degrades for the flipping behavior. Does that address the issue for you?

WatchTheFort commented 1 year ago

That sounds workable, for now I'll implements Sprung's suggestion, since I've broken it for players who play with a flipped map.

badosu commented 1 year ago

I dislike the current way DrawInMiniMap happens to be honest. I'm not at all comfortable with the engine not handling minimap rotation transformations itself.

It does not make sense for the game developers to have to apply those transformations themselves, and they can always get true north with GetMiniMapRotation. Alternatively, a Callin can be added for Minimap post tranformations, e.g. DrawInMiniMapPost. Thoughts @sprunk?

WatchTheFort commented 1 year ago

@sprunk Unfortunately, it didn't work, the minimap does not flip when the map flips.

local miniMapCanFlip = Spring.GetConfigInt('MiniMapCanFlip', 0)

if camState.flipped then
    Spring.SetConfigInt('MiniMapCanFlip', 1)
    camState.flipped = camState.flipped * -1
    Spring.SetCameraState(camState, 0)
    Spring.SetConfigInt('MiniMapCanFlip', miniMapCanFlip)
end

I checked, and it's hitting everything inside there.

badosu commented 1 year ago

For now you can mitigate for players that desire it with /Set MiniMapCanFlip 1

And in the place where you hardcode it to 0, just don't hardcode it (default is 0).

badosu commented 1 year ago

For the players that didn't get the change to 0, Set MiniMapCanFlip 0.

Arguably I don't get "the cinematography rule" for gameplay, if I have free rotation I prefer to have the minimap in the orientation that aligns with my north, although I've heard some players say they dislike the flipping.

For casting in particular, there should be a setting for "Casting Mode" that sets sane defaults for casting specifically.

WatchTheFort commented 1 year ago

It's cinematography not as in movies, but as in a camera and a viewer. The issue is that it flips 0°-180°-0°, reversing left and right, causing the viewer to lose their orientation and points of reference. This is different than having a the minimap use continuous rotation.

sprunk commented 1 year ago
local miniMapCanFlip = Spring.GetConfigInt('MiniMapCanFlip', 0)

if camState.flipped then
    Spring.SetConfigInt('MiniMapCanFlip', 1)
    camState.flipped = camState.flipped * -1
    Spring.SetCameraState(camState, 0)
    Spring.SetConfigInt('MiniMapCanFlip', miniMapCanFlip)
end

Why are you relying on flipped, isn't that only for the regular overhead camera and doesn't apply to the cameras that rotate? Why are you using SetCameraState? That affects the camera and not the minimap. Why are you setting the config int back to the original value? That sounds like it would revert whatever you tried to do.

I thought you'd just do something like this https://github.com/beyond-all-reason/Beyond-All-Reason/commit/79a7803f47b67c625d71dfb5416bfcd6a52faa71

There shouldn't even be camera changes because there should only be one camera

Your game is free not to use the other cameras.

Additionally, I think it makes sense to have a Callin for when camera controller changes, thoughts?

Sounds good.