Skip to content

Commit

Permalink
Calibration setting
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Dec 19, 2022
1 parent 4713b1f commit 8296c6d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
10 changes: 3 additions & 7 deletions Assets/Script/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ public static Game Instance {
private bool songStarted = false;

private float realSongTime = 0f;
private float calibration = 0f;
public float SongTime {
get => realSongTime + calibration;
get => realSongTime + PlayerManager.globalCalibration;
}

public Chart chart;
Expand All @@ -41,7 +40,6 @@ private void Awake() {
Instance = this;

chart = null;
calibration = -0.23f;
realSongTime = 0f;

// Song
Expand Down Expand Up @@ -95,13 +93,11 @@ private void Update() {
realSongTime += Time.deltaTime;

if (Keyboard.current.upArrowKey.wasPressedThisFrame) {
calibration += 0.01f;
Debug.Log(calibration);
PlayerManager.globalCalibration += 0.01f;
}

if (Keyboard.current.downArrowKey.wasPressedThisFrame) {
calibration -= 0.01f;
Debug.Log(calibration);
PlayerManager.globalCalibration -= 0.01f;
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Assets/Script/PlayerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ public static bool LowQualityMode {
QualitySettings.SetQualityLevel(_lowQualityMode ? 0 : 1, true);
}
}

public static float globalCalibration = -0.4f;
}
}
11 changes: 11 additions & 0 deletions Assets/Script/UI/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ private void SetupMainMenu() {

PlayerManager.LowQualityMode = lowQuality.value;
});

// Calibration
var calibrationField = root.Q<FloatField>("Calibration");
calibrationField.value = PlayerManager.globalCalibration;
calibrationField.RegisterValueChangedCallback(e => {
if (calibrationField != e.target) {
return;
}

PlayerManager.globalCalibration = calibrationField.value;
});
}

private void SetupPreSong() {
Expand Down
5 changes: 3 additions & 2 deletions Assets/UI/MainMenu.uxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
<ui:Button tabindex="0" text="Play" display-tooltip-when-elided="true" name="PlayButton" />
<ui:Button tabindex="1" text="Add/Edit Players" display-tooltip-when-elided="true" name="EditPlayersButton" />
</ui:VisualElement>
<ui:VisualElement style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); width: 219px;">
<ui:VisualElement style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); width: 250px; align-self: flex-end;">
<ui:Button tabindex="1" text="Host LAN File Server" display-tooltip-when-elided="true" name="HostServer" style="width: 196px;" />
<ui:TextField picking-mode="Ignore" name="ServerIP" value="localhost" style="width: 199px;" />
<ui:Button tabindex="-1" text="Join LAN File Server" display-tooltip-when-elided="true" name="JoinServer" style="width: 191px;" />
<ui:Toggle label="Low Quality" name="LowQuality" style="position: absolute; bottom: 0;" />
<ui:Toggle label="Low Quality" name="LowQuality" />
<ui:FloatField label="Calibration" value="0" name="Calibration" />
</ui:VisualElement>
</ui:UXML>
4 changes: 2 additions & 2 deletions ProjectSettings/QualitySettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
QualitySettings:
m_ObjectHideFlags: 0
serializedVersion: 5
m_CurrentQuality: 0
m_CurrentQuality: 1
m_QualitySettings:
- serializedVersion: 3
name: Low
Expand Down Expand Up @@ -114,7 +114,7 @@ QualitySettings:
Nintendo Switch: 1
PS4: 1
PS5: 1
Server: 0
Server: 1
Stadia: 1
Standalone: 1
WebGL: 0
Expand Down

0 comments on commit 8296c6d

Please sign in to comment.