From 6667b35062bd53196010f63403a9ad12d8b945bc Mon Sep 17 00:00:00 2001 From: Fleeym <61891787+Fleeym@users.noreply.github.com> Date: Sat, 20 Apr 2024 03:12:14 +0300 Subject: [PATCH] add CustomSongWidget --- src/CustomSongWidget.cpp | 83 +++++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/src/CustomSongWidget.cpp b/src/CustomSongWidget.cpp index 3b29f60..f0d9e8e 100644 --- a/src/CustomSongWidget.cpp +++ b/src/CustomSongWidget.cpp @@ -1,40 +1,63 @@ // #include "AddIDs.hpp" +#include "Geode/binding/InfoAlertButton.hpp" #include -// #include -#include +#include +#include using namespace geode::prelude; +using namespace geode::node_ids; -// $register_ids(CustomSongWidget) { -// setIDSafe(this, 0, "bg"); -// setIDSafe(this, 0, "loading-bar"); -// setIDSafe(this, 0, "song-name-label"); -// setIDSafe(this, 1, "author-name-label"); -// setIDSafe(this, 2, "id-and-size-label"); -// setIDSafe(this, 3, "error-label"); -// setIDSafe(this, 0, "buttons-menu"); -// auto customSongWidgetMenu = this->getChildByID("buttons-menu"); -// setIDSafe(customSongWidgetMenu, 0, "download-button"); -// setIDSafe(customSongWidgetMenu, 1, "cancel-button"); -// setIDSafe(customSongWidgetMenu, 2, "use-button"); -// setIDSafe(customSongWidgetMenu, 3, "refresh-button"); -// setIDSafe(customSongWidgetMenu, 4, "play-song-button"); -// setIDSafe(customSongWidgetMenu, 5, "more-button"); -// }; +$register_ids(CustomSongWidget) { + setIDSafe(this, 0, "bg"); + setIDSafe(this, 0, "loading-bar"); + m_songLabel->setID("song-name-label"); + m_artistLabel->setID("artist-label"); + m_songIDLabel->setID("id-and-size-label"); + m_errorLabel->setID("error-label"); + m_buttonMenu->setID("buttons-menu"); + m_downloadBtn->setID("download-button"); + m_cancelDownloadBtn->setID("cancel-button"); + m_selectSongBtn->setID("use-button"); + m_getSongInfoBtn->setID("get-song-info-button"); + m_playbackBtn->setID("play-song-button"); + m_moreBtn->setID("more-button"); + m_deleteBtn->setID("delete-button"); + setIDSafe(m_buttonMenu, 0, "info-button"); +}; -// struct CustomSongWidgetIDs : Modify { -// static void onModify(auto& self) { -// if (!self.setHookPriority("CustomSongWidget::init", GEODE_ID_PRIORITY)) { -// log::warn("Failed to set CustomSongWidget::init hook priority, node IDs may not work properly"); -// } -// } +struct CustomSongWidgetIDs : Modify { + static void onModify(auto& self) { + if (!self.setHookPriority("CustomSongWidget::init", GEODE_ID_PRIORITY)) { + log::warn("Failed to set CustomSongWidget::init hook priority, node IDs may not work properly"); + } + } -// bool init(SongInfoObject* s, LevelSettingsObject* l, bool b1, bool b2, bool b3, bool b4, bool hideBackground) { -// if (!CustomSongWidget::init(s, l, b1, b2, b3, b4, hideBackground)) return false; + bool init( + SongInfoObject* songInfo, + CustomSongDelegate* songDelegate, + bool showSongSelect, + bool showPlayMusic, + bool showDownload, + bool isRobtopSong, + bool unk, + bool isMusicLibrary + ) { + if (!CustomSongWidget::init( + songInfo, + songDelegate, + showSongSelect, + showPlayMusic, + showDownload, + isRobtopSong, + unk, + isMusicLibrary + )) { + return false; + } -// NodeIDs::get()->provide(this); + NodeIDs::get()->provide(this); -// return true; -// } -// }; \ No newline at end of file + return true; + } +}; \ No newline at end of file