Skip to content

Commit

Permalink
Improve Instrument and MusicVenueTool overlays.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeronica committed Mar 25, 2024
1 parent 7eab7ba commit 70972ed
Show file tree
Hide file tree
Showing 43 changed files with 1,464 additions and 412 deletions.
23 changes: 22 additions & 1 deletion src/generated/resources/assets/mxtune/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
"commands.mxtune.music.dump": "Wrote %s records",
"commands.mxtune.music.load": "Read %s records",
"config.mxtune.client.double_click_time_ms": "Double-click time in milliseconds for GUI widgets",
"config.mxtune.client.instrument_overlay_x_pos": "Instrument Overlay X-Pos",
"config.mxtune.client.instrument_overlay_y_pct": "Instrument Overlay Y-Pos %",
"config.mxtune.client.mml_Link": "MML Site Link",
"config.mxtune.client.venue_tool_overlay_x_pos": "Venue Tool Overlay X-Pos",
"config.mxtune.client.venue_tool_overlay_y_pct": "Venue Tool Overlay Y-Pos %",
"config.mxtune.server.listener_range": "Listener Range",
"config.mxtune.server.sheet_music_expires": "Sheet Music Expires",
"config.mxtune.server.sheet_music_life_in_days": "Sheet Music Life in Days.",
"config.mxtune.server.sheet_music_life_in_days": "Sheet Music Life in Days",
"container.mxtune.block_music.more": "%s More",
"entity.mxtune.music_source": "[MusicSource]",
"entity.mxtune.music_venue_info": "Music Venue Info Panel",
Expand All @@ -23,6 +27,9 @@
"enum.mxtune.group.mode.pin": "Pin",
"enum.mxtune.group.mode.pin.help01": "Players must know the pin to join your group.",
"enum.mxtune.group.mode.pin.help02": "Click to toggle access mode.",
"enum.mxtune.item.overlay.position.center": "Center",
"enum.mxtune.item.overlay.position.left": "Left",
"enum.mxtune.item.overlay.position.right": "Right",
"enum.mxtune.tool_state.type.done": "Done",
"enum.mxtune.tool_state.type.end": "End",
"enum.mxtune.tool_state.type.remove": "Remove",
Expand Down Expand Up @@ -52,6 +59,10 @@
"gui.mxtune.button.help.help03": "SHIFT-Hoover over buttons for tips.",
"gui.mxtune.button.import": "Import",
"gui.mxtune.button.import.help01": "Supports 3MLE .mml, Maple Story 2 .ms2mml, and zipped .ms2mml multipart files.",
"gui.mxtune.button.inst_x_pos_enum.help01": "Instrument overlay X Position cycles: [Left, Center, Right]",
"gui.mxtune.button.inst_y_pos_slider": "Instrument YPos",
"gui.mxtune.button.inst_y_pos_slider.help01": "Instrument overlay Y position down screen percentage.",
"gui.mxtune.button.inst_y_pos_slider.help02": "0% top, 100% bottom",
"gui.mxtune.button.left_rs_out.disabled": "Output Disabled",
"gui.mxtune.button.left_rs_out.enabled": "Output Enabled",
"gui.mxtune.button.left_rs_out.help01": "Left Side Redstone Output Toggle",
Expand Down Expand Up @@ -91,9 +102,13 @@
"gui.mxtune.button.new.help01": "Clears all text and MML. Will ask to save.",
"gui.mxtune.button.new_pin.help01": "Enabled: Click to generate a new pin. The server ensures no active groups will have the same pin.",
"gui.mxtune.button.new_pin.help02": "Disabled: When the Access mode is Open.",
"gui.mxtune.button.oms_cancel.help01": "Cancel/Esc discard changes.",
"gui.mxtune.button.oms_done.help01": "Close and save changes.",
"gui.mxtune.button.open_folder": "Open Folder",
"gui.mxtune.button.open_folder.help01": "Place MML files into this folder to be imported. Recognized types are: ",
"gui.mxtune.button.open_folder.help02": " .mml, .ms2mml, .zip (contains multiple .ms2mml files)",
"gui.mxtune.button.overlay_button.help01": "Opens the Overlay Manager screen.",
"gui.mxtune.button.overlay_button.help02": "The Instrument and Music Venue Tool overlay positions can be changed.",
"gui.mxtune.button.play": "Play",
"gui.mxtune.button.play_all": "Play All",
"gui.mxtune.button.play_part": "Play Part",
Expand All @@ -114,6 +129,10 @@
"gui.mxtune.button.save.help03": "A Title and at least one instrument tab must have a melody line. Empty instrument tabs are not allowed.",
"gui.mxtune.button.select": "Select",
"gui.mxtune.button.stop": "Stop",
"gui.mxtune.button.tool_x_pos_enum.help01": "Venue Tool overlay X Position cycles: [Left, Center, Right]",
"gui.mxtune.button.tool_y_pos_slider": "Venue Tool YPos",
"gui.mxtune.button.tool_y_pos_slider.help01": "Venue Tool overlay Y position down screen percentage.",
"gui.mxtune.button.tool_y_pos_slider.help02": "0% top, 100% bottom",
"gui.mxtune.button.upload": "Upload",
"gui.mxtune.button.write_music_score": "Make Music Score",
"gui.mxtune.button.write_sheet_music": "Make Sheet Music",
Expand Down Expand Up @@ -148,6 +167,8 @@
"gui.mxtune.label.source": "Source URL:",
"gui.mxtune.label.status": "Status/Meta",
"gui.mxtune.label.title": "Title:",
"gui.mxtune.overlay.instrument.name": "Instrument Overlay",
"gui.mxtune.overlay.venue_tool.name": "Venue Tool Overlay",
"gui.mxtune.switch.multi_inst_screen.auto_select.help01": "Auto Select Instrument",
"gui.mxtune.switch.multi_inst_screen.auto_select.help02": "On: Changes to the instrument specified by the Sheet Music in the inventory slot.",
"gui.mxtune.switch.multi_inst_screen.auto_select.help03": "Off: Uses the instrument shown on the selector button.",
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/aeronicamc/mods/mxtune/MXTune.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import aeronicamc.mods.mxtune.managers.PlayManager;
import aeronicamc.mods.mxtune.network.MultiPacketStringManager;
import aeronicamc.mods.mxtune.network.PacketDispatcher;
import aeronicamc.mods.mxtune.render.RenderHelper;
import aeronicamc.mods.mxtune.render.blockentity.MusicBlockEntityRenderer;
import aeronicamc.mods.mxtune.render.entity.InfoRenderer;
import aeronicamc.mods.mxtune.render.entity.MusicVenueInfoRenderer;
Expand Down Expand Up @@ -123,6 +124,7 @@ private void clientSetup(final FMLClientSetupEvent event)
RenderTypeLookup.setRenderLayer(ModBlocks.MUSIC_BLOCK.get(), RenderType.cutoutMipped());
ClientRegistry.bindTileEntityRenderer(ModBlockEntities.INV_MUSIC_BLOCK.get(), MusicBlockEntityRenderer::new);
new InfoRenderer(Minecraft.getInstance().getTextureManager());
RenderHelper.init();
}

