Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.theonrd.rmod;
- import net.minecraft.client.gui.GuiButton;
- import net.minecraft.client.gui.GuiScreen;
- import net.minecraft.client.renderer.Tessellator;
- import net.minecraft.util.ResourceLocation;
- import net.minecraftforge.client.event.GuiScreenEvent;
- import net.minecraftforge.common.MinecraftForge;
- import org.lwjgl.input.Keyboard;
- import org.lwjgl.input.Mouse;
- import org.lwjgl.opengl.GL11;
- public class MapGui extends GuiScreen {
- private static int lastwidth;
- private static int lastheight;
- static float tileAdditiveX = 0;
- static float tileAdditiveY = 0;
- static float tileMultipler = 1;
- private static ResourceLocation texture;
- private static ResourceLocation backgr;
- private String TextureName;
- public MapGui(String MapTexture){
- this.TextureName=MapTexture;
- }
- @Override
- public void initGui() {
- texture = new ResourceLocation("rmod", "textures/map_01.png");
- backgr = new ResourceLocation("rmod", "textures/back_01.png");
- buttonList.clear();
- //buttonList.add(BTN_ADDBIND);
- }
- public void updateScaling(){
- lastwidth = width;
- lastheight = height;
- }
- @Override
- public void handleKeyboardInput() {
- if (Keyboard.getEventKeyState())
- {
- this.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
- }
- this.mc.func_152348_aa();
- }
- /*
- * MouseButton:
- *
- * 0 > Left button
- * 1 > Right Button
- * 2 > Middle button
- *
- * */
- @Override
- protected void mouseClicked(int coord_X, int coord_Y, int MouseButton) {
- }
- @Override
- public void drawScreen(int i, int j, float f) {
- if(lastheight != height || lastwidth != width) initGui(); // If we change screen resolution, we need also update auto-scaling.
- if(Mouse.isButtonDown(2) || Mouse.isButtonDown(1)) {
- tileMultipler = .7F;
- tileAdditiveX = (float) Mouse.getX() / width;
- tileAdditiveY = (float) Mouse.getY() / height * -1;
- }
- else {
- tileMultipler = 1;
- tileAdditiveX = 0;
- tileAdditiveY = 0;
- }
- drawDefaultBackground();
- mc.getTextureManager().bindTexture(texture);
- drawQuad(floatToWidth(.6F / tileMultipler), floatToHeight(.8F / tileMultipler));
- super.drawScreen(i, j, f);
- }
- public void drawQuad(int sizeX, int sizeY){
- if(sizeX <= sizeY) sizeY = sizeX;
- else sizeX = sizeY;
- int x = (width - sizeX) / 2;
- int y = (height - sizeY) / 2;
- Tessellator tessellator = Tessellator.instance;
- tessellator.startDrawingQuads();
- tessellator.addVertexWithUV((double)(x + 0), (double)(y + sizeY), (double)this.zLevel,
- (double)((0F + tileAdditiveX) * tileMultipler), (double)((1F + tileAdditiveY) * tileMultipler)); // Left-Up
- tessellator.addVertexWithUV((double)(x + sizeX), (double)(y + sizeY), (double)this.zLevel,
- (double)((1F + tileAdditiveX) * tileMultipler), (double)((1F + tileAdditiveY) * tileMultipler)); // Right-Up
- tessellator.addVertexWithUV((double)(x + sizeX), (double)(y + 0), (double)this.zLevel,
- (double)((1F + tileAdditiveX) * tileMultipler), (double)((0F + tileAdditiveY) * tileMultipler)); // Right-Down
- tessellator.addVertexWithUV((double)(x + 0), (double)(y + 0), (double)this.zLevel,
- (double)((0F + tileAdditiveX) * tileMultipler), (double)((0F + tileAdditiveY) * tileMultipler)); // Left-Down
- tessellator.draw();
- }
- // WARN!
- // Use float from range -1..1
- public int floatToWidth (float f){
- return (int) (width * f);
- }
- // WARN!
- // Use float from range -1..1
- public int floatToHeight (float f) {
- return (int) (height * f);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement