Skip to content

Commit

Permalink
Add opt-out disc sprite switching based on music author
Browse files Browse the repository at this point in the history
  • Loading branch information
NotRyken committed Sep 6, 2024
1 parent 0ad3182 commit 8bf99e1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.github.scotsguy.nowplaying.config.Config;
import com.github.scotsguy.nowplaying.gui.toast.NowPlayingToast;
import com.github.scotsguy.nowplaying.mixin.GuiAccessor;
import com.github.scotsguy.nowplaying.sound.Sound;
import com.github.scotsguy.nowplaying.util.ModLogger;
import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.ChatFormatting;
Expand All @@ -13,7 +14,6 @@
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;

import static com.github.scotsguy.nowplaying.util.Localization.localized;
import static com.github.scotsguy.nowplaying.util.Localization.translationKey;
Expand Down Expand Up @@ -49,7 +49,7 @@ public static void displayLastMusic() {
}

public static void displayMusic(Component name) {
display(name, Items.MUSIC_DISC_CAT, Config.get().options.musicStyle);
display(name, Sound.getMusicDisc(name.getString()), Config.get().options.musicStyle);
}

public static void display(Component name, Item disc, Config.Options.Style style) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public static class Options {
public static final boolean defaultSimpleToast = false;
public boolean simpleToast = defaultSimpleToast;

public static final boolean defaultOnlyCat = false;
public boolean onlyCat = defaultOnlyCat;

public static final int defaultToastTime = 5;
public int toastTime = defaultToastTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ static Screen getConfigScreen(Screen parent) {
.setSaveConsumer(val -> options.simpleToast = val)
.build());

modSettings.addEntry(eb.startBooleanToggle(
localized("option", "only_cat"), options.onlyCat)
.setTooltip(localized("option", "only_cat.tooltip"))
.setDefaultValue(Config.Options.defaultOnlyCat)
.setSaveConsumer(val -> options.onlyCat = val)
.build());

modSettings.addEntry(eb.startIntField(
localized("option", "toast_time"), options.toastTime)
.setTooltip(localized("option", "toast_time.tooltip"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.github.scotsguy.nowplaying.sound;

import com.github.scotsguy.nowplaying.config.Config;
import net.minecraft.client.resources.sounds.SoundInstance;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;

import static com.github.scotsguy.nowplaying.util.Localization.localized;

Expand All @@ -12,4 +15,19 @@ public static Component getSoundName(SoundInstance instance) {
String soundName = splitSoundLocation[splitSoundLocation.length - 1];
return localized("music", soundName);
}

public static Item getMusicDisc(String music) {
if (Config.get().options.onlyCat) return Items.MUSIC_DISC_CAT;
if (music.startsWith("C418")) {
return Items.MUSIC_DISC_BLOCKS;
} else if (music.startsWith("Lena Raine")) {
return Items.MUSIC_DISC_OTHERSIDE;
} else if (music.startsWith("Aaron Cherof")) {
return Items.MUSIC_DISC_RELIC;
} else if (music.startsWith("Kumi Tanioka")) {
return Items.MUSIC_DISC_MALL;
} else {
return Items.MUSIC_DISC_CAT;
}
}
}
2 changes: 2 additions & 0 deletions common/src/main/resources/assets/now-playing/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"option.now-playing.toast_scale.tooltip": "Scale the size of the 'Now Playing' toast",
"option.now-playing.simple_toast": "Simple toast",
"option.now-playing.simple_toast.tooltip": "Only show the song, not the 'Now Playing' text",
"option.now-playing.only_cat": "Only Cat",
"option.now-playing.only_cat.tooltip": "Always show the 'Cat' disc for background music toasts",
"option.now-playing.toast_time": "Toast display time",
"option.now-playing.toast_time.tooltip": "The time, in seconds, to show the 'Now Playing' toast",
"option.now-playing.hotbar_time": "Hotbar display time",
Expand Down

0 comments on commit 8bf99e1

Please sign in to comment.