Skip to content

Added possibility to change the number of levels to be voteable - #3

Open
npXXX wants to merge 5 commits into
pneben:mainfrom
npXXX:voteable-level-number
Open

npXXX wants to merge 5 commits into
pneben:mainfrom
npXXX:voteable-level-number

Conversation

@npXXX

@npXXX npXXX commented Apr 30, 2025

Copy link
Copy Markdown

Hi,
my friends and I would like to be able to set the number of levels that can be voted on.
If for example 3 levels should be voteable, this gets 3 random levels from all available ones to be voted on.
Would be great if we could get this merged, maybe others would like it too 👍

@pneben

pneben commented Apr 30, 2025

Copy link
Copy Markdown
Owner

Great addition!
I'll try it out later today and merge + publish it.

Thank you!

@npXXX

npXXX commented Apr 30, 2025

Copy link
Copy Markdown
Author

I got around to testing with a friend and there's a slight problem: The possible levels than can be voted for aren't synchronized. No problem if ALL levels are present, but very much a problem if there's only 2 or 3. I'm currently looking into that.

@pneben

pneben commented Apr 30, 2025

Copy link
Copy Markdown
Owner

I got around to testing with a friend and there's a slight problem: The possible levels than can be voted for aren't synchronized. No problem if ALL levels are present, but very much a problem if there's only 2 or 3. I'm currently looking into that.

You could add a NetworkedEvent from REPOLib to sync the possibilities

npXXX and others added 2 commits April 30, 2025 22:04
Known bugs: host can't close the voting page, updating the number in the config doesn't work when in vote/game right now
Added synchronization of available levels.
@npXXX

npXXX commented Apr 30, 2025 •

Copy link
Copy Markdown
Author

Thanks, I've done that. For some reason the mod vote button doesn't close the vote menu for the host, but for the clients it works. Also updating the number of maps to be voted on while in a lobby doesn't quite work right, you have to restart the lobby to have that change reflected in the menu.

Maybe you have an idea for those two points. Everything else seems to work as it should.

(the weird merge is there because I accidentally pushed to main instead of the correct branch - sorry)

@pneben

pneben commented Apr 30, 2025

Copy link
Copy Markdown
Owner

I'll look into the two problems you've listed. Also I'd like to suggest some things about the implementation, those are (possibly more):

  • Not-Votable maps should be visible but disabled and always at the end of the votes (i.e. votables are always prioritized to the top) - The code is already implemented to grey-out buttons, but it's kinda single-purpose right now and I'd prefer a attribute Disabled at VoteButtonOption.cs.
    See the second parameter:

    b.UpdateLabel(false, HasBeenLastPlayed(b.Level));

  • The event OnPlayerConnected it not necessary as it'll just call OnMapsRandomized indirectly. This way you could also directly call OnMapsRandomized in Patches/SteamManagerPatch.cs

If you want to change those things by yourself, feel free to!
Otherwise let me know and I'll take it from here 👍

Non-votable maps are now displayed but disabled. Votable maps (and the random option) are displayed at the top of the list.
Player connection event handler gets called directly, without the unnecessary event.
VoteOptionButton now has a "Disabled" property with extension methods to change the disabled state.
Changing the number of votable maps in the config will re-randomize votable maps according to the number that is configured, even while in game/lobby.
@npXXX

npXXX commented May 1, 2025 •

Copy link
Copy Markdown
Author

Hi, I changed the code based on your suggestions and found a solution for updating the number of maps while in a lobby. The host still can't close the vote popup manually though.

Screenshot 2025-05-01 120514

I wasn't able to test the changes in multiplayer as I had no one available for testing just now, but I didn't really change anything regarding that, should be fine. I'll test that later, hopefully.

Client wasn't able to interact with anything except the vote popup in lobby - caused by directly calling HandleOnPlayerConnected instead of letting the client inform the host. Probably because the time differential between the player joining and the host sending the data
Votes weren't cleared when re-randomizing the levels on config change, potentially causing disabled levels to be voted
Fixed last played level being included in random levels (if config option to disable last played level was true)
@npXXX

npXXX commented May 1, 2025

Copy link
Copy Markdown
Author

While testing some bad things popped up: By not utilizing the event the UI somehow got disabled for clients. This seems to be caused by the difference in time the client needs to send the event -> the host receiving it and sending the data -> the client processing it. Because of that I went back to using the event.
Also the votes weren't cleared when the number of votable levels changed. This could cause disabled levels to have votes on them.
The last played level now also isn't included in the random selection anymore, if the config is set to exclude it.

Now it works as expected!

Hope this is good 👍

@pneben

pneben commented May 2, 2025

Copy link
Copy Markdown
Owner

@npXXX Thanks! I'll check it out later 👍

@npXXX

npXXX commented May 4, 2025

Copy link
Copy Markdown
Author

Hey,
I got around to testing with more friends, we got very weird results. For some it worked (as long as the config was the same as the host - that alone is weird), others couldn't use the menu elements again. I honestly don't know what could cause that.
While "on the road" after a shop nobody except the host was able to use the vote menu... I'll look if I can find any causes, but in it's current modified state the mod isn't really usable.

@pneben

pneben commented May 5, 2025

Copy link
Copy Markdown
Owner

@npXXX Does this problem only occur on this Branch, i.e. with your current changes or also on the main branch?

@npXXX

npXXX commented May 9, 2025

Copy link
Copy Markdown
Author

Hi, we tested the original, unmodified version and the problem with the unresponsive menu UI didn't appear.
However, we noticed two unrelated problems: The voting between levels didn't work at all for clients, they couldn't use the vote UI. Only the host was able to do anything with it.
Additionally we noticed that if a client votes, then leaves the lobby and reconnects their vote persists and they can actually vote again. As the votes aren't stored with any identification and therefore can't be removed on disconnect I can see why that happens, but that might be a relatively simple fix, like storing the clients name or steam ID or something along with the vote.

@pneben

pneben commented May 11, 2025

Copy link
Copy Markdown
Owner

Thank you! I'll look into that 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants