当前位置: 首页>>代码示例>>Java>>正文


Java ComponentSprite类代码示例

本文整理汇总了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);
}
 
开发者ID:murapix,项目名称:Inhuman-Resources,代码行数:22,代码来源:GuiBedrockBore.java

示例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++;
		}
	}
}
 
开发者ID:TeamWizardry,项目名称:Wizardry,代码行数:60,代码来源:ComponentStructureList.java

示例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;
}
 
开发者ID:TeamWizardry,项目名称:TMT-Refraction,代码行数:59,代码来源:LeftSidebar.java

示例4: getComponent

import com.teamwizardry.librarianlib.features.gui.components.ComponentSprite; //导入依赖的package包/类
public ComponentSprite getComponent() {
	return component;
}
 
开发者ID:TeamWizardry,项目名称:TMT-Refraction,代码行数:4,代码来源:ExtraSidebar.java

示例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;
}
 
开发者ID:TeamWizardry,项目名称:TMT-Refraction,代码行数:59,代码来源:RightSidebar.java


注:本文中的com.teamwizardry.librarianlib.features.gui.components.ComponentSprite类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。