Fix various platform issues and slightly improve UI

* Fix crash on lower screen resolutions when clicking on Terminal

Mouse coordinates were not being scaled from screenspace into
canvas space, resulting in a crash when clicking on the Terminal.

Also add documentation for internal VirtualScreen
implementation, and define dynamic properties for
CanvasWidth and CanvasHeight in the UI system.

Issue: #13
Signed-off-by: Ritchie Frodomar <alkalinethunder@gmail.com>

* Remove old GuiService virtual screen and document IVirtualScreen

Whoever wrote that old code was high, fuck... wait a minute...

Signed-off-by: Ritchie Frodomar <alkalinethunder@gmail.com>

* Fix various errors after emergency rebase

* Remove Rider caches

* Attempt to enable Wayland support

* Add support for enabling/disabling Wayland support on Linux

* Move SettingsManager to GameApplication so settings can be loaded before the game engine fully boots.

* Test commit.

Signed-off-by: Ritchie Frodomar <alkalinethunder@gmail.com>

* Move Terminals to their own tile

* Add support for getting CPU name on Windows via registry

* Add support for disabling background blur

* Fix window hints not being restored when switching between main tool tabs

* Testing the DCO acknowledgement job

Signed-off-by: Ritchie Frodomar <alkalinethunder@gmail.com>
This commit is contained in:
Ritchie Frodomar 2024-10-28 03:17:01 +00:00
parent 7f8f7dbf42
commit 75c8b5432c
1256 changed files with 7908 additions and 7874 deletions

0
.config/dotnet-tools.json Normal file → Executable file
View file

3
.gitignore vendored
View file

@ -1,3 +1,6 @@
# Rider caches
.idea/
# docfx
api/
public/

0
.gitlab-ci.yml Normal file → Executable file
View file

0
Assets/Assets/Core/WebSites.meta Normal file → Executable file
View file

0
Assets/Assets/Core/WebSites/404.prefab Normal file → Executable file
View file

0
Assets/Assets/Core/WebSites/404.prefab.meta Normal file → Executable file
View file

0
Assets/Assets/Core/WebSites/TheMissingPage.asset Normal file → Executable file
View file

0
Assets/Assets/Core/WebSites/TheMissingPage.asset.meta Normal file → Executable file
View file

0
Assets/Assets/Main/Websites/NewCipherToday.asset Normal file → Executable file
View file

0
Assets/Assets/Main/Websites/NewCipherToday.asset.meta Normal file → Executable file
View file

0
Assets/Assets/Main/Websites/NewCipherToday.prefab Normal file → Executable file
View file

0
Assets/Assets/Main/Websites/NewCipherToday.prefab.meta Normal file → Executable file
View file

0
Assets/Editor/CustomImporters/ArticleImporter.cs Normal file → Executable file
View file

View file

View file

0
Assets/Scripts/UI/Shell/ShellNavigationLink.cs Normal file → Executable file
View file

0
Assets/Scripts/UI/Shell/ShellNavigationLink.cs.meta Normal file → Executable file
View file

0
Assets/Scripts/UI/Websites/News.meta Normal file → Executable file
View file

0
Assets/Scripts/UI/Websites/News/NewsWebSite.cs Normal file → Executable file
View file

0
Assets/Scripts/UI/Websites/News/NewsWebSite.cs.meta Normal file → Executable file
View file

0
Assets/Scripts/UI/Widgets/Prefabs/SocialPost.prefab Normal file → Executable file
View file

View file

View file

View file

0
Assets/Scripts/UI/Widgets/Settings/SocialPostWidget.cs Normal file → Executable file
View file

View file

View file

View file

View file

View file

0
CONTRIBUTING.md Normal file → Executable file
View file

0
LICENSE Normal file → Executable file
View file

0
README.md Normal file → Executable file
View file

0
mgfxc-wine-setup.sh Normal file → Executable file
View file

View file

@ -1,13 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/contentModel.xml
/.idea.sociallydistant.iml
/projectSettingsUpdater.xml
/modules.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View file

@ -1 +0,0 @@
sociallydistant

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders>
<Path>../docs</Path>
</attachedFolders>
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

