Preliminary graphical meters
This commit is contained in:
parent
90cec7a0ef
commit
e64a22b808
11 changed files with 164 additions and 33 deletions
BIN
mods/mmmPowersuits/textures/gui/glass.png
Normal file
BIN
mods/mmmPowersuits/textures/gui/glass.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 190 B |
|
@ -69,4 +69,12 @@ public class ElectricItemUtils {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static double getPlayerHeat(EntityPlayer player) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static double getMaxHeat(EntityPlayer player) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -488,6 +488,26 @@ public abstract class MuseRenderer {
|
|||
drawLightningTextured(x1, y1, z1, x2, y2, z2, colour);
|
||||
}
|
||||
|
||||
public static void drawMPDLightning(double x1, double y1, double z1, double x2, double y2, double z2, Colour colour, double displacement,
|
||||
double detail) {
|
||||
if (displacement < detail) {
|
||||
colour.doGL();
|
||||
GL11.glBegin(GL11.GL_LINES);
|
||||
GL11.glVertex3d(x1, y1, z1);
|
||||
GL11.glVertex3d(x2, y2, z2);
|
||||
GL11.glEnd();
|
||||
} else {
|
||||
double mid_x = (x1 + x2) / 2.0;
|
||||
double mid_y = (y1 + y2) / 2.0;
|
||||
double mid_z = (z1 + z2) / 2.0;
|
||||
mid_x += (Math.random() - 0.5) * displacement;
|
||||
mid_y += (Math.random() - 0.5) * displacement;
|
||||
mid_z += (Math.random() - 0.5) * displacement;
|
||||
drawMPDLightning(x1, y1, z1, mid_x, mid_y, mid_z, colour, displacement / 2, detail);
|
||||
drawMPDLightning(mid_x, mid_y, mid_z, x2, y2, z2, colour, displacement / 2, detail);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawLightningTextured(double x1, double y1, double z1, double x2, double y2, double z2, Colour colour) {
|
||||
double tx = x2 - x1, ty = y2 - y1, tz = z2 - z1;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ public class Colour {
|
|||
public static final Colour YELLOW = new Colour(0.0, 0.0, 0.5, 1.0);
|
||||
public static final Colour WHITE = new Colour(1.0, 1.0, 1.0, 1.0);
|
||||
public static final Colour BLACK = new Colour(0.0, 0.0, 0.0, 1.0);
|
||||
public static final Colour RED = new Colour(1.0, 0.2, 0.2, 1.0);
|
||||
|
||||
/**
|
||||
* The RGBA values are stored as floats from 0.0F (nothing) to 1.0F (full
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package net.machinemuse.general.geometry;
|
||||
|
||||
import java.nio.DoubleBuffer;
|
||||
|
||||
public class LightningBolt {
|
||||
public DoubleBuffer points;
|
||||
|
||||
public LightningBolt(double x1, double y1, double z1, double x2, double y2, double z2, double displacement, double detail) {
|
||||
|
||||
}
|
||||
}
|
|
@ -9,6 +9,12 @@ import net.minecraft.util.Icon;
|
|||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* A curved indicator bar. Probably not gonna use this actually...
|
||||
*
|
||||
* @author MachineMuse
|
||||
*
|
||||
*/
|
||||
public class RadialIndicator {
|
||||
protected DoubleBuffer vertices;
|
||||
protected DoubleBuffer textures;
|
||||
|
|
32
src/minecraft/net/machinemuse/general/gui/EnergyMeter.java
Normal file
32
src/minecraft/net/machinemuse/general/gui/EnergyMeter.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package net.machinemuse.general.gui;
|
||||
|
||||
import net.machinemuse.general.MuseRenderer;
|
||||
import net.machinemuse.general.geometry.Colour;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class EnergyMeter extends HeatMeter {
|
||||
public void draw(double xpos, double ypos, double value) {
|
||||
String old = MuseRenderer.TEXTURE_MAP;
|
||||
MuseRenderer.TEXTURE_MAP = MuseRenderer.BLOCK_TEXTURE_QUILT;
|
||||
Icon icon = Block.waterStill.getIcon(0, 0);
|
||||
GL11.glLineWidth(0.5f);
|
||||
MuseRenderer.on2D();
|
||||
MuseRenderer.blendingOn();
|
||||
if (value < 0.0001) {
|
||||
Colour.RED.doGL();
|
||||
} else if (Math.random() / value < 1) {
|
||||
MuseRenderer.texturelessOn();
|
||||
MuseRenderer.drawMPDLightning(xpos + xsize * (Math.random() / 2 + 0.25), ypos + ysize * (1 - value), 1, xpos + xsize
|
||||
* (Math.random() / 2 + 0.25), ypos + ysize, 1, Colour.WHITE, 4, 1);
|
||||
MuseRenderer.texturelessOff();
|
||||
}
|
||||
drawFluid(xpos, ypos, value, icon);
|
||||
drawGlass(xpos, ypos);
|
||||
MuseRenderer.blendingOff();
|
||||
MuseRenderer.off2D();
|
||||
MuseRenderer.TEXTURE_MAP = old;
|
||||
}
|
||||
}
|
52
src/minecraft/net/machinemuse/general/gui/HeatMeter.java
Normal file
52
src/minecraft/net/machinemuse/general/gui/HeatMeter.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
package net.machinemuse.general.gui;
|
||||
|
||||
import net.machinemuse.general.MuseRenderer;
|
||||
import net.machinemuse.general.geometry.Colour;
|
||||
import net.machinemuse.powersuits.common.Config;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class HeatMeter {
|
||||
int xsize = 8;
|
||||
int ysize = 32;
|
||||
|
||||
public void draw(double xpos, double ypos, double value) {
|
||||
String old = MuseRenderer.TEXTURE_MAP;
|
||||
MuseRenderer.TEXTURE_MAP = MuseRenderer.BLOCK_TEXTURE_QUILT;
|
||||
Icon icon = Block.lavaStill.getIcon(0, 0);
|
||||
drawFluid(xpos, ypos, value, icon);
|
||||
drawGlass(xpos, ypos);
|
||||
MuseRenderer.TEXTURE_MAP = old;
|
||||
}
|
||||
|
||||
public void drawFluid(double xpos, double ypos, double value, Icon icon) {
|
||||
|
||||
double bottomY = (ypos + ysize);
|
||||
double topY = (ypos + ysize * (1 - value));
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled(0.5, 0.5, 0.5);
|
||||
while (bottomY - 8 > topY) {
|
||||
MuseRenderer.drawIconAt(xpos * 2, (bottomY - 8) * 2, icon, Colour.WHITE);
|
||||
bottomY -= 8;
|
||||
}
|
||||
MuseRenderer.drawIconPartial(xpos * 2, (bottomY - 8) * 2, icon, Colour.WHITE, 0, (topY - bottomY + 8) * 2, 16, 16);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void drawGlass(double xpos, double ypos) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(Config.GLASS_TEXTURE);
|
||||
GL11.glBegin(GL11.GL_QUADS);
|
||||
GL11.glTexCoord2d(0, 0);
|
||||
GL11.glVertex2d(xpos, ypos);
|
||||
GL11.glTexCoord2d(0, 1);
|
||||
GL11.glVertex2d(xpos, ypos + ysize);
|
||||
GL11.glTexCoord2d(1, 1);
|
||||
GL11.glVertex2d(xpos + xsize, ypos + ysize);
|
||||
GL11.glTexCoord2d(1, 0);
|
||||
GL11.glVertex2d(xpos + xsize, ypos);
|
||||
GL11.glEnd();
|
||||
}
|
||||
}
|
|
@ -58,6 +58,7 @@ public class Config {
|
|||
public static final String LIGHTNING_TEXTURE = TEXTURE_PREFIX + "gui/lightning-medium.png";
|
||||
public static final String CITIZENJOE_ARMOR_PATH = TEXTURE_PREFIX + "models/joearmor.png";
|
||||
public static final String CITIZENJOE_ARMORPANTS_PATH = TEXTURE_PREFIX + "models/joearmorpants.png";
|
||||
public static final String GLASS_TEXTURE = TEXTURE_PREFIX + "gui/glass.png";
|
||||
|
||||
private static Configuration config;
|
||||
|
||||
|
@ -180,8 +181,6 @@ public class Config {
|
|||
List<IModularItem> FEETONLY = Collections.singletonList((IModularItem) ModularPowersuits.powerArmorFeet);
|
||||
List<IModularItem> TOOLONLY = Collections.singletonList((IModularItem) ModularPowersuits.powerTool);
|
||||
|
||||
IPowerModule module;
|
||||
|
||||
// Armor
|
||||
addModule(new BasicPlatingModule(ARMORONLY));
|
||||
addModule(new DiamondPlatingModule(ARMORONLY));
|
||||
|
@ -265,4 +264,8 @@ public class Config {
|
|||
return message;
|
||||
}
|
||||
|
||||
public static boolean useGraphicalMeters() {
|
||||
return config.get(Configuration.CATEGORY_GENERAL, "Use Graphical Meters", true).getBoolean(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,21 +5,15 @@ import net.machinemuse.powersuits.entity.EntityPlasmaBolt;
|
|||
import net.machinemuse.powersuits.entity.EntitySpinningBlade;
|
||||
import net.machinemuse.powersuits.event.EventHandler;
|
||||
import net.machinemuse.powersuits.event.MovementManager;
|
||||
import net.machinemuse.powersuits.item.ItemComponent;
|
||||
import net.machinemuse.powersuits.item.ItemPowerArmorBoots;
|
||||
import net.machinemuse.powersuits.item.ItemPowerArmorChestplate;
|
||||
import net.machinemuse.powersuits.item.ItemPowerArmorHelmet;
|
||||
import net.machinemuse.powersuits.item.ItemPowerArmorLeggings;
|
||||
import net.machinemuse.powersuits.item.ItemPowerGauntlet;
|
||||
import net.machinemuse.powersuits.item.*;
|
||||
import net.machinemuse.powersuits.network.MusePacketHandler;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.*;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.Mod.PostInit;
|
||||
import cpw.mods.fml.common.Mod.PreInit;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
|
@ -129,6 +123,8 @@ public class ModularPowersuits {
|
|||
Config.getMaximumArmorPerPiece();
|
||||
Config.getMaximumFlyingSpeedmps();
|
||||
Config.useMouseWheel();
|
||||
Config.useGraphicalMeters();
|
||||
Config.getSalvageChance();
|
||||
|
||||
EntityRegistry.registerModEntity(EntityPlasmaBolt.class, "entityPlasmaBolt", 2477, this, 64, 20, true);
|
||||
EntityRegistry.registerModEntity(EntitySpinningBlade.class, "entitySpinningBlade", 2478, this, 64, 20, true);
|
||||
|
|
|
@ -11,9 +11,10 @@ import net.machinemuse.api.electricity.ElectricItemUtils;
|
|||
import net.machinemuse.general.MuseRenderer;
|
||||
import net.machinemuse.general.MuseStringUtils;
|
||||
import net.machinemuse.general.geometry.Colour;
|
||||
import net.machinemuse.general.geometry.RadialIndicator;
|
||||
import net.machinemuse.general.gui.EnergyMeter;
|
||||
import net.machinemuse.general.gui.HeatMeter;
|
||||
import net.machinemuse.powersuits.block.BlockTinkerTable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.machinemuse.powersuits.common.Config;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
|
@ -36,8 +37,8 @@ public class RenderTickHandler implements ITickHandler {
|
|||
private final static int SWAPTIME = 200;
|
||||
public static long lastSwapTime = 0;
|
||||
public static int lastSwapDirection = 0;
|
||||
protected static RadialIndicator heat;
|
||||
protected static RadialIndicator energy;
|
||||
protected static HeatMeter heat;
|
||||
protected static HeatMeter energy;
|
||||
private int lightningCounter = 0;
|
||||
|
||||
@Override
|
||||
|
@ -49,31 +50,32 @@ public class RenderTickHandler implements ITickHandler {
|
|||
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player != null && MuseItemUtils.modularItemsEquipped(player).size() > 0) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ScaledResolution screen = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
|
||||
double currEnergy = ElectricItemUtils.getPlayerEnergy(player);
|
||||
double maxEnergy = ElectricItemUtils.getMaxEnergy(player);
|
||||
if (maxEnergy > 0) {
|
||||
String currStr = MuseStringUtils.formatNumberShort(currEnergy);
|
||||
String maxStr = MuseStringUtils.formatNumberShort(maxEnergy);
|
||||
MuseRenderer.drawString(currStr + '/' + maxStr + " J", 1, 1);
|
||||
}
|
||||
if (BlockTinkerTable.energyIcon != null) {
|
||||
if (energy == null) {
|
||||
energy = new RadialIndicator(8, 16, 15 * Math.PI / 8, 9 * Math.PI / 8,
|
||||
Colour.BLACK, new Colour(0.2, 0.8, 1.0, 1.0), BlockTinkerTable.energyIcon, MuseRenderer.BLOCK_TEXTURE_QUILT);
|
||||
heat = new RadialIndicator(8, 16, 1 * Math.PI / 8, 7 * Math.PI / 8,
|
||||
Colour.BLACK, Colour.WHITE, Block.lavaMoving.getBlockTextureFromSide(1), MuseRenderer.BLOCK_TEXTURE_QUILT);
|
||||
}
|
||||
// heat.draw(50, 50, 0.6);
|
||||
// energy.draw(50, 50, 0.6);
|
||||
// MuseRenderer.drawLightningBetweenPoints(50.0, 50.0, 1.0,
|
||||
// 50.0, 100.0, 1.0, lightningCounter);
|
||||
// lightningCounter = (lightningCounter + 1) % 50;
|
||||
double currHeat = ElectricItemUtils.getPlayerHeat(player);
|
||||
double maxHeat = ElectricItemUtils.getMaxHeat(player);
|
||||
if (maxEnergy > 0 && BlockTinkerTable.energyIcon != null) {
|
||||
if (Config.useGraphicalMeters()) {
|
||||
if (energy == null) {
|
||||
energy = new EnergyMeter();
|
||||
heat = new HeatMeter();
|
||||
}
|
||||
energy.draw(screen.getScaledWidth() - 20, screen.getScaledHeight() / 2.0 - 16, currEnergy / maxEnergy);
|
||||
heat.draw(screen.getScaledWidth() - 12, screen.getScaledHeight() / 2.0 - 16, currHeat / maxHeat);
|
||||
} else {
|
||||
String currStr = MuseStringUtils.formatNumberShort(currEnergy);
|
||||
String maxStr = MuseStringUtils.formatNumberShort(maxEnergy);
|
||||
MuseRenderer.drawString(currStr + '/' + maxStr + " J", 1, 1);
|
||||
currStr = MuseStringUtils.formatNumberShort(currHeat);
|
||||
maxStr = MuseStringUtils.formatNumberShort(maxHeat);
|
||||
MuseRenderer.drawString(currStr + '/' + maxStr + " C", 1, 10);
|
||||
|
||||
}
|
||||
}
|
||||
if (Minecraft.getMinecraft().currentScreen == null) {
|
||||
MuseRenderer.TEXTURE_MAP = MuseRenderer.ITEM_TEXTURE_QUILT;
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ScaledResolution screen = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
|
||||
int i = player.inventory.currentItem;
|
||||
ItemStack stack = player.inventory.mainInventory[i];
|
||||
if (stack != null && stack.getItem() instanceof IModularItem) {
|
||||
|
|
Loading…
Reference in a new issue