Skip to content

Commit

Permalink
Bug and visual fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JLChnToZ committed Apr 21, 2024
1 parent 6e45114 commit 1aeea69
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Packages/idv.jlchntoz.vvmw/Runtime/VVMW/FrontendHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ void PlayQueueList(int index, bool deleteOnly) {

void RecordPlaybackHistory(VRCUrl url, byte playerIndex, string title) {
if (historySize <= 0) return;
if (localHistoryUrls != null || localHistoryUrls.Length == 0) {
if (localHistoryUrls == null || localHistoryUrls.Length == 0) {
localHistoryUrls = new VRCUrl[1] { url };
localHistoryPlayerIndex = new byte[1] { playerIndex };
localHistoryTitles = new string[1] { title };
Expand Down
9 changes: 9 additions & 0 deletions Packages/idv.jlchntoz.vvmw/Runtime/VVMW/PooledScrollView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ void OnEnable() {
scrollRect = GetComponent<ScrollRect>();
viewportRect = scrollRect.viewport;
contentRect = scrollRect.content;
var transformsAfterEntry = new Transform[contentRect.childCount];
int count = 0;
for (int i = contentRect.childCount - 1; i >= 0; i--) {
var child = contentRect.GetChild(i);
if (child == template.transform) break;
transformsAfterEntry[count++] = child;
}
templateRect = template.GetComponent<RectTransform>();
var templateHeight = templateRect.rect.height;
var viewportHeight = viewportRect.rect.height;
Expand All @@ -143,6 +150,8 @@ void OnEnable() {
entry._OnParentScroll();
entries[i] = entry;
}
for (int i = 0; i < count; i++)
transformsAfterEntry[i].SetAsLastSibling();
template.gameObject.SetActive(false);
EventPrefix = eventPrefix;
hasInit = true;
Expand Down
23 changes: 16 additions & 7 deletions Packages/idv.jlchntoz.vvmw/Runtime/VVMW/UIHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,25 @@ int SelectedPlayListIndex {
if (playListScrollView == null) return 0;
int selectedIndex = playListScrollView.SelectedIndex;
if (handler != null) {
if (handler.HistorySize > 0) selectedIndex--;
if (!handler.HasQueueList) selectedIndex++;
if (handler.HistorySize > 0) {
if (selectedIndex == 0) return -1;
if (handler.HasQueueList) selectedIndex--;
} else if (!handler.HasQueueList)
selectedIndex++;
}
return selectedIndex;
}
set {
if (playListScrollView == null) return;
if (value < 0) {
playListScrollView.SelectedIndex = 0;
return;
}
if (handler != null) {
if (handler.HistorySize > 0) value++;
if (!handler.HasQueueList) value--;
if (handler.HistorySize > 0) {
if (handler.HasQueueList) value++;
} else if (!handler.HasQueueList)
value--;
}
playListScrollView.SelectedIndex = value;
}
Expand Down Expand Up @@ -552,8 +561,6 @@ public void _OnUIUpdate() {
}
if (shuffleOnButton != null) shuffleOnButton.gameObject.SetActive(isShuffle);
UpdatePlayList();
if (playNextIndicator != null)
playNextIndicator.SetActive(!isShuffle && SelectedPlayListIndex == 0 && handler.PlayListIndex == 0 && handler.PendingCount > 0);
SetText(queueModeText, queueModeTMPro,
languageManager.GetLocale(
handler.PlayListIndex == 0 && handler.HasQueueList && (core.IsReady || core.IsLoading || handler.QueueUrls.Length > 0) ?
Expand Down Expand Up @@ -601,13 +608,15 @@ bool UpdatePlayList() {
if (isEntryContainerInactive || isNotCoolingDown)
SelectedPlayListIndex = selectedPlayListIndex = playListIndex;
if (playNextButton != null) playNextButton.gameObject.SetActive(hasPending);
if (currentPlayListButton != null) currentPlayListButton.gameObject.SetActive(hasPending);
if (currentPlayListButton != null) currentPlayListButton.gameObject.SetActive(hasPending && selectedPlayListIndex >= 0);
if (!string.IsNullOrEmpty(enqueueCountFormat))
SetText(enqueueCountText, enqueueCountTMPro, string.Format(enqueueCountFormat, pendingCount));
SetText(selectedPlayListText, selectedPlayListTMPro,
selectedPlayListIndex > 0 ? handler.PlayListTitles[selectedPlayListIndex - 1] :
selectedPlayListIndex < 0 ? languageManager.GetLocale("PlaybackHistory") : languageManager.GetLocale("QueueList")
);
if (playNextIndicator != null)
playNextIndicator.SetActive(!handler.Shuffle && selectedPlayListIndex == 0 && handler.PlayListIndex == 0 && handler.PendingCount > 0);
bool shouldRefreshQueue = playListUpdateRequired || selectedPlayListIndex <= 0 || lastSelectedPlayListIndex != selectedPlayListIndex || lastPlayingIndex != playingIndex;
lastSelectedPlayListIndex = selectedPlayListIndex;
lastPlayingIndex = playingIndex;
Expand Down

0 comments on commit 1aeea69

Please sign in to comment.