use of mcjty.lib.gui.layout.HorizontalLayout in project RFTools by McJty.
the class MachineInformationClientScreenModule method addMonitorPanel.
private void addMonitorPanel(Minecraft mc, Gui gui, final NBTTagCompound currentData, Panel panel) {
Panel monitorPanel = new Panel(mc, gui).setLayout(new HorizontalLayout()).setDesiredHeight(16);
String monitoring;
if (currentData.hasKey("monitorx")) {
if (currentData.hasKey("monitordim")) {
this.dim = currentData.getInteger("monitordim");
} else {
// Compatibility reasons
this.dim = currentData.getInteger("dim");
}
World world = mc.player.getEntityWorld();
if (dim == world.provider.getDimension()) {
int x = currentData.getInteger("monitorx");
int y = currentData.getInteger("monitory");
int z = currentData.getInteger("monitorz");
monitoring = currentData.getString("monitorname");
Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock();
monitorPanel.addChild(new BlockRender(mc, gui).setRenderItem(block)).setDesiredWidth(20);
monitorPanel.addChild(new Label(mc, gui).setText(x + "," + y + "," + z).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setDesiredWidth(150));
} else {
monitoring = "<unreachable>";
}
} else {
monitoring = "<not set>";
}
panel.addChild(monitorPanel);
panel.addChild(new Label(mc, gui).setText(monitoring));
}
use of mcjty.lib.gui.layout.HorizontalLayout in project RFTools by McJty.
the class MachineInformationClientScreenModule method addOptionPanel.
private void addOptionPanel(Minecraft mc, Gui gui, final NBTTagCompound currentData, final IModuleGuiChanged moduleGuiChanged, Panel panel) {
Panel optionPanel = new Panel(mc, gui).setLayout(new HorizontalLayout()).setDesiredHeight(16);
final Map<String, Integer> choiceToIndex = new HashMap<>();
final ChoiceLabel tagButton = new ChoiceLabel(mc, gui).setDesiredHeight(16).setDesiredWidth(80);
optionPanel.addChild(tagButton);
// int dim = currentData.getInteger("monitordim");
int x = currentData.getInteger("monitorx");
int y = currentData.getInteger("monitory");
int z = currentData.getInteger("monitorz");
TileEntity tileEntity = mc.world.getTileEntity(new BlockPos(x, y, z));
if (tileEntity instanceof MachineInformation) {
int current = currentData.getInteger("monitorTag");
MachineInformation information = (MachineInformation) tileEntity;
String currentTag = null;
for (int i = 0; i < information.getTagCount(); i++) {
String tag = information.getTagName(i);
choiceToIndex.put(tag, i);
tagButton.addChoices(tag);
tagButton.setChoiceTooltip(tag, information.getTagDescription(i));
if (current == i) {
currentTag = tag;
}
}
if (currentTag != null) {
tagButton.setChoice(currentTag);
}
}
tagButton.addChoiceEvent((parent, newChoice) -> {
String choice = tagButton.getCurrentChoice();
Integer index = choiceToIndex.get(choice);
if (index != null) {
currentData.setInteger("monitorTag", index);
}
moduleGuiChanged.updateData();
});
panel.addChild(optionPanel);
}
use of mcjty.lib.gui.layout.HorizontalLayout in project RFTools by McJty.
the class GuiSecurityManager method initGui.
@Override
public void initGui() {
super.initGui();
players = new WidgetList(mc, this);
Slider allowedPlayerSlider = new Slider(mc, this).setDesiredWidth(10).setVertical().setScrollable(players);
Panel allowedPlayersPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(3).setSpacing(1)).addChild(players).addChild(allowedPlayerSlider).setLayoutHint(new PositionalLayout.PositionalHint(72, 5, SECURITYMANAGER_WIDTH - 76, 96));
nameField = new TextField(mc, this).setDesiredHeight(15);
addButton = new Button(mc, this).setText("Add").setDesiredHeight(14).setDesiredWidth(34).setTooltips("Add a player to the access list").addButtonEvent(parent -> addPlayer());
delButton = new Button(mc, this).setText("Del").setDesiredHeight(14).setDesiredWidth(34).setTooltips("Remove the selected player", "from the access list").addButtonEvent(parent -> delPlayer());
Panel buttonPanel = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(3).setSpacing(1)).addChild(nameField).addChild(addButton).addChild(delButton).setDesiredHeight(16).setLayoutHint(new PositionalLayout.PositionalHint(72, 100, SECURITYMANAGER_WIDTH - 76, 14));
channelNameField = new TextField(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(8, 27, 60, 14)).addTextEvent((parent, newText) -> updateChannelName());
blacklistMode = new ImageChoiceLabel(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(10, 44, 16, 16)).setTooltips("Black or whitelist mode").addChoiceEvent((parent, newChoice) -> updateSettings());
blacklistMode.addChoice("White", "Whitelist players", guiElements, 15 * 16, 32);
blacklistMode.addChoice("Black", "Blacklist players", guiElements, 14 * 16, 32);
Panel toplevel = new Panel(mc, this).setBackground(iconLocation).setLayout(new PositionalLayout()).addChild(allowedPlayersPanel).addChild(buttonPanel).addChild(channelNameField).addChild(blacklistMode);
toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
window = new Window(this, toplevel);
Keyboard.enableRepeatEvents(true);
channelFromServer = null;
}
use of mcjty.lib.gui.layout.HorizontalLayout in project RFTools by McJty.
the class GuiShield method populateFilters.
private void populateFilters() {
List<ShieldFilter> newFilters = new ArrayList<>(fromServer_filters);
if (newFilters.equals(filters)) {
return;
}
filters = new ArrayList<>(newFilters);
filterList.removeChildren();
for (ShieldFilter filter : filters) {
String n;
if ("player".equals(filter.getFilterName())) {
PlayerFilter playerFilter = (PlayerFilter) filter;
if (playerFilter.getName() == null || playerFilter.getName().isEmpty()) {
n = "players";
} else {
n = "player " + playerFilter.getName();
}
} else {
n = filter.getFilterName();
}
Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout());
panel.addChild(new Label(mc, this).setText(n).setColor(StyleConfig.colorTextInListNormal).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setDesiredWidth(85));
String actionName;
boolean solid = (filter.getAction() & ShieldFilter.ACTION_SOLID) != 0;
boolean damage = (filter.getAction() & ShieldFilter.ACTION_DAMAGE) != 0;
if (solid && damage) {
actionName = ACTION_SOLIDDAMAGE;
} else if (solid) {
actionName = ACTION_SOLID;
} else if (damage) {
actionName = ACTION_DAMAGE;
} else {
actionName = ACTION_PASS;
}
panel.addChild(new Label(mc, this).setText(actionName).setColor(StyleConfig.colorTextInListNormal).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT));
filterList.addChild(panel);
}
}
use of mcjty.lib.gui.layout.HorizontalLayout in project RFTools by McJty.
the class GuiChamberDetails method populateLists.
private void populateLists() {
blockList.removeChildren();
if (items == null) {
return;
}
int totalCost = 0;
for (Map.Entry<IBlockState, Integer> entry : items.entrySet()) {
IBlockState bm = entry.getKey();
int count = entry.getValue();
int cost = costs.get(bm);
Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout()).setDesiredHeight(16);
ItemStack stack;
if (stacks.containsKey(bm)) {
stack = stacks.get(bm);
} else {
// @todo uses meta
stack = new ItemStack(bm.getBlock(), 0, bm.getBlock().getMetaFromState(bm));
}
BlockRender blockRender = new BlockRender(mc, this).setRenderItem(stack).setOffsetX(-1).setOffsetY(-1);
Label nameLabel = new Label(mc, this).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setColor(StyleConfig.colorTextInListNormal);
if (stack.getItem() == null) {
nameLabel.setText("?").setDesiredWidth(160);
} else {
nameLabel.setText(stack.getDisplayName()).setDesiredWidth(160);
}
Label countLabel = new Label(mc, this).setText(String.valueOf(count)).setColor(StyleConfig.colorTextInListNormal);
countLabel.setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setDesiredWidth(50);
Label costLabel = new Label(mc, this).setColor(StyleConfig.colorTextInListNormal);
costLabel.setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT);
if (cost == -1) {
costLabel.setText("NOT MOVABLE!");
} else {
costLabel.setText("Move Cost " + cost + " RF");
totalCost += cost;
}
panel.addChild(blockRender).addChild(nameLabel).addChild(countLabel).addChild(costLabel);
blockList.addChild(panel);
}
int totalCostEntities = 0;
RenderHelper.rot += .5f;
for (Map.Entry<String, Integer> entry : entities.entrySet()) {
String className = entry.getKey();
int count = entry.getValue();
int cost = entityCosts.get(className);
Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout()).setDesiredHeight(16);
String entityName = "<?>";
Entity entity = null;
if (realEntities.containsKey(className)) {
entity = realEntities.get(className);
entityName = EntityList.getEntityString(entity);
if (entity instanceof EntityItem) {
EntityItem entityItem = (EntityItem) entity;
if (!entityItem.getItem().isEmpty()) {
String displayName = entityItem.getItem().getDisplayName();
entityName += " (" + displayName + ")";
}
}
} else {
try {
Class<?> aClass = Class.forName(className);
entity = (Entity) aClass.getConstructor(World.class).newInstance(mc.world);
entityName = aClass.getSimpleName();
} catch (ClassNotFoundException e) {
} catch (InstantiationException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
} catch (NoSuchMethodException e) {
}
}
if (playerNames.containsKey(className)) {
entityName = playerNames.get(className);
}
BlockRender blockRender = new BlockRender(mc, this).setRenderItem(entity).setOffsetX(-1).setOffsetY(-1);
Label nameLabel = new Label(mc, this).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT);
nameLabel.setText(entityName).setDesiredWidth(160);
Label countLabel = new Label(mc, this).setText(String.valueOf(count));
countLabel.setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setDesiredWidth(50);
Label costLabel = new Label(mc, this);
costLabel.setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT);
if (cost == -1) {
costLabel.setText("NOT MOVABLE!");
} else {
costLabel.setText("Move Cost " + cost + " RF");
totalCostEntities += cost;
}
panel.addChild(blockRender).addChild(nameLabel).addChild(countLabel).addChild(costLabel);
blockList.addChild(panel);
}
infoLabel.setText("Total cost blocks: " + totalCost + " RF");
info2Label.setText("Total cost entities: " + totalCostEntities + " RF");
}
Aggregations