public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate) { if (DraggedItem != null) { if (input.IsLeftMousePressed()) { float dragDistanceSquared = MyGuiManager.GetScreenSizeFromNormalizedSize(StartDragPosition - MyGuiManager.MouseCursorPosition).LengthSquared(); if (dragDistanceSquared > 16) // Drag Detection Sensitivity - 4 pixels { Dragging = m_frameBackDragging = true; } } else { if (Drop != null && Dragging) { Drop(this, EventArgs.Empty); } Dragging = false; DraggedItem = null; } } return(base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate)); }
public void DeleteItem(MyTreeViewItem item) { if (m_items.Remove(item)) { item.TreeView = null; item.ClearItems(); } }
public MyTreeViewItem AddItem(StringBuilder text, MyTexture2D icon, Vector2 iconSize, MyTexture2D expandIcon, MyTexture2D collapseIcon, Vector2 expandIconSize) { //System.Diagnostics.Trace.Assert(m_items.TrueForAll(a => a.GetIconSize() == iconSize)); var item = new MyTreeViewItem(text, icon, iconSize, expandIcon, collapseIcon, expandIconSize); item.TreeView = TreeView; m_items.Add(item); item.Parent = this; return(item); }
public void FocusItem(MyTreeViewItem item) { if (item != null) { Vector2 offset = MyGUIHelper.GetOffset(m_body.GetPosition(), m_body.GetSize(), item.GetPosition(), item.GetSize()); m_vScrollbar.ChangeValue(-offset.Y); m_hScrollbar.ChangeValue(-offset.X); } FocusedItem = item; }
private MyTreeViewItem PrevVisible(ITreeView iTreeView, MyTreeViewItem focused) { MyTreeViewItem pred = focused; TraverseVisible(m_body, a => { if (a == focused) { focused = pred; } else { pred = a; } } ); return(focused); }
private MyTreeViewItem NextVisible(ITreeView iTreeView, MyTreeViewItem focused) { bool found = false; TraverseVisible(m_body, a => { if (a == focused) { found = true; } else if (found) { focused = a; found = false; } } ); return(focused); }
public bool HandleInput(MyTreeViewItem treeViewItem, MyGuiInput input) { bool captured = false; if (DraggedItem == null) { if (MyGUIHelper.Contains(treeViewItem.GetPosition(), treeViewItem.GetSize(), MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y) && treeViewItem.TreeView.Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y)) { if (input.IsNewLeftMousePressed()) { Dragging = false; DraggedItem = treeViewItem; StartDragPosition = MyGuiManager.MouseCursorPosition; captured = true; } } } return captured; }
public bool HandleInput(MyTreeViewItem treeViewItem, MyGuiInput input) { bool captured = false; if (DraggedItem == null) { if (MyGUIHelper.Contains(treeViewItem.GetPosition(), treeViewItem.GetSize(), MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y) && treeViewItem.TreeView.Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y)) { if (input.IsNewLeftMousePressed()) { Dragging = false; DraggedItem = treeViewItem; StartDragPosition = MyGuiManager.MouseCursorPosition; captured = true; } } } return(captured); }
public void DeleteItem(MyTreeViewItem item) { if (item == FocusedItem) { int index = item.GetIndex(); if (index + 1 < GetItemCount()) { FocusedItem = GetItem(index + 1); } else if (index - 1 >= 0) { FocusedItem = GetItem(index - 1); } else { FocusedItem = FocusedItem.Parent as MyTreeViewItem; } } m_body.DeleteItem(item); }
private MyTreeViewItem AddBaseDragTreeItem(MyTreeViewItem parentItem, MyTextsWrapperEnum text, MyTexture2D icon, MyTexture2D expand, MyTexture2D collapse, Vector2 smallIconSize, Vector2 expandIconSize, object tag) { var item = parentItem.AddItem(MyTextsWrapper.Get(text), icon, smallIconSize, expand, collapse, expandIconSize); item.DragDrop = m_addObjectTreeViewdragDrop; item.Tag = tag; return item; }
public void Init(MyTreeViewItem item, Vector2 startDragPosition) { Dragging = false; DraggedItem = item; StartDragPosition = startDragPosition; }
public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate) { if (DraggedItem != null) { if (input.IsLeftMousePressed()) { float dragDistanceSquared = MyGuiManager.GetScreenSizeFromNormalizedSize(StartDragPosition - MyGuiManager.MouseCursorPosition).LengthSquared(); if (dragDistanceSquared > 16) // Drag Detection Sensitivity - 4 pixels { Dragging = m_frameBackDragging = true; } } else { if (Drop != null && Dragging) { Drop(this, EventArgs.Empty); } Dragging = false; DraggedItem = null; } } return base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate); }
private MyTreeViewItem PrevVisible(ITreeView iTreeView, MyTreeViewItem focused) { MyTreeViewItem pred = focused; TraverseVisible(m_body, a => { if (a == focused) { focused = pred; } else { pred = a; } } ); return focused; }
public bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate) { var oldHooveredItem = HooveredItem; HooveredItem = null; bool captured = m_body.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate) || m_vScrollbar.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate) || m_hScrollbar.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate); if (hasKeyboardActiveControl) { if (FocusedItem == null && m_body.GetItemCount() > 0 && (input.IsNewKeyPress(Keys.Up) || input.IsNewKeyPress(Keys.Down) || input.IsNewKeyPress(Keys.Left) || input.IsNewKeyPress(Keys.Right) || input.DeltaMouseScrollWheelValue() != 0)) { FocusItem(m_body[0]); } else if (FocusedItem != null) { if (input.IsNewKeyPress(Keys.Down) || (input.DeltaMouseScrollWheelValue() < 0 && Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y))) { FocusItem(NextVisible(m_body, FocusedItem)); } if (input.IsNewKeyPress(Keys.Up) || (input.DeltaMouseScrollWheelValue() > 0 && Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y))) { FocusItem(PrevVisible(m_body, FocusedItem)); } if (input.IsNewKeyPress(Keys.Right)) { if (FocusedItem.GetItemCount() > 0) { if (!FocusedItem.IsExpanded) { FocusedItem.IsExpanded = true; } else { var next = NextVisible(FocusedItem, FocusedItem); FocusItem(next); } } } if (input.IsNewKeyPress(Keys.Left)) { if (FocusedItem.GetItemCount() > 0 && FocusedItem.IsExpanded) { FocusedItem.IsExpanded = false; } else if (FocusedItem.Parent is MyTreeViewItem) { FocusItem(FocusedItem.Parent as MyTreeViewItem); } } if (FocusedItem.GetItemCount() > 0) { if (input.IsNewKeyPress(Keys.Add)) { FocusedItem.IsExpanded = true; } if (input.IsNewKeyPress(Keys.Subtract)) { FocusedItem.IsExpanded = false; } } } if (input.IsNewKeyPress(Keys.PageDown)) { m_vScrollbar.PageDown(); } if (input.IsNewKeyPress(Keys.PageUp)) { m_vScrollbar.PageUp(); } captured = captured || input.IsNewKeyPress(Keys.PageDown) || input.IsNewKeyPress(Keys.PageUp) || input.IsNewKeyPress(Keys.Down) || input.IsNewKeyPress(Keys.Up) || input.IsNewKeyPress(Keys.Left) || input.IsNewKeyPress(Keys.Right) || input.IsNewKeyPress(Keys.Add) || input.IsNewKeyPress(Keys.Subtract) || input.DeltaMouseScrollWheelValue() != 0; } // Hoovered item changed if (HooveredItem != oldHooveredItem) { m_control.ShowToolTip(HooveredItem == null ? null : HooveredItem.ToolTip); MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseOver); } return captured; }
public bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate) { var oldHooveredItem = HooveredItem; HooveredItem = null; bool captured = m_body.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate) || m_vScrollbar.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate) || m_hScrollbar.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate); if (hasKeyboardActiveControl) { if (FocusedItem == null && m_body.GetItemCount() > 0 && (input.IsNewKeyPress(Keys.Up) || input.IsNewKeyPress(Keys.Down) || input.IsNewKeyPress(Keys.Left) || input.IsNewKeyPress(Keys.Right) || input.DeltaMouseScrollWheelValue() != 0)) { FocusItem(m_body[0]); } else if (FocusedItem != null) { if (input.IsNewKeyPress(Keys.Down) || (input.DeltaMouseScrollWheelValue() < 0 && Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y))) { FocusItem(NextVisible(m_body, FocusedItem)); } if (input.IsNewKeyPress(Keys.Up) || (input.DeltaMouseScrollWheelValue() > 0 && Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y))) { FocusItem(PrevVisible(m_body, FocusedItem)); } if (input.IsNewKeyPress(Keys.Right)) { if (FocusedItem.GetItemCount() > 0) { if (!FocusedItem.IsExpanded) { FocusedItem.IsExpanded = true; } else { var next = NextVisible(FocusedItem, FocusedItem); FocusItem(next); } } } if (input.IsNewKeyPress(Keys.Left)) { if (FocusedItem.GetItemCount() > 0 && FocusedItem.IsExpanded) { FocusedItem.IsExpanded = false; } else if (FocusedItem.Parent is MyTreeViewItem) { FocusItem(FocusedItem.Parent as MyTreeViewItem); } } if (FocusedItem.GetItemCount() > 0) { if (input.IsNewKeyPress(Keys.Add)) { FocusedItem.IsExpanded = true; } if (input.IsNewKeyPress(Keys.Subtract)) { FocusedItem.IsExpanded = false; } } } if (input.IsNewKeyPress(Keys.PageDown)) { m_vScrollbar.PageDown(); } if (input.IsNewKeyPress(Keys.PageUp)) { m_vScrollbar.PageUp(); } captured = captured || input.IsNewKeyPress(Keys.PageDown) || input.IsNewKeyPress(Keys.PageUp) || input.IsNewKeyPress(Keys.Down) || input.IsNewKeyPress(Keys.Up) || input.IsNewKeyPress(Keys.Left) || input.IsNewKeyPress(Keys.Right) || input.IsNewKeyPress(Keys.Add) || input.IsNewKeyPress(Keys.Subtract) || input.DeltaMouseScrollWheelValue() != 0; } // Hoovered item changed if (HooveredItem != oldHooveredItem) { m_control.ShowToolTip(HooveredItem == null ? null : HooveredItem.ToolTip); MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseOver); } return(captured); }
protected abstract void AddPrefabItems(MyTreeViewItem parentItem, MyMwcObjectBuilder_Prefab_AppearanceEnum appearanceTextureEnum, BuildTypesEnum buildType, CategoryTypesEnum categoryType);
private void AddDebrisItems(MyTreeViewItem parentItem) { Vector2 itemSize = MyGuiManager.GetNormalizedSizeFromScreenSize(new Vector2(64, 64)); foreach (MyMwcObjectBuilder_SmallDebris_TypesEnum enumValue in MyGuiSmallDebrisHelpers.MyMwcSmallDebrisEnumValues) { MyGuiSmallDebrisHelper smallDebrisHelper = MyGuiSmallDebrisHelpers.GetMyGuiSmallDebrisHelper(enumValue); var item = parentItem.AddItem(new StringBuilder(), smallDebrisHelper.Icon, itemSize, MyGuiManager.GetBlankTexture(), MyGuiManager.GetBlankTexture(), MyGuiConstants.CHECKBOX_SIZE); item.ToolTip = new MyToolTips(smallDebrisHelper.Description); item.Tag = enumValue; item.Action = OnAddDebris; item.DragDrop = m_addObjectTreeViewdragDrop; } }
private void AddLargeShipItems(MyTreeViewItem parentItem) { Vector2 itemSize = MyGuiManager.GetNormalizedSizeFromScreenSize(new Vector2(64, 64)); foreach (MyMwcObjectBuilder_LargeShip_TypesEnum enumValue in MyGuiLargeShipHelpers.MyMwcLargeShipTypesEnumValues) { if (enumValue != MyMwcObjectBuilder_LargeShip_TypesEnum.JEROMIE_INTERIOR_STATION && enumValue != MyMwcObjectBuilder_LargeShip_TypesEnum.CRUISER_SHIP) { MyGuiLargeShipHelper largeShipHelper = MyGuiLargeShipHelpers.GetMyGuiLargeShipHelper(enumValue); var item = parentItem.AddItem(new StringBuilder(), largeShipHelper.Icon, itemSize, MyGuiManager.GetBlankTexture(), MyGuiManager.GetBlankTexture(), MyGuiConstants.CHECKBOX_SIZE); item.ToolTip = new MyToolTips(largeShipHelper.Description); item.Tag = enumValue; item.Action = OnAddLargeShip; item.DragDrop = m_addObjectTreeViewdragDrop; } } }
private MyTreeViewItem NextVisible(ITreeView iTreeView, MyTreeViewItem focused) { bool found = false; TraverseVisible(m_body, a => { if (a == focused) { found = true; } else if (found) { focused = a; found = false; } } ); return focused; }
public int GetIndex(MyTreeViewItem item) { return(m_items.IndexOf(item)); }
protected override void AddPrefabItems(MyTreeViewItem parentItem, MyMwcObjectBuilder_Prefab_AppearanceEnum appearanceTextureEnum, BuildTypesEnum buildType, CategoryTypesEnum categoryType) { MyMwcLog.WriteLine("GOD AddPrefabItems - START"); Vector2 itemSize = MyGuiConstants.CHECKBOX_SIZE * 3; foreach (MyMwcObjectBuilderTypeEnum enumValue in MyGuiPrefabHelpers.MyMwcPrefabTypesEnumValues) { foreach (int prefabId in MyMwcObjectBuilder_Base.GetObjectBuilderIDs(enumValue)) { MyPrefabConfiguration config = MyPrefabConstants.GetPrefabConfiguration(enumValue, prefabId); MyGuiPrefabHelper prefabModuleHelper = MyGuiObjectBuilderHelpers.GetGuiHelper(enumValue, prefabId) as MyGuiPrefabHelper; if (config == null) continue; if (config.FactionSpecific.HasValue && config.FactionSpecific.Value != appearanceTextureEnum) continue; if (config.BuildType == buildType && config.CategoryType == categoryType && config.EnabledInEditor) { MyTexture2D previewTexture = MyGuiManager.GetPrefabPreviewTexture(enumValue, prefabId, appearanceTextureEnum); var item = parentItem.AddItem(new StringBuilder(), previewTexture, itemSize, MyGuiManager.GetBlankTexture(), MyGuiManager.GetBlankTexture(), MyGuiConstants.CHECKBOX_SIZE); item.ToolTip = GetPrefabToolTip(prefabModuleHelper.Description, config); //item.ToolTip = new MyToolTips(prefabModuleHelper.Description); item.Tag = new PrefabTag(enumValue, prefabId, appearanceTextureEnum, categoryType); item.Action = OnAddPrefab; item.DragDrop = m_addObjectTreeViewdragDrop; } } } MyMwcLog.WriteLine("GOD AddPrefabItems - END"); }
protected void AddPrefabType(MyTreeViewItem parentItem, MyMwcObjectBuilder_Prefab_AppearanceEnum appearanceTextureEnum, MyTextsWrapperEnum typeText, BuildTypesEnum buildTypesEnum, CategoryTypesEnum[] categories, MyTexture2D icon, Vector2 iconSize, MyTexture2D expand, MyTexture2D collapse, Vector2 expandIconSize) { var prefabTypeItem = parentItem == null ? m_addObjectTreeView.AddItem(MyTextsWrapper.Get(typeText), icon, iconSize, expand, collapse, expandIconSize) : parentItem.AddItem(MyTextsWrapper.Get(typeText), icon, iconSize, expand, collapse, expandIconSize); foreach (var categoryTypesEnum in categories) { var categoryItem = prefabTypeItem.AddItem(MyGuiPrefabHelpers.GetMyGuiCategoryTypeHelper(categoryTypesEnum).Description, icon, iconSize, expand, collapse, expandIconSize); AddPrefabItems(categoryItem, appearanceTextureEnum, buildTypesEnum, categoryTypesEnum); } }
public void DeleteItem(MyTreeViewItem item) { m_treeView.DeleteItem(item); }