Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: Jaquio on January 17, 2004, 07:06 PM

Title: Channel Display Help.
Post by: Jaquio on January 17, 2004, 07:06 PM
Ok, I have a problem in order to show game Icons by usernames do you have to have a file on your form for the icons? If so where can I find this file, If not can someone point me in the direction of find out how to make it show the icons.
Title: Re:Channel Display Help.
Post by: o.OV on January 17, 2004, 09:17 PM
Use the search facility and search for

.bni

That will give you information about the icon file from bnet.

What I did when I first made a chat bot with icon next to username is have an array of imageboxes..

I don't know if that is the best way to go but it is a start.
Title: Re:Channel Display Help.
Post by: UserLoser. on January 17, 2004, 11:42 PM
Assuming you're using Visual Basic, you can just use a ListView along with the ImageList controls, then just have the ListView load images from the ImageList
Title: Re:Channel Display Help.
Post by: Jaquio on January 18, 2004, 10:02 AM
Ok thank you. I got all that working now I just can't get Warcraft 3:tft to work... How would I do that like I did with these


   If Product = "STAR" Then
       InChannel.ListItems.add , , Username, , 6
   ElseIf Product = "SEXP" Then
       InChannel.ListItems.add , , Username, , 9
   ElseIf Product = "D2DV" Then
       InChannel.ListItems.add , , Username, , 5
   ElseIf Product = "D2XP" Then
       InChannel.ListItems.add , , Username, , 13
   ElseIf Product = "W2BN" Then
       InChannel.ListItems.add , , Username, , 10
   ElseIf Product = "WAR3" Then
       InChannel.ListItems.add , , Username, , 61
   ElseIf Product = "CHAT" Then
       InChannel.ListItems.add , , Username, , 2
   ElseIf Product = "DRTL" Then
       InChannel.ListItems.add , , Username, , 12
   ElseIf Product = "DSHR" Then
       InChannel.ListItems.add , , Username, , 1
   ElseIf Product = "JSTR" Then
       InChannel.ListItems.add , , Username, , 11
   ElseIf Product = "SSHR" Then
       InChannel.ListItems.add , , Username, , 1
   Else
       InChannel.ListItems.add , , Username, , 8
   End If
   lbPing.AddItem Ping


What would the war3:tft be?
Title: Re:Channel Display Help.
Post by: UserLoser. on January 18, 2004, 11:47 AM
Warcraft III: The Frozen Throne's id would be W3XP - As far as adding the images to the listview, you'll need to find the W3XP icon if you don't already have one
Title: Re:Channel Display Help.
Post by: Kp on January 18, 2004, 12:19 PM
That code could be improved.  Instead of having each branch invoke add with a common username and an ID# unique to the product, set it up as such:

if product is starcraft, then id = 6
else if product is brood war, then id = 9
etc.  Alternately, you could use a select case statement.  After the branching, id will be set to the number of the icon.  Then you can have InChannel.ListItems.add , , Username, , id.  This has the advantage of (probably) being smaller in code size, and certainly easier to maintain if you change how you add people to the listview.
Title: Re:Channel Display Help.
Post by: hismajesty on January 18, 2004, 01:51 PM
 Select Case product
   Case = "STAR"
       InChannel.ListItems.add , , Username, , 6
   Case = "SEXP"
       InChannel.ListItems.add , , Username, , 9
   Case = "D2DV"
       InChannel.ListItems.add , , Username, , 5
   Case = "D2XP"
       InChannel.ListItems.add , , Username, , 13
   Case = "W2BN"
       InChannel.ListItems.add , , Username, , 10
   Case = "WAR3"
       InChannel.ListItems.add , , Username, , 61
   Case = "W3XP"
       InChannel.ListItems.add , , Username, , 62 'Replace with whatever your icon # is
   Case = "DSHR"
       InChannel.ListItems.add , , Username, , 1
   Case = "DRTL"
       InChannel.ListItems.add , , Username, , 12
   Case = "JSTR"
       InChannel.ListItems.add , , Username, , 11
   Case = "SSHR"
       InChannel.ListItems.add , , Username, , 1
   Case = "CHAT"
       InChannel.ListItems.add , , Username, , 2
   Case Else
       InChannel.ListItems.add , , Username, , 8
 End Select
lbPing.AddItem Ping


Change the W3XP image number.
Title: Re:Channel Display Help.
Post by: Grok on January 18, 2004, 02:11 PM
Kp is correct.  There are multiple ways to implement, each as correct as the others.  They vary in efficiency, readability, and maintainability.

Since you are using an imagelist, you could name each icon the same as the product.  The imagelist image key for "STAR" would be "STAR".  The advantage here being that selecting an image by product is made easier:

   'do this in Form_Load
   InChannel.Icons = ImgLstIcons
   InChannel.SmallIcons = ImgLstSmallIcons
   InChannel.ColumnHeaderIcons = ImgLstSmallIcons
   
   'do this as users are added to the channel list
   InChannel.ListItems.Add , , UserName, Product, Product


