Faction Test 100.4.0.0

This commit is contained in:
Markus Isberg
2022-11-14 18:28:28 +02:00
parent 87426b68b2
commit c772b61fc1
412 changed files with 16984 additions and 5530 deletions
@@ -106,6 +106,11 @@ namespace Microsoft.Xna.Framework {
/// This event is only supported on the Windows DirectX, Windows OpenGL and Linux platforms.
/// </remarks>
public event EventHandler<TextInputEventArgs> TextInput;
/// <summary>
/// Used for displaying uncommitted IME text.
/// </summary>
public event EventHandler<TextEditingEventArgs> TextEditing;
#endif
#endregion Events
@@ -152,6 +157,11 @@ namespace Microsoft.Xna.Framework {
{
EventHelpers.Raise(this, TextInput, e);
}
protected void OnTextEditing(object sender, TextEditingEventArgs e)
{
EventHelpers.Raise(this, TextEditing, e);
}
#endif
protected internal abstract void SetSupportedOrientations (DisplayOrientation orientations);
@@ -71,6 +71,8 @@
<Compile Include="PlayerIndex.cs" />
<Compile Include="PreparingDeviceSettingsEventArgs.cs" />
<Compile Include="ReusableItemList.cs" />
<Compile Include="TextEditingEventArgs.cs" />
<Compile Include="TextInput.cs" />
<Compile Include="TextInputEventArgs.cs">
<Platforms>Angle,Linux,MacOS,Windows,WindowsGL,WindowsUniversal</Platforms>
</Compile>
@@ -71,6 +71,8 @@
<Compile Include="PlayerIndex.cs" />
<Compile Include="PreparingDeviceSettingsEventArgs.cs" />
<Compile Include="ReusableItemList.cs" />
<Compile Include="TextEditingEventArgs.cs" />
<Compile Include="TextInput.cs" />
<Compile Include="TextInputEventArgs.cs">
<Platforms>Angle,Linux,MacOS,Windows,WindowsGL,WindowsUniversal</Platforms>
</Compile>
@@ -84,6 +84,8 @@
<Compile Include="SDL\SDL2.cs" />
<Compile Include="SDL\SDLGamePlatform.cs" />
<Compile Include="SDL\SDLGameWindow.cs" />
<Compile Include="TextEditingEventArgs.cs" />
<Compile Include="TextInput.cs" />
<Compile Include="TextInputEventArgs.cs">
<Platforms>Angle,Linux,MacOS,Windows,WindowsGL,WindowsUniversal</Platforms>
</Compile>
@@ -240,6 +240,22 @@ internal static class Sdl
return pointer;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool d_sdl_istextinputactive();
public static d_sdl_istextinputactive SDL_IsTextInputActive = FuncLoader.LoadFunction<d_sdl_istextinputactive>(NativeLibrary, "SDL_IsTextInputActive");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void d_sdl_starttextinput();
public static d_sdl_starttextinput SDL_StartTextInput = FuncLoader.LoadFunction<d_sdl_starttextinput>(NativeLibrary, "SDL_StartTextInput");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void d_sdl_stoptextinput();
public static d_sdl_stoptextinput SDL_StopTextInput = FuncLoader.LoadFunction<d_sdl_stoptextinput>(NativeLibrary, "SDL_StopTextInput");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void d_sdl_settextinputrect(ref Rectangle rect);
public static d_sdl_settextinputrect SDL_SetTextInputRect = FuncLoader.LoadFunction<d_sdl_settextinputrect>(NativeLibrary, "SDL_SetTextInputRect");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void d_sdl_clearerror();
public static d_sdl_clearerror ClearError = FuncLoader.LoadFunction<d_sdl_clearerror>(NativeLibrary, "SDL_ClearError");
@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
@@ -136,8 +137,7 @@ namespace Microsoft.Xna.Framework
{
var key = KeyboardUtil.ToXna(ev.Key.Keysym.Sym);
if (!_keys.Contains(key))
_keys.Add(key);
if (!_keys.Contains(key)) _keys.Add(key);
//TODO: rethink all of this
char character = (char)KeyboardUtil.ApplyModifiers(ev.Key.Keysym.Sym, ev.Key.Keysym.Mod);
@@ -161,24 +161,23 @@ namespace Microsoft.Xna.Framework
var key = KeyboardUtil.ToXna(ev.Key.Keysym.Sym);
_keys.Remove(key);
}
else if (ev.Type == Sdl.EventType.TextEditing)
{
string text;
unsafe { text = ReadString(ev.Text.Text); }
_view.CallTextEditing(text, ev.Edit.Start, ev.Edit.Length);
}
else if (ev.Type == Sdl.EventType.TextInput)
{
int len = 0;
string text = String.Empty;
unsafe
string text;
unsafe { text = ReadString(ev.Text.Text); }
if (text.Length is 0) { continue; }
foreach (char c in text)
{
while (Marshal.ReadByte ((IntPtr)ev.Text.Text, len) != 0) {
len++;
}
var buffer = new byte [len];
Marshal.Copy ((IntPtr)ev.Text.Text, buffer, 0, len);
text = System.Text.Encoding.UTF8.GetString (buffer);
}
if (text.Length == 0)
continue;
foreach (var c in text)
{
var key = KeyboardUtil.ToXna((int)c);
var key = KeyboardUtil.ToXna(c);
_view.CallTextInput(c, key);
}
}
@@ -194,11 +193,22 @@ namespace Microsoft.Xna.Framework
IsActive = false;
else if (ev.Window.EventID == Sdl.Window.EventId.Moved)
_view.Moved();
else if (ev.Window.EventID == Sdl.Window.EventId.Close)
_isExiting++;
else if (ev.Window.EventID == Sdl.Window.EventId.Close) _isExiting++;
}
}
}
static unsafe string ReadString(byte* ptr)
{
int len = 0;
while (Marshal.ReadByte((IntPtr)ptr, len) != 0)
{
len++;
}
var buffer = new byte [len];
Marshal.Copy((IntPtr)ptr, buffer, 0, len);
return Encoding.UTF8.GetString(buffer);
}
}
public override void StartRunLoop()
@@ -113,6 +113,12 @@ namespace Microsoft.Xna.Framework
Sdl.SetHint("SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS", "0");
Sdl.SetHint("SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS", "1");
/*
* By default SDL2 will hide IME popups since it probably assumes the game will implement their own suggestions box.
* We don't want that, so this hint will allow the system native IME popups to show up when typing in the game.
*/
Sdl.SetHint("SDL_HINT_IME_SHOW_UI", "1");
// when running NUnit tests entry assembly can be null
if (Assembly.GetEntryAssembly() != null)
{
@@ -333,6 +339,11 @@ namespace Microsoft.Xna.Framework
OnTextInput(this, new TextInputEventArgs(c, key));
}
public void CallTextEditing(string text, int start, int length)
{
OnTextEditing(this, new TextEditingEventArgs(text, start, length));
}
public void DropFile(string filePath)
{
OnFileDropped(new FileDropEventArgs(filePath));
@@ -0,0 +1,17 @@
using System;
namespace Microsoft.Xna.Framework
{
public sealed class TextEditingEventArgs : EventArgs
{
public readonly string Text;
public readonly int Start;
public readonly int Length;
public TextEditingEventArgs(string text, int start, int length)
{
Text = text;
Start = start;
Length = length;
}
}
}
@@ -0,0 +1,29 @@
#nullable enable
namespace Microsoft.Xna.Framework
{
public static class TextInput
{
public static void StartTextInput()
{
Sdl.SDL_StartTextInput();
}
public static void StopTextInput()
{
Sdl.SDL_StopTextInput();
}
public static void SetTextInputRect(Rectangle rectangle)
{
Sdl.Rectangle r = new Sdl.Rectangle
{
X = rectangle.X,
Y = rectangle.Y,
Width = rectangle.Width,
Height = rectangle.Height
};
Sdl.SDL_SetTextInputRect(ref r);
}
}
}
Binary file not shown.
Binary file not shown.