Skip to content
Open
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
50 changes: 45 additions & 5 deletions DarkUI/DarkUI/Docking/DarkDockPanel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using DarkUI.Config;
using DarkUI.Config;
using DarkUI.Win32;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -28,6 +28,7 @@ public class DarkDockPanel : UserControl
private bool _prioritizeRight = true;
private DarkDockContent _activeContent;
private bool _switchingContent;
private bool _isBulkUpdating;

#endregion

Expand Down Expand Up @@ -148,6 +149,8 @@ public Dictionary<DarkDockArea, DarkDockRegion> Regions

#region Constructor Region

internal bool IsBulkUpdating => _isBulkUpdating;

public DarkDockPanel()
{
Splitters = new List<DarkDockSplitter>();
Expand Down Expand Up @@ -190,7 +193,8 @@ public void AddContent(DarkDockContent dockContent, DarkDockGroup dockGroup)

ContentAdded?.Invoke(this, new DockContentEventArgs(dockContent));

dockContent.Select();
if (!_isBulkUpdating)
dockContent.Select();
}

public void InsertContent(DarkDockContent dockContent, DarkDockGroup dockGroup, DockInsertType insertType)
Expand All @@ -216,8 +220,12 @@ public void RemoveContent()
if (_contents.Count == 0)
return;

while(_contents.Count > 0)
BeginBulkUpdate();

while (_contents.Count > 0)
RemoveContent(_contents.First());

EndBulkUpdate();
}

public void RemoveContent(DarkDockContent dockContent)
Expand Down Expand Up @@ -353,7 +361,7 @@ public DockPanelState GetDockPanelState()

public void RestoreDockPanelState(DockPanelState state, Func<string, DarkDockContent> getContentBySerializationKey)
{
SuspendLayout();
BeginBulkUpdate();

foreach (var region in state.Regions.OrderByDescending(r => r.Area))
{
Expand Down Expand Up @@ -408,7 +416,39 @@ public void RestoreDockPanelState(DockPanelState state, Func<string, DarkDockCon
}
}

ResumeLayout();
EndBulkUpdate();
}

private void BeginBulkUpdate()
{
_isBulkUpdating = true;

SuspendLayout();

foreach (var region in _regions.Values)
region.SuspendLayout();

if (IsHandleCreated)
Native.SendMessage(Handle, (uint)WM.SETREDRAW, IntPtr.Zero, IntPtr.Zero);
}

private void EndBulkUpdate()
{
foreach (var region in _regions.Values)
region.FinalizeLayout();

_isBulkUpdating = false;

foreach (var region in _regions.Values)
region.ResumeLayout(true);

ResumeLayout(true);

if (IsHandleCreated)
{
Native.SendMessage(Handle, (uint)WM.SETREDRAW, (IntPtr)1, IntPtr.Zero);
Invalidate(true);
}
}

#endregion
Expand Down
22 changes: 17 additions & 5 deletions DarkUI/DarkUI/Docking/DarkDockRegion.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using DarkUI.Config;
using DarkUI.Config;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand Down Expand Up @@ -90,8 +90,11 @@ internal void AddContent(DarkDockContent dockContent, DarkDockGroup dockGroup)
CreateSplitter();
}

RebuildGroupSplitters();
PositionGroups();
if (!DockPanel.IsBulkUpdating)
{
RebuildGroupSplitters();
PositionGroups();
}
}

internal void InsertContent(DarkDockContent dockContent, DarkDockGroup dockGroup, DockInsertType insertType)
Expand Down Expand Up @@ -136,8 +139,11 @@ internal void RemoveContent(DarkDockContent dockContent)
RemoveSplitter();
}

RebuildGroupSplitters();
PositionGroups();
if (!DockPanel.IsBulkUpdating)
{
RebuildGroupSplitters();
PositionGroups();
}
}

public List<DarkDockContent> GetContents()
Expand Down Expand Up @@ -459,6 +465,12 @@ private void RemoveSplitter()
DockPanel.Splitters.Remove(_splitter);
}

internal void FinalizeLayout()
{
RebuildGroupSplitters();
PositionGroups();
}

