Implemented Notification system

This commit is contained in:
JappaWakka 2021-10-09 23:05:56 +02:00
parent 88fc909529
commit 464e1d8c31
8 changed files with 269 additions and 11 deletions

View File

@ -90,6 +90,15 @@ Special_Attack,Special Attack
Special_Defense,Special Defense Special_Defense,Special Defense
Speed,Speed Speed,Speed
--- ---
GameInteractions:
game_interaction_interact,Interact
game_interaction_gamemenu,Game Menu
game_interaction_pokegear,Pokégear
game_interaction_pausemenu,Pause Menu
game_interaction_notification,Notification
game_notification_respond,Press <button.special> to respond to the notification.
game_notification_dismiss,Press <button.special> to dismiss the notification.
---
MainMenuScreen: MainMenuScreen:
main_menu_continue,Continue main_menu_continue,Continue
main_menu_load_game,Load Game main_menu_load_game,Load Game

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

View File

@ -0,0 +1,176 @@
''' <summary>
''' The notification popup.
''' </summary>
Public Class NotificationPopup
Private _background As Texture2D
Private _box As Texture2D
Private _icon As Texture2D
Private FrameSizeBack As Integer
Private FramesizeBox As Integer
Private FramesizeIcon As Integer
Private _positionY As Single = -12
Private _delay As Date
Private _soundEffect As String = ""
Private _text As String = ""
Private _size As Size = New Size(10, 3)
Private _backgroundIndex As Vector2 = New Vector2(0, 0)
Private _iconIndex As Vector2 = New Vector2(0, 0)
Public _waitForInput As Boolean = False
Public _scriptFile As String = ""
Public _show As Boolean = False
''' <summary>
''' Sets the values of the NotificationPopup and displays it on the screen.
''' </summary>
Public Sub Setup(Text As String, Optional Delay As Integer = 500, Optional BackgroundIndex As Integer = 0, Optional IconIndex As Integer = 0, Optional SoundEffect As String = "", Optional ScriptFile As String = "")
_text = Text
If Delay <= 0 Then
_waitForInput = True
_delay = Date.Now
Else
_delay = Date.Now.AddMilliseconds(CDbl(Delay * 10))
End If
_backgroundIndex = New Vector2(BackgroundIndex, 0)
While _backgroundIndex.X >= 3
_backgroundIndex.X -= 3
_backgroundIndex.Y += 1
End While
If _backgroundIndex.X < 0 Then
_backgroundIndex.X = 0
End If
FrameSizeBack = CInt(TextureManager.GetTexture(GameModeManager.ActiveGameMode.ContentPath & "Textures\Notifications\Backgrounds").Width / 3)
_background = TextureManager.GetTexture(GameModeManager.ActiveGameMode.ContentPath & "Textures\Notifications\Backgrounds", New Rectangle(CInt(_backgroundIndex.X * FrameSizeBack), CInt(_backgroundIndex.Y * FrameSizeBack), FrameSizeBack, FrameSizeBack))
_positionY = CInt(0 - _size.Height * (FrameSizeBack / 3) - 12)
FramesizeBox = CInt(TextureManager.GetTexture(GameModeManager.ActiveGameMode.ContentPath & "Textures\Notifications\Boxes").Width / 3)
_box = TextureManager.GetTexture(GameModeManager.ActiveGameMode.ContentPath & "Textures\Notifications\Backgrounds", New Rectangle(CInt(_backgroundIndex.X * FramesizeBox), CInt(_backgroundIndex.Y * FramesizeBox), FramesizeBox, FramesizeBox))
FramesizeIcon = CInt(TextureManager.GetTexture(GameModeManager.ActiveGameMode.ContentPath & "Textures\Notifications\Icons").Width / 3)
_iconIndex = New Vector2(IconIndex, 0)
While _iconIndex.X >= 3
_iconIndex.X -= 3
_iconIndex.Y += 1
End While
If _iconIndex.X < 0 Then
_iconIndex.X = 0
End If
_icon = TextureManager.GetTexture(GameModeManager.ActiveGameMode.ContentPath & "Textures\Notifications\Icons", New Rectangle(CInt(_iconIndex.X * FramesizeIcon), CInt(_iconIndex.Y * FramesizeIcon), FramesizeIcon, FramesizeIcon))
_scriptFile = ScriptFile
If Me._scriptFile <> "" Then
Me._text &= "~[" & Localization.GetString("game_notification_respond") & "]"
Else
Me._text &= "~[" & Localization.GetString("game_notification_dismiss") & "]"
End If
_soundEffect = SoundEffect
_show = True
End Sub
''' <summary>
''' Execute the specified script
''' </summary>
Public Sub Accept()
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(_scriptFile, 0, False)
Me._waitForInput = False
Me._delay = Date.Now
End Sub
''' <summary>
''' Dismiss the Popup
''' </summary>
Public Sub Dismiss()
Me._waitForInput = False
Me._delay = Date.Now
End Sub
''' <summary>
''' Update the NotificationPopup.
''' </summary>
Public Sub Update()
If Date.Now < Me._delay Then
If Me._positionY < 5.0F Then
Me._positionY += CInt(0.7 * (FrameSizeBack / _size.Height))
Else
If _soundEffect IsNot "" Then
SoundManager.PlaySound("Notifications\" & _soundEffect)
_soundEffect = ""
End If
End If
Else
If _waitForInput = False Then
Dim BackY As Integer = CInt(0 - _size.Height * FrameSizeBack - 12)
If Me._positionY > BackY Then
Me._positionY -= CInt(0.7 * (FrameSizeBack / _size.Height))
If Me._positionY <= BackY Then
Me._positionY = BackY
Me._show = False
End If
End If
Else
If Me._scriptFile <> "" Then
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(Me._scriptFile, 0, False)
Me._waitForInput = False
End If
End If
End If
End Sub
''' <summary>
''' Renders the NotificationPopup.
''' </summary>
Public Sub Draw()
If Me._show = True Then
Dim TextBody As String = ""
Dim TextHeader As String
Dim Scale As Double = SpriteBatch.InterfaceScale() * 2
If _text.Contains("*") Then
TextHeader = _text.GetSplit(0, "*").Replace(CChar("~"), Environment.NewLine)
TextBody = _text.GetSplit(1, "*").Replace(CChar("~"), Environment.NewLine)
Else
TextHeader = _text.Replace(CChar("~"), Environment.NewLine)
End If
While FontManager.InGameFont.MeasureString(_text.Replace(CChar("~"), Environment.NewLine)).Y > CInt(_size.Height * FrameSizeBack - 2 * FrameSizeBack)
_size.Height += 1
End While
Dim BackGroundOffsetX As Integer = CInt(Core.windowSize.Width - _size.Width * FrameSizeBack - 5)
Dim TextOffset As Integer
'Draw the frame.
Canvas.DrawImageBorder(_background, CInt(Scale), New Rectangle(BackGroundOffsetX, CInt(Me._positionY), CInt(_size.Width * FrameSizeBack), CInt(_size.Height * FrameSizeBack)), True)
'Draw the (icon) box.
Core.SpriteBatch.DrawInterface(_box, New Rectangle(CInt(FramesizeBox * Scale + 5), CInt(FramesizeBox * Scale + Me._positionY), CInt(_box.Width * Scale), CInt(_box.Height * Scale)), Color.White)
'Draw the icon.
Core.SpriteBatch.DrawInterface(_icon, New Rectangle(CInt(FramesizeIcon * Scale + 5), CInt(FramesizeIcon * Scale + Me._positionY), CInt(_icon.Width * Scale), CInt(_icon.Height * Scale)), Color.White)
TextOffset = CInt(FrameSizeBack * Scale + BackGroundOffsetX * Scale)
If TextBody <> "" Then
If TextHeader <> "" Then
'Draw the header, then the body
Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, TextBody.CropStringToWidth(FontManager.InGameFont, CInt(Scale), CInt(_size.Width * FrameSizeBack - FrameSizeBack * 4)), New Vector2(TextOffset, CInt(Me._positionY + FrameSizeBack)), Color.Black)
Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, TextHeader.CropStringToWidth(FontManager.InGameFont, CInt(Scale / 2), CInt(_size.Width * FrameSizeBack - FrameSizeBack * 4)), New Vector2(TextOffset, CInt(Me._positionY + FrameSizeBack + FontManager.InGameFont.MeasureString(TextHeader).Y)), Color.Black)
Else
'Just draw the body
Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, TextBody.CropStringToWidth(FontManager.InGameFont, CInt(Scale / 2), CInt(_size.Width * FrameSizeBack - FrameSizeBack * 4)), New Vector2(TextOffset, CInt(Me._positionY + FrameSizeBack)), Color.Black)
End If
Else
'Just draw the header
Core.SpriteBatch.DrawInterfaceString(FontManager.InGameFont, TextHeader.CropStringToWidth(FontManager.InGameFont, CInt(Scale), CInt(_size.Width * FrameSizeBack) - FrameSizeBack * 4), New Vector2(TextOffset, CInt(Me._positionY + FrameSizeBack)), Color.Black)
End If
End If
End Sub
End Class

