Jump to content

DrawRect() not working in GuiScreen


ScarabCoder

Recommended Posts

My Gui class (contains my own API stuff):

package com.scarabcoder.ereijan.gui;

import java.io.IOException;
import java.util.List;

import org.lwjgl.opengl.GL11;

import com.mojang.realmsclient.gui.ChatFormatting;
import com.scarabcoder.ereijan.Main;
import com.scarabcoder.ereijan.ScarabUtil.MPlayer;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;

public class GUIMineBook extends GuiScreen{

private GuiTextField text;


MPlayer player;

List<MPlayer> friends;

List<MPlayer> friendRE;

List<MPlayer> friendRS;

public GUIMineBook(){
	initVars();
}

public void initGui()
    {
        this.text = new GuiTextField(1, this.fontRendererObj, this.width / 3, 25, this.width / 3 - 26, 20);
        text.setMaxStringLength(200);
        this.text.setFocused(false);
        this.buttonList.add(new GuiButton(1, this.width / 3 * 2 - 20, 25, 20, 20, ">"));
        this.buttonList.add(new GuiButton(2, this.width - (this.width / 6), 0, this.width / 6, 20, "Refresh"));
        this.buttonList.add(new GuiButton(3, 0, 0, this.width / 6, 20, "Back to Game"));
	this.drawRect(5, 5, 20, 20, 0xFFFFFF);
    }

    public void updateScreen()
    {
        super.updateScreen();
        this.text.updateCursorCounter();
    }

public void initVars(){
	this.player = Main.getMPlayer();

	this.friends = player.getFriends();

	this.friendRE = player.getFriendRequestManager().getFriendRequests();

	this.friendRS = player.getFriendRequestManager().getSentFriendRequests();

}



@Override
    public void drawScreen(int mouseX, int mouseY, float partialTicks){

	this.drawBackground(0);
	this.text.drawTextBox();
	this.drawCenteredString(fontRendererObj, ChatFormatting.BOLD + "MINEBOOK", this.width / 2, 10, 0x32CD32);
	this.drawCenteredString(fontRendererObj, "FRIEND REQUESTS", this.width / 7, 30, 0xFFFFFF);
	this.drawCenteredString(fontRendererObj, "FRIENDS", this.width - (this.width / 7), 30, 0xFFFFFF);
	this.drawHorizontalLine(0, this.width, 65, 0x111);

	super.drawScreen(mouseX, mouseY, partialTicks);
}


    protected void mouseClicked(int x, int y, int btn) {
        try {
		super.mouseClicked(x, y, btn);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
        this.text.mouseClicked(x, y, btn);
    }
    protected void keyTyped(char par1, int par2)
    {
        try {
		super.keyTyped(par1, par2);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
        this.text.textboxKeyTyped(par1, par2);
    }
}

Link to comment
Share on other sites

Nothing you're doing in drawScreen is visible because you're calling super.drawScreen() after drawing.  super() is coming along and drawing on top of it, hiding it.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Umm... wait a second.

 

Why are you calling drawRect from initGui()? That method is called once on opening gui.

 

You need to draw stuff in drawScreen. And super-drawScreen should be at end (depends).

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

I may be wrong, that was what I thought was happening from an initial examination.  I haven't messed with guicode in a while.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I may be wrong, that was what I thought was happening from an initial examination.  I haven't messed with guicode in a while.

 

ScreenGui#drawScreen

draws all the buttons and labels. If you use those you would probably want to call it last, to prevent them from being behind background objects.

Link to comment
Share on other sites

  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.