Ambient icon indicating copy to clipboard operation
Ambient copied to clipboard

Update the client's window title with the server's project name

Open philpax opened this issue 2 years ago • 1 comments

This is a minor quality of life feature, but might be a good challenge for someone who wants to get to know the codebase.

To do this, you'll need to retrieve the project.name from the manifest on the server: https://github.com/AmbientRun/Ambient/blob/676012b96f6f839879cbf2cd280e3994ed008ca5/app/src/server/mod.rs#L63

(I suggest storing it as a component on the resource entity.)

You'll then need to send it to the client during the handshake: https://github.com/AmbientRun/Ambient/blob/676012b96f6f839879cbf2cd280e3994ed008ca5/crates/network/src/protocol.rs#L86

You will need to do some plumbing to get the project name to there.

This will then be accessible in ClientInstance::run: https://github.com/AmbientRun/Ambient/blob/676012b96f6f839879cbf2cd280e3994ed008ca5/crates/network/src/client.rs#L373

This is called by GameClientView above. Replicate the set_connection_status state hook, and pass in set_project_name to ClientInstance and call that once the project name is available.

In GameClientView, update the window_title component with project_name, similar to how it's done here: https://github.com/AmbientRun/Ambient/blob/676012b96f6f839879cbf2cd280e3994ed008ca5/app/src/client/mod.rs#L36

The GameClientView::render method is called every time its hook state changes, so you don't need to do anything special.

Note that there are two worlds on the client - the primary "UI" world (which is what the majority of the ElementComponents dealing with UI use), and the game world kept in ClientGameState. Make sure you're updating window_title on the former, not the latter.

philpax avatar Feb 24 '23 15:02 philpax

I could give it a try!

MavethGH avatar Feb 24 '23 23:02 MavethGH

Fixed by #178. (Annoying that updating the PR title didn't link the PR to this)

philpax avatar Feb 27 '23 10:02 philpax