Search in sources :

Example 51 with Name

use of org.terasology.gestalt.naming.Name in project Terasology by MovingBlocks.

the class UniverseSetupScreen method findIndex.

/**
 * Looks for the index of a selected world from the given list.
 * @param worldsList the list to search
 * @param worldName the name of the world to find
 * @return the found index value or -1 if not found
 */
private int findIndex(List<WorldSetupWrapper> worldsList, String worldName) {
    for (int i = 0; i < worldsList.size(); i++) {
        WorldSetupWrapper currentWorldFromList = worldsList.get(i);
        Name customName = currentWorldFromList.getWorldName();
        if (customName.toString().equals(worldName)) {
            return i;
        }
    }
    return -1;
}
Also used : WorldSetupWrapper(org.terasology.engine.rendering.world.WorldSetupWrapper) Name(org.terasology.gestalt.naming.Name)

Example 52 with Name

use of org.terasology.gestalt.naming.Name in project Terasology by MovingBlocks.

the class NewGameScreen method getGameplayModules.

private List<Module> getGameplayModules() {
    List<Module> gameplayModules = Lists.newArrayList();
    for (Name moduleId : moduleManager.getRegistry().getModuleIds()) {
        Module latestVersion = moduleManager.getRegistry().getLatestModuleVersion(moduleId);
        if (StandardModuleExtension.isGameplayModule(latestVersion)) {
            gameplayModules.add(latestVersion);
        }
    }
    gameplayModules.sort(Comparator.comparing(o -> o.getMetadata().getDisplayName().value()));
    return gameplayModules;
}
Also used : MenuAnimationSystems(org.terasology.engine.rendering.nui.animation.MenuAnimationSystems) WorldGeneratorManager(org.terasology.engine.world.generator.internal.WorldGeneratorManager) UIDropdown(org.terasology.nui.widgets.UIDropdown) In(org.terasology.engine.registry.In) Color(org.terasology.nui.Color) ModuleManager(org.terasology.engine.core.module.ModuleManager) LoggerFactory(org.slf4j.LoggerFactory) NetworkMode(org.terasology.engine.network.NetworkMode) WidgetUtil(org.terasology.nui.WidgetUtil) StandardModuleExtension(org.terasology.engine.core.module.StandardModuleExtension) WorldGeneratorInfo(org.terasology.engine.world.generator.internal.WorldGeneratorInfo) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) GameManifest(org.terasology.engine.game.GameManifest) Lists(com.google.common.collect.Lists) NUIKeyEvent(org.terasology.nui.events.NUIKeyEvent) Canvas(org.terasology.nui.Canvas) StateLoading(org.terasology.engine.core.modes.StateLoading) ReadOnlyBinding(org.terasology.nui.databinding.ReadOnlyBinding) TranslationSystem(org.terasology.engine.i18n.TranslationSystem) StringTextRenderer(org.terasology.nui.itemRendering.StringTextRenderer) Binding(org.terasology.nui.databinding.Binding) UIDropdownScrollable(org.terasology.nui.widgets.UIDropdownScrollable) ModuleConfig(org.terasology.engine.config.ModuleConfig) Logger(org.slf4j.Logger) GameEngine(org.terasology.engine.core.GameEngine) UILabel(org.terasology.nui.widgets.UILabel) Keyboard(org.terasology.input.Keyboard) Module(org.terasology.gestalt.module.Module) CoreScreenLayer(org.terasology.engine.rendering.nui.CoreScreenLayer) SimpleUri(org.terasology.engine.core.SimpleUri) DependencyResolver(org.terasology.gestalt.module.dependencyresolution.DependencyResolver) UIText(org.terasology.nui.widgets.UIText) List(java.util.List) AdvancedGameSetupScreen(org.terasology.engine.rendering.nui.layers.mainMenu.advancedGameSetupScreen.AdvancedGameSetupScreen) Config(org.terasology.engine.config.Config) GameProvider(org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameProvider) Comparator(java.util.Comparator) Name(org.terasology.gestalt.naming.Name) Module(org.terasology.gestalt.module.Module) Name(org.terasology.gestalt.naming.Name)

Example 53 with Name

use of org.terasology.gestalt.naming.Name in project Terasology by MovingBlocks.

the class SelectionScreen method updateDescription.

