Opened 9 years ago

Closed 8 years ago

Last modified 8 years 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 9 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 9 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 9 years ago.
This should be committed separately.
t3168_let_observer_change_perspective_v1.patch (28.0 KB ) - added by elexis 8 years ago.
t3168_fog_of_war_v1.patch (7.8 KB ) - added by elexis 8 years 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 by leper, 9 years ago

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 by elexis, 9 years ago

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.

by elexis, 9 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.

comment:3 by elexis, 9 years ago

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 by elexis, 9 years ago

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 by Stan, 9 years ago

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.

by elexis, 9 years ago

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

by elexis, 9 years ago

This should be committed separately.

comment:6 by elexis, 8 years ago

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 by elexis, 8 years ago

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 by elexis, 8 years ago

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 by elexis, 8 years ago

In 17704:

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

by elexis, 8 years ago

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 by elexis, 8 years ago

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 by elexis, 8 years ago

In 17733:

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

comment:12 by elexis, 8 years ago

Resolution: fixed
Status: assignedclosed

In 17735:

Show fog of war in observermode, fixes #3168.

comment:13 by elexis, 8 years ago

Keywords: review removed

comment:14 by elexis, 8 years ago

In 17745:

Fix compile error for gcc 4.6, refs #3168.

comment:15 by elexis, 8 years ago

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 by elexis, 8 years ago

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 by elexis, 8 years ago

In 17786:

Show time-notifications to observers, refs #3168.

comment:18 by elexis, 8 years ago

In 17832:

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

comment:19 by elexis, 8 years ago

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 by elexis, 8 years ago

In 18223:

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

comment:21 by elexis, 8 years ago

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 by elexis, 8 years ago

In 18346:

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

Note: See TracTickets for help on using tickets.