Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Draw an Image on Inventory


Jumbofile
 Share

Recommended Posts

The reason they turn black is because the engine renders on top of them (with a black background). You'll want to figure out where these windows are being rendered and render your image to the picture boxes there.
Link to comment
Share on other sites

So here is my DrawInventory() sub, what should I change?

```
Sub DrawInventory()

Dim I As Long, X As Long, Y As Long, itemnum As Long, itempic As Long
Dim Amount As Long
Dim rec As RECT, rec_pos As RECT, srcRect As D3DRECT, destRECT As D3DRECT, BlankItemRec As RECT, BlankItemPlaceRec As RECT
Dim colour As Long
Dim tmpItem As Long, amountModifier As Long

   ' If debug mode, handle error then exit out
   If Options.Debug = 1 Then On Error GoTo errorhandler

   If Not InGame Then Exit Sub

   ' reset gold label
   'frmMain.lblGold.Caption = "0g"

   Direct3D_Device.Clear 0, ByVal 0, D3DCLEAR_TARGET, D3DColorRGBA(0, 0, 0, 0), 1#, 0
   Direct3D_Device.BeginScene

   For I = 1 To MAX_INV
       itemnum = GetPlayerInvItemNum(MyIndex, I)
                   With rec
                       .Top = 0
                       .Bottom = 32
                       .Left = 0
                       .Right = 32
                   End With

                   With rec_pos
                       .Top = InvTop + ((InvOffsetY + 32) * ((I - 1) \ InvColumns))
                       .Bottom = .Top + 32
                       .Left = InvLeft + ((InvOffsetX + 32) * (((I - 1) Mod InvColumns)))
                       .Right = .Left + 32
                   End With

                   With BlankItemRec
                       .Top = 0
                       .Bottom = 34
                       .Left = 0
                       .Right = 34
                   End With

                   With BlankItemPlaceRec
                       .Top = rec_pos.Top - 1
                       .Bottom = .Top + 34
                       .Left = rec_pos.Left - 1
                       .Right = .Left + 34

                   End With
               RenderTextureByRects Tex_Inv_Item, BlankItemRec, BlankItemPlaceRec

       If itemnum > 0 And itemnum <= MAX_ITEMS Then
                   itempic = Item(itemnum).Pic

           amountModifier = 0
           ' exit out if we're offering item in a trade.
           If InTrade > 0 Then
               For X = 1 To MAX_INV
                   tmpItem = GetPlayerInvItemNum(MyIndex, TradeYourOffer(X).num)
                   If TradeYourOffer(X).num = I Then
                       ' check if currency
                       If Not Item(tmpItem).Type = ITEM_TYPE_CURRENCY Then
                           ' normal item, exit out
                           GoTo NextLoop
                       Else
                           ' if amount = all currency, remove from inventory
                           If TradeYourOffer(X).Value = GetPlayerInvItemValue(MyIndex, I) Then
                               GoTo NextLoop
                           Else
                               ' not all, change modifier to show change in currency count
                               amountModifier = TradeYourOffer(X).Value
                           End If
                       End If
                   End If
               Next
           End If

           If itempic > 0 And itempic <= numitems Then
               If Tex_Item(itempic).Width <= 64 Then ' more than 1 frame is handled by anim sub

                   If itempic > 0 Then
                   'RenderTextureByRects Tex_Inv_Item, BlankItemRec, BlankItemPlaceRec
                   RenderTextureByRects Tex_Item(itempic), rec, rec_pos
                   'Else
                   'RenderTextureByRects Tex_Inv_Item, BlankItemRec, BlankItemPlaceRec
                   End If

                   ' If item is a stack - draw the amount you have
                   If GetPlayerInvItemValue(MyIndex, I) > 1 Then
                       Y = rec_pos.Top + 22
                       X = rec_pos.Left - 4

                       Amount = GetPlayerInvItemValue(MyIndex, I) - amountModifier

                       ' Draw currency but with k, m, b etc. using a convertion function
                       If Amount < 1000000 Then
                           colour = White
                       ElseIf Amount > 1000000 And Amount < 10000000 Then
                           colour = Yellow
                       ElseIf Amount > 10000000 Then
                           colour = BrightGreen
                       End If
                       RenderText Font_Default, Format$(ConvertCurrency(str(Amount)), "#,###,###,###"), X, Y, colour, 0
                       ' Check if it's gold, and update the label
                       If GetPlayerInvItemNum(MyIndex, I) = 1 Then '1 = gold :P
                           'frmMain.lblGold.Caption = Format$(Amount, "#,###,###,###") & "g"
                       End If
                   End If
               End If

               'End If

           End If
       End If
NextLoop:
   Next

   'update animated items
   DrawAnimatedInvItems

   With srcRect
       .x1 = 2
       .x2 = frmMain.picInventory.Width - 2
       .y1 = 0
       .y2 = frmMain.picInventory.Height + .y1
   End With

   With destRECT
       .x1 = 2
       .x2 = frmMain.picInventory.Width - 2
       .y1 = 2
       .y2 = frmMain.picInventory.Height + .y1
   End With

   Direct3D_Device.EndScene
   Direct3D_Device.Present srcRect, destRECT, frmMain.picInventory.hWnd, ByVal (0)

   ' Error handler
   Exit Sub
errorhandler:
   HandleError "DrawInventory", "modGraphics", Err.Number, Err.Description, Err.Source, Err.HelpContext
   Err.Clear
   Exit Sub
End Sub
```
Link to comment
Share on other sites

It's a little more in-depth than a single edit in that sub, as you'll need to load the UI elements in memory as well. But basically you'd want to add the rendering code after **Direct3D_Device.BeginScene**.

I don't quite have the required elements at hand here though.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...