Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2816cf4
initial work in running game project from editor
ourabigdev May 23, 2025
2946b8b
Merge branch 'stride3d:xplat-editor' into xplat-editor
ourabigdev May 23, 2025
c334afa
Update Directory.Packages.props
ourabigdev May 23, 2025
594cdd2
Merge branch 'xplat-editor' of https://github.com/ourabigdev/stride i…
ourabigdev May 23, 2025
ef5a203
some fixes includin going from async void to async Task
ourabigdev May 24, 2025
3c10136
Update Stride.GameStudio.Avalonia.csproj
ourabigdev May 24, 2025
db37d54
Merge branch 'xplat-editor' of https://github.com/ourabigdev/stride i…
ourabigdev May 26, 2025
6b5a2c1
Update Directory.Packages.props
ourabigdev May 26, 2025
67283fc
Update ImageResources.axaml
ourabigdev May 26, 2025
6c4fe7f
Merge branch 'stride3d:xplat-editor' into xplat-editor
ourabigdev May 28, 2025
9972240
Wip: base changes to add start button
ourabigdev May 28, 2025
0dcf077
Update MainViewModel.cs
ourabigdev May 28, 2025
ba2c592
Merge branch 'stride3d:xplat-editor' into xplat-editor
ourabigdev May 28, 2025
dc3255c
Merge branch 'xplat_editor' into ourabigdev_xplat-editor
Kryptos-FR Jun 23, 2025
0a56ef0
Cleanup
Kryptos-FR Jun 23, 2025
c39f273
Merge branch 'stride3d:xplat-editor' into xplat-editor
ourabigdev Jun 28, 2025
4be3a55
change run button placement
ourabigdev Oct 29, 2025
344bfe3
Update MainView.axaml
ourabigdev Oct 29, 2025
10ad7d7
Update MainView.axaml
ourabigdev Nov 2, 2025
926691b
Update .editorconfig
Kryptos-FR Nov 2, 2025
9788a1f
Reformat MainView.axaml
Kryptos-FR Nov 2, 2025
58587d8
Reformat ImageResources.axaml
Kryptos-FR Nov 2, 2025
e97b863
Merge branch 'origin/xplat-editor' into ourabigdev/xplat-editor
Kryptos-FR Nov 2, 2025
e62cebe
Merge branch 'stride3d:xplat-editor' into xplat-editor
ourabigdev Dec 28, 2025
f061cac
Merge branch 'stride3d:xplat-editor' into xplat-editor
ourabigdev Jan 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions sources/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
<AvaloniaBehaviorVersion>11.2.7.3</AvaloniaBehaviorVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Avalonia" Version="$(AvaloniaVersion)" />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be removed here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did that i keeped this one now and the other has been removed in past commit but it's still there idk why

<PackageVersion Include="Avalonia.Controls.DataGrid" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
Expand Down Expand Up @@ -147,4 +146,4 @@
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" PrivateAssets="all" />
</ItemGroup>
</Project>
</Project>
Comment thread
Kryptos-FR marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,14 @@
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>

<DrawingImage x:Key="ImageStart">
<DrawingImage.Drawing>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 spaces instead of tabs for indentation in XAML files

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to still be a mix of spaces and tabs.

If you are using Visual Studio, you can use Ctrl+E,D to format the current document. Or In Visual Studio code Ctrl+Shift+i.

<GeometryDrawing Brush="#4CAF50">
<GeometryDrawing.Geometry>
<Geometry>F1 M 2,2 L 14,8 L 2,14 Z</Geometry>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingImage.Drawing>
</DrawingImage>
</ResourceDictionary>
1 change: 1 addition & 0 deletions sources/editor/Stride.GameStudio.Avalonia/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data.Core.Plugins;
using Avalonia.Input;
Comment thread
Kryptos-FR marked this conversation as resolved.
using Avalonia.Markup.Xaml;
using Stride.Core.Assets.Editor.Services;
using Stride.Core.IO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" />
Comment thread
Kryptos-FR marked this conversation as resolved.
Outdated
<PackageReference Include="Avalonia.Themes.Fluent" />
<PackageReference Include="Avalonia.Fonts.Inter" />
<PackageReference Include="Avalonia.Xaml.Interactions" />
Expand Down
140 changes: 140 additions & 0 deletions sources/editor/Stride.GameStudio.Avalonia/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
using Avalonia;
//using Microsoft.Build.Utilities;
using Stride.Core.Assets;
using Stride.Core.Assets.Editor.Components.Status;
using Stride.Core.Assets.Editor.ViewModels;
Expand Down Expand Up @@ -44,6 +45,7 @@ public MainViewModel(IViewModelServiceProvider serviceProvider)
OpenCommand = new AnonymousTaskCommand<UFile?>(serviceProvider, OnOpen);
OpenDebugWindowCommand = new AnonymousTaskCommand(serviceProvider, OnOpenDebugWindow, () => DialogService.HasMainWindow);
OpenWebPageCommand = new AnonymousTaskCommand<string>(serviceProvider, OnOpenWebPage);
RunCurrentProjectCommand = new AnonymousTaskCommand(serviceProvider, RunCurrentProject);