This method assumes you associated two imagelists with the listview.

After you get comfortable with this method, you should look at the VB code required to download and parse icons.bni, and use the resulting images to load into the ImageList with ListImages.Add LoadPicture(...)

   'add parsed images to imagelist
   ImageList1.ListImages.Add LoadPicture("STAR.jpg", vbLPSmall, vbLPColor)


Hope this helps.
Title: Re:Channel Display Help.
Post by: UserLoser. on January 18, 2004, 02:13 PM
Quote from: Grok on January 18, 2004, 02:11 PM
Kp is correct.  There are multiple ways to implement, each as correct as the others.  They vary in efficiency, readability, and maintainability.

Since you are using an imagelist, you could name each icon the same as the product.  The imagelist image key for "STAR" would be "STAR".  The advantage here being that selecting an image by product is made easier:

   'do this in Form_Load
   InChannel.Icons = ImgLstIcons
   InChannel.SmallIcons = ImgLstSmallIcons
   InChannel.ColumnHeaderIcons = ImgLstSmallIcons
   
   'do this as users are added to the channel list
   InChannel.ListItems.Add , , UserName, Product, Product


This method assumes you associated two imagelists with the listview.

After you get comfortable with this method, you should look at the VB code required to download and parse icons.bni, and use the resulting images to load into the ImageList with ListImages.Add LoadPicture(...)

   'add parsed images to imagelist
   ImageList1.ListImages.Add LoadPicture("STAR.jpg", vbLPSmall, vbLPColor)


Hope this helps.

Converting the TGA to a JPG/BMP - isn't that a bit hard to do?
Title: Re:Channel Display Help.
Post by: Grok on January 18, 2004, 02:22 PM
You can use DirectX to convert Targa to JPG.  There are probably other libraries in Windows which can do it, and if not, it's very likely you can find a public-domain DLL.

I think ReaJpeg 1.1 does it, but I haven't tested it.
http://download.com.com/3001-2192-10194049.html (http://download.com.com/3001-2192-10194049.html)
Title: Re:Channel Display Help.
Post by: UserLoser. on January 18, 2004, 02:24 PM
Quote from: Grok on January 18, 2004, 02:22 PM
You can use DirectX to convert Targa to JPG.  There are probably other libraries in Windows which can do it, and if not, it's very likely you can find a public-domain DLL.

I can extract the entire list of icons with no problem, separate the flags, product and everything except splitting up each image (so it's just one big list of icons together); perhaps you can show an example? :P
Title: Re:Channel Display Help.
Post by: Grok on January 18, 2004, 02:34 PM
Here is a site with a list of file formats:

http://www.opennet.ru/docs/formats/ (http://www.opennet.ru/docs/formats/)
Title: Re:Channel Display Help.
Post by: UserLoser. on January 18, 2004, 02:47 PM
Quote from: Grok on January 18, 2004, 02:34 PM
Here is a site with a list of file formats:

http://www.opennet.ru/docs/formats/ (http://www.opennet.ru/docs/formats/)

Seen that TGA.txt already, but thanks I don't think i've seen any of the other ones ;)
Title: Re:Channel Display Help.
Post by: Arta on January 19, 2004, 03:07 AM
Converting TGA to BMP isn't particularly difficult. Targa files as used by Battle.net are basically the same as BMPs, except with a different header, a slightly different pixel format and some (trivial) compression. They can vary in their format but for this purpose, it's not complicated.
Title: Re:Channel Display Help.
Post by: DarkMinion on January 19, 2004, 04:26 AM
Owner drawn listbox > *  ;D
Title: Re:Channel Display Help.
Post by: Jaquio on January 19, 2004, 09:28 AM
Wow, thanks for all the help. I did make my code smaller in size with the code and info you all told me and now I have W3XP image showing instead of when someone joins the channel the bot quits. Thank you all for helping me, If I ever need help with anything I always come here and get the problem figured out.
Title: Re:Channel Display Help.
Post by: Hazard on January 19, 2004, 11:03 AM
By the way... you're signature is even more obnoxious than Feanor's.
Title: Re:Channel Display Help.
Post by: ChR0NiC on January 19, 2004, 07:08 PM
Quote from: Jaquio on January 18, 2004, 10:02 AM
Ok thank you. I got all that working now I just can't get Warcraft 3:tft to work... How would I do that like I did with these


   If Product = "STAR" Then
       InChannel.ListItems.add , , Username, , 6
   ElseIf Product = "SEXP" Then
       InChannel.ListItems.add , , Username, , 9
   ElseIf Product = "D2DV" Then
       InChannel.ListItems.add , , Username, , 5
   ElseIf Product = "D2XP" Then
       InChannel.ListItems.add , , Username, , 13
   ElseIf Product = "W2BN" Then
       InChannel.ListItems.add , , Username, , 10
   ElseIf Product = "WAR3" Then
       InChannel.ListItems.add , , Username, , 61
   ElseIf Product = "CHAT" Then
       InChannel.ListItems.add , , Username, , 2
   ElseIf Product = "DRTL" Then
       InChannel.ListItems.add , , Username, , 12
   ElseIf Product = "DSHR" Then
       InChannel.ListItems.add , , Username, , 1
   ElseIf Product = "JSTR" Then
       InChannel.ListItems.add , , Username, , 11
   ElseIf Product = "SSHR" Then
       InChannel.ListItems.add , , Username, , 1
   Else
       InChannel.ListItems.add , , Username, , 8
   End If
   lbPing.AddItem Ping


