rendered paste body#include <GUIConstants.au3>
#include <Array.au3>
#include <Date.au3>
#include <File.au3>
#include <GUICombo.au3>
#include <GUITreeView.au3>
Opt("GUIOnEventMode", 1)
DirCreate(@ScriptDir & "\Old Pickits\")
$Form1 = GUICreate("Pickit Editor for Private Kuk-Bot v4", 793, 574, 193, 115)
$Group1 = GUICtrlCreateGroup("Items", 0, 0, 785, 569)
$Group2 = GUICtrlCreateGroup("Item Edit", 232, 8, 545, 553)
$Combo1 = GUICtrlCreateCombo("ACombo1", 240, 48, 193, 25)
GUICtrlSetOnEvent(-1, "ItemClass")
Global $sIType = IniReadSectionNames(@ScriptDir & "/Itemcodes.ini")
$sITypee = _ArrayToString($sIType, "|", 1)
GUICtrlSetData($Combo1, $sITypee)
$Label1 = GUICtrlCreateLabel("Item Type", 240, 30, 51, 17)
$Label2 = GUICtrlCreateLabel("Item Name", 240, 78, 55, 17)
$Combo2 = GUICtrlCreateCombo("ACombo2", 240, 96, 193, 25)
$Group3 = GUICtrlCreateGroup("Options", 240, 128, 185, 193)
$Combo3 = GUICtrlCreateCombo("", 248, 240, 145, 25)
GUICtrlSetData(-1, "Inferior|Normal|Superior|Magic|Set|Rare|Unique|Crafted")
$Label3 = GUICtrlCreateLabel("Quality:", 248, 222, 39, 17)
$Combo4 = GUICtrlCreateCombo("1", 248, 288, 145, 25)
GUICtrlSetData(-1, "2|3|4|5|6|7|8|9|10")
$Label4 = GUICtrlCreateLabel("Ranking (1=Low, 10=High)", 248, 270, 131, 17)
$Combo5 = GUICtrlCreateCombo("Doesn't matter", 248, 160, 145, 25)
GUICtrlSetData(-1, "Yes|No")
$Label5 = GUICtrlCreateLabel("Ethereal", 248, 142, 43, 17)
$Label6 = GUICtrlCreateLabel("Socketed", 248, 181, 50, 17)
$Combo6 = GUICtrlCreateCombo("Doesn't matter", 247, 197, 145, 25)
GUICtrlSetData(-1, "Yes|No")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Save Item", 240, 328, 187, 25, 0)
GUICtrlSetOnEvent(-1, "SaveItem")
$Button2 = GUICtrlCreateButton("Remove Item", 240, 360, 187, 25, 0)
GUICtrlSetOnEvent(-1, "RemItem")
$Button3 = GUICtrlCreateButton("Add as New Item", 240, 392, 187, 25, 0)
GUICtrlSetOnEvent(-1, "AddItem")
$Button4 = GUICtrlCreateButton("Save Pickit", 528, 176, 211, 25, 0)
GUICtrlSetOnEvent(-1, "SavePick")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TreeView1 = GUICtrlCreateTreeView(8, 24, 217, 529)
$TreeView1_1 = GUICtrlCreateTreeViewItem("Inferior", $TreeView1)
$TreeView1_2 = GUICtrlCreateTreeViewItem("Normal", $TreeView1)
$TreeView1_3 = GUICtrlCreateTreeViewItem("Superior", $TreeView1)
$TreeView1_4 = GUICtrlCreateTreeViewItem("Magic", $TreeView1)
$TreeView1_5 = GUICtrlCreateTreeViewItem("Set", $TreeView1)
$TreeView1_6 = GUICtrlCreateTreeViewItem("Rares", $TreeView1)
$TreeView1_7 = GUICtrlCreateTreeViewItem("Uniques", $TreeView1)
$TreeView1_8 = GUICtrlCreateTreeViewItem("Crafts", $TreeView1)
Local $sPickitI = -1
Global $Pickit[1][5]
While 1
$sPickitI += 1
Local $sPickItm = IniRead(@ScriptDir & "/Pickit_V4.ini", "Pickit", "ItemCode_" & $sPickitI, "ERROR")
If $sPickItm = "ERROR" Then ExitLoop
Local $sPickQual = IniRead(@ScriptDir & "/Pickit_V4.ini", "Pickit", "Quality_" & $sPickitI, 1)
Local $sPickStat = IniRead(@ScriptDir & "/Pickit_V4.ini", "Pickit", "ItemStatBasic_" & $sPickitI, 1)
Local $sPickRank = IniRead(@ScriptDir & "/Pickit_V4.ini", "Pickit", "Rank_" & $sPickitI, 1)
Local $sPick = UBound($Pickit)
ReDim $Pickit[$sPick+1][5]
$Pickit[0][0] = $sPick
$Pickit[$sPick][0] = $sPickItm
$Pickit[$sPick][1] = $sPickQual
$Pickit[$sPick][2] = $sPickStat
$Pickit[$sPick][3] = $sPickRank
$Pickit[$sPick][4] = GUICtrlCreateTreeViewItem(IniRead(@ScriptDir & "/NonSort.ini", "Global", $sPickItm, "Error"), Eval("TreeView1_" & $sPickQual))
GUICtrlSetOnEvent(-1, "ChoseItem")
WEnd
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(10)
WEnd
Func ItemClass ()
Global $sItemType = IniReadSection(@ScriptDir & "/Itemcodes.ini", GUICtrlRead($Combo1))
_GUICtrlComboResetContent($Combo2)
For $i = 1 To $sItemType[0][0] Step 1
_GUICtrlComboAddString($Combo2, $sItemType[$i][1])
Next
EndFunc
Func _GUICtrlTreeViewGetCurSel($hTree)
For $s = 0 To _GUICtrlTreeViewGetCount($hTree) Step 1
If _GUICtrlTreeViewGetState($hTree, $s) = 2 Then Return $s
Next
EndFunc
Func ChoseItem ()
Global $sCurTree = @GUI_CtrlId
For $i = 1 To $Pickit[0][0] Step 1
If $Pickit[$i][4] = $sCurTree Then
For $a = 1 To $sIType[0] Step 1
If IniRead(@ScriptDir & "/Itemcodes.ini", $sIType[$a], $Pickit[$i][0], "##") <> "##" Then
_GUICtrlComboSetCurSel($Combo1, $a)
ItemClass ()
For $s = 1 To $sItemType[0][0] Step 1
If $sItemType[$s][0] = $Pickit[$i][0] Then
_GUICtrlComboSetCurSel($Combo2, _GUICtrlComboFindString($Combo2, $sItemType[$s][1]))
EndIf
Next
EndIf
Next
Local $sSock = StringMid($Pickit[$i][2], 12, 1)
If $sSock = "1" Then
_GUICtrlComboSetCurSel($Combo6, 1)
ElseIf $sSock = "0" Then
_GUICtrlComboSetCurSel($Combo6, 2)
Else
_GUICtrlComboSetCurSel($Combo6, 0)
EndIf
Local $sEth = StringMid($Pickit[$i][2], 23, 1)
If $sEth = "1" Then
_GUICtrlComboSetCurSel($Combo5, 1)
ElseIf $sEth = "0" Then
_GUICtrlComboSetCurSel($Combo5, 2)
Else
_GUICtrlComboSetCurSel($Combo5, 0)
EndIf
_GUICtrlComboSetCurSel($Combo3, $Pickit[$i][1]-1)
_GUICtrlComboSetCurSel($Combo4, $Pickit[$i][3]-1)
EndIf
Next
EndFunc
Func SaveItem ()
If IsDeclared("sCurTree") = 0 Then Return MsgBox(1, "Error", "For New Items, you need to hit 'Add New Item'")
For $i = 1 To $Pickit[0][0] Step 1
If $Pickit[$i][4] = $sCurTree Then
$h_item = GUICtrlSendMsg($Treeview1, $TVM_GETNEXTITEM, $TVGN_CARET, 0)
if _GUICtrlTreeViewGetParentHandle($TreeView1, $h_item) = 0 Then Return MsgBox(1, "Error", "For New Items, you need to hit 'Add New Item'")
Local $sCode = _GUICtrlComboGetCurSel($Combo2)+1
$Pickit[$i][0] = $sItemType[$sCode][0]
$Pickit[$i][1] = _GUICtrlComboGetCurSel($Combo3)+1
$Pickit[$i][2] = Gen(GUICtrlRead($Combo5), GUICtrlRead($Combo6))
$Pickit[$i][3] = _GUICtrlComboGetCurSel($Combo4)+1
_GUICtrlTreeViewSetText($TreeView1, $h_item, $sItemType[$sCode][1])
EndIf
Next
EndFunc
Func RemItem ()
If IsDeclared("sCurTree") = 0 Then Return MsgBox(1, "Error", "No item selected")
For $i = 1 To $Pickit[0][0] Step 1
If $Pickit[$i][4] = $sCurTree Then
Local $sCode = _GUICtrlComboGetCurSel($Combo2)
$h_item = GUICtrlSendMsg($Treeview1, $TVM_GETNEXTITEM, $TVGN_CARET, 0)
_GUICtrlTreeViewDeleteItem($Form1, $TreeView1, $h_item)
_ArrayDelete2D($Pickit, $i)
$Pickit[0][0] -= 1
EndIf
Next
EndFunc
Func AddItem ()
Local $sPick = UBound($Pickit)
ReDim $Pickit[$sPick+1][5]
$Pickit[0][0] = $sPick
Local $sCode = _GUICtrlComboGetCurSel($Combo2)+1
$Pickit[$sPick][0] = $sItemType[$sCode][0]
$Pickit[$sPick][1] = _GUICtrlComboGetCurSel($Combo3)+1
$Pickit[$sPick][2] = Gen(GUICtrlRead($Combo5), GUICtrlRead($Combo6))
$Pickit[$sPick][3] = _GUICtrlComboGetCurSel($Combo4)+1
$Pickit[$sPick][4] = GUICtrlCreateTreeViewItem($sItemType[$sCode][1], Eval("TreeView1_" & Number(_GUICtrlComboGetCurSel($Combo3)+1)))
GUICtrlSetOnEvent($Pickit[$sPick][4], "ChoseItem")
EndFunc
Func SavePick ()
FileMove(@ScriptDir & "\Pickit_V4.ini", @ScriptDir & "\Old Pickits\Pickit_V4_" & @MON & "-" & @MDAY & " " & @HOUR & "!" & @MIN & "!" & @SEC & ".ini", 1)
For $i = 1 To $Pickit[0][0] Step 1
IniWrite(@ScriptDir & "\Pickit_V4.ini", "Pickit", "ItemCode_" & ($i - 1), $Pickit[$i][0])
If StringLower($Pickit[$i][0]) = "gld" Then ContinueLoop
IniWrite(@ScriptDir & "\Pickit_V4.ini", "Pickit", "Quality_" & ($i - 1), $Pickit[$i][1])
IniWrite(@ScriptDir & "\Pickit_V4.ini", "Pickit", "ItemStatBasic_" & ($i - 1), $Pickit[$i][2])
IniWrite(@ScriptDir & "\Pickit_V4.ini", "Pickit", "Rank_" & ($i - 1), $Pickit[$i][3])
Next
EndFunc
Func _ArrayDelete2D(ByRef $avArray, $iElement)
Local $passed = False
If (Not IsArray($avArray)) Then
SetError(1)
Return ""
EndIf
; We have to define this here so that we're sure that $avArray is an array
; before we get it's size.
$iUpper = UBound($avArray) ; Size of original array
$iSubItems= Ubound($avArray, 2)
; If the array is only 1 element in size then we can't delete the 1 element.
If $iUpper = 1 Then
SetError(2)
Return ""
EndIf
Local $avNewArray[$iUpper - 1][$iSubItems]
For $a = 0 to $iUpper - 1
If $a = $iElement then
$passed = True
Else
If Not $passed then
For $b = 0 to $iSubItems - 1
$avNewArray[$a][$b] = $avArray[$a][$b]
Next
Else
For $b = 0 to $iSubItems - 1
$avNewArray[$a - 1][$b] = $avArray[$a][$b]
Next
EndIf
EndIf
Next
$avArray = $avNewArray
Return 1
EndFunc
Func Gen($Sock, $Eth)
Local $sXX = "xxxxxxxxxxxx" & "Sock" & "xxxxxxxxxx" & "Eth" & "xxxxxxxx"
Switch $Sock
case "Yes"
$sXX = StringReplace($sXX, "Sock", "1")
case "No"
$sXX = StringReplace($sXX, "Sock", "0")
case "Doesn't Matter"
$sXX = StringReplace($sXX, "Sock", "x")
Case Else
$sXX = StringReplace($sXX, "Sock", "x")
EndSwitch
Switch $Eth
case "Yes"
$sXX = StringReplace($sXX, "Eth", "1")
case "No"
$sXX = StringReplace($sXX, "Eth", "0")
case "Doesn't Matter"
$sXX = StringReplace($sXX, "Eth", "x")
Case Else
$sXX = StringReplace($sXX, "Eth", "x")
EndSwitch
Return $sXX
EndFunc