本文整理汇总了C#中Sandbox.Game.Screens.Helpers.MyToolbar.GetSlotItem方法的典型用法代码示例。如果您正苦于以下问题:C# MyToolbar.GetSlotItem方法的具体用法?C# MyToolbar.GetSlotItem怎么用?C# MyToolbar.GetSlotItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sandbox.Game.Screens.Helpers.MyToolbar
的用法示例。
在下文中一共展示了MyToolbar.GetSlotItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Toolbar_CurrentPageChanged
private void Toolbar_CurrentPageChanged(MyToolbar toolbar, MyToolbar.PageChangeArgs args)
{
m_contextMenu.Deactivate();
HighlightCurrentPageLabel();
for (int i = 0; i < MyToolbarComponent.CurrentToolbar.SlotCount; ++i)
{
SetGridItemAt(i, toolbar.GetSlotItem(i));
}
}
示例2: ShowToolbar
private void ShowToolbar(MyToolbar toolbar)
{
if (m_shownToolbar != null)
{
m_shownToolbar.ItemChanged -= Toolbar_ItemChanged;
m_shownToolbar.ItemUpdated -= Toolbar_ItemUpdated;
m_shownToolbar.SelectedSlotChanged -= Toolbar_SelectedSlotChanged;
m_shownToolbar.SlotActivated -= Toolbar_SlotActivated;
m_shownToolbar.ItemEnabledChanged -= Toolbar_ItemEnabledChanged;
m_shownToolbar.CurrentPageChanged -= Toolbar_CurrentPageChanged;
foreach (var label in m_pageLabelList)
{
Elements.Remove(label);
}
m_pageLabelList.Clear();
}
m_shownToolbar = toolbar;
if (m_shownToolbar == null) // Toolbar can be null in the passenger seat
{
m_toolbarItemsGrid.Enabled = false;
m_toolbarItemsGrid.Visible = false;
}
else
{
var slotCount = toolbar.SlotCount;
m_toolbarItemsGrid.ColumnsCount = slotCount + (toolbar.ShowHolsterSlot ? 1 : 0);
for (int i = 0; i < slotCount; ++i)
SetGridItemAt(i, toolbar.GetSlotItem(i));
m_selectedItemLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
m_colorVariantPanel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
m_colorVariantPanel.Visible = MyFakes.ENABLE_BLOCK_COLORING; // character != null;
if (toolbar.ShowHolsterSlot)
SetGridItemAt(slotCount, new MyToolbarItemEmpty(), @"Textures\GUI\Icons\HideWeapon.dds", null, MyTexts.GetString(MySpaceTexts.HideWeapon));
if(toolbar.PageCount > 1)
for (int i = 0; i < toolbar.PageCount; ++i)
{
m_textCache.Clear();
m_textCache.AppendInt32(i + 1);
MyGuiControlLabel pageLabel = new MyGuiControlLabel(text: MyToolbarComponent.GetSlotControlText(i).ToString() ?? m_textCache.ToString());
pageLabel.BackgroundTexture = MyGuiConstants.TEXTURE_TOOLBAR_TAB;
pageLabel.TextScale = 0.7f;
pageLabel.Size = m_toolbarItemsGrid.ItemSize * new Vector2(0.5f, 0.35f);
pageLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER;
m_pageLabelList.Add(pageLabel);
Elements.Add(pageLabel);
}
RepositionControls();
HighlightCurrentPageLabel();
RefreshSelectedItem(toolbar);
m_shownToolbar.ItemChanged -= Toolbar_ItemChanged;
m_shownToolbar.ItemChanged += Toolbar_ItemChanged;
m_shownToolbar.ItemUpdated -= Toolbar_ItemUpdated;
m_shownToolbar.ItemUpdated += Toolbar_ItemUpdated;
m_shownToolbar.SelectedSlotChanged -= Toolbar_SelectedSlotChanged;
m_shownToolbar.SelectedSlotChanged += Toolbar_SelectedSlotChanged;
m_shownToolbar.SlotActivated -= Toolbar_SlotActivated;
m_shownToolbar.SlotActivated += Toolbar_SlotActivated;
m_shownToolbar.ItemEnabledChanged -= Toolbar_ItemEnabledChanged;
m_shownToolbar.ItemEnabledChanged += Toolbar_ItemEnabledChanged;
m_shownToolbar.CurrentPageChanged -= Toolbar_CurrentPageChanged;
m_shownToolbar.CurrentPageChanged += Toolbar_CurrentPageChanged;
MaxSize = MinSize = new Vector2(m_toolbarItemsGrid.Size.X, m_toolbarItemsGrid.Size.Y + m_selectedItemLabel.Size.Y + m_colorVariantPanel.Size.Y);
m_toolbarItemsGrid.Enabled = true;
m_toolbarItemsGrid.Visible = true;
}
}