What would the war3:tft be?

I don't mean to be a jerk but I think Select Case might be better :D

Select Case Product

Case "STAR"
       InChannel.ListItems.add , , Username, , 6
Case "SEXP"
       InChannel.ListItems.add , , Username, , 9
Case "D2DV"
       InChannel.ListItems.add , , Username, , 5
Case "D2XP"
       InChannel.ListItems.add , , Username, , 13
Case "W2BN"
       InChannel.ListItems.add , , Username, , 10
Case "WAR3"
       InChannel.ListItems.add , , Username, , 61
Case "CHAT"
       InChannel.ListItems.add , , Username, , 2
Case "DTRL"
       InChannel.ListItems.add , , Username, , 12
Case "DSHR"
       InChannel.ListItems.add , , Username, , 1
Case "JSTR"
       InChannel.ListItems.add , , Username, , 11
Case "SSHR"
       InChannel.ListItems.add , , Username, , 1
Case  Else
       InChannel.ListItems.add , , Username, , 8
End Select
lbPing.AddItem Ping


Just incase you weren't aware of Select Case......it saves alot of time and space. And I have had more efficient results when using it. So just a suggestion  :P
Title: Re:Channel Display Help.
Post by: R.a.B.B.i.T on January 19, 2004, 08:16 PM
Why not use Public or Global Integer Consts instead of a seperate add?

On Error GoTo OnErr1
Dim ICON As Integer
Select Case varProd
   Case "RATS"
       ICON = i_STAR
   Case "PXES"
       ICON = i_SEXP
   Case "VD2D"
       ICON = i_D2DV
   Case "PX2D"
       ICON = i_D2XP
   Case "NB2W"
       ICON = i_W2BN
   Case "3RAW"
       ICON = i_WAR3
   Case "PX3W"
       ICON = i_W3XP
   Case "TAHC"
       ICON = i_CHAT
   Case "LTRD"
       ICON = i_DRTL
   Case "RHSD"
       ICON = i_DSHR
   Case "RHSS"
       ICON = i_SSHR
   Case Else
       ICON = i_UNWN
End Select
InChannel.ListItems.Add , , UserName, , ICON
Exit Sub
OnErr1:
InChannel.ListItems.Add , , UserName, , i_UNWN

It's a lot better.
Title: Re:Channel Display Help.
Post by: hismajesty on January 20, 2004, 08:27 AM
QuoteJust incase you weren't aware of Select Case......it saves alot of time and space. And I have had more efficient results when using it. So just a suggestion  :P

Yeah, using a switch has been said two or three times already. :P
Title: Re:Channel Display Help.
Post by: Grok on January 20, 2004, 12:43 PM
Should also consider wrapping that into a function.

Private Function GetProductIdFromType(ProductType As String) As Integer
...

Title: Re:Channel Display Help.
Post by: R.a.B.B.i.T on January 20, 2004, 05:14 PM
Quote from: Grok on January 20, 2004, 12:43 PM
Should also consider wrapping that into a function.

Private Function GetProductIdFromType(ProductType As String) As Integer
...


Long function name..why not just GetIcon(Product As String) As Integer?
Title: Re:Channel Display Help.
Post by: SKiLLs on January 22, 2004, 09:18 PM
Quote from: UserLoser. on January 18, 2004, 02:13 PMConverting the TGA to a JPG/BMP - isn't that a bit hard to do?

I use IrfanView :
http://download.com.com/3000-2192-10223761.html

and it's FREE!!
Title: Re:Channel Display Help.
Post by: Tuberload on January 23, 2004, 01:03 AM
Quote from: R.a.B.B.i.T on January 20, 2004, 05:14 PM
Quote from: Grok on January 20, 2004, 12:43 PM
Should also consider wrapping that into a function.

Private Function GetProductIdFromType(ProductType As String) As Integer
...


Long function name..why not just GetIcon(Product As String) As Integer?

Some people like to use long, descriptive method/variabled names because it makes it easier for others to understand, as well as yourself if you leave a project and come back to it after a long period of time.