Split mod into core, recording, replay, render[todo], paths[todo] and extras[wip] modules
Move everything to com.replaymod package Add KeyBindingRegistry and SettingsRegistry Recreate settings GUI with new GUI API and dynamically from SettingsRegistry Use ReplayFile from ReplayStudio ReplayHandler is now object oriented Add GuiOverlay, GuiSlider and GuiTexturedButton to GUI API Rewrite both overlays to use new GUI API Fix size capping in vertical and horizontal layout Allow CustomLayouts to have parents Fix tooltip rendering when close to screen border Allow changing of columns in GridLayout
This commit is contained in:
@@ -1,18 +1,12 @@
|
||||
package eu.crushedpixel.replaymod.assets;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFile;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
@EqualsAndHashCode
|
||||
public class AssetRepository {
|
||||
@@ -62,40 +56,29 @@ public class AssetRepository {
|
||||
}
|
||||
|
||||
public void saveAssets() {
|
||||
try {
|
||||
ReplayFile replayFile = new ReplayFile(ReplayHandler.getReplayFile());
|
||||
|
||||
Enumeration<? extends ZipEntry> entries = replayFile.entries();
|
||||
while(entries.hasMoreElements()) {
|
||||
ZipEntry entry = entries.nextElement();
|
||||
if(entry.getName().startsWith(ReplayFile.ENTRY_ASSET_FOLDER)) {
|
||||
ReplayMod.replayFileAppender.registerModifiedFile(null, entry.getName(), ReplayHandler.getReplayFile());
|
||||
}
|
||||
}
|
||||
|
||||
replayFile.close();
|
||||
|
||||
ReplayMod.replayFileAppender.deleteAllFilesByFolder(ReplayFile.ENTRY_ASSET_FOLDER, ReplayHandler.getReplayFile());
|
||||
|
||||
for(Map.Entry<UUID, ReplayAsset> e : replayAssets.entrySet()) {
|
||||
UUID uuid = e.getKey();
|
||||
ReplayAsset asset = e.getValue();
|
||||
try {
|
||||
String filepath = ReplayFile.ENTRY_ASSET_FOLDER + uuid.toString()+ "_" + asset.getDisplayString() + "." + asset.getSavedFileExtension();
|
||||
|
||||
File toAdd = File.createTempFile("ASSET_"+asset.getDisplayString(), asset.getSavedFileExtension());
|
||||
FileOutputStream fos = new FileOutputStream(toAdd);
|
||||
asset.writeToStream(fos);
|
||||
|
||||
|
||||
ReplayMod.replayFileAppender.registerModifiedFile(toAdd, filepath, ReplayHandler.getReplayFile());
|
||||
} catch(IOException io) {
|
||||
io.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 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) {
|
||||
|
||||
@@ -3,7 +3,6 @@ package eu.crushedpixel.replaymod.assets;
|
||||
import eu.crushedpixel.replaymod.holders.GuiEntryListEntry;
|
||||
import eu.crushedpixel.replaymod.holders.Transformations;
|
||||
import eu.crushedpixel.replaymod.registry.ResourceHelper;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -55,19 +54,20 @@ public class CustomImageObject implements GuiEntryListEntry {
|
||||
|
||||
//if no asset repository available, simply accept the UUID and it will load the image later
|
||||
//when calling getResourceLocation for the first time
|
||||
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");
|
||||
}
|
||||
// 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 {
|
||||
@@ -103,14 +103,15 @@ public class CustomImageObject implements GuiEntryListEntry {
|
||||
|
||||
public ResourceLocation getResourceLocation() {
|
||||
if(resourceLocation == null) {
|
||||
ReplayAsset asset = ReplayHandler.getAssetRepository().getAssetByUUID(linkedAsset);
|
||||
if(asset instanceof ReplayImageAsset) {
|
||||
try {
|
||||
setImage(((ReplayImageAsset) asset).getObject());
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
// ReplayAsset asset = ReplayHandler.getAssetRepository().getAssetByUUID(linkedAsset);
|
||||
// if(asset instanceof ReplayImageAsset) {
|
||||
// try {
|
||||
// setImage(((ReplayImageAsset) asset).getObject());
|
||||
// } catch(Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.assets;
|
||||
|
||||
import eu.crushedpixel.replaymod.registry.ResourceHelper;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.utils.BoundingUtils;
|
||||
import eu.crushedpixel.replaymod.utils.BufferedImageUtils;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -67,11 +66,12 @@ public class ReplayImageAsset implements ReplayAsset<BufferedImage> {
|
||||
this.bufferedImageHashCode = BufferedImageUtils.hashCode(object);
|
||||
ResourceHelper.freeResource(previewResource);
|
||||
|
||||
for(CustomImageObject object : ReplayHandler.getCustomImageObjects()) {
|
||||
if(object.getLinkedAsset() != null && object.getLinkedAsset().equals(ReplayHandler.getAssetRepository().getUUIDForAsset(this))) {
|
||||
object.setImage(this.object);
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
// for(CustomImageObject object : ReplayHandler.getCustomImageObjects()) {
|
||||
// if(object.getLinkedAsset() != null && object.getLinkedAsset().equals(ReplayHandler.getAssetRepository().getUUIDForAsset(this))) {
|
||||
// object.setImage(this.object);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user