Hallo zusammen,
ich erklär erstmal worums geht.
Es sollen beliebig viele Bilder mit einander verglichen werden. Dazu werden sie immer paarweise angezeigt und durch einen Klick wird jeweils das bessere bzw der Gewinner bestimmt. Am Ende soll somit das beste Bild angezeigt werden.
Ich hab mir ein wenig Gedanken gemacht, wie ich die Punktevergabe am besten aufbaue, am Ende habe ich es bei 0,1 und 2 belassen.
0 = Verlohren, 1 = noch im Pott, 2 = temporärer Gewinner.
Wenn max. noch ein Bild im Pott ist, sprich es eine 1 hat, werden alle 2er resettet, sprich wieder auf 1 gesetzt.
Sollte danach festgestellt werden, es gibt trozdem nur dieses eine bild mit ner 1 (es gab keine 2er mehr, alle anderen sind 0) ist das der Gewinner.
Das Problem was ich jetzt noch habe, ist, dass manche Bilder nicht angezeigt werden.
Es liegt weder am Pfad noch am Dateinamen, es liegt am Bild oder sonstwas.
Spoiler anzeigen
opt("TrayIconHide", 1)
#Include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $round = 1, $pic1, $pic2
Global $x, $x_abstand, $x_bild, $x_mitte, $y, $y_abstand, $y_bild, $y_text, $oben, $links
gui_start ()
Local $OpenFolder = FileOpenDialog ("Mindestens 2 Bilder auswählen...", "C:\", "Bilder (*.jpg;*.bmp)", 7)
Local $tmp1 = StringSplit(StringTrimLeft($OpenFolder, StringInStr($OpenFolder, "|")), "|")
Global $pfad = StringLeft ($OpenFolder, StringInStr ($OpenFolder, "|")-1) & "\"
Global $aFiles[UBound($tmp1)][2]
For $i = 1 To UBound($aFiles)-1
$aFiles[$i][0] = $tmp1[$i]
$aFiles[$i][1] = 1
Next
While True
$pic1 = ""
$pic2 = ""
; zwei pics raussuchen
For $i = 1 To UBound($aFiles, 1) -1
If $aFiles[$i][1] = 1 And $pic2 = "" Then
If $pic1 = "" Then
$pic1 = $i
ElseIf $pic2 = "" Then ; $pic1 ist immer gefüllt, wenn $pic2 gefüllt ist.
$pic2 = $i
EndIf
EndIf
Next
; Nur ein pic vorhanden, alle sieger resetten
If $pic2 = "" Then
For $i = 1 To UBound($aFiles, 1) -1
If $aFiles[$i][1] = 2 Then
$aFiles[$i][1] = 1
$pic1 = $i
EndIf
Next
; auch nach dem resett nur ein pic vorhanden -> sieger
If UBound(_ArrayFindAll($aFiles, 1, 0, 0, 0, 1, 1)) = 1 Then Gui_final ()
EndIf
; beide teilnehmer vorhanden, match starten
If $pic2 <> "" Then Gui_match ()
WEnd
Func gui_start ()
GUICreate("Barra Sargtlin", 418, 175, 192, 124)
GUICtrlCreateLabel("Linker Rand:", 16, 40, 65, 20)
GUICtrlCreateLabel("Oberer Rand:", 16, 80, 65, 20)
GUICtrlCreateLabel("Breite:", 216, 40, 34, 20)
GUICtrlCreateLabel("Länge:", 216, 80, 37, 20)
Local $lbllinks = GUICtrlCreateInput(120, 100, 40, 40, 20)
Local $lbloben = GUICtrlCreateInput(80, 100, 80, 40, 20)
Local $lblx = GUICtrlCreateInput(275, 288, 40, 40, 20) ; 1100
Local $lbly = GUICtrlCreateInput(200, 288, 80, 40, 20); 800
Local $Button1 = GUICtrlCreateButton("Ok", 224, 128, 75, 25, $WS_GROUP)
Local $Button2 = GUICtrlCreateButton("Abbrechen", 88, 128, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
While True
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
Exit
Case $button1
ExitLoop
EndSwitch
WEnd
GUISetState(@SW_HIDE)
$x = GUICtrlRead($lblx)
$y = GUICtrlRead($lbly)
$oben = GUICtrlRead($lbloben)
$links = GUICtrlRead($lbllinks)
$x_abstand = $x * 0.05; 2* 5 = 10
$x_bild = $x * 0.40; 2* 40 = 80
$x_mitte = $x * 0.10; 1* 10 = 10
$y_abstand = $y * 0.05 ; 4* 5 = 20
$y_text = $y * 0.03 ; 2* 3 = 6
$y_bild = $y * 0.74 ; 1* 74 = 74
EndFunc
Func Gui_final ()
GUICreate("Barra Sargtlin", $x, $y, $links, $oben)
Local $button1 = GUICtrlCreatePic($pfad & $aFiles[$pic1][0], $x_abstand+($x*0.25), 3*$y_abstand+2*$y_text, $x_bild, $y_bild, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlCreateLabel("Sieger !", $x_abstand+$x_bild, $y_abstand, $x_mitte, $y_text)
GUICtrlSetFont(-1, 17)
GUICtrlCreateLabel(StringLeft($aFiles[$pic1][0], StringInStr ($aFiles[$pic1][0], ".", 0, -1)-1), $x_abstand+$x_bild, 2*$y_abstand+$y_text, $x_bild, $y_text)
GUICtrlSetFont(-1, 15)
GUISetState(@SW_SHOW)
While True
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $button1
GUISetState(@SW_HIDE)
Exit
EndSwitch
WEnd
EndFunc
Func Gui_match ()
GUICreate("Barra Sargtlin", $x, $y, $links, $oben)
Local $button1 = GUICtrlCreatePic($pfad & $aFiles[$pic1][0], $x_abstand, 3*$y_abstand+2*$y_text, $x_bild, $y_bild, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
Local $button2 = GUICtrlCreatePic($pfad & $aFiles[$pic2][0], $x_abstand+$x_bild+$x_mitte, 3*$y_abstand+2*$y_text, $x_bild, $y_bild, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlCreateLabel("Runde: " & $round, $x_abstand+$x_bild, $y_abstand, $x_mitte, $y_text)
GUICtrlSetFont(-1, 15)
GUICtrlCreateLabel(StringLeft($aFiles[$pic2][0], StringInStr ($aFiles[$pic2][0], ".", 0, -1)-1), $x_abstand+$x_bild+$x_mitte, 2*$y_abstand+$y_text, $x_bild, $y_text)
GUICtrlSetFont(-1, 15)
GUICtrlCreateLabel(StringLeft($aFiles[$pic1][0], StringInStr ($aFiles[$pic1][0], ".", 0, -1)-1), $x_abstand, 2*$y_abstand+$y_text, $x_bild, $y_text)
GUICtrlSetFont(-1, 15)
GUISetState(@SW_SHOW)
$round += 1
While True
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $button1
$aFiles[$pic1][1] = 2
$aFiles[$pic2][1] = 0
GUISetState(@SW_HIDE)
ExitLoop
Case $button2
$aFiles[$pic2][1] = 2
$aFiles[$pic1][1] = 0
GUISetState(@SW_HIDE)
ExitLoop
EndSwitch
WEnd
EndFunc
/edit: Script aktualisiert.