4 using System.Globalization;
6 using System.Reflection;
7 using System.Threading.Tasks;
8 using SiliconStudio.Core.Mathematics;
9 using SiliconStudio.Paradox.Effects;
10 using SiliconStudio.Paradox.Engine;
11 using SiliconStudio.Paradox.EntityModel;
12 using SiliconStudio.Paradox.Games;
13 using SiliconStudio.Core.Storage;
14 using SiliconStudio.Paradox.Audio;
15 using SiliconStudio.Paradox.Graphics;
16 using SiliconStudio.Paradox.Graphics.Data;
17 using SiliconStudio.Core.Diagnostics;
18 using SiliconStudio.Core.IO;
19 using SiliconStudio.Core.Serialization.Assets;
20 using SiliconStudio.Paradox.Graphics.DataOld;
22 using SiliconStudio.Paradox.Input;
23 using SiliconStudio.Paradox.UI;
34 private readonly GameFontSystem gameFontSystem;
101 if (gameFontSystem.FontSystem == null)
102 throw new InvalidOperationException(
"The font system is not initialized yet");
104 return gameFontSystem.FontSystem;
121 return consoleLogListener != null ? consoleLogListener.LogMode :
default(
ConsoleLogMode);
126 if (consoleLogListener != null)
128 consoleLogListener.LogMode = value;
142 return consoleLogListener != null ? consoleLogListener.LogLevel :
default(
LogMessageType);
147 if (consoleLogListener != null)
149 consoleLogListener.LogLevel = value;
160 logListener = GetLogListener();
162 if (logListener != null)
163 GlobalLogger.GlobalMessageLogged += logListener;
172 gameFontSystem =
new GameFontSystem(Services);
181 GameSystems.Add(Input);
193 GameSystems.Add(Entities);
196 GameSystems.Add(Audio);
199 GameSystems.Add(gameFontSystem);
202 GameSystems.Add(SpriteAnimation);
204 Asset.Serializer.LowLevelSerializerSelector = ParameterContainerExtensions.DefaultSceneSerializerSelector;
214 if (logListener != null)
215 GlobalLogger.GlobalMessageLogged -= logListener;
222 if (Context.InitializeDatabase)
224 InitializeAssetDatabase();
232 GameSystems.Add(RenderSystem);
234 using (var profile = Profiler.Begin(GameProfilingKeys.EntityProcessorInitialize))
244 Entities.Processors.Add(
new SpriteProcessor());
257 Asset.Serializer.RegisterSerializer(
new ImageSerializer());
258 Asset.Serializer.RegisterSerializer(
new SoundEffectSerializer(Audio.AudioEngine));
259 Asset.Serializer.RegisterSerializer(
new SoundMusicSerializer(Audio.AudioEngine));
262 const int screenDesiredHeight = 1080;
264 VirtualResolution =
new Vector3((
int)(screenRatio * screenDesiredHeight), screenDesiredHeight, screenDesiredHeight);
267 Input.MultiTouchEnabled =
true;
270 internal static void InitializeAssetDatabase()
272 using (var profile = Profiler.Begin(GameProfilingKeys.ObjectDatabaseInitialize))
275 var objDatabase =
new ObjectDatabase(
"/data/db",
"index",
"/local/db");
278 var mountPath = VirtualFileSystem.ResolveProviderUnsafe(
"/asset",
true).Provider == null ?
"/asset" : null;
281 AssetManager.GetFileProvider = () => databaseFileProvider;
287 #if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP
289 if (Input.HasKeyboard)
291 if (Input.IsKeyDown(
Keys.LeftCtrl)
292 && Input.IsKeyDown(Keys.C)
293 && Input.IsKeyReleased(
Keys.F12))
295 var currentFilePath = Assembly.GetEntryAssembly().Location;
296 var timeNow = DateTime.Now.ToString(
"s", CultureInfo.InvariantCulture).
Replace(
':',
'_');
297 var newFileName = Path.Combine(
298 Path.GetDirectoryName(currentFilePath),
299 Path.GetFileNameWithoutExtension(currentFilePath) +
"_" + timeNow +
".png");
301 Console.WriteLine(
"Saving screenshot: {0}", newFileName);
303 using (var stream = System.IO.File.Create(newFileName))
305 GraphicsDevice.BackBuffer.Texture.Save(stream, ImageFileType.Png);
310 base.EndDraw(present);
318 return Task.FromResult(
true);
321 internal override void LoadContentInternal()
323 base.LoadContentInternal();
324 Script.Add(LoadContent);
override void EndDraw(bool present)
Ends the drawing of a frame. This method is preceeded by calls to Draw and BeginDraw.
ConsoleLogMode
Defines how the console is opened.
A system in charge of animating the sprites
The interface to create and manage fonts.
virtual LogListener GetLogListener()
A TextureCube frontend to SharpDX.Direct3D11.Texture2D.
RenderTarget BackBuffer
Gets the back buffer sets by the current Presenter setup on this device.
SiliconStudio.Paradox.Engine.MeshProcessor MeshProcessor
Represents a three dimensional mathematical vector.
The script system handles scripts scheduling in a game.
Manages the GraphicsDevice lifecycle.
SharpDX.DirectWrite.Font Font
This processor will take care of adding/removing children of every Entity added/removed in the Entity...
Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders. See The+GraphicsDevice+class to learn more about the class.
Gives access to the object database.
Renders its RenderSystem.Pipeline, which will usually result in drawing all meshes, UI, etc...
virtual Task LoadContent()
Loads the content.
Manage a collection of entities.
LogMessageType
Type of a LogMessage.
A Texture 3D frontend to SharpDX.Direct3D11.Texture3D.
A Texture 2D frontend to SharpDX.Direct3D11.Texture2D.
A Texture 1D frontend to SharpDX.Direct3D11.Texture1D.
Interface of the UI system.
override void Destroy()
Disposes of object resources.
int Height
Gets the height in texel.
Game()
Initializes a new instance of the Game class.
A base class to implement a log listener
The Audio System. It creates an underlying instance of AudioEngine.
override void Initialize()
Called after the Game and GraphicsDevice are created, but before LoadContent. Reference page contains...
Processor in charge of creating and updating the AudioListener data associated to the scene AudioList...
Processor in charge of updating the AudioEmitterComponents.
Base class for texture resources.
A LogListener implementation redirecting its output to the default OS console. If console is not supp...