GD Resources logo

Chapter 2: Adding Song Credits #

OmgRod avatar
Written by:
OmgRod
Owner

A lot of the code in the following tutorial comes from GD Surge by OmgRod (which parts of it come from other existing GD fangames like Lunar and Odyssey), so credit to the developers of these mods for writing this code!

A YouTube tutorial for this is coming very soon... 👀

To give your artists credit (and, most importantly, to display the correct links) we once again hook the LevelTools class.

cpp
1#include <Geode/Geode.hpp>
2#include <Geode/modify/LevelTools.hpp>
3
4using namespace geode::prelude;
5
6class $modify(MyLevelTools, LevelTools) {
7 // Where you set the song URL
8 gd::string urlForAudio(int audioID) {
9 switch(audioID) {
10 case -1: return "https://www.youtube.com/watch?v=5Epc1Beme90";
11 case 0: return "https://www.youtube.com/watch?v=LfgzPpmjM0M";
12 case 1: return "https://www.youtube.com/watch?v=8S9ZpjyrP0A";
13 default: return "";
14 }
15 }
16
17 // Where you set the Newgrounds of that specific artist
18 gd::string ngURLForArtist(int artistID) {
19 switch(artistID) {
20 case 1: return "https://boomkitty.newgrounds.com/";
21 case 2: return "https://waterflame.newgrounds.com/";
22 default: return "";
23 }
24 }
25
26 // Where you set the YouTube channel of that specific artist
27 gd::string ytURLForArtist(int artistID) {
28 switch(artistID) {
29 case 1: return "https://www.youtube.com/@BoomKitty";
30 case 2: return "https://www.youtube.com/@WaterflameMusic";
31 default: return "";
32 }
33 }
34
35 // Where you set the Facebook page of that specific artist
36 gd::string fbURLForArtist(int artistID) {
37 switch(artistID) {
38 case 2: return "https://www.facebook.com/Waterflameworkshop/";
39 default: return "";
40 }
41 }
42};

Changing the credits page #

To change the credits page (SongsLayer), we hook that class:

cpp
1#include <Geode/Geode.hpp>
2#include <Geode/modify/SongsLayer.hpp>
3
4using namespace geode::prelude;
5
6class $modify(MySongsLayer, SongsLayer) {
7 void customSetup() {
8 CCArray* songObjectArray = CCArray::create();
9 songObjectArray->addObject(SongObject::create(0)); // level 1
10 songObjectArray->addObject(SongObject::create(1)); // level 2
11 // ...
12 songObjectArray->addObject(SongObject::create(-1)); // practice song
13
14 m_listLayer->m_listView = CustomListView::create(songObjectArray, nullptr, 220.0, 356.0, 0, BoomListType::Song, 0.0);
15 m_listLayer->addChild(m_listLayer->m_listView);
16 }
17};

Since there is no init() function in this class, we had to modify the customSetup() function (which for now you can think of as being the same as init except it returns void).

Now, you should have fully working custom artist credits pages in GD. If you still need help, feel free to ask a question on GitHub!