MatthiasM wrote:
Thanks a lot!
It works like a charm ^^.
dime here is a screenshot:
Text is Hungarian.
Here is my renderer if someone need it.
Code:
import de.matthiasmann.twl.renderer.lwjgl.LWJGLRenderer;
import org.lwjgl.LWJGLException;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
/**
*
* @author Laxika
*/
public class TWLRenderer extends LWJGLRenderer {
private Graphics g = null;
public TWLRenderer() throws LWJGLException {
super();
}
/**
* @return the g
*/
public Graphics getGraphics() {
return g;
}
public void setGraphics(Graphics g) {
this.g = g;
}
public Color getTintedColor(Color c) {
float[] f = new float[4];
getTintedColor(new de.matthiasmann.twl.Color((byte) c.getRedByte(), (byte) c.getGreenByte(), (byte) c.getBlueByte(), (byte) c.getAlphaByte()), f);
return new Color(f[0], f[1], f[2], f[3]);
}
}
and an example code:
Code:
@Override
protected void paintWidget(GUI gui) {
if (gui.getRenderer() instanceof TWLRenderer) {
TWLRenderer renderer = (TWLRenderer) gui.getRenderer();
Graphics g = renderer.getGraphics();
if (g == null) {
return;
}
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
int percentage = (int) ((float) SkillData.getInstance().getXP(skill) / (float) SkillData.getInstance().getNextLevelXP(skill) * 100);
int pref = 0;
if (percentage == 0) {
pref = 1;
}
g.setColor(renderer.getTintedColor(Color.red));
g.fill(new Rectangle(this.getX() + 130, this.getY() + 27, percentage * 2 + pref, 10));
g.setColor(renderer.getTintedColor(Color.black));
g.drawRect(this.getX() + 130, this.getY() + 26, 200, 10);
font.drawString(this.getX() + 230 - font.getWidth(percentage + "%") / 2, getY() + 26, percentage + "%",renderer.getTintedColor(Color.white));
GL11.glPopAttrib();
}
}
I would like to ask another questation if its possible. :O
Is there are any way to check if any tinting is actually in process?
Just because I don't want to convert the color and check the tinting every time when no tinting is actually in process, instead just return the original color then. I saw this in resizableframe:
Code:
public int getFadeDurationActivate() {
return fadeDurationActivate;
}
public int getFadeDurationDeactivate() {
return fadeDurationDeactivate;
}
Well this isn't really what I want because tinting can occur without resizableframes I think, and I can't get this variable because I don't know wich pharent is my ResizableFrame.