VERSION 5.00
Object = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0"; "FM20.DLL"
Begin VB.Form FoodEditor 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Food Editor"
   ClientHeight    =   4305
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7065
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   287
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   471
   StartUpPosition =   3  'Windows Default
   Begin VB.PictureBox GraphicInventory 
      AutoRedraw      =   -1  'True
      Height          =   2100
      Left            =   120
      ScaleHeight     =   136
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   224
      TabIndex        =   19
      Top             =   1560
      Width           =   3420
      Begin VB.Shape IWearRect1 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Left            =   240
         Top             =   120
         Width           =   270
      End
      Begin VB.Shape IWearRect2 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Left            =   600
         Top             =   120
         Width           =   270
      End
      Begin VB.Shape IWearRect3 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Left            =   960
         Top             =   120
         Width           =   270
      End
      Begin VB.Shape IWearRect4 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Left            =   1320
         Top             =   120
         Width           =   270
      End
      Begin VB.Shape IWearRect5 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Left            =   1680
         Top             =   120
         Width           =   270
      End
      Begin VB.Shape IWearRect6 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Left            =   240
         Top             =   480
         Width           =   270
      End
      Begin VB.Shape IWearRect7 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Left            =   600
         Top             =   480
         Width           =   270
      End
      Begin VB.Shape IWearRect8 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Left            =   960
         Top             =   480
         Width           =   270
      End
      Begin VB.Shape IWearRect9 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Left            =   1320
         Top             =   480
         Width           =   270
      End
      Begin VB.Shape IWearRect10 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Index           =   0
         Left            =   1680
         Top             =   480
         Width           =   270
      End
      Begin VB.Shape IWearRect11 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Index           =   0
         Left            =   600
         Top             =   840
         Width           =   270
      End
      Begin VB.Shape IWearRect11 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Index           =   1
         Left            =   960
         Top             =   840
         Width           =   270
      End
      Begin VB.Shape IWearRect11 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Index           =   2
         Left            =   1320
         Top             =   840
         Width           =   270
      End
      Begin VB.Shape IWearRect11 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Index           =   3
         Left            =   1680
         Top             =   840
         Width           =   270
      End
      Begin VB.Shape IWearRect11 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Index           =   4
         Left            =   240
         Top             =   1200
         Width           =   270
      End
      Begin VB.Shape IWearRect11 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Index           =   5
         Left            =   600
         Top             =   1200
         Width           =   270
      End
      Begin VB.Shape IWearRect11 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Index           =   6
         Left            =   960
         Top             =   1200
         Width           =   270
      End
      Begin VB.Shape IWearRect11 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Index           =   7
         Left            =   1320
         Top             =   1200
         Width           =   270
      End
      Begin VB.Shape IWearRect10 
         BorderColor     =   &H00FFFF80&
         Height          =   270
         Index           =   1
         Left            =   240
         Top             =   840
         Width           =   270
      End
   End
   Begin VB.PictureBox GraphicFloorItem 
      AutoRedraw      =   -1  'True
      Height          =   2100
      Left            =   3600
      ScaleHeight     =   136
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   224
      TabIndex        =   18
      Top             =   1560
      Width           =   3420
   End
   Begin VB.TextBox FoodValue 
      Height          =   285
      Left            =   5640
      TabIndex        =   16
      Top             =   480
      Width           =   735
   End
   Begin VB.TextBox ItemName 
      Enabled         =   0   'False
      Height          =   285
      Left            =   1800
      Locked          =   -1  'True
      TabIndex        =   8
      Top             =   120
      Width           =   2655
   End
   Begin VB.TextBox Combo 
      Height          =   285
      Left            =   1800
      TabIndex        =   7
      Top             =   840
      Width           =   735
   End
   Begin VB.ComboBox CBCombo 
      Height          =   315
      Left            =   2640
      Style           =   2  'Dropdown List
      TabIndex        =   6
      Top             =   840
      Width           =   3495
   End
   Begin VB.TextBox WearLocs 
      Height          =   285
      Left            =   1560
      TabIndex        =   5
      Top             =   1200
      Width           =   1335
   End
   Begin VB.TextBox ItemType 
      Height          =   285
      Left            =   1800
      TabIndex        =   4
      Top             =   480
      Width           =   735
   End
   Begin VB.CommandButton ItemTypeEdit 
      Caption         =   "Edit"
      Height          =   285
      Left            =   2640
      TabIndex        =   3
      Top             =   480
      Width           =   1215
   End
   Begin VB.TextBox FloorGraphic 
      Height          =   285
      Left            =   4800
      TabIndex        =   2
      Top             =   1200
      Width           =   1335
   End
   Begin VB.CommandButton FloorGraphicEdit 
      Caption         =   "Edit"
      Height          =   285
      Left            =   6240
      TabIndex        =   1
      Top             =   1200
      Width           =   735
   End
   Begin VB.CommandButton ComboEdit 
      Caption         =   "Edit"
      Height          =   285
      Left            =   6240
      TabIndex        =   0
      Top             =   840
      Width           =   735
   End
   Begin VB.Label ST 
      Alignment       =   1  'Right Justify
      Caption         =   "food value:"
      Height          =   255
      Index           =   5
      Left            =   3960
      TabIndex        =   17
      Top             =   480
      Width           =   1575
   End
   Begin VB.Label ST 
      Alignment       =   1  'Right Justify
      Caption         =   "name:"
      Height          =   255
      Index           =   0
      Left            =   120
      TabIndex        =   15
      Top             =   120
      Width           =   1575
   End
   Begin VB.Label ST 
      Alignment       =   1  'Right Justify
      Caption         =   "combo:"
      Height          =   255
      Index           =   1
      Left            =   120
      TabIndex        =   14
      Top             =   840
      Width           =   1575
   End
   Begin VB.Label ST 
      Alignment       =   1  'Right Justify
      Caption         =   "wear locations:"
      Height          =   255
      Index           =   2
      Left            =   120
      TabIndex        =   13
      Top             =   1200
      Width           =   1335
   End
   Begin VB.Label ST 
      Alignment       =   1  'Right Justify
      Caption         =   "item type:"
      Height          =   255
      Index           =   3
      Left            =   120
      TabIndex        =   12
      Top             =   480
      Width           =   1575
   End
   Begin VB.Label ST 
      Alignment       =   1  'Right Justify
      Caption         =   "floor graphic:"
      Height          =   255
      Index           =   4
      Left            =   3600
      TabIndex        =   11
      Top             =   1200
      Width           =   1095
   End
   Begin MSForms.CommandButton Cancel 
      Cancel          =   -1  'True
      Height          =   375
      Left            =   5640
      TabIndex        =   10
      Top             =   3840
      Width           =   1335
      Caption         =   "Cancel"
      Size            =   "2355;661"
      FontHeight      =   165
      FontCharSet     =   0
      FontPitchAndFamily=   2
      ParagraphAlign  =   3
   End
   Begin MSForms.CommandButton Ok 
      Default         =   -1  'True
      Height          =   375
      Left            =   120
      TabIndex        =   9
      Top             =   3840
      Width           =   1335
      Caption         =   "Ok"
      Size            =   "2355;661"
      FontHeight      =   165
      FontCharSet     =   0
      FontPitchAndFamily=   2
      ParagraphAlign  =   3
   End
