Skip to content

Commit a3a1859

Browse files
Merge branch 'main' into linux-speech-recognition
2 parents 077d733 + 000d1c3 commit a3a1859

File tree

3 files changed

+50
-15
lines changed

3 files changed

+50
-15
lines changed

src/TrackerCouncil.Smz3.Tracking/TrackingServices/TrackerTreasureService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ public void ClearDungeon(IHasTreasure treasureRegion, float? confidence = null)
151151
var remaining = treasureRegion.RemainingTreasure;
152152
if (remaining > 0)
153153
{
154+
treasureRegion.HasManuallyClearedTreasure = true;
154155
treasureRegion.RemainingTreasure = 0;
155156
}
156157

src/TrackerCouncil.Smz3.UI/Views/GenerationSettingsWindow.axaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@
1010
x:Class="TrackerCouncil.Smz3.UI.Views.GenerationSettingsWindow"
1111
Title="SMZ3 Cas' Randomizer"
1212
Height="750" Width="700"
13-
CanResize="False"
13+
Opened="TopLevel_OnOpened"
14+
CanResize="True"
1415
WindowStartupLocation="CenterOwner"
1516
Icon="/Assets/smz3.ico"
1617
x:DataType="viewModels:GenerationWindowViewModel">
1718
<LayoutTransformControl x:Name="MainLayout">
18-
<Grid RowDefinitions="*, Auto">
19+
<Grid RowDefinitions="*, Auto" x:Name="MainGrid">
1920
<TabControl Grid.Row="0" Margin="5">
2021
<TabItem Header="Basic">
21-
<views:GenerationSettingsBasicPanel DataContext="{Binding}" x:Name="BasicPanel" Displayed="BasicPanel_OnDisplayed"></views:GenerationSettingsBasicPanel>
22+
<ScrollViewer>
23+
<views:GenerationSettingsBasicPanel DataContext="{Binding}" x:Name="BasicPanel" Displayed="BasicPanel_OnDisplayed" Margin="0 0 5 5"></views:GenerationSettingsBasicPanel>
24+
</ScrollViewer>
2225
</TabItem>
2326
<TabItem Header="Game Settings" IsVisible="{Binding CanChangeGameSettings}">
2427
<ScrollViewer>
@@ -39,7 +42,7 @@
3942
</TabItem>
4043
<TabItem Header="Interface/Controls">
4144
<ScrollViewer>
42-
<avalonia:DynamicFormControl Data="{Binding Customizations}" Grid.IsSharedSizeScope="True"></avalonia:DynamicFormControl>
45+
<avalonia:DynamicFormControl Data="{Binding Customizations}" Grid.IsSharedSizeScope="True" Margin="0 0 5 5"></avalonia:DynamicFormControl>
4346
</ScrollViewer>
4447
</TabItem>
4548
</TabControl>

src/TrackerCouncil.Smz3.UI/Views/GenerationSettingsWindow.axaml.cs

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
22
using System.Threading.Tasks;
3+
using Avalonia;
4+
using Avalonia.Controls;
35
using Avalonia.Interactivity;
46
using AvaloniaControls.Controls;
57
using AvaloniaControls.Models;
@@ -10,27 +12,26 @@
1012
using TrackerCouncil.Smz3.Data.ViewModels;
1113
using TrackerCouncil.Smz3.Shared.Enums;
1214
using TrackerCouncil.Smz3.Shared.Models;
15+
using Dispatcher = Avalonia.Threading.Dispatcher;
1316

1417
namespace TrackerCouncil.Smz3.UI.Views;
1518

