#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <UpDownConstants.au3>
#include <File.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
Global $_LANG[3]
$_LANG[0] = UBound($_LANG)
$_LANG[1] = "English"
$_LANG[2] = "Français"
Global $id_lang = 2
Global $Filter_name
Global $choix
Global $choix1 = 0
Global $choix2 = ""
Global $but1,$but2,$But3
Global $b,$i
Global $filtreLabel
Global $affixe[51][2] ; (1 => Affix name / 2 => default value)
$affixe[0][0] = "AtkSpeedBonus:"
$affixe[0][1] = 5
$affixe[1][0] = "ArmorBonus:"
$affixe[1][1] = 200
$affixe[2][0] = "CritChance:"
$affixe[2][1] = 7
$affixe[3][0] = "_stun_:"
$affixe[3][1] = 10
$affixe[4][0] = "Dex:"
$affixe[4][1] = 150
$affixe[5][0] = "gf:"
$affixe[5][1] = 20
$affixe[6][0] = "mf:"
$affixe[6][1] = 20
$affixe[7][0] = "CritDamage:"
$affixe[7][1] = 30
$affixe[8][0] = "_shard_:"
$affixe[8][1] = 100
$affixe[9][0] = "ExpBonus:"
$affixe[9][1] = 10
$affixe[10][0] = "Str:"
$affixe[10][1] = 150
$affixe[11][0] = "_indes_:"
;$affixe[11][1] =
$affixe[12][0] = "Int:"
$affixe[12][1] = 150
$affixe[13][0] = "Radius:"
$affixe[13][1] = 6
$affixe[14][0] = "lvlreq:"
$affixe[14][1] = 5
$affixe[15][0] = "regen:"
$affixe[15][1] = 200
$affixe[16][0] = "ResArcane:"
$affixe[16][1] = 40
$affixe[17][0] = "ResFire:"
$affixe[17][1] = 40
$affixe[18][0] = "ResCold:"
$affixe[18][1] = 40
$affixe[19][0] = "ResPoison:"
$affixe[19][1] = 40
$affixe[20][0] = "ResPhysical:"
$affixe[20][1] = 40
$affixe[21][0] = "ResLightning:"
$affixe[21][1] = 40
$affixe[22][0] = "Allres:"
$affixe[22][1] = 50
$affixe[23][0] = "GlobeBonus:"
$affixe[23][1] = 1500
$affixe[24][0] = "Vita:"
$affixe[24][1] = 100
$affixe[25][0] = "Sockets:"
$affixe[25][1] = 1
$affixe[26][0] = "LifePercent:"
$affixe[26][1] = 8
$affixe[27][0] = "AverageDamage:"
$affixe[27][1] = 20
$affixe[28][0] = "_blind_:"
$affixe[28][1] = 5
$affixe[29][0] = "MeleeRed:"
$affixe[29][1] = 3
$affixe[30][0] = "RangedRed:"
$affixe[30][1] = 3
$affixe[31][0] = "ControlReduction:"
$affixe[31][1] = 10
$affixe[32][0] = "BlockChanceBonus:"
$affixe[32][1] = 5
$affixe[33][0] = "BlockChance:"
$affixe[33][1] = 20
$affixe[34][0] = "leach:"
$affixe[34][1] = 5
$affixe[35][0] = "loh:"
$affixe[35][1] = 200
$affixe[36][0] = "LifeOnKill:"
$affixe[36][1] = 200
$affixe[37][0] = "WeaponAttacksPerSecond:"
$affixe[37][1] = 1.4
$affixe[38][0] = "DPS:"
$affixe[38][1] = 900
$affixe[39][0] = "BonusVsElites:"
$affixe[39][1] = 5
$affixe[40][0] = "ReducFromElites:"
$affixe[40][1] = 5
$affixe[41][0] = "HatredRegen:"
$affixe[41][1] = 3
$affixe[42][0] = "MaxDiscipline:"
$affixe[42][1] = 3
$affixe[43][0] = "MaxArcanePower:"
$affixe[43][1] = 10
$affixe[44][0] = "MaxMana:"
$affixe[44][1] = 50
$affixe[45][0] = "MaxFury:"
$affixe[45][1] = 10
$affixe[46][0] = "MaxSpirit:"
$affixe[46][1] = 5
$affixe[47][0] = "ManaRegen:"
$affixe[47][1] = 10
$affixe[48][0] = "SpiritRegen:"
$affixe[48][1] = 3
$affixe[49][0] = "ArcaneOnCrit:"
$affixe[49][1] = 10
$affixe[50][0] = "HealthPerSpirit:"
$affixe[50][1] = 150
Global $affixLabel[$_LANG[0]][51]
$affixLabel[2][0] = "% de vitesse d'attaque"
$affixLabel[2][1] = "Armure"
$affixLabel[2][2] = "Chance de coup critique"
$affixLabel[2][3] = "Chance d'étourdir par coup"
$affixLabel[2][4] = "Dextérité"
$affixLabel[2][5] = "Découverte d'objet magique"
$affixLabel[2][6] = "Découverte d'or"
$affixLabel[2][7] = "Dégâts des coups critiques"
$affixLabel[2][8] = "Dégâts phys. à l'attaquant"
$affixLabel[2][9] = "Expérience"
$affixLabel[2][10] = "Force"
$affixLabel[2][11] = "Indestructible"
$affixLabel[2][12] = "Intelligence"
$affixLabel[2][13] = "Rayon de ramassage"
$affixLabel[2][14] = "Réduction du niveau requis"
$affixLabel[2][15] = "Régénération de vie"
$affixLabel[2][16] = "Résistance arcanique"
$affixLabel[2][17] = "Résistance au feu"
$affixLabel[2][18] = "Résistance au froid"
$affixLabel[2][19] = "Résistance au poison"
$affixLabel[2][20] = "Résistance physique"
$affixLabel[2][21] = "Résistance à la foudre"
$affixLabel[2][22] = "Toutes les résistances"
$affixLabel[2][23] = "Vie supplémentaire des globes"
$affixLabel[2][24] = "Vitalité"
$affixLabel[2][25] = "Avec châsses"
$affixLabel[2][26] = "% de vie"
$affixLabel[2][27] = "Bonus moyen aux dégats phy."
$affixLabel[2][28] = "Chance d'aveugler par coup"
$affixLabel[2][29] = "Réduc. des dégats en mélée"
$affixLabel[2][30] = "Réduc. des dégats distants"
$affixLabel[2][31] = "Réduc. du contrôle des foules"
$affixLabel[2][32] = "% de blocage"
$affixLabel[2][33] = "% de blocage total *"
$affixLabel[2][34] = "Vol de vie"
$affixLabel[2][35] = "Vie par coup"
$affixLabel[2][36] = "Vie par victime"
$affixLabel[2][37] = "Attaques par seconde *"
$affixLabel[2][38] = "Dégats par seconde *"
$affixLabel[2][39] = "Bonus contre les élites"
$affixLabel[2][40] = "Réduc. des dégats des élites"
$affixLabel[2][41] = "Régénération de haine"
$affixLabel[2][42] = "Discipline max."
$affixLabel[2][43] = "Puissance arcanique max."
$affixLabel[2][44] = "Mana max."
$affixLabel[2][45] = "Fureur max."
$affixLabel[2][46] = "Esprit max. *"
$affixLabel[2][47] = "Régénération du mana"
$affixLabel[2][48] = "Régénération d'esprit"
$affixLabel[2][49] = "Puiss. arca. par coup critique"
$affixLabel[2][50] = "Vie par esprit dépensé"
Global $filter_count = 1
Global $nb_affixe = UBound($affixe,1)
Global $buto[$nb_affixe]
Global $butf[$nb_affixe]
Global $etato[$nb_affixe]
Global $etatf[$nb_affixe]
Global $val[$nb_affixe]
Global $affixDisplay
Global $x = 10
Global $y = 10
Global $disableTable[20] = [3,8,11,16,17,18,19,20,21,28,41,42,43,44,45,46,47,48,49,50]
;***********************************************************************************************
; génération du tableau de boutons des statistiques ou affixes
;***********************************************************************************************
_main()
While 1
Sleep(100)
WEnd
Func _main()
GUICreate("Filter generator",900,600)
GUICtrlCreateLabel("Obl Fac",$x+20,$y+40)
Local $currentItem = 1
Local $maxItem = 20
For $i=0 To UBound($affixe,1)-1
If $currentItem > $maxItem Then
$currentItem = 1
$x += 300
$y = 10
GUICtrlCreateLabel("Obl Fac",$x+20,$y+40)
EndIf
$buto[$i] = GUICtrlCreateCheckbox ($i, $x+20, $y+60, 15,16)
$butf[$i] = GUICtrlCreateCheckbox ($i, $x+40, $y+60, 15,16)
GUICtrlCreateLabel($affixLabel[$id_lang][$i], $x+60, $y+60)
$val[$i] = GUICtrlCreateInput($affixe[$i][1], $x+210, $y+60, 50, 18)
GUICtrlCreateUpdown($val[$i],$UDS_HORZ)
$y += 20
$currentItem += 1
GUICtrlSetOnEvent($buto[$i], "_ToggleCheckBox")
GUICtrlSetOnEvent($butf[$i], "_ToggleCheckBox")
Next
_Disable()
$x = 10
$y = 10
$choix = GUICtrlCreateInput("2",$x+20,$y+475,50,18)
GUICtrlCreateUpdown($choix,$UDS_HORZ)
GUICtrlCreateLabel("affixe(s) facultatif(s) à retenir parmi:",$x+80,$y+477)
$affixDisplay = GUICtrlCreateLabel("0", $x+250,$y+477)
$But1 = GUICtrlCreateButton("Générer filtre",$x+280,$y+470)
$Filter_name = GUICtrlCreateInput("filter"&$filter_count,$x+355,$y+475,80,18)
$But2 = GUICtrlCreateButton("Ajouter à Grablist.txt",$x+460,$y+470)
$But3 = GUICtrlCreateButton("Réinitialiser la sélection",$x+590,$y+470)
GUICtrlSetState($But2,$GUI_DISABLE)
GUICtrlSetOnEvent($But1, "_Genere_Filtre")
GUICtrlSetOnEvent($But2, "_Ajouter_A_Grablist")
GUICtrlSetOnEvent($But3, "_Reset")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Terminate")
GUISetState(@SW_SHOW)
EndFunc
Func _ToggleCheckBox()
Local $affixId = guiCtrlRead(@GUI_CtrlId,1)
Local $state = GUICtrlRead(@GUI_CtrlId)
Switch @GUI_CtrlId
Case $butf[$affixId]
If $state == $GUI_CHECKED Then
GUICtrlSetState($buto[$affixId],$GUI_UNCHECKED)
GUICtrlSetData($affixDisplay,GUICtrlRead($affixDisplay)+1)
Else
GUICtrlSetData($affixDisplay,GUICtrlRead($affixDisplay)-1)
EndIf
Case $buto[$affixId]
If $state == $GUI_CHECKED And GUICtrlRead($butf[$affixId]) == $GUI_CHECKED Then
GUICtrlSetState($butf[$affixId],$GUI_UNCHECKED)
GUICtrlSetData($affixDisplay,GUICtrlRead($affixDisplay)-1)
EndIf
EndSwitch
EndFunc
; *** désactive les boutons nont pris en compte pour le moment
Func _Disable()
For $i=0 To UBound($disableTable)-1
GUICtrlSetState($buto[$disableTable[$i]],$GUI_DISABLE)
GUICtrlSetState($butf[$disableTable[$i]],$GUI_DISABLE)
GUICtrlSetState($val[$disableTable[$i]],$GUI_DISABLE)
Next
EndFunc
; *** retourne le totale de champs obligatoires ou facultifs ($array => $buto ou $butf)
Func _getTotal($array)
Local $return = 0
For $i=0 To UBound($affixe,1)-1
If GUICtrlRead($array[$i]) == $GUI_CHECKED Then $return += 1
Next
Return $return
EndFunc
; *** fonction qui nettoie la sélection de toute coche
Func _Reset()
For $i = 0 to UBound($affixe,1)-1
GUICtrlSetState($buto[$i],$GUI_UNCHECKED)
GUICtrlSetState($butf[$i],$GUI_UNCHECKED)
Next
GUICtrlSetData($affixDisplay, 0)
GUICtrlSetState($But2,$GUI_DISABLE)
EndFunc
; *** ajoute le filtre cree à la grablist.txt
Func _Ajouter_A_Grablist()
If FileExists(@UserProfileDir&"\Documents\grablist.txt") Then
Else
_FileCreate(@UserProfileDir&"\Documents\grablist.txt")
EndIf
FileOpen(@UserProfileDir&"\Documents\grablist.txt",1)
FileWriteLine(@UserProfileDir&"\Documents\grablist.txt",GuiCtrlRead($filtreLabel))
MsgBox(64,"Filtre enregistré ...","Le fichier "&@UserProfileDir&"\Documents\grablist.txt a été généré/modifié")
$filter_count +=1
GUICtrlSetData ($Filter_name, "filter"&$filter_count)
EndFunc
;*** filtre genere dans un label
Func _Genere_Filtre()
Local $filtre
Local $final_fac
Local $final_obl
Local $obli = _getTotal($buto)
Local $parmi = _getTotal($butf)
Local $fac_retenus = GUICtrlRead($choix)
If ($obli+$fac_retenus) > 6 Then
MsgBox(16,"Impossible !","Trop d'affixes (6 maximum) ...")
Return
EndIf
If ($obli+$parmi) = 0 Then
MsgBox(16,"Impossible !","Aucun affixe sélectionné ...")
Return
EndIf
If $fac_retenus > $parmi Then
MsgBox(16,"Impossible !","Le nombre d'affixes retenus ("&$fac_retenus&") est supérieur au nombre d'affixes cochés ("&$parmi&") ...")
Return
EndIf
If $fac_retenus = $parmi And ($fac_retenus + $parmi <> 0) Then
MsgBox(16,"Impossible !","Le nombre d'affixes retenus ("&$fac_retenus&") ne peut être égal aux nombre d'affixes cochés ("&$parmi&") , auquel cas ces affixes deviennent obligatoires ...")
Return
EndIf
If $fac_retenus = 0 Then
MsgBox(16,"Impossible !","Le nombre d'affixes facultatifs cochés ("&$fac_retenus&") est nul, le générateur n'a rien à faire ...")
Return
EndIf
Local $cpt
Local $chn
Local $aff_val
Local $ArrayFacultatifs[1]
Local $ArrayObligatoires[1]
For $i = 0 To UBound($affixe,1)-1
If GuiCtrlRead($butf[$i]) == $GUI_CHECKED Then _ArrayAdd($ArrayFacultatifs, $affixe[$i][0]&GUICtrlRead($val[$i]))
If GuiCtrlRead($buto[$i]) == $GUI_CHECKED Then _ArrayAdd($ArrayObligatoires, $affixe[$i][0]&GUICtrlRead($val[$i]))
Next
_ArrayDelete($ArrayFacultatifs, 0) ; Removes first index which is empty due to _ArrayAdd
_ArrayDelete($ArrayObligatoires, 0)
Local $aArrayCombo = _ArrayCombinations($ArrayFacultatifs, $fac_retenus, ",")
; remplit la chaine des combinaisons
For $i = 1 to $parmi
If $i=1 Then
$chn = "("&$aArrayCombo[$i]&")"
Else
$chn = $chn&" or ("&$aArrayCombo[$i]&")"
EndIf
Next
Local $final_fac = StringReplace($chn,","," and ")
;remplit la chaine des obligatoires
Local $final_obl
$cpt=0
For $i = 0 to UBound($affixe,1)-1
If GuiCtrlRead($buto[$i]) == $GUI_CHECKED Then
$cpt +=1
If $cpt = 1 Then
$final_obl = $affixe[$i][0]&GUICtrlRead($val[$i])
Else
$final_obl = $final_obl&" and "&$affixe[$i][0]&GUICtrlRead($val[$i])
EndIf
EndIf
Next
If $obli = 0 Then
$filtre = GUICtrlRead($Filter_name)&"=("&$final_fac&")"
Else
$filtre = GUICtrlRead($Filter_name)&"=("&$final_obl&" and ("&$final_fac&"))"
EndIf
$filtreLabel = GUICtrlCreateLabel($filtre,30,530,640,60)
GUICtrlSetState($But2,$GUI_ENABLE)
EndFunc
Func _Terminate()
Exit 0
EndFunc ;==>Terminate