mirror of
https://github.com/P3D-Legacy/P3D-Legacy.git
synced 2025-09-26 03:18:58 +02:00
Make it possible for the scale factor to be a Single instead of always an Integer.
This commit is contained in:
parent
86ef705fa5
commit
575b48de04
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Private Shared TextureReplacements As New Dictionary(Of TextureSource, TextureSource)
|
Private Shared TextureReplacements As New Dictionary(Of TextureSource, TextureSource)
|
||||||
Private Shared FilesExist As New Dictionary(Of String, Boolean)
|
Private Shared FilesExist As New Dictionary(Of String, Boolean)
|
||||||
Private Shared TextureResolutions As New Dictionary(Of String, Integer)
|
Private Shared TextureResolutions As New Dictionary(Of String, Single)
|
||||||
|
|
||||||
Public Shared Sub Load(ByVal ContentPackFile As String)
|
Public Shared Sub Load(ByVal ContentPackFile As String)
|
||||||
If System.IO.Directory.Exists(GameController.GamePath & "\ContentPacks") = True Then
|
If System.IO.Directory.Exists(GameController.GamePath & "\ContentPacks") = True Then
|
||||||
@ -12,7 +12,7 @@
|
|||||||
Select Case Line.CountSplits("|")
|
Select Case Line.CountSplits("|")
|
||||||
Case 2 'ResolutionChange
|
Case 2 'ResolutionChange
|
||||||
Dim TextureName As String = Line.GetSplit(0, "|")
|
Dim TextureName As String = Line.GetSplit(0, "|")
|
||||||
Dim Resolution As Integer = CInt(Line.GetSplit(1, "|"))
|
Dim Resolution As Single = CInt(Line.GetSplit(1, "|"))
|
||||||
|
|
||||||
If TextureResolutions.ContainsKey(TextureName) = False Then
|
If TextureResolutions.ContainsKey(TextureName) = False Then
|
||||||
TextureResolutions.Add(TextureName, Resolution)
|
TextureResolutions.Add(TextureName, Resolution)
|
||||||
@ -45,7 +45,7 @@
|
|||||||
Return TextureSource
|
Return TextureSource
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Shared Function GetTextureResolution(ByVal TextureName As String) As Integer
|
Public Shared Function GetTextureResolution(ByVal TextureName As String) As Single
|
||||||
For i = 0 To TextureResolutions.Count - 1
|
For i = 0 To TextureResolutions.Count - 1
|
||||||
If TextureResolutions.Keys(i).ToLower() = TextureName.ToLower() Then
|
If TextureResolutions.Keys(i).ToLower() = TextureName.ToLower() Then
|
||||||
Return TextureResolutions.Values(i)
|
Return TextureResolutions.Values(i)
|
||||||
|
@ -82,7 +82,7 @@ Public Class TextureManager
|
|||||||
Dim tSource As TextureSource = ContentPackManager.GetTextureReplacement(TexturePath & Name, r)
|
Dim tSource As TextureSource = ContentPackManager.GetTextureReplacement(TexturePath & Name, r)
|
||||||
|
|
||||||
Dim cContent As ContentManager = ContentPackManager.GetContentManager(tSource.TexturePath, ".xnb,.png")
|
Dim cContent As ContentManager = ContentPackManager.GetContentManager(tSource.TexturePath, ".xnb,.png")
|
||||||
Dim resolution As Integer = ContentPackManager.GetTextureResolution(TexturePath & Name)
|
Dim resolution As Single = ContentPackManager.GetTextureResolution(TexturePath & Name)
|
||||||
|
|
||||||
Dim tKey As String = cContent.RootDirectory & "\" & tSource.TexturePath & "," & tSource.TextureRectangle.X & "," & tSource.TextureRectangle.Y & "," & tSource.TextureRectangle.Width & "," & tSource.TextureRectangle.Height & "," & resolution
|
Dim tKey As String = cContent.RootDirectory & "\" & tSource.TexturePath & "," & tSource.TextureRectangle.X & "," & tSource.TextureRectangle.Y & "," & tSource.TextureRectangle.Width & "," & tSource.TextureRectangle.Height & "," & resolution
|
||||||
If TextureList.ContainsKey(tKey) = False Then
|
If TextureList.ContainsKey(tKey) = False Then
|
||||||
@ -135,7 +135,7 @@ Public Class TextureManager
|
|||||||
Return GetTexture(Name, r, "Textures\")
|
Return GetTexture(Name, r, "Textures\")
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Shared Function GetTexture(ByVal Texture As Texture2D, ByVal Rectangle As Rectangle, Optional ByVal Factor As Integer = 1) As Texture2D
|
Public Shared Function GetTexture(ByVal Texture As Texture2D, ByVal Rectangle As Rectangle, Optional ByVal Factor As Single = 1) As Texture2D
|
||||||
Dim tex As Texture2D = Nothing
|
Dim tex As Texture2D = Nothing
|
||||||
|
|
||||||
If TextureRectList.TryGetValue(New KeyValuePair(Of Int32, Rectangle)(Texture.GetHashCode(), Rectangle), tex) Then
|
If TextureRectList.TryGetValue(New KeyValuePair(Of Int32, Rectangle)(Texture.GetHashCode(), Rectangle), tex) Then
|
||||||
@ -148,11 +148,11 @@ Public Class TextureManager
|
|||||||
Return tex
|
Return tex
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Shared Function TextureRectangle(ByVal Texture As Texture2D, ByVal Rectangle As Rectangle, Optional ByVal Factor As Integer = 1) As Texture2D
|
Private Shared Function TextureRectangle(ByVal Texture As Texture2D, ByVal Rectangle As Rectangle, Optional ByVal Factor As Single = 1) As Texture2D
|
||||||
If Rectangle = Rectangle.Empty Then
|
If Rectangle = Rectangle.Empty Then
|
||||||
Return Texture
|
Return Texture
|
||||||
Else
|
Else
|
||||||
Rectangle = New Rectangle(Rectangle.X * Factor, Rectangle.Y * Factor, Rectangle.Width * Factor, Rectangle.Height * Factor)
|
Rectangle = New Rectangle(CInt(Rectangle.X * Factor), CInt(Rectangle.Y * Factor), CInt(Rectangle.Width * Factor), CInt(Rectangle.Height * Factor))
|
||||||
|
|
||||||
Dim tRectangle As New Rectangle(0, 0, Texture.Width, Texture.Height)
|
Dim tRectangle As New Rectangle(0, 0, Texture.Width, Texture.Height)
|
||||||
If tRectangle.Contains(Rectangle) = False Then
|
If tRectangle.Contains(Rectangle) = False Then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user