Mirage Source
Another Visual Inventory - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49)
+---- Thread: Another Visual Inventory (/showthread.php?tid=1869)



Another Visual Inventory - Jacob - 26-06-2008

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)


Re: Another Visual Inventory - Robin - 26-06-2008

I thought this was already tutorialised >_>

Oh well, if not, as good as ever


Re: Another Visual Inventory - Jacob - 26-06-2008

[quote="Robin"]I thought this was already tutorialised >_>

Oh well, if not, as good as ever


Re: Another Visual Inventory - Jacob - 26-06-2008

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.


Re: Another Visual Inventory - Ligaman - 26-06-2008

What code do i add to use/drop item?


Re: Another Visual Inventory - Tony - 27-06-2008

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.


Re: Another Visual Inventory - Jacob - 27-06-2008

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



Re: Another Visual Inventory - Ligaman - 27-06-2008

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?


Re: Another Visual Inventory - Jacob - 27-06-2008

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


Re: Another Visual Inventory - Ligaman - 27-06-2008

Yep but i cannot click on items.


Re: Another Visual Inventory - Coke - 28-06-2008

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


Re: Another Visual Inventory - Labmonkey - 28-06-2008

lol that games owns. Big Grin