use of mcjty.rftools.blocks.screens.modulesclient.ClientScreenModule in project RFTools by McJty.
the class GuiScreen method installModuleGui.
private void installModuleGui(int i, final ItemStack slot, ModuleProvider moduleProvider, Class<? extends ClientScreenModule> clientScreenModuleClass) {
buttons[i].setEnabled(true);
toplevel.removeChild(modulePanels[i]);
try {
ClientScreenModule clientScreenModule = clientScreenModuleClass.newInstance();
clientScreenModules[i] = clientScreenModule;
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
NBTTagCompound tagCompound = slot.getTagCompound();
if (tagCompound == null) {
tagCompound = new NBTTagCompound();
}
final NBTTagCompound finalTagCompound = tagCompound;
final int finalI = i;
modulePanels[i] = clientScreenModules[i].createGui(mc, this, tagCompound, new ModuleGuiChanged() {
@Override
public void updateData() {
slot.setTagCompound(finalTagCompound);
tileEntity.setInventorySlotContents(finalI, slot);
RFToolsMessages.INSTANCE.sendToServer(new PacketModuleUpdate(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, finalI, finalTagCompound));
}
});
modulePanels[i].setLayoutHint(new PositionalLayout.PositionalHint(80, 8, 170, 130));
modulePanels[i].setFilledRectThickness(-2).setFilledBackground(0xff8b8b8b);
toplevel.addChild(modulePanels[i]);
buttons[i].setText(moduleProvider.getName());
}
use of mcjty.rftools.blocks.screens.modulesclient.ClientScreenModule in project RFTools by McJty.
the class ScreenRenderer method renderModules.
private void renderModules(FontRenderer fontrenderer, ClientScreenModule.TransformMode mode, List<ClientScreenModule> modules, Map<Integer, Object[]> screenData, int size) {
float f3;
float factor = size + 1.0f;
int currenty = 7;
int moduleIndex = 0;
for (ClientScreenModule module : modules) {
if (module != null) {
int height = module.getHeight();
// Check if this module has enough room
if (currenty + height <= 124) {
if (module.getTransformMode() != mode) {
if (mode != ClientScreenModule.TransformMode.NONE) {
GL11.glPopMatrix();
}
GL11.glPushMatrix();
mode = module.getTransformMode();
switch(mode) {
case TEXT:
GL11.glTranslatef(-0.5F, 0.5F, 0.07F);
f3 = 0.0075F;
GL11.glScalef(f3 * factor, -f3 * factor, f3);
GL11.glNormal3f(0.0F, 0.0F, -1.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
break;
case TEXTLARGE:
GL11.glTranslatef(-0.5F, 0.5F, 0.07F);
f3 = 0.0075F * 2;
GL11.glScalef(f3 * factor, -f3 * factor, f3);
GL11.glNormal3f(0.0F, 0.0F, -1.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
break;
case ITEM:
break;
default:
break;
}
}
module.render(fontrenderer, currenty, screenData.get(moduleIndex), factor);
currenty += height;
}
}
moduleIndex++;
}
if (mode != ClientScreenModule.TransformMode.NONE) {
GL11.glPopMatrix();
}
}
use of mcjty.rftools.blocks.screens.modulesclient.ClientScreenModule in project RFTools by McJty.
the class ScreenRenderer method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
GL11.glPushAttrib(GL11.GL_CURRENT_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_ENABLE_BIT | GL11.GL_LIGHTING_BIT | GL11.GL_TEXTURE_BIT);
GL11.glPushMatrix();
float f3;
int meta = tileEntity.getBlockMetadata();
f3 = 0.0F;
if (meta == 2) {
f3 = 180.0F;
}
if (meta == 4) {
f3 = 90.0F;
}
if (meta == 5) {
f3 = -90.0F;
}
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.75F, (float) z + 0.5F);
GL11.glRotatef(-f3, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(0.0F, -0.2500F, -0.4375F);
ScreenTileEntity screenTileEntity = (ScreenTileEntity) tileEntity;
if (!screenTileEntity.isTransparent()) {
GL11.glDisable(GL11.GL_LIGHTING);
renderScreenBoard(screenTileEntity.getSize(), screenTileEntity.getColor());
}
if (screenTileEntity.isPowerOn()) {
FontRenderer fontrenderer = this.func_147498_b();
ClientScreenModule.TransformMode mode = ClientScreenModule.TransformMode.NONE;
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_LIGHTING);
Map<Integer, Object[]> screenData = updateScreenData(screenTileEntity);
List<ClientScreenModule> modules = screenTileEntity.getClientScreenModules();
renderModules(fontrenderer, mode, modules, screenData, screenTileEntity.getSize());
}
GL11.glPopMatrix();
GL11.glPopAttrib();
}
use of mcjty.rftools.blocks.screens.modulesclient.ClientScreenModule in project RFTools by McJty.
the class ScreenTileEntity method getClientScreenModules.
// This is called client side.
public List<ClientScreenModule> getClientScreenModules() {
if (clientScreenModules == null) {
needsServerData = false;
clientScreenModules = new ArrayList<ClientScreenModule>();
for (int i = 0; i < inventoryHelper.getCount(); i++) {
ItemStack itemStack = inventoryHelper.getStackInSlot(i);
if (itemStack != null && itemStack.getItem() instanceof ModuleProvider) {
ModuleProvider moduleProvider = (ModuleProvider) itemStack.getItem();
ClientScreenModule clientScreenModule;
try {
clientScreenModule = moduleProvider.getClientScreenModule().newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
continue;
} catch (IllegalAccessException e) {
e.printStackTrace();
continue;
}
clientScreenModule.setupFromNBT(itemStack.getTagCompound(), worldObj.provider.dimensionId, xCoord, yCoord, zCoord);
clientScreenModules.add(clientScreenModule);
if (clientScreenModule.needsServerData()) {
needsServerData = true;
}
} else {
// To keep the indexing correct so that the modules correspond with there slot number.
clientScreenModules.add(null);
}
}
}
return clientScreenModules;
}
use of mcjty.rftools.blocks.screens.modulesclient.ClientScreenModule in project RFTools by McJty.
the class ScreenTileEntity method hitScreenClient.
public void hitScreenClient(double hitX, double hitY, double hitZ, int side) {
float factor = size + 1.0f;
float dx = 0;
float dy = (float) ((-hitY + 1.0) / factor);
switch(side) {
case 2:
dx = (float) ((1.0 - hitX) / factor);
break;
case 3:
dx = (float) (hitX / factor);
break;
case 4:
dx = (float) (hitZ / factor);
break;
case 5:
dx = (float) ((1.0 - hitZ) / factor);
break;
}
int x = (int) (dx * 128);
int y = (int) (dy * 128);
int currenty = 7;
int moduleIndex = 0;
List<ClientScreenModule> clientScreenModules = getClientScreenModules();
for (ClientScreenModule module : clientScreenModules) {
if (module != null) {
int height = module.getHeight();
// Check if this module has enough room
if (currenty + height <= 124) {
if (currenty <= y && y < (currenty + height)) {
break;
}
currenty += height;
}
}
moduleIndex++;
}
if (moduleIndex >= clientScreenModules.size()) {
return;
}
clientScreenModules.get(moduleIndex).mouseClick(worldObj, x, y - currenty, true);
clickedModules.add(new ActivatedModule(moduleIndex, 5, x, y));
RFToolsMessages.INSTANCE.sendToServer(new PacketServerCommand(xCoord, yCoord, zCoord, CMD_CLICK, new Argument("x", x), new Argument("y", y - currenty), new Argument("module", moduleIndex)));
}
Aggregations