View File

@ -12,6 +12,7 @@ Public Class OverworldScreen
Private Shared _fadeColor As Color = Color.Black 'Fade screen color. Private Shared _fadeColor As Color = Color.Black 'Fade screen color.
Private Shared _fadeValue As Integer = 0 'Fade progress value for the screen fade. Private Shared _fadeValue As Integer = 0 'Fade progress value for the screen fade.
Private Shared _drawRodID As Integer = -1 'The rod ID to display on the screen during the fishing animation. Private Shared _drawRodID As Integer = -1 'The rod ID to display on the screen during the fishing animation.
Public NotificationPopupList As List(Of NotificationPopup) = Nothing
Private _actionScript As ActionScript 'Private ActionScript instance. Private _actionScript As ActionScript 'Private ActionScript instance.
Private _particlesTexture As Texture2D 'A texture field to contain the particles texture, currently only used for the crosshair. Private _particlesTexture As Texture2D 'A texture field to contain the particles texture, currently only used for the crosshair.
@ -188,6 +189,16 @@ Public Class OverworldScreen
PokemonImageView.Update() PokemonImageView.Update()
End If End If
If Level.NotificationPopup IsNot Nothing Then
Level.NotificationPopup.Update()
If Level.NotificationPopup._show = False Then
Level.NotificationPopup = Nothing
End If
ElseIf NotificationPopupList.Count > 0 Then
Level.NotificationPopup = NotificationPopupList(0)
NotificationPopupList.RemoveAt(0)
End If
'Middle click/Thumbstick press: Show first Pokémon in party. 'Middle click/Thumbstick press: Show first Pokémon in party.
If ActionScript.IsReady = True Then If ActionScript.IsReady = True Then
If MouseHandler.ButtonPressed(MouseHandler.MouseButtons.MiddleButton) = True Or ControllerHandler.ButtonPressed(Buttons.LeftStick) = True Then If MouseHandler.ButtonPressed(MouseHandler.MouseButtons.MiddleButton) = True Or ControllerHandler.ButtonPressed(Buttons.LeftStick) = True Then
@ -217,7 +228,6 @@ Public Class OverworldScreen
If KeyBoardHandler.KeyPressed(KeyBindings.OpenInventoryKey) = True Or ControllerHandler.ButtonPressed(Buttons.X) = True Then If KeyBoardHandler.KeyPressed(KeyBindings.OpenInventoryKey) = True Or ControllerHandler.ButtonPressed(Buttons.X) = True Then
If Screen.Camera.IsMoving() = False And ActionScript.IsReady = True Then If Screen.Camera.IsMoving() = False And ActionScript.IsReady = True Then
Level.RouteSign.Hide() Level.RouteSign.Hide()
SoundManager.PlaySound("menu_open") SoundManager.PlaySound("menu_open")
Core.SetScreen(New NewMenuScreen(Me)) Core.SetScreen(New NewMenuScreen(Me))
End If End If
@ -225,13 +235,20 @@ Public Class OverworldScreen
'Open the PokégearScreen: 'Open the PokégearScreen:
If KeyBoardHandler.KeyPressed(KeyBindings.SpecialKey) = True Or ControllerHandler.ButtonPressed(Buttons.Y) = True Then If KeyBoardHandler.KeyPressed(KeyBindings.SpecialKey) = True Or ControllerHandler.ButtonPressed(Buttons.Y) = True Then
If Level.NotificationPopup Is Nothing Then
If Core.Player.HasPokegear = True Or GameController.IS_DEBUG_ACTIVE = True Or Core.Player.SandBoxMode = True Then If Core.Player.HasPokegear = True Or GameController.IS_DEBUG_ACTIVE = True Or Core.Player.SandBoxMode = True Then
If Screen.Camera.IsMoving() = False And ActionScript.IsReady = True Then If Screen.Camera.IsMoving() = False And ActionScript.IsReady = True Then
Core.SetScreen(New GameJolt.PokegearScreen(Me, GameJolt.PokegearScreen.EntryModes.MainMenu, {})) Core.SetScreen(New GameJolt.PokegearScreen(Me, GameJolt.PokegearScreen.EntryModes.MainMenu, {}))
End If End If
End If End If
Else
If Level.NotificationPopup._scriptFile <> "" Then
Level.NotificationPopup.Accept()
Else
Level.NotificationPopup.Dismiss()
End If
End If
End If End If
ActionScript.Update() 'Update the action script. ActionScript.Update() 'Update the action script.
Else 'Dialogues are showing: Else 'Dialogues are showing:
'Update some parts of the camera: 'Update some parts of the camera:
@ -342,17 +359,28 @@ Public Class OverworldScreen
Level.RouteSign.Draw() Level.RouteSign.Draw()
If Level.NotificationPopup IsNot Nothing Then
Level.NotificationPopup.Draw()
End If
'If the XBOX render control delay is 0, render the controls. 'If the XBOX render control delay is 0, render the controls.
If ShowControlsDelay = 0.0F Then If ShowControlsDelay = 0.0F Then
Dim d As New Dictionary(Of Buttons, String) Dim d As New Dictionary(Of Buttons, String)
d.Add(Buttons.A, "Interact")
d.Add(Buttons.X, "Menu")
If Core.Player.HasPokegear = True Then If Level.NotificationPopup IsNot Nothing Then
d.Add(Buttons.Y, "Pokégear") If Level.NotificationPopup._scriptFile <> "" Then
d.Add(Buttons.A, Localization.GetString("game_interaction_notification", "Notification"))
Else
End If
Else
d.Add(Buttons.A, Localization.GetString("game_interaction_interact", "Interact"))
End If End If
d.Add(Buttons.Start, "Game Menu") d.Add(Buttons.X, Localization.GetString("game_interaction_gamemenu", "Game Menu"))
If Core.Player.HasPokegear = True Then
d.Add(Buttons.Y, Localization.GetString("game_interaction_pokegear", "Pokégear"))
End If
d.Add(Buttons.Start, Localization.GetString("game_interaction_pausemenu", "Game Menu"))
DrawGamePadControls(d) DrawGamePadControls(d)
End If End If

