P3D-Legacy/P3D/Screens/StatisticsScreen.vb

198 lines
8.8 KiB
VB.net
Raw Normal View History

2016-09-07 18:50:38 +02:00
Public Class StatisticsScreen
Inherits Screen
Dim Statistics As New Dictionary(Of String, Integer)
Dim texture As Texture2D
Dim TileOffset As Integer = 0
Dim Scroll As Integer = 0
Dim GJStatistics As New Dictionary(Of String, Decimal)
Dim GJGrabIndex As Integer = 0
Dim GJCanGrabNewScore As Boolean = False
Dim GJGrabDelay As Single = 0.0F
Dim StatisticsStartIndex As Integer = 0
Public Sub New(ByVal currentScreen As Screen)
Me.PreScreen = currentScreen
Me.Identification = Identifications.StatisticsScreen
Me.texture = TextureManager.GetTexture("GUI\Menus\General")
Me.CanBePaused = True
Me.CanMuteMusic = True
If Core.Player.IsGamejoltSave = True Then
StatisticsStartIndex = 2
End If
Me.LoadStatistics()
End Sub
Private Sub LoadStatistics()
If Core.Player.IsGamejoltSave = True Then
Me.Statistics.Add("Level", GameJolt.Emblem.GetPlayerLevel(Core.GameJoltSave.Points))
Me.Statistics.Add("Points", Core.GameJoltSave.Points)
End If
Dim data As String = PlayerStatistics.GetData()
For Each line As String In data.SplitAtNewline()
If line.Contains(",") = True Then
Dim statName As String = line.Remove(line.IndexOf(","))
Dim statValue As Integer = CInt(line.Remove(0, line.IndexOf(",") + 1))
If Statistics.ContainsKey(statName) = True Then
Statistics.Remove(statName)
End If
Statistics.Add(statName, statValue)
End If
Next
If Me.Statistics.Count > Me.StatisticsStartIndex Then ' And Basic.Player.IsGamejoltSave = True And GameJolt.API.LoggedIn = True
Me.GJGrabIndex = Me.StatisticsStartIndex
Me.GJCanGrabNewScore = True
End If
End Sub
Public Overrides Sub Draw()
Canvas.DrawRectangle(Core.windowSize, New Color(84, 198, 216))
For i = 0 To Me.Statistics.Count - 1
Dim ItemID As String = ""
Dim ItemIDX As Integer = 0
Dim name As String = Me.Statistics.Keys(i)
If name.StartsWith("[") = True And name.Contains("]") = True Then
ItemID = name.Remove(name.IndexOf("]")).Remove(0, 1)
ItemIDX = 40
name = name.Remove(0, name.IndexOf("]") + 1)
End If
Dim value As Integer = Me.Statistics.Values(i)
If ItemID <> "" Then
Dim Item As Item = Item.GetItemByID(CInt(ItemID))
Core.SpriteBatch.Draw(Item.Texture, New Rectangle(150, 160 + i * 50 + Scroll, 32, 32), Color.White)
End If
Core.SpriteBatch.DrawString(FontManager.MainFont, name, New Vector2(150 + ItemIDX, 160 + i * 50 + Scroll), Color.White, 0.0F, Vector2.Zero, 1.2F, SpriteEffects.None, 0.0F)
If GJStatistics.ContainsKey(Me.Statistics.Keys(i)) = True Then
Core.SpriteBatch.DrawString(FontManager.MainFont, GJStatistics(Me.Statistics.Keys(i)).ToString(), New Vector2(Core.windowSize.Width - 418, 178 + i * 50 + Scroll), Color.White, 0.0F, Vector2.Zero, 0.8F, SpriteEffects.None, 0.0F)
Core.SpriteBatch.DrawString(FontManager.MainFont, value.ToString(), New Vector2(Core.windowSize.Width - 420, 150 + i * 50 + Scroll), Color.White, 0.0F, Vector2.Zero, 1.2F, SpriteEffects.None, 0.0F)
Else
Core.SpriteBatch.DrawString(FontManager.MainFont, value.ToString(), New Vector2(Core.windowSize.Width - 420, 160 + i * 50 + Scroll), Color.White, 0.0F, Vector2.Zero, 1.2F, SpriteEffects.None, 0.0F)
End If
Canvas.DrawRectangle(New Rectangle(130, 200 + i * 50 + Scroll, Core.windowSize.Width - 360, 1), Color.White)
Next
Canvas.DrawRectangle(New Rectangle(0, 0, Core.windowSize.Width, 150), New Color(84, 198, 216))
Canvas.DrawRectangle(New Rectangle(0, Core.windowSize.Height - 100, Core.windowSize.Width, 100), New Color(84, 198, 216))
Canvas.DrawGradient(New Rectangle(50, 150, 50, 2), New Color(255, 255, 255, 0), Color.White, True, -1)
Canvas.DrawRectangle(New Rectangle(100, 150, Core.windowSize.Width - 300, 2), Color.White)
Canvas.DrawGradient(New Rectangle(Core.windowSize.Width - 200, 150, 50, 2), Color.White, New Color(255, 255, 255, 0), True, -1)
Canvas.DrawGradient(New Rectangle(Core.windowSize.Width - 450, 100, 2, 50), New Color(255, 255, 255, 0), Color.White, False, -1)
Canvas.DrawRectangle(New Rectangle(Core.windowSize.Width - 450, 150, 2, Core.windowSize.Height - 250), Color.White)
Canvas.DrawGradient(New Rectangle(Core.windowSize.Width - 450, Core.windowSize.Height - 100, 2, 50), Color.White, New Color(255, 255, 255, 0), False, -1)
Canvas.DrawGradient(New Rectangle(50, Core.windowSize.Height - 100, 50, 2), New Color(255, 255, 255, 0), Color.White, True, -1)
Canvas.DrawRectangle(New Rectangle(100, Core.windowSize.Height - 100, Core.windowSize.Width - 300, 2), Color.White)
Canvas.DrawGradient(New Rectangle(Core.windowSize.Width - 200, Core.windowSize.Height - 100, 50, 2), Color.White, New Color(255, 255, 255, 0), True, -1)
For y = -64 To Core.windowSize.Height Step 64
Core.SpriteBatch.Draw(Me.texture, New Rectangle(Core.windowSize.Width - 128, y + TileOffset, 128, 64), New Rectangle(48, 0, 16, 16), Color.White)
Next
Canvas.DrawGradient(New Rectangle(0, 0, CInt(Core.windowSize.Width), 200), New Color(42, 167, 198), New Color(42, 167, 198, 0), False, -1)
Canvas.DrawGradient(New Rectangle(0, CInt(Core.windowSize.Height - 200), CInt(Core.windowSize.Width), 200), New Color(42, 167, 198, 0), New Color(42, 167, 198), False, -1)
Core.SpriteBatch.DrawString(FontManager.MainFont, "Name", New Vector2(150, 110), Color.White, 0.0F, Vector2.Zero, 1.2F, SpriteEffects.None, 0.0F)
Core.SpriteBatch.DrawString(FontManager.MainFont, "Value", New Vector2(Core.windowSize.Width - 420, 110), Color.White, 0.0F, Vector2.Zero, 1.2F, SpriteEffects.None, 0.0F)
Core.SpriteBatch.DrawString(FontManager.MainFont, "Statistics", New Vector2(100, 24), Color.White, 0.0F, Vector2.Zero, 2.0F, SpriteEffects.None, 0.0F)
End Sub
Public Overrides Sub Update()
If Controls.Up(False, True, False, True, True, True) = True Then
If Controls.ShiftDown() = True Then
Me.Scroll += 14
Else
Me.Scroll += 7
End If
End If
If Controls.Down(False, True, False, True, True, True) = True Then
If Controls.ShiftDown() = True Then
Me.Scroll -= 14
Else
Me.Scroll -= 7
End If
End If
If Controls.Up(True, False, True, False, False, False) = True Then
If Controls.ShiftDown() = True Then
Me.Scroll += 70
Else
Me.Scroll += 35
End If
End If
If Controls.Down(True, False, True, False, False, False) = True Then
If Controls.ShiftDown() = True Then
Me.Scroll -= 70
Else
Me.Scroll -= 35
End If
End If
If -Me.Statistics.Count * 50 + Core.windowSize.Height - 250 >= 0 Then
Me.Scroll = 0
Else
Me.Scroll = Me.Scroll.Clamp(-Me.Statistics.Count * 50 + Core.windowSize.Height - 250, 0)
End If
If Me.GJCanGrabNewScore = True Then
If GJGrabDelay <= 0.0F Then
Me.GJCanGrabNewScore = False
GameJolt.GameJoltStatistics.GetStatisticValue(Me.Statistics.Keys(Me.GJGrabIndex), AddressOf Me.GetGJStatistic)
Else
GJGrabDelay -= 0.1F
End If
End If
If Controls.Dismiss() = True Then
Fix audio engine & contentpacks (#35) * Replaced existing Gen 2 SFX with better sounding ones (no ugly reverb) Replaced MediaPlayer with NAudio(and NAudio.Vorbis) for playing music in order to fix random stopping issues. The game now directly loads .ogg files instead of the .wma/.xnb combination from before. ContentPacks are now able to replace Music and SFX again (I haven't added a menu yet for choosing ContentPacks). To make older GameModes work with current versions, you can add the GameMode property EnterType and set it to "1", this will make the game use the older 2D NewGameScreen. * Delete GameController.vb * Add gamecontroller.vb back * Fix sfx missing * Battleintro doodle now doesn't loop anymore (for no trainer) Changed the shutter sound (aka Large Door sound) to something more large door-y Made the enter sound slightly louder The enter sound now plays when going through any warp to or from an indoor map (including falling through holes) The flying sound effect is played earlier in the animation after selecting a location Changed played sound effect when using the Escape Rope to "teleport" instead of "destroy" The bump noise now also plays when bumping into something in first person Fixed small gap between the end of the intro song and the start of the main song Replaced some songs with better songs * Fixed some more intro issues * Forgot to change a thing * Fixed an error where the main music would play, ignoring the muted musicmanager. * fix indenting in musicmanager * The music player will now only start playback on a new song if the music player is not muted, fixed the end time calculation of the intro of a song after muting, Music can't be unmuted now as long as a sound effect plays that stops the music. * Fixed league restplace position, fixed sound effects sharing the volume slider of the music, sound effects are now also muted when pressing M, changed music on/off popup to audio on/off, removed bump delay in first person, added more control on whether played songs should be looping or not. * Fixed some more scripts that turn on thirdperson mode but don't check if it was on before or set it back to what it was before afterwards, also fixed a small error in creditsscreen.vb. * Fixed indenting error in musicmanager.vb, fixed an error of mine where the loopsong parameter would be seen as the playintro parameter. * Added more music commands, added quite some menu select noises, will add more later * More select sound effects! * Fix music not resuming after soundeffect * Trainer using item now plays the single_heal soundeffect * Pokémon cries now sound louder * Possibly fixing crash when playing Pokémon cry at volume higher than 0.71 * Added better quality Pokémon cries, made random overworld cries slightly less loud, added cries for 719 and 720. * Sound effects now sound louder * Revert "Added better quality Pokémon cries, made random overworld cries slightly less loud, added cries for 719 and 720." This reverts commit 8c9296ed1a82144d17f303a52c3f2e9e65a5bfea. * Fixed the cause of why the title screen music plays even when the game is muted * Tabs to spaces * Revert Co-authored-by: darkfire006 <blazer257@live.com> Co-authored-by: JappaWakkaP3D <66885565+JappaWakkaP3D@users.noreply.github.com> Co-authored-by: JappaWakkaP3D <jasper.speelman@outlook.com> Co-authored-by: Vitaly Mikhailov <personal@aragas.org>
2020-07-09 19:59:42 +02:00
SoundManager.PlaySound("select")
2016-09-07 18:50:38 +02:00
Core.SetScreen(New TransitionScreen(Me, Me.PreScreen, Color.White, False))
End If
TileOffset += 1
If TileOffset >= 64 Then
TileOffset = 0
End If
End Sub
Private Sub GetGJStatistic(ByVal result As String)
Dim statName As String = Me.Statistics.Keys(Me.GJGrabIndex)
Dim statValue As String = "0"
Dim list As List(Of GameJolt.API.JoltValue) = GameJolt.API.HandleData(result)
If CBool(list(0).Value) = True Then
statValue = list(1).Value
If Me.GJStatistics.ContainsKey(statName) = True Then
Me.GJStatistics(statName) = CDec(statValue)
Else
Me.GJStatistics.Add(statName, CDec(statValue))
End If
End If
Me.GJGrabIndex += 1
If Me.GJGrabIndex > Me.Statistics.Count - 1 Then
Me.GJGrabIndex = Me.StatisticsStartIndex
Me.GJGrabDelay = 25.0F + CSng(Me.Statistics.Count)
End If
Me.GJCanGrabNewScore = True
End Sub
End Class