Files
sbox-public/game/addons/tools/Code/Scene/SceneView/SceneViewWidget.Events.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

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();
}
}