End
Attribute VB_Name = "FoodEditor"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public itemnum As Integer
Public obj As New obj
Public foodval As Integer
Public dlg_itemtypechooser As ItemTypeChooser
Public dlg_comboeditor As ComboEditor
Public dlg_attackeditor As AttackEditor
Public dlg_objectlist As ObjectList
Public parenttype As Integer

Public subchange As Boolean





Public Function init()
    subchange = True
    
    'graphics.resetmodifiedcolorarray
    'ImageInventory.Picture = graphics.loadgraphic(18, 0)
    'ImageChest.Picture = graphics.loadgraphic(26, 0)
    
    Dim i As Integer
    
    parenttype = 0
    For i = 1 To 44
        CBCombo.AddItem Str(i - 1) + " " + App.graphics.f560.Combo(i).tostring
    Next
    
    foodval = App.graphics.f559.FoodValue(itemnum - 156)
    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
    
    ItemName.Text = App.graphics.f556.objstring(obj.ItemType + 1)
    ItemType.Text = Str(obj.ItemType)
    Combo.Text = Str(obj.Combos)
    CBCombo.ListIndex = obj.Combos
    FoodValue.Text = Str(foodval)
    
    graphics.drawbmp GraphicInventory.hdc, 17
    graphics.drawtransparentbmpat GraphicInventory.hdc, 25, 80, 52, 8
    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_floorgraphics
    init_wearlocs
    
    subchange = False
