Pushed missing files
Started adding Replay Editor using johni0702's excellent ReplayStudio Library Added fully functional GuiDropdown GUI Element (useable in other projects as well)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package eu.crushedpixel.replaymod.utils;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
public class MouseUtils {
|
||||
|
||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public static Point getMousePos() {
|
||||
Point scaled = getScaledDimensions();
|
||||
int width = (int)scaled.getX();
|
||||
int height = (int)scaled.getY();
|
||||
|
||||
final int mouseX = (Mouse.getX() * width / mc.displayWidth);
|
||||
final int mouseY = (height - Mouse.getY() * height / mc.displayHeight);
|
||||
|
||||
return new Point(mouseX, mouseY);
|
||||
}
|
||||
|
||||
public static Point getScaledDimensions() {
|
||||
ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
final int width = sr.getScaledWidth();
|
||||
final int heigth = sr.getScaledHeight();
|
||||
|
||||
return new Point(width, heigth);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package eu.crushedpixel.replaymod.utils;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import eu.crushedpixel.replaymod.reflection.MCPNames;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class ResourceHelper {
|
||||
|
||||
private static BufferedImage defaultThumb;
|
||||
|
||||
static {
|
||||
try {
|
||||
defaultThumb = ImageIO.read(MCPNames.class.getClassLoader().getResourceAsStream("default_thumb.jpg"));
|
||||
} catch(Exception e) {
|
||||
defaultThumb = new BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private static List<ResourceLocation> openResources = new ArrayList<ResourceLocation>();
|
||||
|
||||
public static void registerResource(ResourceLocation loc) {
|
||||
openResources.add(loc);
|
||||
}
|
||||
|
||||
public static void freeResource(ResourceLocation loc) {
|
||||
Minecraft.getMinecraft().getTextureManager().deleteTexture(loc);
|
||||
openResources.remove(loc);
|
||||
}
|
||||
|
||||
public static void freeAllResources() {
|
||||
for(ResourceLocation loc : openResources) {
|
||||
Minecraft.getMinecraft().getTextureManager().deleteTexture(loc);
|
||||
}
|
||||
|
||||
openResources = new ArrayList<ResourceLocation>();
|
||||
}
|
||||
|
||||
public static BufferedImage getDefaultThumbnail() {
|
||||
return defaultThumb;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user