Mirage Source http://miragesource.net/forums/ |
|
Another Visual Inventory http://miragesource.net/forums/viewtopic.php?f=210&t=3899 |
Page 1 of 1 |
Author: | Jacob [ Thu Jun 26, 2008 5:43 pm ] |
Post subject: | Another Visual Inventory |
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) <= MAX_ITEMS Then With rec .top = Item(GetPlayerInvItemNum(MyIndex, i)).Pic * PIC_Y .Bottom = .top + PIC_Y .Left = 0 .Right = .Left + PIC_X End With With rec_pos .top = InvX + ((InvOffsetY + 32) * ((i - 1) \ 4)) .Bottom = .top + PIC_Y .Left = InvY + ((InvOffsetX + 32) * (((i - 1) Mod 4))) .Right = .Left + PIC_X End With Call DD_ItemSurf.BltToDC(frmMirage.picVisInv.hdc, rec, rec_pos) End If Next i frmMirage.picVisInv.Refresh End If End Sub in Sub UpdateInventory add the following: Code: Call BltInventory *Edit - Because there was a tutorial similar already I'll show how to interact with items. frmMirage Add another picture box and name it picItemDesc Add a label in the picItemDesc and name it lblItemName Make picItemDesc visible = false Under "Option Explicit" add: Code: Private InvPosX As Single Private InvPosY As Single Add the following Subs + Function: 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) <= MAX_ITEMS Then With tempRec .top = InvX + ((InvOffsetY + 32) * ((i - 1) \ 4)) .Bottom = .top + PIC_Y .Left = InvY + ((InvOffsetX + 32) * (((i - 1) Mod 4))) .Right = .Left + PIC_X End With If X >= tempRec.Left And X <= tempRec.Right Then If Y >= tempRec.top And Y <= tempRec.Bottom Then IsItem = i Exit Function End If End If End If Next i IsItem = 0 End Function If something doesn't work please let me know. |
Author: | Robin [ Thu Jun 26, 2008 5:47 pm ] |
Post subject: | Re: Another Visual Inventory |
I thought this was already tutorialised >_> Oh well, if not, as good as ever <3 Although I'm pretty sure most people were using this method anyway xD |
Author: | Jacob [ Thu Jun 26, 2008 5:54 pm ] |
Post subject: | Re: Another Visual Inventory |
Robin wrote: I thought this was already tutorialised >_> Oh well, if not, as good as ever <3 Although I'm pretty sure most people were using this method anyway xD Well if it was already a tutorial, I guess I'll add something else to mine then. |
Author: | Asrrin29 [ Thu Jun 26, 2008 6:12 pm ] |
Post subject: | Re: Another Visual Inventory |
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. |
Author: | Jacob [ Thu Jun 26, 2008 7:42 pm ] |
Post subject: | Re: Another Visual Inventory |
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. In my test client that's how I displayed the inventory. |
Author: | Asrrin29 [ Thu Jun 26, 2008 8:44 pm ] |
Post subject: | Re: Another Visual Inventory |
once I finish my resource gathering code I'll try this out and see how it looks but your screenshot looks awesome. |
Author: | Ligaman [ Thu Jun 26, 2008 10:41 pm ] |
Post subject: | Re: Another Visual Inventory |
What code do i add to use/drop item? |
Author: | Tony [ Fri Jun 27, 2008 12:53 am ] |
Post subject: | Re: Another Visual Inventory |
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. |
Author: | Jacob [ Fri Jun 27, 2008 1:27 am ] |
Post subject: | Re: Another Visual Inventory |
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 |
Author: | Ligaman [ Fri Jun 27, 2008 4:07 am ] |
Post subject: | Re: Another Visual Inventory |
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? |
Author: | Jacob [ Fri Jun 27, 2008 10:47 am ] |
Post subject: | Re: Another Visual Inventory |
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) <= MAX_ITEMS Then With tempRec .top = InvX + ((InvOffsetY + 32) * ((i - 1) \ 4)) .Bottom = .top + PIC_Y .Left = InvY + ((InvOffsetX + 32) * (((i - 1) Mod 4))) .Right = .Left + PIC_X End With If X >= tempRec.Left And X <= tempRec.Right Then If Y >= tempRec.top And Y <= tempRec.Bottom Then IsItem = i Exit Function End If End If End If Next i IsItem = 0 End Function |
Author: | Ligaman [ Fri Jun 27, 2008 3:37 pm ] |
Post subject: | Re: Another Visual Inventory |
Yep but i cannot click on items. |
Author: | Coke [ Sat Jun 28, 2008 5:34 pm ] |
Post subject: | Re: Another Visual Inventory |
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. In my test client that's how I displayed the inventory. Thats a Zelda:Lttp key xP |
Author: | Labmonkey [ Sat Jun 28, 2008 8:57 pm ] |
Post subject: | Re: Another Visual Inventory |
lol that games owns. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |