本文整理汇总了Java中com.teamwizardry.librarianlib.features.gui.components.ComponentSprite类的典型用法代码示例。如果您正苦于以下问题:Java ComponentSprite类的具体用法?Java ComponentSprite怎么用?Java ComponentSprite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ComponentSprite类属于com.teamwizardry.librarianlib.features.gui.components包,在下文中一共展示了ComponentSprite类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GuiBedrockBore
import com.teamwizardry.librarianlib.features.gui.components.ComponentSprite; //导入依赖的package包/类
public GuiBedrockBore(ContainerBedrockBore container)
{
super(container, texture.getWidth(), texture.getHeight());
ComponentSprite background = new ComponentSprite(texture, 0, 0);
getMainComponents().add(background);
InventoryWrapperPlayer playerInv = container.playerInv;
PlayerLayout inventory = BaseLayouts.INSTANCE.player(playerInv);
inventory.getRoot().setPos(new Vec2d(8, 84));
GridLayout block = BaseLayouts.INSTANCE.grid(container.blockInv.getSlotArray(), container.blockInv.getSlotArray().size());
block.getSlots()[0][0].setPos(new Vec2d(56, 35));
block.getSlots()[0][1].setPos(new Vec2d(116, 35));
ComponentSprite progressBar = new ComponentSprite(progress, 77, 37);
double progressPercent = ((double) container.bore.burnTime) / TEBedrockBore.FUEL_TIME;
Vec2d progressSize = new Vec2d(progress.getWidth() * progressPercent, progress.getHeight());
progressBar.setSize(progressSize);
background.add(inventory.getRoot(), block.getRoot(), progressBar);
}
示例2: ComponentStructureList
import com.teamwizardry.librarianlib.features.gui.components.ComponentSprite; //导入依赖的package包/类
public ComponentStructureList(Structure structure) {
super(0, 0, 200, 300);
Deque<Block> sorted = new ArrayDeque<>();
HashMap<Block, Integer> ingredients = new HashMap<>();
HashMap<Block, IBlockState> access = new HashMap<>();
for (Template.BlockInfo info : structure.blockInfos()) {
if (info.blockState.getBlock() == Blocks.AIR) continue;
ingredients.putIfAbsent(info.blockState.getBlock(), 0);
ingredients.put(info.blockState.getBlock(), ingredients.get(info.blockState.getBlock()) + 1);
access.putIfAbsent(info.blockState.getBlock(), info.blockState);
if (!sorted.contains(info.blockState.getBlock())) sorted.add(info.blockState.getBlock());
}
ComponentVoid recipe = new ComponentVoid(0, 0, 200, 300);
recipe.getTransform().setScale(2);
add(recipe);
ComponentText text = new ComponentText(0, 3, ComponentText.TextAlignH.LEFT, ComponentText.TextAlignV.TOP);
text.setSize(new Vec2d(200, 16));
text.getText().setValue(" " + LibrarianLib.PROXY.translate("wizardry.misc.structure_materials"));
recipe.add(text);
ComponentSprite lineBreak = new ComponentSprite(BookGui.LINE_BREAK, (int) (getSize().getX() / 2.0 - 177.0 / 2.0), 30, 177, 2);
add(lineBreak);
int i = 0;
int row = 0;
while (!sorted.isEmpty() && sorted.peek() != null) {
Block nextBlock = sorted.pop();
ItemStack stack;
if (FluidRegistry.lookupFluidForBlock(nextBlock) != null) {
stack = FluidUtil.getFilledBucket(new FluidStack(FluidRegistry.lookupFluidForBlock(nextBlock), 1));
stack = new ItemStack(stack.getItem(), ingredients.get(nextBlock), stack.getMetadata(), stack.getTagCompound());
} else {
NonNullList<ItemStack> itemStacks = NonNullList.create();
nextBlock.getDrops(itemStacks, structure.getBlockAccess(), null, access.get(nextBlock), 0);
if (itemStacks.isEmpty())
stack = new ItemStack(nextBlock, ingredients.get(nextBlock));
else {
stack = itemStacks.get(0);
stack.setCount(ingredients.get(nextBlock));
}
}
ComponentStack componentStack = new ComponentStack(i * 16, 20 + row * 16);
componentStack.getStack().setValue(stack);
recipe.add(componentStack);
if (i++ > 4) {
i = 0;
row++;
}
}
}
示例3: LeftSidebar
import com.teamwizardry.librarianlib.features.gui.components.ComponentSprite; //导入依赖的package包/类
public LeftSidebar(ComponentList list, String title, Sprite icon, boolean defaultSelected, boolean selectable) {
this.title = title;
this.icon = icon;
ComponentSprite background = new ComponentSprite(leftNormal, 0, 0);
background.setMarginBottom(2);
background.setMarginLeft(list.getMarginLeft());
if (defaultSelected) background.addTag("selected");
ComponentSprite iconComp = new ComponentSprite(this.icon, 5, 1, 16, 16);
background.add(iconComp);
ComponentText titleComp = new ComponentText(iconComp.getSize().getXi() + 10, 9, ComponentText.TextAlignH.LEFT, ComponentText.TextAlignV.MIDDLE);
titleComp.setOutOfFlow(true);
background.add(titleComp);
ComponentList listComp = new ComponentList(leftExtended.getWidth(), leftExtended.getHeight() + 2);
background.add(listComp);
this.listComp = listComp;
new ButtonMixin<>(background, () -> {
});
background.BUS.hook(GuiComponent.ComponentTickEvent.class, (event) -> {
if (background.hasTag("selected")) {
if (listComp.getChildren().size() > 0) {
listComp.setVisible(true);
listComp.setEnabled(true);
} else {
listComp.setVisible(false);
listComp.setEnabled(false);
}
background.setSprite(leftExtended);
background.setSize(new Vec2d(leftExtended.getWidth(), leftExtended.getHeight()));
background.setPos(new Vec2d(-leftExtended.getWidth() + (list.getChildren().contains(background) ? 0 : 5), 0));
titleComp.getText().setValue(TextFormatting.ITALIC + title);
} else {
listComp.setVisible(false);
listComp.setEnabled(false);
background.setSprite(leftNormal);
background.setSize(new Vec2d(leftNormal.getWidth(), leftNormal.getHeight()));
background.setPos(new Vec2d(-leftNormal.getWidth() + (list.getChildren().contains(background) ? 5 : 0), 0));
titleComp.getText().setValue(title);
}
});
if (selectable)
background.BUS.hook(ButtonMixin.ButtonClickEvent.class, (event -> {
if (event.getButton() == EnumMouseButton.LEFT) {
if (!background.hasTag("selected")) {
background.addTag("selected");
for (GuiComponent component : list.getChildren())
if (component != background) component.removeTag("selected");
}
}
}));
component = background;
}
示例4: getComponent
import com.teamwizardry.librarianlib.features.gui.components.ComponentSprite; //导入依赖的package包/类
public ComponentSprite getComponent() {
return component;
}
示例5: RightSidebar
import com.teamwizardry.librarianlib.features.gui.components.ComponentSprite; //导入依赖的package包/类
public RightSidebar(ComponentList list, String title, Sprite icon, boolean defaultSelected, boolean selectable) {
this.title = title;
this.icon = icon;
ComponentSprite background = new ComponentSprite(rightNormal, 0, 0);
background.setMarginBottom(2);
background.setMarginLeft(list.getMarginRight());
if (defaultSelected) background.addTag("selected");
ComponentSprite iconComp = new ComponentSprite(this.icon, 5, 1, 16, 16);
background.add(iconComp);
ComponentText titleComp = new ComponentText(iconComp.getSize().getXi() + 10, 9, ComponentText.TextAlignH.LEFT, ComponentText.TextAlignV.MIDDLE);
titleComp.setOutOfFlow(true);
background.add(titleComp);
ComponentList listComp = new ComponentList(rightExtended.getWidth(), rightExtended.getHeight() + 2);
background.add(listComp);
this.listComp = listComp;
new ButtonMixin<>(background, () -> {
});
background.BUS.hook(GuiComponent.ComponentTickEvent.class, (event) -> {
if (background.hasTag("selected")) {
if (listComp.getChildren().size() > 0) {
listComp.setVisible(true);
listComp.setEnabled(true);
} else {
listComp.setVisible(false);
listComp.setEnabled(false);
}
background.setSprite(rightExtended);
background.setSize(new Vec2d(rightExtended.getWidth(), rightExtended.getHeight()));
background.setPos(new Vec2d(-rightNormal.getWidth() + (list.getChildren().contains(background) ? -5 : 0), 0));
titleComp.getText().setValue(TextFormatting.ITALIC + title);
} else {
listComp.setVisible(false);
listComp.setEnabled(false);
background.setSprite(rightNormal);
background.setSize(new Vec2d(rightNormal.getWidth(), rightNormal.getHeight()));
background.setPos(new Vec2d(-rightNormal.getWidth() + (list.getChildren().contains(background) ? -5 : 0), 0));
titleComp.getText().setValue(title);
}
});
if (selectable)
background.BUS.hook(ButtonMixin.ButtonClickEvent.class, (event -> {
if (event.getButton() == EnumMouseButton.LEFT) {
if (!background.hasTag("selected")) {
background.addTag("selected");
for (GuiComponent component : list.getChildren())
if (component != background) component.removeTag("selected");
}
}
}));
component = background;
}