Je vais détailler ce que la fonction _Enregistrer (du code ci-dessous) est censée faire et expliquer mes problèmes :
-Créer un tableau $tabitem de 6 lignes et 2 colonnes et le remplir de différentes variables.
-Questions :
Ai-je réussi ? Sinon corrigez moi.
Est-ce que je pourrai utiliser ce tableau ultérieurement (fonction _Retrait) ?
-Problème : Remplacer "item" par la variable $titre de la fonction _Config pour permettre la création d'un maximum de 14 tableaux et leurs utilisations ultérieurs. J'ai eu beau essayer, chercher sur google/forum j'ai pas réussi. Pourriez-vous me dire comment faire ?
Voici le code :
► Afficher le texte
Code : Tout sélectionner
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $radio[14]
Global $item_gui, $titre="", $Input1, $Input2 ,$Input3, $Input4, $Input5, $Input6, $Combo2, $Combo3, $Combo4, $Combo5
Global $tstats = ["Absorbtion", "Afflux", "Alacrite", "Bouclier", "Critique", "Defense", "Expertise", "Precision", "Puissance"]
Global $stt, $stats[9]
Global $stat
$gui = GUICreate("Calculateur SWTOR v1", 405, 294, 694, 294)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUICtrlCreateLabel("Stat principale :", 8, 8, 145, 17)
$Combo1 = GUICtrlCreateCombo("", 8, 32, 145, 25)
GUICtrlSetData($Combo1, "Astuce|Vigueur|Visée|Volonté", "")
GUICtrlCreateGroup("Puissance", 8, 56, 153, 41)
GUICtrlCreateLabel("Puissance", 16, 72, 53, 17)
$Label_Puissance = GUICtrlCreateLabel("0", 120, 72, 36, 17)
GUICtrlCreateGroup("Total", 8, 152, 385, 121)
$Lbl1 = GUICtrlCreateLabel("Choisir", 16, 176, 35, 17)
GUICtrlCreateGroup("PvP", 8, 96, 153, 41)
GUICtrlCreateLabel("Ind. Expertise", 16, 112, 68, 17)
$Label_Expertise = GUICtrlCreateLabel("0", 120, 112, 36, 17)
GUICtrlCreateLabel("Endurance", 16, 208, 62, 17)
GUICtrlCreateLabel("Ind. Précision", 16, 240, 74, 17)
GUICtrlCreateLabel("Ind. Alacrité", 144, 176, 66, 17)
GUICtrlCreateLabel("Ind .Critique", 144, 208, 66, 17)
GUICtrlCreateLabel("Ind. Afflux", 144, 240, 57, 17)
GUICtrlCreateLabel("Ind. Défense", 264, 176, 71, 17)
GUICtrlCreateLabel("Ind. Bouclier", 264, 208, 69, 17)
GUICtrlCreateLabel("Ind. Absorb", 264, 240, 64, 17)
$Label_Principale = GUICtrlCreateLabel("0", 96, 176, 36, 17)
$Label_Endurance = GUICtrlCreateLabel("0", 96, 208, 36, 17)
$Label_Precision = GUICtrlCreateLabel("0", 96, 240, 36, 17)
$Label_Alacrite = GUICtrlCreateLabel("0", 216, 176, 36, 17)
$Label_Critique = GUICtrlCreateLabel("0", 216, 208, 36, 17)
$Label_Afflux = GUICtrlCreateLabel("0", 216, 240, 36, 17)
$Label_Defense = GUICtrlCreateLabel("0", 344, 176, 42, 17)
$Label_Bouclier = GUICtrlCreateLabel("0", 344, 208, 42, 17)
$Label_Absorbtion = GUICtrlCreateLabel("0", 344, 240, 42, 17)
$Radio[0] = GUICtrlCreateRadio("Main principale", 168, 112, 100, 17)
$Radio[1] = GUICtrlCreateRadio("Relique 2", 168, 96, 100, 17)
$Radio[2] = GUICtrlCreateRadio("Relique 1", 168, 80, 100, 17)
$Radio[3] = GUICtrlCreateRadio("Poignets", 168, 64, 100, 17)
$Radio[4] = GUICtrlCreateRadio("Implant 2", 168, 48, 100, 17)
$Radio[5] = GUICtrlCreateRadio("Implant 1", 168, 32, 100, 17)
$Radio[6] = GUICtrlCreateRadio("Oreillette", 168, 16, 100, 17)
$Radio[7] = GUICtrlCreateRadio("Casque", 280, 16, 100, 17)
$Radio[8] = GUICtrlCreateRadio("Torse", 280, 32, 100, 17)
$Radio[9] = GUICtrlCreateRadio("Mains", 280, 48, 100, 17)
$Radio[10] = GUICtrlCreateRadio("Ceinture", 280, 64, 100, 17)
$Radio[11] = GUICtrlCreateRadio("Jambières", 280, 80, 100, 17)
$Radio[12] = GUICtrlCreateRadio("Bottes", 280, 96, 100, 17)
$Radio[13] = GUICtrlCreateRadio("Main secondaire", 280, 112, 100, 17)
$Button = GUICtrlCreateButton("Modifier", 192, 136, 131, 17, $WS_GROUP)
GUICtrlSetOnEvent($Combo1, "_stat")
GUICtrlSetOnEvent($Button, "_Config")
GUISetState(@SW_SHOW)
While 1
Sleep(10)
WEnd
Func _stat()
GUICtrlSetData($Lbl1, GUICtrlRead($Combo1));
EndFunc
Func _Config()
If $titre<>"" Then GuiDelete($item_gui)
For $i = 0 To 13
If _IsChecked($radio[$i]) Then $titre = GUICtrlRead($radio[$i], 1)
Next
$item_gui = GUICreate($titre, 216, 185, 816, 242)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
$stat = GUICtrlRead($Combo1)
GUICtrlCreateLabel($stat, 8, 8, 46, 17)
GUICtrlCreateLabel("Endurance", 8, 32, 62, 17)
$Combo2 = GUICtrlCreateCombo("", 8, 56, 80, 25)
$Combo3 = GUICtrlCreateCombo("", 8, 80, 80, 25)
$Combo4 = GUICtrlCreateCombo("", 8, 104, 80, 25)
$Combo5 = GUICtrlCreateCombo("", 8, 128, 80, 25)
For $i = 2 to 5 Step 1
For $j = 1 to 9 Step 1 ;
GUICtrlSetData(Eval("Combo" & $i), $tstats[$j-1]) ; Boucle "inutile" vu le nombre combo (enfin je crois), mais première utilisation de tableau et de boucle dans une boucle :)
Next ;
Next
$Input1 = GUICtrlCreateInput("", 128, 8, 80, 21)
$Input2 = GUICtrlCreateInput("", 128, 32, 80, 21)
$Input3 = GUICtrlCreateInput("", 128, 56, 80, 21)
$Input4 = GUICtrlCreateInput("", 128, 80, 80, 21)
$Input5 = GUICtrlCreateInput("", 128, 104, 80, 21)
$Input6 = GUICtrlCreateInput("", 128, 128, 80, 21)
$Button2 = GUICtrlCreateButton("Ajout objet", 8, 152, 80, 25)
$Button3 = GUICtrlCreateButton("Retrait objet", 128, 152, 80, 25)
GUICtrlSetOnEvent($Button2, "_Enregistrer")
GUICtrlSetOnEvent($Button3, "_Retrait")
GUISetState(@SW_SHOW)
EndFunc
Func _Enregistrer() ; Mes questions problèmes
Dim $tabitem[6][2]=[[$stat,$Input1],["Endurance",$Input2],[$Combo2,$Input3],[$Combo3,$Input4],[$Combo4,$Input5],[$Combo5,$Input6]]
GuiDelete(@GUI_WinHandle)
EndFunc
Func _Retrait()
EndFunc
;Ce qui suit n'est pas de moi, tout comme la première boucle for de _Config()
Func SpecialEvents()
Switch @GUI_CtrlId ; d'où vient le clic ?
Case $GUI_EVENT_CLOSE ; si clic sur la croix
If @GUI_WinHandle = $gui Then ; si la gui d'origine du clic est la principale
Exit ; on ferme tout
Else ; sinon
GuiDelete(@GUI_WinHandle) ; on ferme juste la gui concernée
EndIf
EndSwitch
EndFunc
Func _IsChecked($iControlID)
Return BitAND(GUICtrlRead($iControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc ;==>_IsCheckedMiryhan




