Show More
Commit Description:
Dialog tweaks and update swear list....
Commit Description:
Dialog tweaks and update swear list.
Keep the list of swears to censor up to date, lol.
References:
File last commit:
Show/Diff file:
Action:
FNA/src/FNAPlatform/FNAPlatform.cs
383 lines | 13.1 KiB | text/x-csharp | CSharpLexer
383 lines | 13.1 KiB | text/x-csharp | CSharpLexer
r0 | #region License | |||
/* FNA - XNA4 Reimplementation for Desktop Platforms | ||||
r690 | * Copyright 2009-2022 Ethan Lee and the MonoGame Team | |||
r0 | * | |||
* Released under the Microsoft Public License. | ||||
* See LICENSE for details. | ||||
*/ | ||||
#endregion | ||||
#region Using Statements | ||||
using System; | ||||
using System.IO; | ||||
r690 | using System.Collections.Generic; | |||
r0 | ||||
using Microsoft.Xna.Framework.Graphics; | ||||
using Microsoft.Xna.Framework.Audio; | ||||
using Microsoft.Xna.Framework.Input; | ||||
using Microsoft.Xna.Framework.Input.Touch; | ||||
#endregion | ||||
namespace Microsoft.Xna.Framework | ||||
{ | ||||
internal static class FNAPlatform | ||||
{ | ||||
#region Static Constructor | ||||
static FNAPlatform() | ||||
{ | ||||
/* I suspect you may have an urge to put an #if in here for new | ||||
* FNAPlatform implementations. | ||||
* | ||||
* DON'T. | ||||
* | ||||
* Determine this at runtime, or load dynamically. | ||||
* No amount of whining will get me to budge on this. | ||||
* -flibit | ||||
*/ | ||||
// Environment.GetEnvironmentVariable("FNA_PLATFORM_BACKEND"); | ||||
// Built-in command line arguments | ||||
LaunchParameters args = new LaunchParameters(); | ||||
string arg; | ||||
if (args.TryGetValue("enablehighdpi", out arg) && arg == "1") | ||||
{ | ||||
Environment.SetEnvironmentVariable( | ||||
"FNA_GRAPHICS_ENABLE_HIGHDPI", | ||||
"1" | ||||
); | ||||
} | ||||
if (args.TryGetValue("gldevice", out arg)) | ||||
{ | ||||
Environment.SetEnvironmentVariable( | ||||
r690 | "FNA3D_FORCE_DRIVER", | |||
r0 | arg | |||
); | ||||
} | ||||
r690 | if (args.TryGetValue("enablelateswaptear", out arg) && arg == "1") | |||
{ | ||||
Environment.SetEnvironmentVariable( | ||||
"FNA3D_ENABLE_LATESWAPTEAR", | ||||
"1" | ||||
); | ||||
} | ||||
r0 | if (args.TryGetValue("mojoshaderprofile", out arg)) | |||
{ | ||||
Environment.SetEnvironmentVariable( | ||||
r690 | "FNA3D_MOJOSHADER_PROFILE", | |||
r0 | arg | |||
); | ||||
} | ||||
if (args.TryGetValue("backbufferscalenearest", out arg) && arg == "1") | ||||
{ | ||||
Environment.SetEnvironmentVariable( | ||||
r690 | "FNA3D_BACKBUFFER_SCALE_NEAREST", | |||
r0 | "1" | |||
); | ||||
} | ||||
if (args.TryGetValue("usescancodes", out arg) && arg == "1") | ||||
{ | ||||
Environment.SetEnvironmentVariable( | ||||
"FNA_KEYBOARD_USE_SCANCODES", | ||||
"1" | ||||
); | ||||
} | ||||
r690 | if (args.TryGetValue("nukesteaminput", out arg) && arg == "1") | |||
{ | ||||
Environment.SetEnvironmentVariable( | ||||
"FNA_NUKE_STEAM_INPUT", | ||||
"1" | ||||
); | ||||
} | ||||
r0 | ||||
CreateWindow = SDL2_FNAPlatform.CreateWindow; | ||||
DisposeWindow = SDL2_FNAPlatform.DisposeWindow; | ||||
ApplyWindowChanges = SDL2_FNAPlatform.ApplyWindowChanges; | ||||
r690 | ScaleForWindow = SDL2_FNAPlatform.ScaleForWindow; | |||
r0 | GetWindowBounds = SDL2_FNAPlatform.GetWindowBounds; | |||
GetWindowResizable = SDL2_FNAPlatform.GetWindowResizable; | ||||
SetWindowResizable = SDL2_FNAPlatform.SetWindowResizable; | ||||
GetWindowBorderless = SDL2_FNAPlatform.GetWindowBorderless; | ||||
SetWindowBorderless = SDL2_FNAPlatform.SetWindowBorderless; | ||||
SetWindowTitle = SDL2_FNAPlatform.SetWindowTitle; | ||||
r690 | IsScreenKeyboardShown = SDL2_FNAPlatform.IsScreenKeyboardShown; | |||
RegisterGame = SDL2_FNAPlatform.RegisterGame; | ||||
UnregisterGame = SDL2_FNAPlatform.UnregisterGame; | ||||
PollEvents = SDL2_FNAPlatform.PollEvents; | ||||
r0 | GetGraphicsAdapters = SDL2_FNAPlatform.GetGraphicsAdapters; | |||
GetCurrentDisplayMode = SDL2_FNAPlatform.GetCurrentDisplayMode; | ||||
GetKeyFromScancode = SDL2_FNAPlatform.GetKeyFromScancode; | ||||
r690 | IsTextInputActive = SDL2_FNAPlatform.IsTextInputActive; | |||
r0 | StartTextInput = SDL2.SDL.SDL_StartTextInput; | |||
StopTextInput = SDL2.SDL.SDL_StopTextInput; | ||||
SetTextInputRectangle = SDL2_FNAPlatform.SetTextInputRectangle; | ||||
GetMouseState = SDL2_FNAPlatform.GetMouseState; | ||||
SetMousePosition = SDL2.SDL.SDL_WarpMouseInWindow; | ||||
OnIsMouseVisibleChanged = SDL2_FNAPlatform.OnIsMouseVisibleChanged; | ||||
GetRelativeMouseMode = SDL2_FNAPlatform.GetRelativeMouseMode; | ||||
SetRelativeMouseMode = SDL2_FNAPlatform.SetRelativeMouseMode; | ||||
GetGamePadCapabilities = SDL2_FNAPlatform.GetGamePadCapabilities; | ||||
GetGamePadState = SDL2_FNAPlatform.GetGamePadState; | ||||
SetGamePadVibration = SDL2_FNAPlatform.SetGamePadVibration; | ||||
r690 | SetGamePadTriggerVibration = SDL2_FNAPlatform.SetGamePadTriggerVibration; | |||
r0 | GetGamePadGUID = SDL2_FNAPlatform.GetGamePadGUID; | |||
SetGamePadLightBar = SDL2_FNAPlatform.SetGamePadLightBar; | ||||
r690 | GetGamePadGyro = SDL2_FNAPlatform.GetGamePadGyro; | |||
GetGamePadAccelerometer = SDL2_FNAPlatform.GetGamePadAccelerometer; | ||||
r0 | GetStorageRoot = SDL2_FNAPlatform.GetStorageRoot; | |||
GetDriveInfo = SDL2_FNAPlatform.GetDriveInfo; | ||||
r690 | ReadFileToPointer = SDL2_FNAPlatform.ReadToPointer; | |||
FreeFilePointer = SDL2_FNAPlatform.FreeFilePointer; | ||||
r0 | ShowRuntimeError = SDL2_FNAPlatform.ShowRuntimeError; | |||
GetMicrophones = SDL2_FNAPlatform.GetMicrophones; | ||||
GetMicrophoneSamples = SDL2_FNAPlatform.GetMicrophoneSamples; | ||||
GetMicrophoneQueuedBytes = SDL2_FNAPlatform.GetMicrophoneQueuedBytes; | ||||
StartMicrophone = SDL2_FNAPlatform.StartMicrophone; | ||||
StopMicrophone = SDL2_FNAPlatform.StopMicrophone; | ||||
GetTouchCapabilities = SDL2_FNAPlatform.GetTouchCapabilities; | ||||
UpdateTouchPanelState = SDL2_FNAPlatform.UpdateTouchPanelState; | ||||
GetNumTouchFingers = SDL2_FNAPlatform.GetNumTouchFingers; | ||||
SupportsOrientationChanges = SDL2_FNAPlatform.SupportsOrientationChanges; | ||||
r690 | NeedsPlatformMainLoop = SDL2_FNAPlatform.NeedsPlatformMainLoop; | |||
RunPlatformMainLoop = SDL2_FNAPlatform.RunPlatformMainLoop; | ||||
r0 | ||||
r690 | FNALoggerEXT.Initialize(); | |||
r0 | ||||
AppDomain.CurrentDomain.ProcessExit += SDL2_FNAPlatform.ProgramExit; | ||||
TitleLocation = SDL2_FNAPlatform.ProgramInit(args); | ||||
r690 | ||||
/* Do this AFTER ProgramInit so the platform library | ||||
* has a chance to load first! | ||||
*/ | ||||
FNALoggerEXT.HookFNA3D(); | ||||
r0 | } | |||
#endregion | ||||
#region Public Static Variables | ||||
public static readonly string TitleLocation; | ||||
r690 | /* Setup Text Input Control Character Arrays | |||
* (Only 7 control keys supported at this time) | ||||
*/ | ||||
public static readonly char[] TextInputCharacters = new char[] | ||||
{ | ||||
(char) 2, // Home | ||||
(char) 3, // End | ||||
(char) 8, // Backspace | ||||
(char) 9, // Tab | ||||
(char) 13, // Enter | ||||
(char) 127, // Delete | ||||
(char) 22 // Ctrl+V (Paste) | ||||
}; | ||||
public static readonly Dictionary<Keys, int> TextInputBindings = new Dictionary<Keys, int>() | ||||
{ | ||||
{ Keys.Home, 0 }, | ||||
{ Keys.End, 1 }, | ||||
{ Keys.Back, 2 }, | ||||
{ Keys.Tab, 3 }, | ||||
{ Keys.Enter, 4 }, | ||||
{ Keys.Delete, 5 } | ||||
// Ctrl+V is special! | ||||
}; | ||||
r0 | #endregion | |||
#region Public Static Methods | ||||
public delegate GameWindow CreateWindowFunc(); | ||||
public static readonly CreateWindowFunc CreateWindow; | ||||
public delegate void DisposeWindowFunc(GameWindow window); | ||||
public static readonly DisposeWindowFunc DisposeWindow; | ||||
public delegate void ApplyWindowChangesFunc( | ||||
IntPtr window, | ||||
int clientWidth, | ||||
int clientHeight, | ||||
bool wantsFullscreen, | ||||
string screenDeviceName, | ||||
ref string resultDeviceName | ||||
); | ||||
public static readonly ApplyWindowChangesFunc ApplyWindowChanges; | ||||
r690 | public delegate void ScaleForWindowFunc(IntPtr window, bool invert, ref int w, ref int h); | |||
public static readonly ScaleForWindowFunc ScaleForWindow; | ||||
r0 | public delegate Rectangle GetWindowBoundsFunc(IntPtr window); | |||
public static readonly GetWindowBoundsFunc GetWindowBounds; | ||||
public delegate bool GetWindowResizableFunc(IntPtr window); | ||||
public static readonly GetWindowResizableFunc GetWindowResizable; | ||||
public delegate void SetWindowResizableFunc(IntPtr window, bool resizable); | ||||
public static readonly SetWindowResizableFunc SetWindowResizable; | ||||
public delegate bool GetWindowBorderlessFunc(IntPtr window); | ||||
public static readonly GetWindowBorderlessFunc GetWindowBorderless; | ||||
public delegate void SetWindowBorderlessFunc(IntPtr window, bool borderless); | ||||
public static readonly SetWindowBorderlessFunc SetWindowBorderless; | ||||
public delegate void SetWindowTitleFunc(IntPtr window, string title); | ||||
public static readonly SetWindowTitleFunc SetWindowTitle; | ||||
r690 | public delegate bool IsScreenKeyboardShownFunc(IntPtr window); | |||
public static readonly IsScreenKeyboardShownFunc IsScreenKeyboardShown; | ||||
public delegate GraphicsAdapter RegisterGameFunc(Game game); | ||||
public static readonly RegisterGameFunc RegisterGame; | ||||
r0 | ||||
r690 | public delegate void UnregisterGameFunc(Game game); | |||
public static readonly UnregisterGameFunc UnregisterGame; | ||||
public delegate void PollEventsFunc( | ||||
Game game, | ||||
ref GraphicsAdapter currentAdapter, | ||||
bool[] textInputControlDown, | ||||
ref bool textInputSuppress | ||||
r0 | ); | |||
r690 | public static readonly PollEventsFunc PollEvents; | |||
r0 | ||||
public delegate GraphicsAdapter[] GetGraphicsAdaptersFunc(); | ||||
public static readonly GetGraphicsAdaptersFunc GetGraphicsAdapters; | ||||
public delegate DisplayMode GetCurrentDisplayModeFunc(int adapterIndex); | ||||
public static readonly GetCurrentDisplayModeFunc GetCurrentDisplayMode; | ||||
public delegate Keys GetKeyFromScancodeFunc(Keys scancode); | ||||
public static readonly GetKeyFromScancodeFunc GetKeyFromScancode; | ||||
r690 | public delegate bool IsTextInputActiveFunc(); | |||
public static readonly IsTextInputActiveFunc IsTextInputActive; | ||||
r0 | public delegate void StartTextInputFunc(); | |||
public static readonly StartTextInputFunc StartTextInput; | ||||
public delegate void StopTextInputFunc(); | ||||
public static readonly StopTextInputFunc StopTextInput; | ||||
public delegate void SetTextInputRectangleFunc(Rectangle rectangle); | ||||
public static readonly SetTextInputRectangleFunc SetTextInputRectangle; | ||||
public delegate void GetMouseStateFunc( | ||||
IntPtr window, | ||||
out int x, | ||||
out int y, | ||||
out ButtonState left, | ||||
out ButtonState middle, | ||||
out ButtonState right, | ||||
out ButtonState x1, | ||||
out ButtonState x2 | ||||
); | ||||
public static readonly GetMouseStateFunc GetMouseState; | ||||
public delegate void SetMousePositionFunc( | ||||
IntPtr window, | ||||
int x, | ||||
int y | ||||
); | ||||
public static readonly SetMousePositionFunc SetMousePosition; | ||||
public delegate void OnIsMouseVisibleChangedFunc(bool visible); | ||||
public static readonly OnIsMouseVisibleChangedFunc OnIsMouseVisibleChanged; | ||||
public delegate bool GetRelativeMouseModeFunc(); | ||||
public static readonly GetRelativeMouseModeFunc GetRelativeMouseMode; | ||||
public delegate void SetRelativeMouseModeFunc(bool enable); | ||||
public static readonly SetRelativeMouseModeFunc SetRelativeMouseMode; | ||||
public delegate GamePadCapabilities GetGamePadCapabilitiesFunc(int index); | ||||
public static readonly GetGamePadCapabilitiesFunc GetGamePadCapabilities; | ||||
public delegate GamePadState GetGamePadStateFunc( | ||||
int index, | ||||
GamePadDeadZone deadZoneMode | ||||
); | ||||
public static readonly GetGamePadStateFunc GetGamePadState; | ||||
public delegate bool SetGamePadVibrationFunc( | ||||
int index, | ||||
float leftMotor, | ||||
float rightMotor | ||||
); | ||||
public static readonly SetGamePadVibrationFunc SetGamePadVibration; | ||||
r690 | public delegate bool SetGamePadTriggerVibrationFunc( | |||
int index, | ||||
float leftTrigger, | ||||
float rightTrigger | ||||
); | ||||
public static readonly SetGamePadTriggerVibrationFunc SetGamePadTriggerVibration; | ||||
r0 | public delegate string GetGamePadGUIDFunc(int index); | |||
public static readonly GetGamePadGUIDFunc GetGamePadGUID; | ||||
public delegate void SetGamePadLightBarFunc(int index, Color color); | ||||
public static readonly SetGamePadLightBarFunc SetGamePadLightBar; | ||||
r690 | public delegate bool GetGamePadGyroFunc(int index, out Vector3 gyro); | |||
public static readonly GetGamePadGyroFunc GetGamePadGyro; | ||||
public delegate bool GetGamePadAccelerometerFunc(int index, out Vector3 accel); | ||||
public static readonly GetGamePadAccelerometerFunc GetGamePadAccelerometer; | ||||
r0 | public delegate string GetStorageRootFunc(); | |||
public static readonly GetStorageRootFunc GetStorageRoot; | ||||
public delegate DriveInfo GetDriveInfoFunc(string storageRoot); | ||||
public static readonly GetDriveInfoFunc GetDriveInfo; | ||||
r690 | public delegate IntPtr ReadFileToPointerFunc(string path, out IntPtr size); | |||
public static readonly ReadFileToPointerFunc ReadFileToPointer; | ||||
public delegate void FreeFilePointerFunc(IntPtr file); | ||||
public static readonly FreeFilePointerFunc FreeFilePointer; | ||||
r0 | public delegate void ShowRuntimeErrorFunc(string title, string message); | |||
public static readonly ShowRuntimeErrorFunc ShowRuntimeError; | ||||
public delegate Microphone[] GetMicrophonesFunc(); | ||||
public static readonly GetMicrophonesFunc GetMicrophones; | ||||
public delegate int GetMicrophoneSamplesFunc( | ||||
uint handle, | ||||
byte[] buffer, | ||||
int offset, | ||||
int count | ||||
); | ||||
public static readonly GetMicrophoneSamplesFunc GetMicrophoneSamples; | ||||
public delegate int GetMicrophoneQueuedBytesFunc(uint handle); | ||||
public static readonly GetMicrophoneQueuedBytesFunc GetMicrophoneQueuedBytes; | ||||
public delegate void StartMicrophoneFunc(uint handle); | ||||
public static readonly StartMicrophoneFunc StartMicrophone; | ||||
public delegate void StopMicrophoneFunc(uint handle); | ||||
public static readonly StopMicrophoneFunc StopMicrophone; | ||||
public delegate TouchPanelCapabilities GetTouchCapabilitiesFunc(); | ||||
public static readonly GetTouchCapabilitiesFunc GetTouchCapabilities; | ||||
public delegate void UpdateTouchPanelStateFunc(); | ||||
public static readonly UpdateTouchPanelStateFunc UpdateTouchPanelState; | ||||
public delegate int GetNumTouchFingersFunc(); | ||||
public static readonly GetNumTouchFingersFunc GetNumTouchFingers; | ||||
public delegate bool SupportsOrientationChangesFunc(); | ||||
public static readonly SupportsOrientationChangesFunc SupportsOrientationChanges; | ||||
r690 | public delegate bool NeedsPlatformMainLoopFunc(); | |||
public static readonly NeedsPlatformMainLoopFunc NeedsPlatformMainLoop; | ||||
public delegate void RunPlatformMainLoopFunc(Game game); | ||||
public static readonly RunPlatformMainLoopFunc RunPlatformMainLoop; | ||||
r0 | #endregion | |||
} | ||||
} | ||||