Button for viewing content fields on wiki + More tests and fixes
This commit is contained in:
@@ -448,7 +448,7 @@ public class ContentParser{
|
||||
T two = (T)Vars.content.getByName(ctype, jsonData.asString());
|
||||
|
||||
if(two != null) return two;
|
||||
throw new IllegalArgumentException("\"" + jsonData.name + "\": No " + ctype + " found with name '" + jsonData.asString() + "'.\nMake sure '" + jsonData.asString() + "' is spelled correctly, and that it really exists!\nThis may also occur because its file failed to parse.");
|
||||
throw new IllegalArgumentException((jsonData.name == null ? "" : "\"" + jsonData.name + "\": ") + "No " + ctype + " found with name '" + jsonData.asString() + "'.\nMake sure '" + jsonData.asString() + "' is spelled correctly, and that it really exists!\nThis may also occur because its file failed to parse.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ public class ContentPatcher{
|
||||
|
||||
try{
|
||||
JsonValue value = parser.getJson().fromJson(null, Jval.read(patch).toString(Jformat.plain));
|
||||
set.json = value;
|
||||
currentlyApplying = set;
|
||||
|
||||
set.name = value.getString("name", "");
|
||||
@@ -381,9 +382,13 @@ public class ContentPatcher{
|
||||
}else{
|
||||
//assign each field manually
|
||||
var childFields = parser.getJson().getFields(prevValue.getClass().isAnonymousClass() ? prevValue.getClass().getSuperclass() : prevValue.getClass());
|
||||
|
||||
for(var child : jsv){
|
||||
if(child.name != null){
|
||||
assign(prevValue, child.name, child, !childFields.containsKey(child.name) ? null : new FieldData(childFields.get(child.name)), object, field);
|
||||
assign(prevValue, child.name, child,
|
||||
metadata != null && metadata.type == ObjectMap.class ? metadata :
|
||||
!childFields.containsKey(child.name) ? null :
|
||||
new FieldData(childFields.get(child.name)), object, field);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -541,6 +546,15 @@ public class ContentPatcher{
|
||||
public FieldData(FieldMetadata data){
|
||||
this(data.field.getType(), data.elementType, data.keyType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "FieldData{" +
|
||||
"type=" + type +
|
||||
", elementType=" + elementType +
|
||||
", keyType=" + keyType +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
private static class PatchRecord{
|
||||
|
||||
@@ -10,6 +10,7 @@ import mindustry.ctype.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.input.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static arc.Core.*;
|
||||
@@ -93,6 +94,15 @@ public class ContentInfoDialog extends BaseDialog{
|
||||
table.row();
|
||||
}
|
||||
|
||||
if(settings.getBool("console")){
|
||||
table.button("@viewfields", Icon.link, Styles.grayt, () -> {
|
||||
Class<?> contentClass = content.getClass();
|
||||
if(contentClass.isAnonymousClass()) contentClass = contentClass.getSuperclass();
|
||||
|
||||
Core.app.openURI("https://mindustrygame.github.io/wiki/Modding%20Classes/" + contentClass.getSimpleName());
|
||||
}).margin(8f).pad(4f).size(300f, 50f).row();
|
||||
}
|
||||
|
||||
content.displayExtra(table);
|
||||
|
||||
ScrollPane pane = new ScrollPane(table);
|
||||
|
||||
@@ -86,6 +86,7 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
/** if true, {@link #buildEditorConfig(Table)} will be called for configuring this block in the editor. */
|
||||
public boolean editorConfigurable;
|
||||
/** the last configuration value applied to this block. */
|
||||
@NoPatch
|
||||
public @Nullable Object lastConfig;
|
||||
/** whether to save the last config and apply it to newly placed blocks */
|
||||
public boolean saveConfig = false;
|
||||
|
||||
Reference in New Issue
Block a user