GUIOnEventMode - 2. GUI aufrufen

10/29/2010 19:34 mipez#1
Code:
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode",1)
$Form1 = GUICreate("Flyff Char Manager", 578, 347, 299, 218)
$Tab = GUICtrlCreateTab(0, 0, 577, 346)
$Home = GUICtrlCreateTabItem("Home")
$btn_delchar = GUICtrlCreateButton("Delete Character", 214, 39, 97, 25)
$CharSelection = GUICtrlCreateCombo("", 16, 40, 177, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Add = GUICtrlCreateTabItem("Add")
$btn_add = GUICtrlCreateButton("Add", 16, 32, 81, 25)
$Edit = GUICtrlCreateTabItem("Edit")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
GUISetOnEvent($btn_add,"_add")

While 1
	Sleep(100)
WEnd

Func _add()
	#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode",1)
#Region ### START Koda GUI section ### Form=
$Stats = GUICreate("Stats", 308, 238, 349, 249)
$OK = GUICtrlCreateButton("OK", 22, 195, 75, 25)
$Cancel = GUICtrlCreateButton("Cancel", 117, 196, 75, 25)
$Help = GUICtrlCreateButton("Help", 213, 196, 75, 25)
$Name = GUICtrlCreateInput("Name", 8, 8, 121, 21)
$Job = GUICtrlCreateInput("Job", 8, 56, 121, 21)
$MaleFemale = GUICtrlCreateInput("Male/Female", 8, 104, 121, 21)
$Level = GUICtrlCreateInput("Level", 8, 152, 121, 21)
$Strength = GUICtrlCreateInput("Strength", 176, 8, 121, 21)
$Stamina = GUICtrlCreateInput("Stamina", 176, 56, 121, 21)
$Dexterity = GUICtrlCreateInput("Dexterity", 176, 104, 121, 21)
$Intelligence = GUICtrlCreateInput("Intelligence", 176, 152, 121, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUISetOnEvent($GUI_EVENT_CLOSE,"_del")


While 1
	Sleep(100)
WEnd


EndFunc
Func _del()
	GUIDelete($OK)
EndFunc

Func _exit()
	Exit
EndFunc
So, klappt nicht. Über GUIGetMsg klappts allerdings :x
Woran liegts?
10/29/2010 20:09 lolkop#2
warum genau willst du das denn über onevent handeln?
10/29/2010 20:28 PenGuin :O#3
Da hat aber hinten und vorne nix gepasst o.O

Code:
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode",1)

$Form1 = GUICreate("Flyff Char Manager", 578, 347, 299, 218)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
$Tab = GUICtrlCreateTab(0, 0, 577, 346)
$Home = GUICtrlCreateTabItem("Home")
$btn_delchar = GUICtrlCreateButton("Delete Character", 214, 39, 97, 25)
$CharSelection = GUICtrlCreateCombo("", 16, 40, 177, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Add = GUICtrlCreateTabItem("Add")
$btn_add = GUICtrlCreateButton("Add", 16, 32, 81, 25)
GUICtrlSetOnEvent($btn_add,"_add")
$Edit = GUICtrlCreateTabItem("Edit")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

$Stats = GUICreate("Stats", 308, 238, 349, 249)
GUISetOnEvent($GUI_EVENT_CLOSE,"_del")
$OK = GUICtrlCreateButton("OK", 22, 195, 75, 25)
$Cancel = GUICtrlCreateButton("Cancel", 117, 196, 75, 25)
$Help = GUICtrlCreateButton("Help", 213, 196, 75, 25)
$Name = GUICtrlCreateInput("Name", 8, 8, 121, 21)
$Job = GUICtrlCreateInput("Job", 8, 56, 121, 21)
$MaleFemale = GUICtrlCreateInput("Male/Female", 8, 104, 121, 21)
$Level = GUICtrlCreateInput("Level", 8, 152, 121, 21)
$Strength = GUICtrlCreateInput("Strength", 176, 8, 121, 21)
$Stamina = GUICtrlCreateInput("Stamina", 176, 56, 121, 21)
$Dexterity = GUICtrlCreateInput("Dexterity", 176, 104, 121, 21)
$Intelligence = GUICtrlCreateInput("Intelligence", 176, 152, 121, 21)
GUISetState(@SW_HIDE)


While 1
	Sleep(100)
WEnd

Func _add()
	GUISetState(@SW_HIDE, $Form1)
	GUISetState(@SW_SHOW, $Stats)
EndFunc

Func _del()
	GUISetState(@SW_SHOW, $Form1)
	GUISetState(@SW_HIDE, $Stats)
EndFunc

Func _exit()
	Exit
EndFunc
10/29/2010 20:30 mipez#4
Quote:
Originally Posted by pinguin94 View Post
Da hat aber hinten und vorne nix gepasst o.O

Code:
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode",1)

$Form1 = GUICreate("Flyff Char Manager", 578, 347, 299, 218)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")
$Tab = GUICtrlCreateTab(0, 0, 577, 346)
$Home = GUICtrlCreateTabItem("Home")
$btn_delchar = GUICtrlCreateButton("Delete Character", 214, 39, 97, 25)
$CharSelection = GUICtrlCreateCombo("", 16, 40, 177, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Add = GUICtrlCreateTabItem("Add")
$btn_add = GUICtrlCreateButton("Add", 16, 32, 81, 25)
GUICtrlSetOnEvent($btn_add,"_add")
$Edit = GUICtrlCreateTabItem("Edit")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

$Stats = GUICreate("Stats", 308, 238, 349, 249)
GUISetOnEvent($GUI_EVENT_CLOSE,"_del")
$OK = GUICtrlCreateButton("OK", 22, 195, 75, 25)
$Cancel = GUICtrlCreateButton("Cancel", 117, 196, 75, 25)
$Help = GUICtrlCreateButton("Help", 213, 196, 75, 25)
$Name = GUICtrlCreateInput("Name", 8, 8, 121, 21)
$Job = GUICtrlCreateInput("Job", 8, 56, 121, 21)
$MaleFemale = GUICtrlCreateInput("Male/Female", 8, 104, 121, 21)
$Level = GUICtrlCreateInput("Level", 8, 152, 121, 21)
$Strength = GUICtrlCreateInput("Strength", 176, 8, 121, 21)
$Stamina = GUICtrlCreateInput("Stamina", 176, 56, 121, 21)
$Dexterity = GUICtrlCreateInput("Dexterity", 176, 104, 121, 21)
$Intelligence = GUICtrlCreateInput("Intelligence", 176, 152, 121, 21)
GUISetState(@SW_HIDE)


While 1
	Sleep(100)
WEnd

Func _add()
	GUISetState(@SW_HIDE, $Form1)
	GUISetState(@SW_SHOW, $Stats)
EndFunc

Func _del()
	GUISetState(@SW_SHOW, $Form1)
	GUISetState(@SW_HIDE, $Stats)
EndFunc

Func _exit()
	Exit
EndFunc
Aso, beide GUIs erstellen und dann Sichtbarkeit ändern :x

Ach ja, ich habe eine ComboBox mit einer bestimmten Anzahl von Strings. Ich will jedem dieser Strings eine Integer zuweisen, dem 1. String=1,2. String=2,... Prinzip nach, jedoch ohne großartige If-Then-Abfragen... ne Idee?
10/29/2010 20:33 PenGuin :O#5
Und vor allem wichtig:

GUICTRLSetOnEvent, nicht GUISetOnEvent ;)
Wenns um Controls geht, für die GUI dann halt GUISetOnEvent.
Thanks darfste auch drücken :P (thanks geil sein ;O)
10/29/2010 20:42 mipez#6
Wenn du mir mit meinem 2. Prob hilfst, kriegste sogar 2 Thanks ;D
10/29/2010 20:46 lolkop#7
$string[n+1] = ['string_1', 'string_2', 'string_3', ..., 'string_n']
10/29/2010 20:54 mipez#8
Quote:
Originally Posted by lolkop View Post
$string[n+1] = ['string_1', 'string_2', 'string_3', ..., 'string_n']
Es soll ja parallel zum String eine Integer stehen... ich brauchs für weitere Funktionen, deswegen :x

Als Beispiel:
GUICtrlRead liest die ComboBox aus -> passend zum Eintrag wird eine bestimmte Integer gelesen
Nach dem Prinzip: If $string = "Hallo" Then $wert = 2 ... nur würde das viel zuviele Abfragen ergeben...

EDIT:
Habs^^
Code:
$snumber = _GUICtrlComboBox_SelectString($Combo,GUICtrlRead($Combo))
10/29/2010 21:14 lolkop#9
genau deswegen ja als array...

Code:
for $i=0 to ubound($string)-1
    if guictrlread($combo) = $string[$i] then ...
next
10/29/2010 22:05 mipez#10
Code:
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("", 117, 171)
$Dex = GUICtrlCreateInput("Dex", 8, 40, 97, 25)
$Level = GUICtrlCreateInput("Level", 8, 8, 97, 25)
$Job = GUICtrlCreateCombo("Job", 8, 104, 97, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Vagrant|Mercenary|Acrobat|Assist|Magician|Knight|Blade|Jester|Ranger|Ringmaster|Billposter|Psykeeper|Elementor")
$Weapon = GUICtrlCreateCombo("Weapon", 8, 72, 97, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Sword (One Handed)|Sword (Two Handed)|Axe (One Handed)|Axe (Two Handed)|Stick|Knuckle|Wand|Staff|Yoyo|Bow")
$Calculate = GUICtrlCreateButton("Calculate", 16, 136, 89, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Calculate
			$read1 = GUICtrlRead($Dex)
			$read2 = GUICtrlRead($Level)
			$read4 = GUICtrlRead($Job)
			$read3 = GUICtrlRead($Weapon)
			
			If $read4 = "Vagrant" Or $read4 = "Acrobat" Or $read4 = "Ranger" Then
				Local $tjob = 75
			ElseIf $read4 = "Magician" Then
				Local $tjob = 65
			ElseIf $read4 = "Mercenary" Then
				Local $tjob = 80
			ElseIf $read4 = "Assist" Or $read4 = "Ringmaster" Or $read4 = "Elementor" Or $read4 = "Psykeeper" Then
				Local $tjob = 70
			ElseIf $read4 = "Jester" Or $read4 = "Billposter" Then
				Local $tjob = 85
			ElseIf $read4 = "Blade" Then 
				Local $tjob = 90
			ElseIf $read4 = "Knight" Then				
				Local $tjob = 60
			EndIf

			If $read3 = "Knuckle" Or $read3 = "Bow" Then
				Local $twep = 0.070
			ElseIf $read3 = "Sword (One Handed)" Then
				Local $twep = 0.085
			ElseIf $read3 = "Axe (One Handed)" Then
				Local $twep = 0.060
			ElseIf $read3 = "Axe (Two Handed)" Then
				Local $twep = 0.030
			ElseIf $read3 = "Sword (Two Handed)" Then
				Local $twep = 0.035
			ElseIf $read4 = "Stick" Then 
				Local $twep = 0.050
			ElseIf $read4 = "Wand" Then				
				Local $twep = 0.025
			ElseIf $read4 = "Staff" Then				
				Local $twep = 0.045
			ElseIf $read4 = "Yoyo" Then				
				Local $twep = 0.075				
			EndIf
		
			_calculate($read1,$read2,$twep,$tjob)
			
	EndSwitch
WEnd

Func _calculate($sdex,$slvl,$mod_wep,$mod_job)
	;If IsInt($slvl) And $slvl >= 1 And IsInt($sdex) And $sdex >= 15 Then
		$step1 = Round(($slvl / 8 + $sdex * 4) * $mod_wep + $mod_job - 3)
		If $step1 < 187 Then
			$imod = $step1 * 0.1
			MsgBox(0,"",$imod)
			If $imod > 0 And $imod < 1 Then
				Local $imodx = 0.08
			ElseIf $imod >= 1 And $imod < 2 Then
				Local $imodx = 0.16
			ElseIf $imod >= 2 And $imod < 3 Then
				Local $imodx = 0.24
			ElseIf $imod >= 3 And $imod < 4 Then
				Local $imodx = 0.32
			ElseIf $imod >= 4 And $imod < 5 Then
				Local $imodx = 0.4
			ElseIf $imod >= 5 And $imod < 6 Then
				Local $imodx = 0.48
			ElseIf $imod >= 6 And $imod < 7 Then
				Local $imodx = 0.56
			ElseIf $imod >= 7 And $imod < 8 Then
				Local $imodx = 0.64
			ElseIf $imod >= 8 And $imod < 9 Then
				Local $imodx = 0.72
			ElseIf $imod >= 9 And $imod < 10 Then
				Local $imodx = 0.8
			ElseIf $imod >= 10 And $imod < 11 Then
				Local $imodx = 0.88
			ElseIf $imod >= 11 And $imod < 12 Then
				Local $imodx = 0.96
			ElseIf $imod >= 12 And $imod < 13 Then
				Local $imodx = 1.04
			ElseIf $imod >= 13 And $imod < 14 Then
				Local $imodx = 1.12
			ElseIf $imod >= 14 And $imod < 15 Then
				Local $imodx = 1.2
			ElseIf $imod >= 15 And $imod < 16 Then
				Local $imodx = 1.3
			ElseIf $imod >= 16 And $imod < 17 Then
				Local $imodx = 1.38
			ElseIf $imod >= 17 And $imod < 18 Then
				Local $imodx = 1.5
			ElseIf $imod >= 18 And $imod < 19 Then
				Local $imodx = 1.5
			EndIf
			$step2 = Round(50 / (200 - $step1) * 0.5 + $imodx,2)
			$step3 = Round($step2 * 50)
			MsgBox(0,"","Your Attackspeed in % is:" & @crlf &$step3)
		Else
			MsgBox(0,"","Failed, over 187")
		EndIf
	
	;EndIf
EndFunc
Kleiner Attackspeed-Kalkulator für Flyff (ohne Buffs) xD

Code:
If IsInt($slvl) And $slvl >= 1 And IsInt($sdex) And $sdex >= 15 Then
...
EndIf
Mit der Abfrage funzt _calculate nich mehr... find nur gerade nich den Fehler

EDIT:
Code:
StringIsDigit($slvl) And $slvl >= 1 And StringIsDigit($sdex) And $sdex >= 15
Hm... naja hier mal der fertige Kalkulator xD
Code:
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("", 117, 171)
$Dex = GUICtrlCreateInput("Dex", 8, 40, 97, 25)
$Level = GUICtrlCreateInput("Level", 8, 8, 97, 25)
$Job = GUICtrlCreateCombo("Job", 8, 104, 97, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Vagrant|Mercenary|Acrobat|Assist|Magician|Knight|Blade|Jester|Ranger|Ringmaster|Billposter|Psykeeper|Elementor")
$Weapon = GUICtrlCreateCombo("Weapon", 8, 72, 97, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Sword (One Handed)|Sword (Two Handed)|Axe (One Handed)|Axe (Two Handed)|Stick|Knuckle|Wand|Staff|Yoyo|Bow")
$Calculate = GUICtrlCreateButton("Calculate", 16, 136, 89, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Calculate
			$read1 = GUICtrlRead($Dex)
			$read2 = GUICtrlRead($Level)
			$read4 = GUICtrlRead($Job)
			$read3 = GUICtrlRead($Weapon)
			
			If $read4 = "Vagrant" Or $read4 = "Acrobat" Or $read4 = "Ranger" Then
				Local $tjob = 75
			ElseIf $read4 = "Magician" Then
				Local $tjob = 65
			ElseIf $read4 = "Mercenary" Then
				Local $tjob = 80
			ElseIf $read4 = "Assist" Or $read4 = "Ringmaster" Or $read4 = "Elementor" Or $read4 = "Psykeeper" Then
				Local $tjob = 70
			ElseIf $read4 = "Jester" Or $read4 = "Billposter" Then
				Local $tjob = 85
			ElseIf $read4 = "Blade" Then 
				Local $tjob = 90
			ElseIf $read4 = "Knight" Then				
				Local $tjob = 60
			EndIf

			If $read3 = "Knuckle" Or $read3 = "Bow" Then
				Local $twep = 0.070
			ElseIf $read3 = "Sword (One Handed)" Then
				Local $twep = 0.085
			ElseIf $read3 = "Axe (One Handed)" Then
				Local $twep = 0.060
			ElseIf $read3 = "Axe (Two Handed)" Then
				Local $twep = 0.030
			ElseIf $read3 = "Sword (Two Handed)" Then
				Local $twep = 0.035
			ElseIf $read4 = "Stick" Then 
				Local $twep = 0.050
			ElseIf $read4 = "Wand" Then				
				Local $twep = 0.025
			ElseIf $read4 = "Staff" Then				
				Local $twep = 0.045
			ElseIf $read4 = "Yoyo" Then				
				Local $twep = 0.075				
			EndIf
		
			_calculate($read1,$read2,$twep,$tjob)
			
	EndSwitch
WEnd

Func _calculate($sdex,$slvl,$mod_wep,$mod_job)
	If StringIsDigit($slvl) And $slvl >= 1 And StringIsDigit($sdex) And $sdex >= 15 Then
		$step1 = Round(($slvl / 8 + $sdex * 4) * $mod_wep + $mod_job - 3)
		If $step1 < 187 Then
			$imod = $step1 * 0.1
			MsgBox(0,"",$imod)
			If $imod > 0 And $imod < 1 Then
				Local $imodx = 0.08
			ElseIf $imod >= 1 And $imod < 2 Then
				Local $imodx = 0.16
			ElseIf $imod >= 2 And $imod < 3 Then
				Local $imodx = 0.24
			ElseIf $imod >= 3 And $imod < 4 Then
				Local $imodx = 0.32
			ElseIf $imod >= 4 And $imod < 5 Then
				Local $imodx = 0.4
			ElseIf $imod >= 5 And $imod < 6 Then
				Local $imodx = 0.48
			ElseIf $imod >= 6 And $imod < 7 Then
				Local $imodx = 0.56
			ElseIf $imod >= 7 And $imod < 8 Then
				Local $imodx = 0.64
			ElseIf $imod >= 8 And $imod < 9 Then
				Local $imodx = 0.72
			ElseIf $imod >= 9 And $imod < 10 Then
				Local $imodx = 0.8
			ElseIf $imod >= 10 And $imod < 11 Then
				Local $imodx = 0.88
			ElseIf $imod >= 11 And $imod < 12 Then
				Local $imodx = 0.96
			ElseIf $imod >= 12 And $imod < 13 Then
				Local $imodx = 1.04
			ElseIf $imod >= 13 And $imod < 14 Then
				Local $imodx = 1.12
			ElseIf $imod >= 14 And $imod < 15 Then
				Local $imodx = 1.2
			ElseIf $imod >= 15 And $imod < 16 Then
				Local $imodx = 1.3
			ElseIf $imod >= 16 And $imod < 17 Then
				Local $imodx = 1.38
			ElseIf $imod >= 17 And $imod < 18 Then
				Local $imodx = 1.5
			ElseIf $imod >= 18 And $imod < 19 Then
				Local $imodx = 1.5
			EndIf
			$step2 = Round(50 / (200 - $step1) * 0.5 + $imodx,2)
			$step3 = Round($step2 * 50)
			MsgBox(0,"","Your Attackspeed in % is:" & @crlf &$step3)
		Else
			MsgBox(0,"","Failed, over 187")
		EndIf
	Else
		MsgBox(0,"","Failed, wrong Parameters")
	EndIf
EndFunc
10/29/2010 22:58 PenGuin :O#11
Ich würde dir dringend raten Switch...Case...Endswitch zu lernen.
10/30/2010 21:56 mipez#12
Hrm, iMo macht das keinen Sinn, aber kommen ja noch HP/MP/FP-, Pet- und Skill-Formel - und die bauen unter anderem auf der bisherigen auf - da wäre es angebracht xD

Aber mich stört, dass mir per se nix einfallen will wie ich das ganze vereinfachen könnte, selbst mit Switches wäre es noch sehr groß :x
10/30/2010 22:26 lolkop#13
mit arrays könntest du das ganze deutlich einfacher aufbauen.
10/30/2010 22:32 mipez#14
Quote:
Originally Posted by lolkop View Post
mit arrays könntest du das ganze deutlich einfacher aufbauen.
Toll, leite ich mir erstmal eine ellenlange Formel für die For-Next-Schleife herbei :x
Drecks Modifier, ohne die wäre es einfacher xD
10/30/2010 23:11 PenGuin :O#15
Alle Modifier in ein Array laden und dann einfach immer den Index aufrufen o.O