mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-04-19 05:48:07 -04:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
52 lines
1.4 KiB
C#
52 lines
1.4 KiB
C#
namespace Editor;
|
|
|
|
public partial class SceneViewWidget : ResourceLibrary.IEventListener
|
|
{
|
|
private PopupDialogWidget _externalChangesDialog;
|
|
|
|
void ResourceLibrary.IEventListener.OnExternalChanges( GameResource resource )
|
|
{
|
|
if ( resource != Session.Scene.Source ) return;
|
|
|
|
if ( _externalChangesDialog.IsValid() ) // already showing one
|
|
return;
|
|
|
|
Session.MakeActive();
|
|
|
|
var popup = new PopupDialogWidget( "published_with_changes" );
|
|
_externalChangesDialog = popup;
|
|
|
|
popup.FixedWidth = 650;
|
|
popup.WindowTitle = "External Changes Detected";
|
|
|
|
string filename = System.IO.Path.GetFileName( Session.Scene.Source.ResourcePath );
|
|
popup.MessageLabel.Text = $"The asset '{filename}' has been modified outside of the s&box editor.\n\nPress Reload to discard any unsaved changes and load the new version.\nPress Keep My Work to overwrite the external changes with your working copy.";
|
|
|
|
popup.ButtonLayout.Spacing = 4;
|
|
popup.ButtonLayout.AddStretchCell();
|
|
|
|
popup.ButtonLayout.Add( new Button.Primary( "Reload", "sync" )
|
|
{
|
|
Clicked = () =>
|
|
{
|
|
Session.Reload();
|
|
popup.Destroy();
|
|
}
|
|
} );
|
|
|
|
popup.ButtonLayout.Add( new Button( "Keep My Work", "save" )
|
|
{
|
|
Clicked = () =>
|
|
{
|
|
// Save what we have already, discarding any external changes.
|
|
Session.Save( false );
|
|
popup.Destroy();
|
|
}
|
|
} );
|
|
|
|
popup.SetModal( true, true );
|
|
popup.Hide();
|
|
popup.Show();
|
|
}
|
|
}
|