End Function

Public Function init_floorgraphics()
    Dim num As Integer
    
    
    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 Long
    inum = graphics.f558.itemgraphicinfo(num + 1).GraphicNum + 360
    
    GraphicFloorItem.width = 2 * graphics.getgbitmapwidth(inum) + 4
    GraphicFloorItem.height = 2 * graphics.getgbitmapheight(inum) + 4
    graphics.stretchbmpby GraphicFloorItem.hdc, inum, 0, 0, 0, 0, 200, 200
    
    GraphicFloorItem.Refresh
End Function
Public Function 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 Function
Public Function point_isin(ByVal X As Integer, ByVal Y As Integer, ByVal x1 As Integer, ByVal y1 As Integer, ByVal x2 As Integer, ByVal y2 As Integer) 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


Private Sub Cancel_Click()

    unload Me
End Sub

Private Sub CBCombo_Click()
    If subchange = True Then
        Exit Sub
    End If
    
    subchange = True
    obj.Combos = CBCombo.ListIndex
    
    Combo.Text = Str(obj.Combos)
    
    subchange = False
End Sub

Private Sub Combo_Change()
    If subchange = True Then
        Exit Sub
    End If
    
    subchange = True
    obj.Combos = App.EFChange8(Combo, 0, 43)
    CBCombo.ListIndex = obj.Combos
    subchange = False
End Sub

Private Sub ComboEdit_Click()
    App.dlg_comboeditor.init
    App.dlg_comboeditor.selectcombo (obj.Combos + 1)
    App.dlg_comboeditor.Show
End Sub

Private Sub FloorGraphic_Change()
    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 FoodValue_Change()
    If subchange = True Then
        Exit Sub
    End If
    
    subchange = True
    foodval = App.EFChange16(FoodValue, 0, 65535)
    subchange = False
End Sub

Private Sub GraphicInventory_MouseDown(button As Integer, Shift As Integer, X As Single, Y As Single)
    '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 Function wearloc_f(ByVal X As Integer, ByVal Y As Integer, ByRef s As Shape)
    Dim isin As Boolean
    
    isin = point_isin(X, Y, s.Left, s.Top, s.Left + s.width, s.Top + s.height)
    
    '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 Function

Private Sub ItemType_Change()
    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()
    Set dlg_itemtypechooser = New ItemTypeChooser
    Set dlg_itemtypechooser.obj = obj
    Set dlg_itemtypechooser.textfield = ItemType
    dlg_itemtypechooser.init
    dlg_itemtypechooser.selectitem (obj.ItemType)
    dlg_itemtypechooser.Show
End Sub

Private Sub 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.setfoodvalue itemnum - 156, foodval
    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
    unload Me
End Sub

Private Sub WearLocs_Change()
    If subchange = True Then
        Exit Sub
    End If
    
    subchange = True
    obj.WearLocs = App.EFChange16(WearLocs, 0, 65535)
    init_wearlocs
    subchange = False
End Sub

