Posted December 13, 201410 yr Hello everyone, i am need to draw white string in textfield, and i set it text color to 0xFFFFFF, but color now looks grey. Picture below. Need solution. http://i.imgur.com/XfNxbZG.png SOLUTION: If you're using drawDefaultBackground() method in drawScreen() at your gui, you must put it before drawing anything else.
December 13, 201410 yr Author With this method, it is rendered public void drawTextBox(int mouseX, int mouseY) { drawRect(this.posX - 1, this.posY - 1, this.posX + this.width + 1, this.posY + this.height + 1, -6250336); drawRect(this.posX, this.posY, this.posX + this.width, this.posY + this.height, -16777216); int color = 0xFFFFFF; boolean flag = this.isFocused() && this.cursorCounter / 6 % 2 == 0; int startLine = this.getStartLineY(); int maxLine = this.height / this.fontrenderer.FONT_HEIGHT + startLine; List lines = this.getLines(); int charCount = 0; int lineCount = 0; int maxSize = this.width - (this.isScrolling()?14:4); int k2; for(k2 = 0; k2 < lines.size(); ++k2) { String wholeLine = (String)lines.get(k2); String line = ""; char[] xx = wholeLine.toCharArray(); int yy = xx.length; for(int i$ = 0; i$ < yy; ++i$) { char c = xx[i$]; if(this.fontrenderer.getStringWidth(line + c) > maxSize && this.wrapLine) { if(lineCount >= startLine && lineCount < maxLine) { this.fontrenderer.drawString(line, this.posX + 4, this.posY + 4 + (lineCount - startLine) * this.fontrenderer.FONT_HEIGHT, color); } line = ""; ++lineCount; } if(flag && charCount == this.cursorPosition && lineCount >= startLine && lineCount < maxLine && super.canEdit) { int xx1 = this.posX + this.fontrenderer.getStringWidth(line) + 3; int yy1 = this.posY + (lineCount - startLine) * this.fontrenderer.FONT_HEIGHT + 4; if(this.getText().length() == this.cursorPosition) { this.fontrenderer.drawString("_", xx1, yy1, color); } else { this.drawCursorVertical(xx1, yy1, xx1 + 1, yy1 + this.fontrenderer.FONT_HEIGHT); } } ++charCount; line = line + c; } if(lineCount >= startLine && lineCount < maxLine) { this.fontrenderer.drawString(line, this.posX + 4, this.posY + 4 + (lineCount - startLine) * this.fontrenderer.FONT_HEIGHT, color); if(flag && charCount == this.cursorPosition && super.canEdit) { int var20 = this.posX + this.fontrenderer.getStringWidth(line) + 3; yy = this.posY + (lineCount - startLine) * this.fontrenderer.FONT_HEIGHT + 4; if(this.getText().length() == this.cursorPosition) { this.fontrenderer.drawString("_", var20, yy, color); } else { this.drawCursorVertical(var20, yy, var20 + 1, yy + this.fontrenderer.FONT_HEIGHT); } } } ++lineCount; ++charCount; } k2 = Mouse.getDWheel(); if(k2 != 0 && this.isFocused()) { this.addScrollY(k2 < 0?-10:10); } if(Mouse.isButtonDown(0)) { if(this.clickVerticalBar) { if(this.startClick >= 0) { this.addScrollY(this.startClick - (mouseY - this.posY)); } if(this.hoverVerticalScrollBar(mouseX, mouseY)) { this.startClick = mouseY - this.posY; } this.startClick = mouseY - this.posY; } } else { this.clickVerticalBar = false; } this.listHeight = lineCount * this.fontrenderer.FONT_HEIGHT; this.drawVerticalScrollBar(); }
December 13, 201410 yr Author Nothing has been changed, this glitch also exists in vanilla GuiTextField
December 13, 201410 yr Author I mean, after i wrote GL11.glPushMatrix(); GL11.glColor3f(1, 1, 1); this.fontrenderer.drawString(line, this.posX + 4, this.posY + 4 + (lineCount - startLine) * this.fontrenderer.FONT_HEIGHT, color); GL11.glPopMatrix(); nothing has been changed, color in vanilla version the same.
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.