0
src/AcidicGUI/AcidicGUI.csproj Normal file → Executable file
View file

0
src/AcidicGUI/ColorHelpers.cs Normal file → Executable file
View file

0
src/AcidicGUI/CustomProperties/CanvasAnchors.cs Normal file → Executable file
View file

0
src/AcidicGUI/CustomProperties/CustomPropertyObject.cs Normal file → Executable file
View file

2
src/AcidicGUI/CustomProperties/FlexPanelProperties.cs Normal file → Executable file
View file

@ -14,7 +14,7 @@ public sealed class FlexPanelProperties : CustomPropertyObject
get => proportionalValue;
set
{
proportionalValue = MathHelper.Clamp(value, 0f, 1f);
proportionalValue = Math.Max(0, value);
Widget.InvalidateLayout();
}
}

0
src/AcidicGUI/CustomProperties/StructProperty.cs Normal file → Executable file
View file

4
src/AcidicGUI/Effects/IEffect.cs Normal file → Executable file
View file

@ -1,5 +1,3 @@
using Microsoft.Xna.Framework;
namespace AcidicGUI.Effects;
public interface IEffect
@ -7,5 +5,5 @@ public interface IEffect
int PassesCount { get; }
void Use(int pass);
void UpdateWidgetParameters(float opacity, Matrix widgetTransform);
void UpdateOpacity(float opacity);
}

0
src/AcidicGUI/Effects/IWidgetEffect.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/FocusEvent.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/GuiEvent.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IDragEndHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IDragHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IDragStartHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IGainFocusHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IKeyCharHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IKeyDownHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IKeyUpHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/ILoseFocusHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IMouseClickHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IMouseDownHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IMouseEnterHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IMouseHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IMouseLeaveHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IMouseMoveHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IMouseScrollHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IMouseUpHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IPreviewKeyCharHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IPreviewKeyDownHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IPreviewKeyUpHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/IUpdateHandler.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/KeyCharEvent.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/KeyEvent.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/ModifierKeys.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/MouseButtonEvent.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/MouseEvent.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/MouseMoveEvent.cs Normal file → Executable file
View file

0
src/AcidicGUI/Events/MouseScrollEvent.cs Normal file → Executable file
View file

39
src/AcidicGUI/GuiManager.cs Normal file → Executable file
View file

