Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'list of powers:
- Private powers As New List(Of TPowers)
- ...
- 'add the powers integer ID, image and display name:
- powers.Add(New TPowers(powerID_1, modFilesFolder & "Images\power1.png", "power 1"))
- powers.Add(New TPowers(powerID_2, modFilesFolder & "Images\power2.png", "power 2"))
- powers.Add(New TPowers(powerID_3, modFilesFolder & "Images\power3.png", "power 3"))
- HUD_ImageSize = New Vector2(0.05, 0.09)
- HUD_indicatorIconFile = modFilesFolder & "Images\crosshair.png"
- HUD_indicatorIconColor = Color.White
- HUD_indicatorIconSizeCoef = 1
- HUD_backGround = modFilesFolder & "Images\background.png"
- HUD_powers = powers
- HUD_nonSelectedColor = Color.FromArgb(200, 150, 150, 150)
- HUD_DescriptionPos = New Vector2(0.5, 0.9)
- ...
- 'basic class to retain powers info:
- Public Class TPowers
- Public hudImg As String
- Public powerID As Integer
- Public description As String
- Public Sub New(pPower As Integer, pImg As String, pDescription As String)
- powerID = pPower
- hudImg = pImg
- description = pDescription
- End Sub
- End Class
- ...
- 'im not using a class like i should, this is why all vars are "Shared":
- Private Shared HUD_powersSelectionHeading As Double = 0
- Private Shared HUD_powersFakeMousePos As Vector3 = New Vector3(0.5, 0.5, 0)
- Private Shared HUD_radius As Double = 0
- Public Shared bShowPowersSelectionWheel As Boolean = False
- Private Shared HUD_powers_startup As Boolean = True
- Public Shared HUD_selectedPower As Integer = 0
- Public Shared HUD_ImageSize As Vector2 = New Vector2(0.074, 0.124)
- Public Shared HUD_reset As Boolean = False
- Public Shared HUD_backGround As String = ""
- Public Shared HUD_backGroundSize As Vector2 = New Vector2(1, 1)
- Public Shared HUD_backGroundPos As Vector2 = New Vector2(0, 0)
- Public Shared HUD_indicatorIconFile As String = ""
- Public Shared HUD_indicatorIconColor As Color = Color.White
- Public Shared HUD_indicatorIconSizeCoef As Double = 1
- Public Shared HUD_powers As List(Of TPowers)
- Public Shared HUD_nonSelectedColor As Color = Color.FromArgb(150, 100, 100, 100)
- Public Shared HUD_selectedColor As Color = Color.White
- Public Shared HUD_isOff As Boolean = True
- Private Shared HUD_iniFile As CustomIniFile = Nothing
- Public Shared HUD_DescriptionPos As Vector2 = Nothing
- 'call in a tick, set bShowPowersSelectionWheel = true to show
- Public Shared Sub HUD_powerSelectionTick()
- If bShowPowersSelectionWheel Then
- If HUD_powers.Count = 0 Then
- Exit Sub
- End If
- If HUD_isOff Then
- HUD_isOff = False
- End If
- If HUD_powers_startup Then
- HUD_powers_startup = False
- HUD_iniFile = New CustomIniFile
- HUD_powersFakeMousePos.X = HUD_iniFile.settingsGetDouble("x", "HUD_powersFakeMousePos", 0.5)
- HUD_powersFakeMousePos.Y = HUD_iniFile.settingsGetDouble("y", "HUD_powersFakeMousePos", 0.5)
- HUD_powersFakeMousePos.Z = HUD_iniFile.settingsGetDouble("z", "HUD_powersFakeMousePos", 0)
- End If
- HUD_reset = True
- Game.TimeScale = 0
- toggleCameraControls(False)
- 'determine fake mouse pos
- Dim tmpX As Double = 0.5
- Dim tmpY As Double = 0.5
- Dim tmpHSpacing As Double = 360 / HUD_powers.Count
- Dim tmpHeading As Double = 0
- Dim tmpPos As Vector3 = New Vector3(tmpX, tmpY, 0)
- Dim tmpSize As Vector2 = HUD_ImageSize
- Dim tmpRadius As Double = HUD_radius
- Dim tmpIndex As Integer = 0
- Dim tmpRatio As Double = Game.ScreenResolution.Height / Game.ScreenResolution.Width
- If HUD_radius < 0.25 Then
- HUD_radius += 0.035
- End If
- HUD_powersFakeMousePos.X += getMouseChange_X(usingController) * 0.01
- HUD_powersFakeMousePos.Y += getMouseChange_Y(usingController) * 0.01
- Dim tmpFakeMousePos As Vector3 = New Vector3(HUD_powersFakeMousePos.X, HUD_powersFakeMousePos.Y, 0)
- Dim tmpCenterPos As Vector3 = New Vector3(0.5, 0.5, 0)
- Dim tmpMouseDir As Vector3 = Vector3.Normalize(tmpFakeMousePos - tmpCenterPos)
- Dim tmpMouseHeading As Double = directionToHeading(tmpMouseDir)
- Dim tmpMouse2dPos As Vector2 = New Vector2((tmpCenterPos + tmpMouseDir * tmpRadius).X, (tmpCenterPos + tmpMouseDir * tmpRadius).Y)
- Dim tmpArrowOffset As Double = 0.68
- Dim tmpArrowSize As Vector2 = New Vector2(0.0449, 0.0789) * HUD_indicatorIconSizeCoef
- Dim tmpArrowPos As Vector2 = New Vector2((tmpCenterPos + tmpMouseDir * tmpRadius * tmpArrowOffset).X, (tmpCenterPos + tmpMouseDir * tmpRadius * tmpArrowOffset).Y)
- HUD_powersFakeMousePos = tmpCenterPos + tmpMouseDir
- 'draw the arrow
- tmpArrowPos.X *= tmpRatio
- tmpArrowPos.X += 0.24 - tmpArrowSize.X
- tmpArrowPos.Y -= tmpArrowSize.Y * 0.5
- If HUD_backGround <> "" Then
- drawTextureAux(HUD_backGround, HUD_backGroundPos, HUD_backGroundSize, 0, Color.White)
- End If
- If HUD_indicatorIconFile <> "" Then
- drawTextureAux(HUD_indicatorIconFile, tmpArrowPos, tmpArrowSize, 0, HUD_indicatorIconColor)
- End If
- 'draw the hud power icons
- Dim tmpSelected As Integer = HUD_selectedPower
- Dim tmpCloserH As Double = 1000
- Dim tmpCloserPos3d As Vector3
- For Each i As TPowers In HUD_powers
- Dim tmpDir As Vector3 = HeadingToDirection(tmpHeading) * tmpRadius
- tmpDir.X *= tmpRatio
- Dim tmp As Vector3 = tmpPos + tmpDir
- tmpHeading += tmpHSpacing
- Dim tmpImgPos2d As Vector2 = New Vector2(tmp.X, tmp.Y) '+ tmpSize * 0.5
- Dim tmpImgPos3d As Vector3 = New Vector3(tmpImgPos2d.X, tmpImgPos2d.Y, 0)
- Dim tmpImgHeading As Double = directionToHeading(Vector3.Normalize(tmpImgPos3d - tmpCenterPos))
- Dim tmpHDiff As Double = Abs(headingDiff(tmpImgHeading, tmpMouseHeading))
- If (tmpHDiff < tmpCloserH) Then
- tmpCloserH = tmpHDiff
- tmpSelected = i.powerID
- tmpCloserPos3d = tmpImgPos3d
- End If
- Next
- HUD_selectedPower = tmpSelected
- tmpHeading = 0
- Dim tmpDescription As String = ""
- For Each i As TPowers In HUD_powers
- Dim tmpDir As Vector3 = HeadingToDirection(tmpHeading) * tmpRadius
- tmpDir.X *= tmpRatio
- Dim tmp As Vector3 = tmpPos + tmpDir
- tmpHeading += tmpHSpacing
- Dim tmpImgPos2d As Vector2 = New Vector2(tmp.X, tmp.Y) - tmpSize * 0.5
- If tmpSelected = i.powerID Then
- drawTextureAux(i.hudImg, New Vector2(tmp.X, tmp.Y) - tmpSize * 0.5, tmpSize, 0, HUD_selectedColor, 100, tmpIndex)
- tmpDescription = i.description
- Else
- drawTextureAux(i.hudImg, New Vector2(tmp.X, tmp.Y) - tmpSize * 0.5, tmpSize, 0, HUD_nonSelectedColor, 100, tmpIndex)
- End If
- tmpIndex += 1
- Next
- If HUD_DescriptionPos = Nothing Then
- HUD_DescriptionPos = New Vector2(0.5, 0.5)
- End If
- drawText(tmpDescription, HUD_DescriptionPos.X, HUD_DescriptionPos.Y, Color.White, True)
- Else
- If HUD_reset Then
- HUD_reset = False
- HUD_radius = 0
- Game.TimeScale = 1
- If Not HUD_iniFile Is Nothing Then
- HUD_iniFile.WriteINI("x", "HUD_powersFakeMousePos", HUD_powersFakeMousePos.X)
- HUD_iniFile.WriteINI("y", "HUD_powersFakeMousePos", HUD_powersFakeMousePos.Y)
- HUD_iniFile.WriteINI("z", "HUD_powersFakeMousePos", HUD_powersFakeMousePos.Z)
- End If
- End If
- If Not HUD_isOff Then
- HUD_isOff = True
- End If
- End If
- End Sub
Add Comment
Please, Sign In to add comment