Jump to content

Help with race top times


*FuN

Recommended Posts

GUI labels doesn't allow HEX colors.

You'll have to find the function: guiCreateColorLabel or something similar around the forums and implement it in the script.

public class ColorLabelField extends LabelField{     
     
    private int color = 0x000000; 
    private int bg; 
    
    public ColorLabelField(){ 
        super(); 
    } 
    public ColorLabelField(Object text){ 
        super(text); 
    } 
     
    public ColorLabelField(Object text, int offset, int length, long style){ 
        super(text, offset, length, style); 
    } 
     
    public ColorLabelField(Object text, long style){ 
        super(text, style); 
    } 
     
    public ColorLabelField(ResourceBundleFamily rb, int key){ 
        super(rb, key); 
    } 
  
     
    public void setColor(int newColor){ 
        color = newColor; 
    } 
    public void setBackgroundColor(int newBG){ 
        bg=newBG; 
         
    } 
   
    public void paint(Graphics graphics){ 
        graphics.setColor(color); 
        graphics.setBackgroundColor(bg); 
       
        super.paint(graphics); 
    } 
}  

this ?

Link to comment

I sometimes wonder if people is just stupid or blind.

I even leaved the highlighting to the function, you just had to scroll down the code.

function guiCreateColorLabel(ax, ay, bx, by,str, parent, bool) 
    local pat = "(.-)#(%x%x%x%x%x%x)" 
    local s, e, cap, col = str:find(pat, 1) 
    local last = 1 
    local labels = {} 
    while s do 
        if cap == "" and col then r,g,b = tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)) end 
        if (s ~= 1) or cap ~= "" then 
            local w = dxGetTextWidth(cap) 
            lbl = guiCreateLabel(ax, ay, ax + w, by,cap,parent, bool) 
            table.insert(labels, lbl) 
            if (r == nil) then r = 255 end 
            if (g == nil) then g = 255 end 
            if (b == nil) then b = 255 end 
            guiLabelSetColor(lbl,r,g,b) 
            ax = ax + w 
            r,g,b = tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)) 
        end 
        last = e + 1 
        s, e, cap, col = str:find(pat, last) 
    end 
    if (last <= #str) then 
        cap = str:sub(last) 
        local w = dxGetTextWidth(cap) 
        lbl2 = guiCreateLabel(ax, ay, ax + w, by,cap,parent, bool) 
        table.insert(labels, lbl2) 
        guiLabelSetColor(lbl2,r,g,b) 
    end 
    return labels 
end 

Link to comment
race has a function which removes HEX colors, they shouldn't appear.

thankz

Edit:

I sometimes wonder if people is just stupid or blind.

I even leaved the highlighting to the function, you just had to scroll down the code.

function guiCreateColorLabel(ax, ay, bx, by,str, parent, bool) 
    local pat = "(.-)#(%x%x%x%x%x%x)" 
    local s, e, cap, col = str:find(pat, 1) 
    local last = 1 
    local labels = {} 
    while s do 
        if cap == "" and col then r,g,b = tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)) end 
        if (s ~= 1) or cap ~= "" then 
            local w = dxGetTextWidth(cap) 
            lbl = guiCreateLabel(ax, ay, ax + w, by,cap,parent, bool) 
            table.insert(labels, lbl) 
            if (r == nil) then r = 255 end 
            if (g == nil) then g = 255 end 
            if (b == nil) then b = 255 end 
            guiLabelSetColor(lbl,r,g,b) 
            ax = ax + w 
            r,g,b = tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)) 
        end 
        last = e + 1 
        s, e, cap, col = str:find(pat, last) 
    end 
    if (last <= #str) then 
        cap = str:sub(last) 
        local w = dxGetTextWidth(cap) 
        lbl2 = guiCreateLabel(ax, ay, ax + w, by,cap,parent, bool) 
        table.insert(labels, lbl2) 
        guiLabelSetColor(lbl2,r,g,b) 
    end 
    return labels 
end 

When I do a hunter time dont show the coloured names ! :S

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...