- Offizieller Beitrag
Hi,
ich habe das Spiel Yahtzee (Kniffel) in Autoit geschrieben.
Link: Yahtzee(Mega)
Wäre nett, wenn ihr es mal anspielt und ggf. Vorschläge unterbreitet.
Vielen Dank im Voraus!
So long,
Mega
P.S.: Es ist eine Zip-Date in der auch der Source-Code enthalten ist.
Source:
Spoiler anzeigen
PHP
; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1 beta
; Author: Thorsten Meger <Th DOT Meger AT gmx DOT de>
;
; Script Function: Yahtzee
;
; ----------------------------------------------------------------------------
#include <GUIConstants.au3>
#include <Array.au3>
#include <file.au3>
#include <string.au3>
#NoTrayIcon
;ToDo
; sound menu preferences
Opt("TrayAutoPause", 0) ; Script will not be paused when clicking the tray icon.
Opt("ExpandVarStrings", 1) ; make macro available
HotKeySet("w", "fixDice1")
HotKeySet("e", "fixDice2")
HotKeySet("a", "fixDice3")
HotKeySet("s", "fixDice4")
HotKeySet("d", "fixDice5")
HotKeySet("{esc}", "end")
HotKeySet("{F1}", "help")
HotKeySet("{F2}", "hide")
HotKeySet("{F3}", "restart")
HotKeySet("{F5}", "undo")
HotKeySet("{F7}", "highScoreGUI")
Global $config_A = IniReadSection(@ScriptDir & "\settings\config.ini", "config")
If @error Then MsgBox(4096, "", "Error occured, probably no language.ini file.")
Global $language_A = IniReadSection($config_A[1][1], IniRead($config_A[16][1], "settings", "DefaultLanguage", "No Language found"))
If @error Then MsgBox(4096, "", "Error occured, probably no DefaultLanguage.ini file.")
Global $languages_A = IniReadSectionNames($config_A[1][1])
If @error Then MsgBox(4096, "", "Error occured, probably no language.ini incl sections file.")
; Central GUI
$GUI = GUICreate("Yahtzee (c) Th.Meger", 737, 574, 50, 50)
GUICtrlCreatePic($config_A[17][1], 0, 0, 737, 574)
GUICtrlSetState(-1, $GUI_DISABLE)
RoundGUI($GUI, 3, 3, 30, 30)
; Menu (restart, Undo, HighScore, Help, Exit)
Global $defaultstatus = $language_A[1][1]
$options = GUICtrlCreateMenu("&" & $language_A[2][1])
$restart = GUICtrlCreateMenuitem($language_A[3][1], $options)
$undo = GUICtrlCreateMenuitem($language_A[4][1], $options)
GUICtrlSetState(-1, $GUI_DISABLE)
$highScore = GUICtrlCreateMenuitem($language_A[5][1], $options)
$exit = GUICtrlCreateMenuitem($language_A[6][1], $options)
$sep = GUICtrlCreateMenuitem("", $options, 3)
;game
$game = GUICtrlCreateMenu("&" & $language_A[60][1])
$fixDice1 = GUICtrlCreateMenuitem($language_A[61][1], $game)
$fixDice2 = GUICtrlCreateMenuitem($language_A[62][1], $game)
$fixDice3 = GUICtrlCreateMenuitem($language_A[63][1], $game)
$fixDice4 = GUICtrlCreateMenuitem($language_A[64][1], $game)
$fixDice5 = GUICtrlCreateMenuitem($language_A[65][1], $game)
$rollDice = GUICtrlCreateMenuitem($language_A[33][1], $game)
$sep1 = GUICtrlCreateMenuitem("", $game, 5)
;View
$view = GUICtrlCreateMenu("&" & $language_A[7][1])
$hide = GUICtrlCreateMenuitem($language_A[8][1], $view)
;Language
$language = GUICtrlCreateMenu("&" & $language_A[9][1])
$languageChoice = GUICtrlCreateMenu($language_A[10][1], $language, 1)
$german = GUICtrlCreateMenuitem($languages_A[2], $languageChoice)
$english = GUICtrlCreateMenuitem($languages_A[1], $languageChoice)
;?
$question = GUICtrlCreateMenu("&" & $language_A[36][1])
$help = GUICtrlCreateMenuitem($language_A[11][1], $question)
$aboutGUI = GUICtrlCreateMenuitem($language_A[12][1], $question)
$statuslabel = GUICtrlCreateLabel($defaultstatus, 20, 520, 700, 20, $SS_SUNKEN)
; Groups
$game_G = GUICtrlCreateGroup($language_A[13][1], 24, 56, 697, 457, -1) ; Game
GUICtrlSetBkColor(-1, $config_A[23][1])
$dices_G = GUICtrlCreateGroup($language_A[14][1], 48, 296, 257, 201) ; Dices
GUICtrlSetBkColor(-1, $config_A[23][1])
$numbers_G = GUICtrlCreateGroup($language_A[15][1], 48, 80, 257, 201) ; Numbers
GUICtrlSetBkColor(-1, $config_A[23][1])
$specials_G = GUICtrlCreateGroup($language_A[16][1], 328, 80, 369, 201) ; Specials
GUICtrlSetBkColor(-1, $config_A[23][1])
$rolls_G = GUICtrlCreateGroup($language_A[17][1], 328, 356, 369, 141) ; Rolls
GUICtrlSetBkColor(-1, $config_A[23][1])
$totalPoints_G = GUICtrlCreateGroup($language_A[18][1], 328, 296, 369, 49) ; Total Points
GUICtrlSetBkColor(-1, $config_A[23][1])
; Dice Images
$dice1_L = GUICtrlCreateLabel("", 93, 325, 73, 73)
GUICtrlSetBkColor($dice1_L, $config_A[19][1])
GUICtrlSetState($dice1_L, $GUI_DISABLE + $GUI_HIDE)
$dice2_L = GUICtrlCreateLabel("", 181, 325, 73, 73)
GUICtrlSetBkColor(-$dice2_L, $config_A[19][1])
GUICtrlSetState($dice2_L, $GUI_DISABLE + $GUI_HIDE)
$dice3_L = GUICtrlCreateLabel("", 61, 413, 73, 73)
GUICtrlSetBkColor($dice3_L, $config_A[19][1])
GUICtrlSetState($dice3_L, $GUI_DISABLE + $GUI_HIDE)
$dice4_L = GUICtrlCreateLabel("", 141, 413, 73, 73)
GUICtrlSetBkColor($dice4_L, $config_A[19][1])
GUICtrlSetState($dice4_L, $GUI_DISABLE + $GUI_HIDE)
$dice5_L = GUICtrlCreateLabel("", 221, 413, 73, 73)
GUICtrlSetBkColor($dice5_L, $config_A[19][1])
GUICtrlSetState($dice5_L, $GUI_DISABLE + $GUI_HIDE)
$dice1_B = GUICtrlCreateButton("", 96, 328, 65, 65, $BS_ICON + $WS_BORDER)
GUICtrlSetImage($dice1_B, $config_A[3][1], -1, 1)
$dice2_B = GUICtrlCreateButton("", 184, 328, 65, 65, $BS_ICON + $WS_BORDER)
GUICtrlSetImage($dice2_B, $config_A[4][1], -1, 1)
$dice3_B = GUICtrlCreateButton("", 64, 416, 65, 65, $BS_ICON + $WS_BORDER)
GUICtrlSetImage($dice3_B, $config_A[5][1], -1, 1)
$dice4_B = GUICtrlCreateButton("", 144, 416, 65, 65, $BS_ICON + $WS_BORDER)
GUICtrlSetImage($dice4_B, $config_A[6][1], -1, 1)
$dice5_B = GUICtrlCreateButton("", 224, 416, 65, 65, $BS_ICON + $WS_BORDER)
GUICtrlSetImage($dice5_B, $config_A[7][1], -1, 1)
; Identification Labels
$ones_L = GUICtrlCreateLabel($language_A[19][1], 64, 104, 115, 17, $SS_SUNKEN)
$twos_L = GUICtrlCreateLabel($language_A[20][1], 64, 128, 115, 17, $SS_SUNKEN)
$threes_L = GUICtrlCreateLabel($language_A[21][1], 64, 152, 115, 17, $SS_SUNKEN)
$fours_L = GUICtrlCreateLabel($language_A[22][1], 64, 176, 115, 17, $SS_SUNKEN)
$fives_L = GUICtrlCreateLabel($language_A[23][1], 64, 200, 115, 17, $SS_SUNKEN)
$sixes_L = GUICtrlCreateLabel($language_A[24][1], 64, 224, 115, 17, $SS_SUNKEN)
$bonus_L = GUICtrlCreateLabel($language_A[25][1], 64, 248, 115, 17, $SS_SUNKEN)
; Points Labels _PL
$ones_PL = GUICtrlCreateLabel("0", 184, 104, 30, 17, $SS_SUNKEN + $SS_CENTER) ; Ones
$twos_PL = GUICtrlCreateLabel("0", 184, 128, 30, 17, $SS_SUNKEN + $SS_CENTER) ; Twos
$threes_PL = GUICtrlCreateLabel("0", 184, 152, 30, 17, $SS_SUNKEN + $SS_CENTER) ; Threes
$fours_PL = GUICtrlCreateLabel("0", 184, 176, 30, 17, $SS_SUNKEN + $SS_CENTER) ; Fours
$fives_PL = GUICtrlCreateLabel("0", 184, 200, 30, 17, $SS_SUNKEN + $SS_CENTER) ; Fives
$sixes_PL = GUICtrlCreateLabel("0", 184, 224, 30, 17, $SS_SUNKEN + $SS_CENTER) ; Sixes
$bonus_PL = GUICtrlCreateLabel("63", 184, 248, 30, 17, $SS_SUNKEN + $SS_CENTER) ; Bonus
$bonusPoints_PL = GUICtrlCreateLabel($language_A[37][1], 218, 248, 75, 17, $SS_SUNKEN + $SS_CENTER) ; Points
; Points Buttons _B
$ones_B = GUICtrlCreateButton("Ok", 218, 104, 75, 17)
$twos_B = GUICtrlCreateButton("Ok", 218, 128, 75, 17)
$threes_B = GUICtrlCreateButton("Ok", 218, 152, 75, 17)
$fours_B = GUICtrlCreateButton("Ok", 218, 176, 75, 17)
$fives_B = GUICtrlCreateButton("Ok", 218, 200, 75, 17)
$sixes_B = GUICtrlCreateButton("Ok", 218, 224, 75, 17)
; Identification Labels
$threeOK_L = GUICtrlCreateLabel($language_A[26][1], 344, 104, 150, 17, $SS_SUNKEN)
$fourOK_L = GUICtrlCreateLabel($language_A[27][1], 344, 128, 150, 17, $SS_SUNKEN)
$fullHouse_L = GUICtrlCreateLabel($language_A[28][1], 344, 152, 150, 17, $SS_SUNKEN)
$shortRun_L = GUICtrlCreateLabel($language_A[29][1], 344, 176, 150, 17, $SS_SUNKEN)
$longRun_L = GUICtrlCreateLabel($language_A[30][1], 344, 200, 150, 17, $SS_SUNKEN)
$yahtzee_L = GUICtrlCreateLabel($language_A[31][1], 344, 224, 150, 17, $SS_SUNKEN)
$chance_L = GUICtrlCreateLabel($language_A[32][1], 344, 248, 150, 17, $SS_SUNKEN)
; Points Labels_PL
$threeOK_PL = GUICtrlCreateLabel("0", 520, 104, 50, 17, $SS_SUNKEN + $SS_CENTER) ; Three OK
$fourOK_PL = GUICtrlCreateLabel("0", 520, 128, 50, 17, $SS_SUNKEN + $SS_CENTER) ; Four OK
$fullhouse_PL = GUICtrlCreateLabel("0", 520, 152, 50, 17, $SS_SUNKEN + $SS_CENTER) ; Full house
$shortRun_PL = GUICtrlCreateLabel("0", 520, 176, 50, 17, $SS_SUNKEN + $SS_CENTER) ; Short run
$longRun_PL = GUICtrlCreateLabel("0", 520, 200, 50, 17, $SS_SUNKEN + $SS_CENTER) ; Long run
$yahtzee_PL = GUICtrlCreateLabel("0", 520, 224, 50, 17, $SS_SUNKEN + $SS_CENTER) ; yahtzee (Mega)
$chance_PL = GUICtrlCreateLabel("0", 520, 248, 50, 17, $SS_SUNKEN + $SS_CENTER) ; Chance
; Points Buttons_B
$threeOK_B = GUICtrlCreateButton("Ok", 608, 104, 75, 17) ; Three OK
$fourOK_B = GUICtrlCreateButton("Ok", 608, 128, 75, 17) ; Four OK
$fullHouse_B = GUICtrlCreateButton("Ok", 608, 152, 75, 17) ; Full house
$shortRun_B = GUICtrlCreateButton("Ok", 608, 176, 75, 17) ; Short run
$longRun_B = GUICtrlCreateButton("Ok", 608, 200, 75, 17) ; Long run
$yahtzee_B = GUICtrlCreateButton("Ok", 608, 224, 75, 17) ; Yahtzee (Mega)
$chance_B = GUICtrlCreateButton("Ok", 608, 248, 75, 17) ; Chance
; Rolls & Points
$roll_B = GUICtrlCreateButton($language_A[33][1], 344, 446, 337, 43, $BS_ICON) ; Roll
$roll_B_Icon = GUICtrlSetImage($roll_B, $config_A[24][1], -1, 0)
$rollsLeft_DL = GUICtrlCreateLabel($language_A[34][1], 344, 400, 230, 25, $SS_SUNKEN)
$rollsCount_L = GUICtrlCreateLabel("2", 600, 400, 81, 25, $SS_SUNKEN + $SS_CENTER) ; Rolls left count
$points_DL = GUICtrlCreateLabel($language_A[35][1], 344, 315, 230, 25, $SS_SUNKEN)
$point_PL = GUICtrlCreateLabel("0", 600, 315, 81, 25, $SS_SUNKEN + $SS_CENTER) ; Total Points
GUICtrlSetState($roll_B, $GUI_FOCUS)
;SetFont and Size
GUICtrlSetFont($rollsLeft_DL, 14, 400, "", $config_A[22][1])
GUICtrlSetColor($rollsLeft_DL, $config_A[21][1])
GUICtrlSetFont($rollsCount_L, 14, 200, "", $config_A[22][1])
GUICtrlSetColor($rollsCount_L, $config_A[21][1])
GUICtrlSetFont($points_DL, 14, 400, "", $config_A[22][1])
GUICtrlSetColor($points_DL, $config_A[21][1])
GUICtrlSetFont($point_PL, 14, 400, "", $config_A[22][1])
GUICtrlSetColor($point_PL, $config_A[21][1])
GUICtrlSetFont($roll_B, 14, 400, "", $config_A[22][1])
GUICtrlSetFont($statuslabel, 12, 400, "", $config_A[22][1])
GUICtrlSetColor($statuslabel, $config_A[21][1])
$about = TrayCreateItem($language_A[12][1])
TraySetState()
TraySetToolTip("Yahtzee written by Th.Meger")
; GUI HighScore
Global $highScore_A[12]
Global $listViewItems[13]
Dim $defaultName = "Player1"
; GUI
$GUI_HighScore = GUICreate(" HighScore", 502, 283, 190, 158, $WS_EX_TRANSPARENT)
GUICtrlCreatePic($config_A[18][1], 0, 0, 502, 283)
GUICtrlSetState(-1, $GUI_DISABLE)
RoundGUI($GUI_HighScore, 5, 5, 20, 20)
;DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $GUI_HighScore, "int", 1000, "long", 0x00080000);)0x00040010
; ListView
$highScoreList = GUICtrlCreateListView($language_A[38][1], 240, 16, 250, 206)
; Group
$menu_G = GUICtrlCreateGroup("Menu", 8, 48, 209, 177)
; Label
$pointInHighScore_L = GUICtrlCreateLabel($language_A[39][1] & " " & 0 & " " & $language_A[35][1], 16, 72, 187, 17)
$Headline_L = GUICtrlCreateLabel("HighScore of Yahtzee(Mega)", 8, 15, 211, 20)
; Input
$name_I = GUICtrlCreateInput(IniRead($config_A[2][1], "Name", "Name", "No Name found!"), _
16, 104, 185, 21, -1, $WS_EX_CLIENTEDGE)
; Button
$save_B = GUICtrlCreateButton($language_A[40][1], 16, 144, 187, 25, $SS_SUNKEN)
$exit_B = GUICtrlCreateButton($language_A[41][1], 16, 184, 187, 25, $SS_SUNKEN)
;States and Fonts
GUICtrlSetState($name_I, $GUI_FOCUS)
GUICtrlSetState($save_B, $GUI_DEFBUTTON)
GUICtrlSetState($save_B, $GUI_DISABLE)
GUICtrlSetState($name_I, $GUI_DISABLE)
GUICtrlSetState($exit_B, $GUI_FOCUS)
GUICtrlSetFont($Headline_L, 12, 550, 4, "Arial")
GUISetState(@SW_HIDE, $GUI_HighScore)
; End GUIHighScore
$aboutinbox = GUICreate("About", 215, 150, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU))
GUICtrlCreateIcon(@AutoItExe, -1, 11, 11)
GUICtrlCreateLabel("Yahtzee(Mega)", 59, 11, 135, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Arial"); bold
GUICtrlCreateLabel("(c) 2006" & @CRLF & @CRLF & "Created by: Thorsten Meger", 59, 30, 135, 40)
$email_L = GUICtrlCreateLabel("Th.Meger@gmx.de", 59, 70, 135, 15)
GUICtrlSetFont($email_L, 8.5, -1, 4); underlined
GUICtrlSetColor($email_L, 0x0000ff)
GUICtrlSetCursor($email_L, 0)
$www_L = GUICtrlCreateLabel("www.autoitscript.com", 59, 85, 140, 15)
GUICtrlSetFont($www_L, 8.5, -1, 4); underlined
GUICtrlSetColor($www_L, 0x0000ff)
GUICtrlSetCursor($www_L, 0)
$ok_B = GUICtrlCreateButton("OK", 65, 115, 75, 23, BitOR($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON))
GUICtrlSetState(-1, $GUI_FOCUS)
GUISetState(@SW_HIDE, $aboutinbox)
; Variables
Dim $dice1 = 0, $dice2 = 0, $dice3 = 0, $dice4 = 0, $dice5 = 0, $eyes = 0
Dim $shortRun = 0, $longRun = 0, $fullHouse = 0, $checkArray = 0
Dim $bonus = 35
Dim $finished = False
;Status fields
Global $ones_S = False, $twos_S = False, $threes_S = False, $fours_S = False, $fives_S = False, $sixes_S = False
Global $threeOK_S = False, $fourOK_S = False, $fullHouse_S = False, $shortRun_S = False, $longRun_S = False, $yahtzee_S = False, $chance_S = False
Global $dice1_S = 0, $dice2_S = 0, $dice3_S = 0, $dice4_S = 0, $dice5_S = 0
Global $bonus_S = False
Global $lastFixed = "" ; for undo
Global $CheatCounter = 0
;Possibilities
$shortRun = StringSplit("66543,65543,65443,65433,65431,64321,55432,54432,54332,54322,44321,43321,43221,43211", ",")
$longRun = _ArrayCreate("65432", "54321")
$fullHouse = StringSplit("66655,66644,66633,66622,66611,66555,55544,55533,55522,55511,66444,55444,44433,44422,44411,66333,55333,44333,33322,33311,66222,55222,44222,33222,22211,66111,55111,44111,33111,22111", ",")
$yahtzee = _ArrayCreate("66666", "55555", "44444", "33333", "22222", "11111")
; Arrays
Global $diceArray = _ArrayCreate($dice1, $dice2, $dice3, $dice4, $dice5)
Global $point_A = _ArrayCreate($ones_PL, $twos_PL, $threes_PL, $fours_PL, $fives_PL, $sixes_PL, $threeOK_PL, $fourOK_PL, _
$fullhouse_PL, $shortRun_PL, $longRun_PL, $yahtzee_PL, $chance_PL)
Global $status_A_S = _ArrayCreate($ones_S, $twos_S, $threes_S, $fours_S, $fives_S, $sixes_S, $threeOK_S, _
$fourOK_S, $fullHouse_S, $shortRun_S, $longRun_S, $yahtzee_S, $chance_S)
Global $diceArray_S = _ArrayCreate($dice1_S, $dice2_S, $dice3_S, $dice4_S, $dice5_S)
Global $buttonArray = _ArrayCreate($ones_B, $twos_B, $threes_B, $fours_B, $fives_B, $sixes_B, $threeOK_B, $fourOK_B, _
$fullHouse_B, $shortRun_B, $longRun_B, $yahtzee_B, $chance_B)
init()
start()
Sleep(800)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $GUI, "int", 1000, "long", 0x00080000)
GUISetState(@SW_SHOW, $GUI)
; Pseudo-Menu
Func start()
GUICtrlSetState($roll_B, $GUI_FOCUS)
deleteNonFixedValues()
dicing()
showDice($dice1_B, $diceArray[0])
showDice($dice2_B, $diceArray[1])
showDice($dice3_B, $diceArray[2])
showDice($dice4_B, $diceArray[3])
showDice($dice5_B, $diceArray[4])
prepareDices()
checkSpecials(specials())
pointing()
checkIfFinished()
EndFunc ;==>start
Func prepareDices()
Local $a = $diceArray
_ArraySort($a, 1, 0)
$checkArray = StringReplace(_ArrayToString($a, ","), ",", "", 0, 0)
EndFunc ;==>prepareDices
Func countPoints($Nr)
Local $result = 0
For $i = 0 To UBound($diceArray) - 1
If $Nr = $diceArray[$i] Then
$result += $Nr
EndIf
Next
Return $result
EndFunc ;==>countPoints
Func dicing()
For $i = 0 To UBound($diceArray_S) - 1
If $diceArray_S[$i] = 0 Then $diceArray[$i] = Random(1, 6, 1)
Next
EndFunc ;==>dicing
Func initialState()
For $i = 0 To UBound($diceArray_S) - 1
$diceArray_S[$i] = 0
Next
GUICtrlSetStyle($dice1_B, $BS_ICON + $WS_BORDER, "")
GUICtrlSetStyle($dice2_B, $BS_ICON + $WS_BORDER, "")
GUICtrlSetStyle($dice3_B, $BS_ICON + $WS_BORDER, "")
GUICtrlSetStyle($dice4_B, $BS_ICON + $WS_BORDER, "")
GUICtrlSetStyle($dice5_B, $BS_ICON + $WS_BORDER, "")
GUICtrlSetState($dice1_L, $GUI_DISABLE + $GUI_HIDE)
GUICtrlSetState($dice2_L, $GUI_DISABLE + $GUI_HIDE)
GUICtrlSetState($dice3_L, $GUI_DISABLE + $GUI_HIDE)
GUICtrlSetState($dice4_L, $GUI_DISABLE + $GUI_HIDE)
GUICtrlSetState($dice5_L, $GUI_DISABLE + $GUI_HIDE)
GUICtrlSetState($roll_B, $GUI_ENABLE + $GUI_FOCUS)
GUICtrlSetState($rollDice, $GUI_ENABLE)
ControlSetText("", "", $rollsCount_L, "2")
EndFunc ;==>initialState
Func rollsMinus()
GUICtrlSetData($rollsCount_L, ControlGetText("", "", $rollsCount_L) - 1)
If ControlGetText("", "", $rollsCount_L) = 0 Then
GUICtrlSetState($roll_B, $GUI_DISABLE)
GUICtrlSetState($rollDice, $GUI_DISABLE)
EndIf
EndFunc ;==>rollsMinus
Func showDice($controlID, $diceNr)
Select
Case $diceNr = 1
GUICtrlSetImage($controlID, $config_A[3][1], -1, 1)
Case $diceNr = 2
GUICtrlSetImage($controlID, $config_A[4][1], -1, 1)
Case $diceNr = 3
GUICtrlSetImage($controlID, $config_A[5][1], -1, 1)
Case $diceNr = 4
GUICtrlSetImage($controlID, $config_A[6][1], -1, 1)
Case $diceNr = 5
GUICtrlSetImage($controlID, $config_A[7][1], -1, 1)
Case $diceNr = 6
GUICtrlSetImage($controlID, $config_A[8][1], -1, 1)
EndSelect
EndFunc ;==>showDice
Func checkSpecials($special)
$eyes = $diceArray[0] + $diceArray[1] + $diceArray[2] + $diceArray[3] + $diceArray[4]
Select
Case $special = 3
If $status_A_S[6] <> True Then GUICtrlSetData($point_A[6], $eyes)
Case $special = 7
If $status_A_S[6] <> True Then GUICtrlSetData($point_A[6], $eyes)
If $status_A_S[7] <> True Then GUICtrlSetData($point_A[7], $eyes)
Case $special = 28
If $status_A_S[8] <> True Then GUICtrlSetData($point_A[8], 25)
If $status_A_S[6] <> True Then GUICtrlSetData($point_A[6], $eyes)
Case $special = 57
If $status_A_S[11] <> True Then GUICtrlSetData($point_A[11], 50)
If $status_A_S[6] <> True Then GUICtrlSetData($point_A[6], $eyes)
If $status_A_S[7] <> True Then GUICtrlSetData($point_A[7], $eyes)
If IniRead($config_A[16][1], "settings", "sound", "No sound setting found") = "On" Then SoundPlay($config_A[11][1])
SplashImageOn("", $config_A[13][1], @DesktopWidth, @DesktopHeight, 0, 0, 1)
Sleep(1500)
SplashOff()
Case $special = 30
If $status_A_S[9] <> True Then GUICtrlSetData($point_A[9], 30)
Case $special = 70
If $status_A_S[9] <> True Then GUICtrlSetData($point_A[9], 30)
If $status_A_S[10] <> True Then GUICtrlSetData($point_A[10], 40)
EndSelect
EndFunc ;==>checkSpecials
; Return Value
; Long run = 70 (40 + 30)
; Short run = 30
; Yahtzee = 57 ( 50 + 4 + 3)
; FullHouse = 28 (25 + 3)
; 3ofAKind = 3
; 3ofAKind = 7
Func specials()
;Full House
For $i = 0 To UBound($fullHouse) - 1
If $fullHouse[$i] = $checkArray Then
Return 28
EndIf
Next
; Yahtzee
For $i = 0 To UBound($yahtzee) - 1
If $yahtzee[$i] = $checkArray Then
Return 57
EndIf
Next
;Four of a kind
If StringInStr($checkArray, "6666") Or StringInStr($checkArray, "5555") Or StringInStr($checkArray, "4444") Or _
StringInStr($checkArray, "3333") Or StringInStr($checkArray, "2222") Or StringInStr($checkArray, "1111") Then
Return 7
EndIf
;Three of a kind
If StringInStr($checkArray, "666") Or StringInStr($checkArray, "555") Or StringInStr($checkArray, "444") Or _
StringInStr($checkArray, "333") Or StringInStr($checkArray, "222") Or StringInStr($checkArray, "111") Then
Return 3
EndIf
;Long run
For $i = 0 To UBound($longRun) - 1
If $longRun[$i] = $checkArray Then
Return 70
EndIf
Next
;Short run
For $i = 0 To UBound($shortRun) - 1
If $shortRun[$i] = $checkArray Then
Return 30
EndIf
Next
EndFunc ;==>specials
Func totalPoints()
Local $pointCounter = 0
For $i = 0 To UBound($point_A) - 1
If $status_A_S[$i] = True Then
$pointCounter += ControlGetText("", "", $point_A[$i])
EndIf
Next
If $status_A_S[0] = True And $status_A_S[1] = True And $status_A_S[2] = True And $status_A_S[3] = True And $status_A_S[4] = True And $status_A_S[5] = True And _
(ControlGetText("", "", $point_A[0]) + ControlGetText("", "", $point_A[1]) _
+ ControlGetText("", "", $point_A[2]) + ControlGetText("", "", $point_A[3]) + ControlGetText("", "", $point_A[4]) _
+ ControlGetText("", "", $point_A[5])) >= 63 Then
GUICtrlSetData($point_PL, $pointCounter + $bonus) ; Bonus is set above to 35
Else
GUICtrlSetData($point_PL, $pointCounter)
EndIf
EndFunc ;==>totalPoints
Func deleteNonFixedValues()
If $status_A_S[6] = False Then GUICtrlSetData($point_A[6], 0)
If $status_A_S[7] = False Then GUICtrlSetData($point_A[7], 0)
If $status_A_S[8] = False Then GUICtrlSetData($point_A[8], 0)
If $status_A_S[9] = False Then GUICtrlSetData($point_A[9], 0)
If $status_A_S[10] = False Then GUICtrlSetData($point_A[10], 0)
If $status_A_S[11] = False Then GUICtrlSetData($point_A[11], 0)
EndFunc ;==>deleteNonFixedValues
Func end()
setHotKeys(0)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $GUI, "int", 1500, "long", 0x00090000)
Exit (0)
EndFunc ;==>end
Func checkIfFinished()
For $i = 0 To UBound($status_A_S) - 1
If $status_A_S[$i] <> True Then ExitLoop
Next
If $i = UBound($status_A_S) Then
SplashImageOn("", $config_A[9][1], @DesktopWidth, @DesktopHeight, -1, -1, 1)
Sleep(1000)
SplashOff()
setHotKeys()
GUICtrlSetState($roll_B, $GUI_DISABLE)
IniWrite($config_A[2][1], "points", "points", ControlGetText("", "", $point_PL))
$finished = True
highScoreGUI()
EndIf
EndFunc ;==>checkIfFinished
Func pointing()
Local $minusBonus = 0
For $i = 0 To 5
If $status_A_S[$i] = False Then
GUICtrlSetData($point_A[$i], countPoints($i + 1))
Else
$minusBonus += ControlGetText("", "", $point_A[$i])
EndIf
Next
If $status_A_S[12] = False Then GUICtrlSetData($point_A[12], $eyes)
GUICtrlSetData($bonus_PL, 63 - $minusBonus)
If $minusBonus >= 63 Then
GUICtrlSetData($bonus_PL, 63 + ($minusBonus - 63))
GUICtrlSetBkColor($bonusPoints_PL, $config_A[20][1])
GUICtrlSetData($point_PL, ControlGetText("", "", $point_PL) + $bonus)
EndIf
totalPoints()
EndFunc ;==>pointing
While 1
$msg = GUIGetMsg(1)
$msgTray = TrayGetMsg()
Select
Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $GUI
end()
Case $msg[0] = $roll_B And $msg[1] = $GUI
deleteNonFixedValues()
start()
rollsMinus()
setFocus()
GUICtrlSetData($statuslabel, $language_A[42][1])
Case $msg[0] = $ones_B And $msg[1] = $GUI; ones
If $status_A_S[0] = False Then
GUICtrlSetData($point_A[0], countPoints(1))
GUICtrlSetBkColor($ones_PL, $config_A[20][1])
$status_A_S[0] = True
EndIf
initialState()
start()
GUICtrlSetState($ones_B, $GUI_DISABLE)
GUICtrlSetData($statuslabel, $language_A[43][1])
Case $msg[0] = $twos_B And $msg[1] = $GUI; twos
If $status_A_S[1] = False Then
GUICtrlSetData($point_A[1], countPoints(2))
GUICtrlSetBkColor($twos_PL, $config_A[20][1])
$status_A_S[1] = True
EndIf
initialState()
start()
GUICtrlSetState($twos_B, $GUI_DISABLE)
GUICtrlSetData($statuslabel, $language_A[44][1])
Case $msg[0] = $threes_B And $msg[1] = $GUI; threes
If $status_A_S[2] = False Then
GUICtrlSetData($point_A[2], countPoints(3))
GUICtrlSetBkColor($threes_PL, $config_A[20][1])
$status_A_S[2] = True
EndIf
initialState()
start()
GUICtrlSetState($threes_B, $GUI_DISABLE)
GUICtrlSetData($statuslabel, $language_A[45][1])
Case $msg[0] = $fours_B And $msg[1] = $GUI; fours
If $status_A_S[3] = False Then
GUICtrlSetData($point_A[3], countPoints(4))
GUICtrlSetBkColor($fours_PL, $config_A[20][1])
$status_A_S[3] = True
EndIf
initialState()
start()
GUICtrlSetState($fours_B, $GUI_DISABLE)
GUICtrlSetData($statuslabel, $language_A[46][1])
Case $msg[0] = $fives_B And $msg[1] = $GUI; fives
If $status_A_S[4] = False Then
GUICtrlSetData($point_A[4], countPoints(5))
GUICtrlSetBkColor($fives_PL, $config_A[20][1])
$status_A_S[4] = True
EndIf
initialState()
start()
GUICtrlSetState($fives_B, $GUI_DISABLE)
GUICtrlSetData($statuslabel, $language_A[47][1])
Case $msg[0] = $sixes_B And $msg[1] = $GUI; sixes
If $status_A_S[5] = False Then
GUICtrlSetData($point_A[5], countPoints(6))
GUICtrlSetBkColor($sixes_PL, $config_A[20][1])
$status_A_S[5] = True
EndIf
initialState()
start()
GUICtrlSetState($sixes_B, $GUI_DISABLE)
GUICtrlSetData($statuslabel, $language_A[48][1])
Case $msg[0] = $chance_B And $msg[1] = $GUI; Chance
If $status_A_S[12] = False Then
GUICtrlSetData($point_A[12], $eyes)
GUICtrlSetBkColor($chance_PL, $config_A[20][1])
$status_A_S[12] = True
EndIf
initialState()
start()
GUICtrlSetState($chance_B, $GUI_DISABLE)
GUICtrlSetData($statuslabel, $language_A[49][1])
Case $msg[0] = $threeOK_B And $msg[1] = $GUI; $threeOK
If $status_A_S[6] = False Then
If specials() = 3 Or specials() = 7 Then
GUICtrlSetData($point_A[6], $eyes)
GUICtrlSetBkColor($threeOK_PL, $config_A[20][1])
$status_A_S[6] = True
EndIf
GUICtrlSetBkColor($threeOK_PL, $config_A[20][1])
$status_A_S[6] = True
$lastFixed = "$threeOK_S"
EndIf
initialState()
start()
GUICtrlSetState($threeOK_B, $GUI_DISABLE)
GUICtrlSetData($statuslabel, $language_A[50][1])
Case $msg[0] = $fourOK_B And $msg[1] = $GUI; $fourOK
If $status_A_S[7] = False Then
If specials() = 7 Then
GUICtrlSetData($point_A[7], $eyes)
GUICtrlSetBkColor($fourOK_PL, $config_A[20][1])
$status_A_S[7] = True
EndIf
GUICtrlSetBkColor($fourOK_PL, $config_A[20][1])
$status_A_S[7] = True
$lastFixed = "$fourOK"
EndIf
initialState()
start()
GUICtrlSetState($fourOK_B, $GUI_DISABLE)
GUICtrlSetData($statuslabel, $language_A[51][1])
Case $msg[0] = $fullHouse_B And $msg[1] = $GUI; $fullHouse
If $status_A_S[8] = False Then
If specials() = 28 Then
GUICtrlSetData($point_A[8], 25)
GUICtrlSetBkColor($fullhouse_PL, $config_A[20][1])
$status_A_S[8] = True
EndIf
GUICtrlSetBkColor($fullhouse_PL, $config_A[20][1])
$status_A_S[8] = True
$lastFixed = "$fullHouse"
EndIf
initialState()
start()
GUICtrlSetState($fullHouse_B, $GUI_DISABLE)
GUICtrlSetData($statuslabel, $language_A[52][1])
Case $msg[0] = $shortRun_B And $msg[1] = $GUI; $shortRun
If $status_A_S[9] = False Then
If specials() = 30 Then
GUICtrlSetData($point_A[9], 30)
GUICtrlSetBkColor($shortRun_PL, $config_A[20][1])
$status_A_S[9] = True
EndIf
GUICtrlSetBkColor($shortRun_PL, $config_A[20][1])
$status_A_S[9] = True
$lastFixed = "$shortRun_S"
EndIf
initialState()
start()
GUICtrlSetState($shortRun_B, $GUI_DISABLE)
GUICtrlSetData($statuslabel, $language_A[53][1])
Case $msg[0] = $longRun_B And $msg[1] = $GUI; $longRun
If $status_A_S[10] = False Then
If specials() = 70 Then
GUICtrlSetData($point_A[10], 40)
GUICtrlSetBkColor($longRun_PL, $config_A[20][1])
$status_A_S[10] = True
EndIf
GUICtrlSetBkColor($longRun_PL, $config_A[20][1])
$status_A_S[10] = True
$lastFixed = "$longRun_S"
EndIf
initialState()
start()
GUICtrlSetState($longRun_B, $GUI_DISABLE)
GUICtrlSetData($statuslabel, $language_A[54][1])
Case $msg[0] = $yahtzee_B And $msg[1] = $GUI; $yahtzee
If $status_A_S[11] = False Then
If specials() = 57 Then
GUICtrlSetData($point_A[11], 50)
GUICtrlSetBkColor($yahtzee_PL, $config_A[20][1])
$status_A_S[11] = True
EndIf
GUICtrlSetBkColor($yahtzee_PL, $config_A[20][1])
$status_A_S[11] = True
$lastFixed = "$yahtzee_S"
EndIf
initialState()
start()
GUICtrlSetState($yahtzee_B, $GUI_DISABLE)
GUICtrlSetData($statuslabel, $language_A[55][1])
Case $msg[0] = $fixDice1 Or $msg[0] = $dice1_B And $msg[1] = $GUI
fixDice1()
Case ($msg[0] = $fixDice2 Or $msg[0] = $dice2_B) And $msg[1] = $GUI
fixDice2()
Case ($msg[0] = $fixDice3 Or $msg[0] = $dice3_B) And $msg[1] = $GUI
fixDice3()
Case ($msg[0] = $fixDice4 Or $msg[0] = $dice4_B) And $msg[1] = $GUI
fixDice4()
Case ($msg[0] = $fixDice5 Or $msg[0] = $dice5_B) And $msg[1] = $GUI
fixDice5()
Case $msg[0] = $rollDice And $msg[1] = $GUI
deleteNonFixedValues()
start()
rollsMinus()
setFocus()
GUICtrlSetData($statuslabel, $language_A[42][1])
Case $msg[0] = $exit And $msg[1] = $GUI
end()
Case $msg[0] = $undo And $msg[1] = $GUI
undo()
Case $msg[0] = $help And $msg[1] = $GUI
help()
Case $msg[0] = $restart And $msg[1] = $GUI
restart()
Case $msg[0] = $hide And $msg[1] = $GUI
hide()
Case $msg[0] = $german And $msg[1] = $GUI
setLanguage(1)
Case $msg[0] = $english And $msg[1] = $GUI
setLanguage(0)
; TrayMenu
Case $msg[0] = $aboutGUI
GUICtrlSetData($statuslabel, $language_A[57][1])
GUISetState(@SW_SHOW, $aboutinbox)
; HighScore GUI
Case $msg[0] = $highScore And $msg[1] = $GUI
GUICtrlSetData($statuslabel, $language_A[58][1])
setHotKeys()
highScoreGUI()
Case $msg[0] = $exit_B And $msg[1] = $GUI_HighScore
GUISetState(@SW_HIDE, $GUI_HighScore)
setHotKeys(0)
IniDelete($config_A[2][1], "points")
Case $msg[0] = $save_B And $msg[1] = $GUI_HighScore
save()
Case $msg[0] = $ok_B And $msg[1] = $aboutinbox
GUISetState(@SW_HIDE, $aboutinbox)
Case $msgTray = $about
GUISetState(@SW_SHOW, $aboutinbox)
EndSelect
If WinActive("Yahtzee (c) Th.Meger") = 0 Then
setHotKeys()
Else
setHotKeys(0)
EndIf
WEnd
Func fixDice1()
If $diceArray_S[0] <> 1 Then
GUICtrlSetStyle($dice1_B, $BS_ICON, $WS_EX_STATICEDGE)
GUICtrlSetState($dice1_L, $GUI_SHOW)
$diceArray_S[0] = 1
Else
GUICtrlSetStyle($dice1_B, $BS_ICON + $WS_BORDER, "")
GUICtrlSetState($dice1_L, $GUI_DISABLE + $GUI_HIDE)
$diceArray_S[0] = 0
EndIf
EndFunc ;==>fixDice1
Func fixDice2()
If $diceArray_S[1] <> 1 Then
GUICtrlSetStyle($dice2_B, $BS_ICON, $WS_EX_STATICEDGE)
GUICtrlSetState($dice2_L, $GUI_SHOW)
$diceArray_S[1] = 1
Else
GUICtrlSetStyle($dice2_B, $BS_ICON + $WS_BORDER, "")
GUICtrlSetState($dice2_L, $GUI_DISABLE + $GUI_HIDE)
$diceArray_S[1] = 0
EndIf
EndFunc ;==>fixDice2
Func fixDice3()
If $diceArray_S[2] <> 1 Then
GUICtrlSetStyle($dice3_B, $BS_ICON, $WS_EX_STATICEDGE)
GUICtrlSetState($dice3_L, $GUI_SHOW)
$diceArray_S[2] = 1
Else
GUICtrlSetStyle($dice3_B, $BS_ICON + $WS_BORDER, "")
GUICtrlSetState($dice3_L, $GUI_DISABLE + $GUI_HIDE)
$diceArray_S[2] = 0
EndIf
EndFunc ;==>fixDice3
Func fixDice4()
If $diceArray_S[3] <> 1 Then
GUICtrlSetStyle($dice4_B, $BS_ICON, $WS_EX_STATICEDGE)
GUICtrlSetState($dice4_L, $GUI_SHOW)
$diceArray_S[3] = 1
Else
GUICtrlSetStyle($dice4_B, $BS_ICON + $WS_BORDER, "")
GUICtrlSetState($dice4_L, $GUI_DISABLE + $GUI_HIDE)
$diceArray_S[3] = 0
EndIf
EndFunc ;==>fixDice4
Func fixDice5()
If $diceArray_S[4] <> 1 Then
GUICtrlSetStyle($dice5_B, $BS_ICON, $WS_EX_STATICEDGE)
GUICtrlSetState($dice5_L, $GUI_SHOW)
$diceArray_S[4] = 1
Else
GUICtrlSetStyle($dice5_B, $BS_ICON + $WS_BORDER, "")
GUICtrlSetState($dice5_L, $GUI_DISABLE + $GUI_HIDE)
$diceArray_S[4] = 0
EndIf
EndFunc ;==>fixDice5
Func undo()
; Optional mit Undo oder ohne Undo
MsgBox(64, "Info", "Status open!")
; Merken: Was wurde als letztes fixiert?
; Wie waren die Würfel zu dem Zeitpunkt?
; Undo geht nur wenn RollsLeft noch 2 ist.
; TotalPoints zurücksetzen
;
EndFunc ;==>undo
Func help()
Opt("ExpandVarStrings", 1)
Run(@ComSpec & " /c " & '"' & $config_A[10][1] & '"', "", @SW_HIDE)
EndFunc ;==>help
Func restart()
$CheatCounter += 1
If $CheatCounter >= 3 Then
GUICtrlSetData($statuslabel, $language_A[59][1])
Else
GUICtrlSetData($statuslabel, $language_A[56][1])
setHotKeys(0)
$finished = False
GUICtrlSetState($highScore, $GUI_ENABLE)
For $i = 0 To UBound($point_A) - 1
ControlSetText("", "", $point_A[$i], 0)
GUICtrlSetBkColor($point_A[$i], 0xEFEBDE)
Next
For $i = 0 To UBound($status_A_S) - 1
$status_A_S[$i] = False
Next
For $i = 0 To UBound($buttonArray) - 1
GUICtrlSetState($buttonArray[$i], $GUI_ENABLE)
Next
GUICtrlSetState($roll_B, $GUI_FOCUS)
GUICtrlSetBkColor($bonusPoints_PL, 0xEFEBDE)
initialState()
start()
EndIf
EndFunc ;==>restart
; Only for the main window!
Func hide()
If WinActive("Yahtzee (c) Th.Meger") = 1 Then
WinSetState("Yahtzee (c) Th.Meger", "", @SW_HIDE)
Opt("TrayIconHide", 1)
Else
WinSetState("Yahtzee (c) Th.Meger", "", @SW_SHOW)
Opt("TrayIconHide", 0)
EndIf
EndFunc ;==>hide
Func init()
SplashImageOn("", $config_A[15][1], @DesktopWidth, @DesktopHeight, 0, 0, 1)
Sleep(2000)
SplashOff()
EndFunc ;==>init
Func setHotKeys($state = 1)
If $state = 1 Then
HotKeySet("w")
HotKeySet("e")
HotKeySet("a")
HotKeySet("s")
HotKeySet("d")
HotKeySet("{F1}", "help")
HotKeySet("{F3}", "restart")
HotKeySet("{F5}")
HotKeySet("{F7}")
ElseIf $state = 0 Then
HotKeySet("w", "fixDice1")
HotKeySet("e", "fixDice2")
HotKeySet("a", "fixDice3")
HotKeySet("s", "fixDice4")
HotKeySet("d", "fixDice5")
HotKeySet("{F1}", "help")
HotKeySet("{F3}", "restart")
HotKeySet("{F5}", "undo")
HotKeySet("{F7}", "highScoreGUI")
EndIf
EndFunc ;==>setHotKeys
Func setLanguage($languages_A = 0)
If $languages_A = 0 Then
$language_A = IniReadSection($config_A[1][1], "English")
If @error Then MsgBox(4096, "", "Error occured, probably language.ini file.")
ElseIf $languages_A = 1 Then
$language_A = IniReadSection($config_A[1][1], "Deutsch")
If @error Then MsgBox(4096, "", "Error occured, probably language.ini file.")
EndIf
Dim $Label_A[49] = ['', $defaultstatus, $options, $restart, $undo, $highScore, $exit, $view, $hide, $language, _
$languageChoice, $help, $aboutGUI, $game_G, $dices_G, $numbers_G, $specials_G, _
$rolls_G, $totalPoints_G, $ones_L, $twos_L, $threes_L, $fours_L, $fives_L, $sixes_L, $bonus_L, $threeOK_L, _
$fourOK_L, $fullHouse_L, $shortRun_L, $longRun_L, $yahtzee_L, $chance_L, $roll_B, $rollsLeft_DL, _
$points_DL, $question, $bonusPoints_PL, $highScoreList, $save_B, $exit_B, $statuslabel, $game, $fixDice1, $fixDice2, _
$fixDice3, $fixDice4, $fixDice5, $rollDice]
For $i = 1 To 39
GUICtrlSetData($Label_A[$i], $language_A[$i][1])
Next
GUICtrlSetData($Label_A[39], $language_A[40][1])
GUICtrlSetData($Label_A[40], $language_A[41][1])
GUICtrlSetData($Label_A[41], $language_A[1][1])
GUICtrlSetData($Label_A[42], $language_A[60][1])
GUICtrlSetData($Label_A[43], $language_A[61][1])
GUICtrlSetData($Label_A[44], $language_A[62][1])
GUICtrlSetData($Label_A[45], $language_A[63][1])
GUICtrlSetData($Label_A[46], $language_A[64][1])
GUICtrlSetData($Label_A[47], $language_A[65][1])
GUICtrlSetData($Label_A[48], $language_A[33][1])
EndFunc ;==>setLanguage
; set the focus to that control which has the biggest score
Func setFocus()
If GUICtrlRead($rollsCount_L) = 0 Then
$CheatCounter = 0 ; set cheatcounter to 0.
Local $r[13]
For $i = 0 To UBound($point_A) - 1
$r[$i] = GUICtrlRead($point_A[$i])
Next
For $i = 0 To UBound($point_A) - 1
If $status_A_S[$i] = True Then
$r[$i] = 0
EndIf
Next
If $status_A_S[_ArrayMaxIndex($r, 1, 0) ] = False Then GUICtrlSetState($buttonArray[_ArrayMaxIndex($r, 1, 0) ], $GUI_FOCUS)
EndIf
EndFunc ;==>setFocus
;Program-Code HighScore
Func highScoreGUI()
GUICtrlSetData($statuslabel, $language_A[58][1])
GUICtrlSetState($highScore, $GUI_DISABLE)
GUICtrlSetData($pointInHighScore_L, $language_A[39][1] & " " & ControlGetText("", "", $point_PL) & " " & $language_A[35][1])
If IniRead($config_A[16][1], "settings", "sound", "No sound setting found") = "On" Then SoundPlay($config_A[12][1])
readHighScoreIni()
If ControlGetText("", "", $point_PL) >= Int(StringMid($highScore_A[9], 1, 3)) And $finished = True Then
GUICtrlSetState($save_B, $GUI_ENABLE)
GUICtrlSetState($name_I, $GUI_ENABLE)
GUICtrlSetState($name_I, $GUI_FOCUS)
Else
GUICtrlSetState($save_B, $GUI_DISABLE)
GUICtrlSetState($name_I, $GUI_DISABLE)
GUICtrlSetState($highScore, $GUI_ENABLE)
EndIf
For $i = 0 To UBound($listViewItems) - 1
GUICtrlDelete($listViewItems[$i]) ; delete otherwise the list grows up ...
Next
For $i = 0 To UBound($highScore_A) - 1
$listViewItems[$i] = GUICtrlCreateListViewItem($i + 1 & "|" & StringMid($highScore_A[$i], 5) & "|" & StringMid($highScore_A[$i], 1, 3), $highScoreList)
Next
GUISetState(@SW_SHOW, $GUI_HighScore)
EndFunc ;==>highScoreGUI
Func readHighScoreIni()
For $i = 1 To UBound($highScore_A)
$highScore_A[$i - 1] = _StringEncrypt(0, IniRead($config_A[2][1], $i, "value", "000"), "yahtzee", 2)
Next
EndFunc ;==>readHighScoreIni
Func save()
$finished = False
GUICtrlSetState($highScore, $GUI_DISABLE)
GUICtrlSetState($save_B, $GUI_DISABLE)
GUICtrlSetState($name_I, $GUI_DISABLE)
Local $p = IniRead($config_A[2][1], "points", "points", "NotFound")
If GUICtrlRead($name_I) = "" Then GUICtrlSetData($name_I, $defaultName)
_ArrayAdd($highScore_A, $p & "," & GUICtrlRead($name_I))
_ArraySort($highScore_A, 1, 0)
_ArrayDelete($highScore_A, 12)
For $i = 1 To 12
IniWrite($config_A[2][1], $i, "value", _StringEncrypt(1, $highScore_A[$i - 1], "yahtzee", 2))
Next
readHighScoreIni()
For $i = 1 To 12
GUICtrlSetData($listViewItems[$i - 1], $i & "|" & StringMid($highScore_A[$i - 1], 5) & "|" & StringMid($highScore_A[$i - 1], 1, 3))
Next
IniWrite($config_A[2][1], "Name", "Name", GUICtrlRead($name_I))
IniDelete($config_A[2][1], "points")
EndFunc ;==>save
Func RoundGUI($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
Dim $pos, $ret, $ret2
$pos = WinGetPos($h_win)
$ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3)
If $ret[0] Then
$ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
If $ret2[0] Then
Return 1
Else
Return 0
EndIf
Else
Return 0
EndIf
EndFunc ;==>RoundGUI
Alles anzeigen
Edit peethebee: Code übersichtlicher gemacht.