Tree views and tag info

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
User avatar
Patrickh




Wordewatician 500

Posts: 1173
Joined: Wed Mar 14, 2007 4:53 pm

Tree views and tag info

Post by Patrickh »

I'm trying to get together a basic map file loader, and here's what I have so far:
reads headers and tags
loads them into a list box
opens ce or pc

However, I cant figure out how to put the tags into a tree view.
Im loading the tags by doing a loop where it reads one tag each time around, setting variables for the tag classes, meta offsets, name, etc., and i put the tags into the listbox by simply telling it to add the primary tagclass and name at the end of each loop.
Am i on the right track to putting them into a tree view?
Also, I'm not sure how to store the information from each tag. What I'm looking for is this: loading the tags into a tree view, then when you click on one, it displays some of the info i read earlier, like the classes, offsets, and such
I'm using vb, but you don't need to give me code, just the idea of what to do

here's what i have so far:
Image

Any help is much appreciated!
Image
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
User avatar
grimdoomer




System Engineer

Posts: 1440
Joined: Mon Oct 09, 2006 4:36 pm

Post by grimdoomer »

well if you add them to a treeview, you willl have that entire line the offset, tag class, and path. What you should dp is make it like tag classes then you exspand them and there are all the tags of that class.
Image
AI Zones in MP | Ambiance | Gravemind Beta v1.1
Aumaan Anubis wrote:Grimdoomer. The first person ever to mod Halo 2 Vista.
User avatar
Patrickh




Wordewatician 500

Posts: 1173
Joined: Wed Mar 14, 2007 4:53 pm

Post by Patrickh »

grimdoomer wrote:well if you add them to a treeview, you willl have that entire line the offset, tag class, and path. What you should dp is make it like tag classes then you exspand them and there are all the tags of that class.
yes, but how? I have never used tree views before
Image
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
Patrickssj6




Pi Collaborator

Posts: 5426
Joined: Sat Jul 24, 2004 12:12 pm
Location: I'm a Paranoid
Contact:

Post by Patrickssj6 »

Wait, you just cracked the magic of Halo maps...but you don't know how to populate a tree view? xD

No sorry, that's irony. :D
...left for good
User avatar
Patrickh




Wordewatician 500

Posts: 1173
Joined: Wed Mar 14, 2007 4:53 pm

Post by Patrickh »

Patrickssj6 wrote:Wait, you just cracked the magic of Halo maps...but you don't know how to populate a tree view? xD

No sorry, that's irony. :D
thats pretty much it >_>

so do you know how? you're good at vb, if i send you my source could you look at my method for loading the map and then determine a way to load it into a tree view?
Image
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
User avatar
grimdoomer




System Engineer

Posts: 1440
Joined: Mon Oct 09, 2006 4:36 pm

Post by grimdoomer »

ill help you but only on aim.
Image
AI Zones in MP | Ambiance | Gravemind Beta v1.1
Aumaan Anubis wrote:Grimdoomer. The first person ever to mod Halo 2 Vista.
User avatar
Prey




Connoisseur Snitch! Pyre Articulatist 500

Posts: 1026
Joined: Wed Dec 27, 2006 6:49 am
Location: UK
Contact:

Post by Prey »

grimdoomer wrote:ill help you but only on aim.
Halomods is not good enough?..

Anyway, Treeviews are easy. Just loop through the main classes, make a node for each, loop through the tags, add the tag if it's of the same class, repeat..
Halo 2 Prophet - Skin with ease with the simple 3D point and click interface.
Halo 3 Research Thread - Contribute to the research into Halo 3.
User avatar
Patrickh




Wordewatician 500

Posts: 1173
Joined: Wed Mar 14, 2007 4:53 pm

Post by Patrickh »

thanks for the link, prey. I was able to figure it out from there
Image

Onward to my next problem: being able to click on a tag and retrieve it's attributes. would i create some sort of arraylist and then add to it as I loop through the tags? Once again, I'm a beginner programmer and could use some examples. Thanks for the help!
Image
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
User avatar
grimdoomer




System Engineer

Posts: 1440
Joined: Mon Oct 09, 2006 4:36 pm

Post by grimdoomer »

create a TreeView1_AfterSelect meathod then, you can get the tag path by doing Me.TreeView1.SelectedNodes.Text
Image
AI Zones in MP | Ambiance | Gravemind Beta v1.1
Aumaan Anubis wrote:Grimdoomer. The first person ever to mod Halo 2 Vista.
User avatar
Patrickh




Wordewatician 500

Posts: 1173
Joined: Wed Mar 14, 2007 4:53 pm

Post by Patrickh »

I know how to do that, but that can only return the tag's name. what I'm looking for is this:
when loading the tags, for each tag, I found some info, like the classes, meta offsets, etc. I want to be able to retrieve that info when I click on a tag... so I click on the warthog's tag and I can display it's meta offset in a textbox or something.
Image
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
User avatar
grimdoomer




System Engineer

Posts: 1440
Joined: Mon Oct 09, 2006 4:36 pm

Post by grimdoomer »

create a function and add this once you read it you will be able to make others,

Code: Select all

Public Function FindTagIndexByPath(ByVal TagPath As String) As Integer

            Dim TagIndex As Integer = 0
            'Loop through all the tags and if we find a matching path then we return then index of it
            For i As Integer = 1 To ObjectCount Step 1
                If H2Tag(i).TagPath = TagPath Then
                    TagIndex = i
                    Exit For
                End If
            Next
            Return TagIndex
        End Function