private void modLoadingComplete(FMLLoadCompleteEvent event)
Expand Down
49 changes: 45 additions & 4 deletions src/main/java/aeronicamc/mods/mxtune/config/MXTuneConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package aeronicamc.mods.mxtune.config;

import aeronicamc.mods.mxtune.render.IOverlayItem;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
import net.minecraftforge.common.ForgeConfigSpec.IntValue;
Expand All @@ -26,6 +27,7 @@

public class MXTuneConfig
{
public static final Object SYNC = new Object();
public static final int SHEET_MUSIC_MAX_DAYS = 999999;
private MXTuneConfig() { /* NOP */ }

Expand All @@ -34,22 +36,53 @@ public static class Client
{
public final ConfigValue<Integer> doubleClickTime;
public final ConfigValue<String> site;
public final ConfigValue<IOverlayItem.Position> instrumentOverlayXPosition;
public final ConfigValue<Integer> instrumentOverlayYPercent;
public final ConfigValue<IOverlayItem.Position> venueToolOverlayXPosition;
public final ConfigValue<Integer> venueToolOverlayYPercent;

public Client(final ForgeConfigSpec.Builder builder)
{
builder.comment("Client Only Settings")
.push("client");

builder.comment("1) GUI widgets Double-click time")
.push("1) GUI widgets Double-click time");
doubleClickTime = builder
.comment("Double-click time in milliseconds for GUI widgets")
.translation("config.mxtune.client.double_click_time_ms")
.defineInRange("doubleClickTime", 500, 10, 5000);
builder.pop();

builder.comment("2) MML Site Link")
.push("2) MML Site Link");
site = builder
.comment("Site Link")
.comment("MML Site Link")
.translation("config.mxtune.client.mml_Link")
.define("site", "https://mabibeats.com/");
builder.pop();

builder.comment("3) Instrument Overlay Positions")
.push("3) Instrument Overlay Positions");
instrumentOverlayXPosition = builder
.comment("Instrument Overlay X Position")
.translation("config.mxtune.client.instrument_overlay_x_pos")
.defineEnum("instrumentOverlayXPosition", IOverlayItem.Position.LEFT);

instrumentOverlayYPercent = builder
.comment("Instrument Overlay Y Percent down screen")
.translation("config.mxtune.client.instrument_overlay_y_pct")
.defineInRange("instrumentOverlayYPercent", 0, 0, 100);
builder.pop();

builder.comment("4) Venue Tool Overlay Positions")
.push("4) Venue Tool Overlay Positions");
venueToolOverlayXPosition = builder
.comment("Venue Tool Overlay X Position")
.translation("config.mxtune.client.venue_tool_overlay_x_pos")
.defineEnum("venueToolOverlayXPosition", IOverlayItem.Position.CENTER);

venueToolOverlayYPercent = builder
.comment("Venue Tool Overlay Y Percent down screen")
.translation("config.mxtune.client.venue_tool_overlay_y_pct")
.defineInRange("venueToolOverlayYPercent", 70, 0, 100);
builder.pop();
}
}
Expand Down Expand Up @@ -95,6 +128,14 @@ public Server(final ForgeConfigSpec.Builder builder)

public static String getMmlLink() { return CLIENT.site.get(); }

public static IOverlayItem.Position getInstrumentOverlayPosition() { return CLIENT.instrumentOverlayXPosition.get(); }

public static int getInstrumentOverlayPercent() { return CLIENT.instrumentOverlayYPercent.get(); }

public static IOverlayItem.Position getVenueToolOverlayPosition() { return CLIENT.venueToolOverlayXPosition.get(); }

public static int getVenueToolOverlayPercent() { return CLIENT.venueToolOverlayYPercent.get(); }

private static final ForgeConfigSpec serverSpec;
public static final Server SERVER;
static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ private void addGuiTexts()
addGuiText("label.metadata", "Chars: %s, Duration: %s, Meta: %s");
addGuiText("label.duration_value_total", "Duration All: ");

// ModGuiHelper, GuiHelpButton, generic texts
// ModGuiHelper, GuiHelpButton, GuiOverlayButton, generic texts
addGuiText("button.help.help01", "Help");
addGuiText("button.help.help02", "Hoover over buttons for tips.");
addGuiText("button.help.help03", "SHIFT-Hoover over buttons for tips.");
addGuiText("button.enabled", "Enabled");
addGuiText("button.disabled", "Disabled");
addGuiText("button.overlay_button.help01", "Opens the Overlay Manager screen.");
addGuiText("button.overlay_button.help02", "The Instrument and Music Venue Tool overlay positions can be changed.");

// GuiMXT, GuiMXTPartTab, GuiFileImporter, GuiMusicLibrary
addGuiText("button.import", "Import");
Expand Down Expand Up @@ -240,6 +242,24 @@ private void addGuiTexts()
addGuiText("button.member_remove.help01", "Remove: ");
addGuiText("button.member_remove.help02", "Remove the member from the group.");
addGuiText("button.member_remove.help03", "Only the member themselves or the leader may remove. If the leader is the only member, then if the leader removes themself the group is removed too.");

// OverlayManagerScreen
addGuiText("button.inst_y_pos_slider", "Instrument YPos");
addGuiText("button.inst_y_pos_slider.help01", "Instrument overlay Y position down screen percentage.");
addGuiText("button.inst_y_pos_slider.help02", "0% top, 100% bottom");
addGuiText("button.tool_y_pos_slider", "Venue Tool YPos");
addGuiText("button.tool_y_pos_slider.help01", "Venue Tool overlay Y position down screen percentage.");
addGuiText("button.tool_y_pos_slider.help02", "0% top, 100% bottom");

addGuiText("button.inst_x_pos_enum.help01","Instrument overlay X Position cycles: [Left, Center, Right]");
addGuiText("button.tool_x_pos_enum.help01","Venue Tool overlay X Position cycles: [Left, Center, Right]");

addGuiText("button.oms_done.help01","Close and save changes.");
addGuiText("button.oms_cancel.help01","Cancel/Esc discard changes.");

// Instrument Overlay, Music Venue Tool Overlay
addGuiText("overlay.instrument.name", "Instrument Overlay");
addGuiText("overlay.venue_tool.name", "Venue Tool Overlay");
}

