Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub DrawMapResource(ByVal Resource_num As Long, Optional ByVal screenShot As Boolean = False)
- Dim Resource_master As Long
- Dim Resource_state As Long
- Dim Resource_sprite As Long
- Dim rec As RECT
- Dim x As Long, y As Long
- Dim i As Long, Alpha As Long
- ' If debug mode, handle error then exit out
- If Options.Debug = 1 Then On Error GoTo errorhandler
- ' make sure it's not out of map
- If MapResource(Resource_num).x > Map.MaxX Then Exit Sub
- If MapResource(Resource_num).y > Map.MaxY Then Exit Sub
- ' Get the Resource type
- Resource_master = Map.Tile(MapResource(Resource_num).x, MapResource(Resource_num).y).data1
- If Resource_master = 0 Then Exit Sub
- If Resource(Resource_master).ResourceImage = 0 Then Exit Sub
- ' Get the Resource state
- Resource_state = MapResource(Resource_num).ResourceState
- If Resource_state = 0 Then ' normal
- Resource_sprite = Resource(Resource_master).ResourceImage
- ElseIf Resource_state = 1 Then ' used
- Resource_sprite = Resource(Resource_master).ExhaustedImage
- End If
- ' cut down everything if we're editing
- If InMapEditor Then
- Resource_sprite = Resource(Resource_master).ExhaustedImage
- End If
- ' src rect
- With rec
- .Top = 0
- .Bottom = Tex_Resource(Resource_sprite).Height
- .Left = 0
- .Right = Tex_Resource(Resource_sprite).Width
- End With
- ' Set base x + y, then the offset due to size
- x = (MapResource(Resource_num).x * PIC_X) - (Tex_Resource(Resource_sprite).Width / 2) + 16
- y = (MapResource(Resource_num).y * PIC_Y) - Tex_Resource(Resource_sprite).Height + 32
- If Options.STT = 1 Then
- ' Semi Transparent Trees :D
- For i = 1 To Player_HighIndex
- If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
- If ConvertMapY(GetPlayerY(i)) < ConvertMapY(MapResource(Resource_num).y) And ConvertMapY(GetPlayerY(i)) > ConvertMapY(MapResource(Resource_num).y) - (Tex_Resource(Resource_sprite).Height) / 32 Then
- If ConvertMapX(GetPlayerX(i)) >= ConvertMapX(MapResource(Resource_num).x) - ((Tex_Resource(Resource_sprite).Width / 2) / 32) And ConvertMapX(GetPlayerX(i)) <= ConvertMapX(MapResource(Resource_num).x) + ((Tex_Resource(Resource_sprite).Width / 2) / 32) Then
- Alpha = 150
- Else
- Alpha = 255
- End If
- Else
- Alpha = 255
- End If
- End If
- Next
- ' render it
- Call DrawResource(Resource_sprite, Alpha, x, y, rec)
- Else
- ' render it
- If Not screenShot Then
- Call DrawResource(Resource_sprite, x, y, rec)
- Else
- Call ScreenshotResource(Resource_sprite, x, y, rec)
- End If
- End If
- ' Error handler
- Exit Sub
- errorhandler:
- HandleError "DrawMapResource", "modGraphics", Err.Number, Err.Description, Err.Source, Err.HelpContext
- Err.Clear
- Exit Sub
- End Sub
- Private Sub DrawResource(ByVal Resource As Long, ByVal Alpha As Long, ByVal dX As Long, dY As Long, rec As RECT)
- Dim x As Long
- Dim y As Long
- Dim Width As Long
- Dim Height As Long
- Dim destRect As RECT
- ' If debug mode, handle error then exit out
- If Options.Debug = 1 Then On Error GoTo errorhandler
- If Resource < 1 Or Resource > NumResources Then Exit Sub
- x = ConvertMapX(dX)
- y = ConvertMapY(dY)
- Width = (rec.Right - rec.Left)
- Height = (rec.Bottom - rec.Top)
- If Options.STT = 1 Then
- RenderTexture Tex_Resource(Resource), x, y, rec.Left, rec.Top, rec.Right - rec.Left, rec.Bottom - rec.Top, rec.Right - rec.Left, rec.Bottom - rec.Top, D3DColorRGBA(255, 255, 255, Alpha)
- Else
- RenderTexture Tex_Resource(Resource), x, y, rec.Left, rec.Top, rec.Right - rec.Left, rec.Bottom - rec.Top, rec.Right - rec.Left, rec.Bottom - rec.Top, D3DColorRGBA(255, 255, 255, 255)
- End If
- ' Error handler
- Exit Sub
- errorhandler:
- HandleError "DrawResource", "modGraphics", Err.Number, Err.Description, Err.Source, Err.HelpContext
- Err.Clear
- Exit Sub
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement