Sign in to follow this  
Followers 0
Truffle

ListView Searching

4 posts in this topic

Posted Image

Okay first let me explain what the purpose of this program is and how it works.

First of all it is a "database", if you will, of levels created by various authors for an old FPS game called Outlaws. When I release it it will come with an INI file with a list of maps. It will contain the levels name, filesize, author, etc as pictured above. The user can click on the Check for Updates button and it phones home to my webserver and downloads an updated INI file and adds to the list.

That all works fine and dandy, but I would like that Search function to work because (as of right now there are 48 maps in the list) when it starts getting into the 100s and more it will be very hard to find the level you are looking for.

I do however have the sort columns thing going, so its better than nothing, but a search would be really cool!

And another thing is how do I check for which item is clicked on? Say they click on Map No. 6. Which is The Alamo. My idea is for them to click on Map Info and it brings up a summary of the level. (written in the ini file and corresponds to the map number) Then when they click download and it pulls the correct zip file from the webserver.

Here is a sample of the INI file to give you better idea how it works

[version]numMaps=48

[zips]

1=demoranch.zip

2=spacewar.zip

3=oltown.zip

4=olcity.zip

[filesize]

1=14KB

2=1.4MB

3=53KB

4=40KB

[mapnames]

1=Demolition Ranch

2=Space War

3=OL Town

4=OL City

[author]

1=Truffle

2=Molycoat

3=Truffle

4=Truffle

[screenshots]

1=demoranch.jpg

2=spacewar.jpg

3=oltown.jpg

4=olcity.jpg

[mapinfo]

1=Small DM arena map designed for Sanchez/Dynamite matches only

2=Transforms OL into a sci-fi space shooter!

3=First map created by Truffle. A sanc mod featuring the "Cuncussion Rifle"

4=Another map in the "OL" series also containing the Cuncussion Rifle

Share this post


Link to post
Share on other sites



And another thing is how do I check for which item is clicked on? Say they click on Map No. 6. Which is The Alamo. My idea is for them to click on Map Info and it brings up a summary of the level. (written in the ini file and corresponds to the map number) Then when they click download and it pulls the correct zip file from the webserver.

Nice Clean Gui btw...

Reference the above question: this should answer that part.

case $msg = $Listview 
    $filename= $myarray[_GUICtrlListViewGetCurSel($listview)+1]
;;;;-   dont know if u will need the +1 bit in your array. try with and without it.

this returns the index# of the currently selected item in your listview.....hopefully if you have stored these listview items in parallel to an array u can extract the filename stored in it.

hth HardCopy :)


Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Share this post


Link to post
Share on other sites

No Im not using an array. But the GetSurSel does do the job, just differently than the way you used it.

case $msg = $btnInfo

  $a = _GUICtrlListViewGetCurSel($lstMaps)+1

  $selMapName = IniRead($mainDir&"\maplist.ini","mapnames",$a,"Error")

  $selZip = IniRead($mainDir&"\maplist.ini","zips",$a,"Error")

  $selSize = IniRead($mainDir&"\maplist.ini","filesize",$a,"Error")

  $selAuthor = IniRead($mainDir&"\maplist.ini","author",$a,"Error")

  $selScreen =  IniRead($mainDir&"\maplist.ini","screenshots",$a,"Error")

  $selInfo = IniRead($mainDir&"\maplist.ini","mapinfo",$a,"Error")

  MsgBox(0,"",$selMapName&" "&$selZip&" "&$selSize&" "&$selAuthor&" "&$selScreen&" "&$selInfo)

Works great. Thanks for pointing me in the right direction. Now I just gotta read up on child windows so I can put all that information in a new window instead of that message box.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

For the search function you will want to use something like...

For $I = 0 To _GUICtrlListViewGetItemCount(listview) - 1
   $Search = _GUICtrlListViewGetItemText($listview, $I, 1)
   If $Search = "What you want to search for" Then
    ; Do something
   EndIf
Next

Will search the map column (1) of each list view item to check if thats what you wanted to search for. To change if you want to search for, map, author, filename etc. Change the "1" to the appropriate number, remembers its zero based.

All that should work... in theory :).

Edited by Burrup

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0