Mirage Source http://www.miragesource.net/forums/ |
|
[Feature] Visual Inventory http://www.miragesource.net/forums/viewtopic.php?f=183&t=4370 |
Page 1 of 66 |
Author: | Jacob [ Fri Sep 19, 2008 6:19 pm ] |
Post subject: | [Feature] 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 modDirectDraw7 Add the following sub: Code: Public Sub BltInventory() Dim i As Long Dim rec As DxVBLib.RECT Dim rec_pos As DxVBLib.RECT 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 = InvY + ((InvOffsetY + 32) * ((i - 1) \ 4)) .Bottom = .top + PIC_Y .Left = InvX + ((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 I would have used Engine_BltToDc but since it clears on every call it would clear out every item except the last one being draw. in Sub UpdateInventory add the following: Code: Call BltInventory For Interaction: frmMirage Add another picture box and name it picItemDesc Add a label in the picItemDesc and name it lblItemName Make picItemDesc visible = false still in frmMirage Under "Option Explicit" add: Code: Private InvPosX As Single Private InvPosY As Single Add the following Subs + Function: Code: Private Sub picVisInv_DblClick() 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 Code: Private Sub picVisInv_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 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 Code: Private Sub picVisInv_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 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 Code: 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 = InvY + ((InvOffsetY + 32) * ((i - 1) \ 4)) .Bottom = .Top + PIC_Y .Left = InvX + ((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: | Jacob [ Fri Sep 19, 2008 9:53 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
To be fair... It's still very good as is. |
Author: | Jacob [ Sat Sep 20, 2008 2:04 am ] |
Post subject: | Re: [Feature] Visual Inventory |
How would you improve this? |
Author: | Jacob [ Sat Sep 20, 2008 2:33 am ] |
Post subject: | Re: [Feature] Visual Inventory |
That's not helping to improve my code haha. You're using a custom DX8 engine you made. I'm giving people a basic visual inventory they can expand. The base code for that is very good imho. |
Author: | Egon [ Sat Sep 20, 2008 2:42 am ] |
Post subject: | Re: [Feature] Visual Inventory |
There really isn't much more Dugor can do to improve on it. It's kickass as is. |
Author: | skillzalot [ Sat Sep 20, 2008 12:45 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
I want to add this but my frmMIrage cant go any bigger to allow for this any ideas. |
Author: | Robin [ Sat Sep 20, 2008 12:55 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
Oh dear God, just stop posting. |
Author: | skillzalot [ Sat Sep 20, 2008 12:56 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
? My frmMirage wont go bigger. At all |
Author: | Robin [ Sat Sep 20, 2008 12:58 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
Awww. The fucking IDE isn't letting you drag it bigger? BAAAAAAAAAAAAW. frmMirage.width = 9001 HOLY SHIT THAT WAS FUCKING HARD WASNT IT. |
Author: | DarkC [ Sat Sep 20, 2008 3:16 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
lol Robin, that was hilarious. Try getting messages on MSN from him, that are ALL like that. =.= I've just blocked him now. |
Author: | Robin [ Sat Sep 20, 2008 3:18 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
Of course I get them. I'm always the first person to get all the retards adding me on msn. Being so godly is more of a curse than anything ;-; |
Author: | Mattyw [ Sat Sep 20, 2008 3:21 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
Robin wrote: Of course I get them. I'm always the first person to get all the retards adding me on msn. Being so godly is more of a curse than anything ;-; Doom said add you. Blame him. XD |
Author: | Nean [ Sat Sep 20, 2008 6:57 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
Yeah, I was thinking of adding Giaken, and Robin, and all the other 1337 programmers to MSN, but I know what'll happen... |
Author: | Mattyw [ Sat Sep 20, 2008 6:59 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
Well I got DFA & Robin. But Robin doesn't talk. =-p |
Author: | Robin [ Sat Sep 20, 2008 7:01 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
Nean wrote: Yeah, I was thinking of adding Giaken, and Robin, and all the other 1337 programmers to MSN, but I know what'll happen... Go ahead. I don't mind talking to people trying to learn. I do care when idiots ask me retarded shit, or just don't learn at all. I've had one guy who's asked me how to add 'the way megalith does its chat box so its like over the game sorta' 3 times now. |
Author: | Dane [ Thu Oct 16, 2008 12:51 am ] |
Post subject: | Re: [Feature] Visual Inventory |
Does this work for MS4? Because everytime I try to do this tutorial I get errors...Am i suppost to make pictures boxes 32x32 auto redraw and name it picVisInv and then picVisInv1 and so on? Or do the other option (I forgot) that names them picVisInv(0) / picVisInv(1) ... |
Author: | Dane [ Thu Oct 16, 2008 1:07 am ] |
Post subject: | Re: [Feature] Visual Inventory |
Sorry for double post but - Even when I compile without errors the pictures dont show up. |
Author: | Anthony [ Thu Oct 16, 2008 3:19 am ] |
Post subject: | Re: [Feature] Visual Inventory |
You don't need to make any picture boxes. Re read the tutorial. And if I remember correctly the inventory won't update properly by just opening it. You will have to open it and then pick up or drop an item for it to blt everything. |
Author: | Dane [ Thu Oct 16, 2008 8:38 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
frmMirage Add a Picture Box Name it picVisInv Set AutoRedraw to True and I already tried to pick up an item and it still didnt update. |
Author: | Ramsey [ Thu Oct 16, 2008 9:36 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
Quote: Add a Picture Box You only need one. |
Author: | Anthony [ Fri Oct 17, 2008 1:32 am ] |
Post subject: | Re: [Feature] Visual Inventory |
Meh, when I did this I just used the existing picInv. My mistake. |
Author: | Dane [ Tue Oct 21, 2008 6:27 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
What do I do with the existing Inventory? The text one? |
Author: | Dane [ Tue Oct 21, 2008 6:36 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
The item doesnt show up in the picture box. picVisInv AutoRedraw = True 32x32 but nothing changed../ Im going to ask again. Does this work with MS4? |
Author: | Rian [ Tue Oct 21, 2008 6:38 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
It's made specifically for MS4. That's why it's in the MS4 Tutorials section of the forums. |
Author: | Rian [ Tue Oct 21, 2008 6:42 pm ] |
Post subject: | Re: [Feature] Visual Inventory |
As far as I can tell, picVisInv needs to be larger than 32x32. picVisInv is not a box that displays an inventory item, picVisInv is THE box that displays ALL of your inventory items. |
Page 1 of 66 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |