diff --git a/src/main/java/com/moulberry/flashback/combo_options/GlowingOverride.java b/src/main/java/com/moulberry/flashback/combo_options/GlowingOverride.java new file mode 100644 index 0000000..fb38548 --- /dev/null +++ b/src/main/java/com/moulberry/flashback/combo_options/GlowingOverride.java @@ -0,0 +1,20 @@ +package com.moulberry.flashback.combo_options; + +public enum GlowingOverride implements ComboOption { + + DEFAULT("Default"), + FORCE_GLOW("Force Glow"), + FORCE_NO_GLOW("Force No Glow"); + + private final String text; + + GlowingOverride(String text) { + this.text = text; + } + + @Override + public String text() { + return this.text; + } + +} diff --git a/src/main/java/com/moulberry/flashback/editor/ui/windows/SelectedEntityPopup.java b/src/main/java/com/moulberry/flashback/editor/ui/windows/SelectedEntityPopup.java index dcae94a..1d85a7a 100644 --- a/src/main/java/com/moulberry/flashback/editor/ui/windows/SelectedEntityPopup.java +++ b/src/main/java/com/moulberry/flashback/editor/ui/windows/SelectedEntityPopup.java @@ -5,6 +5,7 @@ import com.mojang.authlib.yggdrasil.ProfileResult; import com.moulberry.flashback.FilePlayerSkin; import com.moulberry.flashback.Flashback; import com.moulberry.flashback.Utils; +import com.moulberry.flashback.combo_options.GlowingOverride; import com.moulberry.flashback.editor.ui.ImGuiHelper; import com.moulberry.flashback.exporting.AsyncFileDialogs; import com.moulberry.flashback.state.EditorState; @@ -82,89 +83,95 @@ public class SelectedEntityPopup { editorState.markDirty(); } - if (!isHiddenDuringExport && entity instanceof Player player) { - boolean hideNametag = editorState.hideNametags.contains(entity.getUUID()); - if (ImGui.checkbox("Render Nametag", !hideNametag)) { - if (hideNametag) { - editorState.hideNametags.remove(entity.getUUID()); - } else { - editorState.hideNametags.add(entity.getUUID()); - } - } - - if (!hideNametag) { - boolean changedName = ImGui.inputTextWithHint("Name##SetNameInput", player.getScoreboardName(), changeNameInput); - - if (changedName) { - String string = ImGuiHelper.getString(changeNameInput); - if (string.isEmpty()) { - editorState.nameOverride.remove(entity.getUUID()); + if (!isHiddenDuringExport) { + if (entity instanceof Player player) { + boolean hideNametag = editorState.hideNametags.contains(entity.getUUID()); + if (ImGui.checkbox("Render Nametag", !hideNametag)) { + if (hideNametag) { + editorState.hideNametags.remove(entity.getUUID()); } else { - editorState.nameOverride.put(entity.getUUID(), string); + editorState.hideNametags.add(entity.getUUID()); } } - if (editorState.hideTeamPrefix.contains(player.getUUID())) { - if (ImGui.checkbox("Hide Team Prefix", true)) { - editorState.hideTeamPrefix.remove(player.getUUID()); + if (!hideNametag) { + boolean changedName = ImGui.inputTextWithHint("Name##SetNameInput", player.getScoreboardName(), changeNameInput); + + if (changedName) { + String string = ImGuiHelper.getString(changeNameInput); + if (string.isEmpty()) { + editorState.nameOverride.remove(entity.getUUID()); + } else { + editorState.nameOverride.put(entity.getUUID(), string); + } } - } else { - PlayerTeam team = player.getTeam(); - if (team != null && !Utils.isComponentEmpty(team.getPlayerPrefix())) { - if (ImGui.checkbox("Hide Team Prefix", false)) { - editorState.hideTeamPrefix.add(player.getUUID()); + + if (editorState.hideTeamPrefix.contains(player.getUUID())) { + if (ImGui.checkbox("Hide Team Prefix", true)) { + editorState.hideTeamPrefix.remove(player.getUUID()); + } + } else { + PlayerTeam team = player.getTeam(); + if (team != null && !Utils.isComponentEmpty(team.getPlayerPrefix())) { + if (ImGui.checkbox("Hide Team Prefix", false)) { + editorState.hideTeamPrefix.add(player.getUUID()); + } + } + } + + if (editorState.hideTeamSuffix.contains(player.getUUID())) { + if (ImGui.checkbox("Hide Team Suffix", true)) { + editorState.hideTeamSuffix.remove(player.getUUID()); + } + } else { + PlayerTeam team = player.getTeam(); + if (team != null && !Utils.isComponentEmpty(team.getPlayerSuffix())) { + if (ImGui.checkbox("Hide Team Suffix", false)) { + editorState.hideTeamSuffix.add(player.getUUID()); + } } } } - if (editorState.hideTeamSuffix.contains(player.getUUID())) { - if (ImGui.checkbox("Hide Team Suffix", true)) { - editorState.hideTeamSuffix.remove(player.getUUID()); - } - } else { - PlayerTeam team = player.getTeam(); - if (team != null && !Utils.isComponentEmpty(team.getPlayerSuffix())) { - if (ImGui.checkbox("Hide Team Suffix", false)) { - editorState.hideTeamSuffix.add(player.getUUID()); + showGlowingDropdown(entity, editorState); + + ImGuiHelper.separatorWithText("Change Skin & Cape (UUID)"); + ImGui.setNextItemWidth(320); + ImGui.inputTextWithHint("##SetSkinInput", "e.g. d0e05de7-6067-454d-beae-c6d19d886191", changeSkinInput); + + if (!changeSkinInput.isEmpty()) { + String string = ImGuiHelper.getString(changeSkinInput); + try { + UUID changeSkinUuid = UUID.fromString(string); + if (ImGui.button("Apply Skin from UUID")) { + ProfileResult profile = Minecraft.getInstance().getMinecraftSessionService().fetchProfile(changeSkinUuid, true); + editorState.skinOverride.put(entity.getUUID(), profile.profile()); + editorState.skinOverrideFromFile.remove(entity.getUUID()); } - } + } catch (Exception ignored) {} } - } - ImGuiHelper.separatorWithText("Change Skin & Cape (UUID)"); - ImGui.setNextItemWidth(320); - ImGui.inputTextWithHint("##SetSkinInput", "e.g. d0e05de7-6067-454d-beae-c6d19d886191", changeSkinInput); + if (ImGui.button("Upload Skin from File")) { + Path gameDir = FabricLoader.getInstance().getGameDir(); + CompletableFuture future = AsyncFileDialogs.openFileDialog(gameDir.toString(), + "Skin Texture", "png"); + future.thenAccept(pathStr -> { + if (pathStr != null) { + editorState.skinOverride.remove(entity.getUUID()); + editorState.skinOverrideFromFile.put(entity.getUUID(), new FilePlayerSkin(pathStr)); + } + }); + } - if (!changeSkinInput.isEmpty()) { - String string = ImGuiHelper.getString(changeSkinInput); - try { - UUID changeSkinUuid = UUID.fromString(string); - if (ImGui.button("Apply Skin from UUID")) { - ProfileResult profile = Minecraft.getInstance().getMinecraftSessionService().fetchProfile(changeSkinUuid, true); - editorState.skinOverride.put(entity.getUUID(), profile.profile()); - editorState.skinOverrideFromFile.remove(entity.getUUID()); - } - } catch (Exception ignored) {} - } - - if (ImGui.button("Upload Skin from File")) { - Path gameDir = FabricLoader.getInstance().getGameDir(); - CompletableFuture future = AsyncFileDialogs.openFileDialog(gameDir.toString(), - "Skin Texture", "png"); - future.thenAccept(pathStr -> { - if (pathStr != null) { + if (editorState.skinOverride.containsKey(entity.getUUID()) || editorState.skinOverrideFromFile.containsKey(entity.getUUID())) { + if (ImGui.button("Reset Skin")) { editorState.skinOverride.remove(entity.getUUID()); - editorState.skinOverrideFromFile.put(entity.getUUID(), new FilePlayerSkin(pathStr)); + editorState.skinOverrideFromFile.remove(entity.getUUID()); + changeSkinInput.set(""); } - }); - } - - if (editorState.skinOverride.containsKey(entity.getUUID()) || editorState.skinOverrideFromFile.containsKey(entity.getUUID())) { - if (ImGui.button("Reset Skin")) { - editorState.skinOverride.remove(entity.getUUID()); - editorState.skinOverrideFromFile.remove(entity.getUUID()); - changeSkinInput.set(""); } + } else { + showGlowingDropdown(entity, editorState); } } @@ -186,4 +193,19 @@ public class SelectedEntityPopup { // } } + private static void showGlowingDropdown(Entity entity, EditorState editorState) { + GlowingOverride glowingOverride = GlowingOverride.DEFAULT; + if (editorState.glowingOverride.containsKey(entity.getUUID())) { + glowingOverride = editorState.glowingOverride.get(entity.getUUID()); + } + GlowingOverride newGlowingOverride = ImGuiHelper.enumCombo("Glowing", glowingOverride); + if (newGlowingOverride != glowingOverride) { + if (newGlowingOverride == GlowingOverride.DEFAULT) { + editorState.glowingOverride.remove(entity.getUUID()); + } else { + editorState.glowingOverride.put(entity.getUUID(), newGlowingOverride); + } + } + } + } diff --git a/src/main/java/com/moulberry/flashback/mixin/MixinMinecraft.java b/src/main/java/com/moulberry/flashback/mixin/MixinMinecraft.java index 08f92bc..b7f56a9 100644 --- a/src/main/java/com/moulberry/flashback/mixin/MixinMinecraft.java +++ b/src/main/java/com/moulberry/flashback/mixin/MixinMinecraft.java @@ -6,6 +6,7 @@ import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; import com.mojang.blaze3d.systems.RenderSystem; import com.moulberry.flashback.Flashback; import com.moulberry.flashback.FreezeSlowdownFormula; +import com.moulberry.flashback.combo_options.GlowingOverride; import com.moulberry.flashback.configuration.FlashbackConfig; import com.moulberry.flashback.editor.ui.windows.ExportDoneWindow; import com.moulberry.flashback.editor.ui.windows.WindowType; @@ -165,6 +166,20 @@ public abstract class MixinMinecraft implements MinecraftExt { } } + @Inject(method = "shouldEntityAppearGlowing", at = @At("HEAD"), cancellable = true) + private void shouldEntityAppearGlowing(Entity entity, CallbackInfoReturnable cir) { + EditorState editorState = EditorStateManager.getCurrent(); + if (editorState != null) { + GlowingOverride glowingOverride = editorState.glowingOverride.get(entity.getUUID()); + + if (glowingOverride == GlowingOverride.FORCE_GLOW) { + cir.setReturnValue(true); + } else if (glowingOverride == GlowingOverride.FORCE_NO_GLOW) { + cir.setReturnValue(false); + } + } + } + @WrapOperation(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/sounds/SoundManager;updateSource(Lnet/minecraft/client/Camera;)V")) public void runTick_updateSource(SoundManager instance, Camera camera, Operation original) { EditorState editorState = EditorStateManager.getCurrent(); diff --git a/src/main/java/com/moulberry/flashback/state/EditorState.java b/src/main/java/com/moulberry/flashback/state/EditorState.java index d00c7de..9654cae 100644 --- a/src/main/java/com/moulberry/flashback/state/EditorState.java +++ b/src/main/java/com/moulberry/flashback/state/EditorState.java @@ -4,6 +4,7 @@ import com.mojang.authlib.GameProfile; import com.moulberry.flashback.FilePlayerSkin; import com.moulberry.flashback.Flashback; import com.moulberry.flashback.FlashbackGson; +import com.moulberry.flashback.combo_options.GlowingOverride; import com.moulberry.flashback.editor.ui.ReplayUI; import com.moulberry.flashback.keyframe.Keyframe; import com.moulberry.flashback.keyframe.KeyframeType; @@ -51,6 +52,7 @@ public class EditorState { public Map skinOverride = new HashMap<>(); public Map skinOverrideFromFile = new HashMap<>(); public Map nameOverride = new HashMap<>(); + public Map glowingOverride = new HashMap<>(); public Set hideTeamPrefix = new HashSet<>(); public Set hideTeamSuffix = new HashSet<>(); public Set filteredEntities = new HashSet<>();