View File

@ -15325,6 +15325,9 @@
<Content Include="Content\Sounds\Heal_Party.wav"> <Content Include="Content\Sounds\Heal_Party.wav">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Content\Sounds\Notifications\Phone.wav">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Sounds\PC\LogOn.wav"> <Content Include="Content\Sounds\PC\LogOn.wav">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@ -15577,6 +15580,12 @@
<Content Include="Content\Textures\Emblem\victorious.png"> <Content Include="Content\Textures\Emblem\victorious.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Content\Textures\Notifications\Backgrounds.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Textures\Notifications\Boxes.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Textures\NPC\0_bow.png"> <Content Include="Content\Textures\NPC\0_bow.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@ -27523,6 +27532,8 @@
<Compile Include="Battle\BattleAnimations\BABillSize.vb" /> <Compile Include="Battle\BattleAnimations\BABillSize.vb" />
<Compile Include="Battle\BattleAnimations\BASound.vb" /> <Compile Include="Battle\BattleAnimations\BASound.vb" />
<Compile Include="Battle\BattleSystemV2\QueryObjects\AnimationQueryObject.vb" /> <Compile Include="Battle\BattleSystemV2\QueryObjects\AnimationQueryObject.vb" />
<Compile Include="Overworld\NotificationPopup.vb" />
<Compile Include="Overworld\RouteSign.vb" />
<Compile Include="Pokemon\Abilities\Aerilate.vb" /> <Compile Include="Pokemon\Abilities\Aerilate.vb" />
<Compile Include="Pokemon\Abilities\PsychicSurge.vb" /> <Compile Include="Pokemon\Abilities\PsychicSurge.vb" />
<Compile Include="Pokemon\Abilities\MistySurge.vb" /> <Compile Include="Pokemon\Abilities\MistySurge.vb" />
@ -29322,7 +29333,6 @@
<Compile Include="Overworld\OverworldCamera.vb" /> <Compile Include="Overworld\OverworldCamera.vb" />
<Compile Include="Overworld\OverworldScreen.vb" /> <Compile Include="Overworld\OverworldScreen.vb" />
<Compile Include="Overworld\OverworldStorage.vb" /> <Compile Include="Overworld\OverworldStorage.vb" />
<Compile Include="Overworld\RouteSign.vb" />
<Compile Include="Overworld\SecretBase\SecretBase.vb" /> <Compile Include="Overworld\SecretBase\SecretBase.vb" />
<Compile Include="Overworld\SecretBase\SecretBaseCamera.vb" /> <Compile Include="Overworld\SecretBase\SecretBaseCamera.vb" />
<Compile Include="Overworld\SecretBase\SecretBaseScreen.vb" /> <Compile Include="Overworld\SecretBase\SecretBaseScreen.vb" />

