mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-17 18:59:27 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
71 lines
1.3 KiB
C#
71 lines
1.3 KiB
C#
using System;
|
|
|
|
namespace Editor;
|
|
|
|
/// <summary>
|
|
/// Opens an invisible popup above the game screen which allows you to left click once on the scene.
|
|
/// This is great for things like selecting something from the game scene.
|
|
/// </summary>
|
|
public class GameScenePicker : Widget
|
|
{
|
|
public Action Destroyed { get; set; }
|
|
|
|
public GameScenePicker() : base( null )
|
|
{
|
|
NoSystemBackground = true;
|
|
TranslucentBackground = true;
|
|
MinimumSize = 32;
|
|
MouseTracking = true;
|
|
IsPopup = true;
|
|
Visible = true;
|
|
DeleteOnClose = true;
|
|
Cursor = CursorShape.None;
|
|
}
|
|
|
|
public override void OnDestroyed()
|
|
{
|
|
base.OnDestroyed();
|
|
|
|
Destroyed?.Invoke();
|
|
}
|
|
|
|
protected override void DoLayout()
|
|
{
|
|
base.DoLayout();
|
|
|
|
var activeSession = SceneEditorSession.Active;
|
|
var dock = activeSession.SceneDock;
|
|
|
|
Position = dock.ScreenPosition - 8;
|
|
Size = dock.ScreenRect.Size + 16;
|
|
}
|
|
|
|
Vector2 hoverPos;
|
|
|
|
protected override void OnMouseMove( MouseEvent e )
|
|
{
|
|
base.OnMouseMove( e );
|
|
|
|
hoverPos = e.LocalPosition;
|
|
Update();
|
|
}
|
|
|
|
protected override void OnPaint()
|
|
{
|
|
var r = LocalRect;
|
|
r.Size -= 2;
|
|
|
|
var color = Color.Parse( "#df9194" ) ?? Color.White;
|
|
|
|
Paint.SetPen( color, 8.0f, PenStyle.Dot );
|
|
Paint.DrawRect( LocalRect );
|
|
|
|
}
|
|
|
|
protected override void OnMouseReleased( MouseEvent e )
|
|
{
|
|
base.OnMouseReleased( e );
|
|
Destroy();
|
|
}
|
|
}
|