From 620bab5421bbea7b154cbe36907c5723844b3671 Mon Sep 17 00:00:00 2001 From: tartaric_acid Date: Fri, 20 Oct 2023 02:44:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=A3=B0=E9=9F=B3=E5=8C=85?= =?UTF-8?q?=20GUI=20=E7=95=8C=E9=9D=A2=E7=9A=84=E8=AE=BE=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/maid/AbstractMaidContainerGui.java | 2 + .../client/gui/sound/MaidSoundPackGui.java | 187 ++++++++++++++++++ .../gui/widget/button/FlatColorButton.java | 66 +++++++ .../gui/widget/button/SoundElementButton.java | 55 ++++++ .../gui/widget/button/SoundPackButton.java | 70 +++++++ .../client/sound/CustomSoundLoader.java | 8 +- .../assets/touhou_little_maid/lang/en_us.json | 35 ++++ .../assets/touhou_little_maid/lang/zh_cn.json | 37 +++- .../textures/gui/maid_custom_sound.png | Bin 0 -> 1427 bytes 9 files changed, 455 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/sound/MaidSoundPackGui.java create mode 100644 src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/widget/button/FlatColorButton.java create mode 100644 src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/widget/button/SoundElementButton.java create mode 100644 src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/widget/button/SoundPackButton.java create mode 100644 src/main/resources/assets/touhou_little_maid/textures/gui/maid_custom_sound.png diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/entity/maid/AbstractMaidContainerGui.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/entity/maid/AbstractMaidContainerGui.java index 92a841fbf..03676e6c8 100644 --- a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/entity/maid/AbstractMaidContainerGui.java +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/entity/maid/AbstractMaidContainerGui.java @@ -6,6 +6,7 @@ import com.github.tartaricacid.touhoulittlemaid.client.download.pojo.DownloadInfo; import com.github.tartaricacid.touhoulittlemaid.client.gui.entity.ModelDownloadGui; import com.github.tartaricacid.touhoulittlemaid.client.gui.entity.model.MaidModelGui; +import com.github.tartaricacid.touhoulittlemaid.client.gui.sound.MaidSoundPackGui; import com.github.tartaricacid.touhoulittlemaid.client.gui.widget.button.MaidTabButton; import com.github.tartaricacid.touhoulittlemaid.client.gui.widget.button.ScheduleButton; import com.github.tartaricacid.touhoulittlemaid.client.gui.widget.button.TaskButton; @@ -335,6 +336,7 @@ private void addDownloadButton() { }); soundDownload = new ImageButton(leftPos + 41, topPos + 217, 20, 20, 21, 86, 20, BUTTON, (b) -> { + Minecraft.getInstance().setScreen(new MaidSoundPackGui(maid)); }); this.addRenderableWidget(modelDownload); this.addRenderableWidget(soundDownload); diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/sound/MaidSoundPackGui.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/sound/MaidSoundPackGui.java new file mode 100644 index 000000000..83658879b --- /dev/null +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/sound/MaidSoundPackGui.java @@ -0,0 +1,187 @@ +package com.github.tartaricacid.touhoulittlemaid.client.gui.sound; + +import com.github.tartaricacid.touhoulittlemaid.TouhouLittleMaid; +import com.github.tartaricacid.touhoulittlemaid.client.gui.widget.button.FlatColorButton; +import com.github.tartaricacid.touhoulittlemaid.client.gui.widget.button.SoundElementButton; +import com.github.tartaricacid.touhoulittlemaid.client.gui.widget.button.SoundPackButton; +import com.github.tartaricacid.touhoulittlemaid.client.sound.CustomSoundLoader; +import com.github.tartaricacid.touhoulittlemaid.client.sound.data.MaidSoundInstance; +import com.github.tartaricacid.touhoulittlemaid.client.sound.pojo.SoundPackInfo; +import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid; +import com.github.tartaricacid.touhoulittlemaid.init.InitSounds; +import com.github.tartaricacid.touhoulittlemaid.network.NetworkHandler; +import com.github.tartaricacid.touhoulittlemaid.network.message.SetMaidSoundIdMessage; +import com.github.tartaricacid.touhoulittlemaid.util.ParseI18n; +import com.mojang.blaze3d.audio.SoundBuffer; +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.Util; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.ConfirmLinkScreen; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvent; +import net.minecraftforge.registries.ForgeRegistries; +import org.apache.commons.lang3.StringUtils; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public class MaidSoundPackGui extends Screen { + private static final ResourceLocation ICON = new ResourceLocation(TouhouLittleMaid.MOD_ID, "textures/gui/maid_custom_sound.png"); + private final int packPerSize = 4; + private final int soundPerSize = 13; + private final EntityMaid maid; + private String selectSoundId = null; + private int startX; + private int startY; + private int packPage = 0; + private int soundPage = 0; + private int packMaxPage = 0; + private int soundMaxPage = 0; + + public MaidSoundPackGui(EntityMaid maid) { + super(Component.literal("Maid Custom Sound Pack GUI")); + this.maid = maid; + } + + @Override + protected void init() { + this.clearWidgets(); + + this.startX = (width - 400) / 2; + this.startY = (height - 220) / 2; + this.packMaxPage = (CustomSoundLoader.CACHE.size() - 1) / packPerSize; + this.soundMaxPage = 0; + + int yOffset = 19; + List soundPackIds = List.copyOf(CustomSoundLoader.CACHE.keySet()); + int startPackIndex = packPage * packPerSize; + if (startPackIndex >= soundPackIds.size()) { + this.packPage = 0; + startPackIndex = 0; + } + int endPackIndex = Math.min(soundPackIds.size(), startPackIndex + packPerSize); + for (int i = startPackIndex; i < endPackIndex; i++) { + String soundId = soundPackIds.get(i); + SoundPackInfo info = CustomSoundLoader.getSoundCache(soundId).getInfo(); + SoundPackButton button = new SoundPackButton(startX + 5, startY + yOffset, info, b -> { + this.selectSoundId = soundId; + this.soundPage = 0; + this.init(); + }); + if (StringUtils.isNotBlank(info.getDescription())) { + MutableComponent description = ParseI18n.parse(info.getDescription()); + button.setTooltips(Collections.singletonList(description)); + } + if (soundId.equals(selectSoundId)) { + button.setSelect(true); + } + this.addRenderableWidget(button); + yOffset += 45; + } + + if (StringUtils.isNotBlank(selectSoundId) && CustomSoundLoader.CACHE.containsKey(selectSoundId)) { + yOffset = 41; + boolean otherColor = false; + Map> buffers = CustomSoundLoader.getSoundCache(selectSoundId).getBuffers(); + List soundIds = List.copyOf(buffers.keySet()); + this.soundMaxPage = (buffers.size() - 1) / soundPerSize; + int startSoundIndex = soundPage * soundPerSize; + if (startSoundIndex >= soundIds.size()) { + this.soundPage = 0; + startSoundIndex = 0; + } + int endSoundIndex = Math.min(soundIds.size(), startSoundIndex + soundPerSize); + for (int i = startSoundIndex; i < endSoundIndex; i++) { + ResourceLocation soundEvent = soundIds.get(i); + this.addRenderableWidget(new SoundElementButton(startX + 245, startY + yOffset, 152, 12, soundEvent, buffers.get(soundEvent), otherColor, (b) -> { + SoundElementButton soundButton = (SoundElementButton) b; + SoundEvent event = ForgeRegistries.SOUND_EVENTS.getValue(soundButton.getSoundEvent()); + if (minecraft != null && event != null) { + minecraft.getSoundManager().play(new MaidSoundInstance(event, this.selectSoundId, this.maid)); + } + }).setTooltips("tooltips.touhou_little_maid.custom_sound.play_sound")); + otherColor = !otherColor; + yOffset += 12; + } + } + + this.addRenderableWidget(new FlatColorButton(startX + 245, startY + 19, 110, 18, Component.translatable("gui.touhou_little_maid.custom_sound.pack.apply"), (b) -> { + if (StringUtils.isNotBlank(selectSoundId) && CustomSoundLoader.CACHE.containsKey(selectSoundId)) { + NetworkHandler.CHANNEL.sendToServer(new SetMaidSoundIdMessage(this.maid.getId(), this.selectSoundId)); + } + })); + this.addRenderableWidget(new FlatColorButton(startX + 358, startY + 19, 18, 18, Component.empty(), (b) -> { + if (StringUtils.isNotBlank(selectSoundId) && CustomSoundLoader.CACHE.containsKey(selectSoundId)) { + String url = CustomSoundLoader.getSoundCache(selectSoundId).getInfo().getUrl(); + if (StringUtils.isNotBlank(url) && minecraft != null) { + minecraft.setScreen(new ConfirmLinkScreen(yes -> { + if (yes) { + Util.getPlatform().openUri(url); + } + minecraft.setScreen(this); + }, url, false)); + } + } + }).setTooltips("tooltips.touhou_little_maid.custom_sound.open_url")); + this.addRenderableWidget(new FlatColorButton(startX + 379, startY + 19, 18, 18, Component.empty(), (b) -> { + if (minecraft != null) { + minecraft.getSoundManager().play(new MaidSoundInstance(InitSounds.MAID_CREDIT.get(), this.selectSoundId, this.maid)); + } + }).setTooltips("tooltips.touhou_little_maid.custom_sound.credit")); + + this.addRenderableWidget(new FlatColorButton(startX + 5, startY + 201, 32, 16, Component.literal("<"), (b) -> { + if (this.packPage > 0) { + packPage--; + this.init(); + } + })); + this.addRenderableWidget(new FlatColorButton(startX + 203, startY + 201, 32, 16, Component.literal(">"), (b) -> { + if ((packPage + 1) * packPerSize < CustomSoundLoader.CACHE.size()) { + packPage++; + this.init(); + } + })); + + this.addRenderableWidget(new FlatColorButton(startX + 245, startY + 201, 16, 16, Component.literal("<"), (b) -> { + if (this.soundPage > 0) { + soundPage--; + this.init(); + } + })); + this.addRenderableWidget(new FlatColorButton(startX + 381, startY + 201, 16, 16, Component.literal(">"), (b) -> { + if (StringUtils.isNotBlank(selectSoundId) && CustomSoundLoader.CACHE.containsKey(selectSoundId)) { + Map> buffers = CustomSoundLoader.getSoundCache(selectSoundId).getBuffers(); + if ((soundPage + 1) * soundPerSize < buffers.size()) { + soundPage++; + this.init(); + } + } + })); + } + + @Override + public void render(GuiGraphics graphics, int pMouseX, int pMouseY, float pPartialTick) { + this.renderBackground(graphics); + graphics.fill(startX, startY, startX + 240, startY + 220, 0xFF2A2A2A); + graphics.drawCenteredString(font, Component.translatable("gui.touhou_little_maid.custom_sound.pack.title"), startX + 120, startY + 6, 0xFFFFFF); + graphics.drawCenteredString(font, String.format("%d/%d", packPage + 1, packMaxPage + 1), startX + 120, startY + 206, 0xBBBBBB); + + graphics.fill(startX + 242, startY, startX + 400, startY + 220, 0xFF2A2A2A); + graphics.drawCenteredString(font, Component.translatable("gui.touhou_little_maid.custom_sound.sounds.preview"), startX + 321, startY + 6, 0xFFFFFF); + graphics.drawCenteredString(font, String.format("%d/%d", soundPage + 1, soundMaxPage + 1), startX + 321, startY + 206, 0xBBBBBB); + + super.render(graphics, pMouseX, pMouseY, pPartialTick); + + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderTexture(0, ICON); + graphics.blit(ICON, startX + 359, startY + 20, 0, 0, 16, 16, 256, 256); + graphics.blit(ICON, startX + 380, startY + 20, 16, 0, 16, 16, 256, 256); + + this.renderables.stream().filter(b -> b instanceof FlatColorButton).forEach(b -> ((FlatColorButton) b).renderToolTip(graphics, this, pMouseX, pMouseY)); + } +} diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/widget/button/FlatColorButton.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/widget/button/FlatColorButton.java new file mode 100644 index 000000000..6c86348df --- /dev/null +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/widget/button/FlatColorButton.java @@ -0,0 +1,66 @@ +package com.github.tartaricacid.touhoulittlemaid.client.gui.widget.button; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.Component; +import net.minecraft.util.Mth; + +import java.util.Collections; +import java.util.List; + + +public class FlatColorButton extends Button { + private boolean isSelect = false; + private List tooltips; + + public FlatColorButton(int pX, int pY, int pWidth, int pHeight, Component pMessage, OnPress pOnPress) { + super(pX, pY, pWidth, pHeight, pMessage, pOnPress, DEFAULT_NARRATION); + } + + public FlatColorButton setTooltips(String key) { + tooltips = Collections.singletonList(Component.translatable(key)); + return this; + } + + public FlatColorButton setTooltips(List tooltips) { + this.tooltips = tooltips; + return this; + } + + public void renderToolTip(GuiGraphics graphics, Screen screen, int pMouseX, int pMouseY) { + if (this.isHovered && tooltips != null) { + graphics.renderComponentTooltip(screen.getMinecraft().font, tooltips, pMouseX, pMouseY); + } + } + + @Override + public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float pPartialTick) { + Minecraft minecraft = Minecraft.getInstance(); + Font font = minecraft.font; + if (isSelect) { + graphics.fillGradient(this.getX(), this.getY(), this.getX() + this.width, this.getY() + this.height, 0xff_1E90FF, 0xff_1E90FF); + } else { + graphics.fillGradient(this.getX(), this.getY(), this.getX() + this.width, this.getY() + this.height, 0xff_434242, 0xff_434242); + } + if (this.isHoveredOrFocused()) { + graphics.fillGradient(this.getX(), this.getY() + 1, this.getX() + 1, this.getY() + this.height - 1, 0xff_F3EFE0, 0xff_F3EFE0); + graphics.fillGradient(this.getX(), this.getY(), this.getX() + this.width, this.getY() + 1, 0xff_F3EFE0, 0xff_F3EFE0); + graphics.fillGradient(this.getX() + this.width - 1, this.getY() + 1, this.getX() + this.width, this.getY() + this.height - 1, 0xff_F3EFE0, 0xff_F3EFE0); + graphics.fillGradient(this.getX(), this.getY() + this.height - 1, this.getX() + this.width, this.getY() + this.height, 0xff_F3EFE0, 0xff_F3EFE0); + } + int i = getFGColor(); + this.renderString(graphics, minecraft.font, i | Mth.ceil(this.alpha * 255.0F) << 24); + } + + @Override + public void renderString(GuiGraphics graphics, Font font, int pColor) { + graphics.drawCenteredString(font, this.getMessage(), this.getX() + this.width / 2, this.getY() + (this.height - 8) / 2, 0xF3EFE0); + } + + public void setSelect(boolean select) { + isSelect = select; + } +} diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/widget/button/SoundElementButton.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/widget/button/SoundElementButton.java new file mode 100644 index 000000000..adacddcca --- /dev/null +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/widget/button/SoundElementButton.java @@ -0,0 +1,55 @@ +package com.github.tartaricacid.touhoulittlemaid.client.gui.widget.button; + +import com.mojang.blaze3d.audio.SoundBuffer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; + +import java.util.List; + +public class SoundElementButton extends FlatColorButton { + private final ResourceLocation soundEvent; + private final int soundCount; + private final boolean otherColor; + + public SoundElementButton(int pX, int pY, int pWidth, int pHeight, ResourceLocation soundEvent, List sounds, boolean otherColor, OnPress pOnPress) { + super(pX, pY, pWidth, pHeight, Component.translatable(soundEvent.toLanguageKey("button")), pOnPress); + this.soundEvent = soundEvent; + this.soundCount = sounds.size(); + this.otherColor = otherColor; + } + + @Override + public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float pPartialTick) { + Minecraft minecraft = Minecraft.getInstance(); + if (otherColor) { + graphics.fillGradient(this.getX(), this.getY(), this.getX() + this.width, this.getY() + this.height, 0x5f_9e9e9e, 0x5f_9e9e9e); + } else { + graphics.fillGradient(this.getX(), this.getY(), this.getX() + this.width, this.getY() + this.height, 0xff_434242, 0xff_434242); + } + if (this.isHoveredOrFocused()) { + graphics.fillGradient(this.getX(), this.getY() + 1, this.getX() + 1, this.getY() + this.height - 1, 0xff_F3EFE0, 0xff_F3EFE0); + graphics.fillGradient(this.getX(), this.getY(), this.getX() + this.width, this.getY() + 1, 0xff_F3EFE0, 0xff_F3EFE0); + graphics.fillGradient(this.getX() + this.width - 1, this.getY() + 1, this.getX() + this.width, this.getY() + this.height - 1, 0xff_F3EFE0, 0xff_F3EFE0); + graphics.fillGradient(this.getX(), this.getY() + this.height - 1, this.getX() + this.width, this.getY() + this.height, 0xff_F3EFE0, 0xff_F3EFE0); + } + int i = getFGColor(); + this.renderString(graphics, minecraft.font, i | Mth.ceil(this.alpha * 255.0F) << 24); + } + + @Override + public void renderString(GuiGraphics graphics, Font font, int pColor) { + graphics.drawString(font, "▷", this.getX() + 5, this.getY() + (this.height - 8) / 2, 0xe0e0e0); + graphics.drawString(font, this.getMessage(), this.getX() + 15, this.getY() + (this.height - 8) / 2, 0xfafafa); + String countText = soundCount + "♫"; + int countTextWidth = font.width(countText); + graphics.drawString(font, countText, this.getX() + this.getWidth() - countTextWidth - 5, this.getY() + (this.height - 8) / 2, 0xCCCCCC); + } + + public ResourceLocation getSoundEvent() { + return soundEvent; + } +} diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/widget/button/SoundPackButton.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/widget/button/SoundPackButton.java new file mode 100644 index 000000000..09b55fdd2 --- /dev/null +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/gui/widget/button/SoundPackButton.java @@ -0,0 +1,70 @@ +package com.github.tartaricacid.touhoulittlemaid.client.gui.widget.button; + +import com.github.tartaricacid.touhoulittlemaid.TouhouLittleMaid; +import com.github.tartaricacid.touhoulittlemaid.client.sound.pojo.SoundPackInfo; +import com.github.tartaricacid.touhoulittlemaid.util.ParseI18n; +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.resources.ResourceLocation; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; + +public class SoundPackButton extends FlatColorButton { + private static final ResourceLocation ICON = new ResourceLocation(TouhouLittleMaid.MOD_ID, "textures/gui/maid_custom_sound.png"); + private final SoundPackInfo info; + + public SoundPackButton(int pX, int pY, SoundPackInfo info, OnPress onPress) { + super(pX, pY, 230, 43, Component.empty(), onPress); + this.info = info; + } + + @Override + public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float pPartialTick) { + super.renderWidget(graphics, mouseX, mouseY, pPartialTick); + ResourceLocation icon = info.getIcon(); + if (icon == null) { + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderTexture(0, ICON); + graphics.blit(ICON, this.getX() + 4, this.getY() + 4, 0, 16, 32, 32, 256, 256); + } + } + + @Override + @SuppressWarnings("all") + public void renderString(GuiGraphics graphics, Font font, int pColor) { + int startX = this.getX() + 42; + int startY = this.getY() + 7; + + MutableComponent packName = ParseI18n.parse(info.getPackName()); + String version = info.getVersion(); + List author = info.getAuthor(); + String date = info.getDate(); + + graphics.drawString(font, packName, startX, startY, ChatFormatting.WHITE.getColor()); + + if (StringUtils.isNotBlank(version)) { + int titleWidth = font.width(packName); + graphics.drawString(font, "§nv" + version, startX + titleWidth + 5, startY, ChatFormatting.AQUA.getColor()); + } + + if (!author.isEmpty()) { + startY += 10; + String authorListText = StringUtils.joinWith(I18n.get("gui.touhou_little_maid.resources_download.author.delimiter"), author); + String authorText = I18n.get("gui.touhou_little_maid.resources_download.author", authorListText); + graphics.drawString(font, authorText, startX, startY, ChatFormatting.GOLD.getColor()); + } + + if (StringUtils.isNotBlank(date)) { + startY += 10; + MutableComponent dateText = Component.translatable("gui.touhou_little_maid.skin.text.date", date); + graphics.drawString(font, dateText, startX, startY, ChatFormatting.GREEN.getColor()); + } + } +} diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/sound/CustomSoundLoader.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/sound/CustomSoundLoader.java index 9d2b48fe6..459438add 100644 --- a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/sound/CustomSoundLoader.java +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/sound/CustomSoundLoader.java @@ -35,7 +35,7 @@ public class CustomSoundLoader { public static final Map CACHE = Maps.newHashMap(); - private static final Pattern FILENAME_REG = Pattern.compile("^\\d+\\.ogg$"); + private static final Pattern FILENAME_REG = Pattern.compile("^\\d*\\.ogg$"); private static final Marker MARKER = MarkerManager.getMarker("CustomSoundLoader"); private static final String JSON_FILE_NAME = "maid_sound.json"; @@ -152,9 +152,9 @@ private static void reuseSounds(Map> buffers buffers.get(to.getLocation()).addAll(fromBuffers); } - private static boolean checkFileName(String fileName, String name) { - if (name.startsWith(fileName)) { - String substring = name.substring(fileName.length()); + private static boolean checkFileName(String patterString, String rawString) { + if (rawString.startsWith(patterString)) { + String substring = rawString.substring(patterString.length()); Matcher matcher = FILENAME_REG.matcher(substring); return matcher.matches(); } diff --git a/src/main/resources/assets/touhou_little_maid/lang/en_us.json b/src/main/resources/assets/touhou_little_maid/lang/en_us.json index 13d1fe233..b9b1e299c 100644 --- a/src/main/resources/assets/touhou_little_maid/lang/en_us.json +++ b/src/main/resources/assets/touhou_little_maid/lang/en_us.json @@ -73,6 +73,9 @@ "tooltips.touhou_little_maid.maid_beacon.desc": "Storage Power: %s", "tooltips.touhou_little_maid.chair_show.desc": "Hold this item and sneak to see the hit box of chair", "tooltips.touhou_little_maid.model_switcher.bounded": "Already bound to the maid", + "tooltips.touhou_little_maid.custom_sound.credit": "Play a credit sound", + "tooltips.touhou_little_maid.custom_sound.open_url": "Open the sound pack's url", + "tooltips.touhou_little_maid.custom_sound.play_sound": "Click to play the sound", "gui.touhou_little_maid.schedule.day": "Day Shift", "gui.touhou_little_maid.schedule.night": "Night Shift", "gui.touhou_little_maid.schedule.all": "All Day", @@ -156,6 +159,9 @@ "gui.touhou_little_maid.model_switcher.direction.west": "Face: W", "gui.touhou_little_maid.model_switcher.list.add": "Add", "gui.touhou_little_maid.model_switcher.uuid.empty": "Unbound maid, use it right click maid to bind!", + "gui.touhou_little_maid.custom_sound.pack.title": "§l§nMaid Sound Pack", + "gui.touhou_little_maid.custom_sound.pack.apply": "Apply Sound Pack", + "gui.touhou_little_maid.custom_sound.sounds.preview": "§l§nSound Preview", "message.touhou_little_maid.change_model.disabled": "Model switch is disabled.", "message.touhou_little_maid.extinguisher.player_cannot_use": "Your lack of knowledge does not know how to use this item", "message.touhou_little_maid.altar.not_enough_power": "You don't have enough power.", @@ -252,6 +258,35 @@ "task.touhou_little_maid.feed_animal.desc": "Maid will try to breed the surrounding animals", "task.touhou_little_maid.extinguishing.desc": "Maid will try to extinguish the surrounding fire", "task.touhou_little_maid.extinguishing.condition.has_extinguisher": "Mainhand holds a extinguisher", + "button.touhou_little_maid.maid.mode.idle": "Idle", + "button.touhou_little_maid.maid.mode.attack": "Attack", + "button.touhou_little_maid.maid.mode.range_attack": "Range Attack", + "button.touhou_little_maid.maid.mode.danmaku_attack": "Danmaku Sttack", + "button.touhou_little_maid.maid.mode.farm": "Farm", + "button.touhou_little_maid.maid.mode.feed": "Feed", + "button.touhou_little_maid.maid.mode.shears": "Shears", + "button.touhou_little_maid.maid.mode.milk": "Get Milk", + "button.touhou_little_maid.maid.mode.torch": "Torch", + "button.touhou_little_maid.maid.mode.feed_animal": "Feed Animal", + "button.touhou_little_maid.maid.mode.extinguishing": "Extinguishing", + "button.touhou_little_maid.maid.mode.snow": "Remove Snow", + "button.touhou_little_maid.maid.mode.break": "Break", + "button.touhou_little_maid.maid.mode.furnace": "Furnace", + "button.touhou_little_maid.maid.mode.brewing": "Brewing", + "button.touhou_little_maid.maid.ai.find_target": "Find Target", + "button.touhou_little_maid.maid.ai.hurt": "Hurt", + "button.touhou_little_maid.maid.ai.hurt_fire": "Fire Hurt", + "button.touhou_little_maid.maid.ai.hurt_player": "Player Hurt", + "button.touhou_little_maid.maid.ai.tamed": "Tamed", + "button.touhou_little_maid.maid.ai.item_get": "Get Item", + "button.touhou_little_maid.maid.ai.death": "Death", + "button.touhou_little_maid.maid.environment.hot": "Feel Hot", + "button.touhou_little_maid.maid.environment.cold": "Feel Cold", + "button.touhou_little_maid.maid.environment.rain": "Rain", + "button.touhou_little_maid.maid.environment.snow": "Snow", + "button.touhou_little_maid.maid.environment.morning": "Morning", + "button.touhou_little_maid.maid.environment.night": "Night", + "button.touhou_little_maid.maid.credit": "Credit", "subtitle.touhou_little_maid.maid.mode.idle": "Maid Idle Sound", "subtitle.touhou_little_maid.maid.mode.attack": "Maid Attack Sound", "subtitle.touhou_little_maid.maid.mode.range_attack": "Maid Range Attack Sound", diff --git a/src/main/resources/assets/touhou_little_maid/lang/zh_cn.json b/src/main/resources/assets/touhou_little_maid/lang/zh_cn.json index 05feee769..a2037f164 100644 --- a/src/main/resources/assets/touhou_little_maid/lang/zh_cn.json +++ b/src/main/resources/assets/touhou_little_maid/lang/zh_cn.json @@ -73,6 +73,9 @@ "tooltips.touhou_little_maid.maid_beacon.desc": "存储 P 点:%s", "tooltips.touhou_little_maid.chair_show.desc": "潜行时手持此物品可以查看坐垫的碰撞箱", "tooltips.touhou_little_maid.model_switcher.bounded": "已经绑定女仆", + "tooltips.touhou_little_maid.custom_sound.credit": "播放一个声音包的备注说明", + "tooltips.touhou_little_maid.custom_sound.open_url": "打开声音包的网络链接", + "tooltips.touhou_little_maid.custom_sound.play_sound": "点击播放声音", "gui.touhou_little_maid.schedule.day": "白班", "gui.touhou_little_maid.schedule.night": "夜班", "gui.touhou_little_maid.schedule.all": "全天", @@ -156,6 +159,9 @@ "gui.touhou_little_maid.model_switcher.direction.west": "朝向:西", "gui.touhou_little_maid.model_switcher.list.add": "添加", "gui.touhou_little_maid.model_switcher.uuid.empty": "未绑定女仆,请用它右击女仆进行绑定!", + "gui.touhou_little_maid.custom_sound.pack.title": "§l§n女仆声音包", + "gui.touhou_little_maid.custom_sound.pack.apply": "应用此声音包", + "gui.touhou_little_maid.custom_sound.sounds.preview": "§l§n声音预览", "message.touhou_little_maid.change_model.disabled": "模型切换功能已被禁止", "message.touhou_little_maid.extinguisher.player_cannot_use": "你匮乏的知识并不了解这物品该如何使用", "message.touhou_little_maid.altar.not_enough_power": "你没有足够多的 P 点", @@ -252,6 +258,35 @@ "task.touhou_little_maid.feed_animal.desc": "女仆会主动繁殖周围的动物", "task.touhou_little_maid.extinguishing.desc": "女仆会主动扑灭周围的火", "task.touhou_little_maid.extinguishing.condition.has_extinguisher": "主手持有灭火器", + "button.touhou_little_maid.maid.mode.idle": "空闲", + "button.touhou_little_maid.maid.mode.attack": "攻击", + "button.touhou_little_maid.maid.mode.range_attack": "范围攻击", + "button.touhou_little_maid.maid.mode.danmaku_attack": "弹幕攻击", + "button.touhou_little_maid.maid.mode.farm": "农场", + "button.touhou_little_maid.maid.mode.feed": "喂养", + "button.touhou_little_maid.maid.mode.shears": "剪刀", + "button.touhou_little_maid.maid.mode.milk": "获取牛奶", + "button.touhou_little_maid.maid.mode.torch": "火把", + "button.touhou_little_maid.maid.mode.feed_animal": "繁殖动物", + "button.touhou_little_maid.maid.mode.extinguishing": "灭火", + "button.touhou_little_maid.maid.mode.snow": "扫雪", + "button.touhou_little_maid.maid.mode.break": "破坏", + "button.touhou_little_maid.maid.mode.furnace": "熔炉", + "button.touhou_little_maid.maid.mode.brewing": "酿造", + "button.touhou_little_maid.maid.ai.find_target": "发现目标", + "button.touhou_little_maid.maid.ai.hurt": "受伤", + "button.touhou_little_maid.maid.ai.hurt_fire": "火焰伤害", + "button.touhou_little_maid.maid.ai.hurt_player": "玩家伤害", + "button.touhou_little_maid.maid.ai.tamed": "被驯服", + "button.touhou_little_maid.maid.ai.item_get": "拾起物件", + "button.touhou_little_maid.maid.ai.death": "死亡", + "button.touhou_little_maid.maid.environment.hot": "热", + "button.touhou_little_maid.maid.environment.cold": "冷", + "button.touhou_little_maid.maid.environment.rain": "下雨", + "button.touhou_little_maid.maid.environment.snow": "下雪", + "button.touhou_little_maid.maid.environment.morning": "早上", + "button.touhou_little_maid.maid.environment.night": "傍晚", + "button.touhou_little_maid.maid.credit": "备注说明", "subtitle.touhou_little_maid.maid.mode.idle": "女仆:空闲", "subtitle.touhou_little_maid.maid.mode.attack": "女仆:攻击", "subtitle.touhou_little_maid.maid.mode.range_attack": "女仆:范围攻击", @@ -280,7 +315,7 @@ "subtitle.touhou_little_maid.maid.environment.snow": "女仆:下雪", "subtitle.touhou_little_maid.maid.environment.morning": "女仆:早上", "subtitle.touhou_little_maid.maid.environment.night": "女仆:傍晚", - "subtitle.touhou_little_maid.other.credit": "致谢:あみたろの声素材工房", + "subtitle.touhou_little_maid.other.credit": "备注说明", "subtitle.touhou_little_maid.item.camera_use": "相机咔哒声", "subtitle.touhou_little_maid.item.album_open": "相册:打开", "subtitle.touhou_little_maid.block.altar_craft": "祭坛:合成", diff --git a/src/main/resources/assets/touhou_little_maid/textures/gui/maid_custom_sound.png b/src/main/resources/assets/touhou_little_maid/textures/gui/maid_custom_sound.png new file mode 100644 index 0000000000000000000000000000000000000000..5dff4ce69517f27ce81b4041b2475108ae67474b GIT binary patch literal 1427 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|GzJFNC{Gv1kczmscm2C$Qe}=m z+!-L2$GndDp3(zdrh6*IY_<+9XBh9Oc^|abi0pXaB&fM|Udi%jf6L0XCi_hPP+RvQ z;p_5M%hNyqv)VCpb>^&f4Ss@R$0Xm+|9ZLK-pBiKZ9=u+vhU}A{E>ZpP`>v(^KHq) zHoyPNJ$rjF_S}zsb3bmFZ?up9#<5RFZBD;Fti$)V=-r)xt+wA#!)TXf5OzxVgcVf-?8^@kE=DyK?78$1>zyEs0f_~X|AOCGkZ#aD` z{>DP_Uwd;CickFrET{-Rg>Fd^~ zo2}&@n6g*HEPeCq+(FyYhU32<7caNkFxT)*@$$F)uV(>OeR^7b?D~OkNk80_-{B3c46}FLs+a!%^Sk}!rD^}x{C)1{UZ?rMh>!ch zrDVnf-*gx>wpB6Ke0_8C%gx2^@+o!aS8ilTs9r68pkl{$D^oFsobyZ#Nn#8ln;90& zU}ZS^ZZCu1*;~(b7;el1@_@S27#%kHZ(`V2`!VU)r_6t+R-&a?^ z{Cs@8u)ZcwhMQqqc^TuHpK1Reot(U*{LRinpb_^@vTpb`yY|iEV31S%^cuF_fAf6a z?Dun}K+204d)h0v%+KHV&+6UVv)}!CSs89y?_{uhGQ0L)J?rV`&tLDHD-BV2=lks1 zw-F2*_D<$bnD@J8^Lkl`eKt>kg0|cYU9w^g`?(ov|D-BtJj-WxGOU-C=#qW*>)F|N z0e1D3*)|*Gv;P<8Pd_{RuzLS~fdWgx2Dwo*8UpkQf&WYo?%tdEBzgKNU}4MP>FVdQ I&MBb@0BzJQ82|tP literal 0 HcmV?d00001