Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Visual Inventory (GSD)
#1
This wasn't here, or on the old forums, Spoon sent it to me, so I posted it. ^^

Visual Inventory Tutorial
Created By: God Sent Death (Sean)

This Code Might Have Slight Bugs In It, But It Shouldnt Be Too Hard To
Figure Out How To Fix Them.

----------------------------------------------------------------------
Index
----------------------------------------------------------------------
I. Displaying The Inventory Pictures
II. Click Any PicInv() To Display The Info (Relying On The Pics Instead)
III. Removing Image When Item Dropped
IV. Bringing Back To Item One
V. Use Item Potion Fix And Updating Visual Inventory
VI. (OPTIONAL)Double Click Item To Use It
VII. Fin
----------------------------------------------------------------------


::::::::::::::::::::::
:::All In frmMirage:::
::::::::::::::::::::::


---------------------------------------
make a timer called "VisInvTimer"
interval = 50
enabled = false
---------------------------------------
make 24 picture boxes (make as many as your max inventory) all control
arrays(call them picInv)
---------------------------------------
make another picture box called picItems
AutoRedraw = true
AutoResize = true
Scale Mode = pixel
Visible = false
---------------------------------------
make 4 picture box (these will be your visual equiped items(Make as many as
you want if you got more item equipment)
name them:
ArmorImage
WeaponImage
HelmetImage
ShieldImage
---------------------------------------
Make a picture box called picInv2 (This will be the selected item picture)
---------------------------------------
make a label called IName (this will be the item name)
---------------------------------------


::::::::::::::::::::::::::::::::::
:::THIS CODE IS ALL CLIENT SIDE:::
::::::::::::::::::::::::::::::::::


----------------------------------------------------------------------
I. Displaying The Inventory Pictures
----------------------------------------------------------------------

in the modGameLogic find:
Code:
Sub GameInit()
at the very bottom of that put (above end sub though)

Code:
frmMirage.VisInvTimer.Enabled = True
frmMirage.PicItems.Picture = LoadPicture(App.Path & "\gfx\items.bmp")

double click the timer in frmMirage (the one u made) add the following:

Code:
Dim Q As Integer

On Error Resume Next
For Q = 0 To MAX_INV - 1
If PicInv(Q).Picture  LoadPicture() Then
    PicInv(Q).Picture = LoadPicture()
Else
    Call BitBlt(PicInv(Q).hdc, 0, 0, PIC_X, PIC_Y, PicItems.hdc, 0,
Item(GetPlayerInvItemNum(MyIndex, lstInv.SelCount + Q)).Pic * PIC_Y,
SRCCOPY)
End If
Next Q


----------------------------------------------------------------------
II. Click Any PicInv() To Display The Info (Relying On The Pics Instead)
----------------------------------------------------------------------

Keep your original inventory list box, just make the visble = false

double click on any picInv(), in there add:

Code:
Private Sub PicInv_Click(Index As Integer)
Dim D As Long
For D = 0 To MAX_INV - 1
On Error Resume Next
If Index = D Then
    lstInv.Selected(D) = True
    If Item(GetPlayerInvItemNum(MyIndex, lstInv.SelCount + D + e)).Name = ""
Then
        picInv2.Picture = LoadPicture()
        IName.Caption = ""
    Else
        If Item(GetPlayerInvItemNum(MyIndex, D + 1)).Type =
ITEM_TYPE_CURRENCY Then
            IName.Caption = Trim(Item(GetPlayerInvItemNum(MyIndex, D +
1)).Name) & " (" & GetPlayerInvItemValue(MyIndex, D + 1) & ")"
            Call BitBlt(PicInv2.hdc, 0, 0, PIC_X, PIC_Y, picItems.hdc, 0,
Item(GetPlayerInvItemNum(MyIndex, D + 1)).Pic * PIC_Y, SRCCOPY)
        Else
                ' Check if this item is being worn
            If GetPlayerWeaponSlot(MyIndex) = D + 1 Or
GetPlayerArmorSlot(MyIndex) = D + 1 Or GetPlayerHelmetSlot(MyIndex) = D + 1
Or GetPlayerShieldSlot(MyIndex) = D + 1 Then
                IName.Caption = Trim(Item(GetPlayerInvItemNum(MyIndex, D +
1)).Name) & " (worn)"
                Call BitBlt(PicInv2.hdc, 0, 0, PIC_X, PIC_Y, picItems.hdc,
0, Item(GetPlayerInvItemNum(MyIndex, D + 1)).Pic * PIC_Y, SRCCOPY)
            Else
                IName.Caption = Trim(Item(GetPlayerInvItemNum(MyIndex, D +
1)).Name)
                Call BitBlt(PicInv2.hdc, 0, 0, PIC_X, PIC_Y, picItems.hdc,
0, Item(GetPlayerInvItemNum(MyIndex, D + 1)).Pic * PIC_Y, SRCCOPY)
            End If
        End If
    End If
End If
Next D
End Sub


----------------------------------------------------------------------
III. Removing Image When Item Dropped
----------------------------------------------------------------------

in frmMirage double click lblDropItem
in there you will see at the bottom:

Code:
End If

right under that add:

Code:
PicInv(InvNum - 1).Picture = LoadPicture()


----------------------------------------------------------------------
IV. Bringing Back To Item One
----------------------------------------------------------------------

In frmMirage source add the following code at the very bottom:

Code:
Sub UpdateVisInv()
Dim Index As Long

For Index = 1 To MAX_INV
    If GetPlayerShieldSlot(MyIndex)  Index Then ShieldImage.Picture =
LoadPicture()
    If GetPlayerWeaponSlot(MyIndex)  Index Then WeaponImage.Picture =
LoadPicture()
    If GetPlayerHelmetSlot(MyIndex)  Index Then HelmetImage.Picture =
LoadPicture()
    If GetPlayerArmorSlot(MyIndex)  Index Then ArmorImage.Picture =
LoadPicture()
Next Index

For Index = 1 To MAX_INV
    If GetPlayerShieldSlot(MyIndex) = Index Then Call
BitBlt(ShieldImage.hdc, 0, 0, PIC_X, PIC_Y, PicItems.hdc, 0,
Item(GetPlayerInvItemNum(MyIndex, Index)).Pic * PIC_Y, SRCCOPY)
    If GetPlayerWeaponSlot(MyIndex) = Index Then Call
BitBlt(WeaponImage.hdc, 0, 0, PIC_X, PIC_Y, PicItems.hdc, 0,
Item(GetPlayerInvItemNum(MyIndex, Index)).Pic * PIC_Y, SRCCOPY)
    If GetPlayerHelmetSlot(MyIndex) = Index Then Call
BitBlt(HelmetImage.hdc, 0, 0, PIC_X, PIC_Y, PicItems.hdc, 0,
Item(GetPlayerInvItemNum(MyIndex, Index)).Pic * PIC_Y, SRCCOPY)
    If GetPlayerArmorSlot(MyIndex) = Index Then Call BitBlt(ArmorImage.hdc,
0, 0, PIC_X, PIC_Y, PicItems.hdc, 0, Item(GetPlayerInvItemNum(MyIndex,
Index)).Pic * PIC_Y, SRCCOPY)
Next Index

If GetPlayerInvItemNum(MyIndex, lstInv.SelCount) = ITEM_TYPE_NONE Then
PicInv2.Picture = LoadPicture()
IName.Caption = ""
Else
    If Item(GetPlayerInvItemNum(MyIndex, lstInv.SelCount)).Type =
ITEM_TYPE_CURRENCY Then
        IName.Caption = Trim(Item(GetPlayerInvItemNum(MyIndex,
lstInv.SelCount)).Name) & " (" & GetPlayerInvItemValue(MyIndex,
lstInv.SelCount) & ")"
    Else
        If GetPlayerWeaponSlot(MyIndex) = lstInv.SelCount Or
GetPlayerArmorSlot(MyIndex) = lstInv.SelCount Or
GetPlayerHelmetSlot(MyIndex) = lstInv.SelCount Or
GetPlayerShieldSlot(MyIndex) = lstInv.SelCount Then
            IName.Caption = Trim(Item(GetPlayerInvItemNum(MyIndex,
lstInv.SelCount)).Name) & " (worn)"
        Else
            IName.Caption = Trim(Item(GetPlayerInvItemNum(MyIndex,
lstInv.SelCount)).Name)
        End If
    End If
Call BitBlt(PicInv2.hdc, 0, 0, PIC_X, PIC_Y, PicItems.hdc, 0,
Item(GetPlayerInvItemNum(MyIndex, lstInv.SelCount)).Pic * PIC_Y, SRCCOPY)
End If
End Sub

in the drop item code at the bottom add:

Code:
Call UpdateVisInv

now in the picInventory code at the bottom add (Or whatever you have to click on to open your inventory):

Code:
Call UpdateVisInv


----------------------------------------------------------------------
V. Use Item Potion Fix And Updating Visual Inventory
----------------------------------------------------------------------

Replace all the Use Item code for:

Code:
Call SendUseItem(lstInv.ListIndex + 1)
    Call UpdateVisInv
    Dim D As Long
    For D = 1 To MAX_INV
        If Item(lstInv.ListIndex + D).Type = ITEM_TYPE_POTIONADDMP Or
ITEM_TYPE_POTIONADDHP Or ITEM_TYPE_POTIONADDSP Or ITEM_TYPE_POTIONSUBHP Or
ITEM_TYPE_POTIONSUBMP Or ITEM_TYPE_POTIONSUBSP Then
        PicInv(D - 1).Picture = LoadPicture()
        End If
    Next D


----------------------------------------------------------------------
VI. (OPTIONAL CODE)
----------------------------------------------------------------------

//DOUBLE CLICK TO USE ITEM\\

Code:
Private Sub PicInv_DblClick(Index As Integer)
    Call SendUseItem(lstInv.ListIndex + 1)
    Call UpdateVisInv
    Dim D As Long
    For D = 1 To MAX_INV
        If Item(lstInv.ListIndex + D).Type = ITEM_TYPE_POTIONADDMP Or
ITEM_TYPE_POTIONADDHP Or ITEM_TYPE_POTIONADDSP Or ITEM_TYPE_POTIONSUBHP Or
ITEM_TYPE_POTIONSUBMP Or ITEM_TYPE_POTIONSUBSP Then
        PicInv(D - 1).Picture = LoadPicture()
        End If
    Next D
End Sub

//VISUAL EQUIPMENT\\

COMING SOON!

----------------------------------------------------------------------
VII. Fin
----------------------------------------------------------------------
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)