Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Traditional photo scenery often requires downloading and building large areas be
- **Towns lit at night** — optionally give the photo scenery street lamps and the light of the houses along X-Plane's roads, so towns glow after dark as on X-Plane's own scenery. You can also skip the detailed photos at night to save downloads, keeping the lights.
- **Exposure and a live preview** — tone down photos that look too bright next to X-Plane's own scenery, and see any colour change on a photo from your cache before you fly.
- **See what happened during your flight** — review download performance, scenery loading, and your flight route.
- **Your scenery list, without Notepad** — switch X-Plane's scenery packages on or off and drag them into order on the X-Plane Custom Scenery page, and leave any of your photo scenery packages out of a flight with one switch on the Home page.
- **Your scenery list, without Notepad** — switch X-Plane's scenery packages on or off and drag them into order on the X-Plane Custom Scenery page (with a search box for long lists), and leave any of your photo scenery packages out of a flight with one switch on the Home page.
- **Level airports** — an airport that sits on a bump or in a hollow of the photo scenery's ground can be flattened on the Airports page, one at a time, without changing the airport's own files. Undo puts it back.

### Designed for everyday flying
Expand Down
Binary file modified docs/OrthoStreamXP-UserGuide.pdf
Binary file not shown.
10 changes: 9 additions & 1 deletion docs/custom-scenery.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@ X-Plane keeps a list of its scenery packages in `Custom Scenery\scenery_packs.in
- The page needs the **X-Plane folder** to be set in [Settings › Folders](settings.md#folders); until then it says *Choose your X-Plane folder first*. If X-Plane has never started with this folder, the list is empty: X-Plane writes the file the first time it starts.
- **Open the folder** opens X-Plane's `Custom Scenery` folder in Explorer. **Refresh** reads the file again, for example after you installed scenery while the page was open.

## Finding a package

The list can be long. Type part of a package's name or folder in the search box above the list to show only the packages that match, for example `kden` or `D:\Ortho4XP`. Capitals do not matter, and a folder can be typed with `\` or `/`. On the right, the page counts the packages: all of them, or how many match while you search (*3 of 1,623 packages*). **Esc** or the **×** in the box empties it and shows the whole list again; the search stays while the list is read again (**Refresh**, Start, Stop).

![Searching for kden: three of the packages match, each with Show in list](images/custom-scenery-search.png)

While you search, the switches work as usual, but packages cannot be dragged: between two packages that match, many others may be hidden. To move a package you found, click **Show in list** in its row. The search is cleared, the page scrolls to the package and marks it with a coloured border, and you can drag it to its new place.

## Switching packages on or off

The switch at the end of each row turns a package on or off in X-Plane. A package switched off stays in its folder and in the list; X-Plane just does not load it. This is the same as X-Plane's own `SCENERY_PACK_DISABLED` lines in the file.

## Changing the order

Drag a package by the handle at the start of its row and drop it where you want it: the other rows move apart to show where it lands. Higher in the list means drawn on top.
Drag a package by the handle at the start of its row and drop it where you want it: the other rows move apart to show where it lands. Higher in the list means drawn on top. To find a package first, see [Finding a package](#finding-a-package).

Leave the photo scenery near the end, below airports and overlays. With **Keep the photo scenery below airports and overlays** on (see [Settings › Other](settings.md#other)), OrthoStreamXP moves its packages back to the end at every start anyway.

Expand Down
Binary file added docs/images/custom-scenery-search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/custom-scenery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions release-notes/v2.1.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## What's new

- **Search your scenery list.** The **X-Plane Custom Scenery** page now has a search box above the list. Type part of a package's name or folder, such as *kden* or *D:\Ortho4XP*, and only the packages that match are shown. Capitals don't matter, and a folder can be typed with \ or /. On the right, the page counts the packages: all of them, or how many match, such as *3 of 1,623 packages*. **Esc** or the **×** in the box shows the whole list again.
- **Show in list.** While you search, each package that matches has a **Show in list** button. It clears the search, scrolls to the package and marks it with a coloured border, so you can drag it to a new place.

## Good to know

- While you search, the switches work as usual, but packages can't be dragged: between two packages that match, many others may be hidden. Use **Show in list** first, or clear the search.
- The search stays when the list is read again, after **Refresh**, Start or Stop.
- As before, the list can be changed only while OrthoStreamXP is stopped. Searching works at any time.
- Nothing changes for your packages or settings with the update.

Thanks to andrewcarlberg for this feature.
9 changes: 8 additions & 1 deletion src/OrthoStreamXP/Gui/Scenery/SceneryPackRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace OrthoStreamXP.Gui;
internal sealed class SceneryPackRow : ObservableObject
{
private readonly Func<SceneryPackRow, bool, bool> _switch;
private bool _enabled;
private bool _enabled, _highlighted;

/// <param name="streamed">One of the packages the running mount shows to X-Plane.</param>
/// <param name="switchTo">Writes the change; false when it could not, and the switch goes back.</param>
Expand All @@ -23,6 +23,13 @@ public SceneryPackRow(SceneryPackEntry entry, bool streamed, Func<SceneryPackRow
public string Path => Entry.Path;
public bool Streamed { get; }

/// <summary>The package last found with "Show in list": marked so it stands out in the whole list.</summary>
public bool IsHighlighted
{
get => _highlighted;
set => Set(ref _highlighted, value);
}

/// <summary>Whether X-Plane loads it: written to the file as soon as it is switched.</summary>
public bool IsEnabled
{
Expand Down
31 changes: 31 additions & 0 deletions src/OrthoStreamXP/Gui/Scenery/SceneryPackSearch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Globalization;
using OrthoStreamXP.Scenery;

namespace OrthoStreamXP.Gui;

/// <summary>
/// What the Scenery page's search box keeps: the packages whose name or path contains the text, ignoring case and whether
/// the path is written with / or \. An empty search keeps every package.
/// </summary>
internal sealed class SceneryPackSearch(string? text)
{
private readonly string _text = Normalize(text?.Trim() ?? "");

public bool IsEmpty => _text.Length == 0;

public bool Matches(SceneryPackEntry entry) =>
IsEmpty
|| entry.Name.Contains(_text, StringComparison.OrdinalIgnoreCase)
|| Normalize(entry.Path).Contains(_text, StringComparison.OrdinalIgnoreCase);

/// <summary>"1,630 packages", or "3 of 1,630 packages" while searching; null for an empty list.</summary>
public string? CountText(int shown, int total)
{
if (total == 0) return null;
// Invariant, as the program runs (Program.cs): the same thousands separator on every machine.
string packages = string.Create(CultureInfo.InvariantCulture, $"{total:N0} {(total == 1 ? "package" : "packages")}");
return IsEmpty ? packages : string.Create(CultureInfo.InvariantCulture, $"{shown:N0} of {packages}");
}

private static string Normalize(string path) => path.Replace('\\', '/');
}
75 changes: 73 additions & 2 deletions src/OrthoStreamXP/Gui/ViewModels/SceneryViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Data;
using System.Windows.Input;
using OrthoStreamXP.Scenery;

Expand All @@ -13,20 +15,28 @@ internal sealed class SceneryViewModel : ObservableObject, IPage
{
private readonly MountController _mount;
private readonly Func<string?> _xplane;
private readonly ICollectionView _shown;
private string? _message;
private string _searchText = "";
private SceneryPackSearch _search = new(null);

/// <param name="xplane">The X-Plane folder of the settings; null while there is none.</param>
public SceneryViewModel(MountController mount, Func<string?> xplane)
{
_mount = mount;
_xplane = xplane;
// The list on the page shows this view of Rows: the rows the search keeps, in the file's order.
_shown = CollectionViewSource.GetDefaultView(Rows);
_shown.Filter = row => _search.Matches(((SceneryPackRow)row).Entry);
Refresh = new RelayCommand(Load);
OpenFolder = new RelayCommand(() => Shell.Open(CustomScenery!), () => CustomScenery is { } folder && Directory.Exists(folder));
_mount.PropertyChanged += (_, e) =>
{
if (e.PropertyName != nameof(MountController.State)) return;
Raise(nameof(CanEdit));
Raise(nameof(CanDrag));
Raise(nameof(RunningNote));
RaiseCount();
RelayCommand.Refresh();
if (_mount.IsRunning || _mount.IsStopped) Load();
};
Expand All @@ -39,6 +49,52 @@ public SceneryViewModel(MountController mount, Func<string?> xplane)
/// <summary>The list can be changed only while OrthoStreamXP is stopped: starting and stopping change the file too.</summary>
public bool CanEdit => _mount.IsStopped;

/// <summary>
/// Rows are dragged only while every row is shown: between two rows a search keeps, hundreds may be hidden, so where a
/// drop lands would be a guess.
/// </summary>
public bool CanDrag => CanEdit && _search.IsEmpty;

/// <summary>Part of a package's name or path; kept while the list is read again.</summary>
public string Search
{
get => _searchText;
set
{
if (!Set(ref _searchText, value ?? "")) return;
_search = new SceneryPackSearch(_searchText);
_shown.Refresh();
Raise(nameof(IsSearching));
Raise(nameof(CanDrag));
RaiseCount();
}
}

/// <summary>Whether the search hides some rows; then each row offers "Show in list".</summary>
public bool IsSearching => !_search.IsEmpty;

/// <summary>
/// Clears the search and highlights <paramref name="row"/>, so it can be found in the whole list and dragged to its new
/// place (the page scrolls to it).
/// </summary>
public void ShowInList(SceneryPackRow row)
{
foreach (SceneryPackRow other in Rows) other.IsHighlighted = false;
row.IsHighlighted = true;
Search = "";
}

/// <summary>How many packages the list has, and how many of them the search keeps.</summary>
public string? CountText => _search.CountText(Rows.Count(r => _search.Matches(r.Entry)), Rows.Count);

/// <summary>While searching: why the rows cannot be dragged, or that nothing matches.</summary>
public string? SearchNote =>
_search.IsEmpty || Rows.Count == 0 ? null
: Rows.Any(r => _search.Matches(r.Entry)) ? (CanEdit ? "Clear the search to drag packages into a new order." : null)
: $"No package matches \"{_searchText.Trim()}\".";

public bool HasSearchNote => SearchNote is not null;

public string? RunningNote => CanEdit ? null : "OrthoStreamXP is running: stop it to change the list.";

public string? CustomScenery => _xplane() is { } xplane ? Path.Join(xplane, "Custom Scenery") : null;
Expand Down Expand Up @@ -67,7 +123,11 @@ private void Load()
Message = null;
Raise(nameof(FileText));
RelayCommand.Refresh();
if (CustomScenery is not { } folder) return;
if (CustomScenery is not { } folder)
{
RaiseCount();
return;
}
var list = new SceneryPackList(folder);
try
{
Expand All @@ -80,6 +140,17 @@ private void Load()
{
Message = $"Could not read {list.FilePath}: {ex.Message}";
}
finally
{
RaiseCount();
}
}

private void RaiseCount()
{
Raise(nameof(CountText));
Raise(nameof(SearchNote));
Raise(nameof(HasSearchNote));
}

private bool Switch(SceneryPackRow row, bool enabled)
Expand All @@ -105,7 +176,7 @@ private bool Switch(SceneryPackRow row, bool enabled)
public void Drop(SceneryPackRow row, int insertAt)
{
int from = Rows.IndexOf(row);
if (!CanEdit || CustomScenery is not { } folder || from < 0 || insertAt < 0 || insertAt > Rows.Count) return;
if (!CanDrag || CustomScenery is not { } folder || from < 0 || insertAt < 0 || insertAt > Rows.Count) return;
int to = insertAt > from ? insertAt - 1 : insertAt;
if (to == from) return;
try
Expand Down
44 changes: 41 additions & 3 deletions src/OrthoStreamXP/Gui/Views/SceneryView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@
<TextBlock Style="{StaticResource PageIntro}"
Text="Switch X-Plane's scenery packages on or off, and drag them to change their order: a package higher in the list covers the ones below it. X-Plane reads the list when it starts, so a change shows from its next start. The packages OrthoStreamXP adds when you press Start are taken out again when you press Stop." />
<TextBlock Style="{StaticResource Secondary}" Text="{Binding FileText}" Margin="0,0,0,12" TextWrapping="Wrap" />

<!-- Search (as on the Airports page), with how many packages it keeps; Esc clears it -->
<Grid Margin="0,0,0,12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="360" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid>
<TextBox x:Name="SearchBox" Text="{Binding Search, UpdateSourceTrigger=PropertyChanged, Delay=250}" Padding="34,6,10,6"
PreviewKeyDown="OnSearchKeyDown" AutomationProperties.Name="Search the scenery list" />
<TextBlock Style="{StaticResource Icon}" Text="&#xE721;" FontSize="14" HorizontalAlignment="Left" Margin="12,0,0,0" IsHitTestVisible="False"
Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
<TextBlock Text="Package name or folder" Margin="35,0,0,0" VerticalAlignment="Center" IsHitTestVisible="False"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
Visibility="{Binding Text, ElementName=SearchBox, Converter={StaticResource Visible}, ConverterParameter=Invert}" />
</Grid>
<TextBlock Grid.Column="1" Text="{Binding CountText}" Style="{StaticResource Secondary}" Margin="14,0,0,0"
HorizontalAlignment="Right" VerticalAlignment="Center" />
</Grid>
<TextBlock Text="{Binding SearchNote}" Style="{StaticResource Caption}" Margin="2,0,0,8" TextWrapping="Wrap"
Visibility="{Binding HasSearchNote, Converter={StaticResource Visible}}" />
<TextBlock Text="{Binding RunningNote}" Style="{StaticResource Caption}" Margin="2,0,0,8"
Visibility="{Binding RunningNote, Converter={StaticResource Visible}}" />
<TextBlock Text="{Binding Message}" Margin="2,0,0,8" TextWrapping="Wrap"
Expand All @@ -31,16 +52,29 @@
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Background="Transparent" PreviewMouseLeftButtonDown="OnRowMouseDown" PreviewMouseMove="OnRowMouseMove">
<Border Style="{StaticResource RowCard}">
<Border>
<!-- The package found with "Show in list": an accent border, as on a chosen card (1 px less padding: no shift) -->
<Border.Style>
<Style TargetType="Border" BasedOn="{StaticResource RowCard}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsHighlighted}" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource AccentFillColorDefaultBrush}" />
<Setter Property="BorderThickness" Value="2" />
<Setter Property="Padding" Value="15,11" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Icon}" Text="&#xE76F;" FontSize="14" Margin="0,0,14,0" VerticalAlignment="Center"
Foreground="{DynamicResource TextFillColorSecondaryBrush}" Cursor="SizeAll" ToolTip="Drag to change the order"
Visibility="{Binding DataContext.CanEdit, RelativeSource={RelativeSource AncestorType=ItemsControl}, Converter={StaticResource Visible}}" />
Visibility="{Binding DataContext.CanDrag, RelativeSource={RelativeSource AncestorType=ItemsControl}, Converter={StaticResource Visible}}" />
<StackPanel Grid.Column="1" VerticalAlignment="Center" Margin="0,0,16,0">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" FontWeight="SemiBold" TextTrimming="CharacterEllipsis" />
Expand All @@ -51,7 +85,11 @@
</StackPanel>
<TextBlock Text="{Binding Path}" Style="{StaticResource Caption}" Margin="0,2,0,0" TextTrimming="CharacterEllipsis" />
</StackPanel>
<CheckBox Grid.Column="2" Style="{StaticResource Switch}" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"
<Button Grid.Column="2" Content="Show in list" Margin="0,0,16,0" VerticalAlignment="Center" Click="OnShowInList"
ToolTip="Clear the search and scroll to this package, to drag it to a new place"
AutomationProperties.Name="{Binding Name, StringFormat='Show {0} in the whole list'}"
Visibility="{Binding DataContext.IsSearching, RelativeSource={RelativeSource AncestorType=ItemsControl}, Converter={StaticResource Visible}}" />
<CheckBox Grid.Column="3" Style="{StaticResource Switch}" IsChecked="{Binding IsEnabled}" VerticalAlignment="Center"
IsEnabled="{Binding DataContext.CanEdit, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
AutomationProperties.Name="{Binding Name, StringFormat='Load {0} in X-Plane'}" />
</Grid>
Expand Down
Loading
Loading