1619
public partial class GenerationSettingsWindow : ScalableWindow
1720
{
18-
private GenerationSettingsWindowService? _generationSettingsWindowService;
19-
private IServiceProvider? _serviceProvider;
20-
private IStatGenerator? _statGenerator;
21-
private GenerationWindowViewModel? _model;
21+
private readonly GenerationSettingsWindowService? _generationSettingsWindowService;
22+
private readonly IServiceProvider? _serviceProvider;
23+
private readonly GenerationWindowViewModel? _model;
2224

2325
public GenerationSettingsWindow()
2426
{
2527
InitializeComponent();
2628
DataContext = new GenerationWindowViewModel();
2729
}
2830

29-
public GenerationSettingsWindow(GenerationSettingsWindowService generationSettingsWindowService, IServiceProvider serviceProvider, IStatGenerator statGenerator)
31+
public GenerationSettingsWindow(GenerationSettingsWindowService generationSettingsWindowService, IServiceProvider serviceProvider)
3032
{
3133
_generationSettingsWindowService = generationSettingsWindowService;
3234
_serviceProvider = serviceProvider;
33-
_statGenerator = statGenerator;
3435
InitializeComponent();
3536
DataContext = BasicPanel.Data = _model = _generationSettingsWindowService.GetViewModel();
3637
BasicPanel.SetServices(serviceProvider, generationSettingsWindowService);
@@ -60,7 +61,7 @@ public void EnableImportMode(ParsedRomDetails importDetails)
6061
{
6162
_model.Basic.CanSetMsu = false;
6263
}
63-
64+
6465
_model.IsImportMode = true;
6566
_model.ImportDetails = importDetails;
6667
}
@@ -117,7 +118,7 @@ private async Task GenerateRom()
117118

118119
window.ShowDialog();
119120

120-
window.Closed += (sender, args) =>
121+
window.Closed += (_, _) =>
121122
{
122123
if (generatedRom.Rom != null)
123124
{
@@ -152,12 +153,12 @@ private void GenerateStatsMenuItem_OnClick(object? sender, RoutedEventArgs e)
152153
var statGenerator = _serviceProvider.GetRequiredService<IStatGenerator>();
153154
var statWindow = new ProgressWindow(this, "Generating stats test");
154155

155-
statGenerator.StatProgressUpdated += (o, args) =>
156+
statGenerator.StatProgressUpdated += (_, args) =>
156157
{
157158
statWindow.Report(args.Current / (double)args.Total);
158159
};
159160

160-
statGenerator.StatsCompleted += (o, args) =>
161+
statGenerator.StatsCompleted += (_, args) =>
161162
{
162163
statWindow.Close();
163164
var messageWindow = new MessageWindow(new MessageWindowRequest()
@@ -190,7 +191,7 @@ private void SavePresetMenuItem_OnClick(object? sender, RoutedEventArgs e)
190191
DisplayTextBox = true,
191192
});
192193

193-
window.Closed += (o, args) =>
194+
window.Closed += (_, _) =>
194195
{
195196
if (window.DialogResult?.PressedAcceptButton != true)
196197
{
@@ -229,5 +230,35 @@ private void BasicPanel_OnDisplayed(object? sender, EventArgs e)
229230
{
230231
_generationSettingsWindowService?.UpdateSummaryText();
231232
}
233+
234+
private void TopLevel_OnOpened(object? sender, EventArgs e)
235+
{
236+
var val = Avalonia.VisualTree
237+
.VisualExtensions
238+
.GetTransformedBounds(this);
239+
240+
// Fix window on smaller displays
241+
if (val is { Bounds.Height: < 750 })
242+
{
243+
Height = val.Value.Bounds.Height - 100;
244+
var grid = this.Find<Grid>("MainGrid")!;
245+
grid.IsVisible = false;
246+
Task.Run(async () =>
247+
{
248+
await Task.Delay(TimeSpan.FromSeconds(0.25));
249+
Dispatcher.UIThread.Invoke(() =>
250+
{
251+
grid.IsVisible = true;
252+
});
253+
254+
});
255+
}
256+
257+
if (Position.Y is < 0 and > -200)
258+
{
259+
var newPos = new PixelPoint(Position.X, 0);
260+
Position = newPos;
261+
}
262+
}
232263
}
233264

0 commit comments

Comments
 (0)