Add downloadPath and renderPath settings
This commit is contained in:
@@ -39,8 +39,6 @@ public class ReplayModOnline {
|
||||
|
||||
private Logger logger;
|
||||
|
||||
private File downloadsFolder = new File("replay_downloads");
|
||||
|
||||
private ApiClient apiClient;
|
||||
|
||||
/**
|
||||
@@ -64,8 +62,8 @@ public class ReplayModOnline {
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
if (!downloadsFolder.mkdirs()) {
|
||||
logger.warn("Failed to create downloads folder: " + downloadsFolder);
|
||||
if (!getDownloadsFolder().mkdirs()) {
|
||||
logger.warn("Failed to create downloads folder: " + getDownloadsFolder());
|
||||
}
|
||||
|
||||
new GuiHandler(this).register();
|
||||
@@ -103,11 +101,11 @@ public class ReplayModOnline {
|
||||
}
|
||||
|
||||
public File getDownloadsFolder() {
|
||||
return downloadsFolder;
|
||||
return new File(core.getSettingsRegistry().get(Setting.DOWNLOAD_PATH));
|
||||
}
|
||||
|
||||
public File getDownloadedFile(int id) {
|
||||
return new File(downloadsFolder, id + ".mcpr");
|
||||
return new File(getDownloadsFolder(), id + ".mcpr");
|
||||
}
|
||||
|
||||
public boolean hasDownloaded(int id) {
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.replaymod.core.SettingsRegistry;
|
||||
|
||||
public final class Setting<T> extends SettingsRegistry.SettingKeys<T> {
|
||||
public static final Setting<Boolean> SKIP_LOGIN_PROMPT = make("skipLoginPrompt", null, false);
|
||||
public static final SettingsRegistry.SettingKey<String> DOWNLOAD_PATH =
|
||||
new SettingsRegistry.SettingKeys<>("advanced", "downloadPath", null, "./replay_downloads/");
|
||||
|
||||
private static <T> Setting<T> make(String key, String displayName, T defaultValue) {
|
||||
return new Setting<>(key, displayName, defaultValue);
|
||||
|
||||
@@ -20,10 +20,16 @@ public class ReplayModRender {
|
||||
|
||||
private Configuration configuration;
|
||||
|
||||
public ReplayMod getCore() {
|
||||
return core;
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
logger = event.getModLog();
|
||||
configuration = new Configuration(event.getSuggestedConfigurationFile());
|
||||
|
||||
core.getSettingsRegistry().register(Setting.class);
|
||||
}
|
||||
|
||||
public Configuration getConfiguration() {
|
||||
|
||||
8
src/main/java/com/replaymod/render/Setting.java
Normal file
8
src/main/java/com/replaymod/render/Setting.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.replaymod.render;
|
||||
|
||||
import com.replaymod.core.SettingsRegistry;
|
||||
|
||||
public final class Setting<T> {
|
||||
public static final SettingsRegistry.SettingKey<String> RENDER_PATH =
|
||||
new SettingsRegistry.SettingKeys<>("advanced", "renderPath", null, "./replay_videos/");
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.InstanceCreator;
|
||||
import com.replaymod.render.RenderSettings;
|
||||
import com.replaymod.render.ReplayModRender;
|
||||
import com.replaymod.render.Setting;
|
||||
import com.replaymod.render.rendering.VideoRenderer;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
||||
@@ -390,7 +391,8 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
|
||||
|
||||
private File generateOutputFile(RenderSettings.EncodingPreset encodingPreset) {
|
||||
String fileName = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss").format(new Date());
|
||||
return new File("replay_videos/" + fileName + "." + encodingPreset.getFileExtension());
|
||||
File folder = new File(ReplayModRender.instance.getCore().getSettingsRegistry().get(Setting.RENDER_PATH));
|
||||
return new File(folder, fileName + "." + encodingPreset.getFileExtension());
|
||||
}
|
||||
|
||||
private RenderSettings getDefaultRenderSettings() {
|
||||
|
||||
Reference in New Issue
Block a user