multiselect + sort table polish, sort table keybinds
This commit is contained in:
@@ -25,6 +25,8 @@ public class DrawMultiSelect : MonoBehaviour
|
||||
private bool drawing;
|
||||
private bool secondary;
|
||||
|
||||
private static Vector2 Deadzone = new(5f, 5f);
|
||||
|
||||
public void Start()
|
||||
{
|
||||
selectTexture = new Texture2D(1, 1);
|
||||
@@ -70,6 +72,21 @@ public class DrawMultiSelect : MonoBehaviour
|
||||
selectOrigin = Input.mousePosition;
|
||||
drawing = true;
|
||||
secondary = shiftDown;
|
||||
|
||||
if (!secondary)
|
||||
{
|
||||
MultiSelect.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (drawing && !Settings.SelectionBoxKey.Value.IsPressedIgnoreOthers())
|
||||
{
|
||||
drawing = false;
|
||||
if (secondary)
|
||||
{
|
||||
MultiSelect.CombineSecondary();
|
||||
secondary = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (drawing)
|
||||
@@ -77,6 +94,10 @@ public class DrawMultiSelect : MonoBehaviour
|
||||
selectEnd = Input.mousePosition;
|
||||
|
||||
Rect selectRect = new(selectOrigin, selectEnd - selectOrigin);
|
||||
if (Mathf.Abs(selectRect.size.x) < Deadzone.x && Mathf.Abs(selectRect.size.y) < Deadzone.y)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If not secondary, then we can kick out any non-rendered items, plus they won't be covered by the foreach below
|
||||
if (!secondary)
|
||||
@@ -119,16 +140,6 @@ public class DrawMultiSelect : MonoBehaviour
|
||||
MultiSelect.Deselect(gridItemView, secondary);
|
||||
}
|
||||
}
|
||||
|
||||
if (drawing && !Settings.SelectionBoxKey.Value.IsPressedIgnoreOthers())
|
||||
{
|
||||
drawing = false;
|
||||
if (secondary)
|
||||
{
|
||||
MultiSelect.CombineSecondary();
|
||||
secondary = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnGUI()
|
||||
|
||||
@@ -125,6 +125,8 @@ public class MultiSelect
|
||||
|
||||
public static void OnKillItemView(GridItemView itemView)
|
||||
{
|
||||
CombineSecondary();
|
||||
|
||||
MultiSelectItemContext itemContext = SelectedItems.FirstOrDefault(x => x.Value == itemView).Key;
|
||||
if (itemContext != null)
|
||||
{
|
||||
@@ -140,6 +142,8 @@ public class MultiSelect
|
||||
return;
|
||||
}
|
||||
|
||||
CombineSecondary();
|
||||
|
||||
MultiSelectItemContext itemContext = SelectedItems.FirstOrDefault(x => x.Key.Item == itemView.Item).Key;
|
||||
if (itemContext != null)
|
||||
{
|
||||
@@ -158,6 +162,8 @@ public class MultiSelect
|
||||
return;
|
||||
}
|
||||
|
||||
CombineSecondary();
|
||||
|
||||
MultiSelectItemContext oldItemContext = SelectedItems.FirstOrDefault(x => x.Key.Item == eventArgs.Item).Key;
|
||||
if (oldItemContext != null)
|
||||
{
|
||||
@@ -221,7 +227,7 @@ public class MultiSelect
|
||||
|
||||
public static bool Active
|
||||
{
|
||||
get { return SelectedItems.Count > 0; }
|
||||
get { return SelectedItems.Count > 0 || SecondaryItems.Count > 0; }
|
||||
}
|
||||
|
||||
// Sort the items to prioritize the items that share a grid with the dragged item, prepend the dragContext as the first one
|
||||
|
||||
Reference in New Issue
Block a user