Search in sources :

Example 1 with NUIEditorScreen

use of org.terasology.engine.rendering.nui.editor.layers.NUIEditorScreen in project Terasology by MovingBlocks.

the class CoreCommands method editScreen.

/**
 * Opens the NUI editor for a ui screen
 *
 * @param uri String containing ui screen name
 * @return String containing final message
 */
@Command(shortDescription = "Opens the NUI editor for a ui screen", requiredPermission = PermissionManager.NO_PERMISSION)
public String editScreen(@CommandParam(value = "uri", suggester = ScreenSuggester.class) String uri) {
    if (!nuiEditorSystem.isEditorActive()) {
        nuiEditorSystem.toggleEditor();
    }
    Set<ResourceUrn> urns = assetManager.resolve(uri, UIElement.class);
    switch(urns.size()) {
        case 0:
            return String.format("No asset found for screen '%s'", uri);
        case 1:
            ResourceUrn urn = urns.iterator().next();
            ((NUIEditorScreen) nuiManager.getScreen(NUIEditorScreen.ASSET_URI)).selectAsset(urn);
            return "Success";
        default:
            return String.format("Multiple matches for screen '%s': {%s}", uri, Arrays.toString(urns.toArray()));
    }
}
Also used : ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) NUIEditorScreen(org.terasology.engine.rendering.nui.editor.layers.NUIEditorScreen) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command) ConsoleCommand(org.terasology.engine.logic.console.commandSystem.ConsoleCommand)

Aggregations

ConsoleCommand (org.terasology.engine.logic.console.commandSystem.ConsoleCommand)1 Command (org.terasology.engine.logic.console.commandSystem.annotations.Command)1 NUIEditorScreen (org.terasology.engine.rendering.nui.editor.layers.NUIEditorScreen)1 ResourceUrn (org.terasology.gestalt.assets.ResourceUrn)1