basicly if h2Tag.w/e = H2Tag.w/e Then you can read the info you want cus you now have that tag.
Image
AI Zones in MP | Ambiance | Gravemind Beta v1.1
Aumaan Anubis wrote:Grimdoomer. The first person ever to mod Halo 2 Vista.
User avatar
Patrickh




Wordewatician 500

Posts: 1173
Joined: Wed Mar 14, 2007 4:53 pm

Post by Patrickh »

the problem, though, is that the warthog's collision, model, physics, vehi, etc., all share the same name... that would definately lead to inaccuracies. That also seems like it would work really slowly.
Image
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
User avatar
Altimit01




Connoisseur Snitch! Literarian 500

Posts: 947
Joined: Sun Jun 04, 2006 12:10 pm

Post by Altimit01 »

There's always the lazy way of using a hidden column (or if the language has a built in hidden value for a given item use that) with the array index of the data for the given tag. I find that to be the simplest solution even if it does feel like cheating.

Edit: found the hidden associator: control.tag. If you can use that on a per listbox.item basis that'd be my recommendation.

P.S. why would you use a loop? It's faster to use objects like dictionary or hashtable isn't it?
Image
Download Eschaton: Halomods | Filefront | Mediafire
OwnZ joO




Articulatist 500

Posts: 980
Joined: Thu Nov 10, 2005 4:24 pm

Post by OwnZ joO »

Altimit01 wrote:P.S. why would you use a loop? It's faster to use objects like dictionary or hashtable isn't it?
Those are faster I think, and easy to program with too, another solution that I used is a custom generic TreeNode<T> class that has an Item of type T, and I made the Type be Tag.
User avatar
Patrickh




Wordewatician 500

Posts: 1173
Joined: Wed Mar 14, 2007 4:53 pm

Post by Patrickh »

thanks for the help everyone! I figured out a method. I created a hash table called MetaOffsetStorage. Then, While I'm looping through tags (only only ever loop once), for each tag, I create a key/value pair. I set the key to be the title of the branch i stuck that tag in plus "\" and then the name of the tag. Then I set the value to be Hex$(offset) (the number that HMT shows you when you do meta swaps). Then when you click on a tag, it returns it's path, which is the same as what i set the key to be, so I can easily retrieve it's corresponding value. Also, by adding the primary class to the beginning of the key, it prevent name duplicates like i mentioned earlier. It's probably a little unorthodox, but it works. Thanks for the help!

Removed double post.
Image
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
User avatar
Cryticfarm





Posts: 3611
Joined: Sat Dec 09, 2006 7:23 pm
Location: canada
Contact:

Post by Cryticfarm »

Maybe you pressed post instead of edit?
User avatar
Patrickh




Wordewatician 500

Posts: 1173
Joined: Wed Mar 14, 2007 4:53 pm

Post by Patrickh »

Quick question:

I have a node selected in a tree view. it's key is... key. I want to add that node and every other node within that parent to a combobox.
I tried:
ComboBox1.Items.Add(tv.SelectedNode.Parent.Nodes)

But it just prints "(Collection)"

Thanks in advance
Image
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
-DeToX-




Illusionist Recreator Connoisseur Acolyte
Sigma Decryptor Droplet Pyre
Blacksmith Socialist New Age System Engineer
ONI

Posts: 4589
Joined: Sun Jun 18, 2006 3:58 pm
Location: ...

Post by -DeToX- »

Code: Select all

For i as integer = 0 to treeView1.SelectedNode.Parent.Nodes.Count - 1
ComboBox1.Items.Add(treeView1.SelectedNode.Parent.Nodes(i).Text
Next
Should take care of it for you.

Also you said some tags have different classes... Why not edit the above function to check classes aswell? Here I did it for you.

Code: Select all

Public Function FindTagIndexByPath(ByVal TagClass As String, ByVal TagPath As String) As Integer
Dim TagIndex As Integer = 0
'Loop through all the tags and if we find a matching path then we return then index of it
For i As Integer = 1 To ObjectCount Step 1
  If H2Tag(i).TagPath = TagPath Then
  If H2Tag(i).TagClass = TagClass Then
    TagIndex = i
    Exit For
  End If
   End If
Next
Return TagIndex
End Function
Image
User avatar
Prey




Connoisseur Snitch! Pyre Articulatist 500

Posts: 1026
Joined: Wed Dec 27, 2006 6:49 am
Location: UK
Contact:

Post by Prey »

-DeToX- wrote:[...]

Should take care of it for you.
Missed out a bracket.. :Z

Code: Select all

For i as integer = 0 to treeView1.SelectedNode.Parent.Nodes.Count - 1
ComboBox1.Items.Add(treeView1.SelectedNode.Parent.Nodes(i).Text)
Next
-DeToX- wrote:Also you said some tags have different classes... Why not edit the above function to check classes aswell? Here I did it for you.
[...]
Meh I would swap the checks around, as comparing 4 chars against 4 chars first would be less memory intensive, opposed to comparing variable sized strings to each other that is. Also why the two if commands.. =x

And grimdoomer, initialising the TagIndex to 0 is a bad idea, because if no tag is found 0 is returned.. which is the first tag...

Here fixed it up:

Code: Select all

    Public Function IndexOf(ByVal TagClass As String, ByVal TagPath As String) As Integer
        For i As Integer = 1 To ObjectCount Step 1
            If H2Tag(i).TagClass = TagClass And H2Tag(i).TagPath = TagPath Then
                Return i
            End If
        Next
        Return -1
    End Function
Halo 2 Prophet - Skin with ease with the simple 3D point and click interface.
Halo 3 Research Thread - Contribute to the research into Halo 3.
Post Reply