Author Topic: Lag bars in a BNI?  (Read 4261 times)

0 Members and 1 Guest are viewing this topic.

Offline Camel

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
    • BNU Bot
Lag bars in a BNI?
« 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).

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!

Offline Skywing

  • Full Member
  • ***
  • Posts: 139
    • View Profile
    • Nynaeve
Re: Lag bars in a BNI?
« Reply #1 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.)
« Last Edit: December 27, 2007, 03:06:35 pm by Skywing »

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: Lag bars in a BNI?
« Reply #2 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.
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline Skywing

  • Full Member
  • ***
  • Posts: 139
    • View Profile
    • Nynaeve
Re: Lag bars in a BNI?
« Reply #3 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.

Offline Camel

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
    • BNU Bot
Re: Lag bars in a BNI?
« Reply #4 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?



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

« Last Edit: December 28, 2007, 04:09:10 pm by Camel »

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!

Offline Camel

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
    • BNU Bot
Re: Lag bars in a BNI?
« Reply #5 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/

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!

Offline Camel

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
    • BNU Bot
Re: Lag bars in a BNI?
« Reply #6 on: December 30, 2007, 05:22:39 pm »
Can anyone tell me what the ranges for each icon are supposed to be?

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Lag bars in a BNI?
« Reply #7 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).

Offline Skywing

  • Full Member
  • ***
  • Posts: 139
    • View Profile
    • Nynaeve
Re: Lag bars in a BNI?
« Reply #8 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):

Code: [Select]
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.

Offline Camel

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
    • BNU Bot
Re: Lag bars in a BNI?
« Reply #9 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?

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!

Offline Skywing

  • Full Member
  • ***
  • Posts: 139
    • View Profile
    • Nynaeve
Re: Lag bars in a BNI?
« Reply #10 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.