Opened 3 years ago

Closed 22 months ago

Last modified 18 months ago

#3168 closed enhancement (fixed)

[PATCH] Let observer change perspective

Reported by: elexis Owned by: elexis
Priority: Should Have Milestone: Alpha 20
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description

Observers should be able to change the perspective, just like the function in the developers overlay. This way they can experience the game from one players perspective and see their fog of war.

This function is also required by the visual replay of games #9, since the program will be in observer mode then and we want to change the perspective when replaying games too.

Attachments (5)

t3168_let_observer_change_perspective_wip1.patch (21.3 KB) - added by elexis 2 years ago.
Reuses the "change perspective" dropdown list. Works for the top panel (resources, population count, civ icon), trade & diplomacy window and updates the hero & tech research overlay. TODO: (1) Line-of-sight (How to handle SetCurrentDisplayedPlayer?? in SimContext???) (2) How to clean GuiInterface?? calls ('differentPlayer')? (3) Probably in another ticket implement TODO in menu.js L643, so that one can see researched techs in the ingame tech tree.
t3168_let_observer_change_perspective_wip1.1.patch (22.3 KB) - added by elexis 2 years ago.
Rebased. Has a bug when starting as a player and then changing perspective to observer. Still doesn't change fog-of-war.
t3168_preparative_cleanup_v1.patch (4.6 KB) - added by elexis 2 years ago.
This should be committed separately.
t3168_let_observer_change_perspective_v1.patch (28.0 KB) - added by elexis 23 months ago.
t3168_fog_of_war_v1.patch (7.8 KB) - added by elexis 22 months ago.
Updates the fog of war if the observer changes the viewed player. This means the SimContext must be non-const since that class holds the globals checked by the components.

Download all attachments as: .zip

Change History (27)

comment:1 Changed 3 years ago by leper

Milestone: Alpha 19Backlog

It might be nice to do so for observers, but doing so without ensuring that observers can't send messages on behalf of the player they switched to is required.

comment:2 Changed 3 years ago by elexis

I think the easiest way to go is to make the dropdown list of the change-perspective tool accessible to observers too, but to make sure that all commands are disabled, unless the change-perspective option in the developers overlay is enabled.

Changed 2 years ago by elexis

Reuses the "change perspective" dropdown list. Works for the top panel (resources, population count, civ icon), trade & diplomacy window and updates the hero & tech research overlay. TODO: (1) Line-of-sight (How to handle SetCurrentDisplayedPlayer?? in SimContext???) (2) How to clean GuiInterface?? calls ('differentPlayer')? (3) Probably in another ticket implement TODO in menu.js L643, so that one can see researched techs in the ingame tech tree.

comment:3 Changed 2 years ago by elexis

Keywords: patch added
Milestone: BacklogAlpha 20
Owner: set to elexis
Status: newassigned
Summary: Let observer change perspective[PATCH] Let observer change perspective

The patch should be split into multiple commits, starting with a partial, rebased and cleaned version of the pach above.

comment:4 Changed 2 years ago by elexis

Sometimes one wants to compare two specific players throughout the whole game. However selecting the correct item from the dropdown becomes annoying quickly.

A hotkey with which you could switch back the perspective to the previously selected player would be nice.

comment:5 Changed 2 years ago by stanislas69

Actually it should not switch back, it should just switch. In general games at most, you'll have to press the hotkey three times or more, which shouldn't be that much trouble.

Changed 2 years ago by elexis

Rebased. Has a bug when starting as a player and then changing perspective to observer. Still doesn't change fog-of-war.

Changed 2 years ago by elexis

This should be committed separately.

comment:6 Changed 23 months ago by elexis

Keywords: review added

Changing the fog-of-war requires C++ changes, to be done afterwards. If I don't get any complaints, the commit message will be:


Let observers change perspective.

Disable the controls for observers unless the developer-option is enabled. Don't check for g_IsObserver, since observers should be able to use the developer overlay as well. Update all GUI elements when changing the perspective using onSimulationUpdate(). Enable observermode for defeated players.

comment:7 Changed 22 months ago by elexis

In 17675:

Let observers change perspective. Refs #3168.

Disable the controls for observers (unless the developer-option is enabled).
Don't check for g_IsObserver, since observers should be able to use the developer overlay as well.
Update all GUI elements when changing the perspective using onSimulationUpdate().
Enable observermode for defeated players.

comment:8 Changed 22 months ago by elexis

Keywords: review removed

Thanks mimo for doing a brief review on satuday.

The ticket is not completely finished since some more things like entity selection and some GUIInterface calls also need to be updated to fully support the dropdown for observers.

comment:9 Changed 22 months ago by elexis

In 17704:

Update the unit selection for observers, refs #3168.
Don't disable the deselect button.

Changed 22 months ago by elexis

Attachment: t3168_fog_of_war_v1.patch added

Updates the fog of war if the observer changes the viewed player. This means the SimContext must be non-const since that class holds the globals checked by the components.

comment:10 Changed 22 months ago by elexis

Keywords: review added

Remaining TODO for this ticket:

  1. Fog of war changes (see patch above)
  2. Remove the player argument from GUIInterfaceCall, since that's mostly unused now

comment:11 Changed 22 months ago by elexis

In 17733:

Add color indicator to the playerselection in observermode, refs #3168.

comment:12 Changed 22 months ago by elexis

Resolution: fixed
Status: assignedclosed

In 17735:

Show fog of war in observermode, fixes #3168.

comment:13 Changed 22 months ago by elexis

Keywords: review removed

comment:14 Changed 22 months ago by elexis

In 17745:

Fix compile error for gcc 4.6, refs #3168.

comment:15 Changed 22 months ago by elexis

In 17758:

Improve and fix some wrong observer-checks that didn't take defeated players into account. Refs #3168, #3215.
Introduce isPlayerObserver to easily cover that case.
Move some checks and updates into selectViewPlayer and eliminate setObserverMode.
Initialize the music before changing the perspective.

comment:16 Changed 22 months ago by elexis

When an observer changes perspective, the selection and health bars also need to be updated.

PickNonGaiaEntitiesOnScreen (or a called function) needs to remove entities which are not visible in the fog of war of the selected player, if the current playerID is different from the viewed player.

comment:17 Changed 21 months ago by elexis

In 17786:

Show time-notifications to observers, refs #3168.

comment:18 Changed 21 months ago by elexis

In 17832:

Immediately set the fog-of-war instead of waiting for session.js to load, refs #3168.

comment:19 Changed 18 months ago by elexis

In 18201:

Simulation context cleanup, refs #3991, #3168.

Save the viewed player in the CGame class.
Add the const keyword back to the SimContext? to help find mistakes at compiletime.

comment:20 Changed 18 months ago by elexis

In 18223:

Take new observermode into account in some missing places, refs #3850, #3168.

comment:21 Changed 18 months ago by elexis

In 18283:

GUIInterface / observermode cleanup as recommended by leper, fixes #3999.

Default to the viewed player in the GUIInterface to avoid passing that separately in some places, refs #3168.
Thus GetEntityState? will be called for the viewed player instead of observer playerID, therefore
fixes a fog-of-war selection relict when changing the perspective, refs #3850.
Also remove some unused player arguments.

comment:22 Changed 18 months ago by elexis

In 18346:

Continue to allow cheating and some other commands after winning the game. Refs #3168.

Note: See TracTickets for help on using tickets.