Search in sources :

Example 1 with NUISkinEditorScreen

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

the class CoreCommands method editSkin.

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

Aggregations

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