Sign in to follow this  
Followers 0
Shonnie

TreeView Help

2 posts in this topic

So I've been working on this interpreter, where you select what items you want and set thier attibutes, and it writes a file.

I started with checkboxes, and attempted to cross reference them against eachother to write the file, but it was a no-go, as it was way too many lines of coce (Not dynamic enough)

I'm looking for a way to make icons beside a treeview item, or something exactly like this : http://i29.tinypic.com/a2w409.jpg

Also, I got how to right click the treeview items and get a context menu that will pop up another window, but how would I like, assign the attributes in the window to the treeview item?

I was thinking cross-comparing multiple arrays. Example :

You have one checkbox in a list view. You check it, and then right-click and a child GUI pops up with that checkbox's attributes, and an ok button, you set the attributes and hit OK, then it assigns each of those attributes to the same offset in an array as the Checkbox's location in the original array. Like this :

Array Boxes[1]

Boxes[0] = "Checkboxes"

Boxes[1] = "Checkbox 1"

Array Code[1]

Code[0] = "ItemCode"

Code[1] = "Chk"

Array Quality[1]

Quality[0] = "Quality"

Quality[1] = "Checkbox 1 Quality"

Then when you write the file, it will go something like :

FileWriteLine($File, $Code[1] & Quality[1])

Sorry for the cruddy explanation, I don't know what I'm trying to explain, lol

Heres my current script :

#include <GUIConstants.au3>
#include <array.au3>

Opt("TrayAutoPause", 1);dont pause on tray click

$Pickit = "PickItem.lua"
$Priority = 10
Global $GoldAmount

Dim $sCode[1]

_ReadItems(1)

Dim $Checked[1]
Dim $Checkboxes[$sCode[0] + 1]
Dim $CheckboxLeft = 10, $CheckboxTop = 55

$GUI = GUICreate("Awesom-O Pickit Writer", 400, 420, -1, -1, $WS_POPUP+$WS_BORDER)
GUISetBkColor(0xFFFFFF)

GUICtrlCreateLabel("Awesom-O Pickit Writer", 0, 5, 400, 15, $ES_CENTER, $GUI_WS_EX_PARENTDRAG)

$Tab1 = GUICtrlCreateTab(0, 20, 400, 378)
$TabSheet1 = GUICtrlCreateTabItem("Home")

$TabSheet2 = GUICtrlCreateTabItem("Items")
    $TreeView = GUICtrlCreateTreeView(10, 50, 380, 335, BitOR($GUI_SS_DEFAULT_TREEVIEW, $TVS_CHECKBOXES))

    $SelAll_Item = GUICtrlCreateTreeViewItem("Select all", $TreeView)

    For $i = 1 To $sCode[0] Step 1
        GUICtrlCreateTreeViewItem($sCode[$i], $SelAll_Item)
    Next
    
$TabSheet3 = GUICtrlCreateTabItem("Misc")
    $GoldLabel = GUICtrlCreateLabel("Gold: ", 10, 60)
    $GoldInput = GUICtrlCreateInput("1000", 40, 55)
    
    $MeowLabel = GUICtrlCreateLabel("Meow: ", 10, 85)
    $Meow = GUICtrlCreateCombo("Normal", 40, 80, 120)
    GUICtrlSetData(-1,"Unique|Set")
GUICtrlCreateTabItem("")
GUICtrlSetBkColor(-1, 0xFFFFFF)

$Status = GUICtrlCreateLabel("Ready", 5, 400, 100, 30)
GUICtrlSetColor(-1, 0x2B80E6)
$Exit = GUICtrlCreateButton("", 375, 400, 22, 17, 0)
GUICtrlSetBkColor(-1, 0xFF0000)
$Generate = GUICtrlCreateButton("", 350, 400, 22, 17, 0)
GUICtrlSetBkColor(-1, 0x00FF00)

GUISetState()
Do
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $Tab1
            $ActiveTab = GUICtrlRead($Tab1)
            _ReadItems($ActiveTab)
        Case $Generate
            ReDim $Checked[1]
            $Checked[0] = 0
            FileDelete($Pickit)
            _WritePickitStart()
            For $i = 1 To $Checkboxes[0] Step 1
                If GUICtrlRead($Checkboxes[$i]) = $GUI_CHECKED Then
                    $Code = StringRight($sCode[$i], 3)
                    _ArrayAdd($Checked, $Code)
                    
                    _WriteItems($Code)
                    
                    $Checked[0] += 1
                EndIf
            Next
            _WritePickitEnd()
        Case $Exit
            Exit
    EndSwitch
Until $Msg = $GUI_EVENT_CLOSE

Func _ReadItems($FileNumber)
    $Helms = FileOpen("Items/Helms.txt", 0)

    While 1
        $Temp = FileReadLine($Helms)
        If $Temp = "" Then ExitLoop
        _ArrayAdd($sCode, $Temp)
        $sCode[0] += 1
    WEnd
EndFunc  ;==>_ReadItems

Func _WritePickitStart();Writes the start and first few lines
    FileWriteLine($Pickit, "function pickItem(item)");Always starts here
    
    $GoldAmount = GUICtrlRead($GoldInput)
    FileWriteLine($Pickit, '    if item.baseItem.code == "gld" and item.stats[0].Value > ' & $GoldAmount & ' then')
    FileWriteLine($Pickit, "        return " & $Priority)
EndFunc  ;==>_WritePickit

Func _WriteItems($ItemCode);Writes the items individual lines
    FileWriteLine($Pickit, '    elseif item.baseItem.code == "' & $ItemCode & '" then')
    FileWriteLine($Pickit, "        return " & $Priority)
EndFunc  ;==>_WriteItems

Func _WritePickitEnd();Writes the finish
    FileWriteLine($Pickit, "    end");Always ends here
    FileWriteLine($Pickit, "end")
EndFunc  ;==>_WritePickit

Share this post


Link to post
Share on other sites



For really dynamic data referencing, consider the _SQLite_ functions. However, in this case, I think that multi-dimensional arrays would serve you well. Instead of two arrays, it's a single array with two dimensions (like a table).

$Data[0][0] probably has your first checkbox's ID

$Data[0][1] could have the code associated with the first checkbox

$Data[0][2] could have the quality associated with the first checkbox.

$Data[1][0] would be the second checkbox's ID

$Data[1][1] could have the code associated with the second checkbox

$Data[1][2] could have the quality associated with the second checkbox

...

$Data[4][1] could have the code associated with the fifth checkbox

...

$Data[220][2] could have the quality associated with the 221st checkbox

...

etc (however many checkboxes you have)

Just Dim the array (assuming you have 221 checkboxes and three pieces of data associated with each, as shown above) with:

Dim $Data[221][3]

Just remember that, since you start with row '0' for the first checkbox, the xth checkbox will always be represented by $Data[x-1][0, 1 and 2].

A table representation of the above array might look like:

--------------------------------------------------------------------
|                |  0 (Checkbox ID)  |  1 (code)  |  2 (quality)  |
--------------------------------------------------------------------
| 0 (checkbox 1)  |                |            |              |
--------------------------------------------------------------------
| 1 (checkbox 2)  |                |            |              |
--------------------------------------------------------------------
| 2 (checkbox 3)  |                |            |              |
--------------------------------------------------------------------
| 3 (checkbox 4)  |                |            |              |
--------------------------------------------------------------------

.
.
.

--------------------------------------------------------------------
| 220 (c'box 221) |                |            |              |
--------------------------------------------------------------------

Then your FileWrite() would look like:

For $i=0 To 220
    FileWriteLine($File,$Data[$i][1] & $Data[$i][2]
Next

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

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