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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

Version numbers follow `MAJOR.MINOR.PATCH`; the 0.x series is under active development. Release tags and downloadable archives use the same version.

## 0.12.4 — 2026-11-13

- Clicking a World tree row button after switching back to zStudio keeps the tree at its current scroll position.
- Maximized zStudio leaves the reveal edge available for an automatically hidden Windows taskbar.

## 0.12.3 — 2026-11-12

- The Blender extension now installs on Blender 5.3 and newer, retaining the 5.2 minimum without an upper version cutoff.
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
<Description>Advanced viewer and editor for Zipper Interactive's ZBD files</Description>
<RepositoryUrl>https://github.com/Vorta/zStudio</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Version>0.12.3</Version>
<Version>0.12.4</Version>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

zStudio is a Windows desktop application. It unpacks RECOIL's retail game files once into an editable source project (the developers' original `data\` and `gamegen\` tree: text resources, glTF models, PNG textures, WAV sounds and build scripts), lets you edit the maps in zStudio or in Blender, and exports new game files from the sources. AI agents can work in the same workspace through local MCP.

Download **[zStudio v0.12.3](https://github.com/Vorta/zStudio/releases/tag/v0.12.3)** for Windows x64.
Download **[zStudio v0.12.4](https://github.com/Vorta/zStudio/releases/tag/v0.12.4)** for Windows x64.

zStudio tells you when a newer release is out: **Update available** appears in the status bar; click it for the release page. zStudio asks GitHub's public release API at most once a day and sends nothing but its version; **Help → Check for updates** asks now, and **Help → Check for updates automatically** turns the daily check off. Running zStudio 0.9.6 or older on the same Windows account turns the daily check back on, because older versions drop settings they don't know.

Expand Down
2 changes: 1 addition & 1 deletion blender/zstudio_recoil/blender_manifest.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
schema_version = "1.0.0"
id = "zstudio_recoil"
version = "0.12.3"
version = "0.12.4"
name = "zStudio RECOIL"
tagline = "Edit RECOIL glTF models, linked worlds, flags and zones"
maintainer = "Vorta"
Expand Down
77 changes: 75 additions & 2 deletions src/zStudio.Desktop/MainWindow.Chrome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace zStudio.Desktop;
public partial class MainWindow
{
private bool captionMaximizePressed;
private bool maximizedFrameQueued;
private CaptionBounds? maximizedClientBounds;
private static readonly int taskbarCreatedMessage = (int)RegisterWindowMessage("TaskbarCreated");
// A private desktop has no Explorer taskbar. Tests supply its reported edges without changing shell settings.
internal Func<uint>? AutoHideTaskbarEdgesForTest { get; set; }
private void InitializeChrome()
{
WindowChrome.SetWindowChrome(this, new WindowChrome
Expand All @@ -27,7 +32,7 @@ private void InitializeChrome()
SourceInitialized += (_, _) =>
{
nint handle = new WindowInteropHelper(this).Handle;
HwndSource.FromHwnd(handle)?.AddHook(ChromeMessage);
InstallChromeHook(handle);
ApplyCornerPreference(handle);
UpdateCaptionBounds();
};
Expand All @@ -49,6 +54,13 @@ private void InitializeChrome()
}
private nint ChromeMessage(nint hwnd, int message, nint wParam, nint lParam, ref bool handled)
{
if (message == 0x0083 && lParam != 0 && TryMaximizedClientBounds(hwnd, out var client, Marshal.PtrToStructure<CaptionBounds>(lParam)))
{
// Both NCCALCSIZE_PARAMS and the wParam=FALSE form begin with a RECT. Correct the native client, not just XAML.
Marshal.StructureToPtr(client, lParam, false);
maximizedClientBounds = client;
handled = true; return 0;
}
if (presentationFullscreen && message == 0x0112 && ((long)wParam & 0xFFF0) == 0xF030)
{ handled = true; return 0; } // SC_MAXIMIZE: fullscreen exits only through its own command.
// Windows 11 discovers Snap Layouts from the real maximize hit region, even
Expand All @@ -70,9 +82,65 @@ private nint ChromeMessage(nint hwnd, int message, nint wParam, nint lParam, ref
}
if (message is 0x031A or 0x031E) ApplyCornerPreference(hwnd);
if (message is 0x02E0 or 0x007E or 0x001A) QueueFullscreenBounds();
if (message is 0x02E0 or 0x007E or 0x001A or 0x0047 || message == taskbarCreatedMessage) QueueMaximizedFrame();
if (message is 0x02E0 or 0x031A or 0x031E or 0x001A or 0x0047) Dispatcher.BeginInvoke(DispatcherPriority.Loaded, UpdateCaptionBounds);
return 0;
}
private void InstallChromeHook(nint handle)
{
// Hooks run newest first. WindowChrome installs a new hook when F11 restores the ordinary frame.
var source = HwndSource.FromHwnd(handle);
source?.RemoveHook(ChromeMessage);
source?.AddHook(ChromeMessage);
}
private static void RefreshChromeFrame(nint handle) => RequireNative(SetWindowPos(handle, 0, 0, 0, 0, 0,
0x0001 | 0x0002 | 0x0004 | 0x0010 | 0x0020 | 0x0200)); // frame only, no size/position/activation/Z-order changes

private void QueueMaximizedFrame()
{
if (maximizedFrameQueued || presentationFullscreen) return;
maximizedFrameQueued = true;
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, () =>
{
maximizedFrameQueued = false;
if (shutdownToken.IsCancellationRequested || !IsVisible) return;
nint handle = new WindowInteropHelper(this).Handle;
if (!TryMaximizedClientBounds(handle, out var bounds) || maximizedClientBounds is { } applied && applied.Equals(bounds)) return;
try { RefreshChromeFrame(handle); }
catch (System.ComponentModel.Win32Exception ex) { ViewModel.Status = "Maximized window bounds could not be updated: " + ex.Message; }
});
}
private bool TryMaximizedClientBounds(nint handle, out CaptionBounds client, CaptionBounds? proposed = null)
{
client = default;
if (presentationFullscreen || handle == 0 || !IsZoomed(handle)) return false;
var rect = proposed.GetValueOrDefault();
nint monitorHandle = proposed.HasValue ? MonitorFromRect(ref rect, 2) : MonitorFromWindow(handle, 2);
var monitor = new MonitorBounds { Size = Marshal.SizeOf<MonitorBounds>() };
if (!GetMonitorInfo(monitorHandle, ref monitor)) return false;
uint edges = AutoHideTaskbarEdgesForTest?.Invoke() ?? AutoHideTaskbarEdges(monitor.Monitor);
client = MaximizedClientArea(monitor.Monitor, monitor.Work, edges);
return true;
}
private static uint AutoHideTaskbarEdges(CaptionBounds monitor)
{
uint edges = 0;
for (uint edge = 0; edge < 4; edge++)
{
var data = new AppBarData { Size = (uint)Marshal.SizeOf<AppBarData>(), Edge = edge, Bounds = monitor };
if (SHAppBarMessage(0x0000000B, ref data) != 0) edges |= 1u << (int)edge; // ABM_GETAUTOHIDEBAREX
}
return edges;
}
internal static CaptionBounds MaximizedClientArea(CaptionBounds monitor, CaptionBounds work, uint autoHideEdges)
{
// Two physical pixels, as in Windows Terminal's custom chrome. Do not scale by DPI or reserve an occupied edge twice.
if ((autoHideEdges & 1) != 0) work.Left = Math.Max(work.Left, monitor.Left + 2);
if ((autoHideEdges & 2) != 0) work.Top = Math.Max(work.Top, monitor.Top + 2);
if ((autoHideEdges & 4) != 0) work.Right = Math.Min(work.Right, monitor.Right - 2);
if ((autoHideEdges & 8) != 0) work.Bottom = Math.Min(work.Bottom, monitor.Bottom - 2);
return work;
}
private void ApplyCornerPreference(nint handle)
{
if (handle == 0 || !OperatingSystem.IsWindowsVersionAtLeast(10,0,22000)) return;
Expand Down Expand Up @@ -135,10 +203,15 @@ internal static Size DialogWorkArea(Window owner)
}
return SystemParameters.WorkArea.Size;
}
[StructLayout(LayoutKind.Sequential)] private struct CaptionBounds { public int Left,Top,Right,Bottom; }
[StructLayout(LayoutKind.Sequential)] internal struct CaptionBounds { public int Left,Top,Right,Bottom; }
[StructLayout(LayoutKind.Sequential)] private struct ScreenPoint { public int X,Y; }
[StructLayout(LayoutKind.Sequential)] private struct MonitorBounds { public int Size; public CaptionBounds Monitor,Work; public uint Flags; }
[StructLayout(LayoutKind.Sequential)] private struct MouseTracking { public int Size; public uint Flags; public nint Window; public uint HoverTime; }
[StructLayout(LayoutKind.Sequential)] private struct AppBarData { public uint Size; public nint Window; public uint Callback, Edge; public CaptionBounds Bounds; public nint Param; }
[DllImport("shell32.dll")] private static extern nuint SHAppBarMessage(uint message, ref AppBarData data);
[DllImport("user32.dll", EntryPoint = "RegisterWindowMessageW", CharSet = CharSet.Unicode)] private static extern uint RegisterWindowMessage(string message);
[DllImport("user32.dll")] private static extern bool IsZoomed(nint handle);
[DllImport("user32.dll")] private static extern nint MonitorFromRect(ref CaptionBounds rect, uint flags);
[DllImport("user32.dll")] private static extern bool TrackMouseEvent(ref MouseTracking tracking);
[DllImport("user32.dll")] private static extern nint MonitorFromWindow(nint hwnd,uint flags);
[DllImport("user32.dll",CharSet=CharSet.Auto,SetLastError=true)] private static extern bool GetMonitorInfo(nint monitor,ref MonitorBounds info);
Expand Down
42 changes: 42 additions & 0 deletions src/zStudio.Desktop/MainWindow.OutlinerKeyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;

namespace zStudio.Desktop;

Expand All @@ -19,11 +20,51 @@ public partial class MainWindow
/// <summary>Set while a rebuild disables the tree that had keyboard focus: the rebuilt tree gives it back to the selection.</summary>
private bool outlinerFocusPending;

private bool suppressOutlinerFocusScroll;
private int outlinerFocusScrollGeneration;

private void InitializeOutlinerFocusScroll()
{
Activated += (_, _) => GuardOutlinerFocusScroll();
DocumentSceneTree.AddHandler(Mouse.PreviewMouseDownEvent,
new MouseButtonEventHandler((_, _) => GuardOutlinerFocusScroll()), handledEventsToo: true);
DocumentSceneTree.IsVisibleChanged += (_, _) => { if (!DocumentSceneTree.IsVisible) ClearOutlinerFocusScroll(); };
}

/// <summary>
/// WPF restores the old focused row on activation, and on mouse-down even when a non-focusable row button handles it.
/// Let focus return without scrolling away from the row being clicked. Deliberate navigation clears this guard.
/// </summary>
private void GuardOutlinerFocusScroll()
{
if (!sourceChromeActive || sceneTree?.Projection == null || !DocumentSceneTree.IsVisible) return;
suppressOutlinerFocusScroll = true;
int generation = ++outlinerFocusScrollGeneration;
Dispatcher.BeginInvoke(DispatcherPriority.Input, () =>
{
if (generation == outlinerFocusScrollGeneration) ClearOutlinerFocusScroll();
});
}

private void ClearOutlinerFocusScroll()
{
suppressOutlinerFocusScroll = false;
++outlinerFocusScrollGeneration;
}

private void OutlinerBringIntoView(object sender, RequestBringIntoViewEventArgs e)
{
// This handler belongs on each item, below the internal ScrollViewer. WPF redirects an item's request to its header.
if (suppressOutlinerFocusScroll && sender is TreeViewItem { DataContext: SceneTreeItem row } && row.Owner == sceneTree)
e.Handled = true;
}

private void OutlinerKeyDown(object sender, KeyEventArgs e)
{
if (!sourceChromeActive || sceneTree is not { Projection: not null } model || System.Windows.Input.Keyboard.Modifiers != ModifierKeys.None) return;
// The tree's context menu routes its keys through the tree: they are the menu's.
if (e.OriginalSource is not Visual source || !DocumentSceneTree.IsAncestorOf(source)) return;
ClearOutlinerFocusScroll();
var focused = System.Windows.Input.Keyboard.FocusedElement as DependencyObject;
var item = focused == null ? null : RowContainer(focused);
var row = item?.DataContext as SceneTreeItem;
Expand Down Expand Up @@ -98,6 +139,7 @@ private static void FocusRow(TreeViewItem item)
/// <summary>The row's container, created (and scrolled to) when the tree has not made it yet.</summary>
private TreeViewItem? RealizeRow(SceneTreeItem row)
{
ClearOutlinerFocusScroll();
Stack<SceneTreeItem> path = new(); for (var at = row; at != null; at = at.Parent) path.Push(at);
ItemsControl parent = DocumentSceneTree;
TreeViewItem? container = null;
Expand Down
2 changes: 2 additions & 0 deletions src/zStudio.Desktop/MainWindow.Presentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,10 @@ private void RestoreOrdinaryWindow(nint handle, WindowPresentation saved)
WindowStyle = saved.Style; ResizeMode = saved.Resize;
MinWidth = saved.MinWidth; MinHeight = saved.MinHeight; MaxWidth = saved.MaxWidth; MaxHeight = saved.MaxHeight;
WindowChrome.SetWindowChrome(this, saved.Chrome);
InstallChromeHook(handle);
var placement = saved.Placement;
RequireNative(SetWindowPlacement(handle, ref placement));
RefreshChromeFrame(handle);
ApplyCornerPreference(handle);
UpdateCaptionBounds();
}
Expand Down
2 changes: 2 additions & 0 deletions src/zStudio.Desktop/MainWindow.SceneTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ private void RefreshSceneTree()
if (outlinerFocusPending) { if (sceneTree?.Selected == null) outlinerFocusPending = false; else ScheduleSceneTreeReveal(); }
return;
}
ClearOutlinerFocusScroll();
changingSceneTree = true;
try
{
Expand Down Expand Up @@ -281,6 +282,7 @@ private void ScheduleSceneTreeReveal(SceneTreeItem? reveal = null)
{
if (sceneTree != model || generation != sceneTreeRevealGeneration) return;
if (!DocumentSceneTree.IsVisible) { outlinerFocusPending = false; return; }
ClearOutlinerFocusScroll(); // An explicit reveal (including rebuild restoration) may scroll its intended row.
changingSceneTree = true;
try
{
Expand Down
Loading