use of org.terasology.assets.exceptions.InvalidUrnException in project Terasology by MovingBlocks.
the class AbstractEditorScreen method loadAutosave.
/**
* Resets the editor based on the state of the autosave file.
*/
protected void loadAutosave() {
if (!disableAutosave) {
try (JsonReader reader = new JsonReader(new InputStreamReader(Files.newInputStream(getAutosaveFile())))) {
reader.setLenient(true);
String autosaveString = new JsonParser().parse(reader).toString();
JsonObject autosaveObject = new JsonParser().parse(autosaveString).getAsJsonObject();
String selectedAsset = autosaveObject.get("selectedAsset").getAsString();
setSelectedAsset(selectedAsset);
try {
ResourceUrn urn = new ResourceUrn(selectedAsset);
setSelectedAssetPath(urn);
} catch (InvalidUrnException ignored) {
}
JsonTree editorContents = JsonTreeConverter.serialize(autosaveObject.get("editorContents"));
resetState(editorContents);
setUnsavedChangesPresent(true);
} catch (NoSuchFileException ignored) {
} catch (IOException e) {
logger.warn("Could not load autosaved info", e);
}
}
}
use of org.terasology.assets.exceptions.InvalidUrnException in project Terasology by MovingBlocks.
the class NUIEditorScreen method resetStateInternal.
/**
* {@inheritDoc}
*/
@Override
protected void resetStateInternal(JsonTree node) {
getEditor().setTreeViewModel(node, true);
resetPreviewWidget();
getEditor().clearHistory();
updateConfig();
selectedAsset = selectedAssetPending;
try {
ResourceUrn urn = new ResourceUrn(selectedAsset);
setSelectedAssetPath(urn);
} catch (InvalidUrnException ignored) {
}
}
use of org.terasology.assets.exceptions.InvalidUrnException in project Terasology by MovingBlocks.
the class NUISkinEditorScreen method resetStateInternal.
/**
* {@inheritDoc}
*/
@Override
protected void resetStateInternal(JsonTree node) {
getEditor().setTreeViewModel(node, true);
resetPreviewWidget();
getEditor().clearHistory();
updateConfig();
selectedAsset = selectedAssetPending;
try {
ResourceUrn urn = new ResourceUrn(selectedAsset);
setSelectedAssetPath(urn);
} catch (InvalidUrnException ignored) {
}
}
Aggregations