Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in-game server menu #6

Open
Jenna1337 opened this issue Dec 6, 2024 · 4 comments
Open

Add in-game server menu #6

Jenna1337 opened this issue Dec 6, 2024 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Jenna1337
Copy link
Member

Add an in-game menu that lets the player pick which server to connect to from a list of servers the player has previously connected to, and discovered LAN servers.

Note: LAN discovery requires #5

@Jenna1337 Jenna1337 added enhancement New feature or request help wanted Extra attention is needed labels Dec 6, 2024
@Jenna1337 Jenna1337 pinned this issue Dec 6, 2024
@gmottajr
Copy link

gmottajr commented Dec 6, 2024

Hi @Jenna1337,

I’d love to collaborate on implementing the in-game server menu! Before getting started, I’d appreciate it if you could clarify a few technical details so I can ensure my approach aligns with the current structure of the project:
Technical Context:
Does the game already have a method of saving previously connected servers, or will we need to implement that functionality?
What does the current server connection system look like? Do we need to modify any existing code or add new methods?
How does the LAN server discovery work, and what dependencies are required to enable it?

UI/UX Requirements:
Is there an existing UI system for menus, or will we need to create a new one from scratch?
How should the server list be displayed? Should it just show server names, or do you want to include more detailed information (e.g., server IPs, names, player counts)?

Server Data Format:
What information is stored for each server in the list? Will we need to create a class or structure to hold the server data?
Network Handling:
How does the game currently handle connecting to servers? Do we need to modify or extend any networking code for this feature?

Looking forward to your feedback,
Best regard!

@Jenna1337
Copy link
Member Author

@gmottajr
To address your questions one by one:
There is currently not a method of saving servers.
The server connection currently uses TCP/IP. The code that handles network data transfer should not require any modifications, but the FezMultiplayerMod class (FezMultiplayerMod/MultiplayerMod/FezMultiplayerMod.cs) will require changes, which calls mp.ConnectToServerAsync(IPEndPoint) to connect to the server.
Additionally, the LAN server discovery has not been implemented yet (see #5).

As for UI,
There is a menu system, but I am currently unsure how much of it is suitable for our needs. I think our menu should integrate with the game's menus, but idk the best way to add stuff to them. I know @Krzyhau did some stuff with modifying the menus in FEZ before; perhaps he can help?
I think for now the server list should just show server names; just a list where the user can add and remove entries from the list, and connect to whichever server they select.

There is currently not a structure for holding server data, but entries should require an IPEndPoint and maybe also a name so the players don't have to distinguish by IP addresses.
As for how it currently connects to servers, the FezMultiplayerMod class (FezMultiplayerMod/MultiplayerMod/FezMultiplayerMod.cs) calls mp.ConnectToServerAsync(IPEndPoint) to connect to the server. The underlying code that handles network data should not require any modifications.
We should be able to add this in as a feature in the FezMultiplayerMod class.

Note as I am unsure about the the capabilities of the game's menu system (I don't believe FEZ has a DrawableGameComponent for inputting text), we will probably have to make at least one more class that extends DrawableGameComponent, maybe more.

I hope that answered your questions.

@gmottajr
Copy link

gmottajr commented Dec 6, 2024

Hi @Jenna1337,
Awesome!
Thanks for the detailed response! This helps a lot in shaping the approach. Here's how I plan to proceed based on the clarifications you provided:

Technical Context:

  • Server Saving: Since there isn’t a method for saving servers yet, I will implement functionality to store and retrieve the list of previously connected servers. I will consider using a simple storage mechanism, like saving the list to a configuration file (e.g., JSON or INI format), so the user doesn't lose their server history between sessions.

  • Server Connection: The current system uses mp.ConnectToServerAsync(IPEndPoint) for server connections, and I understand that we don't need to modify the network transfer code. I'll focus on modifying the FezMultiplayerMod class to handle server connections from the server list, and possibly refactor the existing code to integrate this new feature smoothly.

  • LAN Discovery: Since LAN discovery isn’t implemented yet (see Add network discovery #5), I’ll hold off on integrating this until that feature is in place. However, I’ll make sure the server list is easily extendable so that once LAN discovery is ready, it can be added without much hassle.

UI/UX:

  • Menu Integration: I'll look into how the menu system works in FEZ. If modifications are needed to integrate our server list, I’ll investigate how to extend the current menu system. If it turns out that the existing menus are too limiting, I’ll be ready to create new components, potentially by extending DrawableGameComponent as you suggested. I’ll also reach out to @Krzyhau for advice on modifying menus in FEZ.

  • Server List: For the initial implementation, I’ll create a simple list that shows server names, with options to add, remove, and connect to servers. The player can select from the list, and the server will be connected using the mp.ConnectToServerAsync(IPEndPoint) method.

  • Server Data: I’ll create a simple structure to hold the server data, consisting of the IPEndPoint and the server name. This way, players won’t need to remember or distinguish between IP addresses.

Once I’ve implemented the feature, I’ll add a configuration file to save and load the list of servers, and I’ll also create unit tests to verify the server list functionality and integration.
How does that sound?
I’ll keep you posted on my progress. Let me know if there’s anything else you’d like me to consider or if you have any further input!

@Jenna1337
Copy link
Member Author

To save the list to a config file, you could modify MultiplayerClientSettings (FezMultiplayerMod/MultiplayerMod/MultiplayerClientSettings.cs) to store the server list there in lieu of MainEndpoint

For context, I recommend looking at

const string SettingsFilePath = "FezMultiplayerMod.ini";//TODO: probably should use an actual path instead of just the file name
MultiplayerClientSettings settings = IniTools.ReadSettingsFile(SettingsFilePath, new MultiplayerClientSettings());
mp = new MultiplayerClient(settings);
IniTools.WriteSettingsFile(SettingsFilePath, settings);
mp.ConnectToServerAsync(settings.MainEndpoint);

Also, when the server list is updated, please call IniTools.WriteSettingsFile(SettingsFilePath, settings);

(Note: (IniTools (Shared/IniTools.cs) doesn't currently support any kind of IEnumerable aside from arrays, but more we can always add support for more collection types)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants