Imports net.Pokemon3D.Game
'''
''' The base class for all screens in the game.
'''
Public MustInherit Class Screen
'''
''' The ID for a screen.
'''
Public Enum Identifications
MainMenuScreen
OverworldScreen
MenuScreen
PokedexSelectScreen
PokedexScreen
PokedexViewScreen
PokedexSearchScreen
PokedexHabitatScreen
PartyScreen
SummaryScreen
InventoryScreen
BerryScreen
TrainerScreen
PauseScreen
SaveScreen
NewGameScreen
OptionScreen
StorageSystemScreen
TradeScreen
MapScreen
ChatScreen
UseItemScreen
ItemDetailScreen
ChooseItemScreen
ChoosePokemonScreen
EvolutionScreen
ApricornScreen
TransitionScreen
BattleCatchScreen
BlackOutScreen
BattlePokemonScreen
CreditsScreen
DonationScreen
NameObjectScreen
LearnAttackScreen
SecretBaseScreen
PokegearScreen
BattleGrowStatsScreen
DaycareScreen
HatchEggScreen
SplashScreen
GameJoltLoginScreen
GameJoltUserViewerScreen
GameJoltLobbyScreen
GameJoltAddFriendScreen
ChooseAttackScreen
BattleScreen
BattleIniScreen
BattleAnimationScreen
GTSMainScreen
GTSInboxScreen
GTSSearchScreen
GTSSelectLevelScreen
GTSSelectPokemonScreen
GTSSelectGenderScreen
GTSSetupScreen
GTSEditTradeScreen
GTSSelectAreaScreen
GTSSelectUserScreen
GTSTradeScreen
GTSTradingScreen
TeachMovesScreen
OfflineGameWarningScreen
HallofFameScreen
ViewModelScreen
MailSystemScreen
PVPLobbyScreen
InputScreen
JoinServerScreen
ConnectScreen
AddServerScreen
MysteryEventScreen
DirectTradeScreen
StorageSystemFilterScreen
WonderTradeScreen
RegisterBattleScreen
StatisticsScreen
MapPreviewScreen
KeyBindingScreen
MessageBoxScreen
PressStartScreen
CharacterSelectionScreen
GameModeSelectionScreen
'TEMPORARY, OLD
PokemonScreen
IntroScreen
PokemonStatusScreen
End Enum
#Region "Shared values"
'''
''' A global camera instance, that carries over screen instances.
'''
Public Shared Property Camera() As Camera
Private Shared _globalLevel As Level
'''
''' A global level instance, that carries over screen instances.
'''
Public Shared Property Level() As Level
Get
Return _globalLevel
End Get
Set(value As Level)
If _globalLevel IsNot Nothing Then
_globalLevel.StopOffsetMapUpdate()
End If
_globalLevel = value
_globalLevel.StartOffsetMapUpdate()
End Set
End Property
'''
''' A global BasicEffect instance, that carries over screen instances.
'''
Public Shared Property Effect() As BasicEffect
'''
''' A global SkyDome instance, that carries over screen instances.
'''
Public Shared Property SkyDome() As SkyDome
'''
''' A global TextBox instance, that carries over screen instances.
'''
Public Shared Property TextBox() As TextBox = New TextBox()
'''
''' A global ChooseBox instance, that carries over screen instances.
'''
Public Shared Property ChooseBox() As ChooseBox = New ChooseBox()
'''
''' A global PokemonImageView instance, that carries over screen instances.
'''
Public Shared Property PokemonImageView() As PokemonImageView = New PokemonImageView()
#End Region
#Region "Fields"
'''
''' A value to store the screen that underlies the current screen in.
'''
Public Property PreScreen() As Screen = Nothing
'''
''' The ID of the screen.
'''
Public Property Identification() As Identifications = Identifications.MainMenuScreen
'''
''' Wether the mouse is visible on the screen.
'''
Public Property MouseVisible() As Boolean = False
'''
''' Wether the game can be paused when pressing Escape.
'''
Public Property CanBePaused() As Boolean = True
'''
''' Wether the game can be muted by pressing M (default).
'''
Public Property CanMuteMusic() As Boolean = True
'''
''' Wether the ChatScreen can be opened by pressing T (default).
'''
Public Property CanChat() As Boolean = True
'''
''' Wether a screenshot can be taken by pressing F2 (default).
'''
Public Property CanTakeScreenshot() As Boolean = True
'''
''' Wether the debug information can be drawn on the screen.
'''
Public Property CanDrawDebug() As Boolean = True
'''
''' Wether the game can switch its fullscreen state by pressing F11 (default).
'''
Public Property CanGoFullscreen() As Boolean = True
'''
''' Wether this screen draws gradients.
'''
Protected Property IsDrawingGradients() As Boolean = False
'''
''' If this screen completely overlays its PreScreen.
'''
Public Property IsOverlay() As Boolean = False
Public UpdateFadeOut As Boolean = False 'Sets if the screen gets updated during its set as a FadeOut screen on the TransitionScreen.
Public UpdateFadeIn As Boolean = False 'Sets if the screen gets updated during its set as a FadeIn screen on the TransitionScreen.
#End Region
'''
''' Copies variables from another screen.
'''
''' The source screen.
Protected Sub CopyFrom(ByVal scr As Screen)
_MouseVisible = scr._MouseVisible
_CanBePaused = scr._CanBePaused
_CanMuteMusic = scr._CanMuteMusic
_CanChat = scr._CanChat
_CanTakeScreenshot = scr._CanTakeScreenshot
_CanDrawDebug = scr._CanDrawDebug
_CanGoFullscreen = scr._CanGoFullscreen
End Sub
'''
''' The base draw function of a screen.
'''
''' Contains no default code.
Public Overridable Overloads Sub Draw()
End Sub
'''
''' The base render function of the screen. Used to render models above sprites.
'''
Public Overridable Overloads Sub Render()
End Sub
'''
''' The base update fucntion of a screen.
'''
''' Contains no default code.
Public Overridable Overloads Sub Update()
End Sub
'''
''' An event that gets raised when this screen gets changed to.
'''
''' Contains no default code.
Public Overridable Sub ChangeTo()
End Sub
'''
''' An event that gets raised when this screen gets changed from.
'''
''' Contains no default code.
Public Overridable Sub ChangeFrom()
End Sub
'''
''' Returns if this screen instance is the currently active screen (set in the global Basic.CurrentScreen).
'''
'''
Public Function IsCurrentScreen() As Boolean
If CurrentScreen.Identification = Identification Then 'If the screen stored in the CurrentScreen field has the same ID as this screen, return true.
Return True
Else
Return False
End If
End Function
'''
''' An event that gets raised when the window handle size changed.
'''
''' Contains no default code.
Public Overridable Sub SizeChanged()
End Sub
'''
''' A void that gets raised when the mute option of the game gets toggled.
'''
''' Contains no default code.
Public Overridable Sub ToggledMute()
End Sub
'''
''' An event that is getting raised when the Escape button is getting pressed. The PauseScreen is getting brought up if the CanBePaused field is set to true.
'''
Public Overridable Sub EscapePressed()
'If the game can be paused on this screen, open the PauseScreen.
If CurrentScreen.CanBePaused = True Then
SetScreen(New PauseScreen(CurrentScreen))
End If
End Sub
'''
''' Draws XBOX controls on the bottom right of the screen.
'''
''' The button types and descriptions.
''' Calculates the position and calls DrawGamePadControls(Descriptions,Position)
Public Sub DrawGamePadControls(ByVal Descriptions As Dictionary(Of Buttons, String))
Dim x As Integer = windowSize.Width 'Store the x position of the start of the controls render.
'Loop through the buttons and add to the x location.
For i = 0 To Descriptions.Count - 1
Select Case Descriptions.Keys(i)
Case Buttons.A, Buttons.B, Buttons.X, Buttons.Y, Buttons.Start, Buttons.LeftStick, Buttons.RightStick, Buttons.LeftTrigger, Buttons.RightTrigger
x -= 32 + 4
Case Buttons.LeftShoulder, Buttons.RightShoulder
x -= 64 + 4
End Select
'Add to the x location for the length of the string and a separator.
x -= CInt(FontManager.MainFont.MeasureString(Descriptions.Values(i)).X) + 16
Next
'Finally, render the buttons:
DrawGamePadControls(Descriptions, New Vector2(x, windowSize.Height - 40))
End Sub
'''
''' Generic void to render XBOX Gamepad controls on the screen.
'''
''' The button types and descriptions.
''' The position to draw the buttons.
Public Sub DrawGamePadControls(ByVal Descriptions As Dictionary(Of Buttons, String), ByVal Position As Vector2)
'Only if a Gamepad is connected and the screen is active, render the buttons:
If GamePad.GetState(PlayerIndex.One).IsConnected = True And Core.GameOptions.GamePadEnabled = True And IsCurrentScreen() = True Then
'Transform the position to integers and store the current drawing position:
Dim x As Integer = CInt(Position.X)
Dim y As Integer = CInt(Position.Y)
'Loop through the button list:
For i = 0 To Descriptions.Count - 1
Dim t As String = "GUI\GamePad\xboxController" 'Store the texture path.
Dim width As Integer = 32 'Store the width of the image.
Dim height As Integer = 32 'Store the height of the image.
'Get the correct button image and size (currently, all buttons use the same size of 32x32 pixels).
Select Case Descriptions.Keys(i)
Case Buttons.A
t &= "ButtonA"
Case Buttons.B
t &= "ButtonB"
Case Buttons.X
t &= "ButtonX"
Case Buttons.Y
t &= "ButtonY"
Case Buttons.LeftShoulder
t &= "LeftShoulder"
Case Buttons.RightShoulder
t &= "RightShoulder"
Case Buttons.LeftStick
t &= "LeftStick"
Case Buttons.RightStick
t &= "RightStick"
Case Buttons.LeftTrigger
t &= "LeftTrigger"
Case Buttons.RightTrigger
t &= "RightTrigger"
Case Buttons.Start
t &= "Start"
End Select
'Draw the buttons (first, the "shadow" with a black color, then the real button).
SpriteBatch.Draw(TextureManager.GetTexture(t), New Rectangle(x + 2, y + 2, width, height), Color.Black)
SpriteBatch.Draw(TextureManager.GetTexture(t), New Rectangle(x, y, width, height), Color.White)
'Add the button width and a little offset to the drawing position:
x += width + 4
'Draw the button description (again, with a shadow):
SpriteBatch.DrawString(FontManager.MainFont, Descriptions.Values(i), New Vector2(x + 3, y + 7), Color.Black)
SpriteBatch.DrawString(FontManager.MainFont, Descriptions.Values(i), New Vector2(x, y + 4), Color.White)
'Add the text width and the offset for the next button description to the drawing position:
x += CInt(FontManager.MainFont.MeasureString(Descriptions.Values(i)).X) + 16
Next
End If
End Sub
'''
''' Renders fading gradients.
'''
''' The alpha to draw the gradients at.
Protected Sub DrawGradients(ByVal alpha As Integer)
DrawGradients(alpha, Screens.UI.ColorProvider.IsGameJolt)
End Sub
Protected Sub DrawGradients(ByVal alpha As Integer, ByVal isGameJolt As Boolean)
Dim canDrawGradients As Boolean = True
Dim s As Screen = Me
While s.PreScreen IsNot Nothing And canDrawGradients = True
If s._IsOverlay = False Then
s = s.PreScreen
If s.IsDrawingGradients = True Then
canDrawGradients = False
End If
Else
Exit While
End If
End While
If canDrawGradients = True Then
Dim c As Color = Screens.UI.ColorProvider.GradientColor(isGameJolt, 0)
Dim cA As Color = Screens.UI.ColorProvider.GradientColor(isGameJolt, alpha)
Canvas.DrawGradient(New Rectangle(0, 0, CInt(windowSize.Width), 200), cA, c, False, -1)
Canvas.DrawGradient(New Rectangle(0, CInt(windowSize.Height - 200), CInt(windowSize.Width), 200), c, cA, False, -1)
End If
End Sub
'''
''' Returns the screen status of the current screen. Override this function to return a screen state.
'''
'''
Public Overridable Function GetScreenStatus() As String
'// Return the generic "not implemented" message:
Return "Screen state not implemented for screen class: " & Identification.ToString()
End Function
'''
''' Returns the minimum size for the screen size to display a large interface before switching to the small size.
'''
'''
''' The default size is 800x620 pixels.
Public Overridable Function GetScreenScaleMinimum() As Size
'// Default size: 800x620 pixels.
Return New Size(800, 620)
End Function
'''
''' Returns the spritebatch that should render a font.
'''
'''
Protected Overridable Function GetFontRenderer() As SpriteBatch
If IsCurrentScreen() Then
Return FontRenderer
Else
Return SpriteBatch
End If
End Function
End Class