@ -1,5 +1,4 @@
using AcidicGUI.Animation;
using AcidicGUI.Events;
using AcidicGUI.Events;
using AcidicGUI.Layout;
using AcidicGUI.Rendering;
using AcidicGUI.TextRendering;
@ -48,6 +47,18 @@ public sealed class GuiManager : IFontFamilyProvider
visualStyleOverride = globalStyle;
}
/// <summary>
/// Invalidates the geometry of all interface elements recursively. Use this when changing a global UI setting that affects how all widgets render.
/// Note: This is expensive. That should be obvious. So do not call it every frame.
/// </summary>
public void InvalidateAllGeometry()
{
foreach (var toplevel in TopLevels)
{
toplevel.InvalidateGeometry(true);
}
}
public bool IsFocused(Widget widget)
{
return widget == keyboardFocus;
@ -79,7 +90,7 @@ public sealed class GuiManager : IFontFamilyProvider
? ButtonState.Pressed
: ButtonState.Released;
HandleMouseButton(e.Button, previousState, e.ButtonState, e.Position, Point.Zero);
HandleMouseButton(e.Button, previousState, e.ButtonState, TranslateMousePosition(e.Position), Point.Zero);
if (e.ButtonState == ButtonState.Pressed)
{
@ -191,11 +202,11 @@ public sealed class GuiManager : IFontFamilyProvider
var mustRebuildLayout = false;
var tolerance = 0.001f;
if (MathF.Abs(screenWidth - context.PhysicalScreenWidth) >= tolerance
|| MathF.Abs(screenHeight - context.PhysicalScreenHeight) >= tolerance)
if (MathF.Abs(screenWidth - context.CanvasWidth) >= tolerance
|| MathF.Abs(screenHeight - context.CanvasHeight) >= tolerance)
{
screenWidth = context.PhysicalScreenWidth;
screenHeight = context.PhysicalScreenHeight;
screenWidth = context.CanvasWidth;
screenHeight = context.CanvasHeight;
mustRebuildLayout = true;
}
@ -211,9 +222,7 @@ public sealed class GuiManager : IFontFamilyProvider
public void Update(float deltaTime)
{
Animator.Update(deltaTime);
foreach (Widget widget in this.CollapseChildren())
foreach (Widget widget in CollapseChildren())
{
if (widget is IUpdateHandler handler)
handler.Update(deltaTime);
@ -232,10 +241,12 @@ public sealed class GuiManager : IFontFamilyProvider
{
isRendering = true;
//renderer.SetLayer(-32768);
renderer.SetLayer(-32768);
foreach (Widget widget in topLevels)
widget.RenderInternal(renderer, Matrix.Identity);
widget.RenderInternal(renderer);
renderer.RenderBatches();
isRendering = false;
}
@ -286,9 +297,9 @@ public sealed class GuiManager : IFontFamilyProvider
{
return new Vector2(
((float)mousePosition.X / context.GraphicsDevice.PresentationParameters.BackBufferWidth) *
context.PhysicalScreenWidth,
context.CanvasWidth,
((float)mousePosition.Y / context.GraphicsDevice.PresentationParameters.BackBufferHeight) *
context.PhysicalScreenHeight
context.CanvasHeight
).ToPoint();
}

0
src/AcidicGUI/GuiSynchronizationContext.cs Normal file → Executable file
View file

20
src/AcidicGUI/IGuiContext.cs Normal file → Executable file
View file

@ -1,28 +1,20 @@
using AcidicGUI.Effects;
using AcidicGUI.Layout;
using AcidicGUI.TextRendering;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace AcidicGUI;
public interface IGuiContext
{
int PhysicalScreenWidth { get; }
int PhysicalScreenHeight { get; }
int PhysicalWidth { get; }
int PhysicalHeight { get; }
int CanvasWidth { get; }
int CanvasHeight { get; }
GraphicsDevice GraphicsDevice { get; }
void Render(
VertexBuffer vertices,
IndexBuffer indices,
int offset,
int primitiveCount,
Texture2D? texture,
LayoutRect? clipRect = null,
IEffect? effectOverride = null,
float opacity = 1,
Matrix? widgetTransform = null
);
void Render(VertexPositionColorTexture[] vertices, int[] indices, Texture2D? texture, LayoutRect? clipRect = null);
void Render(VertexBuffer vertices, IndexBuffer indices, int offset, int primitiveCount, Texture2D? texture, LayoutRect? clipRect = null, IEffect? effectOverride = null, float opacity = 1);
/// <summary>
/// Renders the user interface to the given RenderTarget2D. Useful for certain widget rendering techniques such as background blurs.

0
src/AcidicGUI/IOrderedCollection.cs Normal file → Executable file
View file

0
src/AcidicGUI/Layout/Direction.cs Normal file → Executable file
View file

0
src/AcidicGUI/Layout/FlexMode.cs Normal file → Executable file
View file

0
src/AcidicGUI/Layout/HorizontalAlignment.cs Normal file → Executable file
View file

0
src/AcidicGUI/Layout/LayoutRect.cs Normal file → Executable file
View file

0
src/AcidicGUI/Layout/Padding.cs Normal file → Executable file
View file

0
src/AcidicGUI/Layout/TextAlignment.cs Normal file → Executable file
View file

0
src/AcidicGUI/Layout/VerticalAlignment.cs Normal file → Executable file
View file

0
src/AcidicGUI/ListAdapters/DataHelper.cs Normal file → Executable file
View file

0
src/AcidicGUI/ListAdapters/INotifyDataChanged.cs Normal file → Executable file
View file

0
src/AcidicGUI/ListAdapters/ListAdapter.cs Normal file → Executable file
View file

View file

0
src/AcidicGUI/ListAdapters/RecycleBin.cs Normal file → Executable file
View file

0
src/AcidicGUI/ListAdapters/ViewHolder.cs Normal file → Executable file
View file

5
src/AcidicGUI/Rendering/GeometryHelper.cs Normal file → Executable file
View file

@ -25,6 +25,11 @@ public class GeometryHelper : IFontStashRenderer2
whiteMesh = new GuiMeshBuilder(this, null, desaturate);
}
public void PushLayer()
{
guiRenderer.PushLayer();
}
private void Flush()
{
flushedMeshes.Add(whiteMesh.ExportSubMesh());

0
src/AcidicGUI/Rendering/GuiMesh.cs Normal file → Executable file
View file

0
src/AcidicGUI/Rendering/GuiMeshBuilder.cs Normal file → Executable file
View file

36
src/AcidicGUI/Rendering/Vertex.cs Normal file → Executable file
View file

@ -1,18 +1,15 @@
using AcidicGUI.Effects;
using AcidicGUI.Layout;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace AcidicGUI.Rendering;
public sealed class GuiRenderer
{
private GuiBatch? whiteBatch;
private readonly Dictionary<Texture2D, GuiBatch> batches = new();
private readonly IGuiContext context;
private readonly Stack<Matrix> previousMatrices = new();
private Matrix currentMatrix = Matrix.Identity;
private GuiBatch? whiteBatch;
private float layer;
private float layer;
public GuiRenderer(IGuiContext context)
{
@ -21,21 +18,19 @@ public sealed class GuiRenderer
public float Layer => layer;
public void PushTransformMatrix(Matrix matrix)
public void SetLayer(float newLayer)
{
previousMatrices.Push(currentMatrix);
currentMatrix *= matrix;
layer = newLayer;
}
public void PopTransformMatrix()
public void PushLayer()
{
if (previousMatrices.Count == 0)
{
currentMatrix = Matrix.Identity;
return;
}
layer += 0.5f;
}
currentMatrix = previousMatrices.Pop();
public void PopLayer()
{
layer--;
}
public void RenderGuiMesh(GuiMesh mesh)
@ -87,10 +82,10 @@ public sealed class GuiRenderer
public void RenderBatches(IEffect? effectOverride = null, float opacity = 1, LayoutRect? clipRect = null)
{
whiteBatch?.DrawBatch(effectOverride, opacity, clipRect, currentMatrix);
whiteBatch?.DrawBatch(effectOverride, opacity, clipRect);
foreach (GuiBatch batch in batches.Values)
batch.DrawBatch(effectOverride, opacity, clipRect, currentMatrix);
batch.DrawBatch(effectOverride, opacity, clipRect);
}
public void Grab(RenderTarget2D destination)
@ -170,9 +165,6 @@ public sealed class GuiBatch
public void Submit(GuiSubMesh subMesh)
{
if (subMesh.Vertices.Length == 0 || subMesh.Indices.Length == 0)
return;
if (subMesh.IsNew)
{
subMesh.MarkAsOld();
@ -189,7 +181,7 @@ public sealed class GuiBatch
cpuIndices.AddRange(subMesh.Indices);
}
public void DrawBatch(IEffect? effectOverride, float opacity, LayoutRect? clipRect, Matrix widgetTransform)
public void DrawBatch(IEffect? effectOverride, float opacity, LayoutRect? clipRect)
{
if (cpuIndices.Count == 0 || cpuVertices.Count == 0)
return;
@ -221,7 +213,7 @@ public sealed class GuiBatch
dirty = false;
}
context.Render(vertexBuffer, indexBuffer, 0, cpuIndices.Count / 3, texture, clipRect, effectOverride, opacity, widgetTransform);
context.Render(vertexBuffer, indexBuffer, 0, cpuIndices.Count / 3, texture, clipRect, effectOverride, opacity);
cpuVertices.Clear();
cpuIndices.Clear();

0
src/AcidicGUI/Sdl@platform.cs Normal file → Executable file
View file

0
src/AcidicGUI/TextRendering/DynamicFont.cs Normal file → Executable file
View file

0
src/AcidicGUI/TextRendering/Font.cs Normal file → Executable file
View file

Some files were not shown because too many files have changed in this diff Show more