Option Strict Off
Option Explicit On
Imports Microsoft.VisualBasic.PowerPacks
Friend Class WeaponEditor
	Inherits System.Windows.Forms.Form
	Public itemnum As Short
	Public obj As New obj
	Public weapon As New weapon
	Public subchange As Boolean
	
	Public dlg_itemtypechooser As ItemTypeChooser
	Public dlg_comboeditor As ComboEditor
	Public dlg_attackeditor As AttackEditor
    Public dlg_objectlist As ObjectListForm
	Public parenttype As Short
	
	
	
	
	
	'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"'
    Public Sub init()
        subchange = True
        'graphics.resetmodifiedcolorarray
        'ImageInventory.Picture = graphics.loadgraphic(18, 0)
        'ImageChest.Picture = graphics.loadgraphic(26, 0)

        Dim i As Short

        parenttype = 0
        For i = 1 To 44
            CBCombo.Items.Add(zerostr(i - 1, 2) & " " & App.graphics.f560.Combo(i).tostring_Renamed())
        Next

        obj.Combos = App.graphics.f559.obj(itemnum).Combos
        obj.FloorGraphic = App.graphics.f559.obj(itemnum).FloorGraphic
        obj.ItemType = App.graphics.f559.obj(itemnum).ItemType
        obj.WearLocs = App.graphics.f559.obj(itemnum).WearLocs

        weapon.Byte1 = App.graphics.f559.weapon(itemnum - 23).Byte1
        weapon.Damage = App.graphics.f559.weapon(itemnum - 23).Damage
        weapon.Distance = App.graphics.f559.weapon(itemnum - 23).Distance
        weapon.Weight = App.graphics.f559.weapon(itemnum - 23).Weight
        weapon.Word4 = App.graphics.f559.weapon(itemnum - 23).Word4

        ItemName.Text = App.graphics.f556.objstring(obj.ItemType + 1)
        ItemType.Text = Str(obj.ItemType)
        Combo.Text = Str(obj.Combos)
        CBCombo.SelectedIndex = obj.Combos

        Weight.Text = Str(weapon.Weight)
        Damage.Text = Str(weapon.Damage)
        Distance.Text = Str(weapon.Distance)
        Word4.Text = Str(weapon.Word4)
        Byte1.Text = Str(weapon.Byte1)

        CBFiresA.CheckState = weapon.firedby1
        CBFiresB.CheckState = weapon.firedby2
        B1DEnergy.Text = Str(weapon.deltaenergy)
        W4AirbornGraphic.Text = Str(weapon.Graphic)
        W4ShootDamage.Text = Str(weapon.shootdamage)

        Dim offscreen As Bitmap = New Bitmap(GraphicInventory.ClientSize.Width, GraphicInventory.ClientSize.Height)
        Using cv As Drawing.Graphics = Drawing.Graphics.FromImage(offscreen)
            graphics.drawbmp(cv, 17)
            graphics.drawtransparentbmpat(cv, 25, 80, 52, 8)
        End Using
        GraphicInventory.BackgroundImage = offscreen
        GraphicInventory.BackgroundImageLayout = ImageLayout.None
        GraphicInventory.Refresh()

        Me.IWearRect1.Left = graphics.f561.csbbutton(91).x1
        Me.IWearRect1.Top = graphics.f561.csbbutton(91).y1 - 33
        Me.IWearRect2.Left = graphics.f561.csbbutton(86).x1
        Me.IWearRect2.Top = graphics.f561.csbbutton(86).y1 - 33
        Me.IWearRect3.Left = graphics.f561.csbbutton(96).x1
        Me.IWearRect3.Top = graphics.f561.csbbutton(96).y1 - 33
        Me.IWearRect4.Left = graphics.f561.csbbutton(87).x1
        Me.IWearRect4.Top = graphics.f561.csbbutton(87).y1 - 33
        Me.IWearRect5.Left = graphics.f561.csbbutton(88).x1
        Me.IWearRect5.Top = graphics.f561.csbbutton(88).y1 - 33
        Me.IWearRect6.Left = graphics.f561.csbbutton(89).x1
        Me.IWearRect6.Top = graphics.f561.csbbutton(89).y1 - 33
        Me.IWearRect7.Left = graphics.f561.csbbutton(98).x1
        Me.IWearRect7.Top = graphics.f561.csbbutton(98).y1 - 33
        Me.IWearRect8.Left = graphics.f561.csbbutton(94).x1
        Me.IWearRect8.Top = graphics.f561.csbbutton(94).y1 - 33
        Me.IWearRect9.Left = graphics.f561.csbbutton(97).x1
        Me.IWearRect9.Top = graphics.f561.csbbutton(97).y1 - 33
        Me._IWearRect10_0.Left = graphics.f561.csbbutton(84).x1
        Me._IWearRect10_0.Top = graphics.f561.csbbutton(84).y1 - 33
        Me._IWearRect10_1.Left = graphics.f561.csbbutton(85).x1
        Me._IWearRect10_1.Top = graphics.f561.csbbutton(85).y1 - 33
        Me._IWearRect11_0.Left = graphics.f561.csbbutton(33).x1
        Me._IWearRect11_0.Top = graphics.f561.csbbutton(33).y1 - 33
        Me._IWearRect11_1.Left = graphics.f561.csbbutton(34).x1
        Me._IWearRect11_1.Top = graphics.f561.csbbutton(34).y1 - 33
        Me._IWearRect11_2.Left = graphics.f561.csbbutton(35).x1
        Me._IWearRect11_2.Top = graphics.f561.csbbutton(35).y1 - 33
        Me._IWearRect11_3.Left = graphics.f561.csbbutton(36).x1
        Me._IWearRect11_3.Top = graphics.f561.csbbutton(36).y1 - 33
        Me._IWearRect11_4.Left = graphics.f561.csbbutton(37).x1
        Me._IWearRect11_4.Top = graphics.f561.csbbutton(37).y1 - 33
        Me._IWearRect11_5.Left = graphics.f561.csbbutton(38).x1
        Me._IWearRect11_5.Top = graphics.f561.csbbutton(38).y1 - 33
        Me._IWearRect11_6.Left = graphics.f561.csbbutton(39).x1
        Me._IWearRect11_6.Top = graphics.f561.csbbutton(39).y1 - 33
        Me._IWearRect11_7.Left = graphics.f561.csbbutton(40).x1
        Me._IWearRect11_7.Top = graphics.f561.csbbutton(40).y1 - 33

        init_combo()
        init_floorgraphics()
        init_wearlocs()

        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"'
    Public Sub init_combo()
        Dim atk As Short
        Dim rating As Integer

        If obj.Combos < 0 Or obj.Combos >= 44 Then
            A1Dam.Text = ""
            A1Name.Text = ""
            A1Rating.Text = ""
            A1Speed.Text = ""
            A2Dam.Text = ""
            A2Name.Text = ""
            A2Rating.Text = ""
            A2Speed.Text = ""
            A3Dam.Text = ""
            A3Name.Text = ""
            A3Rating.Text = ""
            A3Speed.Text = ""
        Else
            'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f560. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            atk = graphics.f560.Combo(obj.Combos + 1).attack1
            If atk < 0 Or atk >= 44 Then
                A1Dam.Text = ""
                A1Name.Text = ""
                A1Rating.Text = ""
                A1Speed.Text = ""
            Else
                'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f560. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                rating = graphics.f560.attack(atk + 1).damage
                rating = rating * weapon.Damage
                rating = rating / 32
                'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f560. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                A1Dam.Text = Str(graphics.f560.attack(atk + 1).damage)
                'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f560. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                A1Name.Text = graphics.f560.attack(atk + 1).name
                A1Rating.Text = Str(rating)
                'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f560. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                A1Speed.Text = Str(graphics.f560.attack(atk + 1).fatigue)
            End If
            'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f560. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            atk = graphics.f560.Combo(obj.Combos + 1).attack2
            If atk < 0 Or atk >= 44 Then
                A2Dam.Text = ""
                A2Name.Text = ""
                A2Rating.Text = ""
                A2Speed.Text = ""
            Else
                'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f560. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                rating = graphics.f560.attack(atk + 1).damage
                rating = rating * weapon.Damage
                rating = rating / 32
                'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f560. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                A2Dam.Text = Str(graphics.f560.attack(atk + 1).damage)
                'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f560. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                A2Name.Text = graphics.f560.attack(atk + 1).name
                A2Rating.Text = Str(rating)
                'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f560. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                A2Speed.Text = Str(graphics.f560.attack(atk + 1).fatigue)
            End If
            'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f560. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            atk = graphics.f560.Combo(obj.Combos + 1).attack3
            If atk < 0 Or atk >= 44 Then
                A3Dam.Text = ""
                A3Name.Text = ""
                A3Rating.Text = ""
                A3Speed.Text = ""
            Else
                'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f560. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                rating = graphics.f560.attack(atk + 1).damage
                rating = rating * weapon.Damage
                rating = rating / 32
                'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f560. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                A3Dam.Text = Str(graphics.f560.attack(atk + 1).damage)
                'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f560. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                A3Name.Text = graphics.f560.attack(atk + 1).name
                A3Rating.Text = Str(rating)
                'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f560. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                A3Speed.Text = Str(graphics.f560.attack(atk + 1).fatigue)
            End If
        End If
    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"'
    Public Sub init_floorgraphics()
        Dim num As Short


        FloorGraphic.Text = Str(obj.FloorGraphic)

        If obj.FloorGraphic > 84 Then
            num = 84
        Else
            num = obj.FloorGraphic
        End If

        'graphics.resetmodifiedcolorarray
        'ImageFloorGraphic.Picture = graphics.loadgraphic(362 + num, 0)

        Dim inum As Integer
        'UPGRADE_WARNING: Couldn't resolve default property of object graphics.f558. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        inum = graphics.f558.itemgraphicinfo(num + 1).GraphicNum + 360

        'UPGRADE_WARNING: Couldn't resolve default property of object graphics.getgbitmapwidth. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        GraphicFloorItem.Width = 2 * graphics.getgbitmapwidth(inum) + 4
        'UPGRADE_WARNING: Couldn't resolve default property of object graphics.getgbitmapheight. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        GraphicFloorItem.Height = 2 * graphics.getgbitmapheight(inum) + 4
        Dim offscreen As Bitmap = New Bitmap(GraphicFloorItem.ClientSize.Width, GraphicFloorItem.ClientSize.Height)
        Using cv As Drawing.Graphics = Drawing.Graphics.FromImage(offscreen)
            graphics.stretchbmpby(cv, inum, 0, 0, 0, 0, 200, 200)
        End Using
        GraphicFloorItem.Image = offscreen

        GraphicFloorItem.Refresh()
    End Sub
    Public Sub init_wearlocs()
        WearLocs.Text = Str(obj.WearLocs)

        If obj.wearlocnum(0) = 1 Then
            IWearRect1.Visible = True
        Else
            IWearRect1.Visible = False
        End If
        If obj.wearlocnum(1) = 1 Then
            IWearRect2.Visible = True
        Else
            IWearRect2.Visible = False
        End If
        If obj.wearlocnum(2) = 1 Then
            IWearRect3.Visible = True
        Else
            IWearRect3.Visible = False
        End If
        If obj.wearlocnum(3) = 1 Then
            IWearRect4.Visible = True
        Else
            IWearRect4.Visible = False
        End If
        If obj.wearlocnum(4) = 1 Then
            IWearRect5.Visible = True
        Else
            IWearRect5.Visible = False
        End If
        If obj.wearlocnum(5) = 1 Then
            IWearRect6.Visible = True
        Else
            IWearRect6.Visible = False
        End If
        If obj.wearlocnum(6) = 1 Then
            IWearRect7.Visible = True
        Else
            IWearRect7.Visible = False
        End If
        If obj.wearlocnum(7) = 1 Then
            IWearRect8.Visible = True
        Else
            IWearRect8.Visible = False
        End If
        If obj.wearlocnum(8) = 1 Then
            IWearRect9.Visible = True
        Else
            IWearRect9.Visible = False
        End If
        If obj.wearlocnum(9) = 1 Then
            _IWearRect10_0.Visible = True
            _IWearRect10_1.Visible = True
        Else
            _IWearRect10_0.Visible = False
            _IWearRect10_1.Visible = False
        End If
        If obj.wearlocnum(10) = 1 Then
            _IWearRect11_0.Visible = True
            _IWearRect11_1.Visible = True
            _IWearRect11_2.Visible = True
            _IWearRect11_3.Visible = True
            _IWearRect11_4.Visible = True
            _IWearRect11_5.Visible = True
            _IWearRect11_6.Visible = True
            _IWearRect11_7.Visible = True
        Else
            _IWearRect11_0.Visible = False
            _IWearRect11_1.Visible = False
            _IWearRect11_2.Visible = False
            _IWearRect11_3.Visible = False
            _IWearRect11_4.Visible = False
            _IWearRect11_5.Visible = False
            _IWearRect11_6.Visible = False
            _IWearRect11_7.Visible = False
        End If

    End Sub
    Public Function point_isin(ByVal X As Short, ByVal Y As Short, ByVal x1 As Short, ByVal y1 As Short, ByVal x2 As Short, ByVal y2 As Short) As Boolean
        point_isin = False

        If X >= x1 And X <= x2 Then
            If Y >= y1 And Y <= y2 Then
                point_isin = True
            End If
        End If
    End Function


    'UPGRADE_WARNING: Event B1DEnergy.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 B1DEnergy_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles B1DEnergy.TextChanged

        If subchange = True Then
            Exit Sub
        End If
        subchange = True

        weapon.setdeltaenergy(App.EFChange8(B1DEnergy, 0, 15))
        Byte1.Text = Str(weapon.Byte1)
        CBFiresA.CheckState = weapon.firedby1
        CBFiresB.CheckState = weapon.firedby2
        subchange = False
    End Sub

    Private Sub Cancel_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Cancel.Click

        Me.Close()
    End Sub

    'UPGRADE_WARNING: Event CBCombo.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 CBCombo_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CBCombo.SelectedIndexChanged
        If subchange = True Then
            Exit Sub
        End If
        subchange = True

        Combo.Text = Str(CBCombo.SelectedIndex)
        obj.Combos = CBCombo.SelectedIndex
        init_combo()
        subchange = False
    End Sub

    'UPGRADE_WARNING: Event CBFiresA.CheckStateChanged 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 CBFiresA_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CBFiresA.CheckStateChanged
        If subchange = True Then
            Exit Sub
        End If
        subchange = True

        weapon.setfiredby1((CBFiresA.CheckState))
        Byte1.Text = Str(weapon.Byte1)
        CBFiresB.CheckState = weapon.firedby2
        B1DEnergy.Text = Str(weapon.deltaenergy)
        subchange = False

    End Sub

    'UPGRADE_WARNING: Event CBFiresB.CheckStateChanged 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 CBFiresB_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CBFiresB.CheckStateChanged

        If subchange = True Then
            Exit Sub
        End If
        subchange = True

        weapon.setfiredby2((CBFiresB.CheckState))
        Byte1.Text = Str(weapon.Byte1)
        CBFiresA.CheckState = weapon.firedby1
        B1DEnergy.Text = Str(weapon.deltaenergy)
        subchange = False
    End Sub

    'UPGRADE_WARNING: Event Combo.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 Combo_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Combo.TextChanged
        If subchange = True Then
            Exit Sub
        End If
        subchange = True

        obj.Combos = App.EFChange8(Combo, 0, 43)
        CBCombo.SelectedIndex = obj.Combos
        init_combo()

        subchange = False
    End Sub

    Private Sub ComboEdit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles ComboEdit.Click
        App.dlg_comboeditor.init()
        App.dlg_comboeditor.selectcombo(obj.Combos + 1)
        App.dlg_comboeditor.Show()
    End Sub

    'UPGRADE_WARNING: Event FloorGraphic.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 FloorGraphic_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles FloorGraphic.TextChanged
        If subchange = True Then
            Exit Sub
        End If
        subchange = True

        obj.FloorGraphic = App.EFChange8(FloorGraphic, 0, 255)
        init_floorgraphics()
        subchange = False
    End Sub

    Private Sub GraphicInventory_MouseDown(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.MouseEventArgs) Handles GraphicInventory.MouseDown, IWearRect9.MouseDown, IWearRect8.MouseDown, IWearRect7.MouseDown, IWearRect6.MouseDown, IWearRect5.MouseDown, IWearRect4.MouseDown, IWearRect3.MouseDown, IWearRect2.MouseDown, IWearRect1.MouseDown, _IWearRect11_7.MouseDown, _IWearRect11_6.MouseDown, _IWearRect11_5.MouseDown, _IWearRect11_4.MouseDown, _IWearRect11_3.MouseDown, _IWearRect11_2.MouseDown, _IWearRect11_1.MouseDown, _IWearRect11_0.MouseDown, _IWearRect10_1.MouseDown, _IWearRect10_0.MouseDown
        Dim button As Short = eventArgs.Button \ &H100000
        Dim Shift As Short = System.Windows.Forms.Control.ModifierKeys \ &H10000
        Dim pt As Point = If(TypeOf eventSender Is System.Windows.Forms.Control, CType(eventSender, Control).PointToScreen(eventArgs.Location), CType(eventSender, Shape).PointToScreen(eventArgs.Location))
        Dim X As Single = pt.X
        Dim Y As Single = pt.Y
        'X = X * 4 / 3
        'Y = Y * 4 / 3

        'X = X + ImageInventory.Left
        'Y = Y + ImageInventory.Top

        'MsgBox "mousedown at (" + Str(x) + "," + Str(y) + ")"

        obj.wearlocation = 0
        wearloc_f(X, Y, IWearRect1)
        obj.wearlocation = 1
        wearloc_f(X, Y, IWearRect2)
        obj.wearlocation = 2
        wearloc_f(X, Y, IWearRect3)
        obj.wearlocation = 3
        wearloc_f(X, Y, IWearRect4)
        obj.wearlocation = 4
        wearloc_f(X, Y, IWearRect5)
        obj.wearlocation = 5
        wearloc_f(X, Y, IWearRect6)
        obj.wearlocation = 6
        wearloc_f(X, Y, IWearRect7)
        obj.wearlocation = 7
        wearloc_f(X, Y, IWearRect8)
        obj.wearlocation = 8
        wearloc_f(X, Y, IWearRect9)
        obj.wearlocation = 9
        wearloc_f(X, Y, _IWearRect10_0)
        wearloc_f(X, Y, _IWearRect10_1)


        obj.wearlocation = 10
        wearloc_f(X, Y, _IWearRect11_0)
        wearloc_f(X, Y, _IWearRect11_1)
        wearloc_f(X, Y, _IWearRect11_2)
        wearloc_f(X, Y, _IWearRect11_3)
        wearloc_f(X, Y, _IWearRect11_4)
        wearloc_f(X, Y, _IWearRect11_5)
        wearloc_f(X, Y, _IWearRect11_6)
        wearloc_f(X, Y, _IWearRect11_7)

        subchange = True
        init_wearlocs()
        subchange = False
    End Sub
	
	
	
    Public Sub wearloc_f(ByVal X As Short, ByVal Y As Short, ByRef s As Microsoft.VisualBasic.PowerPacks.RectangleShape)
        Dim isin As Boolean

        isin = MyUt.CheckHit(s, X, Y)

        'MsgBox "p(" + Str(X) + "," + Str(Y) + ") ?in ((" + Str(s.Left) + "," + Str(s.Top) + "),(" + Str(s.Left + s.Width) + "," + Str(s.Top + s.Height) + "))"

        If isin = True Then
            'MsgBox "button press in shape: " + s.name
            If s.Visible = True Then
                obj.setwearlocnum(0)
            Else
                obj.setwearlocnum(1)
            End If
        End If
    End Sub
	
	'UPGRADE_WARNING: Event ItemType.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 ItemType_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles ItemType.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		obj.ItemType = App.EFChange16(ItemType, 0, 199) 'fixme
		ItemName.Text = App.graphics.f556.objstring(obj.ItemType + 1)
		subchange = False
	End Sub
	
	Private Sub ItemTypeEdit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles ItemTypeEdit.Click
		dlg_itemtypechooser = New ItemTypeChooser
		dlg_itemtypechooser.obj_Renamed = obj
		dlg_itemtypechooser.textfield = ItemType
		dlg_itemtypechooser.init()
		dlg_itemtypechooser.selectitem(obj.ItemType)
		dlg_itemtypechooser.Show()
	End Sub
	
    Private Sub Ok_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Ok.Click
        App.graphics.f559.obj(itemnum).Combos = obj.Combos
        App.graphics.f559.obj(itemnum).FloorGraphic = obj.FloorGraphic
        App.graphics.f559.obj(itemnum).ItemType = obj.ItemType
        App.graphics.f559.obj(itemnum).WearLocs = obj.WearLocs

        App.graphics.f559.weapon(itemnum - 23).Byte1 = weapon.Byte1
        App.graphics.f559.weapon(itemnum - 23).Damage = weapon.Damage
        App.graphics.f559.weapon(itemnum - 23).Distance = weapon.Distance
        App.graphics.f559.weapon(itemnum - 23).Weight = weapon.Weight
        App.graphics.f559.weapon(itemnum - 23).Word4 = weapon.Word4

        If parenttype = 1 Then
            dlg_comboeditor.init_itemlist()
        ElseIf parenttype = 2 Then
            dlg_attackeditor.init_itemlist()
        ElseIf parenttype = 3 Then
            dlg_objectlist.modifieditem(itemnum)
        End If

        App.graphics.f559.update()
        Me.Close()
    End Sub
	
	'UPGRADE_WARNING: Event W4AirbornGraphic.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 W4AirbornGraphic_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles W4AirbornGraphic.TextChanged
		
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		weapon.setgraphic(App.EFChange8(W4AirbornGraphic, 0, 31))
		Word4.Text = Str(weapon.Word4)
		
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event W4ShootDamage.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 W4ShootDamage_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles W4ShootDamage.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		weapon.setshootdamage(App.EFChange8(W4ShootDamage, 0, 255))
		Word4.Text = Str(weapon.Word4)
		
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event WearLocs.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 WearLocs_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles WearLocs.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		obj.WearLocs = App.EFChange16(WearLocs, 0, 65535)
		init_wearlocs()
		
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event Weight.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 Weight_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Weight.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		weapon.Weight = App.EFChange8(Weight, 0, 255)
		
		subchange = False
	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
		
		weapon.Damage = App.EFChange8(Damage, 0, 255)
		
		subchange = False
	End Sub
	
	'UPGRADE_WARNING: Event distance.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 distance_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles distance.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		weapon.Distance = App.EFChange8(Distance, 0, 255)
		
		subchange = False
	End Sub
	
	
	'UPGRADE_WARNING: Event byte1.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 byte1_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles byte1.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		weapon.Byte1 = App.EFChange8(Byte1, 0, 255)
		
		
		CBFiresA.CheckState = weapon.firedby1
		CBFiresB.CheckState = weapon.firedby2
		B1DEnergy.Text = Str(weapon.deltaenergy)
		subchange = False
	End Sub
	'UPGRADE_WARNING: Event word4.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 word4_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles word4.TextChanged
		If subchange = True Then
			Exit Sub
		End If
		subchange = True
		
		weapon.Word4 = App.EFChange16(Word4, 0, 65535)
		W4AirbornGraphic.Text = Str(weapon.Graphic)
		W4ShootDamage.Text = Str(weapon.shootdamage)
		subchange = False
	End Sub

    Private Sub WeaponEditor_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        If e.CloseReason = CloseReason.UserClosing Then
            e.Cancel = True
            Hide()
        End If
    End Sub
End Class