-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from bookdude13/multiplayer
Multiplayer enhancements
- Loading branch information
Showing
10 changed files
with
306 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
|
||
set BUILT_VERSION="1.1.1" | ||
set MOD_NAME="SRVoting" | ||
set BUILT_VERSION=1.2.0 | ||
set MOD_NAME=SRVoting | ||
|
||
set RELEASE_BUILD_DIR=".\%MOD_NAME%\bin\Release" | ||
set MAIN_DLL="%RELEASE_BUILD_DIR%\%MOD_NAME%.dll" | ||
set LIB_DLL_DIR="%RELEASE_BUILD_DIR%\libs" | ||
set RELEASE_BUILD_DIR=.\%MOD_NAME%\bin\Release | ||
set MAIN_DLL=%RELEASE_BUILD_DIR%\%MOD_NAME%.dll | ||
set LIB_DLL_DIR=%RELEASE_BUILD_DIR%\libs | ||
|
||
set OUTPUT_DIR=".\build\%MOD_NAME%_v%BUILT_VERSION%" | ||
set OUTPUT_DIR=.\build\%MOD_NAME%_v%BUILT_VERSION% | ||
mkdir %OUTPUT_DIR% | ||
|
||
copy %MAIN_DLL% %OUTPUT_DIR% | ||
copy %LIB_DLL_DIR%\* %OUTPUT_DIR% | ||
set OUTPUT_MODS_DIR=%OUTPUT_DIR%\Mods | ||
mkdir %OUTPUT_MODS_DIR% | ||
|
||
copy %MAIN_DLL% %OUTPUT_MODS_DIR% | ||
copy %LIB_DLL_DIR%\* %OUTPUT_MODS_DIR% | ||
|
||
powershell Compress-Archive %OUTPUT_MODS_DIR% %OUTPUT_DIR%\%MOD_NAME%_v%BUILT_VERSION%.zip |
16 changes: 16 additions & 0 deletions
16
SRVoting/Harmony/Patch_MultiplayerRoomController_FillSelectedTrackData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using HarmonyLib; | ||
using Util.Controller; | ||
|
||
namespace SRVoting.Harmony | ||
{ | ||
// This is called during initialization (for the host), | ||
// and from Game_InfoProvider.OnEvent() with event code SetSelectedVersusTrack (for clients) | ||
[HarmonyPatch(typeof(MultiplayerRoomController), nameof(MultiplayerRoomController.FillSelectedTrackData))] | ||
public class Patch_MultiplayerRoomController_FillSelectedTrackData | ||
{ | ||
public static void Postfix(object[] data) | ||
{ | ||
SRVoting.Instance?.OnMultiplayerRoomUpdateTrackData(); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
SRVoting/Harmony/Patch_SongSelectionManager_OpenMultiplayerRoomMenu.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Synth.SongSelection; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using HarmonyLib; | ||
|
||
namespace SRVoting.Harmony | ||
{ | ||
[HarmonyPatch(typeof(SongSelectionManager), nameof(SongSelectionManager.OpenMultiplayerRoomMenu))] | ||
public class Patch_SongSelectionManager_OpenMultiplayerRoomMenu | ||
{ | ||
public static void Postfix(Synth.Versus.Room room) | ||
{ | ||
SRVoting.Instance?.OnOpenMultiplayerRoomMenu(room); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Collections; | ||
using UnityEngine; | ||
|
||
namespace SRVoting.MonoBehaviors | ||
{ | ||
public class VotingMainMenu : VotingMonoBehavior | ||
{ | ||
protected override IEnumerator EnsureUIExists() | ||
{ | ||
if (!upVoteComponent.IsUiCreated || !downVoteComponent.IsUiCreated) | ||
{ | ||
logger.Msg("Initializing Main Menu UI..."); | ||
|
||
// Find existing pieces | ||
var rootGO = GameObject.Find("CentralPanel/Song Selection/VisibleWrap"); | ||
|
||
var controlsGO = rootGO.transform.Find("Controls"); | ||
var volumeText = controlsGO.Find("MuteWrap/VALUE"); | ||
var volumeLeft = controlsGO.Find("MuteWrap/Arrow UP"); | ||
var volumeRight = controlsGO.Find("MuteWrap/Arrow Down"); | ||
|
||
var selectedTrackGO = rootGO.transform.Find("Selected Track"); | ||
var difficultiesGO = selectedTrackGO.transform.Find("Difficulties"); | ||
Transform hardButton = difficultiesGO.Find("StandardButton - Hard"); | ||
Transform customButton = difficultiesGO.Find("StandardButton - Custom"); | ||
|
||
// Create new pieces | ||
upVoteComponent.CreateUIForVertical(selectedTrackGO, difficultiesGO, hardButton, volumeLeft, volumeText.gameObject); | ||
downVoteComponent.CreateUIForVertical(selectedTrackGO, difficultiesGO, customButton, volumeRight, volumeText.gameObject); | ||
|
||
logger.Msg("Done creating main menu UI"); | ||
} | ||
|
||
yield return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using SRModCore; | ||
using System; | ||
using System.Collections; | ||
using UnityEngine; | ||
|
||
namespace SRVoting.MonoBehaviors | ||
{ | ||
public class VotingMultiplayer: VotingMonoBehavior | ||
{ | ||
protected override IEnumerator EnsureUIExists() | ||
{ | ||
var elementsCreated = upVoteComponent.IsUiCreated && downVoteComponent.IsUiCreated; | ||
if (!elementsCreated) | ||
{ | ||
logger.Msg("Initializing Multiplayer UI..."); | ||
|
||
try | ||
{ | ||
// Find existing pieces | ||
var rootGO = GameObject.Find("Multiplayer/RoomPanel/Rooms/BottomPanel"); | ||
|
||
var arrowsContainerGO = rootGO.transform.Find("MuteWrap"); | ||
var volumeText = arrowsContainerGO.Find("VALUE"); | ||
var volumeLeft = arrowsContainerGO.Find("Arrow UP"); | ||
var volumeRight = arrowsContainerGO.Find("Arrow Down"); | ||
|
||
var favoriteWrapGO = rootGO.transform.Find("Favorite Wrap"); | ||
|
||
// Create new pieces | ||
downVoteComponent.CreateUIForHorizontal( | ||
favoriteWrapGO, -1.5f, TMPro.TextAlignmentOptions.Right, volumeRight, volumeText.gameObject | ||
); | ||
upVoteComponent.CreateUIForHorizontal( | ||
favoriteWrapGO, 1.5f, TMPro.TextAlignmentOptions.Left, volumeLeft, volumeText.gameObject | ||
); | ||
|
||
logger.Msg("Done creating UI"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
logger.Error("Failed to initialize UI", ex); | ||
} | ||
} | ||
|
||
yield return null; | ||
} | ||
|
||
protected override IEnumerator UpdateVoteUI() | ||
{ | ||
var countdownTimerWrap = GameObject.Find("Multiplayer/RoomPanel/Rooms/BottomPanel/SongInfo/TimeWrap"); | ||
if (countdownTimerWrap != null && countdownTimerWrap.activeInHierarchy) | ||
{ | ||
logger.Msg("Moving countdown timer wrap"); | ||
// Originally at <2.4, 0.4, 0.0> | ||
countdownTimerWrap.transform.localPosition = new Vector3(4.4f, 0.4f, 0.0f); | ||
} | ||
|
||
return base.UpdateVoteUI(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.