Mirage Source

Free ORPG making software.
It is currently Fri Mar 29, 2024 5:20 am

All times are UTC


Forum rules


Make sure your tutorials are kept up to date with the latest MS4 releases.



Post new topic Reply to topic  [ 1413 posts ]  Go to page 1, 2, 3, 4, 5 ... 57  Next
Author Message
PostPosted: Fri Sep 19, 2008 6:19 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
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.


Last edited by Jacob on Mon Jan 05, 2009 3:32 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Fri Sep 19, 2008 9:53 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
To be fair... It's still very good as is.


Top
 Profile  
 
PostPosted: Sat Sep 20, 2008 2:04 am 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
How would you improve this?


Top
 Profile  
 
PostPosted: Sat Sep 20, 2008 2:33 am 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
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.


Top
 Profile  
 
PostPosted: Sat Sep 20, 2008 2:42 am 
Offline
Knowledgeable
User avatar

Joined: Sat Jun 09, 2007 3:16 am
Posts: 276
There really isn't much more Dugor can do to improve on it. It's kickass as is.

_________________
Image
Island of Lost Souls wrote:
Dr. Moreau: Mr. Parker, do you know what it means to feel like God?


Top
 Profile  
 
PostPosted: Sat Sep 20, 2008 12:45 pm 
Offline
Regular

Joined: Sat Sep 13, 2008 1:41 am
Posts: 97
I want to add this but my frmMIrage cant go any bigger to allow for this any ideas.


Top
 Profile  
 
PostPosted: Sat Sep 20, 2008 12:55 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
Oh dear God, just stop posting.

_________________
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?


Image


Top
 Profile  
 
PostPosted: Sat Sep 20, 2008 12:56 pm 
Offline
Regular

Joined: Sat Sep 13, 2008 1:41 am
Posts: 97
? My frmMirage wont go bigger. At all


Top
 Profile  
 
PostPosted: Sat Sep 20, 2008 12:58 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
Awww. The fucking IDE isn't letting you drag it bigger? BAAAAAAAAAAAAW.

frmMirage.width = 9001

HOLY SHIT

THAT WAS FUCKING HARD WASNT IT.

_________________
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?


Image


Top
 Profile  
 
PostPosted: Sat Sep 20, 2008 3:16 pm 
Offline
Regular
User avatar

Joined: Tue Jun 17, 2008 12:39 pm
Posts: 55
lol Robin, that was hilarious.

Try getting messages on MSN from him, that are ALL like that. =.= I've just blocked him now.


Top
 Profile  
 
PostPosted: Sat Sep 20, 2008 3:18 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
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 ;-;

_________________
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?


Image


Top
 Profile  
 
PostPosted: Sat Sep 20, 2008 3:21 pm 
Offline
Knowledgeable
User avatar

Joined: Fri Sep 12, 2008 11:18 pm
Posts: 176
Location: England.
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


Top
 Profile  
 
PostPosted: Sat Sep 20, 2008 6:57 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
Yeah, I was thinking of adding Giaken, and Robin, and all the other 1337 programmers to MSN, but I know what'll happen...

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
PostPosted: Sat Sep 20, 2008 6:59 pm 
Offline
Knowledgeable
User avatar

Joined: Fri Sep 12, 2008 11:18 pm
Posts: 176
Location: England.
Well I got DFA & Robin. But Robin doesn't talk. =-p


Top
 Profile  
 
PostPosted: Sat Sep 20, 2008 7:01 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
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.

_________________
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?


Image


Top
 Profile  
 
PostPosted: Thu Oct 16, 2008 12:51 am 
Offline
Regular
User avatar

Joined: Tue Sep 30, 2008 6:04 pm
Posts: 47
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) ...


Top
 Profile  
 
PostPosted: Thu Oct 16, 2008 1:07 am 
Offline
Regular
User avatar

Joined: Tue Sep 30, 2008 6:04 pm
Posts: 47
Sorry for double post but -

Even when I compile without errors the pictures dont show up.


Top
 Profile  
 
PostPosted: Thu Oct 16, 2008 3:19 am 
Offline
Pro

Joined: Mon May 29, 2006 5:01 pm
Posts: 420
Location: Canada, BC
Google Talk: anthony.fleck@gmail.com
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.


Top
 Profile  
 
PostPosted: Thu Oct 16, 2008 8:38 pm 
Offline
Regular
User avatar

Joined: Tue Sep 30, 2008 6:04 pm
Posts: 47
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.


Top
 Profile  
 
PostPosted: Thu Oct 16, 2008 9:36 pm 
Offline
Knowledgeable
User avatar

Joined: Tue Feb 06, 2007 9:50 pm
Posts: 180
Location: Bergenfield, New Jersey, US
Quote:
Add a Picture Box


You only need one.


Top
 Profile  
 
PostPosted: Fri Oct 17, 2008 1:32 am 
Offline
Pro

Joined: Mon May 29, 2006 5:01 pm
Posts: 420
Location: Canada, BC
Google Talk: anthony.fleck@gmail.com
Meh, when I did this I just used the existing picInv. My mistake.


Top
 Profile  
 
PostPosted: Tue Oct 21, 2008 6:27 pm 
Offline
Regular
User avatar

Joined: Tue Sep 30, 2008 6:04 pm
Posts: 47
What do I do with the existing Inventory? The text one?


Top
 Profile  
 
PostPosted: Tue Oct 21, 2008 6:36 pm 
Offline
Regular
User avatar

Joined: Tue Sep 30, 2008 6:04 pm
Posts: 47
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?


Top
 Profile  
 
PostPosted: Tue Oct 21, 2008 6:38 pm 
Offline
Persistant Poster
User avatar

Joined: Tue May 30, 2006 2:07 am
Posts: 836
Location: Nashville, Tennessee, USA
Google Talk: rs.ruggles@gmail.com
It's made specifically for MS4. That's why it's in the MS4 Tutorials section of the forums.

_________________
I'm on Facebook! Google Plus My Youtube Channel My Steam Profile

Image


Top
 Profile  
 
PostPosted: Tue Oct 21, 2008 6:42 pm 
Offline
Persistant Poster
User avatar

Joined: Tue May 30, 2006 2:07 am
Posts: 836
Location: Nashville, Tennessee, USA
Google Talk: rs.ruggles@gmail.com
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.

_________________
I'm on Facebook! Google Plus My Youtube Channel My Steam Profile

Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1413 posts ]  Go to page 1, 2, 3, 4, 5 ... 57  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group