Option Strict Off
Option Explicit On
Friend Class AttackEditor
	Inherits System.Windows.Forms.Form
	'UPGRADE_WARNING: Arrays can't be declared with New. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC9D3AE5-6B95-4B43-91C7-28276302A5E8"'
    Private Attacks() As attack = ADGEDotNetUt.ArrayUt(Of attack).NewArray1(44)
	Public selectedattack As Short
	Public subchange As Boolean
	
	
    Public Sub modifiedattack(ByVal num As Short)

        Dim i As Short

        i = num

        'UPGRADE_WARNING: Couldn't resolve default property of object AttackList.List(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        AttackList.Items(i - 1).SubItems(0).Text = zerostr(i - 1, 2)
        'UPGRADE_WARNING: Couldn't resolve default property of object AttackList.List(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        AttackList.Items(i - 1).SubItems(1).Text = Attacks(num).name

    End Sub
    Public Sub init()
        Dim i As Short

        AttackList.Items.Clear()

        For i = 1 To 44
            Attacks(i).damage = App.graphics.f560.attack(i).damage
            Attacks(i).defense = App.graphics.f560.attack(i).defense
            Attacks(i).exp = App.graphics.f560.attack(i).exp
            Attacks(i).fatigue = App.graphics.f560.attack(i).fatigue
            Attacks(i).hitprob = App.graphics.f560.attack(i).hitprob
            Attacks(i).name = App.graphics.f560.attack(i).name
            Attacks(i).skill = App.graphics.f560.attack(i).skill
            Attacks(i).stamina = App.graphics.f560.attack(i).stamina

            AttackList.Items.Add("", "BlueGem").SubItems.Add("")
            modifiedattack(i)
        Next

        CBSkill.Items.Add("00 - Fighter 1")
        CBSkill.Items.Add("01 - Ninja 1")
        CBSkill.Items.Add("02 - Priest 1")
        CBSkill.Items.Add("03 - Wizard 1")
        CBSkill.Items.Add("04 - Fighter 2")
        CBSkill.Items.Add("05 - Fighter 3")
        CBSkill.Items.Add("06 - Fighter 4")
        CBSkill.Items.Add("07 - Fighter 5")
        CBSkill.Items.Add("08 - Ninja 2")
        CBSkill.Items.Add("09 - Ninja 3")
        CBSkill.Items.Add("10 - Ninja 4")
        CBSkill.Items.Add("11 - Ninja 5")
        CBSkill.Items.Add("12 - Priest 2")
        CBSkill.Items.Add("13 - Priest 3")
        CBSkill.Items.Add("14 - Priest 4")
        CBSkill.Items.Add("15 - Priest 5")
        CBSkill.Items.Add("16 - Wizard 2")
        CBSkill.Items.Add("17 - Wizard 3")
        CBSkill.Items.Add("18 - Wizard 4")
        CBSkill.Items.Add("19 - Wizard 5")

        selectattack(1)
    End Sub
	
    Public Sub selectattack(ByVal num As Short)
        selectedattack = num
        subchange = True
        AttackList.Items(num - 1).Focused = True
        MyUt.CheckSel(AttackList, num - 1, "BlueGem")

        init_itemlist()
        init_combolist()

        AttackName.Text = Attacks(selectedattack).name
        Skill.Text = Str(Attacks(selectedattack).skill)
        If Attacks(selectedattack).skill >= 0 And Attacks(selectedattack).skill < 20 Then
            CBSkill.SelectedIndex = Attacks(selectedattack).skill
        Else
            CBSkill.SelectedIndex = 0
        End If
        Exp.Text = Str(Attacks(selectedattack).exp)
        Defense.Text = Str(Attacks(selectedattack).defense)
        Stamina.Text = Str(Attacks(selectedattack).stamina)
        Hitprob.Text = Str(Attacks(selectedattack).hitprob)
        Damage.Text = Str(Attacks(selectedattack).damage)
        Fatigue.Text = Str(Attacks(selectedattack).fatigue)

        subchange = False
    End Sub
	
    Public Sub init_itemlist()

        ItemList.Items.Clear()
        ItemList.FocusedItem = Nothing

        Dim i As Short
        Dim j As Short
        'UPGRADE_NOTE: Combo was upgraded to Combo_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
        Dim Combo_Renamed As Short
        j = 0
        For i = 1 To 180
            'UPGRADE_WARNING: Couldn't resolve default property of object i. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            Combo_Renamed = graphics.f559.obj(i).Combos
            If Combo_Renamed >= 0 And Combo_Renamed < 44 Then
                If App.graphics.f560.Combo(Combo_Renamed + 1).attack1 = selectedattack - 1 Then
                    ItemList.Items.Add(zerostr(i - 1, 3)).SubItems.Add(graphics.f556.objstring(graphics.f559.obj(i).ItemType + 1))
                    j = j + 1
                ElseIf App.graphics.f560.Combo(Combo_Renamed + 1).attack2 = selectedattack - 1 Then
                    ItemList.Items.Add(zerostr(i - 1, 3)).SubItems.Add(graphics.f556.objstring(graphics.f559.obj(i).ItemType + 1))
                    j = j + 1
                ElseIf App.graphics.f560.Combo(Combo_Renamed + 1).attack3 = selectedattack - 1 Then
                    ItemList.Items.Add(zerostr(i - 1, 3)).SubItems.Add(graphics.f556.objstring(graphics.f559.obj(i).ItemType + 1))
                    j = j + 1
                End If
            End If
        Next

    End Sub
	
    Public Sub init_combolist()

        ComboList.Items.Clear()
        ComboList.FocusedItem = Nothing

        Dim i As Short
        Dim j As Short
        'UPGRADE_NOTE: Combo was upgraded to Combo_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
        j = 0
        For i = 1 To 44
            If App.graphics.f560.Combo(i).attack1 = selectedattack - 1 Then
                ComboList.Items.Add(zerostr(i - 1, 2)).SubItems.Add(App.graphics.f560.Combo(i).tostring_Renamed())
                j = j + 1
            ElseIf App.graphics.f560.Combo(i).attack2 = selectedattack - 1 Then
                ComboList.Items.Add(zerostr(i - 1, 2)).SubItems.Add(App.graphics.f560.Combo(i).tostring_Renamed())
                j = j + 1
            ElseIf App.graphics.f560.Combo(i).attack3 = selectedattack - 1 Then
                ComboList.Items.Add(zerostr(i - 1, 2)).SubItems.Add(App.graphics.f560.Combo(i).tostring_Renamed())
                j = j + 1
            End If
        Next

    End Sub
	
	'UPGRADE_WARNING: Event AttackName.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub AttackName_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles AttackName.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		Attacks(selectedattack).name = AttackName.Text
		modifiedattack(selectedattack)
		
		subchange = False
	End Sub
	
    Private Sub Cancel_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Cancel.Click
        Hide()

    End Sub
	
    'UPGRADE_WARNING: Event CBSkill.SelectedIndexChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub CBSkill_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CBSkill.SelectedIndexChanged
		
		
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		Attacks(selectedattack).Skill = CBSkill.SelectedIndex
		Skill.Text = Str(Attacks(selectedattack).Skill)
		
		subchange = False
	End Sub
	
    Private Sub ComboList_DblClick(ByVal eventSender As System.Object, ByVal eventArgs As EventArgs) Handles ComboList.DoubleClick

        App.dlg_comboeditor.Show()
        App.dlg_comboeditor.init()
        'UPGRADE_WARNING: Couldn't resolve default property of object ComboList.List(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        App.dlg_comboeditor.selectcombo(Val(Mid(ComboList.FocusedItem.Text, 1)) + 1)
    End Sub
	
	
	'UPGRADE_WARNING: Event damage.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub damage_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles damage.TextChanged
		
		
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		Attacks(selectedattack).Damage = EFChange8(Damage, 0, 255)
		
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event Defense.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub Defense_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Defense.TextChanged
		
		
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		Attacks(selectedattack).Defense = EFChange8(Defense, -127, 127) 'fixme
		
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event Exp.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub Exp_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Exp.TextChanged
		
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		Attacks(selectedattack).Exp = EFChange8(Exp, 0, 255)
		
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event Fatigue.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub Fatigue_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Fatigue.TextChanged
		
		
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		Attacks(selectedattack).Fatigue = EFChange8(Fatigue, 0, 255)
		
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event hitprob.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub hitprob_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles hitprob.TextChanged
		
		
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		Attacks(selectedattack).HitProb = EFChange8(HitProb, 0, 255)
		
		subchange = False
	End Sub
	
	'UPGRADE_NOTE: graphics was upgraded to graphics_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
    Private Sub ItemList_DblClick(ByVal eventSender As System.Object, ByVal eventArgs As EventArgs) Handles ItemList.DoubleClick
        'Dim dlg_miscobjecteditor As MiscObjectEditor
        'Set dlg_miscobjecteditor = New MiscObjectEditor
        'dlg_miscobjecteditor.itemnum = val(Mid(ItemList.List(ItemList.ListIndex, 0), 2) + 1)
        'dlg_miscobjecteditor.init
        'dlg_miscobjecteditor.parenttype = 2
        'Set dlg_miscobjecteditor.dlg_attackeditor = Me
        'dlg_miscobjecteditor.Show

        Dim itemnum As Short
        Dim ItemType As String

        'itemnum = ObjectList.ListIndex + 1
        'UPGRADE_WARNING: Couldn't resolve default property of object ItemList.List(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        itemnum = Val(CStr((Mid(ItemList.FocusedItem.Text, 2)) + 1))
        'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f556. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        ItemType = graphics.f556.objtype(itemnum)

        Dim dlg_foodeditor As FoodEditor
        Dim dlg_armoreditor As ArmorEditor
        Dim dlg_weaponeditor As WeaponEditor
        Dim dlg_miscobjecteditor As MiscObjectEditor
        If ItemType = "Food" Then
            dlg_foodeditor = New FoodEditor
            dlg_foodeditor.itemnum = itemnum
            dlg_foodeditor.init()
            dlg_foodeditor.parenttype = 2
            dlg_foodeditor.dlg_attackeditor = Me
            dlg_foodeditor.Show()
        ElseIf ItemType = "Armor" Then
            dlg_armoreditor = New ArmorEditor
            dlg_armoreditor.itemnum = itemnum
            dlg_armoreditor.init()
            dlg_armoreditor.parenttype = 2
            dlg_armoreditor.dlg_attackeditor = Me
            dlg_armoreditor.Show()

        ElseIf ItemType = "Weapon" Then
            dlg_weaponeditor = New WeaponEditor
            dlg_weaponeditor.itemnum = itemnum
            dlg_weaponeditor.init()
            dlg_weaponeditor.parenttype = 2
            dlg_weaponeditor.dlg_attackeditor = Me
            dlg_weaponeditor.Show()
        ElseIf ItemType = "Misc" Then
            dlg_miscobjecteditor = New MiscObjectEditor
            dlg_miscobjecteditor.itemnum = itemnum
            dlg_miscobjecteditor.init()
            dlg_miscobjecteditor.parenttype = 2
            dlg_miscobjecteditor.dlg_attackeditor = Me
            dlg_miscobjecteditor.Show()
        Else
            MsgBox("Invalid item type")
        End If
    End Sub
	
    Private Sub Ok_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Ok.Click
        Dim i As Integer
        For i = 1 To 44
            App.graphics.f560.attack(i).damage = Attacks(i).damage
            App.graphics.f560.attack(i).defense = Attacks(i).defense
            App.graphics.f560.attack(i).exp = Attacks(i).exp
            App.graphics.f560.attack(i).fatigue = Attacks(i).fatigue
            App.graphics.f560.attack(i).hitprob = Attacks(i).hitprob
            App.graphics.f560.attack(i).name = Attacks(i).name
            App.graphics.f560.attack(i).skill = Attacks(i).skill
            App.graphics.f560.attack(i).stamina = Attacks(i).stamina
        Next
        App.graphics.f560.update()
        Hide()
    End Sub
	
	'UPGRADE_WARNING: Event Skill.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub Skill_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Skill.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		Attacks(selectedattack).Skill = EFChange8(Skill, 0, 19) 'fixme
		
		If Attacks(selectedattack).Skill >= 0 And Attacks(selectedattack).Skill < 20 Then
			CBSkill.SelectedIndex = Attacks(selectedattack).Skill
		Else
			CBSkill.SelectedIndex = 0
		End If
		
		subchange = False
		
	End Sub
	
	'UPGRADE_WARNING: Event Stamina.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub Stamina_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Stamina.TextChanged
		
		
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		Attacks(selectedattack).Stamina = EFChange8(Stamina, 0, 255)
		
		subchange = False
	End Sub

    Private Sub AttackEditor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AttackList.SmallImageList = App.JewelIL
        ComboList.SmallImageList = App.JewelIL
        ItemList.SmallImageList = App.JewelIL
    End Sub

    Private Sub AttackList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AttackList.SelectedIndexChanged
        If AttackList.FocusedItem Is Nothing Then Exit Sub

        selectattack(AttackList.FocusedItem.Index + 1)
    End Sub
End Class