Status = new StatusViewModel(ServiceProvider);
Status.PushStatus("Ready");
Expand Down Expand Up @@ -79,6 +81,8 @@ public string Title

public ICommandBase OpenDebugWindowCommand { get; }

public ICommandBase RunCurrentProjectCommand { get; }

public async Task<bool?> OpenSession(UFile? filePath, CancellationToken token = default)
{
if (filePath == null || !File.Exists(filePath))
Expand Down Expand Up @@ -138,6 +142,140 @@ private void OnExit()
DialogService.Exit();
}

private bool BuildProject(string projectPath, string framework, string workingDirectory)
{
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "dotnet",
Arguments = $"build \"{projectPath}\" --framework {framework}",
WorkingDirectory = workingDirectory,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true,
}
};

process.OutputDataReceived += (s, e) => { if (e.Data != null) Console.WriteLine("[build] " + e.Data); };
process.ErrorDataReceived += (s, e) => { if (e.Data != null) Console.Error.WriteLine("[build-err] " + e.Data); };

try
{
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();
Comment thread
Kryptos-FR marked this conversation as resolved.
Outdated
return process.ExitCode == 0;
}
catch (Exception ex)
{
Console.Error.WriteLine("Build process failed: " + ex);
return false;
}
}



private async Task RunCurrentProject()
{
var mainProjectPath = Session?.CurrentProject?.RootDirectory;
if (mainProjectPath == null) return;

var projectDir = Path.GetDirectoryName(mainProjectPath.FullPath);
var projectBaseName = Path.GetFileNameWithoutExtension(mainProjectPath.FullPath);

string platformSuffix, framework, platformRuntime;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
platformSuffix = "Windows";
platformRuntime = "win-x64";
framework = "net8.0-windows";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
platformSuffix = "Linux";
platformRuntime = "linux-x64";
framework = "net8.0-linux";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
platformSuffix = "macOS";
platformRuntime = "osx-x64";
framework = "net8.0-macos";
}
else
{
await ShowError("Unsupported OS platform");
return;
}

var platformProjectName = $"{projectBaseName}.{platformSuffix}.csproj";
var platformProjectPath = Path.Combine(projectDir, $"{projectBaseName}.{platformSuffix}", platformProjectName);
var ExecPath = Path.Combine(projectDir, "Bin", platformSuffix, "Debug", platformRuntime);
var dllPath = Path.Combine(ExecPath, $"{projectBaseName}.{platformSuffix}.dll");


if (!File.Exists(platformProjectPath))
{
await ShowError($"Platform-specific project not found: {platformProjectPath}");
return;
}

Status.PushStatus("Building project...");
Console.WriteLine("Building project...");
bool buildSuccess = await Task.Run(() => BuildProject(platformProjectPath, framework, projectDir));
if (!buildSuccess)
{
Status.PushStatus("Build failed.");
Console.WriteLine("Build failed.");
await ShowError("Build failed. See output for details.");
return;
}

Status.PushStatus("Running project...");
Console.WriteLine("Running project...");
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "dotnet",
Arguments = $"\"{dllPath}\"",
WorkingDirectory = projectDir,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = false,
}
};

process.OutputDataReceived += (s, e) => { if (e.Data != null) Console.WriteLine("[run] " + e.Data); };
process.ErrorDataReceived += (s, e) => { if (e.Data != null) Console.Error.WriteLine("[run-err] " + e.Data); };

try
{
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
}
catch (Exception ex)
{
Console.Error.WriteLine("Run process failed: " + ex);
await ShowError("Failed to start the game process. See output for details.");
}
}




private async Task ShowError(string message)
{
await ServiceProvider.Get<IDialogService>().MessageBoxAsync(message, MessageBoxButton.OK, MessageBoxImage.Error);
}



private async Task OnOpen(UFile? initialPath)
{
await OpenSession(initialPath);
Expand All @@ -157,6 +295,8 @@ private async Task OnOpenWebPage(string url)
}
}



private async Task OnOpenDebugWindow()
{
await DialogService.ShowDebugWindowAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.

using Avalonia.Controls;
using Avalonia.Input;

namespace Stride.GameStudio.Avalonia.Views;

Expand All @@ -10,6 +11,17 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();
this.KeyDown += MainWindow_KeyDown;
}

private void MainWindow_KeyDown(object? sender, KeyEventArgs e)
{
if (e.Key == Key.F5)
{
(DataContext as ViewModels.MainViewModel)?.RunCurrentProjectCommand.Execute(null);
Comment thread
ourabigdev marked this conversation as resolved.
Outdated
e.Handled = true;
Console.WriteLine("Run");
}
}

}