Remove lots of old code
Add some additional config settings Update jGui and ReplayStudio
This commit is contained in:
Submodule ReplayStudio updated: 9bb0df08e7...ac595d3caa
@@ -33,7 +33,7 @@ group= "com.replaymod"
|
|||||||
archivesBaseName = "replaymod"
|
archivesBaseName = "replaymod"
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
coreMod = 'eu.crushedpixel.replaymod.coremod.LoadingPlugin'
|
coreMod = 'com.replaymod.core.LoadingPlugin'
|
||||||
version = '1.8-11.14.4.1563'
|
version = '1.8-11.14.4.1563'
|
||||||
runDir = "eclipse"
|
runDir = "eclipse"
|
||||||
mappings = "snapshot_nodoc_20141130"
|
mappings = "snapshot_nodoc_20141130"
|
||||||
|
|||||||
2
jGui
2
jGui
Submodule jGui updated: 611fa2a4ef...10103ec71d
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.coremod;
|
package com.replaymod.core;
|
||||||
|
|
||||||
import net.minecraftforge.fml.relauncher.CoreModManager;
|
import net.minecraftforge.fml.relauncher.CoreModManager;
|
||||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
||||||
@@ -4,20 +4,10 @@ import com.google.common.io.Files;
|
|||||||
import com.google.common.util.concurrent.ListenableFutureTask;
|
import com.google.common.util.concurrent.ListenableFutureTask;
|
||||||
import com.replaymod.core.gui.RestoreReplayGui;
|
import com.replaymod.core.gui.RestoreReplayGui;
|
||||||
import com.replaymod.core.handler.MainMenuHandler;
|
import com.replaymod.core.handler.MainMenuHandler;
|
||||||
import com.replaymod.replay.ReplaySender;
|
|
||||||
import com.replaymod.replaystudio.util.I18n;
|
import com.replaymod.replaystudio.util.I18n;
|
||||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||||
import eu.crushedpixel.replaymod.chat.ChatMessageHandler;
|
import com.replaymod.render.utils.SoundHandler;
|
||||||
import eu.crushedpixel.replaymod.events.handlers.MouseInputHandler;
|
import com.replaymod.core.utils.OpenGLUtils;
|
||||||
import eu.crushedpixel.replaymod.events.handlers.TickAndRenderListener;
|
|
||||||
import eu.crushedpixel.replaymod.events.handlers.keyboard.KeyInputHandler;
|
|
||||||
import eu.crushedpixel.replaymod.registry.KeybindRegistry;
|
|
||||||
import eu.crushedpixel.replaymod.registry.ReplayFileAppender;
|
|
||||||
import eu.crushedpixel.replaymod.registry.UploadedFileHandler;
|
|
||||||
import eu.crushedpixel.replaymod.renderer.CustomObjectRenderer;
|
|
||||||
import eu.crushedpixel.replaymod.settings.ReplaySettings;
|
|
||||||
import eu.crushedpixel.replaymod.sound.SoundHandler;
|
|
||||||
import eu.crushedpixel.replaymod.utils.OpenGLUtils;
|
|
||||||
import eu.crushedpixel.replaymod.utils.TooltipRenderer;
|
import eu.crushedpixel.replaymod.utils.TooltipRenderer;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -25,7 +15,6 @@ import net.minecraft.client.settings.GameSettings;
|
|||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.crash.CrashReportCategory;
|
import net.minecraft.crash.CrashReportCategory;
|
||||||
import net.minecraft.util.*;
|
import net.minecraft.util.*;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
@@ -74,31 +63,11 @@ public class ReplayMod {
|
|||||||
|
|
||||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
private static final Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static ReplaySettings replaySettings;
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Configuration config;
|
public static Configuration config;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static boolean firstMainMenu = true;
|
|
||||||
@Deprecated
|
|
||||||
public static ChatMessageHandler chatMessageHandler = new ChatMessageHandler();
|
|
||||||
@Deprecated
|
|
||||||
public static KeyInputHandler keyInputHandler = new KeyInputHandler();
|
|
||||||
@Deprecated
|
|
||||||
public static MouseInputHandler mouseInputHandler = new MouseInputHandler();
|
|
||||||
@Deprecated
|
|
||||||
public static ReplaySender replaySender;
|
|
||||||
@Deprecated
|
|
||||||
public static int TP_DISTANCE_LIMIT = 128;
|
|
||||||
@Deprecated
|
|
||||||
public static ReplayFileAppender replayFileAppender;
|
|
||||||
@Deprecated
|
|
||||||
public static UploadedFileHandler uploadedFileHandler;
|
|
||||||
@Deprecated
|
|
||||||
public static TooltipRenderer tooltipRenderer;
|
public static TooltipRenderer tooltipRenderer;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static CustomObjectRenderer customObjectRenderer;
|
|
||||||
@Deprecated
|
|
||||||
public static SoundHandler soundHandler = new SoundHandler();
|
public static SoundHandler soundHandler = new SoundHandler();
|
||||||
|
|
||||||
private final KeyBindingRegistry keyBindingRegistry = new KeyBindingRegistry();
|
private final KeyBindingRegistry keyBindingRegistry = new KeyBindingRegistry();
|
||||||
@@ -117,7 +86,7 @@ public class ReplayMod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public File getReplayFolder() throws IOException {
|
public File getReplayFolder() throws IOException {
|
||||||
File folder = new File(replaySettings.getRecordingPath());
|
File folder = new File(getSettingsRegistry().get(Setting.RECORDING_PATH));
|
||||||
FileUtils.forceMkdir(folder);
|
FileUtils.forceMkdir(folder);
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
@@ -133,23 +102,15 @@ public class ReplayMod {
|
|||||||
config = new Configuration(event.getSuggestedConfigurationFile());
|
config = new Configuration(event.getSuggestedConfigurationFile());
|
||||||
config.load();
|
config.load();
|
||||||
settingsRegistry.setConfiguration(config);
|
settingsRegistry.setConfiguration(config);
|
||||||
|
|
||||||
uploadedFileHandler = new UploadedFileHandler(event.getModConfigurationDirectory());
|
|
||||||
|
|
||||||
replaySettings = new ReplaySettings();
|
|
||||||
|
|
||||||
replayFileAppender = new ReplayFileAppender();
|
|
||||||
FMLCommonHandler.instance().bus().register(replayFileAppender);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
|
getSettingsRegistry().register(Setting.class);
|
||||||
|
|
||||||
new MainMenuHandler().register();
|
new MainMenuHandler().register();
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().register(keyInputHandler);
|
|
||||||
FMLCommonHandler.instance().bus().register(keyBindingRegistry);
|
FMLCommonHandler.instance().bus().register(keyBindingRegistry);
|
||||||
FMLCommonHandler.instance().bus().register(mouseInputHandler);
|
|
||||||
MinecraftForge.EVENT_BUS.register(mouseInputHandler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -159,16 +120,6 @@ public class ReplayMod {
|
|||||||
if(!FMLClientHandler.instance().hasOptifine())
|
if(!FMLClientHandler.instance().hasOptifine())
|
||||||
GameSettings.Options.RENDER_DISTANCE.setValueMax(64f);
|
GameSettings.Options.RENDER_DISTANCE.setValueMax(64f);
|
||||||
|
|
||||||
TickAndRenderListener tarl = new TickAndRenderListener();
|
|
||||||
FMLCommonHandler.instance().bus().register(tarl);
|
|
||||||
MinecraftForge.EVENT_BUS.register(tarl);
|
|
||||||
|
|
||||||
customObjectRenderer = new CustomObjectRenderer();
|
|
||||||
FMLCommonHandler.instance().bus().register(customObjectRenderer);
|
|
||||||
MinecraftForge.EVENT_BUS.register(customObjectRenderer);
|
|
||||||
|
|
||||||
KeybindRegistry.initialize();
|
|
||||||
|
|
||||||
tooltipRenderer = new TooltipRenderer();
|
tooltipRenderer = new TooltipRenderer();
|
||||||
|
|
||||||
if (System.getProperty("replaymod.render.file") != null) {
|
if (System.getProperty("replaymod.render.file") != null) {
|
||||||
@@ -360,7 +311,7 @@ public class ReplayMod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void printToChat(boolean warning, String message, Object... args) {
|
private void printToChat(boolean warning, String message, Object... args) {
|
||||||
if (ReplayMod.replaySettings.isShowNotifications()) {
|
if (getSettingsRegistry().get(Setting.NOTIFICATIONS)) {
|
||||||
// Some nostalgia: "§8[§6Replay Mod§8]§r Your message goes here"
|
// Some nostalgia: "§8[§6Replay Mod§8]§r Your message goes here"
|
||||||
ChatStyle coloredDarkGray = new ChatStyle().setColor(EnumChatFormatting.DARK_GRAY);
|
ChatStyle coloredDarkGray = new ChatStyle().setColor(EnumChatFormatting.DARK_GRAY);
|
||||||
ChatStyle coloredGold = new ChatStyle().setColor(EnumChatFormatting.GOLD);
|
ChatStyle coloredGold = new ChatStyle().setColor(EnumChatFormatting.GOLD);
|
||||||
|
|||||||
18
src/main/java/com/replaymod/core/Setting.java
Normal file
18
src/main/java/com/replaymod/core/Setting.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package com.replaymod.core;
|
||||||
|
|
||||||
|
public final class Setting<T> extends SettingsRegistry.SettingKeys<T> {
|
||||||
|
public static final Setting<Boolean> NOTIFICATIONS = make("notifications", "notifications", true);
|
||||||
|
public static final Setting<String> RECORDING_PATH = advanced("recordingPath", null, "./replay_recordings/");
|
||||||
|
|
||||||
|
private static <T> Setting<T> make(String key, String displayName, T defaultValue) {
|
||||||
|
return new Setting<>("core", key, displayName, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> Setting<T> advanced(String key, String displayName, T defaultValue) {
|
||||||
|
return new Setting<>("advanced", key, displayName, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Setting(String category, String key, String displayString, T defaultValue) {
|
||||||
|
super(category, key, displayString == null ? null : "replaymod.gui.settings." + displayString, defaultValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.utils;
|
package com.replaymod.core.utils;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
9
src/main/java/com/replaymod/core/utils/Patterns.java
Normal file
9
src/main/java/com/replaymod/core/utils/Patterns.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package com.replaymod.core.utils;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class Patterns {
|
||||||
|
public static final Pattern ALPHANUMERIC_UNDERSCORE = Pattern.compile("^[a-z0-9_]*$", Pattern.CASE_INSENSITIVE);
|
||||||
|
public static final Pattern ALPHANUMERIC_COMMA = Pattern.compile("^[a-z0-9,]*$", Pattern.CASE_INSENSITIVE);
|
||||||
|
public static final Pattern ALPHANUMERIC_SPACE_HYPHEN_UNDERSCORE = Pattern.compile("^[a-z0-9 \\-_]*$", Pattern.CASE_INSENSITIVE);
|
||||||
|
}
|
||||||
74
src/main/java/com/replaymod/core/utils/Utils.java
Normal file
74
src/main/java/com/replaymod/core/utils/Utils.java
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
package com.replaymod.core.utils;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||||
|
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import org.lwjgl.util.Dimension;
|
||||||
|
import org.lwjgl.util.ReadableDimension;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class Utils {
|
||||||
|
|
||||||
|
public static final BufferedImage DEFAULT_THUMBNAIL;
|
||||||
|
|
||||||
|
static {
|
||||||
|
BufferedImage thumbnail;
|
||||||
|
try {
|
||||||
|
thumbnail = ImageIO.read(Utils.class.getClassLoader().getResourceAsStream("default_thumb.jpg"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
thumbnail = new BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
DEFAULT_THUMBNAIL = thumbnail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String convertSecondsToShortString(int seconds) {
|
||||||
|
int hours = seconds/(60*60);
|
||||||
|
int min = seconds/60 - hours*60;
|
||||||
|
int sec = seconds - ((min*60) + (hours*60*60));
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
if(hours > 0) builder.append(String.format("%02d", hours)).append(":");
|
||||||
|
builder.append(String.format("%02d", min)).append(":");
|
||||||
|
builder.append(String.format("%02d", sec));
|
||||||
|
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Dimension fitIntoBounds(ReadableDimension toFit, ReadableDimension bounds) {
|
||||||
|
int width = toFit.getWidth();
|
||||||
|
int height = toFit.getHeight();
|
||||||
|
|
||||||
|
float w = (float) width / bounds.getWidth();
|
||||||
|
float h = (float) height / bounds.getHeight();
|
||||||
|
|
||||||
|
if (w > h) {
|
||||||
|
height = (int) (height / w);
|
||||||
|
width = (int) (width / w);
|
||||||
|
} else {
|
||||||
|
height = (int) (height / h);
|
||||||
|
width = (int) (width / h);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Dimension(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isValidEmailAddress(String mail) {
|
||||||
|
return mail.matches("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResourceLocation getResourceLocationForPlayerUUID(UUID uuid) {
|
||||||
|
NetworkPlayerInfo info = Minecraft.getMinecraft().getNetHandler().getPlayerInfo(uuid);
|
||||||
|
ResourceLocation skinLocation;
|
||||||
|
if (info != null && info.hasLocationSkin()) {
|
||||||
|
skinLocation = info.getLocationSkin();
|
||||||
|
} else {
|
||||||
|
skinLocation = DefaultPlayerSkin.getDefaultSkin(uuid);
|
||||||
|
}
|
||||||
|
return skinLocation;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.replaymod.extras.playeroverview;
|
package com.replaymod.extras.playeroverview;
|
||||||
|
|
||||||
|
import com.replaymod.core.utils.Utils;
|
||||||
import com.replaymod.replay.ReplayModReplay;
|
import com.replaymod.replay.ReplayModReplay;
|
||||||
import de.johni0702.minecraft.gui.GuiRenderer;
|
import de.johni0702.minecraft.gui.GuiRenderer;
|
||||||
import de.johni0702.minecraft.gui.RenderInfo;
|
import de.johni0702.minecraft.gui.RenderInfo;
|
||||||
@@ -12,7 +13,6 @@ import de.johni0702.minecraft.gui.function.Closeable;
|
|||||||
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
||||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||||
import de.johni0702.minecraft.gui.utils.Colors;
|
import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
import eu.crushedpixel.replaymod.utils.SkinProvider;
|
|
||||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
import net.minecraft.entity.player.EnumPlayerModelParts;
|
||||||
@@ -83,7 +83,7 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
|||||||
|
|
||||||
Collections.sort(players, new PlayerComparator()); // Sort by name, spectators last
|
Collections.sort(players, new PlayerComparator()); // Sort by name, spectators last
|
||||||
for (final EntityPlayer p : players) {
|
for (final EntityPlayer p : players) {
|
||||||
final ResourceLocation texture = SkinProvider.getResourceLocationForPlayerUUID(p.getUniqueID());
|
final ResourceLocation texture = Utils.getResourceLocationForPlayerUUID(p.getUniqueID());
|
||||||
final GuiClickable panel = new GuiClickable().setLayout(new HorizontalLayout().setSpacing(2)).addElements(
|
final GuiClickable panel = new GuiClickable().setLayout(new HorizontalLayout().setSpacing(2)).addElements(
|
||||||
new HorizontalLayout.Data(0.5), new GuiImage() {
|
new HorizontalLayout.Data(0.5), new GuiImage() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import com.replaymod.online.api.replay.SearchQuery;
|
|||||||
import com.replaymod.online.api.replay.holders.*;
|
import com.replaymod.online.api.replay.holders.*;
|
||||||
import eu.crushedpixel.replaymod.gui.elements.listeners.ProgressUpdateListener;
|
import eu.crushedpixel.replaymod.gui.elements.listeners.ProgressUpdateListener;
|
||||||
import com.replaymod.online.AuthenticationHash;
|
import com.replaymod.online.AuthenticationHash;
|
||||||
import eu.crushedpixel.replaymod.utils.Api;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
@@ -222,7 +221,6 @@ public class ApiClient {
|
|||||||
return invokeAndReturn(builder, Favorites.class).getFavorited();
|
return invokeAndReturn(builder, Favorites.class).getFavorited();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Api
|
|
||||||
public void removeFile(int file) throws IOException, ApiException {
|
public void removeFile(int file) throws IOException, ApiException {
|
||||||
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.remove_file);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.remove_file);
|
||||||
builder.put("auth", authData.getAuthKey());
|
builder.put("auth", authData.getAuthKey());
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class GuiLoginPrompt extends AbstractGuiScreen<GuiLoginPrompt> {
|
|||||||
private GuiButton registerButton = new GuiButton(this).setI18nLabel("replaymod.gui.register").setSize(150, 20);
|
private GuiButton registerButton = new GuiButton(this).setI18nLabel("replaymod.gui.register").setSize(150, 20);
|
||||||
private GuiTextField username = new GuiTextField(this).setSize(145, 20).setMaxLength(16).setFocused(true);
|
private GuiTextField username = new GuiTextField(this).setSize(145, 20).setMaxLength(16).setFocused(true);
|
||||||
private GuiPasswordField password = new GuiPasswordField(this).setSize(145, 20)
|
private GuiPasswordField password = new GuiPasswordField(this).setSize(145, 20)
|
||||||
.setMaxLength(GuiConstants.MAX_PW_LENGTH);
|
.setMaxLength(GuiRegister.MAX_PW_LENGTH);
|
||||||
|
|
||||||
{
|
{
|
||||||
Utils.link(username, password);
|
Utils.link(username, password);
|
||||||
|
|||||||
@@ -11,14 +11,15 @@ import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
|||||||
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
||||||
import de.johni0702.minecraft.gui.utils.Consumers;
|
import de.johni0702.minecraft.gui.utils.Consumers;
|
||||||
import de.johni0702.minecraft.gui.utils.Utils;
|
import de.johni0702.minecraft.gui.utils.Utils;
|
||||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
import com.replaymod.core.utils.Patterns;
|
||||||
import eu.crushedpixel.replaymod.utils.EmailAddressUtils;
|
|
||||||
import eu.crushedpixel.replaymod.utils.RegexUtils;
|
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
import org.lwjgl.util.ReadableColor;
|
import org.lwjgl.util.ReadableColor;
|
||||||
|
|
||||||
public class GuiRegister extends AbstractGuiScreen<GuiRegister> {
|
public class GuiRegister extends AbstractGuiScreen<GuiRegister> {
|
||||||
|
public static final int MIN_PW_LENGTH = 5;
|
||||||
|
public static final int MAX_PW_LENGTH = 1024;
|
||||||
|
|
||||||
private final GuiPanel inputs;
|
private final GuiPanel inputs;
|
||||||
private final GuiTextField usernameInput, mailInput;
|
private final GuiTextField usernameInput, mailInput;
|
||||||
private final GuiPasswordField passwordInput, passwordConfirmation;
|
private final GuiPasswordField passwordInput, passwordConfirmation;
|
||||||
@@ -39,10 +40,10 @@ public class GuiRegister extends AbstractGuiScreen<GuiRegister> {
|
|||||||
.addElements(data, mailInput = new GuiTextField().setSize(145, 20)),
|
.addElements(data, mailInput = new GuiTextField().setSize(145, 20)),
|
||||||
new GuiPanel().setLayout(new HorizontalLayout(HorizontalLayout.Alignment.RIGHT).setSpacing(10))
|
new GuiPanel().setLayout(new HorizontalLayout(HorizontalLayout.Alignment.RIGHT).setSpacing(10))
|
||||||
.addElements(data, new GuiLabel().setI18nText("replaymod.gui.password"))
|
.addElements(data, new GuiLabel().setI18nText("replaymod.gui.password"))
|
||||||
.addElements(data, passwordInput = new GuiPasswordField().setMaxLength(GuiConstants.MAX_PW_LENGTH+1).setSize(145, 20)),
|
.addElements(data, passwordInput = new GuiPasswordField().setMaxLength(MAX_PW_LENGTH+1).setSize(145, 20)),
|
||||||
new GuiPanel().setLayout(new HorizontalLayout(HorizontalLayout.Alignment.RIGHT).setSpacing(10))
|
new GuiPanel().setLayout(new HorizontalLayout(HorizontalLayout.Alignment.RIGHT).setSpacing(10))
|
||||||
.addElements(data, new GuiLabel().setI18nText("replaymod.gui.register.confirmpw"))
|
.addElements(data, new GuiLabel().setI18nText("replaymod.gui.register.confirmpw"))
|
||||||
.addElements(data, passwordConfirmation = new GuiPasswordField().setMaxLength(GuiConstants.MAX_PW_LENGTH+1).setSize(145, 20))
|
.addElements(data, passwordConfirmation = new GuiPasswordField().setMaxLength(MAX_PW_LENGTH+1).setSize(145, 20))
|
||||||
);
|
);
|
||||||
Utils.link(usernameInput, mailInput, passwordInput, passwordConfirmation);
|
Utils.link(usernameInput, mailInput, passwordInput, passwordConfirmation);
|
||||||
|
|
||||||
@@ -111,13 +112,13 @@ public class GuiRegister extends AbstractGuiScreen<GuiRegister> {
|
|||||||
String status = null;
|
String status = null;
|
||||||
if (usernameInput.getText().length() < 5) {
|
if (usernameInput.getText().length() < 5) {
|
||||||
status = "replaymod.gui.register.error.shortusername";
|
status = "replaymod.gui.register.error.shortusername";
|
||||||
} else if(!RegexUtils.isValid(RegexUtils.ALPHANUMERIC_UNDERSCORE, usernameInput.getText().trim())) {
|
} else if(!Patterns.ALPHANUMERIC_UNDERSCORE.matcher(usernameInput.getText().trim()).matches()) {
|
||||||
status = "replaymod.gui.register.error.invalidname";
|
status = "replaymod.gui.register.error.invalidname";
|
||||||
} else if (passwordInput.getText().length() < GuiConstants.MIN_PW_LENGTH) {
|
} else if (passwordInput.getText().length() < MIN_PW_LENGTH) {
|
||||||
status = "replaymod.gui.register.error.shortpw";
|
status = "replaymod.gui.register.error.shortpw";
|
||||||
} else if (passwordInput.getText().length() > GuiConstants.MAX_PW_LENGTH) {
|
} else if (passwordInput.getText().length() > MAX_PW_LENGTH) {
|
||||||
status = "replaymod.gui.register.error.longpw";
|
status = "replaymod.gui.register.error.longpw";
|
||||||
} else if (!EmailAddressUtils.isValidEmailAddress(mailInput.getText())) {
|
} else if (!com.replaymod.core.utils.Utils.isValidEmailAddress(mailInput.getText())) {
|
||||||
status = "replaymod.api.invalidmail";
|
status = "replaymod.api.invalidmail";
|
||||||
} else if (!passwordConfirmation.getText().equals(passwordInput.getText())) {
|
} else if (!passwordConfirmation.getText().equals(passwordInput.getText())) {
|
||||||
status = "replaymod.gui.register.error.nomatch";
|
status = "replaymod.gui.register.error.nomatch";
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.google.common.primitives.Ints;
|
|||||||
import com.google.common.util.concurrent.FutureCallback;
|
import com.google.common.util.concurrent.FutureCallback;
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||||
|
import com.replaymod.core.utils.Utils;
|
||||||
import com.replaymod.online.ReplayModOnline;
|
import com.replaymod.online.ReplayModOnline;
|
||||||
import com.replaymod.online.api.ApiClient;
|
import com.replaymod.online.api.ApiClient;
|
||||||
import com.replaymod.online.api.ApiException;
|
import com.replaymod.online.api.ApiException;
|
||||||
@@ -18,6 +19,7 @@ import com.replaymod.online.api.replay.pagination.DownloadedFilePagination;
|
|||||||
import com.replaymod.online.api.replay.pagination.FavoritedFilePagination;
|
import com.replaymod.online.api.replay.pagination.FavoritedFilePagination;
|
||||||
import com.replaymod.online.api.replay.pagination.Pagination;
|
import com.replaymod.online.api.replay.pagination.Pagination;
|
||||||
import com.replaymod.online.api.replay.pagination.SearchPagination;
|
import com.replaymod.online.api.replay.pagination.SearchPagination;
|
||||||
|
import com.replaymod.replaystudio.replay.ReplayMetaData;
|
||||||
import de.johni0702.minecraft.gui.container.AbstractGuiContainer;
|
import de.johni0702.minecraft.gui.container.AbstractGuiContainer;
|
||||||
import de.johni0702.minecraft.gui.container.GuiContainer;
|
import de.johni0702.minecraft.gui.container.GuiContainer;
|
||||||
import de.johni0702.minecraft.gui.container.GuiPanel;
|
import de.johni0702.minecraft.gui.container.GuiPanel;
|
||||||
@@ -33,9 +35,6 @@ import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
|||||||
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
||||||
import de.johni0702.minecraft.gui.utils.Colors;
|
import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
import de.johni0702.minecraft.gui.utils.Consumer;
|
import de.johni0702.minecraft.gui.utils.Consumer;
|
||||||
import com.replaymod.replaystudio.replay.ReplayMetaData;
|
|
||||||
import eu.crushedpixel.replaymod.registry.ResourceHelper;
|
|
||||||
import eu.crushedpixel.replaymod.utils.DurationUtils;
|
|
||||||
import net.minecraftforge.fml.common.FMLLog;
|
import net.minecraftforge.fml.common.FMLLog;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.logging.log4j.core.helpers.Strings;
|
import org.apache.logging.log4j.core.helpers.Strings;
|
||||||
@@ -333,7 +332,7 @@ public class GuiReplayCenter extends GuiScreen {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final GuiImage defaultThumbnail = new GuiImage().setTexture(ResourceHelper.getDefaultThumbnail());
|
private final GuiImage defaultThumbnail = new GuiImage().setTexture(Utils.DEFAULT_THUMBNAIL);
|
||||||
public class GuiReplayEntry extends AbstractGuiContainer<GuiReplayEntry> implements Comparable<GuiReplayEntry> {
|
public class GuiReplayEntry extends AbstractGuiContainer<GuiReplayEntry> implements Comparable<GuiReplayEntry> {
|
||||||
public final FileInfo fileInfo;
|
public final FileInfo fileInfo;
|
||||||
public final GuiLabel name = new GuiLabel();
|
public final GuiLabel name = new GuiLabel();
|
||||||
@@ -414,7 +413,7 @@ public class GuiReplayCenter extends GuiScreen {
|
|||||||
thumbnail = new GuiImage(this).setTexture(thumbImage);
|
thumbnail = new GuiImage(this).setTexture(thumbImage);
|
||||||
}
|
}
|
||||||
thumbnail.setSize(45 * 16 / 9, 45);
|
thumbnail.setSize(45 * 16 / 9, 45);
|
||||||
duration.setText(DurationUtils.convertSecondsToShortString(metaData.getDuration() / 1000));
|
duration.setText(Utils.convertSecondsToShortString(metaData.getDuration() / 1000));
|
||||||
downloads.setText(fileInfo.getDownloads() + " ⬇");
|
downloads.setText(fileInfo.getDownloads() + " ⬇");
|
||||||
favorites.setText("⭑" + fileInfo.getFavorites());
|
favorites.setText("⭑" + fileInfo.getFavorites());
|
||||||
likes.setText("⬆" + fileInfo.getRatings().getPositive());
|
likes.setText("⬆" + fileInfo.getRatings().getPositive());
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.replaymod.online.gui;
|
|||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
|
import com.replaymod.core.utils.Utils;
|
||||||
import com.replaymod.online.api.ApiClient;
|
import com.replaymod.online.api.ApiClient;
|
||||||
import com.replaymod.replay.gui.screen.GuiReplayViewer;
|
import com.replaymod.replay.gui.screen.GuiReplayViewer;
|
||||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||||
@@ -13,10 +14,8 @@ import com.replaymod.online.api.replay.holders.Category;
|
|||||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
||||||
import eu.crushedpixel.replaymod.gui.elements.*;
|
import eu.crushedpixel.replaymod.gui.elements.*;
|
||||||
import eu.crushedpixel.replaymod.gui.elements.listeners.ProgressUpdateListener;
|
import eu.crushedpixel.replaymod.gui.elements.listeners.ProgressUpdateListener;
|
||||||
import eu.crushedpixel.replaymod.registry.ResourceHelper;
|
|
||||||
import eu.crushedpixel.replaymod.utils.ImageUtils;
|
|
||||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
||||||
import eu.crushedpixel.replaymod.utils.RegexUtils;
|
import com.replaymod.core.utils.Patterns;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Gui;
|
import net.minecraft.client.gui.Gui;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
@@ -34,7 +33,6 @@ import org.apache.logging.log4j.LogManager;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -99,7 +97,7 @@ public class GuiUploadFile extends GuiScreen implements ProgressUpdateListener {
|
|||||||
metaData = archive.getMetaData();
|
metaData = archive.getMetaData();
|
||||||
Optional<BufferedImage> img = archive.getThumb();
|
Optional<BufferedImage> img = archive.getThumb();
|
||||||
if(img.isPresent()) {
|
if(img.isPresent()) {
|
||||||
thumb = ImageUtils.scaleImage(img.get(), new Dimension(1280, 720));
|
thumb = img.get();
|
||||||
hasThumbnail = true;
|
hasThumbnail = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,11 +123,7 @@ public class GuiUploadFile extends GuiScreen implements ProgressUpdateListener {
|
|||||||
|
|
||||||
//If thumb is null, set image to placeholder
|
//If thumb is null, set image to placeholder
|
||||||
if(thumb == null) {
|
if(thumb == null) {
|
||||||
try {
|
thumb = Utils.DEFAULT_THUMBNAIL;
|
||||||
thumb = ImageIO.read(GuiUploadFile.class.getClassLoader().getResourceAsStream("default_thumb.jpg"));
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,8 +315,6 @@ public class GuiUploadFile extends GuiScreen implements ProgressUpdateListener {
|
|||||||
} else {
|
} else {
|
||||||
uploader.uploadFile(GuiUploadFile.this, name, tags, replayFile, category, desc);
|
uploader.uploadFile(GuiUploadFile.this, name, tags, replayFile, category, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReplayMod.uploadedFileHandler.markAsUploaded(replayFile);
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
messageTextField.setText(I18n.format("replaymod.gui.unknownerror"));
|
messageTextField.setText(I18n.format("replaymod.gui.unknownerror"));
|
||||||
messageTextField.setTextColor(Color.RED.getRGB());
|
messageTextField.setTextColor(Color.RED.getRGB());
|
||||||
@@ -347,7 +339,6 @@ public class GuiUploadFile extends GuiScreen implements ProgressUpdateListener {
|
|||||||
dynTex = new DynamicTexture(thumb);
|
dynTex = new DynamicTexture(thumb);
|
||||||
mc.getTextureManager().loadTexture(textureResource, dynTex);
|
mc.getTextureManager().loadTexture(textureResource, dynTex);
|
||||||
dynTex.updateDynamicTexture();
|
dynTex.updateDynamicTexture();
|
||||||
ResourceHelper.registerResource(textureResource);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mc.getTextureManager().bindTexture(textureResource); //Will be freed by the ResourceHelper
|
mc.getTextureManager().bindTexture(textureResource); //Will be freed by the ResourceHelper
|
||||||
@@ -388,7 +379,7 @@ public class GuiUploadFile extends GuiScreen implements ProgressUpdateListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGuiClosed() {
|
public void onGuiClosed() {
|
||||||
ResourceHelper.freeAllResources();
|
// Note: Currently intentionally leaks resources, will be fixed soon
|
||||||
Keyboard.enableRepeatEvents(false);
|
Keyboard.enableRepeatEvents(false);
|
||||||
super.onGuiClosed();
|
super.onGuiClosed();
|
||||||
}
|
}
|
||||||
@@ -411,11 +402,11 @@ public class GuiUploadFile extends GuiScreen implements ProgressUpdateListener {
|
|||||||
enabled = false;
|
enabled = false;
|
||||||
name.setTextColor(Color.RED.getRGB());
|
name.setTextColor(Color.RED.getRGB());
|
||||||
startUploadButton.hoverText = I18n.format("replaymod.gui.upload.error.name.length");
|
startUploadButton.hoverText = I18n.format("replaymod.gui.upload.error.name.length");
|
||||||
} else if(!RegexUtils.isValid(RegexUtils.ALPHANUMERIC_SPACE_HYPHEN_UNDERSCORE, name.getText())) {
|
} else if(!Patterns.ALPHANUMERIC_SPACE_HYPHEN_UNDERSCORE.matcher(name.getText()).matches()) {
|
||||||
enabled = false;
|
enabled = false;
|
||||||
name.setTextColor(Color.RED.getRGB());
|
name.setTextColor(Color.RED.getRGB());
|
||||||
startUploadButton.hoverText = I18n.format("replaymod.gui.upload.error.name");
|
startUploadButton.hoverText = I18n.format("replaymod.gui.upload.error.name");
|
||||||
} else if(!RegexUtils.isValid(RegexUtils.ALPHANUMERIC_COMMA, tags.getText())) {
|
} else if(!Patterns.ALPHANUMERIC_COMMA.matcher(tags.getText()).matches()) {
|
||||||
enabled = false;
|
enabled = false;
|
||||||
tags.setTextColor(Color.RED.getRGB());
|
tags.setTextColor(Color.RED.getRGB());
|
||||||
startUploadButton.hoverText = I18n.format("replaymod.gui.upload.error.tags");
|
startUploadButton.hoverText = I18n.format("replaymod.gui.upload.error.tags");
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.replaymod.recording.handler;
|
package com.replaymod.recording.handler;
|
||||||
|
|
||||||
import com.replaymod.recording.packet.PacketListener;
|
import com.replaymod.recording.packet.PacketListener;
|
||||||
import eu.crushedpixel.replaymod.utils.Objects;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -25,6 +24,8 @@ import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemPickupEvent;
|
|||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class RecordingEventHandler {
|
public class RecordingEventHandler {
|
||||||
|
|
||||||
private final Minecraft mc = Minecraft.getMinecraft();
|
private final Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import com.replaymod.core.utils.Restrictions;
|
|||||||
import com.replaymod.replaystudio.data.Marker;
|
import com.replaymod.replaystudio.data.Marker;
|
||||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||||
import com.replaymod.replaystudio.replay.ReplayMetaData;
|
import com.replaymod.replaystudio.replay.ReplayMetaData;
|
||||||
import eu.crushedpixel.replaymod.holders.AdvancedPosition;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.DataWatcher;
|
import net.minecraft.entity.DataWatcher;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.network.EnumConnectionState;
|
import net.minecraft.network.EnumConnectionState;
|
||||||
import net.minecraft.network.EnumPacketDirection;
|
import net.minecraft.network.EnumPacketDirection;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
@@ -231,17 +231,17 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addMarker() {
|
public void addMarker() {
|
||||||
AdvancedPosition pos = new AdvancedPosition(Minecraft.getMinecraft().getRenderViewEntity());
|
Entity view = Minecraft.getMinecraft().getRenderViewEntity();
|
||||||
int timestamp = (int) (System.currentTimeMillis() - startTime);
|
int timestamp = (int) (System.currentTimeMillis() - startTime);
|
||||||
|
|
||||||
Marker marker = new Marker();
|
Marker marker = new Marker();
|
||||||
marker.setTime(timestamp);
|
marker.setTime(timestamp);
|
||||||
marker.setX(pos.getX());
|
marker.setX(view.posX);
|
||||||
marker.setY(pos.getY());
|
marker.setY(view.posY);
|
||||||
marker.setZ(pos.getZ());
|
marker.setZ(view.posZ);
|
||||||
marker.setYaw((float) pos.getYaw());
|
marker.setYaw(view.rotationYaw);
|
||||||
marker.setPitch((float) pos.getPitch());
|
marker.setPitch(view.rotationPitch);
|
||||||
marker.setRoll((float) pos.getRoll());
|
// Roll is always 0
|
||||||
saveService.submit(() -> {
|
saveService.submit(() -> {
|
||||||
synchronized (replayFile) {
|
synchronized (replayFile) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.replaymod.render;
|
|||||||
import com.replaymod.render.frame.RGBFrame;
|
import com.replaymod.render.frame.RGBFrame;
|
||||||
import com.replaymod.render.rendering.FrameConsumer;
|
import com.replaymod.render.rendering.FrameConsumer;
|
||||||
import com.replaymod.render.utils.ByteBufferPool;
|
import com.replaymod.render.utils.ByteBufferPool;
|
||||||
import eu.crushedpixel.replaymod.utils.StreamPipe;
|
import com.replaymod.render.utils.StreamPipe;
|
||||||
import eu.crushedpixel.replaymod.utils.StringUtils;
|
import eu.crushedpixel.replaymod.utils.StringUtils;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.replaymod.render.gui;
|
package com.replaymod.render.gui;
|
||||||
|
|
||||||
|
import com.replaymod.core.utils.Utils;
|
||||||
import com.replaymod.render.frame.RGBFrame;
|
import com.replaymod.render.frame.RGBFrame;
|
||||||
import com.replaymod.render.rendering.VideoRenderer;
|
import com.replaymod.render.rendering.VideoRenderer;
|
||||||
import de.johni0702.minecraft.gui.GuiRenderer;
|
import de.johni0702.minecraft.gui.GuiRenderer;
|
||||||
@@ -12,7 +13,6 @@ import de.johni0702.minecraft.gui.element.GuiLabel;
|
|||||||
import de.johni0702.minecraft.gui.element.advanced.GuiProgressBar;
|
import de.johni0702.minecraft.gui.element.advanced.GuiProgressBar;
|
||||||
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
||||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||||
import eu.crushedpixel.replaymod.utils.BoundingUtils;
|
|
||||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
@@ -257,7 +257,7 @@ public class GuiVideoRenderer extends GuiScreen {
|
|||||||
|
|
||||||
private void renderPreviewTexture(GuiRenderer guiRenderer, ReadableDimension size,
|
private void renderPreviewTexture(GuiRenderer guiRenderer, ReadableDimension size,
|
||||||
int videoWidth, int videoHeight) {
|
int videoWidth, int videoHeight) {
|
||||||
Dimension dimension = BoundingUtils.fitIntoBounds(new Dimension(videoWidth, videoHeight), size);
|
Dimension dimension = Utils.fitIntoBounds(new Dimension(videoWidth, videoHeight), size);
|
||||||
|
|
||||||
int width = dimension.getWidth();
|
int width = dimension.getWidth();
|
||||||
int height = dimension.getHeight();
|
int height = dimension.getHeight();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.replaymod.render.hooks;
|
package com.replaymod.render.hooks;
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.utils.JailingQueue;
|
import com.replaymod.render.utils.JailingQueue;
|
||||||
import net.minecraft.client.renderer.RegionRenderCacheBuilder;
|
import net.minecraft.client.renderer.RegionRenderCacheBuilder;
|
||||||
import net.minecraft.client.renderer.RenderGlobal;
|
import net.minecraft.client.renderer.RenderGlobal;
|
||||||
import net.minecraft.client.renderer.chunk.ChunkCompileTaskGenerator;
|
import net.minecraft.client.renderer.chunk.ChunkCompileTaskGenerator;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.utils;
|
package com.replaymod.render.utils;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.sound;
|
package com.replaymod.render.utils;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package eu.crushedpixel.replaymod.utils;
|
package com.replaymod.render.utils;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
@@ -9,9 +9,8 @@ import com.replaymod.replay.events.ReplayOpenEvent;
|
|||||||
import com.replaymod.replay.gui.overlay.GuiReplayOverlay;
|
import com.replaymod.replay.gui.overlay.GuiReplayOverlay;
|
||||||
import com.replaymod.replaystudio.data.Marker;
|
import com.replaymod.replaystudio.data.Marker;
|
||||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||||
import eu.crushedpixel.replaymod.holders.AdvancedPosition;
|
|
||||||
import eu.crushedpixel.replaymod.registry.ReplayGuiRegistry;
|
|
||||||
import com.replaymod.core.utils.Restrictions;
|
import com.replaymod.core.utils.Restrictions;
|
||||||
|
import com.replaymod.replaystudio.util.Location;
|
||||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.embedded.EmbeddedChannel;
|
import io.netty.channel.embedded.EmbeddedChannel;
|
||||||
@@ -69,7 +68,7 @@ public class ReplayHandler {
|
|||||||
/**
|
/**
|
||||||
* The position at which the camera should be located after the next jump.
|
* The position at which the camera should be located after the next jump.
|
||||||
*/
|
*/
|
||||||
private AdvancedPosition targetCameraPosition;
|
private Location targetCameraPosition;
|
||||||
|
|
||||||
private UUID spectating;
|
private UUID spectating;
|
||||||
|
|
||||||
@@ -123,9 +122,6 @@ public class ReplayHandler {
|
|||||||
mc.timer.timerSpeed = 1;
|
mc.timer.timerSpeed = 1;
|
||||||
overlay.setVisible(false);
|
overlay.setVisible(false);
|
||||||
|
|
||||||
// These might have been hidden by the overlay, so we have to make sure they're visible again
|
|
||||||
ReplayGuiRegistry.show();
|
|
||||||
|
|
||||||
ReplayModReplay.instance.replayHandler = null;
|
ReplayModReplay.instance.replayHandler = null;
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().post(new ReplayCloseEvent.Post(this));
|
FMLCommonHandler.instance().bus().post(new ReplayCloseEvent.Post(this));
|
||||||
@@ -256,7 +252,7 @@ public class ReplayHandler {
|
|||||||
return spectating;
|
return spectating;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTargetPosition(AdvancedPosition pos) {
|
public void setTargetPosition(Location pos) {
|
||||||
targetCameraPosition = pos;
|
targetCameraPosition = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,8 +275,8 @@ public class ReplayHandler {
|
|||||||
if (retainCameraPosition) {
|
if (retainCameraPosition) {
|
||||||
CameraEntity cam = getCameraEntity();
|
CameraEntity cam = getCameraEntity();
|
||||||
if (cam != null) {
|
if (cam != null) {
|
||||||
targetCameraPosition = new AdvancedPosition(cam.posX, cam.posY, cam.posZ,
|
targetCameraPosition = new Location(cam.posX, cam.posY, cam.posZ,
|
||||||
cam.rotationPitch, cam.rotationYaw, cam.roll);
|
cam.rotationPitch, cam.rotationYaw);
|
||||||
} else {
|
} else {
|
||||||
targetCameraPosition = null;
|
targetCameraPosition = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ import com.google.common.util.concurrent.ListenableFutureTask;
|
|||||||
import com.replaymod.core.utils.Restrictions;
|
import com.replaymod.core.utils.Restrictions;
|
||||||
import com.replaymod.replay.camera.CameraEntity;
|
import com.replaymod.replay.camera.CameraEntity;
|
||||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||||
import eu.crushedpixel.replaymod.holders.PacketData;
|
import io.netty.buffer.ByteBuf;
|
||||||
import eu.crushedpixel.replaymod.settings.ReplaySettings;
|
import io.netty.buffer.Unpooled;
|
||||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
|
||||||
import io.netty.channel.ChannelHandler.Sharable;
|
import io.netty.channel.ChannelHandler.Sharable;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||||
@@ -17,9 +16,7 @@ import net.minecraft.client.gui.GuiDownloadTerrain;
|
|||||||
import net.minecraft.client.gui.GuiErrorScreen;
|
import net.minecraft.client.gui.GuiErrorScreen;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.network.EnumConnectionState;
|
import net.minecraft.network.*;
|
||||||
import net.minecraft.network.NetworkManager;
|
|
||||||
import net.minecraft.network.Packet;
|
|
||||||
import net.minecraft.network.play.server.*;
|
import net.minecraft.network.play.server.*;
|
||||||
import net.minecraft.util.IChatComponent;
|
import net.minecraft.util.IChatComponent;
|
||||||
import net.minecraft.world.EnumDifficulty;
|
import net.minecraft.world.EnumDifficulty;
|
||||||
@@ -253,7 +250,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
if (msg instanceof byte[]) {
|
if (msg instanceof byte[]) {
|
||||||
try {
|
try {
|
||||||
Packet p = ReplayFileIO.deserializePacket((byte[]) msg);
|
Packet p = deserializePacket((byte[]) msg);
|
||||||
|
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
p = processPacket(p);
|
p = processPacket(p);
|
||||||
@@ -299,6 +296,18 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Packet deserializePacket(byte[] bytes) throws IOException, IllegalAccessException, InstantiationException {
|
||||||
|
ByteBuf bb = Unpooled.wrappedBuffer(bytes);
|
||||||
|
PacketBuffer pb = new PacketBuffer(bb);
|
||||||
|
|
||||||
|
int i = pb.readVarIntFromBuffer();
|
||||||
|
|
||||||
|
Packet p = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.CLIENTBOUND, i);
|
||||||
|
p.readPacketData(pb);
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process a packet and return the result.
|
* Process a packet and return the result.
|
||||||
* @param p The packet to process
|
* @param p The packet to process
|
||||||
@@ -453,7 +462,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (p instanceof S02PacketChat) {
|
if (p instanceof S02PacketChat) {
|
||||||
if (ReplaySettings.ReplayOptions.showChat.getValue() != Boolean.TRUE) {
|
if (!ReplayModReplay.instance.getCore().getSettingsRegistry().get(Setting.SHOW_CHAT)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -558,10 +567,10 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
// Read the next packet if we don't already have one
|
// Read the next packet if we don't already have one
|
||||||
if (nextPacket == null) {
|
if (nextPacket == null) {
|
||||||
nextPacket = ReplayFileIO.readPacketData(dis);
|
nextPacket = new PacketData(dis);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nextTimeStamp = nextPacket.getTimestamp();
|
int nextTimeStamp = nextPacket.timestamp;
|
||||||
|
|
||||||
// If we aren't jumping and the world has already been loaded (no dirt-screens) then wait
|
// If we aren't jumping and the world has already been loaded (no dirt-screens) then wait
|
||||||
// the required amount to get proper packet timing
|
// the required amount to get proper packet timing
|
||||||
@@ -578,7 +587,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process packet
|
// Process packet
|
||||||
channelRead(ctx, nextPacket.getByteArray());
|
channelRead(ctx, nextPacket.bytes);
|
||||||
nextPacket = null;
|
nextPacket = null;
|
||||||
|
|
||||||
lastTimeStamp = nextTimeStamp;
|
lastTimeStamp = nextTimeStamp;
|
||||||
@@ -725,10 +734,10 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
nextPacket = null;
|
nextPacket = null;
|
||||||
} else {
|
} else {
|
||||||
// Otherwise read one from the input stream
|
// Otherwise read one from the input stream
|
||||||
pd = ReplayFileIO.readPacketData(dis);
|
pd = new PacketData(dis);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nextTimeStamp = pd.getTimestamp();
|
int nextTimeStamp = pd.timestamp;
|
||||||
if (nextTimeStamp > timestamp) {
|
if (nextTimeStamp > timestamp) {
|
||||||
// We are done sending all packets
|
// We are done sending all packets
|
||||||
nextPacket = pd;
|
nextPacket = pd;
|
||||||
@@ -736,7 +745,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process packet
|
// Process packet
|
||||||
channelRead(ctx, pd.getByteArray());
|
channelRead(ctx, pd.bytes);
|
||||||
|
|
||||||
// Store last timestamp
|
// Store last timestamp
|
||||||
lastTimeStamp = nextTimeStamp;
|
lastTimeStamp = nextTimeStamp;
|
||||||
@@ -823,4 +832,15 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class PacketData {
|
||||||
|
private final int timestamp;
|
||||||
|
private final byte[] bytes;
|
||||||
|
|
||||||
|
public PacketData(DataInputStream in) throws IOException {
|
||||||
|
timestamp = in.readInt();
|
||||||
|
bytes = new byte[in.readInt()];
|
||||||
|
in.readFully(bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ package com.replaymod.replay;
|
|||||||
import com.replaymod.core.SettingsRegistry;
|
import com.replaymod.core.SettingsRegistry;
|
||||||
|
|
||||||
public final class Setting<T> extends SettingsRegistry.SettingKeys<T> {
|
public final class Setting<T> extends SettingsRegistry.SettingKeys<T> {
|
||||||
public static final Setting<Boolean> RECORD_SINGLEPLAYER = make("recordSingleplayer", "recordsingleplayer", true);
|
public static final Setting<Boolean> SHOW_CHAT = make("showChat", "showchat", true);
|
||||||
public static final Setting<Boolean> RECORD_SERVER = make("recordServer", "recordserver", true);
|
|
||||||
public static final Setting<Boolean> INDICATOR = make("indicator", "indicator", true);
|
|
||||||
public static final SettingsRegistry.MultipleChoiceSettingKeys<String> CAMERA =
|
public static final SettingsRegistry.MultipleChoiceSettingKeys<String> CAMERA =
|
||||||
new SettingsRegistry.MultipleChoiceSettingKeys<>(
|
new SettingsRegistry.MultipleChoiceSettingKeys<>(
|
||||||
"replay", "camera", "replaymod.gui.settings.camera", "replaymod.camera.classic");
|
"replay", "camera", "replaymod.gui.settings.camera", "replaymod.camera.classic");
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.replaymod.replay.camera;
|
package com.replaymod.replay.camera;
|
||||||
|
|
||||||
import com.replaymod.core.events.SettingsChangedEvent;
|
import com.replaymod.core.events.SettingsChangedEvent;
|
||||||
|
import com.replaymod.core.utils.Utils;
|
||||||
import com.replaymod.replay.ReplayModReplay;
|
import com.replaymod.replay.ReplayModReplay;
|
||||||
import com.replaymod.replay.Setting;
|
import com.replaymod.replay.Setting;
|
||||||
import eu.crushedpixel.replaymod.holders.AdvancedPosition;
|
import com.replaymod.replaystudio.util.Location;
|
||||||
import eu.crushedpixel.replaymod.utils.SkinProvider;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
@@ -107,8 +107,8 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
* Sets the camera position and rotation to that of the specified AdvancedPosition
|
* Sets the camera position and rotation to that of the specified AdvancedPosition
|
||||||
* @param pos The position and rotation to set
|
* @param pos The position and rotation to set
|
||||||
*/
|
*/
|
||||||
public void setCameraPosRot(AdvancedPosition pos) {
|
public void setCameraPosRot(Location pos) {
|
||||||
setCameraRotation((float) pos.getYaw(), (float) pos.getPitch(), (float) pos.getRoll());
|
setCameraRotation(pos.getYaw(), pos.getPitch(), roll);
|
||||||
setCameraPosition(pos.getX(), pos.getY(), pos.getZ());
|
setCameraPosition(pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +238,7 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
public ResourceLocation getLocationSkin() {
|
public ResourceLocation getLocationSkin() {
|
||||||
Entity view = mc.getRenderViewEntity();
|
Entity view = mc.getRenderViewEntity();
|
||||||
if (view != this && view instanceof EntityPlayer) {
|
if (view != this && view instanceof EntityPlayer) {
|
||||||
return SkinProvider.getResourceLocationForPlayerUUID(view.getUniqueID());
|
return Utils.getResourceLocationForPlayerUUID(view.getUniqueID());
|
||||||
}
|
}
|
||||||
return super.getLocationSkin();
|
return super.getLocationSkin();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ package com.replaymod.replay.gui.overlay;
|
|||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
import com.replaymod.replay.ReplayHandler;
|
import com.replaymod.replay.ReplayHandler;
|
||||||
|
import com.replaymod.replaystudio.util.Location;
|
||||||
import de.johni0702.minecraft.gui.GuiRenderer;
|
import de.johni0702.minecraft.gui.GuiRenderer;
|
||||||
import de.johni0702.minecraft.gui.RenderInfo;
|
import de.johni0702.minecraft.gui.RenderInfo;
|
||||||
import de.johni0702.minecraft.gui.element.advanced.AbstractGuiTimeline;
|
import de.johni0702.minecraft.gui.element.advanced.AbstractGuiTimeline;
|
||||||
import de.johni0702.minecraft.gui.function.Draggable;
|
import de.johni0702.minecraft.gui.function.Draggable;
|
||||||
import com.replaymod.replaystudio.data.Marker;
|
import com.replaymod.replaystudio.data.Marker;
|
||||||
import eu.crushedpixel.replaymod.holders.AdvancedPosition;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import org.lwjgl.util.Point;
|
import org.lwjgl.util.Point;
|
||||||
@@ -126,9 +126,9 @@ public class GuiMarkerTimeline extends AbstractGuiTimeline<GuiMarkerTimeline> im
|
|||||||
lastClickTime = now;
|
lastClickTime = now;
|
||||||
} else if (button == 1) { // Right click
|
} else if (button == 1) { // Right click
|
||||||
selectedMarker = null;
|
selectedMarker = null;
|
||||||
replayHandler.setTargetPosition(new AdvancedPosition(
|
replayHandler.setTargetPosition(new Location(
|
||||||
marker.getX(), marker.getY(), marker.getZ(),
|
marker.getX(), marker.getY(), marker.getZ(),
|
||||||
marker.getPitch(), marker.getYaw(), marker.getRoll()
|
marker.getPitch(), marker.getYaw()
|
||||||
));
|
));
|
||||||
replayHandler.doJump(marker.getTime(), false);
|
replayHandler.doJump(marker.getTime(), false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,7 @@ import com.replaymod.replaystudio.replay.ReplayFile;
|
|||||||
import com.replaymod.replaystudio.replay.ReplayMetaData;
|
import com.replaymod.replaystudio.replay.ReplayMetaData;
|
||||||
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
||||||
import com.replaymod.replaystudio.studio.ReplayStudio;
|
import com.replaymod.replaystudio.studio.ReplayStudio;
|
||||||
import eu.crushedpixel.replaymod.registry.ResourceHelper;
|
import com.replaymod.core.utils.Utils;
|
||||||
import eu.crushedpixel.replaymod.utils.DurationUtils;
|
|
||||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
|
||||||
import net.minecraft.client.gui.GuiErrorScreen;
|
import net.minecraft.client.gui.GuiErrorScreen;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.util.Util;
|
import net.minecraft.util.Util;
|
||||||
@@ -162,11 +160,9 @@ public class GuiReplayViewer extends GuiScreen {
|
|||||||
popup.getYesButton().onClick();
|
popup.getYesButton().onClick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).onTextChanged(new Consumer<String>() {
|
}).onTextChanged(obj -> {
|
||||||
@Override
|
popup.getYesButton().setEnabled(!nameField.getText().isEmpty()
|
||||||
public void consume(String obj) {
|
&& !new File(file.getParentFile(), nameField.getText() + ".mcpr").exists());
|
||||||
popup.getYesButton().setEnabled(!nameField.getText().isEmpty());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
Futures.addCallback(popup.getFuture(), new FutureCallback<Boolean>() {
|
Futures.addCallback(popup.getFuture(), new FutureCallback<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -176,11 +172,9 @@ public class GuiReplayViewer extends GuiScreen {
|
|||||||
String name = nameField.getText().trim().replace("[^a-zA-Z0-9\\.\\- ]", "_");
|
String name = nameField.getText().trim().replace("[^a-zA-Z0-9\\.\\- ]", "_");
|
||||||
// This file is what they want
|
// This file is what they want
|
||||||
File targetFile = new File(file.getParentFile(), name + ".mcpr");
|
File targetFile = new File(file.getParentFile(), name + ".mcpr");
|
||||||
// But if it's already used, this is what they get
|
|
||||||
File renamed = ReplayFileIO.getNextFreeFile(targetFile);
|
|
||||||
try {
|
try {
|
||||||
// Finally, try to move it
|
// Finally, try to move it
|
||||||
FileUtils.moveFile(file, renamed);
|
FileUtils.moveFile(file, targetFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// We failed (might also be their OS)
|
// We failed (might also be their OS)
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -268,7 +262,7 @@ public class GuiReplayViewer extends GuiScreen {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private final GuiImage defaultThumbnail = new GuiImage().setTexture(ResourceHelper.getDefaultThumbnail());
|
private final GuiImage defaultThumbnail = new GuiImage().setTexture(Utils.DEFAULT_THUMBNAIL);
|
||||||
public class GuiReplayEntry extends AbstractGuiContainer<GuiReplayEntry> implements Comparable<GuiReplayEntry> {
|
public class GuiReplayEntry extends AbstractGuiContainer<GuiReplayEntry> implements Comparable<GuiReplayEntry> {
|
||||||
public final File file;
|
public final File file;
|
||||||
public final GuiLabel name = new GuiLabel();
|
public final GuiLabel name = new GuiLabel();
|
||||||
@@ -311,7 +305,7 @@ public class GuiReplayViewer extends GuiScreen {
|
|||||||
} else {
|
} else {
|
||||||
thumbnail = new GuiImage(this).setTexture(thumbImage).setSize(30 * 16 / 9, 30);
|
thumbnail = new GuiImage(this).setTexture(thumbImage).setSize(30 * 16 / 9, 30);
|
||||||
}
|
}
|
||||||
duration.setText(DurationUtils.convertSecondsToShortString(metaData.getDuration() / 1000));
|
duration.setText(Utils.convertSecondsToShortString(metaData.getDuration() / 1000));
|
||||||
addElements(null, durationPanel);
|
addElements(null, durationPanel);
|
||||||
|
|
||||||
setLayout(new CustomLayout<GuiReplayEntry>() {
|
setLayout(new CustomLayout<GuiReplayEntry>() {
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.assets;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class AssetFileUtils {
|
|
||||||
|
|
||||||
//make sure to update these methods when adding new implementations of the ReplayAsset interface
|
|
||||||
|
|
||||||
public static String[] fileExtensionsForAssetClass(Class<? extends ReplayAsset> clazz) {
|
|
||||||
if(clazz == ReplayImageAsset.class) {
|
|
||||||
return ImageIO.getReaderFileSuffixes();
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new UnsupportedOperationException("Unknown replay asset type: " + clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] getAllAvailableExtensions() {
|
|
||||||
List<String> extensions = new ArrayList<String>();
|
|
||||||
|
|
||||||
extensions.addAll(Arrays.asList(fileExtensionsForAssetClass(ReplayImageAsset.class)));
|
|
||||||
|
|
||||||
return extensions.toArray(new String[extensions.size()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.assets;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@EqualsAndHashCode
|
|
||||||
public class AssetRepository {
|
|
||||||
|
|
||||||
private final Map<UUID, ReplayAsset> replayAssets;
|
|
||||||
|
|
||||||
public AssetRepository() {
|
|
||||||
replayAssets = new HashMap<UUID, ReplayAsset>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public AssetRepository(AssetRepository toCopy) {
|
|
||||||
HashMap<UUID, ReplayAsset> newAssetList = new HashMap<UUID, ReplayAsset>();
|
|
||||||
|
|
||||||
for(Map.Entry<UUID, ReplayAsset> e : toCopy.replayAssets.entrySet()) {
|
|
||||||
newAssetList.put(e.getKey(), e.getValue().copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.replayAssets = newAssetList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReplayAsset addAsset(String assetFileName, InputStream inputStream) throws IOException {
|
|
||||||
return addAsset(assetFileName, inputStream, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReplayAsset addAsset(String assetFileName, InputStream inputStream, UUID uuid) throws IOException {
|
|
||||||
|
|
||||||
if(uuid == null) {
|
|
||||||
uuid = UUID.randomUUID();
|
|
||||||
} else {
|
|
||||||
assetFileName = assetFileName.replace(uuid.toString()+"_", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
ReplayAsset asset = assetFromFileName(assetFileName);
|
|
||||||
|
|
||||||
asset.loadFromStream(inputStream);
|
|
||||||
|
|
||||||
replayAssets.put(uuid, asset);
|
|
||||||
|
|
||||||
return asset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeAsset(ReplayAsset asset) {
|
|
||||||
for(Map.Entry<UUID, ReplayAsset> e :
|
|
||||||
new HashSet<Map.Entry<UUID, ReplayAsset>>(replayAssets.entrySet()))
|
|
||||||
if(e.getValue().equals(asset))
|
|
||||||
replayAssets.remove(e.getKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveAssets() {
|
|
||||||
// TODO
|
|
||||||
// try {
|
|
||||||
// ReplayFile replayFile = ReplayHandler.getReplayFile();
|
|
||||||
//
|
|
||||||
// for (ReplayAssetEntry entry : replayFile.getAssets()) {
|
|
||||||
// if (!replayAssets.containsKey(entry.getUuid())) {
|
|
||||||
// replayFile.removeAsset(entry.getUuid());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for(Map.Entry<UUID, ReplayAsset> e : replayAssets.entrySet()) {
|
|
||||||
// UUID uuid = e.getKey();
|
|
||||||
// ReplayAsset asset = e.getValue();
|
|
||||||
// String extension = asset.getSavedFileExtension();
|
|
||||||
// String name = asset.getAssetName();
|
|
||||||
//
|
|
||||||
// try (OutputStream out = replayFile.writeAsset(new ReplayAssetEntry(uuid, extension, name))) {
|
|
||||||
// asset.writeToStream(out);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch(IOException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ReplayAsset assetFromFileName(String filename) {
|
|
||||||
String baseName = FilenameUtils.getBaseName(filename);
|
|
||||||
String extension = FilenameUtils.getExtension(filename);
|
|
||||||
|
|
||||||
if(ArrayUtils.contains(AssetFileUtils.fileExtensionsForAssetClass(ReplayImageAsset.class), extension)) {
|
|
||||||
return new ReplayImageAsset(baseName);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new UnsupportedOperationException("Can't create ReplayAsset from File "+filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ReplayAsset> getCopyOfReplayAssets() {
|
|
||||||
return new ArrayList<ReplayAsset>(replayAssets.values());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReplayAsset getAssetByUUID(UUID uuid) {
|
|
||||||
return replayAssets.get(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getUUIDForAsset(ReplayAsset asset) {
|
|
||||||
for(Map.Entry<UUID, ReplayAsset> e : replayAssets.entrySet()) {
|
|
||||||
if(e.getValue().equals(asset)) {
|
|
||||||
return e.getKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.assets;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.holders.GuiEntryListEntry;
|
|
||||||
import eu.crushedpixel.replaymod.holders.Transformations;
|
|
||||||
import eu.crushedpixel.replaymod.registry.ResourceHelper;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@EqualsAndHashCode
|
|
||||||
public class CustomImageObject implements GuiEntryListEntry {
|
|
||||||
|
|
||||||
public CustomImageObject(String name, UUID assetUUID) throws IOException {
|
|
||||||
this.name = name;
|
|
||||||
|
|
||||||
setLinkedAsset(assetUUID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CustomImageObject copy() throws IOException {
|
|
||||||
CustomImageObject copy = new CustomImageObject(this.name, this.getLinkedAsset());
|
|
||||||
|
|
||||||
copy.textureWidth = this.textureWidth;
|
|
||||||
copy.textureHeight = this.textureHeight;
|
|
||||||
|
|
||||||
copy.width = width;
|
|
||||||
copy.height = height;
|
|
||||||
|
|
||||||
copy.transformations = transformations;
|
|
||||||
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter @Setter private String name;
|
|
||||||
@Getter private UUID linkedAsset;
|
|
||||||
|
|
||||||
@Getter @Setter private float width, height;
|
|
||||||
|
|
||||||
private transient ResourceLocation resourceLocation;
|
|
||||||
private transient DynamicTexture dynamicTexture;
|
|
||||||
|
|
||||||
@Getter private float textureWidth, textureHeight;
|
|
||||||
|
|
||||||
@Getter private Transformations transformations = new Transformations();
|
|
||||||
|
|
||||||
public void setLinkedAsset(UUID assetUUID) throws IOException {
|
|
||||||
if(assetUUID == null) return;
|
|
||||||
|
|
||||||
//if no asset repository available, simply accept the UUID and it will load the image later
|
|
||||||
//when calling getResourceLocation for the first time
|
|
||||||
// TODO
|
|
||||||
// if(ReplayHandler.getAssetRepository() == null) {
|
|
||||||
// this.linkedAsset = assetUUID;
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ReplayAsset asset = ReplayHandler.getAssetRepository().getAssetByUUID(assetUUID);
|
|
||||||
//
|
|
||||||
// if(asset instanceof ReplayImageAsset) {
|
|
||||||
// this.linkedAsset = assetUUID;
|
|
||||||
// setImage(((ReplayImageAsset)asset).getObject());
|
|
||||||
// } else if(asset != null) {
|
|
||||||
// throw new UnsupportedOperationException("A CustomImageObject requires a ReplayImageAsset");
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setImage(final BufferedImage bufferedImage) throws IOException {
|
|
||||||
|
|
||||||
this.textureWidth = bufferedImage.getWidth();
|
|
||||||
this.textureHeight = bufferedImage.getHeight();
|
|
||||||
|
|
||||||
float w;
|
|
||||||
float h;
|
|
||||||
|
|
||||||
if(bufferedImage.getWidth() > bufferedImage.getHeight()) {
|
|
||||||
w = 1;
|
|
||||||
h = (bufferedImage.getHeight()/(float)bufferedImage.getWidth());
|
|
||||||
} else {
|
|
||||||
w = (bufferedImage.getWidth()/(float)bufferedImage.getHeight());
|
|
||||||
h = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setWidth(w);
|
|
||||||
this.setHeight(h);
|
|
||||||
|
|
||||||
resourceLocation = new ResourceLocation(UUID.randomUUID().toString()+linkedAsset.toString());
|
|
||||||
|
|
||||||
Minecraft.getMinecraft().addScheduledTask(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
dynamicTexture = new DynamicTexture(bufferedImage);
|
|
||||||
|
|
||||||
ResourceHelper.freeResource(resourceLocation);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceLocation getResourceLocation() {
|
|
||||||
if(resourceLocation == null) {
|
|
||||||
// TODO
|
|
||||||
// ReplayAsset asset = ReplayHandler.getAssetRepository().getAssetByUUID(linkedAsset);
|
|
||||||
// if(asset instanceof ReplayImageAsset) {
|
|
||||||
// try {
|
|
||||||
// setImage(((ReplayImageAsset) asset).getObject());
|
|
||||||
// } catch(Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!ResourceHelper.isRegistered(resourceLocation)) {
|
|
||||||
ResourceHelper.registerResource(resourceLocation);
|
|
||||||
Minecraft.getMinecraft().getTextureManager().loadTexture(resourceLocation, dynamicTexture);
|
|
||||||
dynamicTexture.updateDynamicTexture();
|
|
||||||
}
|
|
||||||
|
|
||||||
return resourceLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayString() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.assets;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CustomObjectRepository {
|
|
||||||
|
|
||||||
public CustomObjectRepository() {
|
|
||||||
this.objects = new ArrayList<CustomImageObject>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setObjects(List<CustomImageObject> objects) {
|
|
||||||
this.objects = new ArrayList<CustomImageObject>(objects);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private ArrayList<CustomImageObject> objects;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.assets;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.holders.GuiEntryListEntry;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
|
|
||||||
public interface ReplayAsset<T> extends GuiEntryListEntry {
|
|
||||||
|
|
||||||
String getSavedFileExtension();
|
|
||||||
|
|
||||||
void loadFromStream(InputStream inputStream) throws IOException;
|
|
||||||
void writeToStream(OutputStream outputStream) throws IOException;
|
|
||||||
|
|
||||||
void drawToScreen(int x, int y, int maxWidth, int maxHeight);
|
|
||||||
|
|
||||||
String getAssetName();
|
|
||||||
void setAssetName(String name);
|
|
||||||
|
|
||||||
ReplayAsset<T> copy();
|
|
||||||
|
|
||||||
T getObject();
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.assets;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.registry.ResourceHelper;
|
|
||||||
import eu.crushedpixel.replaymod.utils.BoundingUtils;
|
|
||||||
import eu.crushedpixel.replaymod.utils.BufferedImageUtils;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.Gui;
|
|
||||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import org.lwjgl.util.Dimension;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(of={"name", "bufferedImageHashCode"})
|
|
||||||
public class ReplayImageAsset implements ReplayAsset<BufferedImage> {
|
|
||||||
|
|
||||||
private final Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
|
|
||||||
private BufferedImage object;
|
|
||||||
private int bufferedImageHashCode;
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ReplayImageAsset copy() {
|
|
||||||
ReplayImageAsset newReplay = new ReplayImageAsset(name);
|
|
||||||
newReplay.object = object;
|
|
||||||
newReplay.bufferedImageHashCode = bufferedImageHashCode;
|
|
||||||
|
|
||||||
return newReplay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReplayImageAsset(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getAssetName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAssetName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayString() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSavedFileExtension() {
|
|
||||||
return "png";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadFromStream(InputStream inputStream) throws IOException {
|
|
||||||
this.object = ImageIO.read(inputStream);
|
|
||||||
this.bufferedImageHashCode = BufferedImageUtils.hashCode(object);
|
|
||||||
ResourceHelper.freeResource(previewResource);
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
// for(CustomImageObject object : ReplayHandler.getCustomImageObjects()) {
|
|
||||||
// if(object.getLinkedAsset() != null && object.getLinkedAsset().equals(ReplayHandler.getAssetRepository().getUUIDForAsset(this))) {
|
|
||||||
// object.setImage(this.object);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToStream(OutputStream outputStream) throws IOException {
|
|
||||||
ImageIO.write(object, "png", outputStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BufferedImage getObject() {
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResourceLocation previewResource = new ResourceLocation("/asset/"+ UUID.randomUUID().toString());
|
|
||||||
private DynamicTexture dynamicTexture;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawToScreen(int x, int y, int maxWidth, int maxHeight) {
|
|
||||||
if(object == null) return;
|
|
||||||
if(!ResourceHelper.isRegistered(previewResource) || dynamicTexture == null) {
|
|
||||||
dynamicTexture = new DynamicTexture(object);
|
|
||||||
mc.getTextureManager().loadTexture(previewResource, dynamicTexture);
|
|
||||||
ResourceHelper.registerResource(previewResource);
|
|
||||||
}
|
|
||||||
|
|
||||||
mc.renderEngine.bindTexture(previewResource);
|
|
||||||
|
|
||||||
Dimension dimension = BoundingUtils.fitIntoBounds(new Dimension(object.getWidth(), object.getHeight()), new Dimension(maxWidth, maxHeight));
|
|
||||||
|
|
||||||
Gui.drawScaledCustomSizeModalRect(x, y, 0, 0, object.getWidth(), object.getHeight(), dimension.getWidth(), dimension.getHeight(), object.getWidth(), object.getHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void finalize() throws Throwable {
|
|
||||||
ResourceHelper.freeResource(previewResource);
|
|
||||||
super.finalize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.chat;
|
|
||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraft.util.*;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
import java.util.Queue;
|
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class ChatMessageHandler {
|
|
||||||
|
|
||||||
private static final IChatComponent prefix;
|
|
||||||
|
|
||||||
static {
|
|
||||||
//results in "§8[§6Replay Mod§8]§r "
|
|
||||||
|
|
||||||
ChatStyle dark_gray = new ChatStyle().setColor(EnumChatFormatting.DARK_GRAY);
|
|
||||||
ChatStyle gold = new ChatStyle().setColor(EnumChatFormatting.GOLD);
|
|
||||||
|
|
||||||
prefix = new ChatComponentText("[").setChatStyle(dark_gray)
|
|
||||||
.appendSibling(new ChatComponentTranslation("replaymod.title").setChatStyle(gold))
|
|
||||||
.appendSibling(new ChatComponentText("] "));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private boolean active = true;
|
|
||||||
private Queue<IChatComponent> requests = new ConcurrentLinkedQueue<IChatComponent>();
|
|
||||||
private EntityPlayerSP player = null;
|
|
||||||
public Thread t = new Thread(new Runnable() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
while(!Thread.currentThread().isInterrupted()) {
|
|
||||||
while(active) {
|
|
||||||
try {
|
|
||||||
while(player == null) {
|
|
||||||
Thread.sleep(100);
|
|
||||||
player = Minecraft.getMinecraft().thePlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
IChatComponent message = requests.poll();
|
|
||||||
if (message != null) {
|
|
||||||
player.addChatComponentMessage(message);
|
|
||||||
}
|
|
||||||
Thread.sleep(100);
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch(InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, "replaymod-chat-message-handler");
|
|
||||||
|
|
||||||
public ChatMessageHandler() {
|
|
||||||
t.setDaemon(true);
|
|
||||||
t.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addLocalizedChatMessage(String message, ChatMessageType type, Object... options) {
|
|
||||||
message = I18n.format(message, options);
|
|
||||||
if(ReplayMod.replaySettings.isShowNotifications()) {
|
|
||||||
|
|
||||||
ChatComponentText cct = new ChatComponentText(message);
|
|
||||||
cct.setChatStyle(type.getChatStyle());
|
|
||||||
|
|
||||||
requests.add(prefix.createCopy().appendSibling(cct));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stop() {
|
|
||||||
active = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initialize() {
|
|
||||||
active = true;
|
|
||||||
requests.clear();
|
|
||||||
if(!ReplayMod.replaySettings.isShowNotifications()) {
|
|
||||||
System.out.println("Chat messages are disabled");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ChatMessageType {
|
|
||||||
INFORMATION(new ChatStyle().setColor(EnumChatFormatting.DARK_GREEN)), WARNING(new ChatStyle().setColor(EnumChatFormatting.RED));
|
|
||||||
|
|
||||||
private ChatStyle chatStyle;
|
|
||||||
|
|
||||||
public ChatStyle getChatStyle() {
|
|
||||||
return chatStyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatMessageType(ChatStyle chatStyle) {
|
|
||||||
this.chatStyle = chatStyle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.events;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.holders.TimestampValue;
|
|
||||||
import eu.crushedpixel.replaymod.interpolation.AdvancedPositionKeyframeList;
|
|
||||||
import eu.crushedpixel.replaymod.interpolation.KeyframeList;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper=true)
|
|
||||||
public class KeyframesModifyEvent extends Event {
|
|
||||||
|
|
||||||
private AdvancedPositionKeyframeList positionKeyframes;
|
|
||||||
private KeyframeList<TimestampValue> timeKeyframes;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,168 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.events.handlers;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraft.client.settings.GameSettings;
|
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
|
||||||
import net.minecraft.crash.CrashReport;
|
|
||||||
import net.minecraft.util.ReportedException;
|
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
import org.lwjgl.input.Mouse;
|
|
||||||
|
|
||||||
public class MinecraftTicker {
|
|
||||||
|
|
||||||
public static void runMouseKeyboardTick(Minecraft mc) {
|
|
||||||
// TODO
|
|
||||||
// ReplayMod.mouseInputHandler.mouseEvent(new MouseEvent());
|
|
||||||
if(mc.thePlayer == null) return;
|
|
||||||
try {
|
|
||||||
mc.mcProfiler.endStartSection("mouse");
|
|
||||||
int i;
|
|
||||||
while(Mouse.next()) {
|
|
||||||
i = Mouse.getEventButton();
|
|
||||||
KeyBinding.setKeyBindState(i - 100, Mouse.getEventButtonState());
|
|
||||||
|
|
||||||
long k = Minecraft.getSystemTime() - mc.systemTime;
|
|
||||||
|
|
||||||
if(k <= 200L) {
|
|
||||||
if(mc.currentScreen == null) {
|
|
||||||
if(!mc.inGameHasFocus && Mouse.getEventButtonState()) {
|
|
||||||
mc.setIngameFocus();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mc.currentScreen.handleMouseInput();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
net.minecraftforge.fml.common.FMLCommonHandler.instance().fireMouseInput();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mc.leftClickCounter > 0) {
|
|
||||||
mc.leftClickCounter--;
|
|
||||||
}
|
|
||||||
mc.mcProfiler.endStartSection("keyboard");
|
|
||||||
|
|
||||||
while(Keyboard.next()) {
|
|
||||||
i = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();
|
|
||||||
KeyBinding.setKeyBindState(i, Keyboard.getEventKeyState());
|
|
||||||
|
|
||||||
if(Keyboard.getEventKeyState()) {
|
|
||||||
KeyBinding.onTick(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mc.debugCrashKeyPressTime > 0L) {
|
|
||||||
if(Minecraft.getSystemTime() - mc.debugCrashKeyPressTime >= 6000L) {
|
|
||||||
throw new ReportedException(new CrashReport("Manually triggered debug crash", new Throwable()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!Keyboard.isKeyDown(46) || !Keyboard.isKeyDown(61)) {
|
|
||||||
mc.debugCrashKeyPressTime = -1;
|
|
||||||
}
|
|
||||||
} else if(Keyboard.isKeyDown(46) && Keyboard.isKeyDown(61)) {
|
|
||||||
mc.debugCrashKeyPressTime = Minecraft.getSystemTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mc.currentScreen == null) {
|
|
||||||
mc.dispatchKeypresses();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Keyboard.getEventKeyState()) {
|
|
||||||
if(i == 62 && mc.entityRenderer != null) {
|
|
||||||
mc.entityRenderer.switchUseShader();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mc.currentScreen != null) {
|
|
||||||
mc.currentScreen.handleKeyboardInput();
|
|
||||||
} else {
|
|
||||||
if(i == 1) {
|
|
||||||
mc.displayInGameMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == 32 && Keyboard.isKeyDown(61) && mc.ingameGUI != null) {
|
|
||||||
mc.ingameGUI.getChatGUI().clearChatMessages();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == 31 && Keyboard.isKeyDown(61)) {
|
|
||||||
mc.refreshResources();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == 20 && Keyboard.isKeyDown(61)) {
|
|
||||||
mc.refreshResources();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == 33 && Keyboard.isKeyDown(61)) {
|
|
||||||
boolean flag1 = Keyboard.isKeyDown(42) | Keyboard.isKeyDown(54);
|
|
||||||
mc.gameSettings.setOptionValue(GameSettings.Options.RENDER_DISTANCE, flag1 ? -1 : 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == 30 && Keyboard.isKeyDown(61)) {
|
|
||||||
mc.renderGlobal.loadRenderers();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == 35 && Keyboard.isKeyDown(61)) {
|
|
||||||
mc.gameSettings.advancedItemTooltips = !mc.gameSettings.advancedItemTooltips;
|
|
||||||
mc.gameSettings.saveOptions();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == 48 && Keyboard.isKeyDown(61)) {
|
|
||||||
mc.getRenderManager().setDebugBoundingBox(!mc.getRenderManager().isDebugBoundingBox());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == 25 && Keyboard.isKeyDown(61)) {
|
|
||||||
mc.gameSettings.pauseOnLostFocus = !mc.gameSettings.pauseOnLostFocus;
|
|
||||||
mc.gameSettings.saveOptions();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == 59) {
|
|
||||||
mc.gameSettings.hideGUI = !mc.gameSettings.hideGUI;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == 61) {
|
|
||||||
mc.gameSettings.showDebugInfo = !mc.gameSettings.showDebugInfo;
|
|
||||||
mc.gameSettings.showDebugProfilerChart = GuiScreen.isShiftKeyDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mc.gameSettings.keyBindTogglePerspective.isPressed()) {
|
|
||||||
++mc.gameSettings.thirdPersonView;
|
|
||||||
|
|
||||||
if(mc.gameSettings.thirdPersonView > 2) {
|
|
||||||
mc.gameSettings.thirdPersonView = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mc.entityRenderer != null) {
|
|
||||||
if (mc.gameSettings.thirdPersonView == 0) {
|
|
||||||
mc.entityRenderer.loadEntityShader(mc.getRenderViewEntity());
|
|
||||||
} else if (mc.gameSettings.thirdPersonView == 1) {
|
|
||||||
mc.entityRenderer.loadEntityShader(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mc.gameSettings.keyBindSmoothCamera.isPressed()) {
|
|
||||||
mc.gameSettings.smoothCamera = !mc.gameSettings.smoothCamera;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mc.gameSettings.showDebugInfo && mc.gameSettings.showDebugProfilerChart) {
|
|
||||||
if(i == 11) {
|
|
||||||
mc.updateDebugProfilerName(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int l = 0; l < 9; ++l) {
|
|
||||||
if(i == 2 + l) {
|
|
||||||
mc.updateDebugProfilerName(l + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
net.minecraftforge.fml.common.FMLCommonHandler.instance().fireKeyInput();
|
|
||||||
}
|
|
||||||
|
|
||||||
mc.systemTime = Minecraft.getSystemTime();
|
|
||||||
} catch (ReportedException e) {
|
|
||||||
throw e;
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.events.handlers;
|
|
||||||
|
|
||||||
public class MouseInputHandler {
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
// private final Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
// private boolean rightDown = false;
|
|
||||||
// private boolean leftDown = false;
|
|
||||||
//
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public void mouseEvent(MouseEvent event) {
|
|
||||||
// if(!ReplayHandler.isInReplay()) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(event.dwheel != 0 && mc.currentScreen == null) {
|
|
||||||
// boolean increase = event.dwheel > 0;
|
|
||||||
// CameraEntity.modifyCameraSpeed(increase);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(Mouse.isButtonDown(0)) {
|
|
||||||
// if(!leftDown) {
|
|
||||||
// leftDown = true;
|
|
||||||
// if(mc.pointedEntity != null && ReplayHandler.isCameraView() && mc.currentScreen == null) {
|
|
||||||
// if(SpectatingHandler.canSpectate(mc.pointedEntity))
|
|
||||||
// ReplayHandler.spectateEntity(mc.pointedEntity);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// leftDown = false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(Mouse.isButtonDown(1)) {
|
|
||||||
// if(!rightDown) {
|
|
||||||
// rightDown = true;
|
|
||||||
// if(mc.pointedEntity != null && ReplayHandler.isCameraView() && mc.currentScreen == null) {
|
|
||||||
// if(SpectatingHandler.canSpectate(mc.pointedEntity))
|
|
||||||
// ReplayHandler.spectateEntity(mc.pointedEntity);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// rightDown = false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.events.handlers;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraftforge.client.event.MouseEvent;
|
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
|
||||||
|
|
||||||
public class TickAndRenderListener {
|
|
||||||
|
|
||||||
private static Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
|
|
||||||
private static int requestScreenshot = 0;
|
|
||||||
|
|
||||||
public static void requestScreenshot() {
|
|
||||||
if(requestScreenshot == 0) requestScreenshot = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void finishScreenshot() {
|
|
||||||
requestScreenshot = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onRenderWorld(RenderWorldLastEvent event) throws Exception {
|
|
||||||
// TODO
|
|
||||||
// if(!ReplayHandler.isInReplay()) return; //If not in Replay, cancel
|
|
||||||
// if (ReplayProcess.isVideoRecording()) return; // If recording, cancel
|
|
||||||
//
|
|
||||||
// if(requestScreenshot == 1) {
|
|
||||||
// mc.addScheduledTask(new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// ReplayMod.chatMessageHandler.addLocalizedChatMessage("replaymod.chat.savingthumb", ChatMessageHandler.ChatMessageType.INFORMATION);
|
|
||||||
// ReplayScreenshot.prepareScreenshot();
|
|
||||||
// requestScreenshot = 2;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// } else if(requestScreenshot == 2) {
|
|
||||||
// mc.addScheduledTask(new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// ReplayScreenshot.saveScreenshot();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(ReplayHandler.isInPath()) ReplayProcess.tickReplay(false);
|
|
||||||
// if(ReplayHandler.isCameraView()) mc.setRenderViewEntity(ReplayHandler.getCameraEntity());
|
|
||||||
//
|
|
||||||
// if(mc.isGamePaused() && ReplayHandler.isInPath()) {
|
|
||||||
// mc.isGamePaused = false;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onRenderTick(TickEvent.RenderTickEvent event) {
|
|
||||||
// TODO
|
|
||||||
// if(!ReplayHandler.isInReplay() || ReplayProcess.isVideoRecording()) return;
|
|
||||||
//
|
|
||||||
// if(ReplayHandler.getCameraEntity() != null)
|
|
||||||
// ReplayHandler.getCameraEntity().updateMovement();
|
|
||||||
// if(ReplayHandler.isInPath()) {
|
|
||||||
// ReplayProcess.tickReplay(true);
|
|
||||||
// } else onMouseMove(new MouseEvent());
|
|
||||||
//
|
|
||||||
// FMLCommonHandler.instance().fireKeyInput();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onMouseMove(MouseEvent event) {
|
|
||||||
// TODO
|
|
||||||
// if(!ReplayHandler.isInReplay()) return;
|
|
||||||
//
|
|
||||||
// mc.mcProfiler.startSection("mouse");
|
|
||||||
//
|
|
||||||
// if(Minecraft.isRunningOnMac && mc.inGameHasFocus && !Mouse.isInsideWindow()) {
|
|
||||||
// Mouse.setGrabbed(false);
|
|
||||||
// Mouse.setCursorPosition(Display.getWidth() / 2, Display.getHeight() / 2);
|
|
||||||
// Mouse.setGrabbed(true);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(mc.inGameHasFocus && !(ReplayHandler.isInPath())) {
|
|
||||||
// mc.mouseHelper.mouseXYChange();
|
|
||||||
// float f1 = mc.gameSettings.mouseSensitivity * 0.6F + 0.2F;
|
|
||||||
// float f2 = f1 * f1 * f1 * 8.0F;
|
|
||||||
// float f3 = (float) mc.mouseHelper.deltaX * f2;
|
|
||||||
// float f4 = (float) mc.mouseHelper.deltaY * f2;
|
|
||||||
// byte b0 = 1;
|
|
||||||
//
|
|
||||||
// if(mc.gameSettings.invertMouse) {
|
|
||||||
// b0 = -1;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(ReplayHandler.getCameraEntity() != null) {
|
|
||||||
// ReplayHandler.getCameraEntity().setAngles(f3, f4 * (float) b0);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,210 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.events.handlers.keyboard;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
|
||||||
import org.lwjgl.Sys;
|
|
||||||
|
|
||||||
public class KeyInputHandler {
|
|
||||||
|
|
||||||
private final Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
|
|
||||||
private long prevKeysDown = Sys.getTime();
|
|
||||||
|
|
||||||
public void onKeyInput() throws Exception {
|
|
||||||
// TODO
|
|
||||||
// if(!ReplayHandler.isInReplay()) return;
|
|
||||||
//
|
|
||||||
// KeyBinding[] keyBindings = Minecraft.getMinecraft().gameSettings.keyBindings;
|
|
||||||
//
|
|
||||||
// boolean speedup = false;
|
|
||||||
//
|
|
||||||
// if(mc.currentScreen == null) {
|
|
||||||
// boolean forward = false, backward = false, left = false, right = false, up = false, down = false;
|
|
||||||
//
|
|
||||||
// if(!ReplayHandler.isInPath()) {
|
|
||||||
// for(KeyBinding kb : keyBindings) {
|
|
||||||
// if(!kb.isKeyDown()) continue;
|
|
||||||
// if(ReplayHandler.isCameraView()) {
|
|
||||||
// if(kb.getKeyDescription().equals("key.forward")) {
|
|
||||||
// forward = true;
|
|
||||||
// speedup = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals("key.back")) {
|
|
||||||
// backward = true;
|
|
||||||
// speedup = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals("key.jump")) {
|
|
||||||
// up = true;
|
|
||||||
// speedup = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals("key.left")) {
|
|
||||||
// left = true;
|
|
||||||
// speedup = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals("key.right")) {
|
|
||||||
// right = true;
|
|
||||||
// speedup = true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals("key.sneak")) {
|
|
||||||
// if(ReplayHandler.isCameraView()) {
|
|
||||||
// down = true;
|
|
||||||
// speedup = true;
|
|
||||||
// }
|
|
||||||
// ReplayHandler.spectateCamera();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// forwardCameraMovement(forward, backward, left, right, up, down);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(ReplayHandler.getCameraEntity() != null) {
|
|
||||||
// if(speedup) {
|
|
||||||
// ReplayHandler.getCameraEntity().speedUp();
|
|
||||||
// prevKeysDown = Sys.getTime();
|
|
||||||
// } else {
|
|
||||||
// if(Sys.getTime() - prevKeysDown > 100) {
|
|
||||||
// ReplayHandler.getCameraEntity().stopSpeedUp();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public void keyInput(InputEvent.KeyInputEvent event) {
|
|
||||||
// try {
|
|
||||||
// onKeyInput();
|
|
||||||
// } catch(Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// KeyBinding[] keyBindings = Minecraft.getMinecraft().gameSettings.keyBindings;
|
|
||||||
//
|
|
||||||
// boolean found = false;
|
|
||||||
//
|
|
||||||
// for(KeyBinding kb : keyBindings) {
|
|
||||||
// if(!kb.isKeyDown()) continue;
|
|
||||||
//
|
|
||||||
// handleCustomKeybindings(kb, found, -1);
|
|
||||||
// found = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(!ReplayHandler.isInReplay() || (mc.currentScreen != null && !(mc.currentScreen instanceof GuiMouseInput))) return;
|
|
||||||
//
|
|
||||||
// for(StaticKeybinding staticKeybinding : KeybindRegistry.staticKeybindings) {
|
|
||||||
// if(!Keyboard.isKeyDown(staticKeybinding.getKeyCode())) {
|
|
||||||
// staticKeybinding.setDown(false);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(staticKeybinding.isDown()) return;
|
|
||||||
// staticKeybinding.setDown(true);
|
|
||||||
//
|
|
||||||
// switch(staticKeybinding.getId()) {
|
|
||||||
// case KeybindRegistry.STATIC_DELETE_KEYFRAME:
|
|
||||||
// if(ReplayHandler.getSelectedKeyframe() != null) ReplayHandler.removeKeyframe(ReplayHandler.getSelectedKeyframe());
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void forwardCameraMovement(boolean forward, boolean backward, boolean left, boolean right, boolean up, boolean down) {
|
|
||||||
// if(forward && !backward) {
|
|
||||||
// ReplayHandler.getCameraEntity().setMovement(MoveDirection.FORWARD);
|
|
||||||
// } else if(backward && !forward) {
|
|
||||||
// ReplayHandler.getCameraEntity().setMovement(MoveDirection.BACKWARD);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(left && !right) {
|
|
||||||
// ReplayHandler.getCameraEntity().setMovement(MoveDirection.LEFT);
|
|
||||||
// } else if(right && !left) {
|
|
||||||
// ReplayHandler.getCameraEntity().setMovement(MoveDirection.RIGHT);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(up && !down) {
|
|
||||||
// ReplayHandler.getCameraEntity().setMovement(MoveDirection.UP);
|
|
||||||
// } else if(down && !up) {
|
|
||||||
// ReplayHandler.getCameraEntity().setMovement(MoveDirection.DOWN);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void handleCustomKeybindings(KeyBinding kb, boolean found, int keyCode) {
|
|
||||||
//Custom registered handlers
|
|
||||||
|
|
||||||
// TODO: Transfer to new key binding registry
|
|
||||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ADD_MARKER) && (kb.isPressed() || kb.getKeyCode() == keyCode)) {
|
|
||||||
// if(ReplayHandler.isInReplay() && (mc.currentScreen == null || mc.currentScreen instanceof GuiMouseInput)) {
|
|
||||||
// ReplayHandler.toggleMarker();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(!ReplayHandler.isInReplay() || (mc.currentScreen != null && !(mc.currentScreen instanceof GuiMouseInput))) return;
|
|
||||||
//
|
|
||||||
// if((kb.getKeyDescription().equals("key.chat") || kb.getKeyDescription().equals("key.command"))
|
|
||||||
// && (kb.isPressed() || kb.getKeyCode() == keyCode)) {
|
|
||||||
// mc.displayGuiScreen(new GuiMouseInput(ReplayMod.overlay));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_PLAY_PAUSE) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
|
||||||
// ReplayMod.overlay.togglePlayPause();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ROLL_CLOCKWISE) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
|
||||||
// ReplayHandler.addCameraTilt(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) ? 0.2f : 1);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ROLL_COUNTERCLOCKWISE) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
|
||||||
// ReplayHandler.addCameraTilt(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) ? -0.2f : -1);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_RESET_TILT) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
|
||||||
// ReplayHandler.setCameraTilt(0);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_THUMBNAIL) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !found && !ReplayHandler.isInPath()) {
|
|
||||||
// TickAndRenderListener.requestScreenshot();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_PLAYER_OVERVIEW) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !found && !ReplayHandler.isInPath()) {
|
|
||||||
// PlayerHandler.openPlayerOverview();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_LIGHTING) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
|
||||||
// ReplayMod.replaySettings.setLightingEnabled(!ReplayMod.replaySettings.isLightingEnabled());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_CLEAR_KEYFRAMES) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
|
||||||
// ReplayHandler.resetKeyframes(false, ReplayMod.replaySettings.showClearKeyframesCallback());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_SYNC_TIMELINE) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
|
||||||
// ReplayHandler.syncTimeCursor(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_KEYFRAME_PRESETS) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
|
||||||
// mc.displayGuiScreen(new GuiKeyframeRepository(ReplayHandler.getKeyframeRepository()));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_PATH_PREVIEW) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
|
||||||
// ReplayMod.replaySettings.setShowPathPreview(!ReplayMod.replaySettings.showPathPreview());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ASSET_MANAGER) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
|
||||||
// mc.displayGuiScreen(new GuiAssetManager());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_OBJECT_MANAGER) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
|
||||||
// mc.displayGuiScreen(new GuiObjectManager());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_TOGGLE_INTERPOLATION) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
|
||||||
// ReplayMod.replaySettings.toggleInterpolation();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.events.handlers.keyboard;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class StaticKeybinding {
|
|
||||||
|
|
||||||
private final int id;
|
|
||||||
private final int keyCode;
|
|
||||||
private boolean down;
|
|
||||||
}
|
|
||||||
@@ -1,223 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.assets.AssetFileUtils;
|
|
||||||
import eu.crushedpixel.replaymod.assets.AssetRepository;
|
|
||||||
import eu.crushedpixel.replaymod.assets.ReplayAsset;
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.*;
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.listeners.FileChooseListener;
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.listeners.SelectionListener;
|
|
||||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
import org.lwjgl.util.Point;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GuiAssetManager extends GuiScreen {
|
|
||||||
|
|
||||||
private String screenTitle;
|
|
||||||
|
|
||||||
private boolean initialized = false;
|
|
||||||
private GuiEntryList<ReplayAsset> assetGuiEntryList;
|
|
||||||
private GuiAdvancedButton removeButton;
|
|
||||||
private GuiAdvancedTextField assetNameInput;
|
|
||||||
private GuiFileChooser fileChooser, addButton;
|
|
||||||
|
|
||||||
private ComposedElement inputElements;
|
|
||||||
|
|
||||||
private ComposedElement composedElement;
|
|
||||||
|
|
||||||
private AssetRepository assetRepository;
|
|
||||||
|
|
||||||
private final AssetRepository initialRepository;
|
|
||||||
|
|
||||||
private ReplayAsset currentAsset;
|
|
||||||
|
|
||||||
public GuiAssetManager() {
|
|
||||||
// TODO
|
|
||||||
initialRepository = null;
|
|
||||||
// this.initialRepository = new AssetRepository(ReplayHandler.getAssetRepository());
|
|
||||||
// this.assetRepository = ReplayHandler.getAssetRepository();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initGui() {
|
|
||||||
if(!initialized) {
|
|
||||||
screenTitle = I18n.format("replaymod.gui.assets.title");
|
|
||||||
|
|
||||||
assetGuiEntryList = new GuiEntryList<ReplayAsset>(fontRendererObj, 0, 0, 0, 0);
|
|
||||||
addButton = new GuiFileChooser(0, 0, 0, I18n.format("replaymod.gui.add"), null, AssetFileUtils.getAllAvailableExtensions()) {
|
|
||||||
@Override
|
|
||||||
protected void updateDisplayString() {
|
|
||||||
this.displayString = baseString;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
addButton.addFileChooseListener(new FileChooseListener() {
|
|
||||||
@Override
|
|
||||||
public void onFileChosen(File file) {
|
|
||||||
try {
|
|
||||||
ReplayAsset newAsset = assetRepository.addAsset(file.getName(), new FileInputStream(file));
|
|
||||||
assetGuiEntryList.addElement(newAsset);
|
|
||||||
sortAssetList();
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
removeButton = new GuiAdvancedButton(0, 0, 0, I18n.format("replaymod.gui.remove")) {
|
|
||||||
@Override
|
|
||||||
public void performAction() {
|
|
||||||
assetRepository.removeAsset(currentAsset);
|
|
||||||
assetGuiEntryList.removeElement(assetGuiEntryList.getSelectionIndex());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
removeButton.setElementEnabled(false);
|
|
||||||
|
|
||||||
assetNameInput = new GuiAdvancedTextField(fontRendererObj, 0, 0, 150, 20);
|
|
||||||
assetNameInput.hint = I18n.format("replaymod.gui.assets.namehint");
|
|
||||||
|
|
||||||
fileChooser = new GuiFileChooser(0, 0, 0, I18n.format("replaymod.gui.assets.changefile"), null, new String[0]) {
|
|
||||||
@Override
|
|
||||||
protected void updateDisplayString() {
|
|
||||||
this.displayString = baseString;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
fileChooser.addFileChooseListener(new FileChooseListener() {
|
|
||||||
@Override
|
|
||||||
public void onFileChosen(File file) {
|
|
||||||
if(currentAsset == null) return;
|
|
||||||
try {
|
|
||||||
currentAsset.loadFromStream(new FileInputStream(file));
|
|
||||||
} catch(IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
fileChooser.width = 150;
|
|
||||||
|
|
||||||
inputElements = new ComposedElement(assetNameInput, fileChooser);
|
|
||||||
composedElement = new ComposedElement(assetGuiEntryList, addButton, removeButton, inputElements);
|
|
||||||
|
|
||||||
inputElements.setElementEnabled(false);
|
|
||||||
|
|
||||||
assetGuiEntryList.addSelectionListener(new SelectionListener() {
|
|
||||||
@Override
|
|
||||||
public void onSelectionChanged(int selectionIndex) {
|
|
||||||
ReplayAsset newAsset = assetGuiEntryList.getElement(selectionIndex);
|
|
||||||
if (newAsset == currentAsset) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
currentAsset = newAsset;
|
|
||||||
inputElements.setElementEnabled(currentAsset != null);
|
|
||||||
|
|
||||||
assetNameInput.setText(currentAsset != null ? currentAsset.getDisplayString() : "");
|
|
||||||
removeButton.setElementEnabled(currentAsset != null);
|
|
||||||
fileChooser.setAllowedExtensions(currentAsset != null ? AssetFileUtils.fileExtensionsForAssetClass(currentAsset.getClass()) : new String[0]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for(ReplayAsset asset : assetRepository.getCopyOfReplayAssets()) {
|
|
||||||
assetGuiEntryList.addElement(asset);
|
|
||||||
}
|
|
||||||
sortAssetList();
|
|
||||||
}
|
|
||||||
|
|
||||||
int visibleEntries = (int)Math.floor(((double)this.height-(45+20+15+20))/14);
|
|
||||||
|
|
||||||
assetGuiEntryList.width = 150;
|
|
||||||
assetGuiEntryList.xPosition = width/2 - assetGuiEntryList.width - 5;
|
|
||||||
assetGuiEntryList.setVisibleElements(visibleEntries);
|
|
||||||
|
|
||||||
assetGuiEntryList.yPosition = assetNameInput.yPosition = 45;
|
|
||||||
|
|
||||||
addButton.xPosition = assetGuiEntryList.xPosition-1;
|
|
||||||
addButton.width = 77;
|
|
||||||
removeButton.width = 76;
|
|
||||||
removeButton.xPosition = addButton.xPosition+addButton.width;
|
|
||||||
|
|
||||||
addButton.yPosition = removeButton.yPosition = assetGuiEntryList.yPosition+assetGuiEntryList.height+2;
|
|
||||||
|
|
||||||
assetNameInput.xPosition = fileChooser.xPosition = this.width / 2 + 5;
|
|
||||||
fileChooser.yPosition = assetNameInput.yPosition + 20 + 5;
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
|
||||||
this.drawCenteredString(fontRendererObj, screenTitle, this.width / 2, 5, Color.WHITE.getRGB());
|
|
||||||
|
|
||||||
int leftBorder = 10;
|
|
||||||
int topBorder = 20;
|
|
||||||
|
|
||||||
drawGradientRect(leftBorder, topBorder, width - leftBorder, this.height - 10, -1072689136, -804253680);
|
|
||||||
|
|
||||||
composedElement.draw(mc, mouseX, mouseY);
|
|
||||||
|
|
||||||
if(currentAsset != null) {
|
|
||||||
int y = fileChooser.yPosition + 20 + 5;
|
|
||||||
int height = (addButton.yPosition+addButton.height)-y;
|
|
||||||
|
|
||||||
GL11.glColor4f(1, 1, 1, 1);
|
|
||||||
currentAsset.drawToScreen(fileChooser.xPosition, y, 150, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
|
||||||
composedElement.mouseClick(mc, mouseX, mouseY, mouseButton);
|
|
||||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
|
||||||
Point mousePos = MouseUtils.getMousePos();
|
|
||||||
composedElement.buttonPressed(mc, mousePos.getX(), mousePos.getY(), typedChar, keyCode);
|
|
||||||
|
|
||||||
if(currentAsset != null) {
|
|
||||||
currentAsset.setAssetName(assetNameInput.getText());
|
|
||||||
sortAssetList();
|
|
||||||
}
|
|
||||||
|
|
||||||
super.keyTyped(typedChar, keyCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateScreen() {
|
|
||||||
composedElement.tick(mc);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGuiClosed() {
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if(assetRepository.equals(initialRepository)) return;
|
|
||||||
assetRepository.saveAssets();
|
|
||||||
}
|
|
||||||
}, "replaymod-asset-saver").start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sortAssetList() {
|
|
||||||
List<ReplayAsset> list = assetGuiEntryList.getElements();
|
|
||||||
Collections.sort(list, new Comparator<ReplayAsset>() {
|
|
||||||
@Override
|
|
||||||
public int compare(ReplayAsset o1, ReplayAsset o2) {
|
|
||||||
return o1.getAssetName().compareTo(o2.getAssetName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
assetGuiEntryList.setSelectionIndex(list.indexOf(currentAsset));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,8 +3,6 @@ package eu.crushedpixel.replaymod.gui;
|
|||||||
public class GuiConstants {
|
public class GuiConstants {
|
||||||
|
|
||||||
//didn't find a better place to put these constants
|
//didn't find a better place to put these constants
|
||||||
public static final int MIN_PW_LENGTH = 5;
|
|
||||||
public static final int MAX_PW_LENGTH = 1024;
|
|
||||||
|
|
||||||
public static final int CENTER_DOWNLOADED_REPLAYS_BUTTON = 2001;
|
public static final int CENTER_DOWNLOADED_REPLAYS_BUTTON = 2001;
|
||||||
public static final int CENTER_SEARCH_BUTTON = 2002;
|
public static final int CENTER_SEARCH_BUTTON = 2002;
|
||||||
|
|||||||
@@ -1,514 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui;
|
|
||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.*;
|
|
||||||
import eu.crushedpixel.replaymod.holders.Keyframe;
|
|
||||||
import eu.crushedpixel.replaymod.interpolation.KeyframeList;
|
|
||||||
import eu.crushedpixel.replaymod.interpolation.KeyframeValue;
|
|
||||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
|
||||||
import eu.crushedpixel.replaymod.utils.TimestampUtils;
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
import org.lwjgl.util.Point;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class GuiEditKeyframe<T extends KeyframeValue> extends GuiScreen {
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static GuiEditKeyframe create(Keyframe kf) {
|
|
||||||
// TODO
|
|
||||||
// if(kf.getValue() instanceof TimestampValue) return new GuiEditKeyframeTime(kf);
|
|
||||||
// if(kf.getValue() instanceof SpectatorData) return new GuiEditKeyframeSpectator(kf);
|
|
||||||
// if(kf.getValue() instanceof AdvancedPosition) return new GuiEditKeyframePosition(kf);
|
|
||||||
throw new UnsupportedOperationException("Keyframe type unknown: " + kf);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean initialized = false;
|
|
||||||
|
|
||||||
private GuiAdvancedButton saveButton, cancelButton;
|
|
||||||
private GuiArrowButton leftButton, rightButton;
|
|
||||||
|
|
||||||
protected GuiNumberInput min, sec, ms;
|
|
||||||
|
|
||||||
protected ComposedElement inputs;
|
|
||||||
|
|
||||||
private int virtualHeight = 200;
|
|
||||||
protected int virtualY;
|
|
||||||
|
|
||||||
protected Keyframe<T> keyframe;
|
|
||||||
protected Keyframe<T> keyframeBackup;
|
|
||||||
protected boolean save;
|
|
||||||
|
|
||||||
private Keyframe<?> previous, next;
|
|
||||||
|
|
||||||
protected int w2;
|
|
||||||
protected int w3;
|
|
||||||
protected int totalWidth;
|
|
||||||
protected int left;
|
|
||||||
|
|
||||||
protected String screenTitle;
|
|
||||||
|
|
||||||
public GuiEditKeyframe(Keyframe<T> keyframe, KeyframeList<T> keyframes) {
|
|
||||||
this.keyframe = keyframe;
|
|
||||||
this.keyframeBackup = keyframe.copy();
|
|
||||||
|
|
||||||
previous = keyframes.getPreviousKeyframe(keyframe.getRealTimestamp(), false);
|
|
||||||
next = keyframes.getNextKeyframe(keyframe.getRealTimestamp(), false);
|
|
||||||
|
|
||||||
ReplayMod.replaySender.setReplaySpeed(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initGui() {
|
|
||||||
Keyboard.enableRepeatEvents(true);
|
|
||||||
|
|
||||||
virtualY = this.height - virtualHeight - 10;
|
|
||||||
|
|
||||||
if(!initialized) {
|
|
||||||
saveButton = new GuiAdvancedButton(GuiConstants.KEYFRAME_EDITOR_SAVE_BUTTON, 0, 0, I18n.format("replaymod.gui.save")) {
|
|
||||||
@Override
|
|
||||||
public void performAction() {
|
|
||||||
save = true;
|
|
||||||
mc.displayGuiScreen(null);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
cancelButton = new GuiAdvancedButton(GuiConstants.KEYFRAME_EDITOR_CANCEL_BUTTON, 0, 0, I18n.format("replaymod.gui.cancel")) {
|
|
||||||
@Override
|
|
||||||
public void performAction() {
|
|
||||||
save = false;
|
|
||||||
mc.displayGuiScreen(null);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
leftButton = new GuiArrowButton(GuiConstants.KEYFRAME_EDITOR_LEFT_BUTTON, 0, 0, "", GuiArrowButton.Direction.LEFT) {
|
|
||||||
@Override
|
|
||||||
public void performAction() {
|
|
||||||
save = true;
|
|
||||||
mc.displayGuiScreen(create(previous));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
rightButton = new GuiArrowButton(GuiConstants.KEYFRAME_EDITOR_RIGHT_BUTTON, 0, 0, "", GuiArrowButton.Direction.RIGHT){
|
|
||||||
@Override
|
|
||||||
public void performAction() {
|
|
||||||
save = true;
|
|
||||||
mc.displayGuiScreen(create(next));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
saveButton.width = cancelButton.width = 100;
|
|
||||||
|
|
||||||
leftButton.enabled = previous != null;
|
|
||||||
rightButton.enabled = next != null;
|
|
||||||
|
|
||||||
//Real Time Input
|
|
||||||
int timestamp = keyframe.getRealTimestamp();
|
|
||||||
min = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 30, 0d, 29d, (double)TimestampUtils.timestampToWholeMinutes(timestamp), false, "", 1);
|
|
||||||
sec = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 25, 0d, 59d, (double)TimestampUtils.getSecondsFromTimestamp(timestamp), false, "", 1);
|
|
||||||
ms = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 35, 0d, 999d, (double)TimestampUtils.getMillisecondsFromTimestamp(timestamp), false, "", 1);
|
|
||||||
|
|
||||||
inputs = new ComposedElement(min, sec, ms, saveButton, cancelButton, leftButton, rightButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
w3 = fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.timelineposition")+":")+10+
|
|
||||||
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.minutes"))+5+min.width+5+
|
|
||||||
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.seconds"))+5+sec.width+5+
|
|
||||||
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.milliseconds"))+5+ms.width;
|
|
||||||
|
|
||||||
int l = (this.width-w3)/2;
|
|
||||||
min.xPosition = fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.timelineposition")+":")+10 + l;
|
|
||||||
sec.xPosition = fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.timelineposition")+":")+10 + l +
|
|
||||||
min.width + 5 + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.minutes")) + 5;
|
|
||||||
ms.xPosition = fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.timelineposition")+":")+10 + l +
|
|
||||||
min.width + 5 + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.minutes")) + 5
|
|
||||||
+ sec.width + 5 + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.seconds")) + 5;
|
|
||||||
|
|
||||||
min.yPosition = sec.yPosition = ms.yPosition = virtualY+virtualHeight-55;
|
|
||||||
|
|
||||||
saveButton.yPosition = cancelButton.yPosition = virtualY + virtualHeight - 20 - 5;
|
|
||||||
saveButton.xPosition = this.width - 100 - 5 - 10;
|
|
||||||
cancelButton.xPosition = saveButton.xPosition - 100 - 5;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<GuiButton> buttonList = this.buttonList;
|
|
||||||
|
|
||||||
buttonList.add(saveButton);
|
|
||||||
buttonList.add(cancelButton);
|
|
||||||
|
|
||||||
leftButton.xPosition = 15;
|
|
||||||
rightButton.xPosition = width-35;
|
|
||||||
leftButton.yPosition = rightButton.yPosition = virtualY + ((virtualHeight - leftButton.height)/2);
|
|
||||||
|
|
||||||
buttonList.add(leftButton);
|
|
||||||
buttonList.add(rightButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGuiClosed() {
|
|
||||||
// TODO
|
|
||||||
// if(!save) {
|
|
||||||
// ReplayHandler.removeKeyframe(property);
|
|
||||||
// ReplayHandler.addKeyframe(keyframeBackup);
|
|
||||||
// ReplayHandler.selectKeyframe(keyframeBackup);
|
|
||||||
// }
|
|
||||||
// ReplayHandler.fireKeyframesModifyEvent();
|
|
||||||
// Keyboard.enableRepeatEvents(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
|
||||||
Point mousePos = MouseUtils.getMousePos();
|
|
||||||
inputs.buttonPressed(mc, mousePos.getX(), mousePos.getY(), typedChar, keyCode);
|
|
||||||
|
|
||||||
if(keyCode == Keyboard.KEY_ESCAPE) {
|
|
||||||
save = false;
|
|
||||||
mc.displayGuiScreen(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
|
||||||
inputs.mouseClick(mc, mouseX, mouseY, mouseButton);
|
|
||||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
|
|
||||||
inputs.mouseDrag(mc, mouseX, mouseY, clickedMouseButton);
|
|
||||||
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void mouseReleased(int mouseX, int mouseY, int state) {
|
|
||||||
inputs.mouseRelease(mc, mouseX, mouseY, state);
|
|
||||||
super.mouseReleased(mouseX, mouseY, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateScreen() {
|
|
||||||
inputs.tick(mc);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
|
||||||
drawGradientRect(10, virtualY, width - 10, virtualY + virtualHeight, -1072689136, -804253680);
|
|
||||||
drawCenteredString(fontRendererObj, screenTitle, this.width / 2, virtualY + 5, Color.WHITE.getRGB());
|
|
||||||
|
|
||||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.timelineposition") + ":", (width - w3) / 2, min.yPosition + 7, Color.WHITE.getRGB());
|
|
||||||
drawString(fontRendererObj, I18n.format("replaymod.gui.minutes"), min.xPosition + min.width + 5, min.yPosition + 7, Color.WHITE.getRGB());
|
|
||||||
drawString(fontRendererObj, I18n.format("replaymod.gui.seconds"), sec.xPosition+sec.width+5, sec.yPosition+7, Color.WHITE.getRGB());
|
|
||||||
drawString(fontRendererObj, I18n.format("replaymod.gui.milliseconds"), ms.xPosition + ms.width + 5, ms.yPosition + 7, Color.WHITE.getRGB());
|
|
||||||
|
|
||||||
drawScreen0();
|
|
||||||
|
|
||||||
inputs.draw(mc, mouseX, mouseY);
|
|
||||||
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void drawScreen0() {}
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
// private static class GuiEditKeyframeMarker extends GuiEditKeyframe<Marker> {
|
|
||||||
// private GuiAdvancedTextField markerNameInput;
|
|
||||||
//
|
|
||||||
// public GuiEditKeyframeMarker(Keyframe<Marker> property) {
|
|
||||||
// super(property, ReplayHandler.getMarkerKeyframes());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void initGui() {
|
|
||||||
// super.initGui();
|
|
||||||
//
|
|
||||||
// if (!initialized) {
|
|
||||||
// String name = property.getValue().getName();
|
|
||||||
// if (name == null) name = "";
|
|
||||||
// markerNameInput = new GuiAdvancedTextField(fontRendererObj, 0, 0, 200, 20);
|
|
||||||
// markerNameInput.hint = I18n.format("replaymod.gui.editkeyframe.markername");
|
|
||||||
// markerNameInput.setText(name);
|
|
||||||
//
|
|
||||||
// inputs.addPart(markerNameInput);
|
|
||||||
//
|
|
||||||
// new KeyframeValueChangeListener(this);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// markerNameInput.xPosition = width/2 - 100;
|
|
||||||
// markerNameInput.yPosition = height/2-10;
|
|
||||||
//
|
|
||||||
// initialized = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onGuiClosed() {
|
|
||||||
// property.getValue().setName(markerNameInput.getText().trim());
|
|
||||||
// super.onGuiClosed();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private static class GuiEditKeyframeTime extends GuiEditKeyframe<TimestampValue> {
|
|
||||||
// private GuiNumberInput kfMin, kfSec, kfMs;
|
|
||||||
//
|
|
||||||
// public GuiEditKeyframeTime(Keyframe<TimestampValue> property) {
|
|
||||||
// super(property, ReplayHandler.getTimeKeyframes());
|
|
||||||
// screenTitle = I18n.format("replaymod.gui.editkeyframe.title.time");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void initGui() {
|
|
||||||
// super.initGui();
|
|
||||||
//
|
|
||||||
// if (!initialized) {
|
|
||||||
// int time = property.getValue().asInt();
|
|
||||||
//
|
|
||||||
// kfMin = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 30, 0d, null, (double)TimestampUtils.timestampToWholeMinutes(time), false, "", 1);
|
|
||||||
// kfSec = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 25, 0d, 59d, (double)TimestampUtils.getSecondsFromTimestamp(time), false, "", 1);
|
|
||||||
// kfMs = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 35, 0d, 999d, (double)TimestampUtils.getMillisecondsFromTimestamp(time), false, "", 1);
|
|
||||||
//
|
|
||||||
// inputs.addPart(kfMin);
|
|
||||||
// inputs.addPart(kfSec);
|
|
||||||
// inputs.addPart(kfMs);
|
|
||||||
//
|
|
||||||
// KeyframeValueChangeListener listener = new KeyframeValueChangeListener(this) {
|
|
||||||
// @Override
|
|
||||||
// public void onValueChange(double value) {
|
|
||||||
// property.setValue(new TimestampValue(TimestampUtils.calculateTimestamp(
|
|
||||||
// kfMin.getIntValue(), kfSec.getIntValue(), kfMs.getIntValue())));
|
|
||||||
//
|
|
||||||
// super.onValueChange(value);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// kfMin.addValueChangeListener(listener);
|
|
||||||
// kfSec.addValueChangeListener(listener);
|
|
||||||
// kfMs.addValueChangeListener(listener);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// kfMin.xPosition = min.xPosition;
|
|
||||||
// kfSec.xPosition = sec.xPosition;
|
|
||||||
// kfMs.xPosition = ms.xPosition;
|
|
||||||
//
|
|
||||||
// kfMin.yPosition = kfSec.yPosition = kfMs.yPosition = min.yPosition - 10 - 20;
|
|
||||||
//
|
|
||||||
// initialized = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void drawScreen0() {
|
|
||||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.timestamp")+":", (width-w3)/2, kfMin.yPosition + 7, Color.WHITE.getRGB());
|
|
||||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.minutes"), kfMin.xPosition + kfMin.width + 5, kfMin.yPosition + 7, Color.WHITE.getRGB());
|
|
||||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.seconds"), kfSec.xPosition + kfSec.width + 5, kfSec.yPosition + 7, Color.WHITE.getRGB());
|
|
||||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.milliseconds"), kfMs.xPosition + kfMs.width + 5, kfMs.yPosition + 7, Color.WHITE.getRGB());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private static class GuiEditKeyframePosition extends GuiEditKeyframe<AdvancedPosition> {
|
|
||||||
// private GuiNumberInput xCoord, yCoord, zCoord, pitch, yaw, roll;
|
|
||||||
// private ComposedElement posInputs;
|
|
||||||
//
|
|
||||||
// public GuiEditKeyframePosition(Keyframe<AdvancedPosition> property) {
|
|
||||||
// super(property, ReplayHandler.getPositionKeyframes());
|
|
||||||
// screenTitle = I18n.format("replaymod.gui.editkeyframe.title.pos");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void initGui() {
|
|
||||||
// super.initGui();
|
|
||||||
//
|
|
||||||
// if (!initialized) {
|
|
||||||
// AdvancedPosition pos = property.getValue();
|
|
||||||
// xCoord = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getX()), true);
|
|
||||||
// yCoord = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getY()), true);
|
|
||||||
// zCoord = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getZ()), true);
|
|
||||||
// yaw = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getYaw()), true);
|
|
||||||
// pitch = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, -90d, 90d, RoundUtils.round2Decimals(pos.getPitch()), true);
|
|
||||||
// roll = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getRoll()), true);
|
|
||||||
//
|
|
||||||
// posInputs = new ComposedElement(xCoord, yCoord, zCoord, yaw, pitch, roll);
|
|
||||||
// inputs.addPart(posInputs);
|
|
||||||
//
|
|
||||||
// KeyframeValueChangeListener listener = new KeyframeValueChangeListener(this) {
|
|
||||||
// @Override
|
|
||||||
// public void onValueChange(double value) {
|
|
||||||
// property.setValue(new AdvancedPosition(xCoord.getPreciseValue(), yCoord.getPreciseValue(),
|
|
||||||
// zCoord.getPreciseValue(), new Float(pitch.getPreciseValue()), (float) yaw.getPreciseValue(),
|
|
||||||
// (float) roll.getPreciseValue()));
|
|
||||||
//
|
|
||||||
// super.onValueChange(value);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// xCoord.addValueChangeListener(listener);
|
|
||||||
// yCoord.addValueChangeListener(listener);
|
|
||||||
// zCoord.addValueChangeListener(listener);
|
|
||||||
// pitch.addValueChangeListener(listener);
|
|
||||||
// yaw.addValueChangeListener(listener);
|
|
||||||
// roll.addValueChangeListener(listener);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// int w = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.xpos")),
|
|
||||||
// Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.ypos")),
|
|
||||||
// fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.zpos"))));
|
|
||||||
// w2 = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.camyaw")),
|
|
||||||
// Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.campitch")),
|
|
||||||
// fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.camroll"))));
|
|
||||||
//
|
|
||||||
// totalWidth = w +100+w2+100+5+5+10;
|
|
||||||
// left = (this.width - totalWidth)/2;
|
|
||||||
//
|
|
||||||
// int x = w + left + 5;
|
|
||||||
// int i = 0;
|
|
||||||
// for(GuiElement input : posInputs.getParts()) {
|
|
||||||
// if(input instanceof GuiTextField) {
|
|
||||||
// GuiTextField textField = (GuiTextField)input;
|
|
||||||
// textField.xPosition = i < 3 ? x : left+totalWidth-100;
|
|
||||||
// textField.yPosition = i < 3 ? virtualY + 20 + i*30 : virtualY + 20 + (i-3)*30;
|
|
||||||
// i++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// initialized = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void drawScreen0() {
|
|
||||||
// if (property.getValue() instanceof SpectatorData) return;
|
|
||||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.xpos"), left, virtualY + 27, Color.WHITE.getRGB());
|
|
||||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.ypos"), left, virtualY + 57, Color.WHITE.getRGB());
|
|
||||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.zpos"), left, virtualY + 87, Color.WHITE.getRGB());
|
|
||||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.camyaw"), left + totalWidth - 100 - 5 - w2, virtualY + 27, Color.WHITE.getRGB());
|
|
||||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.campitch"), left + totalWidth - 100 - 5 - w2, virtualY + 57, Color.WHITE.getRGB());
|
|
||||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.camroll"), left + totalWidth - 100 - 5 - w2, virtualY + 87, Color.WHITE.getRGB());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private static class GuiEditKeyframeSpectator extends GuiEditKeyframe<AdvancedPosition> {
|
|
||||||
// private GuiToggleButton perspectiveButton;
|
|
||||||
//
|
|
||||||
// private GuiString shoulderDistanceString, shoulderPitchString, shoulderYawString, shoulderSmoothnessString;
|
|
||||||
// private GuiDraggingNumberInput shoulderDistanceInput, shoulderPitchOffsetInput,
|
|
||||||
// shoulderYawOffsetInput, shoulderSmoothnessInput;
|
|
||||||
//
|
|
||||||
// private ComposedElement spectatorCamSettings;
|
|
||||||
// private ComposedElement shoulderCamSettings;
|
|
||||||
//
|
|
||||||
// private DelegatingElement perspectiveSettings = new DelegatingElement() {
|
|
||||||
// @Override
|
|
||||||
// public GuiElement delegate() {
|
|
||||||
// switch(perspectiveButton.getValue()) {
|
|
||||||
// case 0:
|
|
||||||
// return spectatorCamSettings;
|
|
||||||
// case 1:
|
|
||||||
// return shoulderCamSettings;
|
|
||||||
// default:
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// public GuiEditKeyframeSpectator(Keyframe<AdvancedPosition> property) {
|
|
||||||
// super(property, ReplayHandler.getPositionKeyframes());
|
|
||||||
// screenTitle = I18n.format("replaymod.gui.editkeyframe.title.spec");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void initGui() {
|
|
||||||
// super.initGui();
|
|
||||||
//
|
|
||||||
// if (!initialized) {
|
|
||||||
// SpectatorData data = (SpectatorData)property.getValue();
|
|
||||||
//
|
|
||||||
// perspectiveButton = new GuiToggleButton(0, 0, 0, 200, 20, I18n.format("replaymod.gui.editkeyframe.spec.method")+": ", new String[]{
|
|
||||||
// I18n.format("replaymod.gui.editkeyframe.spec.method.firstperson"),
|
|
||||||
// I18n.format("replaymod.gui.editkeyframe.spec.method.shoulder")});
|
|
||||||
//
|
|
||||||
// perspectiveButton.setValue(Arrays.asList(SpectatorData.SpectatingMethod.values()).indexOf(data.getSpectatingMethod()));
|
|
||||||
//
|
|
||||||
// spectatorCamSettings = new ComposedElement();
|
|
||||||
//
|
|
||||||
// //create elements in shoulderCamSettings
|
|
||||||
// shoulderDistanceString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.editkeyframe.spec.method.shoulder.distance"));
|
|
||||||
// shoulderPitchString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.editkeyframe.spec.method.shoulder.pitch"));
|
|
||||||
// shoulderYawString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.editkeyframe.spec.method.shoulder.yaw"));
|
|
||||||
// shoulderSmoothnessString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.editkeyframe.spec.method.shoulder.smoothness"));
|
|
||||||
//
|
|
||||||
// shoulderDistanceInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 0, 0d, 30d, data.getThirdPersonInfo().shoulderCamDistance, true, "", 0.1);
|
|
||||||
// shoulderPitchOffsetInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 0, -90d, 90d, data.getThirdPersonInfo().shoulderCamPitchOffset, false, "°", 1);
|
|
||||||
// shoulderYawOffsetInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 0, null, null, data.getThirdPersonInfo().shoulderCamYawOffset, false, "°", 1);
|
|
||||||
// shoulderSmoothnessInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 0, 0.1d, 3d, data.getThirdPersonInfo().shoulderCamSmoothness, true, "", 0.1);
|
|
||||||
//
|
|
||||||
// shoulderCamSettings = new ComposedElement(
|
|
||||||
// shoulderDistanceString, shoulderDistanceInput,
|
|
||||||
// shoulderPitchString, shoulderPitchOffsetInput,
|
|
||||||
// shoulderYawString, shoulderYawOffsetInput,
|
|
||||||
// shoulderSmoothnessString, shoulderSmoothnessInput);
|
|
||||||
//
|
|
||||||
// inputs.addPart(new ComposedElement(perspectiveButton, perspectiveSettings));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// perspectiveButton.xPosition = (this.width-perspectiveButton.width())/2;
|
|
||||||
// perspectiveButton.yPosition = this.virtualY + 20;
|
|
||||||
//
|
|
||||||
// int verticalSpacing = 20 + 5;
|
|
||||||
// int totalWidth = 300;
|
|
||||||
// int elementWidth = 145;
|
|
||||||
// int horizontalSpacing = 10;
|
|
||||||
//
|
|
||||||
// int y = perspectiveButton.yPos() + verticalSpacing;
|
|
||||||
//
|
|
||||||
// int i = 0;
|
|
||||||
// for(GuiElement el : shoulderCamSettings.getParts()) {
|
|
||||||
// el.xPos((width-totalWidth)/2 + (i%2)*(elementWidth + horizontalSpacing));
|
|
||||||
// el.width(elementWidth);
|
|
||||||
//
|
|
||||||
// el.yPos(y + ((i+1)%2)*7);
|
|
||||||
//
|
|
||||||
// if(i%2 == 1) {
|
|
||||||
// y += verticalSpacing;
|
|
||||||
// }
|
|
||||||
// i++;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// initialized = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onGuiClosed() {
|
|
||||||
// SpectatorData data = (SpectatorData)property.getValue();
|
|
||||||
// data.setSpectatingMethod(SpectatorData.SpectatingMethod.values()[perspectiveButton.getValue()]);
|
|
||||||
// data.getThirdPersonInfo().shoulderCamDistance = shoulderDistanceInput.getPreciseValue();
|
|
||||||
// data.getThirdPersonInfo().shoulderCamPitchOffset = shoulderPitchOffsetInput.getIntValue();
|
|
||||||
// data.getThirdPersonInfo().shoulderCamYawOffset = shoulderYawOffsetInput.getIntValue();
|
|
||||||
// data.getThirdPersonInfo().shoulderCamSmoothness = shoulderSmoothnessInput.getPreciseValue();
|
|
||||||
// super.onGuiClosed();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private static class KeyframeValueChangeListener implements NumberValueChangeListener {
|
|
||||||
//
|
|
||||||
// private GuiEditKeyframe parent;
|
|
||||||
//
|
|
||||||
// public KeyframeValueChangeListener(GuiEditKeyframe parent) {
|
|
||||||
// this.parent = parent;
|
|
||||||
//
|
|
||||||
// parent.min.addValueChangeListener(this);
|
|
||||||
// parent.sec.addValueChangeListener(this);
|
|
||||||
// parent.ms.addValueChangeListener(this);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onValueChange(double value) {
|
|
||||||
// int realTimestamp = TimestampUtils.calculateTimestamp(parent.min.getIntValue(), parent.sec.getIntValue(), parent.ms.getIntValue());
|
|
||||||
// parent.property.setRealTimestamp(realTimestamp);
|
|
||||||
//
|
|
||||||
// ReplayHandler.fireKeyframesModifyEvent();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@@ -1,698 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
|
|
||||||
public class GuiObjectManager extends GuiScreen {
|
|
||||||
// TODO
|
|
||||||
//
|
|
||||||
// private boolean initialized = false;
|
|
||||||
//
|
|
||||||
// private GuiEntryList<CustomImageObject> objectList;
|
|
||||||
// private GuiAdvancedButton addButton, removeButton;
|
|
||||||
//
|
|
||||||
// private GuiAdvancedTextField nameInput;
|
|
||||||
//
|
|
||||||
// private GuiString dropdownLabel;
|
|
||||||
// private GuiDropdown<GuiEntryListValueEntry<UUID>> assetDropdown;
|
|
||||||
//
|
|
||||||
// private final List<CustomImageObject> initialObjects = ReplayHandler.getCustomImageObjects();
|
|
||||||
//
|
|
||||||
// private GuiDraggingNumberInput anchorXInput, anchorYInput, anchorZInput;
|
|
||||||
// private GuiDraggingNumberInput positionXInput, positionYInput, positionZInput;
|
|
||||||
// private GuiDraggingNumberInput orientationXInput, orientationYInput, orientationZInput;
|
|
||||||
// private GuiDraggingNumberInput scaleXInput, scaleYInput, scaleZInput;
|
|
||||||
// private GuiDraggingNumberInput opacityInput;
|
|
||||||
//
|
|
||||||
// private NumberPositionInputGroup anchorNumberInputs, positionNumberInputs, orientationNumberInputs, scaleNumberInputs;
|
|
||||||
// private NumberValueInputGroup opacityNumberInputs;
|
|
||||||
//
|
|
||||||
// @Getter
|
|
||||||
// private GuiObjectKeyframeTimeline objectKeyframeTimeline;
|
|
||||||
//
|
|
||||||
// private ComposedElement disableElements, allElements;
|
|
||||||
//
|
|
||||||
// private static final int KEYFRAME_BUTTON_X = 80;
|
|
||||||
// private static final int KEYFRAME_BUTTON_Y = 40;
|
|
||||||
//
|
|
||||||
// private static final float ZOOM_STEPS = 0.05f;
|
|
||||||
//
|
|
||||||
// private DelegatingElement keyframeButton(final int x, final int y, final int line) {
|
|
||||||
// return new DelegatingElement() {
|
|
||||||
//
|
|
||||||
// private GuiTexturedButton normal = new GuiTexturedButton(0, x, y, 20, 20,
|
|
||||||
// GuiReplayOverlay.replay_gui, KEYFRAME_BUTTON_X, KEYFRAME_BUTTON_Y,
|
|
||||||
// GuiReplayOverlay.TEXTURE_SIZE, GuiReplayOverlay.TEXTURE_SIZE, new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// objectKeyframeTimeline.addKeyframe(line);
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// null);
|
|
||||||
//
|
|
||||||
// private GuiTexturedButton selected = new GuiTexturedButton(0, x, y, 20, 20,
|
|
||||||
// GuiReplayOverlay.replay_gui, KEYFRAME_BUTTON_X, KEYFRAME_BUTTON_Y+20,
|
|
||||||
// GuiReplayOverlay.TEXTURE_SIZE, GuiReplayOverlay.TEXTURE_SIZE, new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// objectKeyframeTimeline.removeKeyframe(line);
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// null);
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public GuiElement delegate() {
|
|
||||||
// if(objectKeyframeTimeline.getSelectedKeyframeRow() == line) {
|
|
||||||
// return selected;
|
|
||||||
// } else {
|
|
||||||
// return normal;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void setElementEnabled(boolean enabled) {
|
|
||||||
// selected.setElementEnabled(enabled);
|
|
||||||
// normal.setElementEnabled(enabled);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void initGui() {
|
|
||||||
// if(!initialized) {
|
|
||||||
// anchorXInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 50, null, null, 0d, true, "", 0.1);
|
|
||||||
// anchorYInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 50, null, null, 0d, true, "", 0.1);
|
|
||||||
// anchorZInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 50, null, null, 0d, true, "", 0.1);
|
|
||||||
// anchorNumberInputs = new NumberPositionInputGroup(null, anchorXInput, anchorYInput, anchorZInput);
|
|
||||||
//
|
|
||||||
// positionXInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 50, null, null, 0d, true);
|
|
||||||
// positionYInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 50, null, null, 0d, true);
|
|
||||||
// positionZInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 50, null, null, 0d, true);
|
|
||||||
// positionNumberInputs = new NumberPositionInputGroup(null, positionXInput, positionYInput, positionZInput);
|
|
||||||
//
|
|
||||||
// orientationXInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 50, null, null, 0d, true);
|
|
||||||
// orientationYInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 50, null, null, 0d, true);
|
|
||||||
// orientationZInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 50, null, null, 0d, true);
|
|
||||||
// orientationNumberInputs = new NumberPositionInputGroup(null, orientationXInput, orientationYInput, orientationZInput);
|
|
||||||
//
|
|
||||||
// scaleXInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 50, null, null, 100d, true, "%", 0.5);
|
|
||||||
// scaleYInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 50, null, null, 100d, true, "%", 0.5);
|
|
||||||
// scaleZInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 50, null, null, 100d, true, "%", 0.5);
|
|
||||||
// scaleNumberInputs = new NumberPositionInputGroup(null, scaleXInput, scaleYInput, scaleZInput);
|
|
||||||
//
|
|
||||||
// opacityInput = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 50, 0d, 100d, 100d, true, "%", 0.5);
|
|
||||||
// opacityNumberInputs = new NumberValueInputGroup(null, opacityInput);
|
|
||||||
//
|
|
||||||
// dropdownLabel = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.assets.filechooser")+": ");
|
|
||||||
// assetDropdown = new GuiDropdown<GuiEntryListValueEntry<UUID>>(fontRendererObj, 0, 0, 0, 5);
|
|
||||||
// List<ReplayAsset> assets = ReplayHandler.getAssetRepository().getCopyOfReplayAssets();
|
|
||||||
// Collections.sort(assets, new Comparator<ReplayAsset>() {
|
|
||||||
// @Override
|
|
||||||
// public int compare(ReplayAsset o1, ReplayAsset o2) {
|
|
||||||
// return o1.getAssetName().compareTo(o2.getAssetName());
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// if(assets.isEmpty()) {
|
|
||||||
// assetDropdown.addElement(new GuiEntryListValueEntry<UUID>(I18n.format("replaymod.gui.assets.emptylist"), null));
|
|
||||||
// } else {
|
|
||||||
// assetDropdown.addElement(new GuiEntryListValueEntry<UUID>(I18n.format("replaymod.gui.assets.noselection"), null));
|
|
||||||
// for(ReplayAsset asset : assets) {
|
|
||||||
// assetDropdown.addElement(new GuiEntryListValueEntry<UUID>(
|
|
||||||
// asset.getDisplayString(), ReplayHandler.getAssetRepository().getUUIDForAsset(asset)));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// objectList = new GuiEntryList<CustomImageObject>(fontRendererObj, 0, 0, 0, 0);
|
|
||||||
// objectList.setEmptyMessage(I18n.format("replaymod.gui.objects.empty"));
|
|
||||||
//
|
|
||||||
// addButton = new GuiAdvancedButton(0, 0, 0, 20, I18n.format("replaymod.gui.add"), new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// try {
|
|
||||||
// CustomImageObject customImageObject = new CustomImageObject(I18n.format("replaymod.gui.objects.defaultname"), null);
|
|
||||||
//
|
|
||||||
// Position defaultPosition = new Position(mc.getRenderViewEntity());
|
|
||||||
// customImageObject.getTransformations().setDefaultPosition(defaultPosition);
|
|
||||||
//
|
|
||||||
// objectList.addElement(customImageObject);
|
|
||||||
// } catch(IOException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }, null);
|
|
||||||
//
|
|
||||||
// removeButton = new GuiAdvancedButton(0, 0, 0, 20, I18n.format("replaymod.gui.remove"), new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// if(objectList.getElement(objectList.getSelectionIndex()) != null)
|
|
||||||
// objectList.removeElement(objectList.getSelectionIndex());
|
|
||||||
// }
|
|
||||||
// }, null);
|
|
||||||
//
|
|
||||||
// nameInput = new GuiAdvancedTextField(fontRendererObj, 0, 0, 0, 20);
|
|
||||||
// nameInput.hint = I18n.format("replaymod.gui.objects.properties.name");
|
|
||||||
//
|
|
||||||
// for(CustomImageObject customImageObject : initialObjects) {
|
|
||||||
// try {
|
|
||||||
// objectList.addElement(customImageObject.copy());
|
|
||||||
// } catch(IOException ioe) {
|
|
||||||
// ioe.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// objectList.addSelectionListener(new SelectionListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onSelectionChanged(int selectionIndex) {
|
|
||||||
// CustomImageObject selectedObject = objectList.getElement(selectionIndex);
|
|
||||||
// if(selectedObject != null) {
|
|
||||||
// disableElements.setElementEnabled(true);
|
|
||||||
//
|
|
||||||
// nameInput.setText(selectedObject.getName());
|
|
||||||
//
|
|
||||||
// //setting the dropdown value
|
|
||||||
// int sel = 0;
|
|
||||||
// if(selectedObject.getLinkedAsset() != null) {
|
|
||||||
// int i = 0;
|
|
||||||
// for(GuiEntryListValueEntry<UUID> entry : assetDropdown.getAllElements()) {
|
|
||||||
// if(selectedObject.getLinkedAsset().equals(entry.getValue())) {
|
|
||||||
// sel = i;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// i++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// assetDropdown.setSelectionIndexQuietly(sel);
|
|
||||||
//
|
|
||||||
// Transformations transformations = selectedObject.getTransformations();
|
|
||||||
//
|
|
||||||
// objectKeyframeTimeline.setTransformations(transformations);
|
|
||||||
//
|
|
||||||
// anchorNumberInputs.setUnderlyingKeyframeList(transformations.getAnchorKeyframes());
|
|
||||||
// positionNumberInputs.setUnderlyingKeyframeList(transformations.getPositionKeyframes());
|
|
||||||
// orientationNumberInputs.setUnderlyingKeyframeList(transformations.getOrientationKeyframes());
|
|
||||||
// scaleNumberInputs.setUnderlyingKeyframeList(transformations.getScaleKeyframes());
|
|
||||||
// opacityNumberInputs.setUnderlyingKeyframeList(transformations.getOpacityKeyframes());
|
|
||||||
//
|
|
||||||
// updateValuesForTransformation(objectKeyframeTimeline.getTransformations().getTransformationForTimestamp(objectKeyframeTimeline.cursorPosition));
|
|
||||||
// } else {
|
|
||||||
// disableElements.setElementEnabled(false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// assetDropdown.addSelectionListener(new SelectionListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onSelectionChanged(int selectionIndex) {
|
|
||||||
// CustomImageObject selectedObject = objectList.getElement(objectList.getSelectionIndex());
|
|
||||||
// GuiEntryListValueEntry<UUID> entry = assetDropdown.getElement(selectionIndex);
|
|
||||||
// if(selectedObject != null && entry != null) {
|
|
||||||
// try {
|
|
||||||
// selectedObject.setLinkedAsset(entry.getValue());
|
|
||||||
// } catch(IOException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// String[] labelStrings = new String[] {
|
|
||||||
// I18n.format("replaymod.gui.objects.properties.anchor"),
|
|
||||||
// I18n.format("replaymod.gui.objects.properties.position"),
|
|
||||||
// I18n.format("replaymod.gui.objects.properties.orientation"),
|
|
||||||
// I18n.format("replaymod.gui.objects.properties.scale"),
|
|
||||||
// I18n.format("replaymod.gui.objects.properties.opacity"),
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// int maxStringWidth = 0;
|
|
||||||
// for(String label : labelStrings) {
|
|
||||||
// int stringWidth = fontRendererObj.getStringWidth(label);
|
|
||||||
// if(stringWidth > maxStringWidth) {
|
|
||||||
// maxStringWidth = stringWidth;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// disableElements = new ComposedElement();
|
|
||||||
// allElements = new ComposedElement();
|
|
||||||
//
|
|
||||||
// int inputWidth = 40;
|
|
||||||
//
|
|
||||||
// ComposedElement anchorInputs = new ComposedElement(anchorXInput, anchorYInput, anchorZInput);
|
|
||||||
// ComposedElement positionInputs = new ComposedElement(positionXInput, positionYInput, positionZInput);
|
|
||||||
// ComposedElement orientationInputs = new ComposedElement(orientationXInput, orientationYInput, orientationZInput);
|
|
||||||
// ComposedElement scaleInputs = new ComposedElement(scaleXInput, scaleYInput, scaleZInput);
|
|
||||||
// ComposedElement opacityInputs = new ComposedElement(opacityInput);
|
|
||||||
// ComposedElement numberInputs = new ComposedElement(anchorInputs, positionInputs, orientationInputs, scaleInputs, opacityInputs);
|
|
||||||
//
|
|
||||||
// for(int i = numberInputs.getParts().size()-1; i >= 0; i--) {
|
|
||||||
// int yPos = this.height-5-10-(25*(numberInputs.getParts().size()-i));
|
|
||||||
// DelegatingElement button = keyframeButton(10, yPos, i);
|
|
||||||
// GuiString label = new GuiString(35, yPos + 6, Color.WHITE, labelStrings[i]);
|
|
||||||
//
|
|
||||||
// ComposedElement child = (ComposedElement) numberInputs.getParts().get(i);
|
|
||||||
// int x = 0;
|
|
||||||
// for(GuiElement el : child.getParts()) {
|
|
||||||
// GuiDraggingNumberInput dni = (GuiDraggingNumberInput)el;
|
|
||||||
// dni.width = inputWidth;
|
|
||||||
// dni.xPosition = 35+maxStringWidth+5 + (x*(inputWidth+5));
|
|
||||||
// dni.yPosition = yPos;
|
|
||||||
// x++;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// child.addPart(button);
|
|
||||||
// child.addPart(label);
|
|
||||||
//
|
|
||||||
// disableElements.addPart(child);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// int timelineX = anchorZInput.xPosition + anchorZInput.width + 5 - 1;
|
|
||||||
// int timelineY = anchorZInput.yPosition - 1;
|
|
||||||
//
|
|
||||||
// int timelineWidth = this.width-10-timelineX + 2;
|
|
||||||
// int timelineHeight = this.height-10-10-timelineY + 2;
|
|
||||||
//
|
|
||||||
// objectKeyframeTimeline = new GuiObjectKeyframeTimeline(timelineX, timelineY, timelineWidth, timelineHeight);
|
|
||||||
// disableElements.addPart(objectKeyframeTimeline);
|
|
||||||
//
|
|
||||||
// GuiScrollbar timelineScrollbar = new GuiScrollbar(timelineX, this.height - 15, timelineWidth - 21) {
|
|
||||||
// @Override
|
|
||||||
// public void dragged() {
|
|
||||||
// objectKeyframeTimeline.timeStart = (float) sliderPosition;
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// timelineScrollbar.size = objectKeyframeTimeline.zoom;
|
|
||||||
// timelineScrollbar.sliderPosition = objectKeyframeTimeline.timeStart;
|
|
||||||
//
|
|
||||||
// disableElements.addPart(timelineScrollbar);
|
|
||||||
//
|
|
||||||
// GuiTexturedButton zoomInButton = GuiReplayOverlay.texturedButton(width - 28, this.height - 15, 40, 20, 9, new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// objectKeyframeTimeline.zoom = Math.max(0.025f, objectKeyframeTimeline.zoom - ZOOM_STEPS);
|
|
||||||
// }
|
|
||||||
// }, "replaymod.gui.ingame.menu.zoomin");
|
|
||||||
//
|
|
||||||
// GuiTexturedButton zoomOutButton = GuiReplayOverlay.texturedButton(width - 18, this.height - 15, 40, 30, 9, new Runnable() {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// objectKeyframeTimeline.zoom = Math.min(1f, objectKeyframeTimeline.zoom + ZOOM_STEPS);
|
|
||||||
// objectKeyframeTimeline.timeStart = Math.min(objectKeyframeTimeline.timeStart, 1f - objectKeyframeTimeline.zoom);
|
|
||||||
// }
|
|
||||||
// }, "replaymod.gui.ingame.menu.zoomout");
|
|
||||||
//
|
|
||||||
// disableElements.addPart(zoomInButton);
|
|
||||||
// disableElements.addPart(zoomOutButton);
|
|
||||||
//
|
|
||||||
// objectList.xPosition = 11;
|
|
||||||
// objectList.yPosition = 11;
|
|
||||||
// objectList.width = width/2 - 11 - 5;
|
|
||||||
//
|
|
||||||
// int visibleElements = (int)((anchorXInput.yPosition-5 - objectList.yPosition)/14f);
|
|
||||||
// objectList.setVisibleElements(visibleElements);
|
|
||||||
//
|
|
||||||
// allElements.addPart(objectList);
|
|
||||||
//
|
|
||||||
// nameInput.xPosition = width/2 + 5;
|
|
||||||
// nameInput.yPosition = objectList.yPosition;
|
|
||||||
// nameInput.width = objectList.width;
|
|
||||||
//
|
|
||||||
// disableElements.addPart(nameInput);
|
|
||||||
//
|
|
||||||
// dropdownLabel.positionX = (width/2)+5;
|
|
||||||
// int strWidth = fontRendererObj.getStringWidth(I18n.format("replaymod.gui.assets.filechooser")+": ");
|
|
||||||
//
|
|
||||||
// assetDropdown.xPosition = dropdownLabel.positionX+strWidth+5;
|
|
||||||
// assetDropdown.yPosition = objectList.yPosition+25;
|
|
||||||
// dropdownLabel.positionY = assetDropdown.yPosition + 6;
|
|
||||||
// assetDropdown.width = (objectList.width-strWidth-5);
|
|
||||||
//
|
|
||||||
// disableElements.addPart(dropdownLabel);
|
|
||||||
// disableElements.addPart(assetDropdown);
|
|
||||||
//
|
|
||||||
// addButton.xPosition = nameInput.xPosition;
|
|
||||||
// addButton.width = removeButton.width = nameInput.width/2 - 2;
|
|
||||||
// removeButton.xPosition = addButton.xPosition + nameInput.width/2 + 2;
|
|
||||||
// addButton.yPosition = removeButton.yPosition = objectList.yPosition+objectList.height-25;
|
|
||||||
//
|
|
||||||
// allElements.addPart(addButton);
|
|
||||||
// disableElements.addPart(removeButton);
|
|
||||||
//
|
|
||||||
// allElements.addPart(disableElements);
|
|
||||||
//
|
|
||||||
// objectList.setSelectionIndex(objectList.getSelectionIndex()); // trigger an event for the SelectionListener
|
|
||||||
//
|
|
||||||
// initialized = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void saveOnQuit() {
|
|
||||||
// List<CustomImageObject> objects = objectList.getCopyOfElements();
|
|
||||||
//
|
|
||||||
// if(objects.equals(initialObjects)) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ReplayHandler.setCustomImageObjects(objects);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void updateValuesForTransformation(Transformation transformation) {
|
|
||||||
// anchorXInput.setValueQuietly(transformation.getAnchor().getX());
|
|
||||||
// anchorYInput.setValueQuietly(transformation.getAnchor().getY());
|
|
||||||
// anchorZInput.setValueQuietly(transformation.getAnchor().getZ());
|
|
||||||
//
|
|
||||||
// positionXInput.setValueQuietly(transformation.getPosition().getX());
|
|
||||||
// positionYInput.setValueQuietly(transformation.getPosition().getY());
|
|
||||||
// positionZInput.setValueQuietly(transformation.getPosition().getZ());
|
|
||||||
//
|
|
||||||
// orientationXInput.setValueQuietly(transformation.getOrientation().getX());
|
|
||||||
// orientationYInput.setValueQuietly(transformation.getOrientation().getY());
|
|
||||||
// orientationZInput.setValueQuietly(transformation.getOrientation().getZ());
|
|
||||||
//
|
|
||||||
// scaleXInput.setValueQuietly(transformation.getScale().getX());
|
|
||||||
// scaleYInput.setValueQuietly(transformation.getScale().getY());
|
|
||||||
// scaleZInput.setValueQuietly(transformation.getScale().getZ());
|
|
||||||
//
|
|
||||||
// opacityInput.setValueQuietly(transformation.getOpacity());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
|
||||||
// this.drawDefaultBackground();
|
|
||||||
//
|
|
||||||
// allElements.draw(mc, mouseX, mouseY);
|
|
||||||
//
|
|
||||||
// GlStateManager.enableBlend();
|
|
||||||
//
|
|
||||||
// super.drawScreen(mouseX, mouseY, partialTicks);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
|
||||||
// Point mousePos = MouseUtils.getMousePos();
|
|
||||||
// allElements.buttonPressed(mc, mousePos.getX(), mousePos.getY(), typedChar, keyCode);
|
|
||||||
//
|
|
||||||
// CustomImageObject selectedObject = objectList.getElement(objectList.getSelectionIndex());
|
|
||||||
// if(selectedObject != null) {
|
|
||||||
// selectedObject.setName(nameInput.getText().trim());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(keyCode == Keyboard.KEY_DELETE) {
|
|
||||||
// if(objectKeyframeTimeline.getSelectedKeyframe() != null) {
|
|
||||||
// objectKeyframeTimeline.removeKeyframe(objectKeyframeTimeline.getSelectedKeyframeRow());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// super.keyTyped(typedChar, keyCode);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void updateScreen() {
|
|
||||||
// allElements.tick(mc);
|
|
||||||
// super.updateScreen();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
|
||||||
// allElements.mouseClick(mc, mouseX, mouseY, mouseButton);
|
|
||||||
// super.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void mouseClickMove(int mouseX, int mouseY, int mouseButton, long timeSinceLastClick) {
|
|
||||||
// allElements.mouseDrag(mc, mouseX, mouseY, mouseButton);
|
|
||||||
// super.mouseClickMove(mouseX, mouseY, mouseButton, timeSinceLastClick);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void mouseReleased(int mouseX, int mouseY, int mouseButton) {
|
|
||||||
// allElements.mouseRelease(mc, mouseX, mouseY, mouseButton);
|
|
||||||
// super.mouseReleased(mouseX, mouseY, mouseButton);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onGuiClosed() {
|
|
||||||
// saveOnQuit();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public abstract class NumberInputGroup<T extends KeyframeValue> implements NumberValueChangeListener {
|
|
||||||
//
|
|
||||||
// KeyframeList<T> toModify;
|
|
||||||
//
|
|
||||||
// public void setUnderlyingKeyframeList(KeyframeList<T> toModify) {
|
|
||||||
// this.toModify = toModify;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public class NumberValueInputGroup extends NumberInputGroup<NumberValue> {
|
|
||||||
//
|
|
||||||
// public NumberValueInputGroup(KeyframeList<NumberValue> toModify, GuiNumberInput input) {
|
|
||||||
// this.toModify = toModify;
|
|
||||||
//
|
|
||||||
// input.addValueChangeListener(this);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// @SuppressWarnings("unchecked")
|
|
||||||
// public void onValueChange(double value) {
|
|
||||||
// NumberValue numberValue = new NumberValue(value);
|
|
||||||
//
|
|
||||||
// //if property selected, overwrite its value
|
|
||||||
// if(toModify.contains(objectKeyframeTimeline.getSelectedKeyframe())) {
|
|
||||||
// objectKeyframeTimeline.getSelectedKeyframe().setValue(numberValue);
|
|
||||||
// } else {
|
|
||||||
// toModify.add(new Keyframe<NumberValue>(objectKeyframeTimeline.cursorPosition, numberValue));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public class NumberPositionInputGroup extends NumberInputGroup<Position> {
|
|
||||||
//
|
|
||||||
// public NumberPositionInputGroup(KeyframeList<Position> toModify, GuiNumberInput xInput, GuiNumberInput yInput, GuiNumberInput zInput) {
|
|
||||||
// this.toModify = toModify;
|
|
||||||
// this.xInput = xInput;
|
|
||||||
// this.yInput = yInput;
|
|
||||||
// this.zInput = zInput;
|
|
||||||
//
|
|
||||||
// xInput.addValueChangeListener(this);
|
|
||||||
// yInput.addValueChangeListener(this);
|
|
||||||
// zInput.addValueChangeListener(this);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private GuiNumberInput xInput, yInput, zInput;
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// @SuppressWarnings("unchecked")
|
|
||||||
// public void onValueChange(double value) {
|
|
||||||
// Position position = new Position(xInput.getPreciseValue(), yInput.getPreciseValue(), zInput.getPreciseValue());
|
|
||||||
//
|
|
||||||
// //if property selected, overwrite its value
|
|
||||||
// if(toModify.contains(objectKeyframeTimeline.getSelectedKeyframe())) {
|
|
||||||
// objectKeyframeTimeline.getSelectedKeyframe().setValue(position);
|
|
||||||
// } else {
|
|
||||||
// toModify.add(new Keyframe<Position>(objectKeyframeTimeline.cursorPosition, position));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public class GuiObjectKeyframeTimeline extends GuiTimeline {
|
|
||||||
//
|
|
||||||
// private static final int KEYFRAME_X = 74;
|
|
||||||
// private static final int KEYFRAME_Y = 35;
|
|
||||||
// private static final int KEYFRAME_SIZE = 5;
|
|
||||||
//
|
|
||||||
// @Getter @Setter
|
|
||||||
// private Transformations transformations;
|
|
||||||
//
|
|
||||||
// @Getter private int selectedKeyframeRow = -1;
|
|
||||||
// @Getter private Keyframe selectedKeyframe = null;
|
|
||||||
//
|
|
||||||
// private boolean dragging = false;
|
|
||||||
//
|
|
||||||
// public GuiObjectKeyframeTimeline(int x, int y, int width, int height) {
|
|
||||||
// super(x, y, width, height);
|
|
||||||
//
|
|
||||||
// this.zoom = 0.1;
|
|
||||||
// this.timelineLength = 10 * 60 * 1000;
|
|
||||||
// this.showMarkers = true;
|
|
||||||
//
|
|
||||||
// this.cursorPosition = ReplayHandler.getRealTimelineCursor();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void draw(Minecraft mc, int mouseX, int mouseY) {
|
|
||||||
// super.draw(mc, mouseX, mouseY);
|
|
||||||
//
|
|
||||||
// int bodyWidth = width - BORDER_LEFT - BORDER_RIGHT;
|
|
||||||
//
|
|
||||||
// long leftTime = Math.round(timeStart * timelineLength);
|
|
||||||
// long rightTime = Math.round((timeStart + zoom) * timelineLength);
|
|
||||||
//
|
|
||||||
// double segmentLength = timelineLength * zoom;
|
|
||||||
//
|
|
||||||
// if(transformations != null) {
|
|
||||||
// for(int i = 0; i < 5; i++) {
|
|
||||||
// KeyframeList<?> keyframes = transformations.getKeyframeListByID(i);
|
|
||||||
//
|
|
||||||
// //Draw Keyframe logos
|
|
||||||
// for(Keyframe kf : keyframes) {
|
|
||||||
// drawKeyframe(kf, (int)(i * (height / 5f)) + 10, bodyWidth, leftTime, rightTime, segmentLength);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private int getKeyframeX(int timestamp, long leftTime, int bodyWidth, double segmentLength) {
|
|
||||||
// long positionInSegment = timestamp - leftTime;
|
|
||||||
// double fractionOfSegment = positionInSegment / segmentLength;
|
|
||||||
// return (int) (positionX + BORDER_LEFT + fractionOfSegment * bodyWidth);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void drawKeyframe(Keyframe kf, int y, int bodyWidth, long leftTime, long rightTime, double segmentLength) {
|
|
||||||
// if (kf.getRealTimestamp() <= rightTime && kf.getRealTimestamp() >= leftTime) {
|
|
||||||
// int textureX = KEYFRAME_X;
|
|
||||||
// int textureY = KEYFRAME_Y;
|
|
||||||
// y = positionY+y;
|
|
||||||
//
|
|
||||||
// int keyframeX = getKeyframeX(kf.getRealTimestamp(), leftTime, bodyWidth, segmentLength);
|
|
||||||
//
|
|
||||||
// if (kf == selectedKeyframe) {
|
|
||||||
// textureX += KEYFRAME_SIZE;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// rect(keyframeX - 2, y, textureX, textureY, 5, 5);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean mouseClick(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
// if(!enabled) return false;
|
|
||||||
// super.mouseClick(mc, mouseX, mouseY, button);
|
|
||||||
// int time = (int) getTimeAt(mouseX, mouseY);
|
|
||||||
// if(time != -1) {
|
|
||||||
// boolean clicked = false;
|
|
||||||
//
|
|
||||||
// int tolerance = (int) (2 * Math.round(zoom * timelineLength / width));
|
|
||||||
//
|
|
||||||
// if(transformations != null) {
|
|
||||||
// for(int i = 0; i < 5; i++) {
|
|
||||||
// int upper = positionY + (int)(i * (height / 5f)) + 10;
|
|
||||||
// int lower = upper + KEYFRAME_SIZE;
|
|
||||||
// if(mouseY >= upper && mouseY <= lower) {
|
|
||||||
// KeyframeList keyframes = transformations.getKeyframeListByID(i);
|
|
||||||
//
|
|
||||||
// selectedKeyframe = keyframes.getClosestKeyframeForTimestamp(time, tolerance);
|
|
||||||
//
|
|
||||||
// if(selectedKeyframe != null) {
|
|
||||||
// selectedKeyframeRow = i;
|
|
||||||
// } else {
|
|
||||||
// selectedKeyframeRow = -1;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// clicked = true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(!clicked) {
|
|
||||||
// selectedKeyframe = null;
|
|
||||||
// selectedKeyframeRow = -1;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// cursorPosition = time;
|
|
||||||
// updateValuesForTransformation(getTransformations().getTransformationForTimestamp(cursorPosition));
|
|
||||||
//
|
|
||||||
// dragging = true;
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void mouseDrag(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
// if(!enabled) return;
|
|
||||||
// super.mouseDrag(mc, mouseX, mouseY, button);
|
|
||||||
// if(dragging) {
|
|
||||||
// int time = (int) getTimeAt(mouseX, mouseY);
|
|
||||||
// if(time != -1) {
|
|
||||||
// if(selectedKeyframe != null) {
|
|
||||||
// selectedKeyframe.setRealTimestamp(time);
|
|
||||||
// }
|
|
||||||
// cursorPosition = time;
|
|
||||||
// updateValuesForTransformation(getTransformations().getTransformationForTimestamp(cursorPosition));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void mouseRelease(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
// if(!enabled) return;
|
|
||||||
// super.mouseRelease(mc, mouseX, mouseY, button);
|
|
||||||
// this.dragging = false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @SuppressWarnings("unchecked")
|
|
||||||
// public void addKeyframe(int line) {
|
|
||||||
// CustomImageObject currentObject = objectList.getElement(objectList.getSelectionIndex());
|
|
||||||
// if(currentObject != null) {
|
|
||||||
// KeyframeList list = currentObject.getTransformations().getKeyframeListByID(line);
|
|
||||||
// int timestamp = objectKeyframeTimeline.cursorPosition;
|
|
||||||
//
|
|
||||||
// Keyframe kf = null;
|
|
||||||
//
|
|
||||||
// switch(line) {
|
|
||||||
// case 0:
|
|
||||||
//
|
|
||||||
// kf = new Keyframe<Position>(timestamp, new Position(
|
|
||||||
// anchorXInput.getPreciseValue(),
|
|
||||||
// anchorYInput.getPreciseValue(),
|
|
||||||
// anchorZInput.getPreciseValue()));
|
|
||||||
// break;
|
|
||||||
// case 1:
|
|
||||||
// kf = new Keyframe<Position>(timestamp, new Position(
|
|
||||||
// positionXInput.getPreciseValue(),
|
|
||||||
// positionYInput.getPreciseValue(),
|
|
||||||
// positionZInput.getPreciseValue()));
|
|
||||||
// break;
|
|
||||||
// case 2:
|
|
||||||
// kf = new Keyframe<Position>(timestamp, new Position(
|
|
||||||
// orientationXInput.getPreciseValue(),
|
|
||||||
// orientationYInput.getPreciseValue(),
|
|
||||||
// orientationZInput.getPreciseValue()));
|
|
||||||
// break;
|
|
||||||
// case 3:
|
|
||||||
// kf = new Keyframe<Position>(timestamp, new Position(
|
|
||||||
// scaleXInput.getPreciseValue(),
|
|
||||||
// scaleYInput.getPreciseValue(),
|
|
||||||
// scaleZInput.getPreciseValue()));
|
|
||||||
// break;
|
|
||||||
// case 4:
|
|
||||||
// kf = new Keyframe<NumberValue>(timestamp, new NumberValue(
|
|
||||||
// opacityInput.getPreciseValue()
|
|
||||||
// ));
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// list.add(kf);
|
|
||||||
//
|
|
||||||
// selectedKeyframe = kf;
|
|
||||||
// selectedKeyframeRow = line;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void removeKeyframe(int line) {
|
|
||||||
// if(selectedKeyframeRow == line) {
|
|
||||||
// CustomImageObject currentObject = objectList.getElement(objectList.getSelectionIndex());
|
|
||||||
// if(currentObject != null) {
|
|
||||||
// KeyframeList list = currentObject.getTransformations().getKeyframeListByID(line);
|
|
||||||
// list.remove(selectedKeyframe);
|
|
||||||
// selectedKeyframe = null;
|
|
||||||
// selectedKeyframeRow = -1;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@@ -1,314 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
|
|
||||||
public class GuiPlayerOverview extends GuiScreen {
|
|
||||||
|
|
||||||
public static boolean defaultSave = false;
|
|
||||||
|
|
||||||
// private List<Pair<EntityPlayer, ResourceLocation>> players;
|
|
||||||
// private List<GuiCheckBox> checkBoxes;
|
|
||||||
//
|
|
||||||
// private GuiCheckBox hideAllBox, showAllBox;
|
|
||||||
// private GuiCheckBox rememberHidden;
|
|
||||||
//
|
|
||||||
// private boolean initialized = false;
|
|
||||||
//
|
|
||||||
// private int playerCount;
|
|
||||||
// private int upperPlayer = 0;
|
|
||||||
//
|
|
||||||
// private int lowerBound;
|
|
||||||
//
|
|
||||||
// private boolean drag = false;
|
|
||||||
// private int lastY = 0;
|
|
||||||
// private int fitting = 0;
|
|
||||||
//
|
|
||||||
// private final Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
//
|
|
||||||
// private final String screenTitle = I18n.format("replaymod.input.playeroverview");
|
|
||||||
//
|
|
||||||
// private final Set<UUID> initialHiddenPlayers;
|
|
||||||
//
|
|
||||||
// public GuiPlayerOverview(List<EntityPlayer> players) {
|
|
||||||
// initialHiddenPlayers = new HashSet<UUID>(PlayerHandler.getHiddenPlayers());
|
|
||||||
//
|
|
||||||
// Collections.sort(players, new PlayerComparator());
|
|
||||||
//
|
|
||||||
// this.players = new ArrayList<Pair<EntityPlayer, ResourceLocation>>();
|
|
||||||
// this.checkBoxes = new ArrayList<GuiCheckBox>();
|
|
||||||
//
|
|
||||||
// for(final EntityPlayer p : players) {
|
|
||||||
// final ResourceLocation loc = SkinProvider.getResourceLocationForPlayerUUID(p.getUniqueID());
|
|
||||||
// this.players.add(Pair.of(p, loc));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// playerCount = players.size();
|
|
||||||
//
|
|
||||||
// ReplayMod.replaySender.setReplaySpeed(0);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private boolean isSpectator(EntityPlayer e) {
|
|
||||||
// return e.isInvisible() && e.getActivePotionEffect(Potion.invisibility) == null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
|
||||||
// throws IOException {
|
|
||||||
//
|
|
||||||
// if(fitting < playerCount) {
|
|
||||||
// float visiblePerc = (float) fitting / (float) playerCount;
|
|
||||||
//
|
|
||||||
// int h = this.height - 32 - 32;
|
|
||||||
// int offset = Math.round((upperPlayer / (fitting)) * visiblePerc * h);
|
|
||||||
//
|
|
||||||
// int lower = Math.round(32 + offset + (h * visiblePerc)) - 2;
|
|
||||||
//
|
|
||||||
// int k2 = (int) (this.width * 0.3);
|
|
||||||
//
|
|
||||||
// if(mouseX >= k2 - 16 && mouseX <= k2 - 12 && mouseY >= 32 - 2 + offset && mouseY <= lower) {
|
|
||||||
// lastY = mouseY;
|
|
||||||
// drag = true;
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// int k2 = (int) (this.width * 0.3);
|
|
||||||
//
|
|
||||||
// if(mouseX >= k2 && mouseX <= (this.width * 0.6) && mouseY >= upperBound && mouseY <= lowerBound) {
|
|
||||||
// int off = mouseY - upperBound;
|
|
||||||
// int p = (off / 21) + upperPlayer;
|
|
||||||
// // TODO
|
|
||||||
//// ReplayHandler.spectateEntity(players.get(p).first());
|
|
||||||
// mc.displayGuiScreen(null);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// super.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void mouseClickMove(int mouseX, int mouseY,
|
|
||||||
// int clickedMouseButton, long timeSinceLastClick) {
|
|
||||||
//
|
|
||||||
// if(drag) {
|
|
||||||
// float step = 1f / (float) playerCount;
|
|
||||||
//
|
|
||||||
// int diff = mouseY - lastY;
|
|
||||||
// int h = this.height - 32 - 32;
|
|
||||||
//
|
|
||||||
// float percDiff = (float) diff / (float) h;
|
|
||||||
// if(Math.abs(percDiff) > Math.abs(step)) {
|
|
||||||
// int s = (int) (percDiff / step);
|
|
||||||
// lastY = mouseY;
|
|
||||||
// upperPlayer += s;
|
|
||||||
// if(upperPlayer > playerCount - fitting) {
|
|
||||||
// upperPlayer = playerCount - fitting;
|
|
||||||
// } else if(upperPlayer < 0) {
|
|
||||||
// upperPlayer = 0;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void mouseReleased(int mouseX, int mouseY, int state) {
|
|
||||||
// drag = false;
|
|
||||||
//
|
|
||||||
// for(GuiCheckBox checkBox : checkBoxes) {
|
|
||||||
// checkBox.mouseReleased(mouseX, mouseY);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// super.mouseReleased(mouseX, mouseY, state);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void initGui() {
|
|
||||||
// upperPlayer = 0;
|
|
||||||
// lowerBound = this.height - 10;
|
|
||||||
//
|
|
||||||
// @SuppressWarnings("unchecked")
|
|
||||||
// List<GuiButton> buttonList = this.buttonList;
|
|
||||||
//
|
|
||||||
// int i = 0;
|
|
||||||
// for(GuiCheckBox checkBox : checkBoxes) {
|
|
||||||
// checkBox.xPosition = (int)(this.width*0.7)-5;
|
|
||||||
// buttonList.add(checkBox);
|
|
||||||
// i++;
|
|
||||||
// if(i >= fitting) break;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(!initialized) {
|
|
||||||
// hideAllBox = new GuiCheckBox(GuiConstants.PLAYER_OVERVIEW_HIDE_ALL, 0, 0, "", false);
|
|
||||||
// showAllBox = new GuiCheckBox(GuiConstants.PLAYER_OVERVIEW_SHOW_ALL, 0, 0, "", true);
|
|
||||||
// rememberHidden = new GuiCheckBox(GuiConstants.PLAYER_OVERVIEW_REMEMBER, 0, 0, I18n.format("replaymod.gui.playeroverview.remembersettings"), defaultSave);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// hideAllBox.xPosition = (int)(this.width*0.7)-5;
|
|
||||||
// showAllBox.xPosition = (int)(this.width*0.7)-20;
|
|
||||||
// hideAllBox.yPosition = showAllBox.yPosition = 45;
|
|
||||||
//
|
|
||||||
// rememberHidden.xPosition = (int)(this.width*0.3);
|
|
||||||
// rememberHidden.yPosition = 45;
|
|
||||||
//
|
|
||||||
// buttonList.add(hideAllBox);
|
|
||||||
// buttonList.add(showAllBox);
|
|
||||||
// buttonList.add(rememberHidden);
|
|
||||||
//
|
|
||||||
// initialized = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void actionPerformed(GuiButton button) throws IOException {
|
|
||||||
// if(button == showAllBox) {
|
|
||||||
// showAllBox.setIsChecked(true);
|
|
||||||
// for(Pair<EntityPlayer, ResourceLocation> p : players) {
|
|
||||||
// PlayerHandler.showPlayer(p.first());
|
|
||||||
// }
|
|
||||||
// } else if(button == hideAllBox) {
|
|
||||||
// hideAllBox.setIsChecked(false);
|
|
||||||
// for(Pair<EntityPlayer, ResourceLocation> p : players) {
|
|
||||||
// PlayerHandler.hidePlayer(p.first());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(!(button instanceof GuiCheckBox)) return;
|
|
||||||
// if(button.id >= fitting) return;
|
|
||||||
// if(!checkBoxes.contains(button)) return;
|
|
||||||
// PlayerHandler.setIsVisible(players.get(upperPlayer + button.id).first(), ((GuiCheckBox)button).isChecked());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private static final int upperBound = 65;
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
|
||||||
// this.drawCenteredString(fontRendererObj, screenTitle, this.width / 2, 5, Color.WHITE.getRGB());
|
|
||||||
// int k2 = (int)(this.width * 0.3);
|
|
||||||
// int l2 = upperBound;
|
|
||||||
//
|
|
||||||
// drawGradientRect(k2 - 20, 20, (int) (this.width * 0.7) + 20, this.height - 30 - 2 + 10, -1072689136, -804253680);
|
|
||||||
//
|
|
||||||
// drawString(fontRendererObj, I18n.format("replaymod.gui.playeroverview.spectate"), k2 - 10, 30, Color.WHITE.getRGB());
|
|
||||||
//
|
|
||||||
// String visibleString = I18n.format("replaymod.gui.playeroverview.visible");
|
|
||||||
// drawString(fontRendererObj, visibleString, (int) (this.width * 0.7) + 10 - fontRendererObj.getStringWidth(visibleString), 30, Color.WHITE.getRGB());
|
|
||||||
//
|
|
||||||
// fitting = 0;
|
|
||||||
//
|
|
||||||
// int sk = 0;
|
|
||||||
// for(Pair<EntityPlayer, ResourceLocation> p : players) {
|
|
||||||
// if(sk < upperPlayer) {
|
|
||||||
// sk++;
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// boolean spec = isSpectator(p.first());
|
|
||||||
//
|
|
||||||
// this.drawString(fontRendererObj, p.first().getName(), k2 + 16 + 5, l2 + 8 - (fontRendererObj.FONT_HEIGHT / 2),
|
|
||||||
// spec ? Color.DARK_GRAY.getRGB() : Color.WHITE.getRGB());
|
|
||||||
//
|
|
||||||
// mc.getTextureManager().bindTexture(p.second());
|
|
||||||
//
|
|
||||||
// drawScaledCustomSizeModalRect(k2, l2, 8.0F, 8.0F, 8, 8, 16, 16, 64.0F, 64.0F);
|
|
||||||
// if(p.first().func_175148_a(EnumPlayerModelParts.HAT))
|
|
||||||
// Gui.drawScaledCustomSizeModalRect(k2, l2, 40.0F, 8.0F, 8, 8, 16, 16, 64.0F, 64.0F);
|
|
||||||
//
|
|
||||||
// GlStateManager.resetColor();
|
|
||||||
// if(fitting >= checkBoxes.size()) {
|
|
||||||
// checkBoxes.add(new GuiCheckBox(checkBoxes.size(), (int)(this.width*0.7)-5, l2+3, "", true));
|
|
||||||
// @SuppressWarnings("unchecked")
|
|
||||||
// List<GuiButton> buttonList = this.buttonList;
|
|
||||||
// buttonList.add(checkBoxes.get(checkBoxes.size() - 1));
|
|
||||||
// }
|
|
||||||
// checkBoxes.get(fitting).setIsChecked(!PlayerHandler.isHidden(p.first().getUniqueID()));
|
|
||||||
//
|
|
||||||
// l2 += 16 + 5;
|
|
||||||
// fitting++;
|
|
||||||
// if(l2 + 32 > lowerBound) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// int dw = Mouse.getDWheel();
|
|
||||||
// if(dw > 0) {
|
|
||||||
// dw = -1;
|
|
||||||
// } else if(dw < 0) {
|
|
||||||
// dw = 1;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// upperPlayer = Math.max(Math.min(upperPlayer + dw, playerCount - fitting), 0);
|
|
||||||
//
|
|
||||||
// if(fitting < playerCount) {
|
|
||||||
// float visiblePerc = ((float) fitting) / playerCount;
|
|
||||||
// int barHeight = (int) (visiblePerc * (height - 32 - 32));
|
|
||||||
//
|
|
||||||
// float posPerc = ((float) upperPlayer) / playerCount;
|
|
||||||
// int barY = (int) (posPerc * (height - 32 - 32));
|
|
||||||
//
|
|
||||||
// drawRect(k2 - 18, upperBound - 2, k2 - 10, this.height - 30 - 2, Color.BLACK.getRGB());
|
|
||||||
// drawRect(k2 - 16, upperBound+2 - 2 + barY, k2 - 12, 30+2 - 1 + barY + barHeight, Color.LIGHT_GRAY.getRGB());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// int i = 0;
|
|
||||||
// for(GuiCheckBox checkBox : checkBoxes) {
|
|
||||||
// checkBox.drawButton(mc, mouseX, mouseY);
|
|
||||||
// i++;
|
|
||||||
// if(i >= fitting) break;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// hideAllBox.drawButton(mc, mouseX, mouseY);
|
|
||||||
// showAllBox.drawButton(mc, mouseX, mouseY);
|
|
||||||
// rememberHidden.drawButton(mc, mouseX, mouseY);
|
|
||||||
//
|
|
||||||
// if(hideAllBox.isMouseOver()) {
|
|
||||||
// ReplayMod.tooltipRenderer.drawTooltip(mouseX, mouseY, I18n.format("replaymod.gui.playeroverview.hideall"), this, Color.WHITE);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(showAllBox.isMouseOver()) {
|
|
||||||
// ReplayMod.tooltipRenderer.drawTooltip(mouseX, mouseY, I18n.format("replaymod.gui.playeroverview.showall"), this, Color.WHITE);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(rememberHidden.isMouseOver()) {
|
|
||||||
// ReplayMod.tooltipRenderer.drawTooltip(mouseX, mouseY, I18n.format("replaymod.gui.playeroverview.remembersettings.description"), this, Color.WHITE);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //this is necessary to reset the GL parameters for further GUI rendering
|
|
||||||
// GlStateManager.enableBlend();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void saveOnQuit() {
|
|
||||||
// try {
|
|
||||||
// // TODO
|
|
||||||
//// if(rememberHidden.isChecked()) {
|
|
||||||
//// if(initialHiddenPlayers.equals(PlayerHandler.getHiddenPlayers())) return;
|
|
||||||
//// ReplayHandler.getReplayFile().writeInvisiblePlayers(PlayerHandler.getHiddenPlayers());
|
|
||||||
//// } else {
|
|
||||||
//// if(initialHiddenPlayers.isEmpty()) return;
|
|
||||||
//// ReplayHandler.getReplayFile().writeInvisiblePlayers(Collections.<UUID>emptySet());
|
|
||||||
//// }
|
|
||||||
// } catch(Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void keyTyped(char typedChar, int keyCode) throws IOException {
|
|
||||||
// if(keyCode == Keyboard.KEY_ESCAPE) {
|
|
||||||
// saveOnQuit();
|
|
||||||
// super.keyTyped(typedChar, keyCode);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private class PlayerComparator implements Comparator<EntityPlayer> {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public int compare(EntityPlayer o1, EntityPlayer o2) {
|
|
||||||
// if(isSpectator(o1) && !isSpectator(o2)) {
|
|
||||||
// return 1;
|
|
||||||
// } else if(isSpectator(o2) && !isSpectator(o1)) {
|
|
||||||
// return -1;
|
|
||||||
// } else {
|
|
||||||
// return o1.getName().compareToIgnoreCase(o2.getName());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui;
|
|
||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class GuiReplaySaving extends GuiScreen {
|
|
||||||
|
|
||||||
private GuiScreen waiting = null;
|
|
||||||
|
|
||||||
private final Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
|
|
||||||
public GuiReplaySaving(GuiScreen waiting) {
|
|
||||||
this.waiting = waiting;
|
|
||||||
ReplayMod.replayFileAppender.addFinishListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setWorldAndResolution(Minecraft mc, int width, int height) {
|
|
||||||
super.setWorldAndResolution(mc, width, height);
|
|
||||||
ReplayMod.replayFileAppender.callListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
|
||||||
this.drawDefaultBackground();
|
|
||||||
this.drawCenteredString(this.fontRendererObj, I18n.format("replaymod.gui.replaysaving.title"), this.width / 2, 20, 16777215);
|
|
||||||
this.drawCenteredString(this.fontRendererObj, I18n.format("replaymod.gui.replaysaving.message"), this.width / 2, 40, 16777215);
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispatch() {
|
|
||||||
mc.displayGuiScreen(waiting);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
|
||||||
//Ignore key inputs to disallow users from closing this GUI
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.settings.ReplaySettings.RecordingOptions;
|
|
||||||
import eu.crushedpixel.replaymod.settings.ReplaySettings.ReplayOptions;
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class GuiReplaySettings extends GuiScreen {
|
|
||||||
protected String screenTitle = I18n.format("replaymod.gui.settings.title");
|
|
||||||
private GuiScreen parentGuiScreen;
|
|
||||||
|
|
||||||
public GuiReplaySettings(GuiScreen parentGuiScreen) {
|
|
||||||
this.parentGuiScreen = parentGuiScreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initGui() {
|
|
||||||
this.screenTitle = I18n.format("replaymod.gui.settings.title");
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
java.util.List<GuiButton> buttonList = this.buttonList;
|
|
||||||
|
|
||||||
buttonList.clear();
|
|
||||||
buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height - 27, I18n.format("gui.done")));
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
for(RecordingOptions o : RecordingOptions.values()) {
|
|
||||||
|
|
||||||
int xPos = this.width / 2 - 155 + i % 2 * 160;
|
|
||||||
int yPos = this.height / 6 + 24 * (i >> 1);
|
|
||||||
// TODO
|
|
||||||
// if(o == RecordingOptions.notifications) {
|
|
||||||
// GuiToggleButton sendChatButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_SEND_CHAT, xPos, yPos, 150, 20, o);
|
|
||||||
// buttonList.add(sendChatButton);
|
|
||||||
//
|
|
||||||
// } else if(o == RecordingOptions.recordServer) {
|
|
||||||
// GuiToggleButton recordServerButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_RECORDSERVER_ID, xPos, yPos, 150, 20, o);
|
|
||||||
// buttonList.add(recordServerButton);
|
|
||||||
//
|
|
||||||
// } else if(o == RecordingOptions.recordSingleplayer) {
|
|
||||||
// GuiToggleButton recordSPButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_RECORDSP_ID, xPos, yPos, 150, 20, o);
|
|
||||||
// buttonList.add(recordSPButton);
|
|
||||||
//
|
|
||||||
// } else if(o == RecordingOptions.indicator) {
|
|
||||||
// GuiToggleButton showIndicatorButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_INDICATOR_ID, xPos, yPos, 150, 20, o);
|
|
||||||
// buttonList.add(showIndicatorButton);
|
|
||||||
// }
|
|
||||||
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(i % 2 == 1) {
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(ReplayOptions o : ReplayOptions.values()) {
|
|
||||||
|
|
||||||
int xPos = this.width / 2 - 155 + i % 2 * 160;
|
|
||||||
int yPos = this.height / 6 + 24 * (i >> 1);
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
// if(o == ReplayOptions.linear) {
|
|
||||||
// GuiToggleButton linearButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_FORCE_LINEAR, xPos, yPos, 150, 20, o,
|
|
||||||
// I18n.format("replaymod.gui.settings.interpolation.linear"), I18n.format("replaymod.gui.settings.interpolation.cubic"));
|
|
||||||
// buttonList.add(linearButton);
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
// buttonList.add(new GuiSettingsOnOffButton(0, xPos, yPos, 150, 20, o));
|
|
||||||
// }
|
|
||||||
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i % 2 == 1) {
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
|
||||||
this.drawDefaultBackground();
|
|
||||||
this.drawCenteredString(this.fontRendererObj, screenTitle, this.width / 2, 20, 16777215);
|
|
||||||
if(FMLClientHandler.instance().getClient().thePlayer != null) {
|
|
||||||
this.drawCenteredString(this.fontRendererObj, I18n.format("replaymod.gui.settings.warning.linea"), this.width / 2, 180, Color.RED.getRGB());
|
|
||||||
this.drawCenteredString(this.fontRendererObj, I18n.format("replaymod.gui.settings.warning.lineb"), this.width / 2, 190, Color.RED.getRGB());
|
|
||||||
}
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void actionPerformed(GuiButton button) throws IOException {
|
|
||||||
if(button.enabled) {
|
|
||||||
switch(button.id) {
|
|
||||||
case 200:
|
|
||||||
this.mc.displayGuiScreen(this.parentGuiScreen);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,214 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui;
|
|
||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.GuiAdvancedButton;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
|
|
||||||
public class GuiReplaySpeedSlider extends GuiAdvancedButton {
|
|
||||||
|
|
||||||
private float sliderValue;
|
|
||||||
|
|
||||||
private float valueStep, valueMin, valueMax;
|
|
||||||
private String displayKey;
|
|
||||||
private boolean dragging = false;
|
|
||||||
|
|
||||||
public GuiReplaySpeedSlider(int xPos, int yPos, String displayKey) {
|
|
||||||
super(0, xPos, yPos, displayKey);
|
|
||||||
|
|
||||||
this.width = 100;
|
|
||||||
this.valueMin = 1;
|
|
||||||
this.valueMax = 38;
|
|
||||||
this.valueStep = 1;
|
|
||||||
this.displayKey = displayKey;
|
|
||||||
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void copyValueFrom(GuiReplaySpeedSlider other) {
|
|
||||||
sliderValue = other.sliderValue;
|
|
||||||
recalculateDisplayString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset() {
|
|
||||||
sliderValue = 9f / 38f;
|
|
||||||
recalculateDisplayString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float convertScale(float value) {
|
|
||||||
if(value == 10) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(value <= 9) {
|
|
||||||
return value / 10f;
|
|
||||||
}
|
|
||||||
return 1 + (0.25f * (value - 10));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getHoverState(boolean mouseOver) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
|
||||||
if(this.visible) {
|
|
||||||
try {
|
|
||||||
FontRenderer fontrenderer = mc.fontRendererObj;
|
|
||||||
mc.getTextureManager().bindTexture(buttonTextures);
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
this.hovered = isHovering(mouseX, mouseY);
|
|
||||||
int k = this.getHoverState(this.hovered);
|
|
||||||
GlStateManager.enableBlend();
|
|
||||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
|
||||||
GlStateManager.blendFunc(770, 771);
|
|
||||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
|
|
||||||
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height);
|
|
||||||
this.mouseDragged(mc, mouseX, mouseY);
|
|
||||||
int l = 14737632;
|
|
||||||
|
|
||||||
if(packedFGColour != 0) {
|
|
||||||
l = packedFGColour;
|
|
||||||
} else if(!this.enabled) {
|
|
||||||
l = 10526880;
|
|
||||||
} else if(this.hovered) {
|
|
||||||
l = 16777120;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l);
|
|
||||||
} catch(Exception e) {
|
|
||||||
// TODO: Fix exception
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String translate(float f) {
|
|
||||||
return f + "x";
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getSliderValue() {
|
|
||||||
return convertScale(normalizedToReal(sliderValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseDrag(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
if(this.visible) {
|
|
||||||
try {
|
|
||||||
if(this.dragging) {
|
|
||||||
sliderValue = (float) (mouseX - (this.xPosition + 4)) / (float) (this.width - 8);
|
|
||||||
sliderValue = MathHelper.clamp_float(sliderValue, 0.0F, 1.0F);
|
|
||||||
float f = denormalizeValue(sliderValue);
|
|
||||||
sliderValue = normalizeValue(f);
|
|
||||||
if(ReplayMod.replaySender.getReplaySpeed() != 0) {
|
|
||||||
ReplayMod.replaySender.setReplaySpeed(convertScale(normalizedToReal(sliderValue)));
|
|
||||||
}
|
|
||||||
recalculateDisplayString();
|
|
||||||
}
|
|
||||||
|
|
||||||
mc.getTextureManager().bindTexture(buttonTextures);
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
this.drawTexturedModalRect(this.xPosition + (int) (sliderValue * (float) (this.width - 8)), this.yPosition, 0, 66, 4, 20);
|
|
||||||
this.drawTexturedModalRect(this.xPosition + (int) (sliderValue * (float) (this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20);
|
|
||||||
} catch(Exception e) {
|
|
||||||
// TODO: Fix exception
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void recalculateDisplayString() {
|
|
||||||
this.displayString = displayKey + ": " + translate(convertScale(normalizedToReal(sliderValue)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public float normalizeValue(float p_148266_1_) {
|
|
||||||
return MathHelper.clamp_float((this.snapToStepClamp(p_148266_1_) - this.valueMin) / (this.valueMax - this.valueMin), 0.0F, 1.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
public float denormalizeValue(float p_148262_1_) {
|
|
||||||
return this.snapToStepClamp(this.valueMin + (this.valueMax - this.valueMin) * MathHelper.clamp_float(p_148262_1_, 0.0F, 1.0F));
|
|
||||||
}
|
|
||||||
|
|
||||||
public float snapToStepClamp(float p_148268_1_) {
|
|
||||||
p_148268_1_ = this.snapToStep(p_148268_1_);
|
|
||||||
return MathHelper.clamp_float(p_148268_1_, this.valueMin, this.valueMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected float snapToStep(float p_148264_1_) {
|
|
||||||
if(this.valueStep > 0.0F) {
|
|
||||||
p_148264_1_ = this.valueStep * (float) Math.round(p_148264_1_ / this.valueStep);
|
|
||||||
}
|
|
||||||
|
|
||||||
return p_148264_1_;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float normalizedToReal(float value) {
|
|
||||||
float min = 0 - valueMin;
|
|
||||||
float max = valueMax + min;
|
|
||||||
|
|
||||||
return Math.round(value * max - min);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
|
|
||||||
if(super.mousePressed(mc, mouseX, mouseY)) {
|
|
||||||
this.dragging = true;
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseReleased(int mouseX, int mouseY) {
|
|
||||||
this.dragging = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Minecraft mc, int mouseX, int mouseY) {
|
|
||||||
drawButton(mc, mouseX, mouseY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawOverlay(Minecraft mc, int mouseX, int mouseY) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isHovering(int mouseX, int mouseY) {
|
|
||||||
return mouseX >= this.xPosition
|
|
||||||
&& mouseY >= this.yPosition
|
|
||||||
&& mouseX < this.xPosition + this.width
|
|
||||||
&& mouseY < this.yPosition + this.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean mouseClick(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
return mousePressed(mc, mouseX, mouseY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseRelease(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
mouseReleased(mouseX, mouseY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void buttonPressed(Minecraft mc, int mouseX, int mouseY, char key, int keyCode) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick(Minecraft mc) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setElementEnabled(boolean enabled) {
|
|
||||||
this.enabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void mouseDragged(Minecraft mc, int mouseX, int mouseY) {
|
|
||||||
mouseDrag(mc, mouseX, mouseY, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.GuiAdvancedButton;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
|
|
||||||
public class GuiVideoFramerateSlider extends GuiAdvancedButton {
|
|
||||||
|
|
||||||
public boolean dragging;
|
|
||||||
private String displayKey;
|
|
||||||
private float sliderValue;
|
|
||||||
public GuiVideoFramerateSlider(int xPos, int yPos, int initialFramerate, String displayKey) {
|
|
||||||
super(xPos, yPos, 150, 20, "", null, null);
|
|
||||||
this.displayKey = displayKey;
|
|
||||||
setFPS(initialFramerate);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String translate(int value) {
|
|
||||||
return String.valueOf(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getHoverState(boolean mouseOver) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseDrag(Minecraft mc, int mouseX, int mouseY, int mouseButton) {
|
|
||||||
if(this.visible) {
|
|
||||||
if(this.dragging) {
|
|
||||||
sliderValue = (float) (mouseX - (this.xPosition + 4)) / (float) (this.width - 8);
|
|
||||||
sliderValue = MathHelper.clamp_float(sliderValue, 0.0F, 1.0F);
|
|
||||||
int f = denormalizeValue(sliderValue);
|
|
||||||
this.displayString = displayKey + ": " + translate(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
mc.getTextureManager().bindTexture(buttonTextures);
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
this.drawTexturedModalRect(this.xPosition + (int) (sliderValue * (float) (this.width - 8)), this.yPosition, 0, 66, 4, 20);
|
|
||||||
this.drawTexturedModalRect(this.xPosition + (int) (sliderValue * (float) (this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFPS() {
|
|
||||||
return denormalizeValue(sliderValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFPS(int fps) {
|
|
||||||
this.sliderValue = normalizeValue(fps);
|
|
||||||
this.displayString = displayKey + ": " + translate(fps);
|
|
||||||
}
|
|
||||||
|
|
||||||
private float normalizeValue(int val) {
|
|
||||||
return (val - 10) / 110f;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int denormalizeValue(float val) {
|
|
||||||
//Transfers the value ranging from 0.0 to 1.0 to the scale of 10 to 120
|
|
||||||
float r = 110f * val;
|
|
||||||
return Math.round(10 + r);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean mouseClick(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
if(super.mousePressed(mc, mouseX, mouseY)) {
|
|
||||||
this.dragging = true;
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseRelease(Minecraft mc, int mouseX, int mouseY, int mouseButton) {
|
|
||||||
this.dragging = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void mouseDragged(Minecraft mc, int mouseX, int mouseY) {
|
|
||||||
mouseDrag(mc, mouseX, mouseY, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package eu.crushedpixel.replaymod.gui.elements;
|
package eu.crushedpixel.replaymod.gui.elements;
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.utils.OpenGLUtils;
|
import com.replaymod.core.utils.OpenGLUtils;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui.elements;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
|
||||||
import eu.crushedpixel.replaymod.utils.RoundUtils;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
|
||||||
|
|
||||||
public class GuiDraggingNumberInput extends GuiNumberInputWithText {
|
|
||||||
|
|
||||||
public GuiDraggingNumberInput(FontRenderer fontRenderer,
|
|
||||||
int xPos, int yPos, int width, Double minimum, Double maximum, Double defaultValue, boolean acceptFloats) {
|
|
||||||
this(fontRenderer, xPos, yPos, width, minimum, maximum, defaultValue, acceptFloats, "", 0.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiDraggingNumberInput(FontRenderer fontRenderer,
|
|
||||||
int xPos, int yPos, int width, Double minimum,
|
|
||||||
Double maximum, Double defaultValue, boolean acceptFloats, String suffix, double stepSize) {
|
|
||||||
super(fontRenderer, xPos, yPos, width, minimum, maximum, defaultValue, acceptFloats, suffix);
|
|
||||||
|
|
||||||
this.stepSize = stepSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int prevMouseX;
|
|
||||||
private boolean dragging;
|
|
||||||
private boolean clicked;
|
|
||||||
|
|
||||||
private double stepSize;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean mouseClick(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
if(MouseUtils.isMouseWithinBounds(xPosition, yPosition, width, height) && isEnabled) {
|
|
||||||
dragging = false;
|
|
||||||
clicked = true;
|
|
||||||
prevMouseX = mouseX;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseDrag(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
if(clicked && mouseX != prevMouseX) {
|
|
||||||
dragging = true;
|
|
||||||
int diff = mouseX - prevMouseX;
|
|
||||||
prevMouseX = mouseX;
|
|
||||||
|
|
||||||
double value = getPreciseValue();
|
|
||||||
double valueDiff = diff * stepSize;
|
|
||||||
|
|
||||||
this.setValue(RoundUtils.round2Decimals(value + valueDiff));
|
|
||||||
}
|
|
||||||
super.mouseDrag(mc, mouseX, mouseY, button);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseRelease(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
clicked = false;
|
|
||||||
if(!dragging) {
|
|
||||||
super.mouseClick(mc, mouseX, mouseY, button);
|
|
||||||
}
|
|
||||||
super.mouseRelease(mc, mouseX, mouseY, button);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,255 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui.elements;
|
|
||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.listeners.SelectionListener;
|
|
||||||
import eu.crushedpixel.replaymod.holders.GuiEntryListEntry;
|
|
||||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
|
||||||
import org.lwjgl.input.Mouse;
|
|
||||||
import org.lwjgl.util.Point;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GuiDropdown<T extends GuiEntryListEntry> extends GuiAdvancedTextField implements GuiOverlayElement {
|
|
||||||
|
|
||||||
private final int visibleDropout;
|
|
||||||
private final int dropoutElementHeight = 14;
|
|
||||||
private final int maxDropoutHeight;
|
|
||||||
private int selectionIndex = -1;
|
|
||||||
private boolean open = false;
|
|
||||||
private List<SelectionListener> selectionListeners = new ArrayList<SelectionListener>();
|
|
||||||
|
|
||||||
private int upperIndex = 0;
|
|
||||||
private List<T> elements = new ArrayList<T>();
|
|
||||||
private HashMap<Integer, String> hoverTexts = new HashMap<Integer, String>();
|
|
||||||
|
|
||||||
public GuiDropdown(FontRenderer fontRenderer,
|
|
||||||
int xPos, int yPos, int width, int visibleDropout) {
|
|
||||||
super(fontRenderer, xPos, yPos, width, 20);
|
|
||||||
this.visibleDropout = visibleDropout;
|
|
||||||
this.maxDropoutHeight = dropoutElementHeight * visibleDropout;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public void drawTextBox() {
|
|
||||||
Point mousePos = MouseUtils.getMousePos();
|
|
||||||
draw(Minecraft.getMinecraft(), mousePos.getX(), mousePos.getY());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Minecraft mc, int mouseX, int mouseY) {
|
|
||||||
if(elements.size() > selectionIndex && selectionIndex >= 0) {
|
|
||||||
setText(mc.fontRendererObj.trimStringToWidth(
|
|
||||||
elements.get(selectionIndex).getDisplayString(), width - 8));
|
|
||||||
} else {
|
|
||||||
setText("");
|
|
||||||
}
|
|
||||||
super.drawTextBox();
|
|
||||||
|
|
||||||
//Draw the right part of the Dropdown
|
|
||||||
drawRect(xPosition + width - height, yPosition, xPosition + width, yPosition + height, -16777216);
|
|
||||||
drawRect(xPosition + width - height, yPosition, this.xPosition + width - height + 1, yPosition + height, -6250336);
|
|
||||||
|
|
||||||
//heroically draw the triangle line by line instead of using a texture
|
|
||||||
for(int i = 0; i <= Math.ceil(height / 2) - 4; i++) {
|
|
||||||
drawHorizontalLine(xPosition + width - height + i + 4, xPosition + width - i - 4, yPosition + (height / 4) + i + 2, -6250336);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean drawHover = false;
|
|
||||||
Point hoverPos = null;
|
|
||||||
String hoverText = null;
|
|
||||||
|
|
||||||
if(open && elements.size() > 0) {
|
|
||||||
//draw the dropout part when opened
|
|
||||||
|
|
||||||
boolean drawScrollBar = false;
|
|
||||||
|
|
||||||
int requiredHeight = elements.size() * dropoutElementHeight;
|
|
||||||
if(requiredHeight > maxDropoutHeight) {
|
|
||||||
requiredHeight = maxDropoutHeight;
|
|
||||||
drawScrollBar = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//The light outline
|
|
||||||
drawRect(xPosition - 1, yPosition + height, xPosition + width + 1, yPosition + height + requiredHeight + 1, -6250336);
|
|
||||||
|
|
||||||
//The dark inside
|
|
||||||
drawRect(xPosition, yPosition + height + 1, xPosition + width, yPosition + height + requiredHeight, -16777216);
|
|
||||||
|
|
||||||
//The elements
|
|
||||||
int y = 0;
|
|
||||||
int i = 0;
|
|
||||||
for(T obj : elements) {
|
|
||||||
if(i < upperIndex) {
|
|
||||||
i++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
drawHorizontalLine(xPosition, xPosition + width, yPosition + height + y, -6250336);
|
|
||||||
String toWrite = mc.fontRendererObj.trimStringToWidth(obj.getDisplayString(), width - 8);
|
|
||||||
drawString(mc.fontRendererObj, toWrite, xPosition + 4, yPosition + height + y + 4, Color.WHITE.getRGB());
|
|
||||||
|
|
||||||
if(MouseUtils.isMouseWithinBounds(xPosition, yPosition + height + y, width, dropoutElementHeight)) {
|
|
||||||
String hover = hoverTexts.get(i);
|
|
||||||
if(hover != null) {
|
|
||||||
Point mousePos = MouseUtils.getMousePos();
|
|
||||||
drawHover = true;
|
|
||||||
hoverPos = mousePos;
|
|
||||||
hoverText = hover;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
y += dropoutElementHeight;
|
|
||||||
i++;
|
|
||||||
if(y >= requiredHeight) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(drawScrollBar) {
|
|
||||||
//The scroll bar
|
|
||||||
int dw = 0;
|
|
||||||
|
|
||||||
if(isHovering(mouseX, mouseY)) {
|
|
||||||
dw = Mouse.getDWheel();
|
|
||||||
if(dw > 0) {
|
|
||||||
dw = -1;
|
|
||||||
} else if(dw < 0) {
|
|
||||||
dw = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
upperIndex = Math.max(Math.min(upperIndex + dw, elements.size() - visibleDropout), 0);
|
|
||||||
|
|
||||||
drawRect(xPosition + width - 3, yPosition + height + 1, xPosition + width, yPosition + height + requiredHeight, Color.DARK_GRAY.getRGB());
|
|
||||||
|
|
||||||
float visiblePerc = ((float) visibleDropout) / elements.size();
|
|
||||||
int barHeight = (int) (visiblePerc * (requiredHeight - 1));
|
|
||||||
|
|
||||||
float posPerc = ((float) upperIndex) / elements.size();
|
|
||||||
int barY = (int) (posPerc * (requiredHeight - 1));
|
|
||||||
|
|
||||||
drawRect(xPosition + width - 3, yPosition + height + barY, xPosition + width, yPosition + height + 2 + barY + barHeight, -6250336);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(drawHover) {
|
|
||||||
ReplayMod.tooltipRenderer.drawTooltip(hoverPos.getX(), hoverPos.getY(), hoverText, null, Color.WHITE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean mouseClick(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
return mouseClickedResult(mouseX, mouseY);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean mouseClickedResult(int xPos, int yPos) {
|
|
||||||
if(!isEnabled) return false;
|
|
||||||
boolean success = false;
|
|
||||||
if(xPos > xPosition + width - height && xPos < xPosition + width && yPos > yPosition && yPos < yPosition + height) {
|
|
||||||
open = !open;
|
|
||||||
} else {
|
|
||||||
if(xPos > xPosition && xPos < xPosition + width && open) {
|
|
||||||
int requiredHeight = Math.min(maxDropoutHeight, elements.size() * dropoutElementHeight);
|
|
||||||
if(yPos > yPosition + height && yPos < yPosition + height + requiredHeight) {
|
|
||||||
this.selectionIndex = (int) Math.floor((yPos - (yPosition + height)) / dropoutElementHeight) + upperIndex;
|
|
||||||
success = true;
|
|
||||||
fireSelectionChangeEvent();
|
|
||||||
}
|
|
||||||
open = false;
|
|
||||||
} else {
|
|
||||||
open = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isHovering(int mouseX, int mouseY) {
|
|
||||||
if(isExpanded()) {
|
|
||||||
int requiredHeight = Math.min(elements.size() * dropoutElementHeight, maxDropoutHeight);
|
|
||||||
|
|
||||||
return mouseX >= xPosition
|
|
||||||
&& mouseY >= yPosition
|
|
||||||
&& mouseX < xPosition + width
|
|
||||||
&& mouseY < yPosition + height + requiredHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.isHovering(mouseX, mouseY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setText(String text) {
|
|
||||||
if(!getText().equals(text)) {
|
|
||||||
super.setText(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setElements(List<T> elements) {
|
|
||||||
this.elements = elements;
|
|
||||||
if(selectionIndex == -1 && elements.size() > 0) {
|
|
||||||
selectionIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearElements() {
|
|
||||||
this.elements = new ArrayList<T>();
|
|
||||||
selectionIndex = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addElement(T element) {
|
|
||||||
this.elements.add(element);
|
|
||||||
if(selectionIndex == -1) {
|
|
||||||
selectionIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHoverText(int index, String text) {
|
|
||||||
hoverTexts.put(index, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public T getElement(int index) {
|
|
||||||
return elements.get(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<T> getAllElements() {
|
|
||||||
return elements;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSelectionIndex() {
|
|
||||||
return selectionIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelectionIndex(int index) {
|
|
||||||
setSelectionIndexQuietly(index);
|
|
||||||
fireSelectionChangeEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the selection index without notifying SelectionChangeListeners.
|
|
||||||
* @param index The Selection Index
|
|
||||||
*/
|
|
||||||
public void setSelectionIndexQuietly(int index) {
|
|
||||||
this.selectionIndex = index;
|
|
||||||
if(selectionIndex < 0) selectionIndex = -1;
|
|
||||||
if(selectionIndex >= elements.size()) selectionIndex = elements.size()-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fireSelectionChangeEvent() {
|
|
||||||
for(SelectionListener listener : selectionListeners) {
|
|
||||||
listener.onSelectionChanged(selectionIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addSelectionListener(SelectionListener listener) {
|
|
||||||
this.selectionListeners.add(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isExpanded() {
|
|
||||||
return open;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,187 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui.elements;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.listeners.SelectionListener;
|
|
||||||
import eu.crushedpixel.replaymod.holders.GuiEntryListEntry;
|
|
||||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
|
||||||
import org.lwjgl.input.Mouse;
|
|
||||||
import org.lwjgl.util.Point;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GuiEntryList<T extends GuiEntryListEntry> extends GuiAdvancedTextField {
|
|
||||||
|
|
||||||
public final static int elementHeight = 14;
|
|
||||||
private int selectionIndex = -1;
|
|
||||||
private int visibleElements;
|
|
||||||
private int upperIndex = 0;
|
|
||||||
|
|
||||||
private String emptyMessage = null;
|
|
||||||
|
|
||||||
private List<SelectionListener> selectionListeners = new ArrayList<SelectionListener>();
|
|
||||||
private List<T> elements = new ArrayList<T>();
|
|
||||||
|
|
||||||
public GuiEntryList(FontRenderer fontRenderer,
|
|
||||||
int xPos, int yPos, int width, int visibleEntries) {
|
|
||||||
super(fontRenderer, xPos, yPos, width, elementHeight * visibleEntries - 1);
|
|
||||||
this.visibleElements = visibleEntries;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVisibleElements(int rows) {
|
|
||||||
this.visibleElements = rows;
|
|
||||||
this.height = elementHeight * visibleElements - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEmptyMessage(String emptyMessage) {
|
|
||||||
this.emptyMessage = emptyMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public void drawTextBox() {
|
|
||||||
Point mousePos = MouseUtils.getMousePos();
|
|
||||||
draw(Minecraft.getMinecraft(), mousePos.getX(), mousePos.getY());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Minecraft mc, int mouseX, int mouseY) {
|
|
||||||
try {
|
|
||||||
super.drawTextBox();
|
|
||||||
|
|
||||||
if(elements.size() == 0 && emptyMessage != null) {
|
|
||||||
drawCenteredString(mc.fontRendererObj, emptyMessage,
|
|
||||||
xPosition+(width/2), yPosition+(height/2)-(mc.fontRendererObj.FONT_HEIGHT/2), Color.RED.getRGB());
|
|
||||||
}
|
|
||||||
|
|
||||||
//drawing the entries
|
|
||||||
for(int i = 0; i - upperIndex < visibleElements; i++) {
|
|
||||||
if(i < upperIndex) continue;
|
|
||||||
|
|
||||||
if(i >= elements.size()) break;
|
|
||||||
|
|
||||||
if(i == selectionIndex) {
|
|
||||||
drawRect(xPosition, yPosition + (i - upperIndex) * elementHeight, xPosition + width,
|
|
||||||
yPosition + (i + 1 - upperIndex) * elementHeight - 1, Color.GRAY.getRGB());
|
|
||||||
}
|
|
||||||
|
|
||||||
drawRect(xPosition, yPosition + (i + 1 - upperIndex) * elementHeight - 1, xPosition + width,
|
|
||||||
yPosition + (i + 1 - upperIndex) * elementHeight, -6250336);
|
|
||||||
drawString(mc.fontRendererObj, mc.fontRendererObj.trimStringToWidth(elements.get(i).getDisplayString(), width - 4),
|
|
||||||
xPosition + 2, yPosition + (i - upperIndex) * elementHeight + 3, Color.WHITE.getRGB());
|
|
||||||
}
|
|
||||||
|
|
||||||
//drawing the scroll bar
|
|
||||||
if(elements.size() > visibleElements) {
|
|
||||||
//handle scroll events
|
|
||||||
int dw = 0;
|
|
||||||
|
|
||||||
if(isHovering(mouseX, mouseY)) {
|
|
||||||
dw = Mouse.getDWheel();
|
|
||||||
if(dw > 0) {
|
|
||||||
dw = -1;
|
|
||||||
} else if(dw < 0) {
|
|
||||||
dw = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
upperIndex = Math.max(Math.min(upperIndex + dw, elements.size() - visibleElements), 0);
|
|
||||||
|
|
||||||
float visiblePerc = ((float) visibleElements) / elements.size();
|
|
||||||
int barHeight = (int) (visiblePerc * (height - 1));
|
|
||||||
|
|
||||||
float posPerc = ((float) upperIndex) / elements.size();
|
|
||||||
int barY = (int) (posPerc * (height - 1));
|
|
||||||
|
|
||||||
drawRect(xPosition + width - 3, yPosition, xPosition + width, yPosition + height, Color.DARK_GRAY.getRGB());
|
|
||||||
drawRect(xPosition + width - 3, yPosition + barY, xPosition + width, yPosition + 1 + barY + barHeight, -6250336);
|
|
||||||
}
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(int xPos, int yPos, int mouseButton) {
|
|
||||||
if(!(xPos >= xPosition && xPos <= xPosition + width && yPos >= yPosition && yPos <= yPosition + height)) return;
|
|
||||||
int clickedIndex = (int) Math.floor((yPos - yPosition) / elementHeight) + upperIndex;
|
|
||||||
if(clickedIndex < elements.size() && clickedIndex >= 0) {
|
|
||||||
selectionIndex = clickedIndex;
|
|
||||||
fireSelectionChangeEvent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fireSelectionChangeEvent() {
|
|
||||||
for(SelectionListener listener : selectionListeners) {
|
|
||||||
listener.onSelectionChanged(selectionIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setText(String text) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setElements(List<T> elements) {
|
|
||||||
this.elements = elements;
|
|
||||||
if(selectionIndex == -1 && elements.size() > 0) {
|
|
||||||
selectionIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addElement(T element) {
|
|
||||||
if(element == null) return;
|
|
||||||
this.elements.add(element);
|
|
||||||
selectionIndex = elements.size()-1;
|
|
||||||
fireSelectionChangeEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public T getElement(int index) {
|
|
||||||
if(index >= 0) {
|
|
||||||
return elements.get(index);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeElement(int index) {
|
|
||||||
elements.remove(index);
|
|
||||||
if(selectionIndex >= elements.size()) {
|
|
||||||
selectionIndex = elements.size()-1;
|
|
||||||
}
|
|
||||||
fireSelectionChangeEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSelectionIndex() {
|
|
||||||
return selectionIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelectionIndex(int index) {
|
|
||||||
this.selectionIndex = index;
|
|
||||||
if(selectionIndex < 0) selectionIndex = -1;
|
|
||||||
fireSelectionChangeEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<T> getCopyOfElements() {
|
|
||||||
return new ArrayList<T>(elements);
|
|
||||||
}
|
|
||||||
public List<T> getElements() {
|
|
||||||
return elements;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
public void replaceElement(int index, T replace) {
|
|
||||||
elements.set(index, replace);
|
|
||||||
fireSelectionChangeEvent();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public int getEntryCount() {
|
|
||||||
return elements.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addSelectionListener(SelectionListener listener) {
|
|
||||||
this.selectionListeners.add(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,168 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui.elements;
|
|
||||||
|
|
||||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
|
||||||
import com.replaymod.online.api.replay.holders.Category;
|
|
||||||
import com.replaymod.online.api.replay.holders.FileInfo;
|
|
||||||
import eu.crushedpixel.replaymod.registry.ResourceHelper;
|
|
||||||
import eu.crushedpixel.replaymod.utils.DurationUtils;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.Gui;
|
|
||||||
import net.minecraft.client.gui.GuiListExtended.IGuiListEntry;
|
|
||||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class GuiReplayListEntry implements IGuiListEntry {
|
|
||||||
|
|
||||||
private final DateFormat dateFormat = new SimpleDateFormat();
|
|
||||||
boolean registered = false;
|
|
||||||
private Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
private FileInfo fileInfo;
|
|
||||||
private ResourceLocation textureResource;
|
|
||||||
private DynamicTexture dynTex = null;
|
|
||||||
private File imageFile;
|
|
||||||
private GuiReplayListExtended parent;
|
|
||||||
|
|
||||||
public GuiReplayListEntry(GuiReplayListExtended parent, FileInfo fileInfo, File imageFile) {
|
|
||||||
this.fileInfo = fileInfo;
|
|
||||||
this.parent = parent;
|
|
||||||
dynTex = null;
|
|
||||||
this.imageFile = imageFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileInfo getFileInfo() {
|
|
||||||
return fileInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected) {
|
|
||||||
boolean online = fileInfo.getDownloads() >= 0;
|
|
||||||
|
|
||||||
try {
|
|
||||||
if(fileInfo.getName() == null || fileInfo.getName().length() < 1) {
|
|
||||||
fileInfo.setName("No Name");
|
|
||||||
}
|
|
||||||
mc.fontRendererObj.drawString(ChatFormatting.UNDERLINE.toString()+fileInfo.getName(), x + 3, y + 1, 16777215);
|
|
||||||
|
|
||||||
int thumbnailOffset = -5;
|
|
||||||
|
|
||||||
if(y < -slotHeight || y > parent.height) {
|
|
||||||
if(registered) {
|
|
||||||
registered = false;
|
|
||||||
ResourceHelper.freeResource(textureResource);
|
|
||||||
textureResource = null;
|
|
||||||
dynTex = null;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
if(!registered) {
|
|
||||||
textureResource = new ResourceLocation("thumbs/" + fileInfo.getName() + fileInfo.getId());
|
|
||||||
BufferedImage image;
|
|
||||||
if(imageFile == null) {
|
|
||||||
image = ResourceHelper.getDefaultThumbnail();
|
|
||||||
} else {
|
|
||||||
image = ImageIO.read(imageFile);
|
|
||||||
}
|
|
||||||
if(image == null) {
|
|
||||||
image = ResourceHelper.getDefaultThumbnail();
|
|
||||||
}
|
|
||||||
dynTex = new DynamicTexture(image);
|
|
||||||
mc.getTextureManager().loadTexture(textureResource, dynTex);
|
|
||||||
dynTex.updateDynamicTexture();
|
|
||||||
ResourceHelper.registerResource(textureResource);
|
|
||||||
registered = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
mc.getTextureManager().bindTexture(textureResource);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(x - (int) (slotHeight * (16 / 9f)) + thumbnailOffset, y, 0, 0, 1280, 720, (int) (slotHeight * (16 / 9f)), slotHeight, 1280, 720);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(online) {
|
|
||||||
String downloads = fileInfo.getDownloads() + " ⬇";
|
|
||||||
int downloadsWidth = mc.fontRendererObj.getStringWidth(downloads);
|
|
||||||
|
|
||||||
Gui.drawRect(x + thumbnailOffset - 2 - downloadsWidth - 1, y + slotHeight - (mc.fontRendererObj.FONT_HEIGHT + 2) * 2,
|
|
||||||
x + thumbnailOffset, y + slotHeight - (mc.fontRendererObj.FONT_HEIGHT + 2), 0x80000000);
|
|
||||||
|
|
||||||
mc.fontRendererObj.drawStringWithShadow(downloads, x + thumbnailOffset - 1 - downloadsWidth,
|
|
||||||
y + slotHeight - (mc.fontRendererObj.FONT_HEIGHT) * 2 - 2, Color.WHITE.getRGB());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(fileInfo != null && fileInfo.getMetadata() != null) {
|
|
||||||
String duration = DurationUtils.convertSecondsToShortString(fileInfo.getMetadata().getDuration() / 1000);
|
|
||||||
int durationWidth = mc.fontRendererObj.getStringWidth(duration);
|
|
||||||
|
|
||||||
Gui.drawRect(x + thumbnailOffset - 2 - durationWidth - 1, y + slotHeight - mc.fontRendererObj.FONT_HEIGHT - 2, x + thumbnailOffset, y + slotHeight,
|
|
||||||
0x80000000);
|
|
||||||
|
|
||||||
mc.fontRendererObj.drawStringWithShadow(duration, x + thumbnailOffset - 1 - durationWidth,
|
|
||||||
y + slotHeight - mc.fontRendererObj.FONT_HEIGHT, Color.WHITE.getRGB());
|
|
||||||
|
|
||||||
String serverName = fileInfo.getMetadata().getServerName();
|
|
||||||
if(serverName == null) serverName = ChatFormatting.DARK_RED.toString()+I18n.format("replaymod.gui.iphidden");
|
|
||||||
|
|
||||||
mc.fontRendererObj.drawStringWithShadow(serverName, x + 3, y + (online ? 25 : 13), Color.LIGHT_GRAY.getRGB());
|
|
||||||
|
|
||||||
String dateRecorded = dateFormat.format(new Date(fileInfo.getMetadata().getDate()));
|
|
||||||
int dateWidth = mc.fontRendererObj.getStringWidth(dateRecorded);
|
|
||||||
mc.fontRendererObj.drawStringWithShadow(dateRecorded, x + (online ? listWidth - 9 - dateWidth : 3), y + (online ? 13 : 23), Color.LIGHT_GRAY.getRGB());
|
|
||||||
|
|
||||||
|
|
||||||
if(online) {
|
|
||||||
String owner = I18n.format("replaymod.gui.center.author", ChatFormatting.GRAY.toString()+ChatFormatting.ITALIC, fileInfo.getOwner());
|
|
||||||
|
|
||||||
mc.fontRendererObj.drawStringWithShadow(ChatFormatting.RESET.toString()+owner, x + 3, y + 13, Color.WHITE.getRGB());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(online) {
|
|
||||||
Category category = Category.fromId(fileInfo.getCategory());
|
|
||||||
if (category == null) {
|
|
||||||
category = Category.MISCELLANEOUS;
|
|
||||||
}
|
|
||||||
mc.fontRendererObj.drawStringWithShadow(ChatFormatting.ITALIC.toString()+category.toNiceString(), x + 3, y + slotHeight - mc.fontRendererObj.FONT_HEIGHT, Color.GRAY.getRGB());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(fileInfo.getRatings() != null) {
|
|
||||||
String thumbsString = ChatFormatting.GOLD.toString()+"⭑"+fileInfo.getFavorites()+ChatFormatting.GREEN.toString()+" ⬆"
|
|
||||||
+ fileInfo.getRatings().getPositive() + ChatFormatting.RED.toString()+" ⬇" + fileInfo.getRatings().getNegative();
|
|
||||||
int stringWidth = mc.fontRendererObj.getStringWidth(thumbsString);
|
|
||||||
|
|
||||||
mc.fontRendererObj.drawString(thumbsString, x + listWidth - stringWidth - 5, y + slotHeight - mc.fontRendererObj.FONT_HEIGHT, Color.GREEN.getRGB());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSelected(int p_178011_1_, int p_178011_2_, int p_178011_3_) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean mousePressed(int p_148278_1_, int p_148278_2_,
|
|
||||||
int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_) {
|
|
||||||
for(int slot = 0; slot < parent.getSize(); slot++) {
|
|
||||||
if(parent.getListEntry(slot) == this) {
|
|
||||||
parent.elementClicked(slot, false, p_148278_5_, p_148278_6_);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseReleased(int slotIndex, int x, int y, int mouseEvent,
|
|
||||||
int relativeX, int relativeY) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,254 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui.elements.timelines;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.holders.Keyframe;
|
|
||||||
|
|
||||||
public class GuiKeyframeTimeline extends GuiTimeline {
|
|
||||||
private static final int KEYFRAME_PLACE_X = 74;
|
|
||||||
private static final int KEYFRAME_PLACE_Y = 20;
|
|
||||||
private static final int KEYFRAME_TIME_X = 74;
|
|
||||||
private static final int KEYFRAME_TIME_Y = 25;
|
|
||||||
private static final int KEYFRAME_SPEC_X = 74;
|
|
||||||
private static final int KEYFRAME_SPEC_Y = 30;
|
|
||||||
|
|
||||||
private Keyframe clickedKeyFrame;
|
|
||||||
private long clickTime;
|
|
||||||
private boolean dragging;
|
|
||||||
private boolean timeKeyframes;
|
|
||||||
private boolean placeKeyframes;
|
|
||||||
|
|
||||||
public GuiKeyframeTimeline(int positionX, int positionY, int width, int height, boolean showMarkers,
|
|
||||||
boolean showPlaceKeyframes, boolean showTimeKeyframes) {
|
|
||||||
super(positionX, positionY, width, height);
|
|
||||||
this.showMarkers = showMarkers;
|
|
||||||
this.timeKeyframes = showTimeKeyframes;
|
|
||||||
this.placeKeyframes = showPlaceKeyframes;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
// @Override
|
|
||||||
// public boolean mouseClick(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
// if(!enabled) return false;
|
|
||||||
//
|
|
||||||
// long time = getTimeAt(mouseX, mouseY);
|
|
||||||
// if(time == -1) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// int tolerance = (int) (2 * Math.round(zoom * timelineLength / width));
|
|
||||||
//
|
|
||||||
// Keyframe closest;
|
|
||||||
// if(mouseY >= positionY + BORDER_TOP + 5 && timeKeyframes) {
|
|
||||||
// closest = ReplayHandler.getTimeKeyframes().getClosestKeyframeForTimestamp((int) time, tolerance);
|
|
||||||
// } else if(mouseY >= positionY + BORDER_TOP && placeKeyframes) {
|
|
||||||
// closest = ReplayHandler.getPositionKeyframes().getClosestKeyframeForTimestamp((int) time, tolerance);
|
|
||||||
// } else {
|
|
||||||
// closest = null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //left mouse button
|
|
||||||
// if(button == 0) {
|
|
||||||
// ReplayHandler.selectKeyframe(closest); //can be null, deselects property
|
|
||||||
//
|
|
||||||
// // If we clicked on a key frame, then continue monitoring the mouse for movements
|
|
||||||
// long currentTime = System.currentTimeMillis();
|
|
||||||
// if(closest != null) {
|
|
||||||
// if(currentTime - clickTime < 500) { // if double clicked then open GUI instead
|
|
||||||
// mc.displayGuiScreen(GuiEditKeyframe.create(closest));
|
|
||||||
// this.clickedKeyFrame = null;
|
|
||||||
// } else {
|
|
||||||
// this.clickedKeyFrame = closest;
|
|
||||||
// this.dragging = false;
|
|
||||||
// }
|
|
||||||
// } else { // If we didn't then just update the cursor
|
|
||||||
// ReplayHandler.setRealTimelineCursor((int) time);
|
|
||||||
// this.dragging = true;
|
|
||||||
// }
|
|
||||||
// this.clickTime = currentTime;
|
|
||||||
//
|
|
||||||
// } else if(button == 1) {
|
|
||||||
// if(closest != null) {
|
|
||||||
// if(closest.getValue() instanceof AdvancedPosition) {
|
|
||||||
// AdvancedPosition pos = (AdvancedPosition)closest.getValue();
|
|
||||||
// ReplayHandler.getCameraEntity().movePath(pos);
|
|
||||||
// } else if(closest.getValue() instanceof TimestampValue) {
|
|
||||||
// ReplayMod.overlay.performJump(((TimestampValue)closest.getValue()).asInt());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return isHovering(mouseX, mouseY);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void mouseDrag(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
// if(!enabled) return;
|
|
||||||
// long time = getTimeAt(mouseX, mouseY);
|
|
||||||
// if (time != -1) {
|
|
||||||
// if (clickedKeyFrame != null) {
|
|
||||||
// int tolerance = (int) (2 * Math.round(zoom * timelineLength / width));
|
|
||||||
//
|
|
||||||
// if (dragging || Math.abs(clickedKeyFrame.getRealTimestamp() - time) > tolerance) {
|
|
||||||
// clickedKeyFrame.setRealTimestamp((int) time);
|
|
||||||
// ReplayHandler.getPositionKeyframes().sort();
|
|
||||||
// ReplayHandler.getTimeKeyframes().sort();
|
|
||||||
// dragging = true;
|
|
||||||
// }
|
|
||||||
// } else if (dragging) {
|
|
||||||
// ReplayHandler.setRealTimelineCursor((int) time);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void mouseRelease(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
// mouseDrag(mc, mouseX, mouseY, button);
|
|
||||||
// clickedKeyFrame = null;
|
|
||||||
// dragging = false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void draw(Minecraft mc, int mouseX, int mouseY) {
|
|
||||||
// super.draw(mc, mouseX, mouseY);
|
|
||||||
//
|
|
||||||
// int bodyWidth = width - BORDER_LEFT - BORDER_RIGHT;
|
|
||||||
//
|
|
||||||
// long leftTime = Math.round(timeStart * timelineLength);
|
|
||||||
// long rightTime = Math.round((timeStart + zoom) * timelineLength);
|
|
||||||
//
|
|
||||||
// double segmentLength = timelineLength * zoom;
|
|
||||||
//
|
|
||||||
// //iterate over keyframes to find spectator segments
|
|
||||||
// if(placeKeyframes) {
|
|
||||||
// ListIterator<Keyframe<AdvancedPosition>> iterator = ReplayHandler.getPositionKeyframes().listIterator();
|
|
||||||
// while(iterator.hasNext()) {
|
|
||||||
// Keyframe<AdvancedPosition> kf = iterator.next();
|
|
||||||
//
|
|
||||||
// if(!(kf.getValue() instanceof SpectatorData))
|
|
||||||
// continue;
|
|
||||||
//
|
|
||||||
// int i = iterator.nextIndex();
|
|
||||||
// int nextSpectatorKeyframeRealTime = -1;
|
|
||||||
//
|
|
||||||
// if (iterator.hasNext()) {
|
|
||||||
// Keyframe<AdvancedPosition> kf2 = iterator.next();
|
|
||||||
//
|
|
||||||
// if(kf2.getValue() instanceof SpectatorData) {
|
|
||||||
// SpectatorData spectatorData1 = (SpectatorData)kf.getValue();
|
|
||||||
// SpectatorData spectatorData2 = (SpectatorData)kf2.getValue();
|
|
||||||
//
|
|
||||||
// if(spectatorData1.getSpectatedEntityID() == spectatorData2.getSpectatedEntityID()) {
|
|
||||||
// nextSpectatorKeyframeRealTime = kf2.getRealTimestamp();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// int i2 = iterator.previousIndex();
|
|
||||||
//
|
|
||||||
// while(i2 >= i) {
|
|
||||||
// iterator.previous();
|
|
||||||
// i2--;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(nextSpectatorKeyframeRealTime != -1) {
|
|
||||||
// int keyframeX = getKeyframeX(kf.getRealTimestamp(), leftTime, bodyWidth, segmentLength);
|
|
||||||
// int nextX = getKeyframeX(nextSpectatorKeyframeRealTime, leftTime, bodyWidth, segmentLength);
|
|
||||||
//
|
|
||||||
// int color = ((SpectatorData)kf.getValue()).getSpectatingMethod().getColor();
|
|
||||||
//
|
|
||||||
// drawRect(Math.max(keyframeX + 2, positionX+BORDER_LEFT), positionY + BORDER_TOP + 1, Math.min(nextX - 2, positionX+width-BORDER_RIGHT+1),
|
|
||||||
// positionY + BORDER_TOP + 4, color);
|
|
||||||
//
|
|
||||||
// GlStateManager.color(1, 1, 1, 1);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //iterate over time keyframes to find negative replay speeds
|
|
||||||
// if(timeKeyframes) {
|
|
||||||
// ListIterator<Keyframe<TimestampValue>> iterator = ReplayHandler.getTimeKeyframes().listIterator();
|
|
||||||
// while(iterator.hasNext()) {
|
|
||||||
// Keyframe<TimestampValue> kf = iterator.next();
|
|
||||||
//
|
|
||||||
// int i = iterator.nextIndex();
|
|
||||||
// int nextTimeKeyframeRealTime = -1;
|
|
||||||
//
|
|
||||||
// if (iterator.hasNext()) {
|
|
||||||
// Keyframe<TimestampValue> kf2 = iterator.next();
|
|
||||||
// if(kf.getValue().asInt() > kf2.getValue().asInt()) {
|
|
||||||
// nextTimeKeyframeRealTime = kf2.getRealTimestamp();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// int i2 = iterator.previousIndex();
|
|
||||||
//
|
|
||||||
// while(i2 >= i) {
|
|
||||||
// iterator.previous();
|
|
||||||
// i2--;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(nextTimeKeyframeRealTime != -1) {
|
|
||||||
// int keyframeX = getKeyframeX(kf.getRealTimestamp(), leftTime, bodyWidth, segmentLength);
|
|
||||||
// int nextX = getKeyframeX(nextTimeKeyframeRealTime, leftTime, bodyWidth, segmentLength);
|
|
||||||
//
|
|
||||||
// drawGradientRect(Math.max(keyframeX + 2, positionX+BORDER_LEFT), positionY + BORDER_TOP + 6, Math.min(nextX - 2, positionX+width-BORDER_RIGHT+1),
|
|
||||||
// positionY + BORDER_TOP + 9, 0xFFFF0000, 0xFFFF0000);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// drawTimelineCursor(leftTime, rightTime, bodyWidth);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// //Draw Keyframe logos
|
|
||||||
// for (Keyframe kf : ReplayHandler.getAllKeyframes()) {
|
|
||||||
// if (kf != null && !kf.equals(ReplayHandler.getSelectedKeyframe()))
|
|
||||||
// drawKeyframe(kf, bodyWidth, leftTime, rightTime, segmentLength);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(ReplayHandler.getSelectedKeyframe() != null) {
|
|
||||||
// drawKeyframe(ReplayHandler.getSelectedKeyframe(), bodyWidth, leftTime, rightTime, segmentLength);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private int getKeyframeX(int timestamp, long leftTime, int bodyWidth, double segmentLength) {
|
|
||||||
// long positionInSegment = timestamp - leftTime;
|
|
||||||
// double fractionOfSegment = positionInSegment / segmentLength;
|
|
||||||
// return (int) (positionX + BORDER_LEFT + fractionOfSegment * bodyWidth);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void drawKeyframe(Keyframe kf, int bodyWidth, long leftTime, long rightTime, double segmentLength) {
|
|
||||||
// if (kf.getRealTimestamp() <= rightTime && kf.getRealTimestamp() >= leftTime) {
|
|
||||||
// int textureX;
|
|
||||||
// int textureY;
|
|
||||||
// int y = positionY;
|
|
||||||
//
|
|
||||||
// int keyframeX = getKeyframeX(kf.getRealTimestamp(), leftTime, bodyWidth, segmentLength);
|
|
||||||
//
|
|
||||||
// if(kf.getValue() instanceof AdvancedPosition) {
|
|
||||||
// if(!placeKeyframes) return;
|
|
||||||
// textureX = KEYFRAME_PLACE_X;
|
|
||||||
// textureY = KEYFRAME_PLACE_Y;
|
|
||||||
// y += 0;
|
|
||||||
//
|
|
||||||
// //If Spectator Keyframe, use different texture
|
|
||||||
// if(kf.getValue() instanceof SpectatorData) {
|
|
||||||
// textureX = KEYFRAME_SPEC_X;
|
|
||||||
// textureY = KEYFRAME_SPEC_Y;
|
|
||||||
// }
|
|
||||||
// } else if(kf.getValue() instanceof TimestampValue) {
|
|
||||||
// if(!timeKeyframes) return;
|
|
||||||
// textureX = KEYFRAME_TIME_X;
|
|
||||||
// textureY = KEYFRAME_TIME_Y;
|
|
||||||
// y += 5;
|
|
||||||
// } else {
|
|
||||||
// throw new UnsupportedOperationException("Unknown property type: " + kf.getClass());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (ReplayHandler.isSelected(kf)) {
|
|
||||||
// textureX += 5;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// rect(keyframeX - 2, y + BORDER_TOP, textureX, textureY, 5, 5);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@@ -1,374 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui.elements.timelines;
|
|
||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.GuiElement;
|
|
||||||
import eu.crushedpixel.replaymod.utils.RoundUtils;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.Gui;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
import static com.replaymod.core.ReplayMod.TEXTURE;
|
|
||||||
import static com.replaymod.core.ReplayMod.TEXTURE_SIZE;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_BLEND;
|
|
||||||
import static org.lwjgl.opengl.GL11.glEnable;
|
|
||||||
|
|
||||||
public class GuiTimeline extends Gui implements GuiElement {
|
|
||||||
|
|
||||||
protected static final int TEXTURE_WIDTH = 64;
|
|
||||||
protected static final int TEXTURE_HEIGHT = 22;
|
|
||||||
protected static final int BORDER_TOP = 4;
|
|
||||||
protected static final int BORDER_BOTTOM = 3;
|
|
||||||
|
|
||||||
protected static final int TEXTURE_X = 64;
|
|
||||||
protected static final int TEXTURE_Y = 106;
|
|
||||||
|
|
||||||
protected static final int BORDER_LEFT = 4;
|
|
||||||
protected static final int BORDER_RIGHT = 4;
|
|
||||||
protected static final int BODY_WIDTH = TEXTURE_WIDTH - BORDER_LEFT - BORDER_RIGHT;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Current position of the cursor. Should normally be between 0 and {@link #timelineLength}.
|
|
||||||
*/
|
|
||||||
public int cursorPosition;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Total length of the timeline.
|
|
||||||
*/
|
|
||||||
public int timelineLength;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The time at the left border of this timeline (fraction of the total length).
|
|
||||||
*/
|
|
||||||
public double timeStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Zoom of this timeline. 1/10 allows the user to see 1/10 of the total length.
|
|
||||||
*/
|
|
||||||
public double zoom = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The smallest value <code>zoom</code> might have.
|
|
||||||
*/
|
|
||||||
public double minZoom = 0.005;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The step size of zooming in/out
|
|
||||||
*/
|
|
||||||
public double zoomStep = 0.05;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Where the more detailed part of the timeline begins
|
|
||||||
*/
|
|
||||||
|
|
||||||
public double detailedZoom = 0.05;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The step size for the more detailed part of the timeline
|
|
||||||
*/
|
|
||||||
public double smallZoomStep = 0.005;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether to draw markers on the timeline in regular time intervals.
|
|
||||||
* This draws the time at big markers above the timeline. Therefore extra space in negative y direction
|
|
||||||
* should be kept empty if markers are desired.
|
|
||||||
*/
|
|
||||||
public boolean showMarkers; // TODO: Rename to not be confused with Marker
|
|
||||||
|
|
||||||
protected final int positionX;
|
|
||||||
protected final int positionY;
|
|
||||||
protected final int width;
|
|
||||||
protected final int height;
|
|
||||||
|
|
||||||
protected boolean enabled = true;
|
|
||||||
|
|
||||||
public GuiTimeline(int positionX, int positionY, int width, int height) {
|
|
||||||
this.positionX = positionX;
|
|
||||||
this.positionY = positionY;
|
|
||||||
this.width = width;
|
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the time which the mouse is at.
|
|
||||||
* @param mouseX X coordinate of the mouse
|
|
||||||
* @param mouseY Y coordinate of the mouse
|
|
||||||
* @return The time or -1 if the mouse isn't on the timeline
|
|
||||||
*/
|
|
||||||
public long getTimeAt(int mouseX, int mouseY) {
|
|
||||||
int left = positionX + BORDER_LEFT;
|
|
||||||
int right = positionX + width - BORDER_RIGHT;
|
|
||||||
int bodyWidth = width - BORDER_LEFT - BORDER_RIGHT;
|
|
||||||
if (mouseX >= left && mouseX <= right && mouseY >= positionY && mouseY <= positionY + height) {
|
|
||||||
double segmentLength = timelineLength * zoom;
|
|
||||||
double segmentTime = segmentLength * (mouseX - left) / bodyWidth;
|
|
||||||
return Math.round(timeStart * timelineLength + segmentTime);
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Minecraft mc, int mouseX, int mouseY, boolean hovered) {
|
|
||||||
draw(mc, mouseX, mouseY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Minecraft mc, int mouseX, int mouseY) {
|
|
||||||
int bodyLeft = positionX + BORDER_LEFT;
|
|
||||||
int bodyRight = positionX + width - BORDER_RIGHT;
|
|
||||||
int bodyWidth = width - BORDER_LEFT - BORDER_RIGHT;
|
|
||||||
|
|
||||||
{
|
|
||||||
// We have to increase the border size as there is one pixel row which is part of the border while drawing
|
|
||||||
// but isn't during position calculations
|
|
||||||
int BORDER_LEFT = GuiTimeline.BORDER_LEFT + 1;
|
|
||||||
int BODY_WIDTH = GuiTimeline.BODY_WIDTH - 1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Upper left border
|
|
||||||
rect(positionX, positionY, TEXTURE_X, TEXTURE_Y, BORDER_LEFT, BORDER_TOP);
|
|
||||||
|
|
||||||
// Lower left border
|
|
||||||
rect(positionX, positionY+height-BORDER_BOTTOM, TEXTURE_X, TEXTURE_Y+TEXTURE_HEIGHT-BORDER_BOTTOM, BORDER_LEFT, BORDER_BOTTOM);
|
|
||||||
*/
|
|
||||||
|
|
||||||
boolean leftRightDrawn = false;
|
|
||||||
|
|
||||||
for (int i = positionX; i < bodyRight; i += BODY_WIDTH) {
|
|
||||||
int textureX = leftRightDrawn ? TEXTURE_X+BORDER_LEFT : TEXTURE_X;
|
|
||||||
|
|
||||||
// Upper border
|
|
||||||
rect(i, positionY, textureX, TEXTURE_Y, Math.min(BODY_WIDTH, bodyRight - i), BORDER_TOP);
|
|
||||||
|
|
||||||
int remaining = height-BORDER_TOP-BORDER_BOTTOM;
|
|
||||||
int y = positionY + BORDER_TOP;
|
|
||||||
while(remaining > 0) {
|
|
||||||
int toDraw = Math.min(remaining, TEXTURE_HEIGHT - BORDER_TOP - BORDER_BOTTOM);
|
|
||||||
rect(i, y, textureX, TEXTURE_Y+BORDER_TOP, Math.min(BODY_WIDTH, bodyRight - i), Math.min(TEXTURE_HEIGHT-BORDER_TOP-BORDER_BOTTOM, toDraw));
|
|
||||||
|
|
||||||
// Right border
|
|
||||||
if(!leftRightDrawn) {
|
|
||||||
rect(bodyLeft+bodyWidth, y, TEXTURE_X+TEXTURE_WIDTH-BORDER_RIGHT, TEXTURE_Y+BORDER_TOP, BORDER_RIGHT, Math.min(TEXTURE_HEIGHT-BORDER_TOP-BORDER_BOTTOM, toDraw));
|
|
||||||
}
|
|
||||||
|
|
||||||
y += toDraw;
|
|
||||||
remaining -= toDraw;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lower border
|
|
||||||
rect(i, positionY+height-BORDER_BOTTOM, textureX, TEXTURE_Y+TEXTURE_HEIGHT-BORDER_BOTTOM, Math.min(BODY_WIDTH, bodyRight - i), BORDER_BOTTOM);
|
|
||||||
|
|
||||||
leftRightDrawn = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Upper right corner
|
|
||||||
rect(bodyLeft+bodyWidth, positionY, TEXTURE_X+TEXTURE_WIDTH-BORDER_RIGHT, TEXTURE_Y, BORDER_RIGHT, BORDER_TOP);
|
|
||||||
|
|
||||||
// Lower right corner
|
|
||||||
rect(bodyLeft+bodyWidth, positionY+height-BORDER_BOTTOM, TEXTURE_X+TEXTURE_WIDTH-BORDER_RIGHT, TEXTURE_Y+TEXTURE_HEIGHT-BORDER_BOTTOM, BORDER_RIGHT, BORDER_BOTTOM);
|
|
||||||
}
|
|
||||||
|
|
||||||
long leftTime = Math.round(timeStart * timelineLength);
|
|
||||||
long rightTime = Math.round((timeStart + zoom) * timelineLength);
|
|
||||||
|
|
||||||
// Draw markers
|
|
||||||
if (showMarkers) {
|
|
||||||
int markerY = positionY + height - BORDER_BOTTOM;
|
|
||||||
Markers mt = Markers.getMarkers(zoom, timelineLength, bodyWidth);
|
|
||||||
|
|
||||||
// Small markers
|
|
||||||
for (int s = 0; s <= timelineLength; s += mt.smallDistance) {
|
|
||||||
if (s <= rightTime && s >= leftTime) {
|
|
||||||
long positionInSegment = s - leftTime;
|
|
||||||
double fractionOfSegment = positionInSegment / (zoom * timelineLength);
|
|
||||||
int markerX = (int) (positionX + BORDER_LEFT + fractionOfSegment * bodyWidth);
|
|
||||||
|
|
||||||
drawVerticalLine(markerX, markerY - 3, markerY, 0xffffffff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Big markers
|
|
||||||
for (int s = 0; s <= timelineLength; s += mt.distance) {
|
|
||||||
if (s <= rightTime && s >= leftTime) {
|
|
||||||
long positionInSegment = s - leftTime;
|
|
||||||
double fractionOfSegment = positionInSegment / (zoom * timelineLength);
|
|
||||||
int markerX = (int) (positionX + BORDER_LEFT + fractionOfSegment * bodyWidth);
|
|
||||||
|
|
||||||
drawVerticalLine(markerX, markerY - 7, markerY, 0xffc0c0c0); // Light gray
|
|
||||||
|
|
||||||
// Write time above the timeline
|
|
||||||
long sec = Math.round(s / 1000.0);
|
|
||||||
String timestamp = String.format("%02d:%02d", sec / 60, sec % 60);
|
|
||||||
drawCenteredString(mc.fontRendererObj, timestamp, markerX, positionY - 8, 0xffffffff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
drawTimelineCursor(leftTime, rightTime, bodyWidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void drawTimelineCursor(long leftTime, long rightTime, int bodyWidth) {
|
|
||||||
// Draw the cursor if it's on the current timeline segment
|
|
||||||
if (cursorPosition >= leftTime && cursorPosition <= rightTime) {
|
|
||||||
long positionInSegment = cursorPosition - leftTime;
|
|
||||||
double fractionOfSegment = positionInSegment / (zoom * timelineLength);
|
|
||||||
int cursorX = (int) (positionX + BORDER_LEFT + fractionOfSegment * bodyWidth);
|
|
||||||
|
|
||||||
rect(cursorX - 2, positionY + BORDER_TOP-1, 84, 20, 5, 4);
|
|
||||||
|
|
||||||
|
|
||||||
int remaining = height-BORDER_TOP-BORDER_BOTTOM-3;
|
|
||||||
int y = positionY + BORDER_TOP-1 + 4;
|
|
||||||
while(remaining > 0) {
|
|
||||||
int toDraw = Math.min(remaining, 11);
|
|
||||||
|
|
||||||
rect(cursorX - 2, y, 84, 24, 5, toDraw);
|
|
||||||
|
|
||||||
y += toDraw;
|
|
||||||
remaining -= toDraw;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawOverlay(Minecraft mc, int mouseX, int mouseY) {
|
|
||||||
// Draw time under cursor if the mouse is on the timeline
|
|
||||||
long mouseTime = getTimeAt(mouseX, mouseY);
|
|
||||||
if (mouseTime != -1) {
|
|
||||||
long sec = mouseTime / 1000;
|
|
||||||
String timestamp = String.format("%02d:%02d", sec / 60, sec % 60);
|
|
||||||
ReplayMod.tooltipRenderer.drawTooltip(mouseX, mouseY, timestamp, null, Color.WHITE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isHovering(int mouseX, int mouseY) {
|
|
||||||
return getTimeAt(mouseX, mouseY) != -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean mouseClick(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
return isHovering(mouseX, mouseY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseDrag(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseRelease(Minecraft mc, int mouseX, int mouseY, int button) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void buttonPressed(Minecraft mc, int mouseX, int mouseY, char key, int keyCode) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick(Minecraft mc) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void rect(int x, int y, int u, int v, int width, int height) {
|
|
||||||
if(!enabled) {
|
|
||||||
GlStateManager.color(Color.GRAY.getRed() / 255f, Color.GRAY.getGreen() / 255f, Color.GRAY.getBlue() / 255f, 1f);
|
|
||||||
}
|
|
||||||
Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
|
|
||||||
drawModalRectWithCustomSizedTexture(x, y, u, v, width, height, TEXTURE_SIZE, TEXTURE_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void zoomIn() {
|
|
||||||
if(zoom-zoomStep < detailedZoom) {
|
|
||||||
zoom = Math.max(minZoom, zoom - smallZoomStep);
|
|
||||||
timeStart = Math.min(timeStart, 1f - smallZoomStep);
|
|
||||||
} else {
|
|
||||||
zoom = Math.max(minZoom, zoom - zoomStep);
|
|
||||||
timeStart = Math.min(timeStart, 1f - zoomStep);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void zoomOut() {
|
|
||||||
if(zoom+smallZoomStep <= detailedZoom) {
|
|
||||||
zoom = Math.min(1, zoom+smallZoomStep);
|
|
||||||
} else {
|
|
||||||
zoom = Math.min(1, zoom+zoomStep);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public static class Markers {
|
|
||||||
|
|
||||||
static final int S = 1000;
|
|
||||||
static final int M = 60*1000;
|
|
||||||
|
|
||||||
static final int[] snapNumbers = new int[]{S, 2*S, 5*S, 10*S, 15*S, 20*S, 30*S, M, 2*M,
|
|
||||||
5*M, 10*M, 15*M, 30*M};
|
|
||||||
|
|
||||||
static final int MARKER_DISTANCE = 40;
|
|
||||||
|
|
||||||
int smallDistance;
|
|
||||||
int distance;
|
|
||||||
|
|
||||||
public static Markers getMarkers(double scale, long totalLength, int pixelWidth) {
|
|
||||||
|
|
||||||
//amount of seconds visible on timeline
|
|
||||||
int visible = (int)(scale*totalLength);
|
|
||||||
|
|
||||||
int bigMarkerCount = pixelWidth/MARKER_DISTANCE;
|
|
||||||
|
|
||||||
int bigMarkerDistance = visible / bigMarkerCount;
|
|
||||||
int snap = RoundUtils.getClosestInt(bigMarkerDistance, snapNumbers);
|
|
||||||
|
|
||||||
bigMarkerDistance = RoundUtils.roundToMultiple(bigMarkerDistance, snap);
|
|
||||||
|
|
||||||
return new Markers(bigMarkerDistance/4, bigMarkerDistance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setElementEnabled(boolean enabled) {
|
|
||||||
this.enabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int xPos() {
|
|
||||||
return positionX;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int yPos() {
|
|
||||||
return positionY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int width() {
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int height() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void xPos(int x) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void yPos(int y) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void width(int width) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void height(int height) {}
|
|
||||||
}
|
|
||||||
@@ -1,246 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui.replayeditor;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.GuiArrowButton;
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.GuiDropdown;
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.GuiEntryList;
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.listeners.SelectionListener;
|
|
||||||
import eu.crushedpixel.replaymod.holders.GuiEntryListStringEntry;
|
|
||||||
import eu.crushedpixel.replaymod.studio.StudioImplementation;
|
|
||||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GuiConnectPart extends GuiStudioPart {
|
|
||||||
|
|
||||||
private final String DESCRIPTION = I18n.format("replaymod.gui.editor.connect.description");
|
|
||||||
private final String TITLE = I18n.format("replaymod.gui.editor.connect.title");
|
|
||||||
|
|
||||||
private boolean initialized = false;
|
|
||||||
|
|
||||||
private GuiEntryList<GuiEntryListStringEntry> concatList;
|
|
||||||
private GuiDropdown<GuiEntryListStringEntry> replayDropdown;
|
|
||||||
|
|
||||||
private GuiButton removeButton, addButton;
|
|
||||||
private GuiArrowButton upButton, downButton;
|
|
||||||
|
|
||||||
private List<File> replayFiles;
|
|
||||||
private List<GuiEntryListStringEntry> filesToConcat;
|
|
||||||
|
|
||||||
private Thread filterThread;
|
|
||||||
private File outputFile;
|
|
||||||
|
|
||||||
public GuiConnectPart(int yPos) {
|
|
||||||
super(yPos);
|
|
||||||
this.mc = Minecraft.getMinecraft();
|
|
||||||
fontRendererObj = mc.fontRendererObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applyFilters(File replayFile, final File outputFile) {
|
|
||||||
this.outputFile = outputFile;
|
|
||||||
filterThread = new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
List<File> inputFiles = new ArrayList<File>();
|
|
||||||
OUTER:
|
|
||||||
for (GuiEntryListStringEntry fileName : filesToConcat) {
|
|
||||||
for (File file : replayFiles) {
|
|
||||||
if (fileName.getDisplayString().equals(FilenameUtils.getBaseName(file.getAbsolutePath()))) {
|
|
||||||
inputFiles.add(file);
|
|
||||||
continue OUTER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new RuntimeException(fileName.getDisplayString());
|
|
||||||
}
|
|
||||||
StudioImplementation.connectReplayFiles(inputFiles, outputFile, GuiConnectPart.this);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, "replay-editor-connect");
|
|
||||||
|
|
||||||
filterThread.start();
|
|
||||||
|
|
||||||
mc.displayGuiScreen(new GuiReplayEditingProcess(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void cancelFilters() {
|
|
||||||
filterThread.stop();
|
|
||||||
FileUtils.deleteQuietly(outputFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return DESCRIPTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTitle() {
|
|
||||||
return TITLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initGui() {
|
|
||||||
if(!initialized) {
|
|
||||||
concatList = new GuiEntryList<GuiEntryListStringEntry>(fontRendererObj, 30, yPos, 150, 0);
|
|
||||||
filesToConcat = new ArrayList<GuiEntryListStringEntry>();
|
|
||||||
String selectedName = FilenameUtils.getBaseName(GuiReplayEditor.instance.getSelectedFile().getAbsolutePath());
|
|
||||||
filesToConcat.add(new GuiEntryListStringEntry(selectedName));
|
|
||||||
concatList.setElements(filesToConcat);
|
|
||||||
|
|
||||||
concatList.setSelectionIndex(0);
|
|
||||||
|
|
||||||
replayDropdown = new GuiDropdown<GuiEntryListStringEntry>(fontRendererObj, 250, yPos + 5, 0, 4);
|
|
||||||
|
|
||||||
replayDropdown.clearElements();
|
|
||||||
replayFiles = ReplayFileIO.getAllReplayFiles();
|
|
||||||
int index = -1;
|
|
||||||
int i = 0;
|
|
||||||
for(File file : replayFiles) {
|
|
||||||
String name = FilenameUtils.getBaseName(file.getAbsolutePath());
|
|
||||||
replayDropdown.addElement(new GuiEntryListStringEntry(name));
|
|
||||||
if(name.equals(selectedName)) {
|
|
||||||
index = i;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
replayDropdown.setSelectionPos(index);
|
|
||||||
|
|
||||||
replayDropdown.addSelectionListener(new SelectionListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSelectionChanged(int selectionIndex) {
|
|
||||||
try {
|
|
||||||
filesToConcat.set(concatList.getSelectionIndex(), replayDropdown.getElement(selectionIndex));
|
|
||||||
concatList.setElements(filesToConcat);
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
// TODO Prevent exception
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
concatList.addSelectionListener(new SelectionListener() {
|
|
||||||
@Override
|
|
||||||
public void onSelectionChanged(int selectionIndex) {
|
|
||||||
GuiEntryListStringEntry entry = concatList.getElement(selectionIndex);
|
|
||||||
if(entry == null) {
|
|
||||||
removeButton.enabled = false;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
removeButton.enabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
String selName = entry.getDisplayString();
|
|
||||||
int i = 0;
|
|
||||||
for(Object s : replayDropdown.getAllElements()) {
|
|
||||||
String str = ((GuiEntryListStringEntry)s).getDisplayString();
|
|
||||||
if(str.equals(selName)) {
|
|
||||||
replayDropdown.setSelectionIndex(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
removeButton.enabled = upButton.enabled = downButton.enabled = !(selectionIndex < 0 || selectionIndex >= filesToConcat.size());
|
|
||||||
if(upButton.enabled && selectionIndex == 0) upButton.enabled = false;
|
|
||||||
if(downButton.enabled && selectionIndex == filesToConcat.size() - 1) downButton.enabled = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<GuiButton> buttonList = this.buttonList;
|
|
||||||
|
|
||||||
upButton = new GuiArrowButton(GuiConstants.REPLAY_EDITOR_UP_BUTTON, 195, yPos + 40, "", GuiArrowButton.Direction.UP);
|
|
||||||
buttonList.add(upButton);
|
|
||||||
|
|
||||||
downButton = new GuiArrowButton(GuiConstants.REPLAY_EDITOR_DOWN_BUTTON, 219, yPos + 40, "", GuiArrowButton.Direction.DOWN);
|
|
||||||
buttonList.add(downButton);
|
|
||||||
|
|
||||||
removeButton = new GuiButton(GuiConstants.REPLAY_EDITOR_REMOVE_BUTTON, 249, yPos + 40, I18n.format("replaymod.gui.remove"));
|
|
||||||
buttonList.add(removeButton);
|
|
||||||
|
|
||||||
addButton = new GuiButton(GuiConstants.REPLAY_EDITOR_ADD_BUTTON, 0, yPos + 40, I18n.format("replaymod.gui.add"));
|
|
||||||
buttonList.add(addButton);
|
|
||||||
|
|
||||||
concatList.setSelectionIndex(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int w = GuiReplayEditor.instance.width - 249 - 20 - 4;
|
|
||||||
addButton.xPosition = 249 + 6 + (w / 2);
|
|
||||||
|
|
||||||
addButton.width = w / 2 + 2;
|
|
||||||
removeButton.width = w / 2 + 2;
|
|
||||||
|
|
||||||
replayDropdown.width = GuiReplayEditor.instance.width - 250 - 18;
|
|
||||||
|
|
||||||
int h = GuiReplayEditor.instance.height - yPos - 20;
|
|
||||||
int rows = (int) (h / (float) GuiEntryList.elementHeight);
|
|
||||||
concatList.setVisibleElements(rows);
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
|
||||||
super.mouseClicked(mouseX, mouseY, mouseButton); //call this first to ensure the dropdown is still open
|
|
||||||
concatList.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
replayDropdown.mouseClick(Minecraft.getMinecraft(), mouseX, mouseY, mouseButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
|
||||||
concatList.drawTextBox();
|
|
||||||
replayDropdown.drawTextBox();
|
|
||||||
|
|
||||||
drawString(fontRendererObj, I18n.format("replaymod.gui.replay")+":", 200, yPos + 5 + 7, Color.WHITE.getRGB());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateScreen() {
|
|
||||||
if(!initialized) initGui();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void keyTyped(char typedChar, int keyCode) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void actionPerformed(GuiButton button) {
|
|
||||||
if(!button.enabled || replayDropdown.isExpanded()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(button.id == GuiConstants.REPLAY_EDITOR_ADD_BUTTON) {
|
|
||||||
filesToConcat.add(new GuiEntryListStringEntry(FilenameUtils.getBaseName(replayFiles.get(0).getAbsolutePath())));
|
|
||||||
concatList.setElements(filesToConcat);
|
|
||||||
concatList.setSelectionIndex(filesToConcat.size() - 1);
|
|
||||||
} else if(button.id == GuiConstants.REPLAY_EDITOR_REMOVE_BUTTON) {
|
|
||||||
int indexBefore = concatList.getSelectionIndex();
|
|
||||||
if(indexBefore >= 0 && indexBefore < filesToConcat.size()) {
|
|
||||||
filesToConcat.remove(indexBefore);
|
|
||||||
concatList.setElements(filesToConcat);
|
|
||||||
if(filesToConcat.size() <= indexBefore) {
|
|
||||||
concatList.setSelectionIndex(filesToConcat.size() - 1);
|
|
||||||
} else {
|
|
||||||
concatList.setSelectionIndex(indexBefore);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui.replayeditor;
|
|
||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
|
||||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.GuiProgressBar;
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GuiReplayEditingProcess extends GuiScreen {
|
|
||||||
|
|
||||||
private String title;
|
|
||||||
private String pleaseWait;
|
|
||||||
private String cancelCallback;
|
|
||||||
|
|
||||||
private boolean finished = false;
|
|
||||||
|
|
||||||
private boolean callback = false;
|
|
||||||
|
|
||||||
private boolean initialized = false;
|
|
||||||
|
|
||||||
private GuiProgressBar progressBar;
|
|
||||||
private GuiButton cancelButton;
|
|
||||||
|
|
||||||
private GuiStudioPart studioPart;
|
|
||||||
|
|
||||||
public GuiReplayEditingProcess(GuiStudioPart studioPart) {
|
|
||||||
this.studioPart = studioPart;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initGui() {
|
|
||||||
if(!initialized) {
|
|
||||||
title = I18n.format("replaymod.gui.editor.progress.title");
|
|
||||||
pleaseWait = I18n.format("replaymod.gui.editor.progress.pleasewait");
|
|
||||||
cancelCallback = I18n.format("replaymod.gui.rendering.cancel.callback");
|
|
||||||
|
|
||||||
progressBar = new GuiProgressBar();
|
|
||||||
cancelButton = new GuiButton(GuiConstants.REPLAY_EDITING_CANCEL_BUTTON, 0, 0, I18n.format("gui.cancel"));
|
|
||||||
}
|
|
||||||
|
|
||||||
progressBar.setBounds(10, this.height-30-20, this.width-20, 20);
|
|
||||||
|
|
||||||
cancelButton.xPosition = this.width - 5 - 150;
|
|
||||||
cancelButton.width = 150;
|
|
||||||
cancelButton.yPosition = this.height - 5 - 20;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<GuiButton> buttonList = this.buttonList;
|
|
||||||
buttonList.add(cancelButton);
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
|
||||||
this.drawDefaultBackground();
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
|
||||||
this.drawCenteredString(mc.fontRendererObj, title, this.width / 2, 20, Color.WHITE.getRGB());
|
|
||||||
this.drawCenteredString(mc.fontRendererObj, pleaseWait, this.width / 2, 40, Color.WHITE.getRGB());
|
|
||||||
|
|
||||||
progressBar.setProgress(studioPart.getProgress());
|
|
||||||
progressBar.setProgressString(studioPart.getFilterProgressString());
|
|
||||||
progressBar.drawProgressBar();
|
|
||||||
|
|
||||||
if(studioPart.getProgress() >= 1f && !finished) {
|
|
||||||
finished = true;
|
|
||||||
cancelButton.displayString = I18n.format("gui.done");
|
|
||||||
ReplayMod.soundHandler.playRenderSuccessSound();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void actionPerformed(GuiButton button) throws IOException {
|
|
||||||
if(!button.enabled) return;
|
|
||||||
if(button.id == GuiConstants.REPLAY_EDITING_CANCEL_BUTTON) {
|
|
||||||
if(finished) {
|
|
||||||
mc.displayGuiScreen(null);
|
|
||||||
} else {
|
|
||||||
if(!callback) {
|
|
||||||
callback = true;
|
|
||||||
button.displayString = cancelCallback;
|
|
||||||
} else {
|
|
||||||
studioPart.cancelFilters();
|
|
||||||
mc.displayGuiScreen(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,210 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui.replayeditor;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.GuiDropdown;
|
|
||||||
import eu.crushedpixel.replaymod.holders.GuiEntryListStringEntry;
|
|
||||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
|
||||||
import eu.crushedpixel.replaymod.utils.StringUtils;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
|
||||||
import net.minecraft.client.gui.GuiMainMenu;
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GuiReplayEditor extends GuiScreen {
|
|
||||||
|
|
||||||
private static final int tabYPos = 110;
|
|
||||||
public static GuiReplayEditor instance = null;
|
|
||||||
private StudioTab currentTab = StudioTab.TRIM;
|
|
||||||
private GuiDropdown<GuiEntryListStringEntry> replayDropdown;
|
|
||||||
private GuiButton saveButton;
|
|
||||||
private GuiButton saveModeButton;
|
|
||||||
private boolean overrideSave = false;
|
|
||||||
private boolean initialized = false;
|
|
||||||
private List<File> replayFiles = new ArrayList<File>();
|
|
||||||
|
|
||||||
public GuiReplayEditor() {
|
|
||||||
instance = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getSelectedFile() {
|
|
||||||
try {
|
|
||||||
return replayFiles.get(replayDropdown.getSelectionIndex());
|
|
||||||
} catch(ArrayIndexOutOfBoundsException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshReplayDropdown() {
|
|
||||||
replayDropdown.clearElements();
|
|
||||||
replayFiles = ReplayFileIO.getAllReplayFiles();
|
|
||||||
if(replayFiles.size() == 0) {
|
|
||||||
mc.displayGuiScreen(null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for(File file : replayFiles) {
|
|
||||||
String name = FilenameUtils.getBaseName(file.getAbsolutePath());
|
|
||||||
replayDropdown.addElement(new GuiEntryListStringEntry(name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initGui() {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<GuiButton> buttonList = this.buttonList;
|
|
||||||
List<GuiButton> tabButtons = new ArrayList<GuiButton>();
|
|
||||||
|
|
||||||
tabButtons.add(new GuiButton(GuiConstants.REPLAY_EDITOR_TRIM_TAB, 0, 0, I18n.format("replaymod.gui.editor.trim.title")));
|
|
||||||
tabButtons.add(new GuiButton(GuiConstants.REPLAY_EDITOR_CONNECT_TAB, 0, 0, I18n.format("replaymod.gui.editor.connect.title")));
|
|
||||||
|
|
||||||
GuiButton modifyButton = new GuiButton(GuiConstants.REPLAY_EDITOR_MODIFY_TAB, 0, 0, I18n.format("replaymod.gui.editor.modify.title"));
|
|
||||||
modifyButton.enabled = false;
|
|
||||||
tabButtons.add(modifyButton);
|
|
||||||
|
|
||||||
int w = this.width - 30;
|
|
||||||
int w2 = w / tabButtons.size();
|
|
||||||
int i = 0;
|
|
||||||
for(GuiButton b : tabButtons) {
|
|
||||||
int x = 15 + (w2 * i);
|
|
||||||
b.xPosition = x + 2;
|
|
||||||
b.yPosition = 30;
|
|
||||||
b.width = w2 - 4;
|
|
||||||
|
|
||||||
buttonList.add(b);
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
int modeWidth = tabButtons.get(0).width;
|
|
||||||
|
|
||||||
if(!initialized) {
|
|
||||||
replayDropdown = new GuiDropdown<GuiEntryListStringEntry>(fontRendererObj, 15 + 2 + 1 + 80, 60, this.width - 30 - 8 - 80 - modeWidth - 4, 5);
|
|
||||||
refreshReplayDropdown();
|
|
||||||
} else {
|
|
||||||
replayDropdown.width = this.width - 30 - 8 - 80 - modeWidth - 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!initialized) {
|
|
||||||
saveModeButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVEMODE_BUTTON, width - 15 - modeWidth - 3, 60, getSaveModeLabel());
|
|
||||||
} else {
|
|
||||||
saveModeButton.xPosition = width - 15 - modeWidth - 3;
|
|
||||||
}
|
|
||||||
saveModeButton.width = modeWidth;
|
|
||||||
buttonList.add(saveModeButton);
|
|
||||||
|
|
||||||
|
|
||||||
GuiButton backButton = new GuiButton(GuiConstants.REPLAY_EDITOR_BACK_BUTTON, width - 70 - 18, height - 20 - 5, I18n.format("replaymod.gui.back"));
|
|
||||||
backButton.width = 70;
|
|
||||||
buttonList.add(backButton);
|
|
||||||
|
|
||||||
saveButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVE_BUTTON, width - 70 - 18, height - (2 * 20) - 5 - 3, I18n.format("replaymod.gui.save"));
|
|
||||||
saveButton.width = 70;
|
|
||||||
buttonList.add(saveButton);
|
|
||||||
|
|
||||||
for(StudioTab tab : StudioTab.values()) {
|
|
||||||
tab.getStudioPart().initGui();
|
|
||||||
}
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getSaveModeLabel() {
|
|
||||||
return overrideSave ? I18n.format("replaymod.gui.editor.savemode.override") : I18n.format("replaymod.gui.editor.savemode.newfile");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void actionPerformed(GuiButton button) throws IOException {
|
|
||||||
if(!button.enabled) return;
|
|
||||||
if(button.id == GuiConstants.REPLAY_EDITOR_SAVEMODE_BUTTON) {
|
|
||||||
overrideSave = !overrideSave;
|
|
||||||
button.displayString = getSaveModeLabel();
|
|
||||||
} else if(button.id == GuiConstants.REPLAY_EDITOR_BACK_BUTTON) {
|
|
||||||
mc.displayGuiScreen(new GuiMainMenu());
|
|
||||||
} else if(button.id == GuiConstants.REPLAY_EDITOR_TRIM_TAB) {
|
|
||||||
currentTab = StudioTab.TRIM;
|
|
||||||
} else if(button.id == GuiConstants.REPLAY_EDITOR_CONNECT_TAB) {
|
|
||||||
currentTab = StudioTab.CONNECT;
|
|
||||||
//} else if(button.id == GuiConstants.REPLAY_EDITOR_MODIFY_TAB) {
|
|
||||||
//currentTab = StudioTab.MODIFY;
|
|
||||||
} else if(button.id == GuiConstants.REPLAY_EDITOR_SAVE_BUTTON) {
|
|
||||||
File outputFile = getSelectedFile();
|
|
||||||
File folder = ReplayFileIO.getReplayFolder();
|
|
||||||
if(!overrideSave) {
|
|
||||||
String name = FilenameUtils.getBaseName(outputFile.getAbsolutePath()) + "_edited";
|
|
||||||
File f = new File(folder, name + ".mcpr");
|
|
||||||
int num = 0;
|
|
||||||
while(f.exists()) {
|
|
||||||
num++;
|
|
||||||
String fileName = name + "_" + num;
|
|
||||||
f = new File(folder, fileName + ".mcpr");
|
|
||||||
}
|
|
||||||
outputFile = f;
|
|
||||||
}
|
|
||||||
currentTab.getStudioPart().applyFilters(getSelectedFile(), outputFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton)
|
|
||||||
throws IOException {
|
|
||||||
replayDropdown.mouseClick(Minecraft.getMinecraft(), mouseX, mouseY, mouseButton);
|
|
||||||
currentTab.getStudioPart().mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
|
||||||
saveButton.enabled = currentTab.getStudioPart().validateInputs();
|
|
||||||
drawDefaultBackground();
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
|
||||||
currentTab.getStudioPart().drawScreen(mouseX, mouseY, partialTicks);
|
|
||||||
|
|
||||||
drawCenteredString(fontRendererObj, "§n" + currentTab.getStudioPart().getTitle(), width / 2, 92, Color.WHITE.getRGB());
|
|
||||||
|
|
||||||
String[] rows = StringUtils.splitStringInMultipleRows(currentTab.getStudioPart().getDescription(), width - 30 - 70 - 20);
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
for(String row : rows) {
|
|
||||||
drawString(fontRendererObj, row, 30, height - (15 * (rows.length - i)), Color.WHITE.getRGB());
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
drawCenteredString(fontRendererObj, I18n.format("replaymod.gui.editor.disclaimer"), this.width / 2, 10, 16777215);
|
|
||||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editor.replayfile"), 30, 67, Color.WHITE.getRGB());
|
|
||||||
|
|
||||||
replayDropdown.drawTextBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
|
||||||
currentTab.getStudioPart().keyTyped(typedChar, keyCode);
|
|
||||||
super.keyTyped(typedChar, keyCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateScreen() {
|
|
||||||
currentTab.getStudioPart().updateScreen();
|
|
||||||
super.updateScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum StudioTab {
|
|
||||||
TRIM(new GuiTrimPart(tabYPos)), CONNECT(new GuiConnectPart(tabYPos)), MODIFY(new GuiConnectPart(tabYPos));
|
|
||||||
|
|
||||||
private GuiStudioPart studioPart;
|
|
||||||
|
|
||||||
StudioTab(GuiStudioPart part) {
|
|
||||||
this.studioPart = part;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiStudioPart getStudioPart() {
|
|
||||||
return studioPart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui.replayeditor;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.listeners.ProgressUpdateListener;
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public abstract class GuiStudioPart extends GuiScreen implements ProgressUpdateListener {
|
|
||||||
|
|
||||||
protected int yPos = 0;
|
|
||||||
|
|
||||||
public GuiStudioPart(int yPos) {
|
|
||||||
this.yPos = yPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void applyFilters(File replayFile, File outputFile);
|
|
||||||
|
|
||||||
public abstract void cancelFilters();
|
|
||||||
|
|
||||||
public abstract String getDescription();
|
|
||||||
|
|
||||||
public abstract String getTitle();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract void keyTyped(char typedChar, int keyCode);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
|
||||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
private float progress;
|
|
||||||
private String progressString;
|
|
||||||
|
|
||||||
public float getProgress() {
|
|
||||||
return progress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFilterProgressString() {
|
|
||||||
return progressString;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProgressChanged(float progress, String progressString) {
|
|
||||||
this.progress = progress;
|
|
||||||
this.progressString = progressString;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProgressChanged(float progress) {
|
|
||||||
this.progress = progress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean validateInputs() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,184 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui.replayeditor;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.gui.elements.GuiNumberInput;
|
|
||||||
import eu.crushedpixel.replaymod.studio.StudioImplementation;
|
|
||||||
import eu.crushedpixel.replaymod.utils.TimestampUtils;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GuiTrimPart extends GuiStudioPart {
|
|
||||||
|
|
||||||
private static final String DESCRIPTION = I18n.format("replaymod.gui.editor.trim.description");
|
|
||||||
private final String TITLE = I18n.format("replaymod.gui.editor.trim.title");
|
|
||||||
private Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
private boolean initialized = false;
|
|
||||||
|
|
||||||
private GuiNumberInput startMinInput, startSecInput, startMsInput;
|
|
||||||
private GuiNumberInput endMinInput, endSecInput, endMsInput;
|
|
||||||
|
|
||||||
private List<GuiNumberInput> inputOrder = new ArrayList<GuiNumberInput>();
|
|
||||||
|
|
||||||
private Thread filterThread;
|
|
||||||
private File outputFile;
|
|
||||||
|
|
||||||
public GuiTrimPart(int yPos) {
|
|
||||||
super(yPos);
|
|
||||||
fontRendererObj = mc.fontRendererObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean validateInputs() {
|
|
||||||
return getEndTimestamp() == 0 || getEndTimestamp() > getStartTimestamp();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applyFilters(final File replayFile, final File outputFile) {
|
|
||||||
this.outputFile = outputFile;
|
|
||||||
filterThread = new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
StudioImplementation.trimReplay(replayFile, getStartTimestamp(), getEndTimestamp(), outputFile, GuiTrimPart.this);
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, "replay-editor-trim");
|
|
||||||
|
|
||||||
filterThread.start();
|
|
||||||
|
|
||||||
mc.displayGuiScreen(new GuiReplayEditingProcess(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void cancelFilters() {
|
|
||||||
filterThread.stop();
|
|
||||||
FileUtils.deleteQuietly(outputFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int valueOf(String text) {
|
|
||||||
try {
|
|
||||||
return Integer.valueOf(text);
|
|
||||||
} catch(NumberFormatException e) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getStartTimestamp() {
|
|
||||||
int mins = valueOf(startMinInput.getText());
|
|
||||||
int secs = valueOf(startSecInput.getText());
|
|
||||||
int ms = valueOf(startMsInput.getText());
|
|
||||||
|
|
||||||
return TimestampUtils.calculateTimestamp(mins, secs, ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getEndTimestamp() {
|
|
||||||
int mins = valueOf(endMinInput.getText());
|
|
||||||
int secs = valueOf(endSecInput.getText());
|
|
||||||
int ms = valueOf(endMsInput.getText());
|
|
||||||
|
|
||||||
return TimestampUtils.calculateTimestamp(mins, secs, ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return DESCRIPTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTitle() {
|
|
||||||
return TITLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initGui() {
|
|
||||||
if(!initialized) {
|
|
||||||
startMinInput = new GuiNumberInput(fontRendererObj, 70, yPos, 30, null, 999d, null, false);
|
|
||||||
startSecInput = new GuiNumberInput(fontRendererObj, 125, yPos, 25, null, 99d, null, false);
|
|
||||||
startMsInput = new GuiNumberInput(fontRendererObj, 175, yPos, 30, null, 999d, null, false);
|
|
||||||
|
|
||||||
endMinInput = new GuiNumberInput(fontRendererObj, 70, yPos + 30, 30, null, 999d, null, false);
|
|
||||||
endSecInput = new GuiNumberInput(fontRendererObj, 125, yPos + 30, 25, null, 99d, null, false);
|
|
||||||
endMsInput = new GuiNumberInput(fontRendererObj, 175, yPos + 30, 30, null, 999d, null, false);
|
|
||||||
|
|
||||||
inputOrder.clear();
|
|
||||||
|
|
||||||
inputOrder.add(startMinInput);
|
|
||||||
inputOrder.add(startSecInput);
|
|
||||||
inputOrder.add(startMsInput);
|
|
||||||
inputOrder.add(endMinInput);
|
|
||||||
inputOrder.add(endSecInput);
|
|
||||||
inputOrder.add(endMsInput);
|
|
||||||
}
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
|
||||||
for(GuiNumberInput input : inputOrder) {
|
|
||||||
input.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
|
||||||
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.start")+":", 30, yPos + 7, Color.WHITE.getRGB());
|
|
||||||
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.end")+":", 30, yPos + 7 + 30, Color.WHITE.getRGB());
|
|
||||||
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.minutes"), 105, yPos + 7, Color.WHITE.getRGB());
|
|
||||||
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.minutes"), 105, yPos + 7 + 30, Color.WHITE.getRGB());
|
|
||||||
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.seconds"), 155, yPos + 7, Color.WHITE.getRGB());
|
|
||||||
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.seconds"), 155, yPos + 7 + 30, Color.WHITE.getRGB());
|
|
||||||
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.milliseconds"), 210, yPos + 7, Color.WHITE.getRGB());
|
|
||||||
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.milliseconds"), 210, yPos + 7 + 30, Color.WHITE.getRGB());
|
|
||||||
|
|
||||||
drawString(mc.fontRendererObj, "Timestamp: " + getStartTimestamp(), 240, yPos + 7, Color.WHITE.getRGB());
|
|
||||||
drawString(mc.fontRendererObj, "Timestamp: " + getEndTimestamp(), 240, yPos + 30 + 7, Color.WHITE.getRGB());
|
|
||||||
|
|
||||||
for(GuiNumberInput input : inputOrder) {
|
|
||||||
input.drawTextBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateScreen() {
|
|
||||||
if(!initialized) {
|
|
||||||
initGui();
|
|
||||||
} else {
|
|
||||||
for(GuiNumberInput input : inputOrder) {
|
|
||||||
input.updateCursorCounter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void keyTyped(char typedChar, int keyCode) {
|
|
||||||
if(keyCode == Keyboard.KEY_TAB) { //Tab handling
|
|
||||||
int i = 0;
|
|
||||||
for(GuiNumberInput input : inputOrder) {
|
|
||||||
if(input.isFocused()) {
|
|
||||||
input.setFocused(false);
|
|
||||||
i++;
|
|
||||||
if(i >= inputOrder.size()) i = 0;
|
|
||||||
inputOrder.get(i).setFocused(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for(GuiNumberInput input : inputOrder) {
|
|
||||||
input.textboxKeyTyped(typedChar, keyCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.interpolation.*;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
|
|
||||||
import javax.vecmath.Vector3d;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper=true)
|
|
||||||
public class AdvancedPosition extends Position {
|
|
||||||
|
|
||||||
@Interpolate
|
|
||||||
public double pitch, yaw, roll;
|
|
||||||
|
|
||||||
public AdvancedPosition(double x, double y, double z, double pitch, double yaw, double roll) {
|
|
||||||
super(x, y, z);
|
|
||||||
this.pitch = pitch;
|
|
||||||
this.yaw = yaw;
|
|
||||||
this.roll = roll;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdvancedPosition(int entityID) {
|
|
||||||
this(Minecraft.getMinecraft().theWorld.getEntityByID(entityID));
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdvancedPosition(Entity e) {
|
|
||||||
this(e.posX, e.posY, e.posZ, e.rotationPitch, e.rotationYaw);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdvancedPosition(double x, double y, double z, double pitch, double yaw) {
|
|
||||||
this(x, y, z, pitch, yaw, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SpectatorData asSpectatorData(int entityID) {
|
|
||||||
return new SpectatorData(x, y, z, pitch, yaw, roll, entityID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double distanceSquared(double x, double y, double z) {
|
|
||||||
double dx = this.x - x;
|
|
||||||
double dy = this.y - y;
|
|
||||||
double dz = this.z - z;
|
|
||||||
return dx * dx + dy * dy + dz * dz;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdvancedPosition getDestination(double stepSize) {
|
|
||||||
float f2 = MathHelper.cos((float) (Math.toRadians(-yaw) - (float)Math.PI));
|
|
||||||
float f3 = MathHelper.sin((float) (Math.toRadians(-yaw) - (float) Math.PI));
|
|
||||||
float f4 = -MathHelper.cos((float) (Math.toRadians(-pitch)));
|
|
||||||
float f5 = MathHelper.sin((float) (Math.toRadians(-pitch)));
|
|
||||||
Vector3d direction = new Vector3d((double)(f3 * f4), (double)f5, (double)(f2 * f4));
|
|
||||||
direction.normalize();
|
|
||||||
direction.scale(stepSize);
|
|
||||||
|
|
||||||
Vector3d position = new Vector3d(x, y, z);
|
|
||||||
position.add(direction);
|
|
||||||
return new AdvancedPosition(position.x, position.y, position.z, pitch, yaw, roll);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void apply(AdvancedPosition toApply) {
|
|
||||||
this.x = toApply.getX();
|
|
||||||
this.y = toApply.getY();
|
|
||||||
this.z = toApply.getZ();
|
|
||||||
this.pitch = toApply.getPitch();
|
|
||||||
this.yaw = toApply.getYaw();
|
|
||||||
this.roll = toApply.getRoll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdvancedPosition copy() {
|
|
||||||
return new AdvancedPosition(x, y, z, pitch, yaw, roll);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AdvancedPosition newInstance() {
|
|
||||||
return new AdvancedPosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Interpolation getCubicInterpolator() {
|
|
||||||
return new AdvancedPositionSplineInterpolation();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Interpolation getLinearInterpolator() {
|
|
||||||
return new AdvancedPositionLinearInterpolation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
|
||||||
|
|
||||||
|
|
||||||
public interface GuiEntryListEntry {
|
|
||||||
|
|
||||||
String getDisplayString();
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class GuiEntryListStringEntry implements GuiEntryListEntry {
|
|
||||||
|
|
||||||
private String displayName;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayString() {
|
|
||||||
return displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return displayName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class GuiEntryListValueEntry<T> implements GuiEntryListEntry {
|
|
||||||
|
|
||||||
String displayString;
|
|
||||||
T value;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayString() {
|
|
||||||
return displayString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.interpolation.KeyframeValue;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class Keyframe<T extends KeyframeValue> {
|
|
||||||
|
|
||||||
private int realTimestamp;
|
|
||||||
private T value;
|
|
||||||
|
|
||||||
public Keyframe<T> copy() {
|
|
||||||
return new Keyframe<T>(realTimestamp, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
public class KeyframeComparator implements Comparator<Keyframe> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(Keyframe o1, Keyframe o2) {
|
|
||||||
if(o1 == null || o2 == null) return 0;
|
|
||||||
return ((Integer) o1.getRealTimestamp()).compareTo(o2.getRealTimestamp());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.interpolation.*;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class NumberValue implements KeyframeValue {
|
|
||||||
|
|
||||||
@Interpolate
|
|
||||||
public double value;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NumberValue newInstance() {
|
|
||||||
return new NumberValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Interpolation getLinearInterpolator() {
|
|
||||||
return new GenericLinearInterpolation<NumberValue>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Interpolation getCubicInterpolator() {
|
|
||||||
return new GenericSplineInterpolation<NumberValue>();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class PacketData {
|
|
||||||
private byte[] byteArray;
|
|
||||||
private int timestamp;
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.interpolation.*;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class Point implements KeyframeValue {
|
|
||||||
|
|
||||||
@Interpolate
|
|
||||||
public double x, y;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Point newInstance() {
|
|
||||||
return new Point();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Interpolation getLinearInterpolator() {
|
|
||||||
return new GenericLinearInterpolation<Point>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Interpolation getCubicInterpolator() {
|
|
||||||
return new GenericSplineInterpolation<Point>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.interpolation.*;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.util.BlockPos;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class Position implements KeyframeValue {
|
|
||||||
|
|
||||||
@Interpolate
|
|
||||||
public double x, y, z;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Position newInstance() {
|
|
||||||
return new Position();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Position(BlockPos pos) {
|
|
||||||
this.x = pos.getX();
|
|
||||||
this.y = pos.getY();
|
|
||||||
this.z = pos.getZ();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Position(Entity entity) {
|
|
||||||
this.x = entity.posX;
|
|
||||||
this.y = entity.posY;
|
|
||||||
this.z = entity.posZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Interpolation getLinearInterpolator() {
|
|
||||||
return new GenericLinearInterpolation<Position>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Interpolation getCubicInterpolator() {
|
|
||||||
return new GenericSplineInterpolation<Position>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.interpolation.AdvancedPositionLinearInterpolation;
|
|
||||||
import eu.crushedpixel.replaymod.interpolation.AdvancedPositionSplineInterpolation;
|
|
||||||
import eu.crushedpixel.replaymod.interpolation.Interpolation;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper=true)
|
|
||||||
public class SpectatorData extends AdvancedPosition {
|
|
||||||
|
|
||||||
private Integer spectatedEntityID;
|
|
||||||
|
|
||||||
private SpectatingMethod spectatingMethod = SpectatingMethod.FIRST_PERSON;
|
|
||||||
|
|
||||||
private SpectatorDataThirdPersonInfo thirdPersonInfo = new SpectatorDataThirdPersonInfo();
|
|
||||||
|
|
||||||
public int getSpectatedEntityID() {
|
|
||||||
if(spectatedEntityID == null) throw new IllegalStateException();
|
|
||||||
return spectatedEntityID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SpectatorData(double x, double y, double z, double pitch, double yaw, double roll, int entityID) {
|
|
||||||
super(x, y, z, pitch, yaw, roll);
|
|
||||||
this.spectatedEntityID = entityID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SpectatorData(int entityID) {
|
|
||||||
this(Minecraft.getMinecraft().theWorld.getEntityByID(entityID));
|
|
||||||
}
|
|
||||||
|
|
||||||
public SpectatorData(Entity e) {
|
|
||||||
super(e.posX, e.posY, e.posZ, e.rotationPitch, e.rotationYaw);
|
|
||||||
this.spectatedEntityID = e.getEntityId();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return itself if it's a valid SpectatorData object,
|
|
||||||
* otherwise a new AdvancedPosition object containing the same position data
|
|
||||||
*/
|
|
||||||
public AdvancedPosition normalize() {
|
|
||||||
if(spectatedEntityID != null) return this;
|
|
||||||
return new AdvancedPosition(x, y, z, pitch, yaw, roll);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AdvancedPosition newInstance() {
|
|
||||||
return new AdvancedPosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Interpolation getCubicInterpolator() {
|
|
||||||
return new AdvancedPositionSplineInterpolation();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Interpolation getLinearInterpolator() {
|
|
||||||
return new AdvancedPositionLinearInterpolation();
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum SpectatingMethod {
|
|
||||||
FIRST_PERSON(0xFF0080FF), SHOULDER_CAM(0xFFFF8000);
|
|
||||||
|
|
||||||
private int color;
|
|
||||||
|
|
||||||
public int getColor() {
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
SpectatingMethod(int color) {
|
|
||||||
this.color = color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.interpolation.*;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class SpectatorDataThirdPersonInfo implements KeyframeValue {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The shoulder camera's distance (in blocks) to the player
|
|
||||||
*/
|
|
||||||
@Interpolate
|
|
||||||
public double shoulderCamDistance = 3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The shoulder camera's pitch offset in degrees, value between -90 and 90
|
|
||||||
*/
|
|
||||||
@Interpolate
|
|
||||||
public double shoulderCamPitchOffset = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The shoulder camera's rotation around the player in degrees
|
|
||||||
*/
|
|
||||||
@Interpolate
|
|
||||||
public double shoulderCamYawOffset = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The distance between the automatically calculated position keyframes in seconds
|
|
||||||
*/
|
|
||||||
@Interpolate
|
|
||||||
public double shoulderCamSmoothness = 1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public KeyframeValue newInstance() {
|
|
||||||
return new SpectatorDataThirdPersonInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Interpolation getLinearInterpolator() {
|
|
||||||
return new GenericLinearInterpolation<SpectatorDataThirdPersonInfo>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Interpolation getCubicInterpolator() {
|
|
||||||
return new GenericSplineInterpolation<SpectatorDataThirdPersonInfo>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.interpolation.*;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class TimestampValue implements KeyframeValue {
|
|
||||||
|
|
||||||
@Interpolate
|
|
||||||
public double value;
|
|
||||||
|
|
||||||
public int asInt() {
|
|
||||||
return (int)value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TimestampValue newInstance() {
|
|
||||||
return new TimestampValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Interpolation getLinearInterpolator() {
|
|
||||||
return new GenericLinearInterpolation<TimestampValue>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Interpolation getCubicInterpolator() {
|
|
||||||
return new GenericSplineInterpolation<TimestampValue>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "TimestampValue: "+asInt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class Transformation {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The object's anchor around which modifiers like orientation or position should be applied.
|
|
||||||
* x=0, y=0, z=0 is the object's center.
|
|
||||||
*/
|
|
||||||
private Position anchor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The object's position in the Minecraft world.
|
|
||||||
*/
|
|
||||||
private Position position;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The object's orientation.
|
|
||||||
*/
|
|
||||||
private Position orientation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The object's scale, individual values between 0 and 100.
|
|
||||||
*/
|
|
||||||
private Position scale;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The object's opacity. Value between 0 and 100.
|
|
||||||
*/
|
|
||||||
private double opacity;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.interpolation.KeyframeList;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class Transformations {
|
|
||||||
|
|
||||||
private Position defaultAnchor = new Position(0, 0, 0),
|
|
||||||
defaultPosition = new Position(0, 0, 0),
|
|
||||||
defaultOrientation = new Position(0, 0, 0),
|
|
||||||
defaultScale = new Position(100, 100, 100);
|
|
||||||
private NumberValue defaultOpacity = new NumberValue(100);
|
|
||||||
|
|
||||||
private KeyframeList<Position> anchorKeyframes = new KeyframeList<Position>();
|
|
||||||
private KeyframeList<Position> positionKeyframes = new KeyframeList<Position>();
|
|
||||||
private KeyframeList<Position> orientationKeyframes = new KeyframeList<Position>();
|
|
||||||
private KeyframeList<Position> scaleKeyframes = new KeyframeList<Position>();
|
|
||||||
private KeyframeList<NumberValue> opacityKeyframes = new KeyframeList<NumberValue>();
|
|
||||||
|
|
||||||
public KeyframeList getKeyframeListByID(int id) {
|
|
||||||
switch(id) {
|
|
||||||
case 0:
|
|
||||||
return anchorKeyframes;
|
|
||||||
case 1:
|
|
||||||
return positionKeyframes;
|
|
||||||
case 2:
|
|
||||||
return orientationKeyframes;
|
|
||||||
case 3:
|
|
||||||
return scaleKeyframes;
|
|
||||||
case 4:
|
|
||||||
return opacityKeyframes;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Transformation getTransformationForTimestamp(int timestamp) {
|
|
||||||
Position anchor = anchorKeyframes.getInterpolatedValueForTimestamp(timestamp, true);
|
|
||||||
if(anchor == null) anchor = defaultAnchor;
|
|
||||||
|
|
||||||
Position position = positionKeyframes.getInterpolatedValueForTimestamp(timestamp, true);
|
|
||||||
if(position == null) position = defaultPosition;
|
|
||||||
|
|
||||||
Position orientation = orientationKeyframes.getInterpolatedValueForTimestamp(timestamp, true);
|
|
||||||
if(orientation == null) orientation = defaultOrientation;
|
|
||||||
|
|
||||||
Position scale = scaleKeyframes.getInterpolatedValueForTimestamp(timestamp, true);
|
|
||||||
if(scale == null) scale = defaultScale;
|
|
||||||
|
|
||||||
NumberValue opacity = opacityKeyframes.getInterpolatedValueForTimestamp(timestamp, true);
|
|
||||||
if(opacity == null) opacity = defaultOpacity;
|
|
||||||
|
|
||||||
return new Transformation(anchor, position, orientation, scale, opacity.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.interpolation;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.holders.AdvancedPosition;
|
|
||||||
import eu.crushedpixel.replaymod.holders.Keyframe;
|
|
||||||
import eu.crushedpixel.replaymod.holders.SpectatorData;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.ListIterator;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class AdvancedPositionKeyframeList extends KeyframeList<AdvancedPosition> {
|
|
||||||
|
|
||||||
private KeyframeList<AdvancedPosition> completedKeyframes;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AdvancedPosition getInterpolatedValueForPathPosition(float pathPosition, boolean linear) {
|
|
||||||
if(first() == null) return null;
|
|
||||||
if(size() == 1) return first().getValue();
|
|
||||||
|
|
||||||
if(previousCallLinear != (Boolean)linear) {
|
|
||||||
recalculate(linear);
|
|
||||||
}
|
|
||||||
|
|
||||||
//convert the path position to match the completedKeyframes list
|
|
||||||
int timestamp = getTimestampFromPathPosition(pathPosition);
|
|
||||||
float newPathPosition = completedKeyframes.getPositionOnPath(timestamp);
|
|
||||||
return completedKeyframes.getInterpolatedValueForPathPosition(newPathPosition, linear);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void recalculate(boolean linear) {
|
|
||||||
previousCallLinear = linear;
|
|
||||||
|
|
||||||
if(size() < 2) return;
|
|
||||||
|
|
||||||
completedKeyframes = new KeyframeList<AdvancedPosition>();
|
|
||||||
|
|
||||||
//find subsequent Spectator Keyframes with the same Entity ID
|
|
||||||
ListIterator<Keyframe<AdvancedPosition>> iterator = this.listIterator();
|
|
||||||
while(iterator.hasNext()) {
|
|
||||||
Keyframe<AdvancedPosition> keyframe = iterator.next();
|
|
||||||
SpectatorDataInterpolation spectatorInterpolation = null;
|
|
||||||
|
|
||||||
boolean found = keyframe.getValue() instanceof SpectatorData;
|
|
||||||
int firstTimestamp = -1;
|
|
||||||
|
|
||||||
if(!found) {
|
|
||||||
completedKeyframes.add(keyframe);
|
|
||||||
}
|
|
||||||
|
|
||||||
while(found) {
|
|
||||||
if(spectatorInterpolation == null) {
|
|
||||||
spectatorInterpolation = new SpectatorDataInterpolation(linear);
|
|
||||||
}
|
|
||||||
int keyframeTimestamp = keyframe.getRealTimestamp();
|
|
||||||
// TODO
|
|
||||||
// TimestampValue timestampValue = ReplayHandler.getTimeKeyframes().getInterpolatedValueForTimestamp(keyframeTimestamp, true);
|
|
||||||
// int replayTimestamp = timestampValue == null ? 0 : timestampValue.asInt();
|
|
||||||
// if(firstTimestamp == -1) firstTimestamp = replayTimestamp;
|
|
||||||
// spectatorInterpolation.addPoint(property, replayTimestamp);
|
|
||||||
// if(iterator.hasNext()) {
|
|
||||||
// property = iterator.next();
|
|
||||||
// found = property.getValue() instanceof SpectatorData;
|
|
||||||
// if(!found) completedKeyframes.add(property);
|
|
||||||
// } else {
|
|
||||||
// found = false;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
if(spectatorInterpolation != null && spectatorInterpolation.size() > 1) {
|
|
||||||
spectatorInterpolation.prepare();
|
|
||||||
completedKeyframes.addAll(spectatorInterpolation.elements());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.interpolation;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.holders.AdvancedPosition;
|
|
||||||
import eu.crushedpixel.replaymod.utils.InterpolationUtils;
|
|
||||||
|
|
||||||
public class AdvancedPositionLinearInterpolation extends GenericLinearInterpolation<AdvancedPosition> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addPoint(AdvancedPosition point) {
|
|
||||||
double normalizedYaw = (point.getYaw() + 180) % 360;
|
|
||||||
double normalizedRoll = (point.getRoll()) % 360;
|
|
||||||
|
|
||||||
if(!points.isEmpty()) {
|
|
||||||
AdvancedPosition last = points.get(points.size()-1);
|
|
||||||
|
|
||||||
double yaw = InterpolationUtils.fixEulerRotation(last.getYaw(), point.getYaw(), 180);
|
|
||||||
double roll = InterpolationUtils.fixEulerRotation(last.getRoll(), point.getRoll(), 0);
|
|
||||||
|
|
||||||
point.setYaw(yaw);
|
|
||||||
point.setRoll(roll);
|
|
||||||
} else {
|
|
||||||
point.setYaw(normalizedYaw-180);
|
|
||||||
point.setRoll(normalizedRoll);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.addPoint(point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.interpolation;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.holders.AdvancedPosition;
|
|
||||||
import eu.crushedpixel.replaymod.utils.InterpolationUtils;
|
|
||||||
|
|
||||||
public class AdvancedPositionSplineInterpolation extends GenericSplineInterpolation<AdvancedPosition> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addPoint(AdvancedPosition point) {
|
|
||||||
double normalizedYaw = (point.getYaw() + 180) % 360;
|
|
||||||
double normalizedRoll = (point.getRoll()) % 360;
|
|
||||||
|
|
||||||
if(!points.isEmpty()) {
|
|
||||||
AdvancedPosition last = points.get(points.size()-1);
|
|
||||||
|
|
||||||
double yaw = InterpolationUtils.fixEulerRotation(last.getYaw(), point.getYaw(), 180);
|
|
||||||
double roll = InterpolationUtils.fixEulerRotation(last.getRoll(), point.getRoll(), 0);
|
|
||||||
|
|
||||||
point.setYaw(yaw);
|
|
||||||
point.setRoll(roll);
|
|
||||||
} else {
|
|
||||||
point.setYaw(normalizedYaw-180);
|
|
||||||
point.setRoll(normalizedRoll);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.addPoint(point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.interpolation;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class BasicSpline {
|
|
||||||
public void calcNaturalCubic(List valueCollection, Field val, Collection<Cubic> cubicCollection) throws IllegalArgumentException, IllegalAccessException {
|
|
||||||
int num = valueCollection.size() - 1;
|
|
||||||
|
|
||||||
double[] gamma = new double[num + 1];
|
|
||||||
double[] delta = new double[num + 1];
|
|
||||||
double[] D = new double[num + 1];
|
|
||||||
|
|
||||||
int i;
|
|
||||||
/*
|
|
||||||
We solve the equation
|
|
||||||
[2 1 ] [D[0]] [3(x[1] - x[0]) ]
|
|
||||||
|1 4 1 | |D[1]| |3(x[2] - x[0]) |
|
|
||||||
| 1 4 1 | | . | = | . |
|
|
||||||
| ..... | | . | | . |
|
|
||||||
| 1 4 1| | . | |3(x[n] - x[n-2])|
|
|
||||||
[ 1 2] [D[n]] [3(x[n] - x[n-1])]
|
|
||||||
|
|
||||||
by using row operations to convert the matrix to upper triangular
|
|
||||||
and then back sustitution. The D[i] are the derivatives at the knots.
|
|
||||||
*/
|
|
||||||
gamma[0] = 1.0f / 2.0f;
|
|
||||||
for(i = 1; i < num; i++) {
|
|
||||||
gamma[i] = 1.0f / (4.0f - gamma[i - 1]);
|
|
||||||
}
|
|
||||||
gamma[num] = 1.0f / (2.0f - gamma[num - 1]);
|
|
||||||
|
|
||||||
Double p0 = val.getDouble(valueCollection.get(0));
|
|
||||||
Double p1 = val.getDouble(valueCollection.get(1));
|
|
||||||
|
|
||||||
delta[0] = 3.0f * (p1 - p0) * gamma[0];
|
|
||||||
for(i = 1; i < num; i++) {
|
|
||||||
p0 = val.getDouble(valueCollection.get(i - 1));
|
|
||||||
p1 = val.getDouble(valueCollection.get(i + 1));
|
|
||||||
delta[i] = (3.0f * (p1 - p0) - delta[i - 1]) * gamma[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
p0 = val.getDouble(valueCollection.get(num - 1));
|
|
||||||
p1 = val.getDouble(valueCollection.get(num));
|
|
||||||
|
|
||||||
delta[num] = (3.0f * (p1 - p0) - delta[num - 1]) * gamma[num];
|
|
||||||
|
|
||||||
D[num] = delta[num];
|
|
||||||
for(i = num - 1; i >= 0; i--) {
|
|
||||||
D[i] = delta[i] - gamma[i] * D[i + 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
//now compute the coefficients of the cubics
|
|
||||||
cubicCollection.clear();
|
|
||||||
|
|
||||||
for(i = 0; i < num; i++) {
|
|
||||||
p0 = val.getDouble(valueCollection.get(i));
|
|
||||||
p1 = val.getDouble(valueCollection.get(i + 1));
|
|
||||||
|
|
||||||
cubicCollection.add(new Cubic(
|
|
||||||
p0,
|
|
||||||
D[i],
|
|
||||||
3 * (p1 - p0) - 2 * D[i] - D[i + 1],
|
|
||||||
2 * (p0 - p1) + D[i] + D[i + 1]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.interpolation;
|
|
||||||
|
|
||||||
public class Cubic {
|
|
||||||
private double a, b, c, d;
|
|
||||||
|
|
||||||
public Cubic(double p0, double d2, double e, double f) {
|
|
||||||
this.a = p0;
|
|
||||||
this.b = d2;
|
|
||||||
this.c = e;
|
|
||||||
this.d = f;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double eval(double u) {
|
|
||||||
return (((d * u) + c) * u + b) * u + a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.interpolation;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.utils.ReflectionUtils;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GenericLinearInterpolation<T extends KeyframeValue> implements Interpolation<T> {
|
|
||||||
|
|
||||||
private Field[] fields;
|
|
||||||
|
|
||||||
protected List<T> points = new ArrayList<T>();
|
|
||||||
|
|
||||||
public GenericLinearInterpolation() {
|
|
||||||
points = new ArrayList<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void prepare() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addPoint(T point) {
|
|
||||||
points.add(point);
|
|
||||||
|
|
||||||
if(fields == null) {
|
|
||||||
List<Field> fields = ReflectionUtils.getFieldsToInterpolate(point.getClass());
|
|
||||||
this.fields = fields.toArray(new Field[fields.size()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applyPoint(float position, T toEdit) {
|
|
||||||
if(fields == null) {
|
|
||||||
throw new IllegalStateException("At least one Keyframe has to be added before preparing");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(fields.length <= 0) {
|
|
||||||
throw new IllegalStateException("The passed KeyframeValue class" +
|
|
||||||
" has to contain at least one Field");
|
|
||||||
}
|
|
||||||
|
|
||||||
//first, get previous and next T for given position
|
|
||||||
float relative = position * (points.size()-1);
|
|
||||||
int previousIndex = (int)Math.floor(relative);
|
|
||||||
int nextIndex = (int)Math.ceil(relative);
|
|
||||||
float percentage = relative - previousIndex;
|
|
||||||
|
|
||||||
T previous = points.get(previousIndex);
|
|
||||||
T next = points.get(nextIndex);
|
|
||||||
|
|
||||||
for(Field f : fields) {
|
|
||||||
try {
|
|
||||||
f.set(toEdit, getInterpolatedValue(f.getDouble(previous), f.getDouble(next), percentage));
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private double getInterpolatedValue(double val1, double val2, float perc) {
|
|
||||||
return val1 + ((val2 - val1) * perc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.interpolation;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.utils.ReflectionUtils;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
public class GenericSplineInterpolation<T extends KeyframeValue> extends BasicSpline implements Interpolation<T> {
|
|
||||||
|
|
||||||
protected Field[] fields;
|
|
||||||
|
|
||||||
protected Vector<T> points;
|
|
||||||
protected List<Vector<Cubic>> cubics = Collections.emptyList();
|
|
||||||
|
|
||||||
public GenericSplineInterpolation() {
|
|
||||||
this.points = new Vector<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addPoint(T point) {
|
|
||||||
this.points.add(point);
|
|
||||||
|
|
||||||
if(fields == null) {
|
|
||||||
List<Field> fields = ReflectionUtils.getFieldsToInterpolate(point.getClass());
|
|
||||||
this.fields = fields.toArray(new Field[fields.size()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void prepare() {
|
|
||||||
if(fields == null) {
|
|
||||||
throw new IllegalStateException("At least one Keyframe has to be added before preparing");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(fields.length <= 0) {
|
|
||||||
throw new IllegalStateException("The passed KeyframeValue class" +
|
|
||||||
" has to contain at least one Field");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!points.isEmpty()) {
|
|
||||||
cubics = new ArrayList<Vector<Cubic>>(fields.length);
|
|
||||||
for (Field field : fields) {
|
|
||||||
Vector<Cubic> vec = new Vector<Cubic>();
|
|
||||||
cubics.add(vec);
|
|
||||||
try {
|
|
||||||
calcNaturalCubic(points, field, vec);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new IllegalStateException("At least one Value needs to be added" +
|
|
||||||
" before preparing this Spline");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applyPoint(float position, T toEdit) {
|
|
||||||
Vector<Cubic> first = cubics.get(0);
|
|
||||||
position = position * first.size();
|
|
||||||
int cubicNum = (int) Math.min(first.size() - 1, position);
|
|
||||||
float cubicPos = (position - cubicNum);
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
for(Field f : fields) {
|
|
||||||
try {
|
|
||||||
f.set(toEdit, cubics.get(i).get(cubicNum).eval(cubicPos));
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.interpolation;
|
|
||||||
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.FIELD)
|
|
||||||
public @interface Interpolate {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.interpolation;
|
|
||||||
|
|
||||||
public interface Interpolation<T extends KeyframeValue> {
|
|
||||||
void prepare();
|
|
||||||
void applyPoint(float position, T toEdit);
|
|
||||||
void addPoint(T pos);
|
|
||||||
}
|
|
||||||
@@ -1,249 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.interpolation;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.holders.Keyframe;
|
|
||||||
import eu.crushedpixel.replaymod.holders.KeyframeComparator;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class KeyframeList<K extends KeyframeValue> extends ArrayList<Keyframe<K>> {
|
|
||||||
|
|
||||||
protected static final KeyframeComparator KEYFRAME_COMPARATOR = new KeyframeComparator();
|
|
||||||
|
|
||||||
protected Boolean previousCallLinear = null;
|
|
||||||
|
|
||||||
protected Interpolation<K> interpolation;
|
|
||||||
|
|
||||||
public KeyframeList(List<Keyframe<K>> initial) {
|
|
||||||
for(Keyframe<K> kf : initial) {
|
|
||||||
add(kf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean add(Keyframe<K> t) {
|
|
||||||
//remove keyframes that have same timestamp
|
|
||||||
for(Keyframe kf : new ArrayList<Keyframe>(this)) {
|
|
||||||
if(kf.getRealTimestamp() == t.getRealTimestamp()) {
|
|
||||||
super.remove(kf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean success = super.add(t);
|
|
||||||
sort();
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void add(int index, Keyframe<K> element) {
|
|
||||||
super.add(index, element);
|
|
||||||
sort();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addAll(Collection<? extends Keyframe<K>> c) {
|
|
||||||
boolean result = super.addAll(c);
|
|
||||||
sort();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addAll(int index, Collection<? extends Keyframe<K>> c) {
|
|
||||||
boolean result = super.addAll(index, c);
|
|
||||||
sort();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Keyframe<K> remove(int index) {
|
|
||||||
Keyframe<K> removed = super.remove(index);
|
|
||||||
sort();
|
|
||||||
return removed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean remove(Object o) {
|
|
||||||
boolean success = super.remove(o);
|
|
||||||
sort();
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sort() {
|
|
||||||
previousCallLinear = null;
|
|
||||||
Collections.sort(this, KEYFRAME_COMPARATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the first Keyframe that comes before a given value.
|
|
||||||
* @param realTime The value to use
|
|
||||||
* @param inclusive Whether the previous Keyframe might have the same timestamp as <b>realTime</b>
|
|
||||||
* @return The first Keyframe prior to the given value
|
|
||||||
*/
|
|
||||||
public Keyframe<K> getPreviousKeyframe(int realTime, boolean inclusive) {
|
|
||||||
if(this.isEmpty()) return null;
|
|
||||||
|
|
||||||
List<Keyframe<K>> found = new ArrayList<Keyframe<K>>();
|
|
||||||
|
|
||||||
for(Keyframe<K> kf : this) {
|
|
||||||
|
|
||||||
if((inclusive && kf.getRealTimestamp() <= realTime) || (!inclusive && kf.getRealTimestamp() < realTime)) {
|
|
||||||
found.add(kf);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(found.size() > 0)
|
|
||||||
return found.get(found.size() - 1); //last element is nearest
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the first Keyframe that comes after a given value.
|
|
||||||
* @param realTime The value to use
|
|
||||||
* @param inclusive Whether the next Keyframe might have the same timestamp as <b>realTime</b>
|
|
||||||
* @return The first Keyframe after the given value
|
|
||||||
*/
|
|
||||||
public Keyframe<K> getNextKeyframe(int realTime, boolean inclusive) {
|
|
||||||
if(this.isEmpty()) return null;
|
|
||||||
|
|
||||||
for(Keyframe<K> kf : this) {
|
|
||||||
|
|
||||||
if((inclusive && kf.getRealTimestamp() >= realTime) || (!inclusive && kf.getRealTimestamp() > realTime)) {
|
|
||||||
return kf; //first found element is next
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Keyframe that is closest to the given timestamp.
|
|
||||||
* @param realTime The timestamp to start searching at
|
|
||||||
* @param tolerance The threshold to allow for close Keyframes
|
|
||||||
* @return The closest Keyframe, or null if no Keyframe within treshold
|
|
||||||
*/
|
|
||||||
public Keyframe<K> getClosestKeyframeForTimestamp(int realTime, int tolerance) {
|
|
||||||
List<Keyframe<K>> found = new ArrayList<Keyframe<K>>();
|
|
||||||
for(Keyframe<K> kf : this) {
|
|
||||||
if(Math.abs(kf.getRealTimestamp() - realTime) <= tolerance) {
|
|
||||||
found.add(kf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Keyframe<K> closest = null;
|
|
||||||
|
|
||||||
for(Keyframe<K> kf : found) {
|
|
||||||
if(closest == null || Math.abs(closest.getRealTimestamp() - realTime) > Math.abs(kf.getRealTimestamp() - realTime)) {
|
|
||||||
closest = kf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return closest;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Keyframe<K> first() {
|
|
||||||
if(isEmpty()) return null;
|
|
||||||
return get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Keyframe<K> last() {
|
|
||||||
if(isEmpty()) return null;
|
|
||||||
return get(size()-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public K getInterpolatedValueForTimestamp(int timestamp, boolean linear) {
|
|
||||||
return getInterpolatedValueForPathPosition(getPositionOnPath(timestamp), linear);
|
|
||||||
}
|
|
||||||
|
|
||||||
public K getInterpolatedValueForPathPosition(float pathPosition, boolean linear) {
|
|
||||||
if(first() == null) return null;
|
|
||||||
if(size() == 1) return first().getValue();
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
K toApply = (K) first().getValue().newInstance();
|
|
||||||
|
|
||||||
if(previousCallLinear != (Boolean)linear) {
|
|
||||||
recalculate(linear);
|
|
||||||
}
|
|
||||||
|
|
||||||
interpolation.applyPoint(pathPosition, toApply);
|
|
||||||
|
|
||||||
return toApply;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recalculates the underlying Interpolation instances.
|
|
||||||
* @param linear Whether to prepare linear or cubic interpolation
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void recalculate(boolean linear) {
|
|
||||||
previousCallLinear = linear;
|
|
||||||
|
|
||||||
if(size() < 2) return;
|
|
||||||
|
|
||||||
interpolation = linear ? first().getValue().getLinearInterpolator() : first().getValue().getCubicInterpolator();
|
|
||||||
|
|
||||||
for(Keyframe<K> keyframe : this) {
|
|
||||||
interpolation.addPoint(keyframe.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
interpolation.prepare();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a value between 0 and 1, representing the number that should be passed
|
|
||||||
* to Interpolation#getValue() calls on this list of Keyframes.
|
|
||||||
* @param timestamp The value to use
|
|
||||||
* @return A value between 0 and 1
|
|
||||||
*/
|
|
||||||
protected float getPositionOnPath(int timestamp) {
|
|
||||||
Keyframe previousKeyframe = getPreviousKeyframe(timestamp, true);
|
|
||||||
Keyframe nextKeyframe = getNextKeyframe(timestamp, true);
|
|
||||||
|
|
||||||
int previousTimestamp = 0;
|
|
||||||
int nextTimestamp = 0;
|
|
||||||
|
|
||||||
if(nextKeyframe != null || previousKeyframe != null) {
|
|
||||||
if(nextKeyframe != null) {
|
|
||||||
nextTimestamp = nextKeyframe.getRealTimestamp();
|
|
||||||
} else {
|
|
||||||
nextTimestamp = previousKeyframe.getRealTimestamp();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(previousKeyframe != null) {
|
|
||||||
previousTimestamp = previousKeyframe.getRealTimestamp();
|
|
||||||
} else {
|
|
||||||
previousTimestamp = nextKeyframe.getRealTimestamp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentPosDiff = nextTimestamp - previousTimestamp;
|
|
||||||
int currentPos = timestamp - previousTimestamp;
|
|
||||||
|
|
||||||
float currentStepPercentage = (float) currentPos / (float) currentPosDiff;
|
|
||||||
if(Float.isInfinite(currentStepPercentage) || Float.isNaN(currentStepPercentage)) currentStepPercentage = 0;
|
|
||||||
|
|
||||||
float value = (indexOf(previousKeyframe) + currentStepPercentage) /
|
|
||||||
(float)(size() - 1);
|
|
||||||
|
|
||||||
return Math.max(0, Math.min(1, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int getTimestampFromPathPosition(float pathPosition) {
|
|
||||||
int keyframeIndex = (int)Math.min(size()-1, pathPosition*(size()-1));
|
|
||||||
float remainder = (pathPosition - ((float)keyframeIndex/(size()-1)));
|
|
||||||
float partial = remainder / (1f/(size()-1));
|
|
||||||
|
|
||||||
int previousTimestamp = get(keyframeIndex).getRealTimestamp();
|
|
||||||
int nextTimestamp = size()-1 > keyframeIndex ? get(keyframeIndex+1).getRealTimestamp() : previousTimestamp;
|
|
||||||
|
|
||||||
int diff = nextTimestamp - previousTimestamp;
|
|
||||||
return (int)(previousTimestamp + (partial*diff));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.interpolation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An abstract class that GenericSplineInterpolation can process.
|
|
||||||
* Subclasses simply have to annotate at least one field with @Interpolate,
|
|
||||||
* and the GenericSplineInterpolation will interpolate these.
|
|
||||||
* <br><br>
|
|
||||||
* It is recommended for KeyframeValue subclasses to have a @NoArgsConstructor annotation.
|
|
||||||
*/
|
|
||||||
public interface KeyframeValue {
|
|
||||||
|
|
||||||
KeyframeValue newInstance();
|
|
||||||
|
|
||||||
Interpolation getLinearInterpolator();
|
|
||||||
Interpolation getCubicInterpolator();
|
|
||||||
}
|
|
||||||
@@ -1,144 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.interpolation;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.holders.AdvancedPosition;
|
|
||||||
import eu.crushedpixel.replaymod.holders.Keyframe;
|
|
||||||
import eu.crushedpixel.replaymod.holders.SpectatorData;
|
|
||||||
import eu.crushedpixel.replaymod.holders.SpectatorDataThirdPersonInfo;
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A SpectatorDataInterpolation object calculates Camera Paths between multiple Spectator Keyframes.
|
|
||||||
* It does not matter which SpectatingMethod these Keyframes have, the SpectatorDataInterpolation treats them specifically.
|
|
||||||
*/
|
|
||||||
public class SpectatorDataInterpolation {
|
|
||||||
|
|
||||||
private Integer entityID = null;
|
|
||||||
|
|
||||||
private List<Pair<Integer, Keyframe<AdvancedPosition>>> points = new ArrayList<Pair<Integer, Keyframe<AdvancedPosition>>>();
|
|
||||||
private KeyframeList<AdvancedPosition> underlyingKeyframes;
|
|
||||||
|
|
||||||
private final boolean linear;
|
|
||||||
|
|
||||||
public SpectatorDataInterpolation(boolean linear) {
|
|
||||||
this.linear = linear;
|
|
||||||
underlyingKeyframes = new KeyframeList<AdvancedPosition>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int size() {
|
|
||||||
return points.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Keyframe<AdvancedPosition>> elements() {
|
|
||||||
return new ArrayList<Keyframe<AdvancedPosition>>(underlyingKeyframes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void prepare() {
|
|
||||||
//first, create an Interpolation instance to retreive a SpectatorDataThirdPersonInfo object for every
|
|
||||||
//position on the Spectator Path
|
|
||||||
Interpolation<SpectatorDataThirdPersonInfo> thirdPersonInfoInterpolation =
|
|
||||||
linear ? new GenericLinearInterpolation<SpectatorDataThirdPersonInfo>() :
|
|
||||||
new GenericSplineInterpolation<SpectatorDataThirdPersonInfo>();
|
|
||||||
|
|
||||||
double previousSmoothness = 0.5;
|
|
||||||
for(Pair<Integer, Keyframe<AdvancedPosition>> pair : points) {
|
|
||||||
if(((SpectatorData)pair.getValue().getValue()).getSpectatingMethod() == SpectatorData.SpectatingMethod.FIRST_PERSON) {
|
|
||||||
thirdPersonInfoInterpolation.addPoint(new SpectatorDataThirdPersonInfo(0, 0, 0, previousSmoothness));
|
|
||||||
} else {
|
|
||||||
SpectatorDataThirdPersonInfo thirdPersonInfo = ((SpectatorData)pair.getValue().getValue()).getThirdPersonInfo();
|
|
||||||
thirdPersonInfoInterpolation.addPoint(thirdPersonInfo);
|
|
||||||
previousSmoothness = thirdPersonInfo.shoulderCamSmoothness;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
thirdPersonInfoInterpolation.prepare();
|
|
||||||
|
|
||||||
//updating the spectator property's position in the world to smoothly continue the path
|
|
||||||
//with non-spectator position keyframes
|
|
||||||
for(Pair<Integer, Keyframe<AdvancedPosition>> pair : points) {
|
|
||||||
// TODO
|
|
||||||
// AdvancedPosition entityPosition = ReplayHandler.getEntityPositionTracker().getEntityPositionAtTimestamp(entityID, pair.getKey());
|
|
||||||
// if(entityPosition == null) continue;
|
|
||||||
//
|
|
||||||
// //transform the entity position (sry for no dry code :x )
|
|
||||||
// SpectatorDataThirdPersonInfo thirdPersonInfo = ((SpectatorData)pair.getValue().getValue()).getThirdPersonInfo();
|
|
||||||
//
|
|
||||||
// //first, rotate the camera pitch and yaw according to the settings
|
|
||||||
// entityPosition.setYaw(entityPosition.getYaw() + thirdPersonInfo.shoulderCamYawOffset);
|
|
||||||
// entityPosition.setPitch(entityPosition.getPitch() + thirdPersonInfo.shoulderCamPitchOffset);
|
|
||||||
//
|
|
||||||
// //next, move the camera point to fulfill the specified distance to the entity
|
|
||||||
// entityPosition = entityPosition.getDestination(-1 * thirdPersonInfo.shoulderCamDistance);
|
|
||||||
//
|
|
||||||
// pair.getValue().getValue().apply(entityPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
//feed the underlying property list with AdvancedPosition Keyframes that are derived from the Spectator Keyframes
|
|
||||||
underlyingKeyframes = new KeyframeList<AdvancedPosition>();
|
|
||||||
int i = 0;
|
|
||||||
int firstTimestamp = -1;
|
|
||||||
int size = points.size()-1;
|
|
||||||
for(Pair<Integer, Keyframe<AdvancedPosition>> pair : points) {
|
|
||||||
underlyingKeyframes.add(new Keyframe<AdvancedPosition>(pair.getValue().getRealTimestamp(), pair.getValue().getValue()));
|
|
||||||
|
|
||||||
int timestamp = pair.getKey();
|
|
||||||
if(firstTimestamp == -1) firstTimestamp = timestamp;
|
|
||||||
|
|
||||||
int realTimestamp = pair.getValue().getRealTimestamp();
|
|
||||||
int nextRealTimestamp = realTimestamp;
|
|
||||||
|
|
||||||
int currentTimestamp = timestamp;
|
|
||||||
int nextTimestamp = timestamp;
|
|
||||||
|
|
||||||
if(i+1 < points.size()) {
|
|
||||||
Pair<Integer, Keyframe<AdvancedPosition>> nextPair = points.get(i+1);
|
|
||||||
nextTimestamp = nextPair.getKey();
|
|
||||||
nextRealTimestamp = nextPair.getValue().getRealTimestamp();
|
|
||||||
}
|
|
||||||
|
|
||||||
int difference = nextTimestamp - timestamp;
|
|
||||||
int realTimestampDifference = nextRealTimestamp - realTimestamp;
|
|
||||||
|
|
||||||
int smoothness = 0;
|
|
||||||
while(currentTimestamp + smoothness < nextTimestamp) {
|
|
||||||
currentTimestamp += smoothness;
|
|
||||||
|
|
||||||
SpectatorDataThirdPersonInfo thirdPersonInfo = new SpectatorDataThirdPersonInfo();
|
|
||||||
float percentage = (float)i/size;
|
|
||||||
percentage += ((currentTimestamp-timestamp)/(float)difference) * 1f/size;
|
|
||||||
|
|
||||||
float progress = ((currentTimestamp-timestamp)/(float)difference);
|
|
||||||
int interpolatedRealTimestamp = (int)(realTimestamp + (progress*realTimestampDifference));
|
|
||||||
|
|
||||||
thirdPersonInfoInterpolation.applyPoint(percentage, thirdPersonInfo);
|
|
||||||
|
|
||||||
smoothness = (int)(thirdPersonInfo.shoulderCamSmoothness*1000);
|
|
||||||
|
|
||||||
//calculate the Position relative to the Entity
|
|
||||||
// TODO
|
|
||||||
// AdvancedPosition entityPosition = ReplayHandler.getEntityPositionTracker().getEntityPositionAtTimestamp(entityID, currentTimestamp);
|
|
||||||
// if(entityPosition == null) continue;
|
|
||||||
//
|
|
||||||
// //first, rotate the camera pitch and yaw according to the settings
|
|
||||||
// entityPosition.setYaw(entityPosition.getYaw() + thirdPersonInfo.shoulderCamYawOffset);
|
|
||||||
// entityPosition.setPitch(entityPosition.getPitch() + thirdPersonInfo.shoulderCamPitchOffset);
|
|
||||||
//
|
|
||||||
// //next, move the camera point to fulfill the specified distance to the entity
|
|
||||||
// entityPosition = entityPosition.getDestination(-1 * thirdPersonInfo.shoulderCamDistance);
|
|
||||||
//
|
|
||||||
// underlyingKeyframes.add(new Keyframe<AdvancedPosition>(interpolatedRealTimestamp, entityPosition));
|
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPoint(Keyframe<AdvancedPosition> keyframe, int realTimestamp) {
|
|
||||||
if(!(keyframe.getValue() instanceof SpectatorData)) throw new IllegalArgumentException();
|
|
||||||
SpectatorData spectatorData = (SpectatorData)keyframe.getValue();
|
|
||||||
if(entityID == null) entityID = spectatorData.getSpectatedEntityID();
|
|
||||||
else if(entityID != spectatorData.getSpectatedEntityID()) throw new IllegalArgumentException();
|
|
||||||
points.add(Pair.of(realTimestamp, keyframe));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.registry;
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.events.handlers.keyboard.StaticKeybinding;
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class KeybindRegistry {
|
|
||||||
|
|
||||||
public static final String KEY_LIGHTING = "replaymod.input.lighting";
|
|
||||||
public static final String KEY_THUMBNAIL = "replaymod.input.thumbnail";
|
|
||||||
public static final String KEY_PLAYER_OVERVIEW = "replaymod.input.playeroverview";
|
|
||||||
public static final String KEY_CLEAR_KEYFRAMES = "replaymod.input.clearkeyframes";
|
|
||||||
public static final String KEY_SYNC_TIMELINE = "replaymod.input.synctimeline";
|
|
||||||
public static final String KEY_KEYFRAME_PRESETS = "replaymod.input.keyframerepository";
|
|
||||||
public static final String KEY_ROLL_CLOCKWISE = "replaymod.input.rollclockwise";
|
|
||||||
public static final String KEY_ROLL_COUNTERCLOCKWISE = "replaymod.input.rollcounterclockwise";
|
|
||||||
public static final String KEY_RESET_TILT = "replaymod.input.resettilt";
|
|
||||||
public static final String KEY_PLAY_PAUSE = "replaymod.input.playpause";
|
|
||||||
public static final String KEY_ADD_MARKER = "replaymod.input.marker";
|
|
||||||
public static final String KEY_PATH_PREVIEW = "replaymod.input.pathpreview";
|
|
||||||
public static final String KEY_ASSET_MANAGER = "replaymod.input.assetmanager";
|
|
||||||
public static final String KEY_OBJECT_MANAGER = "replaymod.input.objectmanager";
|
|
||||||
public static final String KEY_TOGGLE_INTERPOLATION = "replaymod.input.interpolation";
|
|
||||||
private static Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private static final List<KeyBinding> replayModKeyBindings;
|
|
||||||
|
|
||||||
static {
|
|
||||||
replayModKeyBindings = new ArrayList<KeyBinding>();
|
|
||||||
|
|
||||||
replayModKeyBindings.add(new KeyBinding(KEY_ROLL_CLOCKWISE, Keyboard.KEY_L, "replaymod.title"));
|
|
||||||
replayModKeyBindings.add(new KeyBinding(KEY_ROLL_COUNTERCLOCKWISE, Keyboard.KEY_J, "replaymod.title"));
|
|
||||||
replayModKeyBindings.add(new KeyBinding(KEY_RESET_TILT, Keyboard.KEY_K, "replaymod.title"));
|
|
||||||
|
|
||||||
replayModKeyBindings.add(new KeyBinding(KEY_CLEAR_KEYFRAMES, Keyboard.KEY_C, "replaymod.title"));
|
|
||||||
replayModKeyBindings.add(new KeyBinding(KEY_PATH_PREVIEW, Keyboard.KEY_H, "replaymod.title"));
|
|
||||||
|
|
||||||
replayModKeyBindings.add(new KeyBinding(KEY_SYNC_TIMELINE, Keyboard.KEY_V, "replaymod.title"));
|
|
||||||
|
|
||||||
replayModKeyBindings.add(new KeyBinding(KEY_ASSET_MANAGER, Keyboard.KEY_G, "replaymod.title"));
|
|
||||||
replayModKeyBindings.add(new KeyBinding(KEY_OBJECT_MANAGER, Keyboard.KEY_F, "replaymod.title"));
|
|
||||||
|
|
||||||
replayModKeyBindings.add(new KeyBinding(KEY_TOGGLE_INTERPOLATION, Keyboard.KEY_O, "replaymod.title"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void initialize() {
|
|
||||||
List<KeyBinding> bindings = new ArrayList<KeyBinding>(Arrays.asList(mc.gameSettings.keyBindings));
|
|
||||||
bindings.addAll(replayModKeyBindings);
|
|
||||||
|
|
||||||
mc.gameSettings.keyBindings = bindings.toArray(new KeyBinding[bindings.size()]);
|
|
||||||
|
|
||||||
mc.gameSettings.loadOptions();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static KeyBinding getKeyBinding(String binding) {
|
|
||||||
for (KeyBinding keyBinding : mc.gameSettings.keyBindings) {
|
|
||||||
if (binding.equals(keyBinding.getKeyDescription())) {
|
|
||||||
return keyBinding;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final int STATIC_DELETE_KEYFRAME = 0;
|
|
||||||
|
|
||||||
public static final StaticKeybinding[] staticKeybindings = new StaticKeybinding[]{new StaticKeybinding(STATIC_DELETE_KEYFRAME, Keyboard.KEY_DELETE)};
|
|
||||||
}
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.registry;
|
|
||||||
|
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
import com.replaymod.replay.events.ReplayCloseEvent;
|
|
||||||
import eu.crushedpixel.replaymod.gui.GuiReplaySaving;
|
|
||||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
|
||||||
|
|
||||||
public class ReplayFileAppender {
|
|
||||||
|
|
||||||
private Multimap<File, Pair<File, String>> filesToMove = ArrayListMultimap.create();
|
|
||||||
private Queue<File> filesToRewrite = new ConcurrentLinkedQueue<File>();
|
|
||||||
|
|
||||||
private List<GuiReplaySaving> listeners = new ArrayList<GuiReplaySaving>();
|
|
||||||
|
|
||||||
//this is true if the DataListener is currently busy saving a newly recorded Replay File
|
|
||||||
private boolean newReplayFileWriting = false;
|
|
||||||
|
|
||||||
public void startNewReplayFileWriting() {
|
|
||||||
newReplayFileWriting = true;
|
|
||||||
|
|
||||||
openGuiSavingScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openGuiSavingScreen() {
|
|
||||||
if(!FMLClientHandler.instance().isGUIOpen(GuiReplaySaving.class)) {
|
|
||||||
Minecraft.getMinecraft().addScheduledTask(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
final GuiReplaySaving savingScreen = new GuiReplaySaving(null);
|
|
||||||
Minecraft.getMinecraft().displayGuiScreen(savingScreen);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void replayFileWritingFinished() {
|
|
||||||
newReplayFileWriting = false;
|
|
||||||
callListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerModifiedFile(File toAdd, String name, File replayFile) {
|
|
||||||
//first, remove any files with the same name assigned to this Replay File
|
|
||||||
for (Iterator<Pair<File, String>> iter = filesToMove.get(replayFile).iterator(); iter.hasNext(); ) {
|
|
||||||
if (iter.next().getRight().equals(name)) {
|
|
||||||
iter.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//then, assign the file/name pair to the Replay File
|
|
||||||
filesToMove.put(replayFile, Pair.of(toAdd, name));
|
|
||||||
|
|
||||||
//finally, add the Replay File to the Queue if not already contained
|
|
||||||
if(!filesToRewrite.contains(replayFile)) {
|
|
||||||
filesToRewrite.add(replayFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteAllFilesByFolder(String folderName, File replayFile) {
|
|
||||||
Iterator<Pair<File, String>> iter = filesToMove.get(replayFile).iterator();
|
|
||||||
List<String> toDelete = new ArrayList<String>();
|
|
||||||
while(iter.hasNext()) {
|
|
||||||
Pair<File, String> pair = iter.next();
|
|
||||||
if (pair.getRight().startsWith(folderName)) {
|
|
||||||
toDelete.add(pair.getRight());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(String del : toDelete) {
|
|
||||||
registerModifiedFile(null, del, replayFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!filesToRewrite.contains(replayFile)) {
|
|
||||||
filesToRewrite.add(replayFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addFinishListener(GuiReplaySaving gui) {
|
|
||||||
listeners.add(gui);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onReplayExit(ReplayCloseEvent.Post event) {
|
|
||||||
if(!filesToRewrite.isEmpty()) {
|
|
||||||
openGuiSavingScreen();
|
|
||||||
writeFiles();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeFiles() {
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
while(!filesToRewrite.isEmpty()) {
|
|
||||||
File replayFile = filesToRewrite.poll();
|
|
||||||
if(replayFile != null) {
|
|
||||||
if(replayFile.canWrite()) {
|
|
||||||
try {
|
|
||||||
Collection<Pair<File, String>> ftm = filesToMove.get(replayFile);
|
|
||||||
|
|
||||||
File replayFile2 = replayFile;
|
|
||||||
|
|
||||||
if(replayFile.getParentFile().equals(ReplayFileIO.getReplayDownloadFolder())) {
|
|
||||||
String fileName = FilenameUtils.getName(replayFile.getAbsolutePath());
|
|
||||||
File copyTo = new File(ReplayFileIO.getReplayFolder(), fileName);
|
|
||||||
copyTo = ReplayFileIO.getNextFreeFile(copyTo);
|
|
||||||
|
|
||||||
FileUtils.copyFile(replayFile, copyTo);
|
|
||||||
replayFile = copyTo;
|
|
||||||
}
|
|
||||||
|
|
||||||
HashMap<String, File> toAdd = new HashMap<String, File>();
|
|
||||||
for(Pair<File, String> p : ftm) {
|
|
||||||
if(p.getLeft() == null || p.getLeft().exists()) {
|
|
||||||
toAdd.put(p.getRight(), p.getLeft());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ReplayFileIO.addFilesToZip(replayFile, toAdd);
|
|
||||||
|
|
||||||
//delete all written files
|
|
||||||
for(Pair<File, String> p : ftm) {
|
|
||||||
if(p.getLeft() != null) {
|
|
||||||
try {
|
|
||||||
FileUtils.forceDelete(p.getLeft());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
filesToMove.removeAll(replayFile2);
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
filesToRewrite.add(replayFile);
|
|
||||||
} finally {
|
|
||||||
callListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
filesToRewrite.add(replayFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callListeners();
|
|
||||||
}
|
|
||||||
}, "replay-file-appender").start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void callListeners() {
|
|
||||||
if(filesToMove.isEmpty() && !newReplayFileWriting) {
|
|
||||||
for(final GuiReplaySaving gui : listeners) {
|
|
||||||
Minecraft.getMinecraft().addScheduledTask(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
gui.dispatch();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
listeners = new ArrayList<GuiReplaySaving>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.registry;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraftforge.client.GuiIngameForge;
|
|
||||||
|
|
||||||
public class ReplayGuiRegistry {
|
|
||||||
|
|
||||||
public static boolean hidden = false;
|
|
||||||
private static Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
|
|
||||||
public static void hide() {
|
|
||||||
if(hidden) return;
|
|
||||||
GuiIngameForge.renderExperiance = false;
|
|
||||||
GuiIngameForge.renderArmor = false;
|
|
||||||
GuiIngameForge.renderAir = false;
|
|
||||||
GuiIngameForge.renderHealth = false;
|
|
||||||
GuiIngameForge.renderHotbar = false;
|
|
||||||
GuiIngameForge.renderFood = false;
|
|
||||||
GuiIngameForge.renderBossHealth = false;
|
|
||||||
GuiIngameForge.renderHelmet = false;
|
|
||||||
GuiIngameForge.renderPortal = false;
|
|
||||||
GuiIngameForge.renderHealthMount = false;
|
|
||||||
GuiIngameForge.renderJumpBar = false;
|
|
||||||
GuiIngameForge.renderObjective = false;
|
|
||||||
|
|
||||||
hidden = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void show() {
|
|
||||||
mc.gameSettings.hideGUI = false;
|
|
||||||
|
|
||||||
GuiIngameForge.renderExperiance = true;
|
|
||||||
GuiIngameForge.renderArmor = true;
|
|
||||||
GuiIngameForge.renderAir = true;
|
|
||||||
GuiIngameForge.renderHealth = true;
|
|
||||||
GuiIngameForge.renderHotbar = true;
|
|
||||||
GuiIngameForge.renderFood = true;
|
|
||||||
GuiIngameForge.renderBossHealth = true;
|
|
||||||
GuiIngameForge.renderHelmet = true;
|
|
||||||
GuiIngameForge.renderPortal = true;
|
|
||||||
GuiIngameForge.renderHealthMount = true;
|
|
||||||
GuiIngameForge.renderJumpBar = true;
|
|
||||||
GuiIngameForge.renderObjective = true;
|
|
||||||
|
|
||||||
hidden = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.registry;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ResourceHelper {
|
|
||||||
|
|
||||||
private static BufferedImage defaultThumb;
|
|
||||||
private static List<ResourceLocation> openResources = new ArrayList<ResourceLocation>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
defaultThumb = ImageIO.read(ResourceHelper.class.getClassLoader().getResourceAsStream("default_thumb.jpg"));
|
|
||||||
} catch(Exception e) {
|
|
||||||
defaultThumb = new BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerResource(ResourceLocation loc) {
|
|
||||||
if(!openResources.contains(loc)) openResources.add(loc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isRegistered(ResourceLocation loc) {
|
|
||||||
return openResources.contains(loc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void freeResource(final ResourceLocation loc) {
|
|
||||||
Minecraft.getMinecraft().addScheduledTask(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Minecraft.getMinecraft().getTextureManager().deleteTexture(loc);
|
|
||||||
openResources.remove(loc);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void freeAllResources() {
|
|
||||||
Minecraft.getMinecraft().addScheduledTask(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
for(ResourceLocation loc : openResources) {
|
|
||||||
Minecraft.getMinecraft().getTextureManager().deleteTexture(loc);
|
|
||||||
}
|
|
||||||
|
|
||||||
openResources = new ArrayList<ResourceLocation>();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BufferedImage getDefaultThumbnail() {
|
|
||||||
return defaultThumb;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.registry;
|
|
||||||
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class UploadedFileHandler {
|
|
||||||
|
|
||||||
private Configuration configuration;
|
|
||||||
|
|
||||||
public UploadedFileHandler(File confDir) {
|
|
||||||
try {
|
|
||||||
File confFile = new File(confDir, "uploaded");
|
|
||||||
FileUtils.touch(confFile);
|
|
||||||
configuration = new Configuration(confFile);
|
|
||||||
configuration.load();
|
|
||||||
|
|
||||||
configuration.get("uploaded", "hashes", new String[0]);
|
|
||||||
|
|
||||||
configuration.save();
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void markAsUploaded(File file) throws IOException {
|
|
||||||
String checksum = String.valueOf(FileUtils.checksumCRC32(file));
|
|
||||||
List<String> hashes = new ArrayList<String>(Arrays.asList(configuration.get("uploaded",
|
|
||||||
"hashes", new String[0]).getStringList()));
|
|
||||||
configuration.removeCategory(configuration.getCategory("uploaded"));
|
|
||||||
|
|
||||||
hashes.add(checksum);
|
|
||||||
|
|
||||||
configuration.get("uploaded", "hashes", hashes.toArray(new String[hashes.size()]));
|
|
||||||
configuration.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUploaded(File file) {
|
|
||||||
try {
|
|
||||||
String checksum = String.valueOf(FileUtils.checksumCRC32(file));
|
|
||||||
List<String> hashes = new ArrayList<String>(Arrays.asList(configuration.get("uploaded",
|
|
||||||
"hashes", new String[0]).getStringList()));
|
|
||||||
return hashes.contains(checksum);
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.renderer;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows users to render custom images in the World.
|
|
||||||
*/
|
|
||||||
public class CustomObjectRenderer {
|
|
||||||
|
|
||||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void renderCustomObjects(RenderWorldLastEvent event) {
|
|
||||||
// TODO
|
|
||||||
// if(!ReplayHandler.isInReplay() || mc.getRenderViewEntity() == null || ReplayHandler.getCustomImageObjects().isEmpty()) return;
|
|
||||||
//
|
|
||||||
// double dX = mc.getRenderViewEntity().lastTickPosX + (mc.getRenderViewEntity().posX - mc.getRenderViewEntity().lastTickPosX) * (double)event.partialTicks;
|
|
||||||
// double dY = mc.getRenderViewEntity().lastTickPosY + (mc.getRenderViewEntity().posY - mc.getRenderViewEntity().lastTickPosY) * (double)event.partialTicks;
|
|
||||||
// double dZ = mc.getRenderViewEntity().lastTickPosZ + (mc.getRenderViewEntity().posZ - mc.getRenderViewEntity().lastTickPosZ) * (double)event.partialTicks;
|
|
||||||
//
|
|
||||||
// GlStateManager.enableTexture2D();
|
|
||||||
//
|
|
||||||
// GlStateManager.enableBlend();
|
|
||||||
// GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
//
|
|
||||||
// for(CustomImageObject object : ReplayHandler.getCustomImageObjects()) {
|
|
||||||
// drawCustomImageObject(dX, dY, dZ, object);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void drawCustomImageObject(double playerX, double playerY, double playerZ, CustomImageObject customImageObject) {
|
|
||||||
// ResourceLocation resourceLocation = customImageObject.getResourceLocation();
|
|
||||||
//
|
|
||||||
// if(customImageObject.getLinkedAsset() == null
|
|
||||||
// || ReplayHandler.getAssetRepository().getAssetByUUID(customImageObject.getLinkedAsset()) == null
|
|
||||||
// || resourceLocation == null) return;
|
|
||||||
//
|
|
||||||
// GlStateManager.pushMatrix();
|
|
||||||
// GlStateManager.pushAttrib();
|
|
||||||
//
|
|
||||||
// Tessellator tessellator = Tessellator.getInstance();
|
|
||||||
// WorldRenderer renderer = tessellator.getWorldRenderer();
|
|
||||||
//
|
|
||||||
// mc.renderEngine.bindTexture(resourceLocation);
|
|
||||||
//
|
|
||||||
// int renderTimestamp;
|
|
||||||
// if(mc.currentScreen instanceof GuiObjectManager) {
|
|
||||||
// renderTimestamp = ((GuiObjectManager) mc.currentScreen).getObjectKeyframeTimeline().cursorPosition;
|
|
||||||
// } else if(ReplayProcess.isVideoRecording()) {
|
|
||||||
// renderTimestamp = ReplayProcess.getVideoRenderer().getVideoTime();
|
|
||||||
// } else {
|
|
||||||
// renderTimestamp = ReplayHandler.getRealTimelineCursor();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Transformation transformation = customImageObject.getTransformations().getTransformationForTimestamp(renderTimestamp);
|
|
||||||
//
|
|
||||||
// Position objectAnchor = transformation.getAnchor();
|
|
||||||
// Position objectPosition = transformation.getPosition();
|
|
||||||
// Position objectOrientation = transformation.getOrientation();
|
|
||||||
//
|
|
||||||
// double x = objectPosition.getX() - playerX;
|
|
||||||
// double y = objectPosition.getY() - playerY;
|
|
||||||
// double z = objectPosition.getZ() - playerZ;
|
|
||||||
//
|
|
||||||
// GL11.glNormal3f(0, 1, 0);
|
|
||||||
//
|
|
||||||
// GlStateManager.translate(x, y + 1.4, z);
|
|
||||||
//
|
|
||||||
// GlStateManager.rotate((float) -objectOrientation.getX(), 0, 1, 0);
|
|
||||||
// GlStateManager.rotate((float) objectOrientation.getY(), 0, 0, 1);
|
|
||||||
// GlStateManager.rotate((float) objectOrientation.getZ(), 1, 0, 0);
|
|
||||||
//
|
|
||||||
// float opacity = (float)transformation.getOpacity() / 100;
|
|
||||||
// GlStateManager.color(1, 1, 1, opacity);
|
|
||||||
//
|
|
||||||
// float width = (float)(customImageObject.getWidth() * transformation.getScale().getX() / 100f);
|
|
||||||
// float height = (float)(customImageObject.getHeight() * transformation.getScale().getY() / 100f);
|
|
||||||
//
|
|
||||||
// float minX = (float)(-width/2 + objectAnchor.getX());
|
|
||||||
// float maxX = (float)(width/2 + objectAnchor.getX());
|
|
||||||
// float minY = (float)(-height/2 + objectAnchor.getY());
|
|
||||||
// float maxY = (float)(height/2 + objectAnchor.getY());
|
|
||||||
//
|
|
||||||
// renderer.startDrawingQuads();
|
|
||||||
//
|
|
||||||
// renderer.addVertexWithUV(minX, minY, 0, 1, 1);
|
|
||||||
// renderer.addVertexWithUV(minX, maxY, 0, 1, 0);
|
|
||||||
// renderer.addVertexWithUV(maxX, maxY, 0, 0, 0);
|
|
||||||
// renderer.addVertexWithUV(maxX, minY, 0, 0, 1);
|
|
||||||
//
|
|
||||||
// renderer.addVertexWithUV(maxX, maxY, 0, 0, 0);
|
|
||||||
// renderer.addVertexWithUV(minX, maxY, 0, 1, 0);
|
|
||||||
// renderer.addVertexWithUV(minX, minY, 0, 1, 1);
|
|
||||||
// renderer.addVertexWithUV(maxX, minY, 0, 0, 1);
|
|
||||||
//
|
|
||||||
// tessellator.draw();
|
|
||||||
// renderer.setTranslation(0, 0, 0);
|
|
||||||
//
|
|
||||||
// GlStateManager.popAttrib();
|
|
||||||
// GlStateManager.popMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.replay;
|
|
||||||
|
|
||||||
import net.minecraft.entity.DataWatcher;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
|
||||||
import net.minecraft.util.Rotations;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A Data Watcher which is applied to the Camera Entity to avoid both NPEs and the Screen constantly jittering (because of the entity being dead)
|
|
||||||
*/
|
|
||||||
public class LesserDataWatcher extends DataWatcher {
|
|
||||||
|
|
||||||
public LesserDataWatcher(Entity owner) {
|
|
||||||
super(owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addObject(int id, Object object) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addObjectByDataType(int id, int type) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte getWatchableObjectByte(int id) {
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public short getWatchableObjectShort(int id) {
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getWatchableObjectInt(int id) {
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getWatchableObjectFloat(int id) {
|
|
||||||
return 10f;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getWatchableObjectString(int id) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getWatchableObjectItemStack(int id) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Rotations getWatchableObjectRotations(int id) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateObject(int id, Object newData) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setObjectWatched(int id) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasObjectChanged() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List getChanged() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(PacketBuffer buffer) throws IOException {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List getAllWatched() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateWatchedObjectsFromList(List p_75687_1_) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getIsBlank() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void func_111144_e() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,522 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.replay;
|
|
||||||
|
|
||||||
// For later use in render and path module
|
|
||||||
public class ReplayHandler {
|
|
||||||
//
|
|
||||||
// private static Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
// private static long lastExit;
|
|
||||||
// private static NetworkManager networkManager;
|
|
||||||
// private static EmbeddedChannel channel;
|
|
||||||
// private int realTimelinePosition = 0;
|
|
||||||
//
|
|
||||||
// private static Keyframe selectedKeyframe;
|
|
||||||
//
|
|
||||||
// private static boolean inPath = false;
|
|
||||||
//
|
|
||||||
// private static AdvancedPositionKeyframeList positionKeyframes = new AdvancedPositionKeyframeList();
|
|
||||||
// private static KeyframeList<TimestampValue> timeKeyframes = new KeyframeList<TimestampValue>();
|
|
||||||
//
|
|
||||||
// private static boolean inReplay = false;
|
|
||||||
// private static AdvancedPosition lastPosition = null;
|
|
||||||
//
|
|
||||||
// private static Set<Marker> markers;
|
|
||||||
//
|
|
||||||
// private static float cameraTilt = 0;
|
|
||||||
//
|
|
||||||
// private static KeyframeSet[] keyframeRepository = new KeyframeSet[]{};
|
|
||||||
//
|
|
||||||
// @Getter @Setter
|
|
||||||
// private static AssetRepository assetRepository;
|
|
||||||
//
|
|
||||||
// private static CustomObjectRepository customImageObjects = new CustomObjectRepository();
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * The file currently being played.
|
|
||||||
// */
|
|
||||||
// private static ReplayFile currentReplayFile;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Currently active replay restrictions.
|
|
||||||
// */
|
|
||||||
// private static Restrictions restrictions;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * The EntityPositionTracker for the current Replay File.
|
|
||||||
// */
|
|
||||||
// @Getter
|
|
||||||
// private static EntityPositionTracker entityPositionTracker;
|
|
||||||
//
|
|
||||||
// public static KeyframeSet[] getKeyframeRepository() {
|
|
||||||
// return keyframeRepository;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void setKeyframeRepository(KeyframeSet[] repo, boolean write) {
|
|
||||||
// keyframeRepository = repo;
|
|
||||||
// if(write) {
|
|
||||||
// try (OutputStream out = currentReplayFile.write("paths.json")) {
|
|
||||||
// out.write(new Gson().toJson(repo).getBytes());
|
|
||||||
// } catch (IOException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static Set<Marker> getMarkers() {
|
|
||||||
// return markers;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void setMarkers(Set<Marker> markers, boolean write) {
|
|
||||||
// ReplayHandler.markers = markers;
|
|
||||||
// if(write) {
|
|
||||||
// try {
|
|
||||||
// currentReplayFile.writeMarkers(markers);
|
|
||||||
// } catch (IOException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void useKeyframePresetFromRepository(int index) {
|
|
||||||
// useKeyframePreset(keyframeRepository[index]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void useKeyframePreset(KeyframeSet keyframeSet) {
|
|
||||||
// setCustomImageObjects(Arrays.asList(keyframeSet.getCustomObjects()));
|
|
||||||
//
|
|
||||||
// Keyframe[] kfs = keyframeSet.getKeyframes();
|
|
||||||
//
|
|
||||||
// positionKeyframes.clear();
|
|
||||||
// timeKeyframes.clear();
|
|
||||||
// for(Keyframe kf : kfs) {
|
|
||||||
// addKeyframe(kf);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// selectKeyframe(null);
|
|
||||||
//
|
|
||||||
// fireKeyframesModifyEvent();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void spectateEntity(Entity e) {
|
|
||||||
// getCameraEntity().spectate(e);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void spectateCamera() {
|
|
||||||
// spectateEntity(null);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static boolean isCamera() {
|
|
||||||
// return mc.thePlayer instanceof CameraEntity && mc.thePlayer == mc.getRenderViewEntity();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void startPath(RenderOptions renderOptions, boolean fromStart) {
|
|
||||||
// if(!com.replaymod.replay.ReplayHandler.isInPath()) {
|
|
||||||
// try {
|
|
||||||
// ReplayProcess.startReplayProcess(renderOptions, fromStart);
|
|
||||||
// } catch (ReportedException e) {
|
|
||||||
// // We have to manually unwrap OOM errors as Minecraft doesn't handle them when they're wrapped
|
|
||||||
// Throwable prevCause = null;
|
|
||||||
// Throwable cause = e;
|
|
||||||
// while (cause != null && cause != prevCause) {
|
|
||||||
// if (cause instanceof OutOfMemoryError) {
|
|
||||||
// // Nevertheless save the crash report in case we actually need it
|
|
||||||
// Minecraft minecraft = Minecraft.getMinecraft();
|
|
||||||
// CrashReport crashReport = e.getCrashReport();
|
|
||||||
// minecraft.addGraphicsAndWorldToCrashReport(crashReport);
|
|
||||||
// Bootstrap.printToSYSOUT(crashReport.getCompleteReport());
|
|
||||||
// File folder = new File(minecraft.mcDataDir, "crash-reports");
|
|
||||||
// File file = new File(folder, "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-client.txt");
|
|
||||||
// crashReport.saveToFile(file);
|
|
||||||
// throw (OutOfMemoryError) cause;
|
|
||||||
// }
|
|
||||||
// prevCause = cause;
|
|
||||||
// cause = e.getCause();
|
|
||||||
// }
|
|
||||||
// throw e;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void interruptReplay() {
|
|
||||||
// ReplayProcess.stopReplayProcess(false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static boolean isInPath() {
|
|
||||||
// return inPath;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void setInPath(boolean replaying) {
|
|
||||||
// inPath = replaying;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static CameraEntity getCameraEntity() {
|
|
||||||
// return mc.thePlayer instanceof CameraEntity ? (CameraEntity) mc.thePlayer : null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static float getCameraTilt() {
|
|
||||||
// return cameraTilt;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void setCameraTilt(float tilt) {
|
|
||||||
// cameraTilt = tilt;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void addCameraTilt(float tilt) {
|
|
||||||
// cameraTilt += tilt;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void toggleMarker() {
|
|
||||||
// // TODO
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void addTimeKeyframe(Keyframe<TimestampValue> property) {
|
|
||||||
// timeKeyframes.add(property);
|
|
||||||
// selectKeyframe(property);
|
|
||||||
//
|
|
||||||
// fireKeyframesModifyEvent();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void addPositionKeyframe(Keyframe<AdvancedPosition> property) {
|
|
||||||
// positionKeyframes.add(property);
|
|
||||||
// selectKeyframe(property);
|
|
||||||
//
|
|
||||||
// fireKeyframesModifyEvent();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @SuppressWarnings("unchecked")
|
|
||||||
// public static void addKeyframe(Keyframe property) {
|
|
||||||
// if(property.getValue() instanceof AdvancedPosition) {
|
|
||||||
// addPositionKeyframe(property);
|
|
||||||
// } else if(property.getValue() instanceof TimestampValue) {
|
|
||||||
// addTimeKeyframe(property);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void removeKeyframe(Keyframe property) {
|
|
||||||
// if(property.getValue() instanceof AdvancedPosition) {
|
|
||||||
// positionKeyframes.remove(property);
|
|
||||||
// } else if(property.getValue() instanceof TimestampValue) {
|
|
||||||
// timeKeyframes.remove(property);
|
|
||||||
// }
|
|
||||||
// // TODO Marker
|
|
||||||
//
|
|
||||||
// if(property == selectedKeyframe) {
|
|
||||||
// selectKeyframe(null);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// fireKeyframesModifyEvent();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static AdvancedPositionKeyframeList getPositionKeyframes() {
|
|
||||||
// return positionKeyframes;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static KeyframeList<TimestampValue> getTimeKeyframes() {
|
|
||||||
// return timeKeyframes;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static ArrayList<Keyframe> getAllKeyframes() {
|
|
||||||
// ArrayList<Keyframe> keyframeList = new ArrayList<Keyframe>();
|
|
||||||
// keyframeList.addAll(positionKeyframes);
|
|
||||||
// keyframeList.addAll(timeKeyframes);
|
|
||||||
//
|
|
||||||
// return keyframeList;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void resetKeyframes(final boolean resetMarkers, boolean callback) {
|
|
||||||
// if(getPositionKeyframes().isEmpty() && getTimeKeyframes().isEmpty()) return;
|
|
||||||
//
|
|
||||||
// if(!callback) {
|
|
||||||
// resetKeyframes(resetMarkers);
|
|
||||||
// } else {
|
|
||||||
// mc.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback() {
|
|
||||||
// @Override
|
|
||||||
// public void confirmClicked(boolean result, int id) {
|
|
||||||
// if(result) {
|
|
||||||
// resetKeyframes(resetMarkers);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// mc.displayGuiScreen(null);
|
|
||||||
// }
|
|
||||||
// }, I18n.format("replaymod.gui.clearcallback.title"), I18n.format("replaymod.gui.clearcallback.message"), 1));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private static void resetKeyframes(boolean resetMarkers) {
|
|
||||||
// timeKeyframes.clear();
|
|
||||||
// positionKeyframes.clear();
|
|
||||||
// selectKeyframe(null);
|
|
||||||
//
|
|
||||||
// if(resetMarkers) {
|
|
||||||
// // TODO Markers
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// setRealTimelineCursor(0); TODO
|
|
||||||
//
|
|
||||||
// fireKeyframesModifyEvent();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void selectKeyframe(Keyframe kf) {
|
|
||||||
// selectedKeyframe = kf;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static boolean isSelected(Keyframe kf) {
|
|
||||||
// return kf == selectedKeyframe;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static boolean isInReplay() {
|
|
||||||
// return inReplay;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void startReplay(File file) {
|
|
||||||
// try {
|
|
||||||
// startReplay(file, true);
|
|
||||||
// } catch (IOException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void startReplay(File file, boolean asyncMode) throws IOException {
|
|
||||||
// entityPositionTracker = new EntityPositionTracker(file);
|
|
||||||
// entityPositionTracker.load();
|
|
||||||
//
|
|
||||||
// ReplayMod.chatMessageHandler.initialize();
|
|
||||||
// mc.ingameGUI.getChatGUI().clearChatMessages();
|
|
||||||
// resetKeyframes(true);
|
|
||||||
//
|
|
||||||
// if(ReplayMod.replaySender != null) {
|
|
||||||
// ReplayMod.replaySender.terminateReplay();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(channel != null) {
|
|
||||||
// channel.close();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// setCameraTilt(0);
|
|
||||||
//
|
|
||||||
// restrictions = new Restrictions();
|
|
||||||
//
|
|
||||||
// networkManager = new NetworkManager(EnumPacketDirection.CLIENTBOUND) {
|
|
||||||
// @Override
|
|
||||||
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable t) {
|
|
||||||
// t.printStackTrace();
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// INetHandlerPlayClient pc = new NetHandlerPlayClient(mc, null, networkManager, new GameProfile(UUID.randomUUID(), "Player"));
|
|
||||||
// networkManager.setNetHandler(pc);
|
|
||||||
//
|
|
||||||
// channel = new EmbeddedChannel(networkManager);
|
|
||||||
// channel.attr(NetworkDispatcher.FML_DISPATCHER).set(new NetworkDispatcher(networkManager));
|
|
||||||
//
|
|
||||||
// // Open replay
|
|
||||||
// currentReplayFile = new ZipReplayFile(new ReplayStudio(), file);
|
|
||||||
//
|
|
||||||
// KeyframeSet[] paths;
|
|
||||||
// Optional<InputStream> is = currentReplayFile.get("paths.json");
|
|
||||||
// if (!is.isPresent()) {
|
|
||||||
// is = currentReplayFile.get("paths");
|
|
||||||
// }
|
|
||||||
// if (is.isPresent()) {
|
|
||||||
// try (Reader reader = new InputStreamReader(is.get())) {
|
|
||||||
// paths = new GsonBuilder().registerTypeAdapter(KeyframeSet[].class, new LegacyKeyframeSetAdapter())
|
|
||||||
// .create().fromJson(reader, KeyframeSet[].class);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// paths = new KeyframeSet[0];
|
|
||||||
// }
|
|
||||||
// com.replaymod.replay.ReplayHandler.setKeyframeRepository(paths == null ? new KeyframeSet[0] : paths, false);
|
|
||||||
// com.replaymod.replay.ReplayHandler.selectKeyframe(null);
|
|
||||||
// com.replaymod.replay.ReplayHandler.setMarkers(currentReplayFile.getMarkers().or(Collections.<Marker>emptySet()), false);
|
|
||||||
// PlayerHandler.loadPlayerVisibilityConfiguration(currentReplayFile.getInvisiblePlayers());
|
|
||||||
//
|
|
||||||
// //load assets
|
|
||||||
// assetRepository = new AssetRepository();
|
|
||||||
// for (ReplayAssetEntry entry : currentReplayFile.getAssets()) {
|
|
||||||
// UUID uuid = entry.getUuid();
|
|
||||||
// assetRepository.addAsset(entry.getName(), currentReplayFile.getAsset(uuid).get(), uuid);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// customImageObjects = new CustomObjectRepository();
|
|
||||||
//
|
|
||||||
// ReplayMod.replaySender = new ReplaySender(currentReplayFile, asyncMode);
|
|
||||||
// channel.pipeline().addFirst(ReplayMod.replaySender);
|
|
||||||
// channel.pipeline().fireChannelActive();
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// ReplayMod.overlay.resetUI(true);
|
|
||||||
// } catch(Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// // TODO: Fix exception
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //Load lighting and trigger update
|
|
||||||
// ReplayMod.replaySettings.setLightingEnabled(ReplayMod.replaySettings.isLightingEnabled());
|
|
||||||
//
|
|
||||||
// inReplay = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void restartReplay() {
|
|
||||||
// mc.ingameGUI.getChatGUI().clearChatMessages();
|
|
||||||
//
|
|
||||||
// if(channel != null) {
|
|
||||||
// channel.close();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// restrictions = new Restrictions();
|
|
||||||
//
|
|
||||||
// networkManager = new NetworkManager(EnumPacketDirection.CLIENTBOUND) {
|
|
||||||
// @Override
|
|
||||||
// public void exceptionCaught(ChannelHandlerContext ctx, Throwable t) {
|
|
||||||
// t.printStackTrace();
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// INetHandlerPlayClient pc = new NetHandlerPlayClient(mc, null, networkManager, new GameProfile(UUID.randomUUID(), "Player"));
|
|
||||||
// networkManager.setNetHandler(pc);
|
|
||||||
//
|
|
||||||
// channel = new EmbeddedChannel(networkManager);
|
|
||||||
// channel.attr(NetworkDispatcher.FML_DISPATCHER).set(new NetworkDispatcher(networkManager));
|
|
||||||
//
|
|
||||||
// channel.pipeline().addFirst(ReplayMod.replaySender);
|
|
||||||
// channel.pipeline().fireChannelActive();
|
|
||||||
//
|
|
||||||
// mc.addScheduledTask(new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// try {
|
|
||||||
// ReplayMod.overlay.resetUI(false);
|
|
||||||
// } catch(Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// inReplay = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void endReplay() {
|
|
||||||
// if(ReplayMod.replaySender != null) {
|
|
||||||
// ReplayMod.replaySender.terminateReplay();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (currentReplayFile != null) {
|
|
||||||
// try {
|
|
||||||
// currentReplayFile.save();
|
|
||||||
// currentReplayFile.close();
|
|
||||||
// } catch (IOException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// currentReplayFile = null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// resetKeyframes(true);
|
|
||||||
//
|
|
||||||
// PlayerHandler.resetHiddenPlayers();
|
|
||||||
// ReplayGuiRegistry.show();
|
|
||||||
// LightingHandler.setLighting(false);
|
|
||||||
//
|
|
||||||
// if (mc.theWorld != null) {
|
|
||||||
// mc.theWorld.sendQuittingDisconnectingPacket();
|
|
||||||
// mc.loadWorld(null);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// CameraEntity.spectating = null;
|
|
||||||
//
|
|
||||||
// inReplay = false;
|
|
||||||
// lastExit = System.currentTimeMillis();
|
|
||||||
//
|
|
||||||
// FMLCommonHandler.instance().bus().post(new ReplayExitEvent());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void setInReplay(boolean inReplay1) {
|
|
||||||
// inReplay = inReplay1;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static Keyframe getSelectedKeyframe() {
|
|
||||||
// return selectedKeyframe;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// public static int getRealTimelineCursor() {
|
|
||||||
//// return realTimelinePosition;
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// public static void setRealTimelineCursor(int pos) {
|
|
||||||
//// realTimelinePosition = pos;
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
// public static AdvancedPosition getLastPosition() {
|
|
||||||
// return lastPosition;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Getter
|
|
||||||
// private static boolean forceLastPosition = false;
|
|
||||||
//
|
|
||||||
// public static void setLastPosition(AdvancedPosition position, boolean force) {
|
|
||||||
// lastPosition = position;
|
|
||||||
// forceLastPosition = force;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void moveCameraToLastPosition() {
|
|
||||||
// //get the camera position we had before jumping in time
|
|
||||||
// AdvancedPosition pos = com.replaymod.replay.ReplayHandler.getLastPosition();
|
|
||||||
// CameraEntity cam = com.replaymod.replay.ReplayHandler.getCameraEntity();
|
|
||||||
// if (cam != null && pos != null) {
|
|
||||||
// // Move camera back in case we have been respawned, unless we're more than ReplayMod.TP_DISTANCE_LIMIT away from that point
|
|
||||||
// // this is ignored if we explicitly said to respect this position, e.g. when jumping to marker keyframes.
|
|
||||||
// if (com.replaymod.replay.ReplayHandler.isForceLastPosition() ||
|
|
||||||
// (Math.abs(pos.getX() - cam.posX) < ReplayMod.TP_DISTANCE_LIMIT &&
|
|
||||||
// Math.abs(pos.getZ() - cam.posZ) < ReplayMod.TP_DISTANCE_LIMIT)) {
|
|
||||||
// cam.moveAbsolute(pos);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static ReplayFile getReplayFile() {
|
|
||||||
// return currentReplayFile;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Synchronizes the cursor on the Keyframe Timeline with the Replay Time
|
|
||||||
// * @param ignoreReplaySpeed If true, it always uses 1.0 as the stretch factor
|
|
||||||
// */
|
|
||||||
// public static void syncTimeCursor(boolean ignoreReplaySpeed) {
|
|
||||||
// selectKeyframe(null);
|
|
||||||
//
|
|
||||||
// int curTime = ReplayMod.replaySender.currentTimeStamp();
|
|
||||||
//
|
|
||||||
// int prevTime, prevRealTime;
|
|
||||||
//
|
|
||||||
// Keyframe<TimestampValue> property = timeKeyframes.last();
|
|
||||||
//
|
|
||||||
// if(property == null) {
|
|
||||||
// prevTime = 0;
|
|
||||||
// prevRealTime = 0;
|
|
||||||
// } else {
|
|
||||||
// prevTime = (int)property.getValue().value;
|
|
||||||
// prevRealTime = property.getRealTimestamp();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// double speed = ignoreReplaySpeed ? 1 : ReplayMod.overlay.getSpeedSliderValue();
|
|
||||||
//
|
|
||||||
// int newCursorPos = Math.min(GuiReplayOverlay.KEYFRAME_TIMELINE_LENGTH, (int)(prevRealTime+((curTime-prevTime)/speed)));
|
|
||||||
//
|
|
||||||
//// setRealTimelineCursor(newCursorPos); TODO
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static List<CustomImageObject> getCustomImageObjects() {
|
|
||||||
// return customImageObjects.getObjects();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void setCustomImageObjects(List<CustomImageObject> objects) {
|
|
||||||
// customImageObjects.setObjects(new ArrayList<CustomImageObject>(objects));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void fireKeyframesModifyEvent() {
|
|
||||||
// FMLCommonHandler.instance().bus().post(new KeyframesModifyEvent(positionKeyframes, timeKeyframes));
|
|
||||||
// positionKeyframes.recalculate(ReplayMod.replaySettings.isLinearMovement());
|
|
||||||
// timeKeyframes.recalculate(ReplayMod.replaySettings.isLinearMovement());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static Restrictions getRestrictions() {
|
|
||||||
// return restrictions;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@@ -1,223 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.settings;
|
|
||||||
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
|
||||||
import net.minecraftforge.common.config.Property;
|
|
||||||
|
|
||||||
public class ReplaySettings {
|
|
||||||
|
|
||||||
private static final String[] CATEGORIES = new String[]{"recording", "replay", "render", "advanced"};
|
|
||||||
|
|
||||||
public String getRecordingPath() {
|
|
||||||
return (String) AdvancedOptions.recordingPath.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRenderPath() {
|
|
||||||
return (String) AdvancedOptions.renderPath.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDownloadPath() { return (String) AdvancedOptions.downloadPath.getValue(); }
|
|
||||||
|
|
||||||
public int getVideoFramerate() {
|
|
||||||
return (Integer) RenderOptions.videoFramerate.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVideoFramerate(int framerate) {
|
|
||||||
RenderOptions.videoFramerate.setValue(Math.min(120, Math.max(10, framerate)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleInterpolation() {
|
|
||||||
ReplayOptions.linear.setValue(!((Boolean)ReplayOptions.linear.getValue()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean showRecordingIndicator() {
|
|
||||||
return (Boolean) RecordingOptions.indicator.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnableRecordingServer() {
|
|
||||||
return (Boolean) RecordingOptions.recordServer.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnableRecordingSingleplayer() {
|
|
||||||
return (Boolean) RecordingOptions.recordSingleplayer.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isShowNotifications() {
|
|
||||||
return (Boolean) RecordingOptions.notifications.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLinearMovement() {
|
|
||||||
return (Boolean) ReplayOptions.linear.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean showPathPreview() { return (Boolean) ReplayOptions.previewPath.getValue(); }
|
|
||||||
|
|
||||||
public void setShowPathPreview(boolean show) {
|
|
||||||
ReplayOptions.previewPath.setValue(show);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean showClearKeyframesCallback() {
|
|
||||||
return (Boolean) ReplayOptions.keyframeCleanCallback.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Property getConfigSetting(Configuration config, String name, Object value, String category, boolean warning) {
|
|
||||||
if(warning) {
|
|
||||||
String warningMsg = "Please be careful when modifying this setting, as setting it to an invalid value might harm your computer.";
|
|
||||||
if(value instanceof Integer) {
|
|
||||||
return config.get(category, name, (Integer) value, warningMsg);
|
|
||||||
} else if(value instanceof Boolean) {
|
|
||||||
return config.get(category, name, (Boolean) value, warningMsg);
|
|
||||||
} else if(value instanceof Double) {
|
|
||||||
return config.get(category, name, (Double) value, warningMsg);
|
|
||||||
} else if(value instanceof Float) {
|
|
||||||
return config.get(category, name, (double) (Float) value, warningMsg);
|
|
||||||
} else if(value instanceof String) {
|
|
||||||
return config.get(category, name, (String) value, warningMsg);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(value instanceof Integer) {
|
|
||||||
return config.get(category, name, (Integer) value);
|
|
||||||
} else if(value instanceof Boolean) {
|
|
||||||
return config.get(category, name, (Boolean) value);
|
|
||||||
} else if(value instanceof Double) {
|
|
||||||
return config.get(category, name, (Double) value);
|
|
||||||
} else if(value instanceof Float) {
|
|
||||||
return config.get(category, name, (double) (Float) value);
|
|
||||||
} else if(value instanceof String) {
|
|
||||||
return config.get(category, name, (String) value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object getValueObject(Property p) {
|
|
||||||
if(p.isIntValue()) {
|
|
||||||
return p.getInt();
|
|
||||||
} else if(p.isDoubleValue()) {
|
|
||||||
return p.getDouble();
|
|
||||||
} else if(p.isBooleanValue()) {
|
|
||||||
return p.getBoolean();
|
|
||||||
} else {
|
|
||||||
return p.getString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum RecordingOptions implements ValueEnum {
|
|
||||||
recordServer(true, "replaymod.gui.settings.recordserver"),
|
|
||||||
recordSingleplayer(true, "replaymod.gui.settings.recordsingleplayer"),
|
|
||||||
notifications(true, "replaymod.gui.settings.notifications"), // TODO
|
|
||||||
indicator(true, "replaymod.gui.settings.indicator");
|
|
||||||
|
|
||||||
private Object value;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
RecordingOptions(Object value, String name) {
|
|
||||||
this.value = value;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setValue(Object value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() { return I18n.format(name); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ReplayOptions implements ValueEnum {
|
|
||||||
linear(false, "replaymod.gui.settings.interpolation"),
|
|
||||||
previewPath(false, "replaymod.gui.settings.pathpreview"),
|
|
||||||
keyframeCleanCallback(true, "replaymod.gui.settings.keyframecleancallback"),
|
|
||||||
showChat(false, "options.chat.visibility"),
|
|
||||||
renderInvisible(true, "replaymod.gui.settings.renderinvisible");
|
|
||||||
|
|
||||||
private Object value;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
ReplayOptions(Object value, String name) {
|
|
||||||
this.value = value;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setValue(Object value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() { return I18n.format(name); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum RenderOptions implements ValueEnum {
|
|
||||||
videoFramerate(30, "replaymod.gui.settings.framerate"),
|
|
||||||
waitForChunks(true, "replaymod.gui.settings.forcechunks");
|
|
||||||
|
|
||||||
private Object value;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
RenderOptions(Object value, String name) {
|
|
||||||
this.value = value;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setValue(Object value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() { return I18n.format(name); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum AdvancedOptions implements ValueEnum {
|
|
||||||
recordingPath("./replay_recordings/", ""),
|
|
||||||
renderPath("./replay_videos/", ""),
|
|
||||||
downloadPath("./replay_downloads", ""),
|
|
||||||
disableLoginPrompt(false, "");
|
|
||||||
|
|
||||||
private Object value;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
AdvancedOptions(Object value, String name) {
|
|
||||||
this.value = value;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setValue(Object value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() { return I18n.format(name); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface ValueEnum {
|
|
||||||
Object getValue();
|
|
||||||
|
|
||||||
void setValue(Object value);
|
|
||||||
|
|
||||||
String getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,148 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.studio;
|
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.replaymod.replaystudio.PacketData;
|
|
||||||
import com.replaymod.replaystudio.Studio;
|
|
||||||
import com.replaymod.replaystudio.filter.StreamFilter;
|
|
||||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
|
||||||
import com.replaymod.replaystudio.replay.ReplayMetaData;
|
|
||||||
import com.replaymod.replaystudio.stream.PacketStream;
|
|
||||||
import com.replaymod.core.ReplayMod;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerResourcePackSendPacket;
|
|
||||||
import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPlayerPacket;
|
|
||||||
import org.spacehq.packetlib.packet.Packet;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
// TODO Reset resourcepack when changing from a resourcepack replay to a normal replay
|
|
||||||
public class ConnectMetadataFilter implements StreamFilter {
|
|
||||||
private ReplayFile replayFile;
|
|
||||||
private Set<String> players = new HashSet<String>();
|
|
||||||
private Set<UUID> invisiblePlayers = new HashSet<UUID>();
|
|
||||||
private long duration;
|
|
||||||
private Map<String, File> resourcePacks = new HashMap<String, File>();
|
|
||||||
private Map<Integer, String> resourcePackIndex = new HashMap<Integer, String>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "connect_metadata";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInputReplay(ReplayFile replayFile) {
|
|
||||||
this.replayFile = replayFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(Studio studio, JsonObject jsonObject) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart(PacketStream packetStream) {
|
|
||||||
try {
|
|
||||||
Optional<Set<UUID>> invisible = replayFile.getInvisiblePlayers();
|
|
||||||
if (invisible.isPresent()) {
|
|
||||||
invisiblePlayers.addAll(invisible.get());
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPacket(PacketStream packetStream, PacketData packetData) {
|
|
||||||
Packet packet = packetData.getPacket();
|
|
||||||
if (packet instanceof ServerSpawnPlayerPacket) {
|
|
||||||
players.add(((ServerSpawnPlayerPacket) packet).getUUID().toString());
|
|
||||||
}
|
|
||||||
if (packet instanceof ServerResourcePackSendPacket) {
|
|
||||||
String url = ((ServerResourcePackSendPacket) packet).getUrl();
|
|
||||||
if (url.startsWith("replay://")) {
|
|
||||||
int id = Integer.parseInt(url.substring("replay://".length()));
|
|
||||||
try {
|
|
||||||
Map<Integer, String> oldIndex = replayFile.getResourcePackIndex();
|
|
||||||
if (oldIndex != null) {
|
|
||||||
String hash = oldIndex.get(id);
|
|
||||||
if (hash != null) {
|
|
||||||
// Make sure we have the resource pack
|
|
||||||
File file = resourcePacks.get(hash);
|
|
||||||
if (file == null) {
|
|
||||||
Optional<InputStream> in = replayFile.getResourcePack(hash);
|
|
||||||
if (in.isPresent()) {
|
|
||||||
try {
|
|
||||||
file = File.createTempFile("replaymod", "resourcepack");
|
|
||||||
OutputStream out = new FileOutputStream(file);
|
|
||||||
try {
|
|
||||||
IOUtils.copy(in.get(), out);
|
|
||||||
} finally {
|
|
||||||
IOUtils.closeQuietly(out);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
IOUtils.closeQuietly(in.get());
|
|
||||||
}
|
|
||||||
resourcePacks.put(hash, file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Re-Index the current packet
|
|
||||||
id = resourcePackIndex.size();
|
|
||||||
resourcePackIndex.put(id, hash);
|
|
||||||
url = "replay://" + id;
|
|
||||||
packetStream.insert(packetData.getTime(), new ServerResourcePackSendPacket(url, ""));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnd(PacketStream packetStream, long l) {
|
|
||||||
if (l > duration) {
|
|
||||||
duration = l;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeTo(ReplayFile output) throws IOException {
|
|
||||||
ReplayMetaData metaData = new ReplayMetaData();
|
|
||||||
metaData.setDuration((int) duration);
|
|
||||||
metaData.setSingleplayer(false);
|
|
||||||
metaData.setServerName("Multiple worlds");
|
|
||||||
metaData.setMcVersion(ReplayMod.getMinecraftVersion());
|
|
||||||
metaData.setDate(System.currentTimeMillis());
|
|
||||||
metaData.setPlayers(players.toArray(new String[players.size()]));
|
|
||||||
output.writeMetaData(metaData);
|
|
||||||
|
|
||||||
if (!invisiblePlayers.isEmpty()) {
|
|
||||||
output.writeInvisiblePlayers(invisiblePlayers);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!resourcePackIndex.isEmpty()) {
|
|
||||||
output.writeResourcePackIndex(resourcePackIndex);
|
|
||||||
|
|
||||||
// Only store resource packs we really need
|
|
||||||
resourcePacks.keySet().retainAll(resourcePackIndex.values());
|
|
||||||
|
|
||||||
for (Map.Entry<String, File> e : resourcePacks.entrySet()) {
|
|
||||||
OutputStream out = output.writeResourcePack(e.getKey());
|
|
||||||
try {
|
|
||||||
InputStream in = new FileInputStream(e.getValue());
|
|
||||||
try {
|
|
||||||
IOUtils.copy(in, out);
|
|
||||||
} finally {
|
|
||||||
IOUtils.closeQuietly(in);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
IOUtils.closeQuietly(out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user