public static ToolbarEntity GetCurrent(ToolbarLocation location) { var isAllowed = Schema.Current.GetInMemoryFilter <ToolbarEntity>(userInterface: true); var result = Toolbars.Value.Values .Where(t => isAllowed(t) && t.Location == location) .OrderByDescending(a => a.Priority) .FirstOrDefault(); return(result); }
public void SetToolbarItem(string name, ToolbarLocation toolbarLocation) { if (IsWeapon(name)) { SetToolbarWeapon(toolbarLocation.Slot, toolbarLocation.Page, name); } else { SetToolbarBlock(toolbarLocation.Slot, toolbarLocation.Page, name); } }
private void SetToolbarItem <T>(MyDefinitionId id, ToolbarLocation toolbarLocation) where T : MyObjectBuilder_ToolbarItemDefinition, new() { var toolbarItemBuilder = MyObjectBuilderSerializer.CreateNewObject <T>(); toolbarItemBuilder.DefinitionId = id; var toolbar = m_session.Character.Toolbar; toolbar.SwitchToPage(toolbarLocation.Page); var item = MyToolbarItemFactory.CreateToolbarItem(toolbarItemBuilder); toolbar.SetItemAtSlot(toolbarLocation.Slot, item); }
public void SetToolbarItem(DefinitionId definitionId, ToolbarLocation toolbarLocation) { var myDefinitionId = definitionId.ToMyDefinitionId(); Definitions.CheckDefinitionIdExists(myDefinitionId); if (IsWeapon(definitionId.Type)) { SetToolbarItem <MyObjectBuilder_ToolbarItemWeapon>(myDefinitionId, toolbarLocation); } else { SetToolbarItem <MyObjectBuilder_ToolbarItemCubeBlock>(myDefinitionId, toolbarLocation); } }
// -------------------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of this class. /// </summary> // -------------------------------------------------------------------------------------------- protected ToolWindowPane() { _BitmapIndex = -1; _BitmapResourceID = -1; _ToolBarLocation = ToolbarLocation.Top; // --- Obtain attributes of the class foreach (object attr in GetType().GetCustomAttributes(false)) { var captionAttr = attr as InitialCaptionAttribute; if (captionAttr != null) { Caption = ResourceResolver <TPackage> .GetString(captionAttr.Value); continue; } var resIdAttr = attr as BitmapResourceIdAttribute; if (resIdAttr != null) { BitmapResourceID = resIdAttr.ResourceId; BitmapIndex = resIdAttr.BitmapIndex; continue; } var toolbarAttr = attr as ToolbarAttribute; if (toolbarAttr != null) { var toolbarProvider = Activator.CreateInstance(toolbarAttr.Value) as IToolbarProvider; if (toolbarProvider != null) { ToolBar = toolbarProvider.CommandId; } continue; } var toolLocAttr = attr as ToolbarLocationAttribute; if (toolLocAttr != null) { _ToolBarLocation = toolLocAttr.Location; continue; } } }
public void EquipToolbarItem(ToolbarLocation toolbarLocation, bool allowSizeChange) { var toolbar = m_session.Character.Toolbar; toolbar.SwitchToPageOrNot(toolbarLocation.Page); if (!allowSizeChange && toolbar.SelectedSlot.HasValue && (toolbar.SelectedSlot.Value == toolbarLocation.Slot)) { return; // Already set (setting it again would change grid size). } var toolbarItem = toolbar[toolbarLocation.Slot]; if (toolbarItem is MyToolbarItemWeapon weapon) { // Very dirty and fast hack, but works for tools, needs more sophistication. m_session.Character.SwitchToWeapon(weapon); } else { toolbar.ActivateItemAtSlot(toolbarLocation.Slot); } }
public static ToolbarResponse GetCurrentToolbarResponse(ToolbarLocation location) { var curr = GetCurrent(location); if (curr == null) { return(null); } var responses = ToResponseList(curr.Elements); if (responses.Count == 0) { return(null); } return(new ToolbarResponse { type = ToolbarElementType.Menu, content = curr.ToLite(), label = curr.Name, elements = responses, }); }
public static ToolbarResponse?GetCurrentToolbarResponse(ToolbarLocation location) { var curr = GetCurrent(location); if (curr == null) { return(null); } var responses = ToResponseList(TranslatedInstanceLogic.TranslatedMList(curr, c => c.Elements).ToList()); if (responses.Count == 0) { return(null); } return(new ToolbarResponse { type = ToolbarElementType.Header, content = curr.ToLite(), label = TranslatedInstanceLogic.TranslatedField(curr, a => a.Name), elements = responses, }); }
void SetToolbarItem(string name, ToolbarLocation toolbarLocation) { m_se.Items.SetToolbarItem(name, toolbarLocation); }
void Equip(ToolbarLocation toolbarLocation) { m_se.Items.Equip(toolbarLocation); }
// -------------------------------------------------------------------------------------------- /// <summary> /// Initializes the toolbar location of the tool window pane. /// </summary> /// <param name="location">Location of the toolbar.</param> // -------------------------------------------------------------------------------------------- public ToolbarLocationAttribute(ToolbarLocation location) { Location = location; }
public void Equip(ToolbarLocation toolbarLocation) { EquipToolbarItem(toolbarLocation, false); }
public ToolbarResponse Current(ToolbarLocation location) { return(ToolbarLogic.GetCurrentToolbarResponse(location)); }
public void SetToolbarItem(string name, ToolbarLocation toolbarLocation) { Enqueue(() => m_items.SetToolbarItem(name, toolbarLocation)); }
public void Equip(ToolbarLocation toolbarLocation) { Enqueue(() => m_items.Equip(toolbarLocation)); }
public void Equip(ToolbarLocation toolbarLocation) { }
public void SetToolbarItem(string name, ToolbarLocation toolbarLocation) { }