P3D-Legacy/P3D/Core/GameController.vb

185 lines
5.4 KiB
VB.net
Raw Normal View History

2016-11-25 21:24:46 +01:00
Imports System.Windows.Forms
2018-02-24 09:32:04 +01:00
Imports GameDevCommon
2016-09-07 18:50:38 +02:00
Public Class Classified
Public Shared Remote_Texture_URL As String = "" ' CLASSIFIED
Public Const GameJolt_Game_ID As String = "" ' CLASSIFIED
Public Const GameJolt_Game_Key As String = "" ' CLASSIFIED
Public Shared Encryption_Password As String = "" ' CLASSIFIED
End Class
2016-09-07 18:50:38 +02:00
''' <summary>
''' Controls the game's main workflow.
''' </summary>
Public Class GameController
Inherits Microsoft.Xna.Framework.Game
2018-02-24 09:32:04 +01:00
Implements IGame
2016-09-07 18:50:38 +02:00
''' <summary>
''' The current version of the game.
''' </summary>
2021-01-27 07:30:43 +01:00
Public Const GAMEVERSION As String = "0.58.1"
2016-09-07 18:50:38 +02:00
''' <summary>
''' The number of released iterations of the game.
''' </summary>
2021-01-27 07:30:43 +01:00
Public Const RELEASEVERSION As String = "101"
2016-09-07 18:50:38 +02:00
''' <summary>
''' The development stage the game is in.
''' </summary>
Public Const GAMEDEVELOPMENTSTAGE As String = "Indev"
''' <summary>
''' The name of the game.
''' </summary>
2016-11-25 21:24:46 +01:00
Public Const GAMENAME As String = "Pokémon 3D"
2016-09-07 18:50:38 +02:00
''' <summary>
''' The name of the developer that appears on the title screen.
''' </summary>
Public Const DEVELOPER_NAME As String = "P3D Team"
2016-09-07 18:50:38 +02:00
''' <summary>
''' If the Debug Mode is active.
''' </summary>
#If DEBUG Or DEBUGNOCONTENT Then
Public Const IS_DEBUG_ACTIVE As Boolean = True
#Else
2016-09-07 18:50:38 +02:00
Public Const IS_DEBUG_ACTIVE As Boolean = False
#End If
2016-09-07 18:50:38 +02:00
''' <summary>
''' If the game should set the GameJolt online version to the current online version.
''' </summary>
Public Const UPDATEONLINEVERSION As Boolean = False
Public Graphics As GraphicsDeviceManager
Public FPSMonitor As FPSMonitor
Private window_change As Boolean = False
Public Shared UpdateChecked As Boolean = False
2016-09-07 18:50:38 +02:00
2018-02-24 09:32:04 +01:00
Private _componentManager As ComponentManager
2016-09-07 18:50:38 +02:00
Public Sub New()
Me.window_change = False
2016-09-07 18:50:38 +02:00
Graphics = New GraphicsDeviceManager(Me)
Content.RootDirectory = "Content"
Window.AllowUserResizing = True
AddHandler Window.ClientSizeChanged, AddressOf Window_ClientSizeChanged
'Dim gameForm As Form = CType(Form.FromHandle(Window.Handle), Form)
'gameForm.MinimumSize = New System.Drawing.Size(600, 360)
2016-09-07 18:50:38 +02:00
FPSMonitor = New FPSMonitor()
GameHacked = System.IO.File.Exists(My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData & "\temp")
If GameHacked = True Then
Security.HackerAlerts.Activate()
End If
2018-02-24 09:32:04 +01:00
_componentManager = New ComponentManager()
GameInstanceProvider.SetInstance(Me)
2016-09-07 18:50:38 +02:00
End Sub
Protected Overrides Sub Initialize()
2018-02-24 09:32:04 +01:00
_componentManager.LoadComponents()
2016-09-07 18:50:38 +02:00
Core.Initialize(Me)
MyBase.Initialize()
End Sub
Protected Overrides Sub LoadContent()
End Sub
Protected Overrides Sub UnloadContent()
End Sub
Protected Overrides Sub Update(ByVal gameTime As GameTime)
If Me.window_change Then
SetWindowSize(New Vector2(Window.ClientBounds.Width, Window.ClientBounds.Height))
Me.window_change = Not Me.window_change
End If
2016-09-07 18:50:38 +02:00
Core.Update(gameTime)
MyBase.Update(gameTime)
GameJolt.SessionManager.Update()
FPSMonitor.Update(gameTime)
End Sub
Protected Overrides Sub Draw(ByVal gameTime As GameTime)
Core.Draw()
MyBase.Draw(gameTime)
FPSMonitor.DrawnFrame()
End Sub
Public Shared ReadOnly Property DecSeparator As String
Get
Return My.Application.Culture.NumberFormat.NumberDecimalSeparator
End Get
End Property
Protected Overrides Sub OnExiting(sender As Object, args As System.EventArgs)
GameJolt.SessionManager.Close()
If Core.ServersManager.ServerConnection.Connected = True Then
Core.ServersManager.ServerConnection.Abort()
End If
Logger.Debug("---Exit Game---")
End Sub
Protected Sub Window_ClientSizeChanged(ByVal sender As Object, ByVal e As EventArgs)
Me.window_change = True
2016-09-07 18:50:38 +02:00
Core.windowSize = New Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height)
2016-09-07 18:50:38 +02:00
If Not Core.CurrentScreen Is Nothing Then
Core.CurrentScreen.SizeChanged()
Screen.TextBox.PositionY = Core.windowSize.Height - 160.0F
End If
NetworkPlayer.ScreenRegionChanged()
End Sub
Private Sub DGame_Activated(sender As Object, e As System.EventArgs) Handles Me.Activated
NetworkPlayer.ScreenRegionChanged()
End Sub
Private Sub DGame_Deactivated(sender As Object, e As System.EventArgs) Handles Me.Deactivated
NetworkPlayer.ScreenRegionChanged()
End Sub
2018-02-24 09:32:04 +01:00
Public Function GetGame() As Game Implements IGame.GetGame
Return Me
End Function
Public Function GetComponentManager() As ComponentManager Implements IGame.GetComponentManager
Return _componentManager
End Function
2016-09-07 18:50:38 +02:00
Private Shared GameHacked As Boolean = False 'Temp value that stores if a hacking file was detected at game start.
2016-09-19 03:26:44 +02:00
2016-09-07 18:50:38 +02:00
''' <summary>
2016-11-25 21:24:46 +01:00
''' If the player hacked any instance of Pokémon3D at some point.
2016-09-07 18:50:38 +02:00
''' </summary>
Public Shared ReadOnly Property Hacker() As Boolean
Get
Return GameHacked
End Get
End Property
''' <summary>
''' The path to the game folder.
''' </summary>
Public Shared ReadOnly Property GamePath() As String
Get
Return My.Application.Info.DirectoryPath
End Get
End Property
End Class