Do not load old data, fix a few bugs

This commit is contained in:
JFronny 2020-12-20 22:28:25 +01:00
parent 60b40ca1cf
commit 6535d74867
7 changed files with 39 additions and 19 deletions

View File

@ -6,7 +6,7 @@ minecraft_version=1.16.4
yarn_mappings=1.16.4+build.7 yarn_mappings=1.16.4+build.7
loader_version=0.10.8 loader_version=0.10.8
# Mod Properties # Mod Properties
mod_version=1.1 mod_version=1.1.2
maven_group=io.gitlab.jfronny maven_group=io.gitlab.jfronny
archives_base_name=respackopts archives_base_name=respackopts
# Dependencies # Dependencies

View File

@ -1,13 +1,7 @@
{ {
"respackopts.title.lumi": "Lumi Lights", "respackopts.title.lumi": "Lumi Lights",
"respackopts.field.lumi.tonemap": "Tonemap mode", "respackopts.field.lumi.tonemap": "Tonemap mode",
"respackopts.field.lumi.tonemap.default": "Default",
"respackopts.field.lumi.tonemap.vibrant": "Vibrant",
"respackopts.field.lumi.tonemap.film": "Film",
"respackopts.field.lumi.pbr": "Enable PBR", "respackopts.field.lumi.pbr": "Enable PBR",
"respackopts.field.lumi.debugMode": "Debug Mode", "respackopts.field.lumi.debugMode": "Debug Mode",
"respackopts.field.lumi.debugMode.none": "Disable",
"respackopts.field.lumi.debugMode.normal": "Render normals",
"respackopts.field.lumi.debugMode.viewDir": "Render view direction",
"respackopts.field.lumi.waterVertexWavy": "Wavy water model" "respackopts.field.lumi.waterVertexWavy": "Wavy water model"
} }

View File

@ -13,6 +13,8 @@
"normal", "normal",
"viewDir" "viewDir"
], ],
"waterVertexWavy": false "waterVertexWavy": false,
"stringTest": "this is a string",
"numTest": 15.4
} }
} }

View File

@ -85,7 +85,7 @@ public class GuiFactory {
} }
i++; i++;
} }
config.addEntry(entryBuilder.startDropdownMenu(getText(n, b), (DropdownBoxEntry.SelectionTopCellElement) DropdownMenuBuilder.TopCellElementBuilder.of(sel, (s) -> s, (s) -> getText(s, b + "." + n)), new DropdownBoxEntry.DefaultSelectionCellCreator()) config.addEntry(entryBuilder.startDropdownMenu(getText(n, b), (DropdownBoxEntry.SelectionTopCellElement) DropdownMenuBuilder.TopCellElementBuilder.of(sel, (s) -> s, (s) -> new LiteralText(s)), new DropdownBoxEntry.DefaultSelectionCellCreator())
.setSuggestionMode(false) .setSuggestionMode(false)
.setDefaultValue(ev.first()) .setDefaultValue(ev.first())
.setSelections(() -> ev.iterator()) .setSelections(() -> ev.iterator())

View File

@ -79,12 +79,30 @@ public class Respackopts implements ClientModInitializer {
Reader reader = Files.newBufferedReader(q); Reader reader = Files.newBufferedReader(q);
Config c = g.fromJson(reader, Config.class); Config c = g.fromJson(reader, Config.class);
reader.close(); reader.close();
if (c.bools != null) if (c.bools != null) {
boolVals.put(id, c.bools); boolVals.get(id).forEach((i, val) -> {
if (c.doubles != null) if (c.bools.containsKey(i)) {
numVals.put(id, c.doubles); boolVals.get(id).put(i, c.bools.get(i));
if (c.strings != null) } else
strVals.put(id, c.strings); System.out.println("Could not find bool " + i + " in " + id);
});
}
if (c.doubles != null) {
numVals.get(id).forEach((i, val) -> {
if (c.doubles.containsKey(i)) {
numVals.get(id).put(i, c.doubles.get(i));
} else
System.out.println("Could not find num " + i + " in " + id);
});
}
if (c.strings != null) {
strVals.get(id).forEach((i, val) -> {
if (c.strings.containsKey(i)) {
strVals.get(id).put(i, c.strings.get(i));
} else
System.out.println("Could not find str " + i + " in " + id);
});
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -9,6 +9,7 @@ import net.minecraft.util.Identifier;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public class FrexCompat implements FrexInitializer { public class FrexCompat implements FrexInitializer {
boolean initial = true;
@Override @Override
public void onInitalizeFrex() { public void onInitalizeFrex() {
ShaderConfig.registerShaderConfigSupplier(new Identifier(Respackopts.ID, "config_supplier"), () -> { ShaderConfig.registerShaderConfigSupplier(new Identifier(Respackopts.ID, "config_supplier"), () -> {
@ -53,11 +54,12 @@ public class FrexCompat implements FrexInitializer {
System.out.println("[respackopts] enabled frex/canvas support"); System.out.println("[respackopts] enabled frex/canvas support");
Respackopts.saveActions.add(() -> { Respackopts.saveActions.add(() -> {
try { try {
ShaderConfig.invalidateShaderConfig(); if (!initial)
ShaderConfig.invalidateShaderConfig();
initial = false;
} }
catch (Throwable e) { catch (Throwable e) {
if (FabricLoader.getInstance().isDevelopmentEnvironment()) e.printStackTrace();
e.printStackTrace();
} }
}); });
} }

View File

@ -29,6 +29,7 @@ public class ResourcePackManagerMixin {
profiles.forEach((s, v) -> { profiles.forEach((s, v) -> {
if (hasMetadata(v, "conf.json")) { if (hasMetadata(v, "conf.json")) {
try { try {
boolean overwriteData = false;
Respackmeta conf = Respackopts.g.fromJson(readMetadata(v, "conf.json", Respackopts.g), Respackmeta.class); Respackmeta conf = Respackopts.g.fromJson(readMetadata(v, "conf.json", Respackopts.g), Respackmeta.class);
if (!Respackopts.boolVals.containsKey(conf.id)) if (!Respackopts.boolVals.containsKey(conf.id))
Respackopts.boolVals.put(conf.id, new HashMap<>()); Respackopts.boolVals.put(conf.id, new HashMap<>());
@ -39,8 +40,8 @@ public class ResourcePackManagerMixin {
if (!Respackopts.enumKeys.containsKey(conf.id)) if (!Respackopts.enumKeys.containsKey(conf.id))
Respackopts.enumKeys.put(conf.id, new HashMap<>()); Respackopts.enumKeys.put(conf.id, new HashMap<>());
if (Respackopts.metaVersion.equals(conf.version)) { if (Respackopts.metaVersion.equals(conf.version)) {
overwriteData |= !Respackopts.resPackMetas.containsKey(v.getDisplayName().asString());
Respackopts.resPackMetas.put(v.getDisplayName().asString(), conf); Respackopts.resPackMetas.put(v.getDisplayName().asString(), conf);
Respackopts.load(conf.id);
} }
else { else {
System.err.println(s + " was not loaded as it specifies a different respackopts version than is installed"); System.err.println(s + " was not loaded as it specifies a different respackopts version than is installed");
@ -98,6 +99,9 @@ public class ResourcePackManagerMixin {
System.err.println("[respackopts] Unsupported non-primitive datatype"); System.err.println("[respackopts] Unsupported non-primitive datatype");
} }
} }
if (overwriteData) {
Respackopts.load(conf.id);
}
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }