Skip to content

Commit ba58306

Browse files
CopilotLeftofZen
andauthored
Polish browser support integration
Agent-Logs-Url: https://github.com/OpenLoco/ObjectEditor/sessions/604fe8ad-6228-459c-9512-e3c03dd2c3eb Co-authored-by: LeftofZen <7483209+LeftofZen@users.noreply.github.com>
1 parent 46a095e commit ba58306

6 files changed

Lines changed: 16 additions & 13 deletions

File tree

Gui.Browser/Gui.Browser.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
9-
<BuildingForBrowser>true</BuildingForBrowser>
109
</PropertyGroup>
1110

1211
<ItemGroup>
1312
<PackageReference Include="Avalonia.Browser" Version="11.3.13" />
1413
</ItemGroup>
1514

1615
<ItemGroup>
17-
<ProjectReference Include="..\Gui\Gui.csproj" />
16+
<ProjectReference Include="..\Gui\Gui.csproj" AdditionalProperties="BuildingForBrowser=true" />
1817
</ItemGroup>
1918
</Project>

Gui/Gui.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
<ItemGroup>
7070
<ProjectReference Include="..\Common\Common.csproj" />
7171
<ProjectReference Include="..\Definitions\Definitions.csproj" />
72-
<ProjectReference Condition="'$(BuildingForBrowser)' != 'true'" Include="..\GuiUpdater\GuiUpdater.csproj" />
7372
<ProjectReference Include="..\Index\Index.csproj" />
7473
</ItemGroup>
7574

Gui/PlatformSpecific.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ public static async Task SetClipboardTextAsync(string text)
160160
}
161161

162162
if (Application.Current?.ApplicationLifetime is ISingleViewApplicationLifetime singleView
163-
&& singleView.MainView is Control control)
163+
&& singleView.MainView is Control mainViewControl)
164164
{
165-
return TopLevel.GetTopLevel(control);
165+
return TopLevel.GetTopLevel(mainViewControl);
166166
}
167167

168168
return null;

Gui/ViewModels/MainWindowViewModel.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public class MainWindowViewModel : ViewModelBase
5858
public string WindowTitle
5959
=> $"{ObjectEditorContext.ApplicationName} - {ApplicationVersion} ({LatestVersionText})";
6060

61+
public bool SupportsDesktopFeatures => !OperatingSystem.IsBrowser();
62+
6163
[Reactive]
6264
public SemanticVersion ApplicationVersion { get; set; }
6365
SemanticVersion? LatestVersion { get; set; }
@@ -138,7 +140,7 @@ public MainWindowViewModel()
138140

139141
OpenEditorSettingsWindow = new();
140142
EditSettingsCommand = OperatingSystem.IsBrowser()
141-
? ReactiveCommand.Create(() => { })
143+
? CreateBrowserUnsupportedCommand()
142144
: ReactiveCommand.CreateFromTask(async () =>
143145
{
144146
var vm = new EditorSettingsWindowViewModel(EditorContext.Settings);
@@ -148,7 +150,7 @@ public MainWindowViewModel()
148150

149151
OpenLogWindow = new();
150152
ShowLogsCommand = OperatingSystem.IsBrowser()
151-
? ReactiveCommand.Create(() => { })
153+
? CreateBrowserUnsupportedCommand()
152154
: ReactiveCommand.CreateFromTask(async () =>
153155
{
154156
var vm = new LogWindowViewModel(EditorContext.LoggerObservableLogs);
@@ -252,6 +254,9 @@ void PopulateObjDataMenu()
252254
ReactiveCommand.Create(() => FolderTreeViewModel.CurrentLocalDirectory = x))));
253255
}
254256

257+
static ReactiveCommand<Unit, Unit> CreateBrowserUnsupportedCommand()
258+
=> ReactiveCommand.Create(() => { });
259+
255260
public static async Task<FileSystemItem?> GetFileSystemItemFromUser(IReadOnlyList<FilePickerFileType> filetypes)
256261
{
257262
var openFile = await PlatformSpecific.OpenFilePicker(filetypes);

Gui/Views/MainView.axaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@
191191
<MenuItem Command="{Binding UseCustomPalette}" Header="Load custom palette"/>
192192
</MenuItem>
193193
<MenuItem Header="_Settings">
194-
<MenuItem Command="{Binding EditSettingsCommand}" Header="Edit settings"/>
195-
<MenuItem Command="{Binding OpenSettingsFolder}" Header="Open settings folder"/>
196-
<MenuItem Command="{Binding OpenDownloadFolder}" Header="Open user downloads folder"/>
197-
<MenuItem Command="{Binding OpenCacheFolder}" Header="Open cached objects folder"/>
198-
<MenuItem Command="{Binding ShowLogsCommand}" Header="Show logs"/>
194+
<MenuItem Command="{Binding EditSettingsCommand}" Header="Edit settings" IsEnabled="{Binding SupportsDesktopFeatures}"/>
195+
<MenuItem Command="{Binding OpenSettingsFolder}" Header="Open settings folder" IsEnabled="{Binding SupportsDesktopFeatures}"/>
196+
<MenuItem Command="{Binding OpenDownloadFolder}" Header="Open user downloads folder" IsEnabled="{Binding SupportsDesktopFeatures}"/>
197+
<MenuItem Command="{Binding OpenCacheFolder}" Header="Open cached objects folder" IsEnabled="{Binding SupportsDesktopFeatures}"/>
198+
<MenuItem Command="{Binding ShowLogsCommand}" Header="Show logs" IsEnabled="{Binding SupportsDesktopFeatures}"/>
199199
</MenuItem>
200200
</Menu>
201201
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal" Spacing="32">

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ A modern implementation of 'LocoTool' for Locomotion `dat` file parsing and edit
159159
- Open `ObjectEditor.sln` in Visual Studio
160160
- You'll need the `Avalonia for Visual Studio` plugin to use the visual XAML previewer, but it isn't required to actually build or run the editor
161161
- Desktop build: `dotnet build Gui/Gui.csproj`
162-
- Browser build: `dotnet build Gui.Browser/Gui.Browser.csproj -p:BuildingForBrowser=true`
162+
- Browser build: `dotnet build Gui.Browser/Gui.Browser.csproj`
163163
- Browser run: `dotnet run --project Gui.Browser/Gui.Browser.csproj`
164164
- This starts Avalonia's local WebAssembly host and prints the local browser URL to open
165165
- Desktop-only features such as opening local folders and separate popup windows remain unavailable in the browser build

0 commit comments

Comments
 (0)