private void addChats()
Expand All @@ -263,9 +283,13 @@ private void addConfigs()
{
addConfig("client.double_click_time_ms", "Double-click time in milliseconds for GUI widgets");
addConfig("client.mml_Link", "MML Site Link");
addConfig("client.instrument_overlay_x_pos", "Instrument Overlay X-Pos");
addConfig("client.instrument_overlay_y_pct", "Instrument Overlay Y-Pos %");
addConfig("client.venue_tool_overlay_x_pos", "Venue Tool Overlay X-Pos");
addConfig("client.venue_tool_overlay_y_pct", "Venue Tool Overlay Y-Pos %");
addConfig("server.listener_range", "Listener Range");
addConfig("server.sheet_music_expires", "Sheet Music Expires");
addConfig("server.sheet_music_life_in_days", "Sheet Music Life in Days.");
addConfig("server.sheet_music_life_in_days", "Sheet Music Life in Days");
}

private void addEntities()
Expand All @@ -286,6 +310,10 @@ private void addEnums()
addEnum("group.mode.open", "Open");
addEnum("group.mode.open.help01", "Anyone can join your group.");
addEnum("group.mode.open.help02", "Click to toggle access mode.");

addEnum("item.overlay.position.left", "Left");
addEnum("item.overlay.position.center", "Center");
addEnum("item.overlay.position.right", "Right");
}

