use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.
the class ReflectionUtil method getTypeUri.
public static String getTypeUri(Type type, ModuleEnvironment moduleEnvironment) {
String typeSimpleName = typeToString(type, true);
if (getRawType(type).getClassLoader() == null) {
return typeSimpleName;
}
Name moduleProvidingType = moduleEnvironment.getModuleProviding(getRawType(type));
if (moduleProvidingType == null) {
return typeSimpleName;
}
return new SimpleUri(moduleProvidingType, typeSimpleName).toString();
}
use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.
the class ReflectionUtil method getFullyQualifiedSimpleUriFor.
/**
* Returns the fully qualified {@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 getFullyQualifiedSimpleUriFor(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.getTypeName());
}
use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.
the class GameDetailsScreen method getGeneralInfo.
private String getGeneralInfo(final GameInfo theGameInfo) {
SimpleUri name = theGameInfo.getManifest().getWorldInfo(TerasologyConstants.MAIN_WORLD).getWorldGenerator();
WorldGeneratorInfo wgi = worldGeneratorManager.getWorldGeneratorInfo(name);
String display = "ERROR: generator " + name + " not found.";
if (wgi != null) {
display = wgi.getDisplayName();
}
return translationSystem.translate("${engine:menu#game-details-game-title} ") + theGameInfo.getManifest().getTitle() + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-last-play}: ") + DATE_FORMAT.format(theGameInfo.getTimestamp()) + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-game-duration} ") + DateTimeHelper.getDeltaBetweenTimestamps(new Date(0).getTime(), theGameInfo.getManifest().getTime()) + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-game-seed} ") + theGameInfo.getManifest().getSeed() + '\n' + '\n' + translationSystem.translate("${engine:menu#game-details-world-generator}: ") + '\t' + display;
}
use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.
the class InputSettingsScreen method onClosed.
@Override
public void onClosed() {
super.onClosed();
bindsManager.registerBinds();
// TODO: Find a better place to do this in.
BindsConfig bindsConf = bindsManager.getBindsConfig();
if (bindsConf != null) {
bindsConf.getBinds(new SimpleUri("engine:tabbingUI")).stream().findFirst().ifPresent(input -> {
TabbingManager.tabForwardInput = input;
});
bindsConf.getBinds(new SimpleUri("engine:tabbingModifier")).stream().findFirst().ifPresent(input -> {
TabbingManager.tabBackInputModifier = input;
});
bindsConf.getBinds(new SimpleUri("engine:activate")).stream().findFirst().ifPresent(input -> {
TabbingManager.activateInput = input;
});
}
}
use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.
the class InputSettingsScreen method addInputSection.
private void addInputSection(InputCategory category, ColumnLayout layout, Map<SimpleUri, RegisterBindButton> inputsById) {
if (category != null) {
layout.addWidget(new UISpace(new Vector2i(0, 16)));
UILabel categoryHeader = new UILabel(translationSystem.translate(category.displayName()));
categoryHeader.setFamily("subheading");
layout.addWidget(categoryHeader);
Set<SimpleUri> processedBinds = Sets.newHashSet();
for (String bindId : category.ordering()) {
SimpleUri bindUri = new SimpleUri(bindId);
if (bindUri.isValid()) {
RegisterBindButton bind = inputsById.get(new SimpleUri(bindId));
if (bind != null) {
addInputBindRow(bindUri, bind, layout);
processedBinds.add(bindUri);
}
}
}
List<ExtensionBind> extensionBindList = Lists.newArrayList();
for (Map.Entry<SimpleUri, RegisterBindButton> bind : inputsById.entrySet()) {
if (bind.getValue().category().equals(category.id()) && !processedBinds.contains(bind.getKey())) {
extensionBindList.add(new ExtensionBind(bind.getKey(), bind.getValue()));
}
}
Collections.sort(extensionBindList);
for (ExtensionBind extension : extensionBindList) {
addInputBindRow(extension.uri, extension.bind, layout);
}
}
}
Aggregations