View File

@ -11,6 +11,32 @@
Dim argument As String = ScriptComparer.GetSubClassArgumentPair(subClass).Argument Dim argument As String = ScriptComparer.GetSubClassArgumentPair(subClass).Argument
Select Case command.ToLower() Select Case command.ToLower()
Case "notification"
Dim _NotificationPopup As New NotificationPopup
Dim args As String() = argument.Split(CChar(","))
Select Case args.Length
Case 1
_NotificationPopup.Setup(args(0))
Case 2
_NotificationPopup.Setup(args(0), CInt(args(1)))
Case 3
_NotificationPopup.Setup(args(0), CInt(args(1)), CInt(args(2)))
Case 4
_NotificationPopup.Setup(args(0), CInt(args(1)), CInt(args(2)), CInt(args(3)))
Case 5
_NotificationPopup.Setup(args(0), CInt(args(1)), CInt(args(2)), CInt(args(3)), args(4))
Case 6, 7
_NotificationPopup.Setup(args(0), CInt(args(1)), CInt(args(2)), CInt(args(3)), args(4), args(5))
End Select
If args.Length = 7 AndAlso CBool(args(6)) = True Then
CType(CurrentScreen, OverworldScreen).NotificationPopupList.Insert(0, _NotificationPopup)
If Screen.Level.NotificationPopup IsNot Nothing Then
CType(CurrentScreen, OverworldScreen).NotificationPopupList.Insert(1, Screen.Level.NotificationPopup)
Screen.Level.NotificationPopup = Nothing
Else
CType(CurrentScreen, OverworldScreen).NotificationPopupList.Add(_NotificationPopup)
End If
End If
Case "show" Case "show"
Screen.TextBox.reDelay = 0.0F Screen.TextBox.reDelay = 0.0F
Screen.TextBox.Show(argument, {}, False, False) Screen.TextBox.Show(argument, {}, False, False)

View File

@ -7,6 +7,7 @@ Public Class Level
#Region "Fields" #Region "Fields"
Private _routeSign As RouteSign = Nothing Private _routeSign As RouteSign = Nothing
Private _notificationPopup As NotificationPopup = Nothing
Private _world As World = Nothing Private _world As World = Nothing
Private _pokemonEncounter As PokemonEncounter = Nothing Private _pokemonEncounter As PokemonEncounter = Nothing
@ -98,6 +99,14 @@ Public Class Level
Return Me._routeSign Return Me._routeSign
End Get End Get
End Property End Property
Public Property NotificationPopup() As NotificationPopup
Set(value As NotificationPopup)
Me._notificationPopup = value
End Set
Get
Return Me._notificationPopup
End Get
End Property
''' <summary> ''' <summary>
''' Indicates whether the player is Surfing. ''' Indicates whether the player is Surfing.