private void addErrors()
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/aeronicamc/mods/mxtune/events/ClientEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import aeronicamc.mods.mxtune.managers.GroupClient;
import aeronicamc.mods.mxtune.network.PacketDispatcher;
import aeronicamc.mods.mxtune.network.messages.SyncRequestMessage;
import aeronicamc.mods.mxtune.render.RenderHelper;
import aeronicamc.mods.mxtune.render.entity.InfoRenderer;
import aeronicamc.mods.mxtune.sound.ClientAudio;
import net.minecraftforge.api.distmarker.Dist;
Expand All @@ -20,12 +21,14 @@ private ClientEvents() { /* NOOP */ }
public static void event(ClientPlayerNetworkEvent.LoggedInEvent event)
{
GroupClient.clear();
RenderHelper.getOverlayItemGui().clear();
PacketDispatcher.sendToServer(new SyncRequestMessage());
}

@SubscribeEvent
public static void event(ClientPlayerNetworkEvent.LoggedOutEvent event)
{
RenderHelper.getOverlayItemGui().clear();
InfoRenderer.getInstance().clearInfoRendererInstances();
}

Expand All @@ -34,6 +37,7 @@ public static void event(ClientPlayerNetworkEvent.RespawnEvent event)
{
GroupClient.clear();
ClientAudio.stopAll();
RenderHelper.getOverlayItemGui().clear();
PacketDispatcher.sendToServer(new SyncRequestMessage());
}
}
5 changes: 5 additions & 0 deletions src/main/java/aeronicamc/mods/mxtune/gui/Handler.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import aeronicamc.mods.mxtune.gui.mml.GuiMXT;
import aeronicamc.mods.mxtune.util.Misc;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen;

import javax.annotation.Nullable;

public class Handler
{
Expand All @@ -31,4 +34,6 @@ public static void openTestScreen()
{
mc.tell(() -> mc.setScreen(new TestScreen()));
}

public static void openOverlayManagerScreen(@Nullable Screen parent) { mc.tell(() -> mc.setScreen(new OverlayManagerScreen(parent))); }
}
21 changes: 17 additions & 4 deletions src/main/java/aeronicamc/mods/mxtune/gui/MXScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,45 @@

import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.util.text.ITextComponent;

import java.util.Objects;

