From 9000c0a0050a6bd38cab7a1e5a711674f4fb8269 Mon Sep 17 00:00:00 2001 From: GregTao Date: Fri, 21 Mar 2025 17:37:05 +0800 Subject: [PATCH] =?UTF-8?q?fix.=20QQ=E9=9F=B3=E4=B9=90=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=AD=8C=E5=8D=95=E9=A1=B5=E9=9D=A2=E6=A6=82=E7=8E=87=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/top/gregtao/concerto/api/WithMetaData.java | 2 ++ src/main/java/top/gregtao/concerto/music/Music.java | 4 ++++ .../java/top/gregtao/concerto/music/list/Playlist.java | 4 ++++ .../screen/netease/NeteaseCloudUserScreen.java | 5 ++--- .../gregtao/concerto/screen/qq/QQMusicUserScreen.java | 10 ++-------- .../concerto/screen/widget/MetadataListWidget.java | 8 ++++++-- .../screen/widget/MusicWithUUIDListWidget.java | 8 ++++++-- 7 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/main/java/top/gregtao/concerto/api/WithMetaData.java b/src/main/java/top/gregtao/concerto/api/WithMetaData.java index 2c29c99..4249fe9 100644 --- a/src/main/java/top/gregtao/concerto/api/WithMetaData.java +++ b/src/main/java/top/gregtao/concerto/api/WithMetaData.java @@ -5,4 +5,6 @@ public interface WithMetaData { MetaData getMeta(); + + boolean isMetaLoaded(); } diff --git a/src/main/java/top/gregtao/concerto/music/Music.java b/src/main/java/top/gregtao/concerto/music/Music.java index 9f14c21..93223fd 100644 --- a/src/main/java/top/gregtao/concerto/music/Music.java +++ b/src/main/java/top/gregtao/concerto/music/Music.java @@ -56,6 +56,10 @@ public boolean isLoaded() { return this.isMetaLoaded; } + public boolean isMetaLoaded() { + return this.isMetaLoaded; + } + public abstract InputStream getMusicSource() throws MusicSourceNotFoundException; public abstract String getLink(); diff --git a/src/main/java/top/gregtao/concerto/music/list/Playlist.java b/src/main/java/top/gregtao/concerto/music/list/Playlist.java index 927e9c8..16be39f 100644 --- a/src/main/java/top/gregtao/concerto/music/list/Playlist.java +++ b/src/main/java/top/gregtao/concerto/music/list/Playlist.java @@ -35,6 +35,10 @@ public boolean isLoaded() { return this.loaded; } + public boolean isMetaLoaded() { + return this.loaded; + } + public boolean isAlbum() { return this.isAlbum; } diff --git a/src/main/java/top/gregtao/concerto/screen/netease/NeteaseCloudUserScreen.java b/src/main/java/top/gregtao/concerto/screen/netease/NeteaseCloudUserScreen.java index 3d200ab..f0b7316 100644 --- a/src/main/java/top/gregtao/concerto/screen/netease/NeteaseCloudUserScreen.java +++ b/src/main/java/top/gregtao/concerto/screen/netease/NeteaseCloudUserScreen.java @@ -55,6 +55,7 @@ protected void init() { this.playlistList = this.initWidget(); this.onPageTurned(0); + this.addDrawableChild(this.playlistList); this.addSelectableChild(this.playlistList); this.addDrawableChild(ButtonWidget.builder(Text.translatable("concerto.screen.daily_recommendation"), @@ -84,9 +85,7 @@ protected void init() { @Override public void render(DrawContext matrices, int mouseX, int mouseY, float delta) { super.render(matrices, mouseX, mouseY, delta); - if (this.loggedIn()) { - this.playlistList.render(matrices, mouseX, mouseY, delta); - } else { + if (!this.loggedIn()) { matrices.drawCenteredTextWithShadow(this.textRenderer, Text.translatable("concerto.screen.163.not_login"), this.width / 2, this.height / 2, 0xffffffff); } diff --git a/src/main/java/top/gregtao/concerto/screen/qq/QQMusicUserScreen.java b/src/main/java/top/gregtao/concerto/screen/qq/QQMusicUserScreen.java index ecd8f1a..7a2145e 100644 --- a/src/main/java/top/gregtao/concerto/screen/qq/QQMusicUserScreen.java +++ b/src/main/java/top/gregtao/concerto/screen/qq/QQMusicUserScreen.java @@ -15,8 +15,6 @@ import top.gregtao.concerto.screen.widget.ConcertoListWidget; import top.gregtao.concerto.screen.widget.MetadataListWidget; -import java.util.ListIterator; - public class QQMusicUserScreen extends PageScreen { private MetadataListWidget playlistList; @@ -54,6 +52,7 @@ protected void init() { this.playlistList = this.initWidget(); this.onPageTurned(0); + this.addDrawableChild(this.playlistList); this.addSelectableChild(this.playlistList); this.addDrawableChild(ButtonWidget.builder(Text.translatable("concerto.screen.play"), button -> { @@ -72,12 +71,7 @@ protected void init() { @Override public void render(DrawContext matrices, int mouseX, int mouseY, float delta) { super.render(matrices, mouseX, mouseY, delta); - if (this.loggedIn()) { - ListIterator.Entry> iterator = this.playlistList.children().listIterator(); - while (iterator.hasNext() && iterator.next().item.isLoaded()) { - if (!iterator.hasNext()) this.playlistList.render(matrices, mouseX, mouseY, delta); - } - } else { + if (!this.loggedIn()) { matrices.drawCenteredTextWithShadow(this.textRenderer, Text.translatable("concerto.screen.qq.not_login"), this.width / 2, this.height / 2, 0xffffffff); } diff --git a/src/main/java/top/gregtao/concerto/screen/widget/MetadataListWidget.java b/src/main/java/top/gregtao/concerto/screen/widget/MetadataListWidget.java index 02f91d2..691bf28 100644 --- a/src/main/java/top/gregtao/concerto/screen/widget/MetadataListWidget.java +++ b/src/main/java/top/gregtao/concerto/screen/widget/MetadataListWidget.java @@ -17,7 +17,11 @@ public MetadataListWidget(int width, int height, int top, int itemHeight, int co @Override public Text getNarration(int index, T t) { - MetaData meta = t.getMeta(); - return Text.literal(meta.title()).append(" ").append(Text.literal(meta.author()).formatted(Formatting.BOLD, Formatting.GRAY)); + if (t.isMetaLoaded()) { + MetaData meta = t.getMeta(); + return Text.literal(meta.title()).append(" ").append(Text.literal(meta.author()).formatted(Formatting.BOLD, Formatting.GRAY)); + } else { + return Text.translatable("concerto.loading"); + } } } diff --git a/src/main/java/top/gregtao/concerto/screen/widget/MusicWithUUIDListWidget.java b/src/main/java/top/gregtao/concerto/screen/widget/MusicWithUUIDListWidget.java index ec6cdd2..fab1a51 100644 --- a/src/main/java/top/gregtao/concerto/screen/widget/MusicWithUUIDListWidget.java +++ b/src/main/java/top/gregtao/concerto/screen/widget/MusicWithUUIDListWidget.java @@ -15,8 +15,12 @@ public MusicWithUUIDListWidget(int width, int height, int top, int itemHeight) { @Override public Text getNarration(int index, Pair t) { - MusicMetaData meta = t.getFirst().getMeta(); - return Text.literal(meta.title() + " - " + meta.getSource()); + if (t.getFirst().isMetaLoaded()) { + MusicMetaData meta = t.getFirst().getMeta(); + return Text.literal(meta.title() + " - " + meta.getSource()); + } else { + return Text.translatable("concerto.loading"); + } } public MusicWithUUIDListWidget(int width, int height, int top, int itemHeight, int color) {