Skip to content

Commit

Permalink
Add ability for players to select Pro Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
MatrikMoon committed Sep 15, 2023
1 parent 9f309b4 commit aa5cf8d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
2 changes: 1 addition & 1 deletion TournamentAssistant/PluginClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ async void loadSongAction(string hash, bool succeeded)
songSpeed,
playSong.GameplayParameters.GameplayModifiers.Options.HasFlag(GameOptions.NoArrows),
playSong.GameplayParameters.GameplayModifiers.Options.HasFlag(GameOptions.GhostNotes),
playSong.GameplayParameters.GameplayModifiers.Options.HasFlag(GameOptions.ProMode),
playSong.GameplayParameters.GameplayModifiers.Options.HasFlag(GameOptions.ProMode) || playerData.gameplayModifiers.proMode, // Allow players to override promode setting,
playSong.GameplayParameters.GameplayModifiers.Options.HasFlag(GameOptions.ZenMode),
playSong.GameplayParameters.GameplayModifiers.Options.HasFlag(GameOptions.SmallCubes)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ abstract class FlowCoordinatorWithClient : FlowCoordinator, IFinishableFlowCoord
private OngoingGameList _ongoingGameList;
private PasswordEntry _passwordEntry;
private GameplaySetupViewController _gameplaySetupViewController;
private GameplayModifiersPanelController _gameplayModifiersPanelController;

protected virtual async Task OnUserDataResolved(string username, ulong userId)
{
Expand All @@ -50,6 +51,7 @@ protected override void DidActivate(bool firstActivation, bool addedToHierarchy,
_passwordEntry.PasswordEntered += PasswordEntry_PasswordEntered;

_gameplaySetupViewController = Resources.FindObjectsOfTypeAll<GameplaySetupViewController>().First();
_gameplayModifiersPanelController = Resources.FindObjectsOfTypeAll<GameplayModifiersPanelController>().First();
}
}

Expand Down Expand Up @@ -173,11 +175,15 @@ public virtual void Dismiss()
{
DismissViewController(_passwordEntry, immediately: true);
}

if (_ongoingGameList.isInViewControllerHierarchy)
{
SetLeftScreenViewController(null, ViewController.AnimationType.None);
SetRightScreenViewController(null, ViewController.AnimationType.None);
}

ReenableDisallowedModifierToggles(_gameplayModifiersPanelController);

RaiseDidFinishEvent();
}

Expand All @@ -195,14 +201,41 @@ protected virtual Task ConnectedToServer(Response.Connect response)
//Needs to run on main thread
UnityMainThreadDispatcher.Instance().Enqueue(() =>
{
_gameplaySetupViewController.Setup(false, true, true, false, PlayerSettingsPanelController.PlayerSettingsPanelLayout.Singleplayer);
_gameplaySetupViewController.Setup(true, true, true, false, PlayerSettingsPanelController.PlayerSettingsPanelLayout.Singleplayer);
SetLeftScreenViewController(_gameplaySetupViewController, ViewController.AnimationType.In);
DisableDisallowedModifierToggles(_gameplayModifiersPanelController);
SetRightScreenViewController(_ongoingGameList, ViewController.AnimationType.In);
_ongoingGameList.SetMatches(Plugin.client.State.Matches.ToArray());
});
return Task.CompletedTask;
}

private void DisableDisallowedModifierToggles(GameplayModifiersPanelController controller)
{
var toggles = controller.GetField<GameplayModifierToggle[]>("_gameplayModifierToggles");
var disallowedToggles = toggles.Where(x => x.name != "ProMode");

foreach (var toggle in disallowedToggles)
{
toggle.gameObject.SetActive(false);
}
}

private void ReenableDisallowedModifierToggles(GameplayModifiersPanelController controller)
{
var toggles = controller.GetField<GameplayModifierToggle[]>("_gameplayModifierToggles");

if (toggles != null)
{
foreach (var toggle in toggles)
{
toggle.gameObject.SetActive(true);
}
}
}

protected virtual Task FailedToConnectToServer(Response.Connect response) { return Task.CompletedTask; }

protected virtual Task ServerDisconnected()
Expand Down
5 changes: 3 additions & 2 deletions TournamentAssistant/UI/FlowCoordinators/RoomCoordinator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,7 @@ private void TeamSelection_TeamSelected(Team team)
Destroy(_teamSelection.screen.gameObject);
}

private void SongSelection_SongSelected(GameplayParameters parameters) =>
SongSelection_SongSelected(parameters.Beatmap.LevelId);
private void SongSelection_SongSelected(GameplayParameters parameters) => SongSelection_SongSelected(parameters.Beatmap.LevelId);

private async void SongSelection_SongSelected(string levelId)
{
Expand Down Expand Up @@ -516,7 +515,9 @@ protected override async Task LoadedSong(IBeatmapLevel level)
{
//If the player is still on the results screen, go ahead and boot them out
if (_resultsViewController.isInViewControllerHierarchy)
{
ResultsViewController_continueButtonPressedEvent(null);
}
SongSelection_SongSelected(level.levelID);
});
Expand Down
4 changes: 3 additions & 1 deletion TournamentAssistantShared/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public static class Constants
"0.6.8: Update for 1.25.0\n" +
"0.6.9: Fixed Discord ids being stored as integers, add password entry prompt in-game\n" +
"0.7.0: Some server synchronization fixes, for players and users that means more stability\n" +
"0.7.3: Update for 1.29.1";
"0.7.3: Update for 1.29.1\n" +
"0.7.4: Score update fix\n" +
"0.7.5: Add ability for players to select Pro Mode";

public enum BeatmapDifficulty
{
Expand Down

0 comments on commit aa5cf8d

Please sign in to comment.