Sign in to follow this  
Followers 0
AceSentinal

Populate Listbox

1 post in this topic

#1 ·  Posted (edited)

I'm trying to populate a listbox from a text file so the user can 1click the item to open its graphic from the web.

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Deck Browser", 346, 357, 192, 124)
GUISetIcon("F:\Apprentice\Appr.exe")
$Block = GUICtrlCreateCombo("Choose Block...", 8, 16, 329, 25)
GUICtrlSetData(-1, IniRead("MagicDeckList.ini","Levels","Expert","Nil"))
$Expansion = GUICtrlCreateCombo("Choose expansion...", 8, 48, 329, 25)
$Deck = GUICtrlCreateCombo("Choose Deck...", 8, 80, 329, 25)
$View = GUICtrlCreateList("", 8, 112, 329, 209, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL))
GUICtrlSetData(-1, "View")
$Btn = GUICtrlCreateButton("Click here to go to the wiki page for this deck", 8, 328, 331, 25, $WS_GROUP)
GUICtrlSetTip(-1, "Only works for theme decks")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Block
            GUICtrlSetData($Expansion, "")
            GUICtrlSetData($Expansion, IniRead("MagicDeckList.ini","Blocks",GUICtrlRead($Block),"nul"))

        Case $Expansion
            GUICtrlSetData($Deck, "")
            GUICtrlSetData($Deck, IniRead("MagicDeckList.ini",GUICtrlRead($Block),GUICtrlRead($Expansion),"No Decks listed in INI"))

        Case $Deck
            GUICtrlSetData($View, "")
            GUICtrlSetData($View, FileRead("Decks\" & IniRead("MagicDeckList.ini",GUICtrlRead($Expansion),GUICtrlRead($Deck),"nul") & "\" & GUICtrlRead($Deck) & ".dec"))

        Case $Btn


;~          http://wiki.mtgsalvation.com/article/
;~ above is the web address where the decks are located. Spaces within deck names are replaced with an underscore and certain decks have _(Deck) attatched to the end of them due to conflicts
;~ between decks/Cards/sets with the same name. Link block/expansion to deck when searching.

;~ http://www.magiccards.info/autocard.php?card=
;~ above is the web address where the cards are located. Spaces within card names are replaced with %20 (the HTML for a space)


    EndSwitch
WEnd

I'm trying to keep it as simple as possible interface wise.

todo:

-TCG options for other sets

-Child window for 1click Card Viewer(pop up window)

-Card list spell check (Against http://www.magiccards.info/autocard.php?card=**)

If anyone is interested:

I do have an extensive list of decks from all of the blocks and expansions to a percentage of world tour decks from Magic: The Gathering

All of the decks are of the Apprentice format.

Figured it out. Thanks.

GUICtrlSetData($View, "")
            FileRead("Decks\" & IniRead("MagicDeckList.ini",GUICtrlRead($Expansion),GUICtrlRead($Deck),"nul") & "\" & GUICtrlRead($Deck) & ".dec")
            $file = FileOpen("Decks\" & IniRead("MagicDeckList.ini",GUICtrlRead($Expansion),GUICtrlRead($Deck),"nul") & "\" & GUICtrlRead($Deck) & ".dec", 0)
            While 1
                $Line = FileReadLine($file)
                If @error = -1 Then ExitLoop
                GUICtrlSetData($View, $Line)
            Wend
            FileClose($file)
Edited by AceSentinal

:blink: What just happened?

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