mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-01 19:08:19 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
using Editor.MapDoc;
|
|
using NativeHammer;
|
|
using System;
|
|
|
|
namespace Editor.MapEditor;
|
|
|
|
/// <summary>
|
|
/// Undo/redo history for the current active mapdoc
|
|
/// </summary>
|
|
public static partial class History
|
|
{
|
|
internal static CHistory Native => CHistory.GetHistory();
|
|
|
|
/// <summary>
|
|
/// Mark new undo position
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
public static void MarkUndoPosition( string name )
|
|
{
|
|
if ( !Native.IsValid ) return;
|
|
Native.MarkUndoPosition( new NativeMapDoc.CSelection( 0 ), name ); // lol
|
|
}
|
|
|
|
/// <summary>
|
|
/// Keeps a map node and all its children, so changes to it can be undone.
|
|
/// </summary>
|
|
public static void Keep( MapNode node )
|
|
{
|
|
if ( !Native.IsValid ) return;
|
|
if ( node == null ) throw new ArgumentNullException( nameof( node ) );
|
|
Native.Keep( node );
|
|
}
|
|
|
|
/// <summary>
|
|
/// Keeps a new object node and all of its children, so they can be deleted on an undo.
|
|
/// </summary>
|
|
public static void KeepNew( MapNode node )
|
|
{
|
|
if ( !Native.IsValid ) return;
|
|
if ( node == null ) throw new ArgumentNullException( nameof( node ) );
|
|
Native.KeepNew( node );
|
|
}
|
|
}
|