diff --git a/CHANGELOG.md b/CHANGELOG.md
index 077d9057..1c3a83a1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,10 @@
-# 2021.05.04.1640
+# 2021.505.2105
+This version is an official release
+
+## Client
++ Fixed embedding/integration of the client in the game window.
+
+# 2021.504.1640
## Launcher
+ Launcher Visual overhaul (work in progress)
+ Added Settings pages
diff --git a/PataNext.Export.Desktop.Tests/KeyboardListenerTest.cs b/PataNext.Export.Desktop.Tests/KeyboardListenerTest.cs
new file mode 100644
index 00000000..751c82bb
--- /dev/null
+++ b/PataNext.Export.Desktop.Tests/KeyboardListenerTest.cs
@@ -0,0 +1,9 @@
+using System;
+using System.Collections.Generic;
+using GameHost.Inputs.Systems;
+using SharpInputSystem;
+
+namespace PataNext.Export.Desktop.Tests
+{
+
+}
\ No newline at end of file
diff --git a/PataNext.Export.Desktop.Tests/PataNext.Export.Desktop.Tests.csproj b/PataNext.Export.Desktop.Tests/PataNext.Export.Desktop.Tests.csproj
index 3743b1f0..dbe7ea7c 100644
--- a/PataNext.Export.Desktop.Tests/PataNext.Export.Desktop.Tests.csproj
+++ b/PataNext.Export.Desktop.Tests/PataNext.Export.Desktop.Tests.csproj
@@ -14,7 +14,7 @@
-
+
diff --git a/PataNext.Export.Desktop.Tests/Visual/GithubChangelogScene.cs b/PataNext.Export.Desktop.Tests/Visual/GithubChangelogScene.cs
new file mode 100644
index 00000000..a225b2d2
--- /dev/null
+++ b/PataNext.Export.Desktop.Tests/Visual/GithubChangelogScene.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Net;
+using osu.Framework.Allocation;
+using osu.Framework.Graphics;
+using osu.Framework.Testing;
+using osuTK;
+using PataNext.Export.Desktop.Visual;
+using PataNext.Export.Desktop.Visual.Dependencies;
+
+namespace PataNext.Export.Desktop.Tests.Visual
+{
+ public class GithubChangelogScene : TestScene
+ {
+ [BackgroundDependencyLoader]
+ private void load()
+ {
+ var changelog = new HomeChangelogControl {Size = Vector2.One, RelativeSizeAxes = Axes.Both};
+ Child = changelog;
+
+ var provider = new WebChangelogProvider(new("https://raw.githubusercontent.com/guerro323/patanext/master/CHANGELOG.md"), Scheduler);
+ provider.Current.BindValueChanged(ev =>
+ {
+ if (ev.NewValue == null)
+ return;
+
+ changelog.Set("test", ev.NewValue);
+ });
+ }
+ }
+}
\ No newline at end of file
diff --git a/PataNext.Export.Desktop.Tests/Visual/LauncherScene.cs b/PataNext.Export.Desktop.Tests/Visual/LauncherScene.cs
index 4c600fc5..e19a2cec 100644
--- a/PataNext.Export.Desktop.Tests/Visual/LauncherScene.cs
+++ b/PataNext.Export.Desktop.Tests/Visual/LauncherScene.cs
@@ -1,7 +1,10 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Drawing;
using System.Linq;
+using GameHost.Game;
+using GameHost.IO;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@@ -15,15 +18,19 @@
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Framework.Logging;
+using osu.Framework.Platform;
using osu.Framework.Platform.Windows;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Framework.Threading;
using osuTK;
using PataNext.Export.Desktop.Visual;
+using PataNext.Export.Desktop.Visual.Configuration;
using PataNext.Export.Desktop.Visual.Dependencies;
using PataNext.Export.Desktop.Visual.Screens;
using PataNext.Export.Desktop.Visual.Screens.Section;
+using SharpInputSystem;
+using SharpInputSystem.DirectX;
namespace PataNext.Export.Desktop.Tests.Visual
{
@@ -39,278 +46,60 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
{
return dependencies = new(base.CreateChildDependencies(parent));
}
-
- public LauncherScene()
- {
- //var t = typeof(ClientSectionScreen);
-
- /*Add(new Box
- {
- Anchor = Anchor.TopCentre,
- Shear = new(0.5f, 0),
- Size = new Vector2(120, 60)
- });*/
-
- /*RelativeSizeAxes = Axes.None;
- Size = new(1920, 1080);*/
- }
+
[Resolved]
private TextureStore textures { get; set; }
[BackgroundDependencyLoader]
- private void load()
+ private void load(Storage storage)
{
- Sidebar sidebar;
- HomeLogoVisual logo;
-
- ScreenStack screenStack;
-
dependencies.CacheAs(new CurrentVersion()
{
Current = {Value = "2021.04.15"}
});
- dependencies.CacheAs(new UpdatePatchDownload(Scheduler)
+ dependencies.CacheAs(new PatchProvider(Scheduler)
{
+ });
+ dependencies.CacheAs(new NotificationsProvider());
+ dependencies.CacheAs(new WebChangelogProvider(new("https://raw.githubusercontent.com/guerro323/patanext/master/CHANGELOG.md"), Scheduler));
+ dependencies.Cache(new LauncherConfigurationManager(storage));
+
+ var gameBootstrap = new GameBootstrap(); // we don't need to have a full bootstrap here, we just need some dependencies data
+ gameBootstrap.GameEntity.Set(new GameName("PataNext"));
+ gameBootstrap.GameEntity.Set(new GameUserStorage(new LocalStorage(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/PataNext")));
+
+ var inputManager = InputManager.CreateInputSystem(typeof(DirectXInputManagerFactory), new ParameterList
+ {
+ new("WINDOW", Process.GetCurrentProcess().MainWindowHandle)
});
- dependencies.CacheAs(new GlobalNotifications());
+ dependencies.CacheAs(inputManager);
+
+ gameBootstrap.Setup();
+
+ dependencies.Cache(gameBootstrap);
- Add(new DrawSizePreservingFillContainer()
+ Add(new LauncherMainScene()
{
/*Strategy = DrawSizePreservationStrategy.Minimum,
FillAspectRatio = 16 / 9f,
FillMode = FillMode.Fit,*/
-
- Children = new Drawable[]
- {
- new Box
- {
- Size = Vector2.One,
- RelativeSizeAxes = Axes.Both,
- Colour = Colour4.FromHex("be5a7f"),
- },
- new Sprite
- {
- Size = Vector2.One,
- RelativeSizeAxes = Axes.Both,
- Colour = Colour4.White,
-
- Scale = new(1.03f),
- Position = new(0, -31f),
-
- Origin = Anchor.Centre,
- Anchor = Anchor.Centre,
- FillMode = FillMode.Fill,
-
- Texture = textures.Get("patanext_background_2")
- },
-
- new DrawSizePreservingFillContainer
- {
- RelativeSizeAxes = Axes.Both,
- Size = new Vector2(0.97f, 0.8f),
-
- Origin = Anchor.TopCentre,
- Anchor = Anchor.TopCentre,
-
- RelativePositionAxes = Axes.Both,
- RelativeAnchorPosition = new Vector2(0.5f, 0.2f),
-
- Child = screenStack = new()
- {
- Size = new(1),
- RelativeSizeAxes = Axes.Both
- }
- },
-
- /*new DrawSizePreservingFillContainer
- {
- RelativeSizeAxes = Axes.X,
- Size = new(1, 500f),
-
- Position = new(0, 50),
-
- Origin = Anchor.BottomCentre,
- Anchor = Anchor.BottomCentre,
-
- FillAspectRatio = 16f / 9f,
- FillMode = FillMode.Stretch,
-
- Children = new Drawable[]
- {
- new NotificationPopup
- {
- FillAspectRatio = 906f / 89f,
- FillMode = FillMode.Fit,
-
- Origin = Anchor.Centre,
- Anchor = Anchor.Centre,
-
- RelativeSizeAxes = Axes.Both,
- Size = new(0.47f, 0.1f),
-
- Position = new(0, 65),
-
- Font = new FontUsage("ar_cena", size: 21.5f),
-
- Title = "Information",
- Text = "Update \"2021.04.15b\" is available!"
- },
-
- playBarControl = new ProgressPlayBarControl
- {
- FillAspectRatio = 1303f / 125f,
- FillMode = FillMode.Fit,
-
- RelativeSizeAxes = Axes.Both,
- Size = new(0.68f, 0.1425f),
-
- Origin = Anchor.Centre,
- Anchor = Anchor.Centre,
- },
- }
- },*/
-
- new Container()
- {
- Origin = Anchor.TopCentre,
- Anchor = Anchor.TopCentre,
-
- RelativeSizeAxes = Axes.Both,
- Size = new(1, 0.25f),
-
- Children = new Drawable[]
- {
- sidebar = new Sidebar()
- {
- Origin = Anchor.CentreLeft,
- Anchor = Anchor.CentreLeft,
- Padding = new() {Left = 16},
-
- RelativeSizeAxes = Axes.X,
- Size = new(0.38f, 43f),
- },
- logo = new HomeLogoVisual(textures.Get("patanext_logo"), textures.Get("patanext_logo_blur"))
- {
- Origin = Anchor.Centre,
- Anchor = Anchor.Centre,
-
- Size = new Vector2(358, 218),
- Position = new Vector2(0, -20)
- },
- new Sidebar()
- {
- Origin = Anchor.CentreRight,
- Anchor = Anchor.CentreRight,
- Padding = new() {Right = 16},
-
- RelativeSizeAxes = Axes.X,
- Size = new(0.38f, 43f),
-
- Flip = true,
- }
- }
- }
- }
});
- sidebar.Menu.AddItem(new(textures.Get("sidebar_settings"), "Settings", () => new()));
- sidebar.Menu.AddItem(new(textures.Get("sidebar_changelogs"), "Changelogs", () =>
- {
- var screen = new HomeChangelogScreen();
- screen.Control.Set("2021.04.15", new()
- {
- {
- "2021.04.15", new[]
- {
- "#Launcher",
- "+ New launcher visual overhaul",
- "+ Inputs Settings Interface",
- "#Online",
- "+ Connection to MasterServer",
- }
- },
- {
- "2021.03.10", new[]
- {
- "+ Some random new stuff added"
- }
- },
- {
- "2021.03.09", new[]
- {
- "+ New launcher visual overhaul",
- "+ Connection to MasterServer",
- "+ Inputs Settings Interface"
- }
- },
- {
- "2021.03.08", new[]
- {
- "+ Some random new stuff added"
- }
- },
- {
- "2021.03.07", new[]
- {
- "+ New launcher visual overhaul",
- "+ Connection to MasterServer",
- "+ Inputs Settings Interface"
- }
- },
- {
- "2021.03.06", new[]
- {
- "+ Some random new stuff added"
- }
- }
- });
-
- return screen;
- }));
-
- sidebar.Menu.SelectFirstTabByDefault = false;
-
- sidebar.Menu.Current.SetDefault();
-
- sidebar.Menu.Current.BindValueChanged(ev =>
- {
- if (screenStack.CurrentScreen is not null)
- screenStack.Exit();
-
- if (ev.NewValue is { } entry)
- {
- // todo: some other stuff
-
- logo.Active.Value = false;
-
- screenStack.Push(ev.NewValue.ScreenFactory());
- }
- else
- {
- logo.Active.Value = true;
-
- var homePlay = new HomePlayScreen();
- screenStack.Push(homePlay);
- }
- }, true);
-
- logo.Action = () => { sidebar.Menu.Current.SetDefault(); };
-
/*n.Clicked += () =>
{
Logger.Log("launch update!", LoggingTarget.Information, LogLevel.Important);
};*/
- AddToggleStep("IsUpdate", b => Dependencies.Get().IsUpdating.Value = b);
- AddSliderStep("UpdateProgress", 0, 1, 0f, f => Dependencies.Get().Progress.Value = f);
+ AddToggleStep("IsUpdate", b => Dependencies.Get().IsUpdating.Value = b);
+ AddSliderStep("UpdateProgress", 0, 1, 0f, f => Dependencies.Get().Progress.Value = f);
AddStep("Add Update", () =>
{
- var notifications = Dependencies.Get();
+ var notifications = Dependencies.Get();
- var updateNotification = new NotificationPopup
+ var updateNotification = new Notification
{
Title = "Information",
Text = "Update Available!",
@@ -319,7 +108,7 @@ private void load()
updateNotification.Action = () =>
{
- var updatePatch = Dependencies.Get();
+ var updatePatch = Dependencies.Get();
updatePatch.StartDownload();
notifications.Remove(updateNotification);
@@ -335,7 +124,7 @@ class CurrentVersion : ICurrentVersion
public Bindable Current { get; } = new();
}
- class UpdatePatchDownload : IUpdatePatchDownload
+ class PatchProvider : IPatchProvider
{
public Bindable Version { get; } = new();
public BindableBool IsUpdating { get; } = new();
@@ -344,7 +133,7 @@ class UpdatePatchDownload : IUpdatePatchDownload
private Scheduler scheduler;
- public UpdatePatchDownload(Scheduler scheduler)
+ public PatchProvider(Scheduler scheduler)
{
this.scheduler = scheduler;
}
@@ -370,13 +159,13 @@ public void UpdateAndRestart()
}
}
- class GlobalNotifications : IGlobalNotifications
+ class NotificationsProvider : INotificationsProvider
{
- private List notifications = new();
+ private List notifications = new();
- public IReadOnlyList GetAll() => notifications;
+ public IReadOnlyList GetAll() => notifications;
- public void Push(NotificationBase notification)
+ public void Push(Notification notification)
{
notifications.Add(notification);
OnNotificationAdded?.Invoke(notification);
@@ -396,13 +185,13 @@ public void Clear(Type type)
notifications.RemoveAll(n => n.GetType().IsSubclassOf(type));
}
- public void Remove(NotificationBase notification)
+ public void Remove(Notification notification)
{
if (notifications.Remove(notification))
OnNotificationRemoved?.Invoke(notification);
}
- public event Action OnNotificationAdded;
- public event Action OnNotificationRemoved;
+ public event Action OnNotificationAdded;
+ public event Action OnNotificationRemoved;
}
}
\ No newline at end of file
diff --git a/PataNext.Export.Desktop/BringIntegratedClientInFrontSystem.cs b/PataNext.Export.Desktop/BringIntegratedClientInFrontSystem.cs
index 5f0dccec..a007d20f 100644
--- a/PataNext.Export.Desktop/BringIntegratedClientInFrontSystem.cs
+++ b/PataNext.Export.Desktop/BringIntegratedClientInFrontSystem.cs
@@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
+using System.Threading;
using GameHost.Applications;
using GameHost.Core.Client;
using GameHost.Core.Ecs;
@@ -33,16 +34,16 @@ public override bool CanUpdate()
protected override void OnUpdate()
{
base.OnUpdate();
- return; // quite buggy
- if (timeBeforeEnablingMainWindow > 0
+ // quite buggy
+ /*if (timeBeforeEnablingMainWindow > 0
&& timeBeforeEnablingMainWindow < Environment.TickCount)
{
timeBeforeEnablingMainWindow = -1;
SetFocus(IntPtr.Zero);
EnableWindow(visualHwnd.Value, false);
return;
- }
+ }*/
visualHwnd = World.Mgr.Get()[0];
foreach (var gameClient in World.Mgr.Get())
@@ -54,30 +55,56 @@ protected override void OnUpdate()
{
if (visualHwnd.ShowIntegratedWindows)
{
- SetWindowPos(gameClient.Hwnd, IntPtr.Zero, 0, 0, visualHwnd.Size.X, visualHwnd.Size.Y, (uint) 0);
+ SetWindowPos(gameClient.Hwnd, IntPtr.Zero, 0, 0,visualHwnd.Size.X, visualHwnd.Size.Y, (uint) 0);
SetFocus(IntPtr.Zero);
SetFocus(visualHwnd.Value);
EnableWindow(visualHwnd.Value, true);
+
+ SendMessage(gameClient.Hwnd, WM_ACTIVATE, WA_ACTIVE, 0);
+ SendMessage(visualHwnd.Value, WM_ACTIVATE, WA_INACTIVE, 0);
}
else
{
DeactivateClientWindow(gameClient.Hwnd);
- SetWindowPos(gameClient.Hwnd, IntPtr.Zero, -visualHwnd.Size.X, 0, visualHwnd.Size.X, visualHwnd.Size.Y, (uint) 0);
- SetFocus(visualHwnd.Value);
+ //SetWindowPos(gameClient.Hwnd, IntPtr.Zero, -visualHwnd.Size.X, 0, visualHwnd.Size.X, visualHwnd.Size.Y, (uint) 0x0010);
+ ShowWindow(gameClient.Hwnd, 0);
+ ShowWindow(visualHwnd.Value, 0);
+ EnableWindow(visualHwnd.Value, true);
gameClient.IsHwndInFront = false;
+
+ SendMessage(visualHwnd.Value, WM_ACTIVATE, WA_ACTIVE, 0);
+
+ Console.WriteLine("disable!");
+
+ visualHwnd.RequireSwap = true;
+ World.Mgr.Get()[0] = visualHwnd;
}
}
if (gameClient.IsHwndInFront || !visualHwnd.ShowIntegratedWindows)
continue;
+ Thread.Sleep(100);
+
EnumChildWindows(visualHwnd.Value, (hwnd, lparam) =>
{
gameClient.Hwnd = hwnd;
gameClient.IsHwndInFront = true;
- ActivateClientWindow(gameClient.Hwnd);
+ /*ActivateClientWindow(gameClient.Hwnd);
+ EnableWindow(gameClient.Hwnd, true);
+ SetFocus(hwnd);*/
+ //ActivateClientWindow(hwnd);
+ SendMessage(hwnd, 6, 1, 0);
return 0;
}, IntPtr.Zero);
+
+ SetWindowPos(gameClient.Hwnd, IntPtr.Zero, 0, 0, 10, 10, (uint) 0);
+ ActivateClientWindow(gameClient.Hwnd);
+ EnableWindow(gameClient.Hwnd, true);
+ SetFocus(gameClient.Hwnd);
+
+ SetWindowPos(gameClient.Hwnd, IntPtr.Zero, 0, 0, 10, 10, (uint) 0);
+ ShowWindow(gameClient.Hwnd, 1);
}
}
@@ -88,23 +115,25 @@ private void ActivateClientWindow(IntPtr hwnd)
EnableWindow(hwnd, true);
EnableWindow(visualHwnd.Value, false);
SetFocus(visualHwnd.Value);
- SendMessage(hwnd, WM_ACTIVATE, WA_ACTIVE, IntPtr.Zero);
+ SendMessage(hwnd, WM_ACTIVATE, WA_ACTIVE, 0);
}
private void DeactivateClientWindow(IntPtr hwnd)
{
- SendMessage(hwnd, WM_ACTIVATE, WA_INACTIVE, IntPtr.Zero);
+ SendMessage(hwnd, WM_ACTIVATE, WA_INACTIVE, 0);
}
private const int WM_ACTIVATE = 0x0006;
- private readonly IntPtr WA_ACTIVE = new IntPtr(1);
- private readonly IntPtr WA_INACTIVE = new IntPtr(0);
+ private readonly int WA_ACTIVE = 1;
+ private readonly int WA_INACTIVE = 0;
[DllImport("User32.dll")]
static extern bool SetWindowPos(IntPtr hdwd, IntPtr insertAfter, int x, int y, int width, int height, uint flags);
[DllImport("User32.dll")]
static extern bool EnableWindow(IntPtr hdwd, bool value);
[DllImport("User32.dll")]
+ static extern IntPtr SetActiveWindow (IntPtr hdwd);
+ [DllImport("User32.dll")]
static extern IntPtr SetFocus(IntPtr hdwn);
internal delegate int WindowEnumProc(IntPtr hwnd, IntPtr lparam);
@@ -112,9 +141,12 @@ private void DeactivateClientWindow(IntPtr hwnd)
internal static extern bool EnumChildWindows(IntPtr hwnd, WindowEnumProc func, IntPtr lParam);
[DllImport("user32.dll")]
- static extern int SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
+ static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int msg);
+
+ [DllImport("user32.dll")]
+ static extern bool HideWindow(IntPtr hWnd, int msg);
}
}
\ No newline at end of file
diff --git a/PataNext.Export.Desktop/Features/AddLauncherProvidersFromSimulationFeature.cs b/PataNext.Export.Desktop/Features/AddLauncherProvidersFromSimulationFeature.cs
new file mode 100644
index 00000000..bf11f9df
--- /dev/null
+++ b/PataNext.Export.Desktop/Features/AddLauncherProvidersFromSimulationFeature.cs
@@ -0,0 +1,29 @@
+using System.Collections.Generic;
+using GameHost.Core.Ecs;
+using GameHost.Injection;
+using GameHost.Simulation.Application;
+using GameHost.Worlds;
+using PataNext.Export.Desktop.Providers;
+using PataNext.Export.Desktop.Visual.Dependencies;
+
+namespace PataNext.Export.Desktop
+{
+ [RestrictToApplication(typeof(SimulationApplication))]
+ public class AddLauncherProvidersFromSimulationFeature : AppSystem
+ {
+ private GlobalWorld globalWorld;
+
+ public AddLauncherProvidersFromSimulationFeature(WorldCollection collection) : base(collection)
+ {
+ DependencyResolver.Add(() => ref globalWorld);
+ }
+
+ protected override void OnDependenciesResolved(IEnumerable