Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another Visual Inventory
#1
This Visual Inventory uses BltToDc to draw your inventory instead of picture boxes.

All Client Side

frmMirage
Add a Picture Box
Name it picVisInv
Set AutoRedraw to True

modConstants
Add the following:
Code:
' Visual Inventory
Public Const InvX As Byte = 30
Public Const InvY As Byte = 11
Public Const InvOffsetX As Byte = 17
Public Const InvOffsetY As Byte = 16

InvX and InvY are where the first item will be drawn within the picVisInv
InvOffsetX and InvOffsetY are the offsets in between the items

modGameLogic
Add the following sub:
[code]Public Sub BltInventory()
Dim i As Long
Dim x As Long
Dim y As Long

If frmMirage.picVisInv.Visible Then
frmMirage.picVisInv.Cls

For i = 1 To MAX_INV
If GetPlayerInvItemNum(MyIndex, i) > 0 And GetPlayerInvItemNum(MyIndex, i)
Reply
#2
I thought this was already tutorialised >_>

Oh well, if not, as good as ever
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#3
[quote="Robin"]I thought this was already tutorialised >_>

Oh well, if not, as good as ever
Reply
#4
Asrrin29 Wrote:the thing with a visual inventory is that you either need to show it all at once or have a way to scroll. plus adding in all the code to interact with the items sounds really tedious.

I just added the code that interacts with the items.

[Image: ss.jpg]

In my test client that's how I displayed the inventory.
Reply
#5
What code do i add to use/drop item?
Reply
#6
Ligaman Wrote:What code do i add to use/drop item?

I remember almost 2 years ago Obsidian was guiding me and

the only way I could come up with is find the coordinates of

where I clicked.

Code:
If (x > 32 and x < 64) and (y etc..

I think that's what I did. I'm guessing that it's a

really bad way to do it.
Reply
#7
It was after the edit:

Double clicking an item will use it:
Code:
Private Sub picVisInv_DblClick()
Dim i As Long
Dim InvNum As Long

    InvNum = IsItem(InvPosX, InvPosY)
        
    If InvNum  0 Then
    
        If GetPlayerInvItemNum(MyIndex, InvNum) = ITEM_TYPE_NONE Then Exit Sub
        
        Call SendUseItem(InvNum)
        Exit Sub
    End If
                    
End Sub

Right clicking an item will drop it:
Code:
Private Sub picVisInv_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim i As Long
Dim InvNum As Long
  
    If Button = 2 Then
  
        InvNum = IsItem(X, Y)

        If InvNum  0 Then

             If Item(GetPlayerInvItemNum(MyIndex, InvNum)).Type = ITEM_TYPE_CURRENCY Then
                 frmDrop.Show vbModal
             Else
                 Call SendDropItem(InvNum, 0)
             End If
         End If
    End If
End Sub
Reply
#8
It works ok but I cant click on the items displayed neither dbl click or right click to drop.The items are unselectable.
Some help?
Reply
#9
Ligaman Wrote:It works ok but I cant click on the items displayed neither dbl click or right click to drop.The items are unselectable.
Some help?

Did you put the code in frmMirage ?

[code] Private Sub picVisInv_DblClick()
Dim i As Long
Dim InvNum As Long

InvNum = IsItem(InvPosX, InvPosY)

If InvNum 0 Then

If GetPlayerInvItemNum(MyIndex, InvNum) = ITEM_TYPE_NONE Then Exit Sub

Call SendUseItem(InvNum)
Exit Sub
End If

End Sub

Private Sub picVisInv_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim i As Long
Dim InvNum As Long

If Button = 2 Then

InvNum = IsItem(X, Y)

If InvNum 0 Then

If Item(GetPlayerInvItemNum(MyIndex, InvNum)).Type = ITEM_TYPE_CURRENCY Then
frmDrop.Show vbModal
Else
Call SendDropItem(InvNum, 0)
End If
End If
End If
End Sub

Private Sub picVisInv_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim i As Long
Dim InvNum As Long
Dim ItemNum As Long

InvPosX = X
InvPosY = Y

InvNum = IsItem(X, Y)

If InvNum 0 Then

ItemNum = GetPlayerInvItemNum(MyIndex, InvNum)

lblItemName.Caption = Trim$(Item(ItemNum).Name)

picItemDesc.top = (Y + (picItemDesc.Height * 0.5)) + picVisInv.top + 5
picItemDesc.Left = (X - picItemDesc.Width) + picVisInv.Left

picItemDesc.Visible = True
Exit Sub
End If

picItemDesc.Visible = False
End Sub

Private Function IsItem(ByVal X As Single, ByVal Y As Single) As Long
Dim tempRec As RECT
Dim i As Long

For i = 1 To MAX_INV
If GetPlayerInvItemNum(MyIndex, i) > 0 And GetPlayerInvItemNum(MyIndex, i) = tempRec.Left And X = tempRec.top And Y
Reply
#10
Yep but i cannot click on items.
Reply
#11
Dugor Wrote:
Asrrin29 Wrote:the thing with a visual inventory is that you either need to show it all at once or have a way to scroll. plus adding in all the code to interact with the items sounds really tedious.

I just added the code that interacts with the items.

[Image: ss.jpg]

In my test client that's how I displayed the inventory.

Thats a Zelda:Lttp key xP
Reply
#12
lol that games owns. Big Grin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)