public class MXScreen extends Screen
{
protected MXScreen(ITextComponent pTitle)
{
super(pTitle);
}

@Override
public <T extends Widget> T addButton(T pButton) {
return super.addButton(pButton);
}

@Override
public void render(MatrixStack pMatrixStack, int pMouseX, int pMouseY, float pPartialTicks)
{
super.render(pMatrixStack, pMouseX, pMouseY, pPartialTicks);
ModGuiHelper.drawHooveringHelp(pMatrixStack, this, children, pMouseX, pMouseY);
}

public static Minecraft getMC()
{
@Override
public Minecraft getMinecraft() {
return Minecraft.getInstance();
}

public static FontRenderer getFont()
public ClientPlayerEntity getPlayer()
{
return Objects.requireNonNull(getMinecraft().player);
}
public FontRenderer getFont()
{
return getMC().font;
return Objects.requireNonNull(getMinecraft()).font;
}
}

2 changes: 2 additions & 0 deletions src/main/java/aeronicamc/mods/mxtune/gui/ModGuiHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class ModGuiHelper
public static final ITextComponent HELP_HELP03 = new TranslationTextComponent("gui.mxtune.button.help.help03").withStyle(TextFormatting.GREEN);
public static final ITextComponent BUTTON_DISABLED = new TranslationTextComponent("gui.mxtune.button.disabled").withStyle(TextFormatting.AQUA);
public static final ITextComponent BUTTON_ENABLED = new TranslationTextComponent("gui.mxtune.button.enabled").withStyle(TextFormatting.AQUA);
public static final ITextComponent BUTTON_OVERLAY_HELP01 = new TranslationTextComponent("gui.mxtune.button.overlay_button.help01").withStyle(TextFormatting.RESET);
public static final ITextComponent BUTTON_OVERLAY_HELP02 = new TranslationTextComponent("gui.mxtune.button.overlay_button.help02").withStyle(TextFormatting.YELLOW);

private ModGuiHelper() { /* NOOP */ }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

public class MultiInstScreen extends ContainerScreen<MultiInstContainer> implements ISlotChangedCallback
{
private static final ResourceLocation GUI = new ResourceLocation(Reference.MOD_ID, "textures/gui/container/multi_inst_item.png");
public static final ResourceLocation GUI = new ResourceLocation(Reference.MOD_ID, "textures/gui/container/multi_inst_item.png");
private static final ITextComponent AUTO_SELECT_ON = new TranslationTextComponent("gui.mxtune.switch.multi_inst_screen.auto_select_on").withStyle(TextFormatting.DARK_GRAY);
private static final ITextComponent AUTO_SELECT_OFF = new TranslationTextComponent("gui.mxtune.switch.multi_inst_screen.auto_select_off").withStyle(TextFormatting.DARK_GRAY);
private static final ITextComponent AUTO_SELECT_HELP01 = new TranslationTextComponent("gui.mxtune.switch.multi_inst_screen.auto_select.help01").withStyle(TextFormatting.RESET);
Expand All @@ -39,6 +39,7 @@ public class MultiInstScreen extends ContainerScreen<MultiInstContainer> impleme

private final MXButton buttonChangeInstrument = new MXButton(this::openSelector);
private final GuiVSlideSwitch autoSelectState = new GuiVSlideSwitch(p -> onChangeAuto());
private final GuiOverlayButton overlayButton = new GuiOverlayButton(p->Handler.openOverlayManagerScreen(null));
private final GuiHelpButton helpButton = new GuiHelpButton(p -> helpClicked());
private final GuiGroupButton groupButton = new GuiGroupButton(p -> onJamClicked());

Expand Down Expand Up @@ -71,6 +72,9 @@ protected void init()
autoSelectState.setPosition(xPos + 18 + 32 + 10, yPos + 36);
this.addButton(autoSelectState);

overlayButton.setPosition(leftPos + imageWidth - 12 - 64, yPos + 53);
this.addButton(overlayButton);

helpButton.setPosition(leftPos + imageWidth - 12 - 20, yPos + 53);
this.addButton(helpButton);

Expand Down Expand Up @@ -137,6 +141,9 @@ void updateButtonStatuses()
buttonChangeInstrument.addHooverText(false, INST_CHOOSER_HELP03);
buttonChangeInstrument.addHooverText(false, autoSelectState.getOnOff() ? BUTTON_DISABLED : BUTTON_ENABLED);
buttonChangeInstrument.active = !autoSelectState.getOnOff();
overlayButton.addHooverText(true, BUTTON_OVERLAY_HELP01);
overlayButton.addHooverText(false, BUTTON_OVERLAY_HELP02);
overlayButton.setButtonEnabled(true);
groupButton.addHooverText(true, OPEN_GROUP);
helpButton.addHooverText(true, HELP_HELP01);
helpButton.addHooverText(false, helpButton.isHelpEnabled() ? HELP_HELP02 : HELP_HELP03);
Expand Down
Loading

0 comments on commit 70972ed

Please sign in to comment.