From 271c407357b9144b961f75dd2dafef86d2446b61 Mon Sep 17 00:00:00 2001 From: Aragas Date: Mon, 12 Sep 2016 19:09:36 +0300 Subject: [PATCH] GPU memory leak fix --- .../Screens/Battle/BattleGrowStatsScreen.vb | 9 ++-- .../2.5DHero/Screens/BattleIntroScreen.vb | 6 +++ .../2.5DHero/Screens/GUI/DonationScreen.vb | 12 ++++- .../Screens/Inventory/ChoosePokemonScreen.vb | 42 +++++++++++------ .../Screens/Inventory/InventoryScreen.vb | 35 ++++++++++---- .../Screens/Inventory/ItemDetailScreen.vb | 17 +++++-- .../Screens/MainMenu/MainMenuScreen.vb | 19 ++++++-- .../2.5DHero/Screens/MainMenu/PauseScreen.vb | 22 +++++---- 2.5DHero/2.5DHero/Screens/NewGameScreen.vb | 16 +++++-- 2.5DHero/2.5DHero/Screens/OptionScreen.vb | 47 ++++++++++++++++--- .../Screens/Pokemon/TeachMovesScreen.vb | 8 +++- 2.5DHero/2.5DHero/Screens/SaveScreen.vb | 10 ++-- 2.5DHero/2.5DHero/Screens/TrainerScreen.vb | 18 ++++--- 13 files changed, 194 insertions(+), 67 deletions(-) diff --git a/2.5DHero/2.5DHero/Screens/Battle/BattleGrowStatsScreen.vb b/2.5DHero/2.5DHero/Screens/Battle/BattleGrowStatsScreen.vb index daafce475..23a7dcd2b 100644 --- a/2.5DHero/2.5DHero/Screens/Battle/BattleGrowStatsScreen.vb +++ b/2.5DHero/2.5DHero/Screens/Battle/BattleGrowStatsScreen.vb @@ -18,6 +18,7 @@ Public Sub New(ByVal currentScreen As Screen, ByVal p As Pokemon, ByVal OldStats() As Integer) Me.mainTexture = TextureManager.GetTexture("GUI\Menus\Menu") + CanvasTexture1 = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)) Me.PreScreen = currentScreen Me.Identification = Identifications.BattleGrowStatsScreen @@ -32,14 +33,13 @@ Me.OldStats = OldStats End Sub + Dim CanvasTexture1 As Texture2D Public Overrides Sub Draw() PreScreen.Draw() - Dim CanvasTexture As Texture2D = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)) - Dim p As New Vector2(Core.windowSize.Width - (544), 32) - Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(CInt(p.X), CInt(p.Y), 480, 352)) + Canvas.DrawImageBorder(CanvasTexture1, 2, New Rectangle(CInt(p.X), CInt(p.Y), 480, 352)) Core.SpriteBatch.Draw(Pokemon.GetMenuTexture(), New Rectangle(CInt(p.X + 20), CInt(p.Y + 20), 64, 64), Color.White) Core.SpriteBatch.DrawString(FontManager.InGameFont, Pokemon.GetDisplayName(), New Vector2(p.X + 90, p.Y + 32), Color.Black) @@ -97,4 +97,7 @@ End If End Sub + Protected Overrides Sub Finalize() + CanvasTexture1.Dispose() + End Sub End Class \ No newline at end of file diff --git a/2.5DHero/2.5DHero/Screens/BattleIntroScreen.vb b/2.5DHero/2.5DHero/Screens/BattleIntroScreen.vb index c8d1bb48a..6dffc8237 100644 --- a/2.5DHero/2.5DHero/Screens/BattleIntroScreen.vb +++ b/2.5DHero/2.5DHero/Screens/BattleIntroScreen.vb @@ -522,4 +522,10 @@ Return startTime + duration < Date.Now End Function + Protected Overrides Sub Finalize() + If Not IsNothing(blurTexture) + blurTexture.Dispose() + End If + End Sub + End Class \ No newline at end of file diff --git a/2.5DHero/2.5DHero/Screens/GUI/DonationScreen.vb b/2.5DHero/2.5DHero/Screens/GUI/DonationScreen.vb index 76246b2f6..6498aa374 100644 --- a/2.5DHero/2.5DHero/Screens/GUI/DonationScreen.vb +++ b/2.5DHero/2.5DHero/Screens/GUI/DonationScreen.vb @@ -15,6 +15,8 @@ mainTexture = TextureManager.GetTexture("House", New Rectangle(83, 98, 10, 12)) Me.scrollTexture = TextureManager.GetTexture("GUI\Menus\Menu") + texture1 = TextureManager.TextureRectangle(scrollTexture, New Rectangle(112, 12, 1, 1)) + texture2 = TextureManager.TextureRectangle(scrollTexture, New Rectangle(113, 12, 1, 1)) Dim l As New List(Of String) Dim oldL As List(Of String) = DonatorList.ToList() @@ -44,6 +46,9 @@ End If End Sub + Dim texture1 As Texture2D + Dim texture2 As Texture2D + Public Overrides Sub Draw() Me.PreScreen.Draw() Core.SpriteBatch.Draw(mainTexture, New Rectangle(CInt(Core.windowSize.Width / 2) - 285, 0, 570, 680), Color.White) @@ -59,7 +64,7 @@ Next If DonatorList.Count > 13 Then - Canvas.DrawScrollBar(New Vector2(CInt(Core.windowSize.Width / 2) + 180, 100), DonatorList.Count, 13, OffsetY, New Size(4, 500), False, TextureManager.TextureRectangle(scrollTexture, New Rectangle(112, 12, 1, 1)), TextureManager.TextureRectangle(scrollTexture, New Rectangle(113, 12, 1, 1))) + Canvas.DrawScrollBar(New Vector2(CInt(Core.windowSize.Width / 2) + 180, 100), DonatorList.Count, 13, OffsetY, New Size(4, 500), False, texture1, texture2) End If Core.SpriteBatch.DrawString(FontManager.MainFont, t, New Vector2(CInt(Core.windowSize.Width / 2) - 180, 100), Color.Black) @@ -68,4 +73,9 @@ Core.SpriteBatch.DrawString(FontManager.MainFont, Localization.GetString("donation_screen_backadvice"), New Vector2(CInt(Core.windowSize.Width / 2) - FontManager.MainFont.MeasureString("Press E to close").X / 2, 640), Color.White) End Sub + Protected Overrides Sub Finalize() + texture1.Dispose() + texture2.Dispose() + End Sub + End Class \ No newline at end of file diff --git a/2.5DHero/2.5DHero/Screens/Inventory/ChoosePokemonScreen.vb b/2.5DHero/2.5DHero/Screens/Inventory/ChoosePokemonScreen.vb index 61c567cad..257a2a445 100644 --- a/2.5DHero/2.5DHero/Screens/Inventory/ChoosePokemonScreen.vb +++ b/2.5DHero/2.5DHero/Screens/Inventory/ChoosePokemonScreen.vb @@ -44,6 +44,12 @@ Me.CanChooseFainted = canChooseFainted MainTexture = TextureManager.GetTexture("GUI\Menus\Menu") + BorderTexture1 = TextureManager.TextureRectangle(MainTexture, New Rectangle(0, 0, 48, 48), ContentPackManager.GetTextureResolution("GUI\Menus\Menu")) + BorderTexture2 = TextureManager.TextureRectangle(MainTexture, New Rectangle(0, 128, 48, 48), ContentPackManager.GetTextureResolution("GUI\Menus\Menu")) + BorderTexture3 = TextureManager.TextureRectangle(MainTexture, New Rectangle(48, 0, 48, 48), ContentPackManager.GetTextureResolution("GUI\Menus\Menu")) + BorderTexture4 = TextureManager.TextureRectangle(MainTexture, New Rectangle(48, 48, 48, 48), ContentPackManager.GetTextureResolution("GUI\Menus\Menu")) + BorderTexture5 = TextureManager.TextureRectangle(MainTexture, New Rectangle(0, 0, 48, 48), ContentPackManager.GetTextureResolution("GUI\Menus\Menu")) + Me.index = Player.Temp.PokemonScreenIndex Me.ChoosePokemon = ChoosePokemon @@ -173,10 +179,8 @@ Public Overrides Sub Draw() Me.PreScreen.Draw() - Dim CanvasTexture As Texture2D = TextureManager.TextureRectangle(MainTexture, New Rectangle(0, 0, 48, 48), ContentPackManager.GetTextureResolution("GUI\Menus\Menu")) - - Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(60, 100, 800, 480)) - Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(60, 100, 480, 64)) + Canvas.DrawImageBorder(BorderTexture1, 2, New Rectangle(60, 100, 800, 480)) + Canvas.DrawImageBorder(BorderTexture1, 2, New Rectangle(60, 100, 480, 64)) Core.SpriteBatch.DrawString(FontManager.InGameFont, Me.Title, New Vector2(142, 132), Color.Black) Core.SpriteBatch.Draw(Item.Texture, New Rectangle(78, 124, 48, 48), Color.White) @@ -207,10 +211,8 @@ TextBox.Draw() End Sub + Dim BorderTexture1 As Texture2D Private Sub DrawEmptyTile(ByVal i As Integer) - Dim BorderTexture As Texture2D - BorderTexture = TextureManager.TextureRectangle(MainTexture, New Rectangle(0, 0, 48, 48), ContentPackManager.GetTextureResolution("GUI\Menus\Menu")) - Dim p As Vector2 Select Case i Case 0, 2, 4 @@ -222,29 +224,33 @@ p.Y += 180 With Core.SpriteBatch - .Draw(BorderTexture, New Rectangle(CInt(p.X), CInt(p.Y), 32, 96), New Rectangle(0, 0, 16, 48), Color.White) + .Draw(BorderTexture1, New Rectangle(CInt(p.X), CInt(p.Y), 32, 96), New Rectangle(0, 0, 16, 48), Color.White) For x = p.X + 32 To p.X + 288 Step 32 - .Draw(BorderTexture, New Rectangle(CInt(x), CInt(p.Y), 32, 96), New Rectangle(16, 0, 16, 48), Color.White) + .Draw(BorderTexture1, New Rectangle(CInt(x), CInt(p.Y), 32, 96), New Rectangle(16, 0, 16, 48), Color.White) Next - .Draw(BorderTexture, New Rectangle(CInt(p.X) + 320, CInt(p.Y), 32, 96), New Rectangle(32, 0, 16, 48), Color.White) + .Draw(BorderTexture1, New Rectangle(CInt(p.X) + 320, CInt(p.Y), 32, 96), New Rectangle(32, 0, 16, 48), Color.White) .DrawString(FontManager.MiniFont, "EMPTY", New Vector2(CInt(p.X + 72), CInt(p.Y + 18)), Color.Black) End With End Sub + Dim BorderTexture2 As Texture2D + Dim BorderTexture3 As Texture2D + Dim BorderTexture4 As Texture2D + Dim BorderTexture5 As Texture2D Private Sub DrawPokemonTile(ByVal i As Integer, ByVal Pokemon As Pokemon) Dim BorderTexture As Texture2D If i = index Then If Pokemon.Status = net.Pokemon3D.Game.Pokemon.StatusProblems.Fainted Then - BorderTexture = TextureManager.TextureRectangle(MainTexture, New Rectangle(0, 128, 48, 48), ContentPackManager.GetTextureResolution("GUI\Menus\Menu")) + BorderTexture = BorderTexture2 Else - BorderTexture = TextureManager.TextureRectangle(MainTexture, New Rectangle(48, 0, 48, 48), ContentPackManager.GetTextureResolution("GUI\Menus\Menu")) + BorderTexture = BorderTexture3 End If Else If Pokemon.Status = net.Pokemon3D.Game.Pokemon.StatusProblems.Fainted Then - BorderTexture = TextureManager.TextureRectangle(MainTexture, New Rectangle(48, 48, 48, 48), ContentPackManager.GetTextureResolution("GUI\Menus\Menu")) + BorderTexture = BorderTexture4 Else - BorderTexture = TextureManager.TextureRectangle(MainTexture, New Rectangle(0, 0, 48, 48), ContentPackManager.GetTextureResolution("GUI\Menus\Menu")) + BorderTexture = BorderTexture5 End If End If @@ -352,4 +358,12 @@ Me.moveLearnArg = arg End Sub + Protected Overrides Sub Finalize() + BorderTexture1.Dispose() + BorderTexture2.Dispose() + BorderTexture3.Dispose() + BorderTexture4.Dispose() + BorderTexture5.Dispose() + End Sub + End Class \ No newline at end of file diff --git a/2.5DHero/2.5DHero/Screens/Inventory/InventoryScreen.vb b/2.5DHero/2.5DHero/Screens/Inventory/InventoryScreen.vb index 756f25d53..b189d2fe3 100644 --- a/2.5DHero/2.5DHero/Screens/Inventory/InventoryScreen.vb +++ b/2.5DHero/2.5DHero/Screens/Inventory/InventoryScreen.vb @@ -32,6 +32,10 @@ Me.Identification = Identifications.InventoryScreen Me.PreScreen = currentScreen Me.mainTexture = TextureManager.GetTexture("GUI\Menus\Menu") + texture1 = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)) + texture2 = TextureManager.TextureRectangle(mainTexture, New Rectangle(112, 12, 1, 1)) + texture3 = TextureManager.TextureRectangle(mainTexture, New Rectangle(113, 12, 1, 1)) + texture4 = TextureManager.TextureRectangle(mainTexture, New Rectangle(48, 0, 48, 48)) Me.ReturnItem = DoStuff Me.AllowedPages = AllowedPages @@ -229,14 +233,20 @@ ChangeBag() End Sub + Dim texture1 As Texture2D + Dim texture2 As Texture2D + Dim texture3 As Texture2D + Dim texture4 As Texture2D + + Public Overrides Sub Draw() Me.PreScreen.Draw() - Canvas.DrawImageBorder(TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)), 2, New Rectangle(60, 100, 800, 480)) - Canvas.DrawImageBorder(TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)), 2, New Rectangle(572, 100, 288, 64)) - Canvas.DrawImageBorder(TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)), 2, New Rectangle(60, 516, 480, 64)) - Canvas.DrawImageBorder(TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)), 2, New Rectangle(572, 196, 288, 384)) - Canvas.DrawImageBorder(TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)), 2, New Rectangle(620, 420, 192, 64)) + Canvas.DrawImageBorder(texture1, 2, New Rectangle(60, 100, 800, 480)) + Canvas.DrawImageBorder(texture1, 2, New Rectangle(572, 100, 288, 64)) + Canvas.DrawImageBorder(texture1, 2, New Rectangle(60, 516, 480, 64)) + Canvas.DrawImageBorder(texture1, 2, New Rectangle(572, 196, 288, 384)) + Canvas.DrawImageBorder(texture1, 2, New Rectangle(620, 420, 192, 64)) Core.SpriteBatch.Draw(TextureManager.GetTexture("GUI\Menus\BagPack"), New Rectangle(592, 126, 48, 48), New Rectangle(24 * bagIndex, 150, 24, 24), Color.White) @@ -244,7 +254,7 @@ Core.SpriteBatch.DrawString(FontManager.MiniFont, Localization.GetString("inventory_menu_backadvice"), New Vector2(1200 - FontManager.MiniFont.MeasureString(Localization.GetString("inventory_menu_backadvice")).X - 330, 580), Color.DarkGray) Core.SpriteBatch.DrawString(FontManager.MainFont, Localization.GetString("inventory_menu_items") & ":" & vbNewLine & Localization.GetString("item_category_" & Me.bagIdentifier.ToString()), New Vector2(640, 446), Color.Black) - Canvas.DrawScrollBar(New Vector2(555, 120), cItems.Count, 6, scrollIndex(bagIndex), New Size(4, 390), False, TextureManager.TextureRectangle(mainTexture, New Rectangle(112, 12, 1, 1)), TextureManager.TextureRectangle(mainTexture, New Rectangle(113, 12, 1, 1))) + Canvas.DrawScrollBar(New Vector2(555, 120), cItems.Count, 6, scrollIndex(bagIndex), New Size(4, 390), False, texture2, texture3) For i As Integer = 0 To cItems.Keys.Count - 1 Dim Item As Item = cItems.Keys(i) @@ -254,9 +264,9 @@ Dim BorderTexture As Texture2D If i = index(bagIndex) Then - BorderTexture = TextureManager.TextureRectangle(mainTexture, New Rectangle(48, 0, 48, 48)) + BorderTexture = texture4 Else - BorderTexture = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)) + BorderTexture = texture1 End If Canvas.DrawImageBorder(BorderTexture, 1, New Rectangle(CInt(p.X), CInt(p.Y + (i + scrollIndex(bagIndex)) * 70), 320, 32)) @@ -304,7 +314,7 @@ Core.SpriteBatch.DrawString(FontManager.MiniFont, "Sortmode: """ & displayMode & """", New Vector2(638, 522), Color.Gray) End If - Canvas.DrawScrollBar(New Vector2(630, 405), 8, 1, bagIndex, New Size(200, 4), True, TextureManager.TextureRectangle(mainTexture, New Rectangle(112, 12, 1, 1)), TextureManager.TextureRectangle(mainTexture, New Rectangle(113, 12, 1, 1))) + Canvas.DrawScrollBar(New Vector2(630, 405), 8, 1, bagIndex, New Size(200, 4), True, texture2, texture3) End Sub Public Overrides Sub ChangeTo() @@ -316,4 +326,11 @@ ChangeBag() End Sub + Protected Overrides Sub Finalize() + texture1.Dispose() + texture2.Dispose() + texture3.Dispose() + texture4.Dispose() + End Sub + End Class \ No newline at end of file diff --git a/2.5DHero/2.5DHero/Screens/Inventory/ItemDetailScreen.vb b/2.5DHero/2.5DHero/Screens/Inventory/ItemDetailScreen.vb index 2a3268f1d..d63d6a5d3 100644 --- a/2.5DHero/2.5DHero/Screens/Inventory/ItemDetailScreen.vb +++ b/2.5DHero/2.5DHero/Screens/Inventory/ItemDetailScreen.vb @@ -19,6 +19,8 @@ Me.canUse = canUse Me.mainTexture = TextureManager.GetTexture("GUI\Menus\Menu") + CanvasTexture1 = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)) + CanvasTexture2 = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 48, 48, 48)) End Sub Public Overrides Sub Draw() @@ -34,10 +36,10 @@ TextBox.Draw() End Sub + Dim CanvasTexture1 As Texture2D + Dim CanvasTexture2 As Texture2D Private Sub DrawItem() - Dim CanvasTexture As Texture2D = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)) - - Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(CInt(Core.windowSize.Width / 2) - 84, 64, 128, 128)) + Canvas.DrawImageBorder(CanvasTexture1, 2, New Rectangle(CInt(Core.windowSize.Width / 2) - 84, 64, 128, 128)) Core.SpriteBatch.Draw(Item.Texture, New Rectangle(CInt(Core.windowSize.Width / 2) - 56, 96, 96, 96), Color.White) End Sub @@ -49,9 +51,9 @@ Dim Text As String = MenuItems(i) If i = index Then - CanvasTexture = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 48, 48, 48)) + CanvasTexture = CanvasTexture2 Else - CanvasTexture = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)) + CanvasTexture = CanvasTexture1 End If Dim offSetX As Integer = 0 @@ -196,4 +198,9 @@ MenuItems.Add(Localization.GetString("item_detail_screen_back")) End Sub + Protected Overrides Sub Finalize() + CanvasTexture1.Dispose() + CanvasTexture2.Dispose() + End Sub + End Class \ No newline at end of file diff --git a/2.5DHero/2.5DHero/Screens/MainMenu/MainMenuScreen.vb b/2.5DHero/2.5DHero/Screens/MainMenu/MainMenuScreen.vb index aa9a37d1a..f956398a6 100644 --- a/2.5DHero/2.5DHero/Screens/MainMenu/MainMenuScreen.vb +++ b/2.5DHero/2.5DHero/Screens/MainMenu/MainMenuScreen.vb @@ -77,6 +77,11 @@ GetPacks() GameJolt.Emblem.ClearOnlineSpriteCache() + Screen.Level.World.Initialize(Screen.Level.EnvironmentType, Screen.Level.WeatherType) + texture1 = TextureManager.GetTexture("GUI\Logos\P3D") + texture2 = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(0, 48, 48, 48), "") + texture3 = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(48, 0, 48, 48), "") + texture4 = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(0, 0, 48, 48), "") End Sub Private Sub GetPacks(Optional ByVal reload As Boolean = False) @@ -228,7 +233,6 @@ Camera.Update() Level.Update() SkyDome.Update() - Screen.Level.World.Initialize(Screen.Level.EnvironmentType, Screen.Level.WeatherType) If Core.GameInstance.IsActive = True Then Select Case Me.menuIndex @@ -265,6 +269,11 @@ #Region "MainMenu" + Dim texture1 As Texture2D + Dim texture2 As Texture2D + Dim texture3 As Texture2D + Dim texture4 As Texture2D + Public Overrides Sub Draw() 'Core.GraphicsDevice.SetRenderTarget(renderTarget) @@ -308,7 +317,7 @@ End Select Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, GameController.DEVELOPER_NAME, New Vector2(7, Core.ScreenSize.Height - FontManager.InGameFont.MeasureString(GameController.DEVELOPER_NAME).Y - 1), Color.Black) Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, GameController.DEVELOPER_NAME, New Vector2(4, Core.ScreenSize.Height - FontManager.InGameFont.MeasureString(GameController.DEVELOPER_NAME).Y - 4), Color.White) - Core.SpriteBatch.DrawInterface(TextureManager.GetTexture("GUI\Logos\P3D"), New Rectangle(CInt(Core.ScreenSize.Width / 2) - 260, 40, 500, 110), Color.White) + Core.SpriteBatch.DrawInterface(texture1, New Rectangle(CInt(Core.ScreenSize.Width / 2) - 260, 40, 500, 110), Color.White) If Core.GameOptions.ShowDebug = 0 Then Dim s As String = GameController.GAMENAME & " " & GameController.GAMEDEVELOPMENTSTAGE & " " & GameController.GAMEVERSION @@ -336,12 +345,12 @@ End Select If i = mainmenuIndex Then - CanvasTexture = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(0, 48, 48, 48), "") + CanvasTexture = texture2 Else If i < 2 And Saves.Count = 0 Or i = 0 And System.IO.Directory.Exists(GameController.GamePath & "\Save\autosave") = False Then - CanvasTexture = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(48, 0, 48, 48), "") + CanvasTexture = texture3 Else - CanvasTexture = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(0, 0, 48, 48), "") + CanvasTexture = texture4 End If End If diff --git a/2.5DHero/2.5DHero/Screens/MainMenu/PauseScreen.vb b/2.5DHero/2.5DHero/Screens/MainMenu/PauseScreen.vb index 22e262f0e..ee63b7f39 100644 --- a/2.5DHero/2.5DHero/Screens/MainMenu/PauseScreen.vb +++ b/2.5DHero/2.5DHero/Screens/MainMenu/PauseScreen.vb @@ -21,6 +21,8 @@ End If Me.mainTexture = TextureManager.GetTexture("GUI\Menus\Menu") + Me.CanvasTexture1 = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 48, 48, 48)) + Me.CanvasTexture2 = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)) If Core.Player.IsGamejoltSave = True Then Me.canCreateAutosave = False @@ -87,9 +89,9 @@ #Region "MainMenu" + Dim CanvasTexture1 As Texture2D + Dim CanvasTexture2 As Texture2D Private Sub DrawMenu() - Dim CanvasTexture As Texture2D - For i = 0 To 1 Dim Text As String = "" Select Case i @@ -100,12 +102,11 @@ End Select If i = mainIndex Then - CanvasTexture = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 48, 48, 48)) + Canvas.DrawImageBorder(CanvasTexture1, 2, New Rectangle(CInt(Core.ScreenSize.Width / 2) - 180, 220 + i * 128, 320, 64), True) Else - CanvasTexture = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)) + Canvas.DrawImageBorder(CanvasTexture2, 2, New Rectangle(CInt(Core.ScreenSize.Width / 2) - 180, 220 + i * 128, 320, 64), True) End If - Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(CInt(Core.ScreenSize.Width / 2) - 180, 220 + i * 128, 320, 64), True) Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, Text, New Vector2(CInt(Core.ScreenSize.Width / 2) - (FontManager.InGameFont.MeasureString(Text).X / 2) - 10, 256 + i * 128), Color.Black) Next End Sub @@ -177,8 +178,6 @@ Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, Localization.GetString("pause_menu_confirmation"), New Vector2(pX - 7, CInt(Core.ScreenSize.Height / 6.8) + 3 + 110), Color.Black) Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, Localization.GetString("pause_menu_confirmation"), New Vector2(pX - 10, CInt(Core.ScreenSize.Height / 6.8) + 110), Color.White) - Dim CanvasTexture As Texture2D - For i = 0 To 1 Dim Text As String = "" Dim x As Integer = 0 @@ -192,12 +191,11 @@ End Select If i = quitIndex Then - CanvasTexture = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 48, 48, 48)) + Canvas.DrawImageBorder(CanvasTexture1, 2, New Rectangle(CInt(Core.ScreenSize.Width / 2) - 180 + x, 320, 320, 64), True) Else - CanvasTexture = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)) + Canvas.DrawImageBorder(CanvasTexture2, 2, New Rectangle(CInt(Core.ScreenSize.Width / 2) - 180 + x, 320, 320, 64), True) End If - Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(CInt(Core.ScreenSize.Width / 2) - 180 + x, 320, 320, 64), True) Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, Text, New Vector2(CInt(Core.ScreenSize.Width / 2) - (FontManager.InGameFont.MeasureString(Text).X / 2) - 10 + x, 356), Color.Black) Next End Sub @@ -281,4 +279,8 @@ MusicManager.ForceVolumeUpdate() End Sub + Protected Overrides Sub Finalize() + CanvasTexture1.Dispose() + CanvasTexture2.Dispose() + End Sub End Class \ No newline at end of file diff --git a/2.5DHero/2.5DHero/Screens/NewGameScreen.vb b/2.5DHero/2.5DHero/Screens/NewGameScreen.vb index bf0bade5d..031e84843 100644 --- a/2.5DHero/2.5DHero/Screens/NewGameScreen.vb +++ b/2.5DHero/2.5DHero/Screens/NewGameScreen.vb @@ -80,6 +80,9 @@ Me.Index = 0 TextBox.reDelay = 0 skinTexture = TextureManager.TextureRectangle(TextureManager.GetTexture("Textures\NPC\" & startSkins(SkinIndex)), New Rectangle(0, 64, 32, 32)) + texture0 = TextureManager.GetTexture("GUI\Menus\Menu") + texture1 = TextureManager.TextureRectangle(texture0, New Rectangle(112, 12, 1, 1)) + texture2 = TextureManager.TextureRectangle(texture0, New Rectangle(113, 12, 1, 1)) MusicManager.PlayMusic("nomusic") End Sub @@ -204,6 +207,10 @@ Index += 1 End Sub + Dim texture0 As Texture2D + Dim texture1 As Texture2D + Dim texture2 As Texture2D + Public Overrides Sub Draw() Canvas.DrawRectangle(New Rectangle(0, 0, Core.windowSize.Width, Core.windowSize.Height), currentBackColor) @@ -236,9 +243,7 @@ Core.SpriteBatch.DrawString(FontManager.MiniFont, Localization.GetString("new_game_choose_skin") & ":" & vbNewLine & skinNames(SkinIndex), New Vector2(TextboxPosition.X, TextboxPosition.Y - 24), Color.White) - Dim sTexture As Texture2D = TextureManager.GetTexture("GUI\Menus\Menu") - - Canvas.DrawScrollBar(New Vector2(TextboxPosition.X, TextboxPosition.Y + 48), startSkins.Count, 1, SkinIndex, New Size(128, 4), True, TextureManager.TextureRectangle(sTexture, New Rectangle(112, 12, 1, 1)), TextureManager.TextureRectangle(sTexture, New Rectangle(113, 12, 1, 1))) + Canvas.DrawScrollBar(New Vector2(TextboxPosition.X, TextboxPosition.Y + 48), startSkins.Count, 1, SkinIndex, New Size(128, 4), True, texture1, texture2) End Select End Sub @@ -546,4 +551,9 @@ Return Localization.GetString("new_game_oak_name_1") & name & Localization.GetString("new_game_oak_name_2") End Function + Protected Overrides Sub Finalize() + texture0.Dispose() + texture1.Dispose() + texture2.Dispose() + End Sub End Class \ No newline at end of file diff --git a/2.5DHero/2.5DHero/Screens/OptionScreen.vb b/2.5DHero/2.5DHero/Screens/OptionScreen.vb index 8fc6ea06f..7c915b4d7 100644 --- a/2.5DHero/2.5DHero/Screens/OptionScreen.vb +++ b/2.5DHero/2.5DHero/Screens/OptionScreen.vb @@ -63,12 +63,16 @@ Me.PreferMultiSampling = Core.GraphicsManager.PreferMultiSampling InitializeControls() + + texture1 = TextureManager.TextureRectangle(TextureManager.GetTexture("GUI\Menus\Menu"), New Rectangle(0, 0, 48, 48)) End Sub + Dim texture1 As Texture2D + Public Overrides Sub Draw() Me.PreScreen.Draw() - Canvas.DrawImageBorder(TextureManager.TextureRectangle(TextureManager.GetTexture("GUI\Menus\Menu"), New Rectangle(0, 0, 48, 48)), 2, New Rectangle(60, 100, 800, 480)) + Canvas.DrawImageBorder(texture1, 2, New Rectangle(60, 100, 800, 480)) Core.SpriteBatch.DrawString(FontManager.InGameFont, Me.CurrentPath, New Vector2(80, 130), Color.Black) If savedOptions = False Then @@ -483,6 +487,9 @@ Public Sub New(ByVal TriggerSub As OnToggle) Me.OnToggleTrigger = TriggerSub + + texture1 = TextureManager.TextureRectangle(TextureManager.GetTexture("GUI\Menus\Menu"), New Rectangle(0, 48, 48, 48)) + texture2 = TextureManager.TextureRectangle(TextureManager.GetTexture("GUI\Menus\Menu"), New Rectangle(0, 0, 48, 48)) End Sub Public Sub New(ByVal Position As Vector2, ByVal Size As Integer, ByVal Text As String, ByVal Toggled As Boolean, ByVal TriggerSub As OnToggle) @@ -496,13 +503,19 @@ Me._toggled = Toggled Me.OnToggleTrigger = TriggerSub Me.Settings = Settings + + texture1 = TextureManager.TextureRectangle(TextureManager.GetTexture("GUI\Menus\Menu"), New Rectangle(0, 48, 48, 48)) + texture2 = TextureManager.TextureRectangle(TextureManager.GetTexture("GUI\Menus\Menu"), New Rectangle(0, 0, 48, 48)) End Sub + Dim texture1 As Texture2D + Dim texture2 As Texture2D + Public Overrides Sub Draw() If _toggled = True Then - Canvas.DrawImageBorder(TextureManager.TextureRectangle(TextureManager.GetTexture("GUI\Menus\Menu"), New Rectangle(0, 48, 48, 48)), 2, New Rectangle(CInt(_position.X), CInt(_position.Y) + YScroll, 32 * _size, 64)) + Canvas.DrawImageBorder(texture1, 2, New Rectangle(CInt(_position.X), CInt(_position.Y) + YScroll, 32 * _size, 64)) Else - Canvas.DrawImageBorder(TextureManager.TextureRectangle(TextureManager.GetTexture("GUI\Menus\Menu"), New Rectangle(0, 0, 48, 48)), 2, New Rectangle(CInt(_position.X), CInt(_position.Y) + YScroll, 32 * _size, 64)) + Canvas.DrawImageBorder(texture2, 2, New Rectangle(CInt(_position.X), CInt(_position.Y) + YScroll, 32 * _size, 64)) End If Dim t As String = Me.Text @@ -528,6 +541,11 @@ End If End Sub + Protected Overrides Sub Finalize() + texture1.Dispose() + texture2.Dispose() + End Sub + End Class Class CommandButton @@ -570,6 +588,9 @@ Public Sub New(ByVal ClickSub As OnClick) Me.OnClickTrigger = ClickSub + + texture1 = TextureManager.TextureRectangle(TextureManager.GetTexture("GUI\Menus\Menu"), New Rectangle(48, 0, 48, 48)) + texture2 = TextureManager.TextureRectangle(TextureManager.GetTexture("GUI\Menus\Menu"), New Rectangle(0, 0, 48, 48)) End Sub Public Sub New(ByVal Position As Vector2, ByVal Size As Integer, ByVal Text As String, ByVal ClickSub As OnClick) @@ -577,15 +598,20 @@ Me._size = Size Me._text = Text Me.OnClickTrigger = ClickSub + + texture1 = TextureManager.TextureRectangle(TextureManager.GetTexture("GUI\Menus\Menu"), New Rectangle(48, 0, 48, 48)) + texture2 = TextureManager.TextureRectangle(TextureManager.GetTexture("GUI\Menus\Menu"), New Rectangle(0, 0, 48, 48)) End Sub + Dim texture1 As Texture2D + Dim texture2 As Texture2D + Public Overrides Sub Draw() Dim r As New Rectangle(CInt(_position.X), CInt(_position.Y) + YScroll, Me._size * 32 + 32, 96) - If r.Contains(MouseHandler.MousePosition) = True Then - Canvas.DrawImageBorder(TextureManager.TextureRectangle(TextureManager.GetTexture("GUI\Menus\Menu"), New Rectangle(48, 0, 48, 48)), 2, New Rectangle(CInt(_position.X), CInt(_position.Y) + YScroll, 32 * _size, 64)) + Canvas.DrawImageBorder(texture1, 2, New Rectangle(CInt(_position.X), CInt(_position.Y) + YScroll, 32 * _size, 64)) Else - Canvas.DrawImageBorder(TextureManager.TextureRectangle(TextureManager.GetTexture("GUI\Menus\Menu"), New Rectangle(0, 0, 48, 48)), 2, New Rectangle(CInt(_position.X), CInt(_position.Y) + YScroll, 32 * _size, 64)) + Canvas.DrawImageBorder(texture2, 2, New Rectangle(CInt(_position.X), CInt(_position.Y) + YScroll, 32 * _size, 64)) End If Core.SpriteBatch.DrawString(FontManager.InGameFont, Me._text, New Vector2(CInt(_position.X) + CInt(((Me._size * 32 + 20) / 2) - (FontManager.InGameFont.MeasureString(Me._text).X / 2)), CInt(_position.Y) + 32 + YScroll), Color.Black) @@ -601,6 +627,11 @@ End If End Sub + Protected Overrides Sub Finalize() + texture1.Dispose() + texture2.Dispose() + End Sub + End Class Class ScrollBar @@ -782,4 +813,8 @@ #End Region + Protected Overrides Sub Finalize() + texture1.Dispose() + End Sub + End Class \ No newline at end of file diff --git a/2.5DHero/2.5DHero/Screens/Pokemon/TeachMovesScreen.vb b/2.5DHero/2.5DHero/Screens/Pokemon/TeachMovesScreen.vb index f3b5ba169..906ca829e 100644 --- a/2.5DHero/2.5DHero/Screens/Pokemon/TeachMovesScreen.vb +++ b/2.5DHero/2.5DHero/Screens/Pokemon/TeachMovesScreen.vb @@ -48,6 +48,7 @@ LearnedMove = False Me.mainTexture = TextureManager.GetTexture("GUI\Menus\Menu") + texture1 = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)) End Sub Public Sub New(ByVal currentScreen As Screen, ByVal PokemonIndex As Integer, ByVal MovesList() As BattleSystem.Attack) @@ -106,9 +107,10 @@ Me.mainTexture = TextureManager.GetTexture("GUI\Menus\Menu") End Sub + Dim texture1 As Texture2D Public Overrides Sub Draw() Me.PreScreen.Draw() - Canvas.DrawImageBorder(TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)), 2, New Rectangle(60, 100, 800, 480)) + Canvas.DrawImageBorder(texture1, 2, New Rectangle(60, 100, 800, 480)) Core.SpriteBatch.Draw(Pokemon.GetTexture(True), New Rectangle(80, 100, 128, 128), Color.White) @@ -214,4 +216,8 @@ End If End Sub + Protected Overrides Sub Finalize() + texture1.Dispose() + End Sub + End Class \ No newline at end of file diff --git a/2.5DHero/2.5DHero/Screens/SaveScreen.vb b/2.5DHero/2.5DHero/Screens/SaveScreen.vb index 054f8b832..5acc4ef8f 100644 --- a/2.5DHero/2.5DHero/Screens/SaveScreen.vb +++ b/2.5DHero/2.5DHero/Screens/SaveScreen.vb @@ -15,11 +15,13 @@ Me.PreScreen = currentScreen Me.mainTexture = TextureManager.GetTexture("GUI\Menus\Menu") + CanvasTexture1 = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)) ChooseBox.Show({Localization.GetString("save_screen_yes"), Localization.GetString("save_screen_no")}, 0, {}) SaveGameHelpers.ResetSaveCounter() End Sub + Dim CanvasTexture1 As Texture2D Public Overrides Sub Draw() Me.PreScreen.Draw() @@ -27,9 +29,7 @@ GameJolt.Emblem.Draw(GameJolt.API.username, Core.GameJoltSave.GameJoltID, Core.GameJoltSave.Points, Core.GameJoltSave.Gender, Core.GameJoltSave.Emblem, New Vector2(CSng(Core.windowSize.Width / 2 - 256), 30), 4, Core.GameJoltSave.DownloadedSprite) End If - Dim CanvasTexture As Texture2D = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)) - - Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(168, 168, 640, 320)) + Canvas.DrawImageBorder(CanvasTexture1, 2, New Rectangle(168, 168, 640, 320)) With Core.SpriteBatch If saveSessionFailed = True Then @@ -127,4 +127,8 @@ End If End Sub + Protected Overrides Sub Finalize() + CanvasTexture1.Dispose() + End Sub + End Class \ No newline at end of file diff --git a/2.5DHero/2.5DHero/Screens/TrainerScreen.vb b/2.5DHero/2.5DHero/Screens/TrainerScreen.vb index 7d0a023f1..991f97bca 100644 --- a/2.5DHero/2.5DHero/Screens/TrainerScreen.vb +++ b/2.5DHero/2.5DHero/Screens/TrainerScreen.vb @@ -12,6 +12,7 @@ Me.PreScreen = currentScreen Me.mainTexture = TextureManager.GetTexture("GUI\Menus\Menu") + CanvasTexture1 = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)) If Screen.Level.Surfing = True Then Me.charTexture = TextureManager.GetTexture("Textures\NPC\" & Core.Player.TempSurfSkin) @@ -48,10 +49,12 @@ End If End Sub + Dim CanvasTexture1 As Texture2D + Public Overrides Sub Draw() Me.PreScreen.Draw() - Canvas.DrawImageBorder(TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)), 2, New Rectangle(60, 100, 800, 480)) + Canvas.DrawImageBorder(CanvasTexture1, 2, New Rectangle(60, 100, 800, 480)) DrawHeader() DrawContent() DrawBadges() @@ -60,15 +63,12 @@ End Sub Private Sub DrawHeader() - Dim CanvasTexture As Texture2D = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)) - Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(60, 100, 480, 64)) + Canvas.DrawImageBorder(CanvasTexture1, 2, New Rectangle(60, 100, 480, 64)) Core.SpriteBatch.Draw(mainTexture, New Rectangle(78, 124, 60, 48), New Rectangle(108, 112, 20, 16), Color.White) Core.SpriteBatch.DrawString(FontManager.InGameFont, Localization.GetString("trainer_screen_trainer_card"), New Vector2(154, 132), Color.Black) End Sub Private Sub DrawContent() - Dim CanvasTexture As Texture2D = TextureManager.TextureRectangle(mainTexture, New Rectangle(0, 0, 48, 48)) - If Core.Player.IsGameJoltSave = True Then GameJolt.Emblem.Draw(GameJolt.API.username, Core.GameJoltSave.GameJoltID, Core.GameJoltSave.Points, Core.GameJoltSave.Gender, Core.GameJoltSave.Emblem, New Vector2(80, 205), 4, Core.GameJoltSave.DownloadedSprite) @@ -116,7 +116,7 @@ Core.SpriteBatch.DrawString(FontManager.MiniFont, "$" & .Money & vbNewLine & vbNewLine & Pokedex.CountEntries(Core.Player.PokedexData, {2, 3}) & " /" & Pokedex.CountEntries(Core.Player.PokedexData, {1, 2, 3}) & vbNewLine & vbNewLine & TimeHelpers.GetDisplayTime(TimeHelpers.GetCurrentPlayTime(), True), New Vector2(700, 220), Color.DarkBlue) End With Else - Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(572, 100, 288, 288)) + Canvas.DrawImageBorder(CanvasTexture1, 2, New Rectangle(572, 100, 288, 288)) Core.SpriteBatch.DrawString(FontManager.MiniFont, Localization.GetString("trainer_screen_name") & ": " & vbNewLine & vbNewLine & Localization.GetString("trainer_screen_points") & ": " & vbNewLine & vbNewLine & Localization.GetString("trainer_screen_money") & ": " & vbNewLine & vbNewLine & Localization.GetString("trainer_screen_pokedex") & ": " & vbNewLine & vbNewLine & Localization.GetString("trainer_screen_time") & ": ", New Vector2(108, 220), Color.Black) @@ -131,7 +131,7 @@ Core.SpriteBatch.Draw(charTexture, New Rectangle(601, 126, 256, 256), Color.White) End If - Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(60, 420, 800, 160)) + Canvas.DrawImageBorder(CanvasTexture1, 2, New Rectangle(60, 420, 800, 160)) End Sub Private Sub DrawBadges() @@ -195,4 +195,8 @@ End If End Sub + Protected Overrides Sub Finalize() + CanvasTexture1.Dispose() + End Sub + End Class \ No newline at end of file