VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsCM_Item"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private Const m_cItemSep As String = "[I ¬]"
Private Const m_cNAME As String = "clsCM_Item"
Private m_nX As Long
Private m_nY As Long
Private m_nHeight As Long
Private m_nWidth As Long
Private m_sGUID As String
Private m_nStatus As Long


Public Property Get Status() As Long
    Status = m_nStatus
End Property
Public Property Let Status(nVal As Long)
    m_nStatus = nVal
End Property

Public Property Get X() As Long
    X = m_nX
End Property
Public Property Let X(nVal As Long)
    m_nX = nVal
End Property

Public Property Get Y() As Long
    Y = m_nY
End Property
Public Property Let Y(nVal As Long)
    m_nY = nVal
End Property

Public Property Get Height() As Long
    Height = m_nHeight
End Property
Public Property Let Height(nVal As Long)
    m_nHeight = nVal
End Property

Public Property Get Width() As Long
    Width = m_nWidth
End Property
Public Property Let Width(nVal As Long)
    m_nWidth = nVal
End Property

Public Property Get GUID() As String
    GUID = m_sGUID
End Property
Public Property Let GUID(nVal As String)
    m_sGUID = nVal
End Property

Public Function Serialize() As String

    On Error GoTo ErrorHandler
    Dim sRoutineName As String
    sRoutineName = m_cNAME & ".Serialize"
    Call WriteProcStart(sRoutineName)
    
    
    Serialize = X & m_cItemSep
    Serialize = Serialize & Y & m_cItemSep
    Serialize = Serialize & Height & m_cItemSep
    Serialize = Serialize & Width & m_cItemSep
    Serialize = Serialize & GUID & m_cItemSep
    Serialize = Serialize & Status & m_cItemSep
   
    
    Call WriteProcStop(sRoutineName) ' Serialize)
    'Exit the sub... on an error we will jump over this function
    Exit Function
ErrorHandler:
    Call LogErrorToFile(sRoutineName & "." & Err.Description): Call g_oErrors.HandleErrorWithSource(Err, sRoutineName): Call g_oErrors.DisplayErrorCount
    
End Function
Public Function DeSerialize(sShape As String) As String

    On Error GoTo ErrorHandler
    Dim sRoutineName As String
    sRoutineName = m_cNAME & ".DeSerialize"
    Call WriteProcStart(sRoutineName) ' sShape)


    Dim sRemStr As String
    sRemStr = sShape
    
    If Len(sShape) > 0 Then
        X() = Left(sRemStr, InStr(sRemStr, m_cItemSep) - 1)
            sRemStr = Right(sRemStr, Len(sRemStr) - InStr(sRemStr, m_cItemSep) - Len(m_cItemSep) + 1)
        Y() = Left(sRemStr, InStr(sRemStr, m_cItemSep) - 1)
            sRemStr = Right(sRemStr, Len(sRemStr) - InStr(sRemStr, m_cItemSep) - Len(m_cItemSep) + 1)
        Height = Left(sRemStr, InStr(sRemStr, m_cItemSep) - 1)
            sRemStr = Right(sRemStr, Len(sRemStr) - InStr(sRemStr, m_cItemSep) - Len(m_cItemSep) + 1)
        Width = Left(sRemStr, InStr(sRemStr, m_cItemSep) - 1)
            sRemStr = Right(sRemStr, Len(sRemStr) - InStr(sRemStr, m_cItemSep) - Len(m_cItemSep) + 1)
        GUID() = Left(sRemStr, InStr(sRemStr, m_cItemSep) - 1)
            sRemStr = Right(sRemStr, Len(sRemStr) - InStr(sRemStr, m_cItemSep) - Len(m_cItemSep) + 1)
        Status() = Left(sRemStr, InStr(sRemStr, m_cItemSep) - 1)
            sRemStr = Right(sRemStr, Len(sRemStr) - InStr(sRemStr, m_cItemSep) - Len(m_cItemSep) + 1)
    End If

    DeSerialize = sRemStr
    
    
    Call WriteProcStop(sRoutineName) ' sRemStr)
    'Exit the sub... on an error we will jump over this function
    Exit Function
ErrorHandler:
    Call LogErrorToFile(sRoutineName & "." & Err.Description): Call g_oErrors.HandleErrorWithSource(Err, sRoutineName): Call g_oErrors.DisplayErrorCount
    
End Function

Public Property Get Status_Normal() As Boolean
    Status_Normal = (Status() = 0)
End Property
Public Property Let Status_Normal(bVal As Boolean)
    If bVal = False Then
        Call Err.Raise(-1, "clsCM_Item.Status_Normal", "You cannot set a status to false, only to true.")
    Else
        Status() = 0
    End If
End Property

Public Property Get Status_Combat(nIndex As Integer) As Boolean
    Status_Combat = (Status() = 1 + nIndex)
End Property
Public Property Let Status_Combat(nIndex As Integer, bVal As Boolean)
    If bVal = False Then
        Call Err.Raise(-1, "clsCM_Item.Status_Combat", "You cannot set a status to false, only to true.")
    Else
        Status() = 1 + nIndex
    End If
End Property

Public Property Get Status_State(nIndex As Integer) As Boolean
    Status_State = (Status() = 6 + nIndex)
End Property
Public Property Let Status_State(nIndex As Integer, bVal As Boolean)
    If bVal = False Then
        Call Err.Raise(-1, "clsCM_Item.Status_State", "You cannot set a status to false, only to true.")
    Else
        Status() = 6 + nIndex
    End If
End Property