void updateDescription(final GameInfo gameInfo) {
    if (gameInfo == null) {
        worldGenerator.setText("");
        moduleNames.setText("");
        loadPreviewImages(null);
        return;
    }
    final WorldGeneratorInfo wgi = worldGeneratorManager.getWorldGeneratorInfo(gameInfo.getManifest().getWorldInfo(TerasologyConstants.MAIN_WORLD).getWorldGenerator());
    String mainWorldGenerator = "ERROR: world generator ";
    if (wgi != null) {
        mainWorldGenerator = wgi.getDisplayName();
    } else {
        mainWorldGenerator = mainWorldGenerator + gameInfo.getManifest().getWorldInfo(TerasologyConstants.MAIN_WORLD).getWorldGenerator().toString() + " not found";
    }
    final String commaSeparatedModules = gameInfo.getManifest().getModules().stream().map(NameVersion::getName).map(Name::toString).sorted(String::compareToIgnoreCase).collect(Collectors.joining(", "));
    worldGenerator.setText(mainWorldGenerator);
    moduleNames.setText(commaSeparatedModules.length() > MODULES_LINE_LIMIT ? commaSeparatedModules.substring(0, MODULES_LINE_LIMIT) + "..." : commaSeparatedModules);
    loadPreviewImages(gameInfo);
}
Also used : WorldGeneratorInfo(org.terasology.engine.world.generator.internal.WorldGeneratorInfo) Name(org.terasology.gestalt.naming.Name)

Example 54 with Name

use of org.terasology.gestalt.naming.Name in project Terasology by MovingBlocks.

the class ReflectionUtil method getSimpleUriFor.

/**
 * Returns the {@link SimpleUri} for a type belonging to the {@link ModuleEnvironment}.
 * If the type does not belong to the module environment, null is returned.
 */
public static SimpleUri getSimpleUriFor(Type type, ModuleEnvironment environment) {
    Class<?> clazz = getRawType(type);
    if (clazz.getClassLoader() == null) {
        // Loaded with the bootstrap class loader, definitely not part of a module
        return null;
    }
    Name moduleProviding = environment.getModuleProviding(clazz);
    if (moduleProviding == null) {
        return null;
    }
    return new SimpleUri(moduleProviding, clazz.getSimpleName());
}
Also used : SimpleUri(org.terasology.engine.core.SimpleUri) Name(org.terasology.gestalt.naming.Name)

Example 55 with Name

use of org.terasology.gestalt.naming.Name in project Terasology by MovingBlocks.

the class CeilingSupportingHorizontalFamily method populateBlockMaps.

/**
 * Populates the map with all 8 rotations of the block that are possible.
 * <p>
 * These are all four 90 degree rotations about the Y-axis (YAW) for each case where the TOP side is
 * - facing upwards
 * - facing downwards
 *
 * @param blockBuilder The block builder to use to produce blocks
 * @param shape        The shape the block should be made in
 * @param definition   The definition for the family
 * @param uri          The base URI for the block
 */
private void populateBlockMaps(BlockBuilderHelper blockBuilder, BlockShape shape, BlockFamilyDefinition definition, BlockUri uri) {
    for (Rotation rotation : Rotation.horizontalRotations()) {
        Side horizontalSide = rotation.rotate(Side.FRONT);
        ExtendedSide extendedSideTop = ExtendedSide.getExtendedSideFor(Side.TOP, horizontalSide);
        blocks.put(extendedSideTop, transformBlock(blockBuilder, shape, definition, new BlockUri(uri, new Name(extendedSideTop.name())), rotation, extendedSideTop));
        ExtendedSide extendedSideBottom = ExtendedSide.getExtendedSideFor(Side.BOTTOM, horizontalSide);
        Yaw yaw = Rotation.horizontalRotations().get((rotation.getYaw().getIndex() + 2) % 4).getYaw();
        blocks.put(extendedSideBottom, transformBlock(blockBuilder, shape, definition, new BlockUri(uri, new Name(extendedSideBottom.name())), Rotation.rotate(yaw, Pitch.CLOCKWISE_180, Roll.NONE), extendedSideBottom));
    }
}
Also used : Side(org.terasology.engine.math.Side) BlockUri(org.terasology.engine.world.block.BlockUri) Rotation(org.terasology.engine.math.Rotation) Yaw(org.terasology.engine.math.Yaw) Name(org.terasology.gestalt.naming.Name)

Aggregations

Name (org.terasology.gestalt.naming.Name)58 ResourceUrn (org.terasology.gestalt.assets.ResourceUrn)15 Module (org.terasology.gestalt.module.Module)14 SimpleUri (org.terasology.engine.core.SimpleUri)13 ModuleManager (org.terasology.engine.core.module.ModuleManager)10 DependencyResolver (org.terasology.gestalt.module.dependencyresolution.DependencyResolver)7 IOException (java.io.IOException)6 ResolutionResult (org.terasology.gestalt.module.dependencyresolution.ResolutionResult)6 List (java.util.List)5 GameEngine (org.terasology.engine.core.GameEngine)5 SubtextureData (org.terasology.engine.rendering.assets.texture.subtexture.SubtextureData)5 BlockUri (org.terasology.engine.world.block.BlockUri)5 ModuleEnvironment (org.terasology.gestalt.module.ModuleEnvironment)5 UIText (org.terasology.nui.widgets.UIText)5 Map (java.util.Map)4 Set (java.util.Set)4 Config (org.terasology.engine.config.Config)4 Path (java.nio.file.Path)3 ArrayList (java.util.ArrayList)3 Arrays (java.util.Arrays)3