private void RebuildGroupSplitters()
{
if (DockArea == DarkDockArea.Document)
Expand Down
16 changes: 15 additions & 1 deletion DarkUI/DarkUI/Docking/DockGroupState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace DarkUI.Docking
{
public class DockGroupState : IEquatable<DockGroupState>
public class DockGroupState : ICloneable, IEquatable<DockGroupState>
{
#region Property Region

Expand All @@ -30,6 +30,20 @@ public DockGroupState()

#endregion

#region Clone Region

public DockGroupState Clone() => new DockGroupState
{
Contents = new List<string>(Contents),
VisibleContent = VisibleContent,
Order = Order,
Size = Size
};

object ICloneable.Clone() => Clone();

#endregion

#region Comparison Region

public bool Equals(DockGroupState other) =>
Expand Down
13 changes: 12 additions & 1 deletion DarkUI/DarkUI/Docking/DockPanelState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace DarkUI.Docking
{
public class DockPanelState : IEquatable<DockPanelState>
public class DockPanelState : ICloneable, IEquatable<DockPanelState>
{
#region Property Region

Expand All @@ -21,6 +21,17 @@ public DockPanelState()

#endregion

#region Clone Region

public DockPanelState Clone() => new DockPanelState
{
Regions = Regions.Select(r => r.Clone()).ToList()
};

object ICloneable.Clone() => Clone();

#endregion

#region Comparison Region

public bool Equals(DockPanelState other) => Regions.SequenceEqual(other.Regions);
Expand Down
15 changes: 14 additions & 1 deletion DarkUI/DarkUI/Docking/DockRegionState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace DarkUI.Docking
{
public class DockRegionState : IEquatable<DockRegionState>
public class DockRegionState : ICloneable, IEquatable<DockRegionState>
{
#region Property Region

Expand Down Expand Up @@ -38,6 +38,19 @@ public DockRegionState(DarkDockArea area, Size size)

#endregion

#region Clone Region

public DockRegionState Clone() => new DockRegionState
{
Area = Area,
Size = Size,
Groups = Groups.Select(g => g.Clone()).ToList()
};

object ICloneable.Clone() => Clone();

#endregion

#region Comparison Region

public bool Equals(DockRegionState other) => Area == other.Area && Size == other.Size && Groups.SequenceEqual(other.Groups);
Expand Down
1 change: 1 addition & 0 deletions Installer/Changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Tomb Editor:
* Added Content Browser tool window for more streamlined object management.
* Added Flyby Timeline control to edit and preview flyby sequences.
* Added "Preview flyby sequence" and "Preview camera" context menus for cameras.
* Added multiple window layout support.

Version 1.11
============
Expand Down
11 changes: 9 additions & 2 deletions TombEditor/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ static CommandHandler()

AddCommand("ShowFlybyTimeline", "Flyby timeline", CommandType.Windows, delegate (CommandArgs args)
{
args.Editor.Configuration.UI_ShowFlybyTimeline = !args.Editor.Configuration.UI_ShowFlybyTimeline;
args.Editor.Configuration.Window_Layout.ShowFlybyTimeline = !args.Editor.Configuration.Window_Layout.ShowFlybyTimeline;
args.Editor.ConfigurationChange();
});

Expand Down Expand Up @@ -1730,10 +1730,17 @@ static CommandHandler()

AddCommand("ShowStatistics", "Statistics display", CommandType.Windows, delegate (CommandArgs args)
{
args.Editor.Configuration.UI_ShowStats = !args.Editor.Configuration.UI_ShowStats;
args.Editor.Configuration.Window_Layout.ShowStats = !args.Editor.Configuration.Window_Layout.ShowStats;
args.Editor.ConfigurationChange();
});

for (int i = 0; i < Configuration.MaxWindowLayouts; i++)
{
int currentLayoutIndex = i;
int visibleLayoutIndex = i + 1;
AddCommand("SwitchLayout" + visibleLayoutIndex, "Switch to layout " + visibleLayoutIndex, CommandType.Windows, (CommandArgs args) => args.Editor.SwitchLayout(currentLayoutIndex));
}

AddCommand("DrawPortals", "Draw portals", CommandType.View, delegate (CommandArgs args)
{
args.Editor.Configuration.Rendering3D_ShowPortals = !args.Editor.Configuration.Rendering3D_ShowPortals;
Expand Down
37 changes: 30 additions & 7 deletions TombEditor/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DarkUI.Docking;
using DarkUI.Docking;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Numerics;
Expand All @@ -13,6 +14,7 @@ namespace TombEditor
// They will be loaded and saved automatically.
public class Configuration : ConfigurationBase
{
public const int MaxWindowLayouts = 10;
Comment thread
Lwmte marked this conversation as resolved.
public override string ConfigName { get { return "TombEditorConfiguration.xml"; } }

// Global editor options
Expand Down Expand Up @@ -61,9 +63,6 @@ public class Configuration : ConfigurationBase
public bool Rendering3D_InvertMouseZoom { get; set; } = false;
public float Rendering3D_LineWidth { get; set; } = 10.0f;
public float Rendering3D_FieldOfView { get; set; } = 50.0f;
public bool Rendering3D_ToolboxVisible { get; set; } = true;
public Point Rendering3D_ToolboxPosition { get; set; } = new Point(15, 15);
public Point Rendering3D_ObjectBrushToolboxPosition { get; set; } = new Point(50, 15);
public bool Rendering3D_DisablePickingForImportedGeometry { get; set; } = false;
public bool Rendering3D_DisablePickingForHiddenRooms { get; set; } = false;
public bool Rendering3D_ShowPortals { get; set; } = false;
Expand Down Expand Up @@ -188,8 +187,6 @@ public class Configuration : ConfigurationBase

// User interface options

public bool UI_ShowStats { get; set; } = true;
public bool UI_ShowFlybyTimeline { get; set; } = true;
public bool UI_AutoFillTriggerTypesForSwitchAndKey { get; set; } = true;
public bool UI_AutoSwitchRoomToOutsideOnAppliedInvisibleTexture { get; set; } = false;
public bool UI_DiscardSelectionOnModeSwitch { get; set; } = false;
Expand Down Expand Up @@ -299,7 +296,9 @@ public class Configuration : ConfigurationBase
public Size Window_FormMaterialEditor_Size { get; set; } = new Size(537, 560);
public bool Window_FormMaterialEditor_Maximized { get; set; } = false;

public DockPanelState Window_Layout { get; set; } = Window_LayoutDefault;
public NamedLayout Window_Layout { get; set; } = new NamedLayout { State = Window_LayoutDefault.Clone() };
public List<NamedLayout> Window_CustomLayouts { get; set; } = new List<NamedLayout>();
public string Window_ActiveLayoutName { get; set; } = string.Empty;

public void EnsureDefaults()
{
Comment thread
Lwmte marked this conversation as resolved.
Expand Down Expand Up @@ -420,4 +419,28 @@ public void EnsureDefaults()
}
};
}

public class NamedLayout : ICloneable
{
public string Name { get; set; } = string.Empty;
public DockPanelState State { get; set; } = Configuration.Window_LayoutDefault.Clone();
public Point ToolboxPosition { get; set; } = new Point(15, 15);
public Point ObjectBrushToolboxPosition { get; set; } = new Point(50, 15);
public bool ShowToolbox { get; set; } = true;
public bool ShowStats { get; set; } = true;
public bool ShowFlybyTimeline { get; set; } = true;

public NamedLayout Clone() => new NamedLayout
{
Name = Name,
State = State.Clone(),
ToolboxPosition = ToolboxPosition,
ObjectBrushToolboxPosition = ObjectBrushToolboxPosition,
ShowToolbox = ShowToolbox,
ShowStats = ShowStats,
ShowFlybyTimeline = ShowFlybyTimeline
};

object ICloneable.Clone() => Clone();
}
}
7 changes: 4 additions & 3 deletions TombEditor/Controls/Panel2DMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public Panel2DMap()
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.Selectable, true);
UpdateStyles();

if (LicenseManager.UsageMode == LicenseUsageMode.Runtime)
if (Editor.Instance is not null)
{
_editor = Editor.Instance;
_editor.EditorEventRaised += EditorEventRaised;
Expand All @@ -117,13 +117,14 @@ public Panel2DMap()

UpdateBrushes();
ResetView();
}
}
}

protected override void Dispose(bool disposing)
{
if (disposing)
if (disposing && _editor is not null)
_editor.EditorEventRaised -= EditorEventRaised;

_movementTimer?.Dispose();
_insertionContourLineData = null;
_currentContextMenu?.Dispose();
Expand Down
Loading