Clan x86

Technical (Development, Security, etc.) => General Programming => Botdev => Topic started by: Camel on December 27, 2007, 02:21:47 PM

Title: Lag bars in a BNI?
Post by: Camel on December 27, 2007, 02:21:47 PM
Does anyone have a file like this/would be willing to do it for me? I am aware that Skywing made a utility to create BNI files, but my computer doesn't meet the requirements (such as having Windows installed).
Title: Re: Lag bars in a BNI?
Post by: Skywing on December 27, 2007, 02:47:28 PM
Lag bar bitmaps are not stored in the .bni file.  (They do not, as I recall, meet the required dimensions for BNI icons anyhow.)
Title: Re: Lag bars in a BNI?
Post by: Joe on December 27, 2007, 03:58:45 PM
I gather that's he's requesting that someone resize them and insert them in a BNI.
Title: Re: Lag bars in a BNI?
Post by: Skywing on December 27, 2007, 05:29:33 PM
I would recommend handling lag bars by having one bar segment of each color as a bitmap included with your program, and then repeatedly drawing the proper number of bars of the proper color based on the user's lag.
Title: Re: Lag bars in a BNI?
Post by: Camel on December 28, 2007, 04:01:51 PM
The image size is specified in the BNI file; it has been precidented to use BNI files to store WC3 icons of non-standard size. For my bot, I shamelessly stole the (nonstandard) BNI file from some other bot. The icons are not 28x14, and my bot is able to parse the file with no problem. The shen below is proof.

The logic for choosing an icon is much simpler if the icons are pre-rendered, and I want to use a BNI file for consistency. I've already got a targa, I just need to convert it to a BNI, and I'd prefer not to have to write my own tool to do so, since this is probably the only time I will ever use it.

[edit] Skywing, would you be willing to update your tool to allow creation of non-standard BNI files?

(http://i125.photobucket.com/albums/p70/MrCamel7/bnubot/bni.png)

[edit2] FWIW, I've already got the logic down, but I'm using static bitmaps that I don't want to put in SVN.

(http://i125.photobucket.com/albums/p70/MrCamel7/bnubot/lag.png)
Title: Re: Lag bars in a BNI?
Post by: Camel on December 30, 2007, 05:19:49 PM
My BNI utility is designed to turn a file to an array of Java Icons; I wrote method to do the opposite.

The BNI file is here: http://bnubot.googlecode.com/svn/trunk/BNUBot/icons_lag.bni
And the source code is here: http://bnubot.googlecode.com/svn/trunk/BNUBot/src/net/bnubot/bot/gui/icons/
Title: Re: Lag bars in a BNI?
Post by: Camel on December 30, 2007, 05:22:39 PM
Can anyone tell me what the ranges for each icon are supposed to be?
Title: Re: Lag bars in a BNI?
Post by: iago on December 30, 2007, 05:25:03 PM
            if(ping < 0)
                return GameIcons.getIcon("6r");
            else if(ping == 0)
                return null;
            else if(ping < 200)
                return GameIcons.getIcon("1g");
            else if(ping < 300)
                return GameIcons.getIcon("2g");
            else if(ping < 400)
                return GameIcons.getIcon("3y");
            else if(ping < 500)
                return GameIcons.getIcon("4y");
            else if(ping < 600)
                return GameIcons.getIcon("5r");

            return GameIcons.getIcon("6r");

I believe I had an actual source for that (ie, I didn't make it up).
Title: Re: Lag bars in a BNI?
Post by: Skywing on December 30, 2007, 06:11:26 PM
That's (slightly) incorrect.  A more accurate version would be as follows (old code and coding styles, but working):


DWORD TranslatePingTime(DWORD dwPingTime)
{
const WORD wBarWidth = 3;
const WORD wGreen = 0 * wBarWidth;
const WORD wYellow = 1 * wBarWidth;
const WORD wRed = 2 * wBarWidth;
WORD wPosition, wCount;
if(dwPingTime < 10) {
wPosition = wGreen;
wCount = 0;
}
else if(dwPingTime < 199) {
wPosition = wGreen;
wCount = 1;
}
else if(dwPingTime < 299) {
wPosition = wGreen;
wCount = 2;
}
else if(dwPingTime < 399) {
wPosition = wYellow;
wCount = 3;
}
else if(dwPingTime < 499) {
wPosition = wYellow;
wCount = 4;
}
else if(dwPingTime < 599) {
wPosition = wRed;
wCount = 5;
}
else {
wPosition = wRed;
wCount = 6;
}
return MAKELONG(wPosition, wCount);
}


Anything below 10ms is counted as no bars by battle.snp to my knowledge, not just 0ms.
Title: Re: Lag bars in a BNI?
Post by: Camel on December 30, 2007, 07:38:08 PM
Skywing, your code seems to indicate the ranges are:
0-9
10-198
199-298
...


Is that correct?
Title: Re: Lag bars in a BNI?
Post by: Skywing on December 31, 2007, 02:26:47 AM
I seem to recall it being so.  If you're not sure, though, you might as well just poke around in battle.snp and get a guaranteed authoritative answer.  I'm pretty sure I did some basic tests to find what the various boundaries were when I wrote that, but maybe I'm misremembering.