Finalize update
This commit is contained in:
parent
163b1524a8
commit
3389db278d
|
@ -37,6 +37,7 @@ public class Respackopts implements ClientModInitializer {
|
|||
public static Path CONF_DIR;
|
||||
|
||||
public static final Map<String, ConfigBranch> CONFIG_BRANCH = new HashMap<>();
|
||||
public static final Map<String, String> NAME_LOOKUP = new HashMap<>();
|
||||
|
||||
public static final Gson GSON;
|
||||
public static GuiFactory factory = new GuiFactory();
|
||||
|
|
|
@ -9,4 +9,11 @@ public class ConfigBooleanEntry extends Entry<Boolean> {
|
|||
public boolean typeMatches(Entry<?> val) {
|
||||
return val instanceof ConfigBooleanEntry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entry<Boolean> clone() {
|
||||
ConfigBooleanEntry be = new ConfigBooleanEntry(getValue());
|
||||
be.setDefault(getDefault());
|
||||
return be;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class ConfigBranch extends Entry<Map<String, Entry<?>>> {
|
|||
for (Map.Entry<String, Entry<?>> e : source.getValue().entrySet()) {
|
||||
if (!has(e.getKey())) {
|
||||
if (mode.isAdd())
|
||||
add(e.getKey(), e.getValue());
|
||||
add(e.getKey(), e.getValue().clone());
|
||||
} else {
|
||||
Entry<?> current = get(e.getKey());
|
||||
if (e.getValue().typeMatches(current)) {
|
||||
|
@ -129,4 +129,13 @@ public class ConfigBranch extends Entry<Map<String, Entry<?>>> {
|
|||
sb.append(e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entry<Map<String, Entry<?>>> clone() {
|
||||
ConfigBranch branch = new ConfigBranch();
|
||||
for (Map.Entry<String, Entry<?>> e : getValue().entrySet()) {
|
||||
branch.add(e.getKey(), e.getValue().clone());
|
||||
}
|
||||
return branch;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package io.gitlab.jfronny.respackopts.data.entry;
|
||||
|
||||
import com.ibm.icu.impl.locale.XCldrStub;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -47,6 +49,16 @@ public class ConfigEnumEntry extends Entry<Integer> {
|
|||
sb.append(')');
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entry<Integer> clone() {
|
||||
ConfigEnumEntry e = new ConfigEnumEntry();
|
||||
e.fieldName = fieldName;
|
||||
e.values = XCldrStub.ImmutableMap.copyOf(values);
|
||||
e.setValue(getValue());
|
||||
e.setDefault(getDefault());
|
||||
return e;
|
||||
}
|
||||
|
||||
public void setFieldName(String s) {
|
||||
if (s != null)
|
||||
fieldName = s;
|
||||
|
|
|
@ -36,4 +36,14 @@ public class ConfigNumericEntry extends Entry<Double> {
|
|||
.append(max)
|
||||
.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entry<Double> clone() {
|
||||
ConfigNumericEntry ce = new ConfigNumericEntry();
|
||||
ce.max = max;
|
||||
ce.min = min;
|
||||
ce.setValue(getValue());
|
||||
ce.setDefault(getDefault());
|
||||
return ce;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,4 +41,6 @@ public abstract class Entry<T> {
|
|||
appendString(log);
|
||||
return log.toString();
|
||||
}
|
||||
|
||||
public abstract Entry<T> clone();
|
||||
}
|
||||
|
|
|
@ -28,8 +28,7 @@ public abstract class ResourcePackEntryMixin {
|
|||
|
||||
@Inject(at = @At("TAIL"), method = "render(Lnet/minecraft/client/util/math/MatrixStack;IIIIIIIZF)V")
|
||||
private void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta, CallbackInfo info) {
|
||||
String k = pack.getDisplayName().asString();
|
||||
if (this.isSelectable() && Respackopts.CONFIG_BRANCH.containsKey(k)) {
|
||||
if (this.isSelectable() && Respackopts.NAME_LOOKUP.containsKey(pack.getDisplayName().asString())) {
|
||||
int d = mouseX - x;
|
||||
d = widget.getRowWidth() - d;
|
||||
int e = mouseY - y;
|
||||
|
@ -43,7 +42,8 @@ public abstract class ResourcePackEntryMixin {
|
|||
if (!info.getReturnValue()) {
|
||||
if (this.isSelectable()) {
|
||||
String k = pack.getDisplayName().asString();
|
||||
if (Respackopts.CONFIG_BRANCH.containsKey(k) && rpo$selected) {
|
||||
if (Respackopts.NAME_LOOKUP.containsKey(k) && rpo$selected) {
|
||||
k = Respackopts.NAME_LOOKUP.get(k);
|
||||
info.setReturnValue(true);
|
||||
MinecraftClient c = MinecraftClient.getInstance();
|
||||
c.openScreen(Respackopts.factory.buildGui(Respackopts.CONFIG_BRANCH.get(k), k, c.currentScreen, () -> Respackopts.forceRespackReload = true));
|
||||
|
|
|
@ -26,6 +26,7 @@ public class ResourcePackManagerMixin {
|
|||
|
||||
@Inject(at = @At("TAIL"), method = "scanPacks()V")
|
||||
private void scanPacks(CallbackInfo info) {
|
||||
Respackopts.NAME_LOOKUP.clear();
|
||||
profiles.forEach((s, v) -> {
|
||||
if (rpo$hasMetadata(v)) {
|
||||
try {
|
||||
|
@ -38,6 +39,7 @@ public class ResourcePackManagerMixin {
|
|||
Respackopts.CONFIG_BRANCH.put(conf.id, conf.conf);
|
||||
else
|
||||
Respackopts.CONFIG_BRANCH.get(conf.id).sync(conf.conf, SyncMode.RESPACK_LOAD);
|
||||
Respackopts.NAME_LOOKUP.put(v.getDisplayName().asString(), conf.id);
|
||||
Respackopts.load(conf.id);
|
||||
} catch (Throwable e) {
|
||||
Respackopts.LOGGER.error(e);
|
||||
|
|
Loading…
Reference in New Issue