private void Toolbar_ItemEnabledChanged(MyToolbar toolbar, MyToolbar.SlotArgs args) { if (args.SlotNumber.HasValue) { var idx = args.SlotNumber.Value; m_toolbarItemsGrid.GetItemAt(idx).Enabled = toolbar.IsEnabled(toolbar.SlotToIndex(idx)); } else { for (int i = 0; i < m_toolbarItemsGrid.ColumnsCount; ++i) { m_toolbarItemsGrid.GetItemAt(i).Enabled = toolbar.IsEnabled(toolbar.SlotToIndex(i)); } } }
private void UpdateItemIcon(MyToolbar toolbar, MyToolbar.IndexArgs args) { if (toolbar.IsValidIndex(args.ItemIndex)) { var slot = toolbar.IndexToSlot(args.ItemIndex); if (slot != -1) { m_toolbarItemsGrid.GetItemAt(slot).Icons = toolbar.GetItemIcons(args.ItemIndex); } } else { for (int i = 0; i < m_toolbarItemsGrid.ColumnsCount; ++i) { m_toolbarItemsGrid.GetItemAt(i).Icons = toolbar.GetItemIcons(toolbar.SlotToIndex(i)); } } }
private void CurrentToolbar_SlotActivated(MyToolbar toolbar, MyToolbar.SlotArgs args) { if (!(toolbar.GetItemAtIndex(toolbar.SlotToIndex(args.SlotNumber.Value)) is MyToolbarItemAreaMarker)) AreaMarkerDefinition = null; }
private void CurrentToolbar_SlotActivated(MyToolbar toolbar, MyToolbar.SlotArgs args) { if (!(toolbar.GetItemAtIndex(toolbar.SlotToIndex(args.SlotNumber.Value)) is MyToolbarItemVoxelHand)) { if (Enabled) Enabled = false; } }
public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid) { SyncFlag = true; var sinkComp = new MyResourceSinkComponent(); sinkComp.Init( BlockDefinition.ResourceSinkGroup, 0.0001f, () => IsFunctional ? 0.0001f : 0); sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged; sinkComp.IsPoweredChanged += ComponentStack_IsFunctionalChanged; ResourceSink = sinkComp; base.Init(builder, cubeGrid); m_emissiveNames = new List<string>(BlockDefinition.ButtonCount); for (int i = 1; i <= BlockDefinition.ButtonCount; i++) //button dummies have 1-based index { m_emissiveNames.Add(string.Format("Emissive{0}", i)); // because of modding } var ob = builder as MyObjectBuilder_ButtonPanel; Toolbar = new MyToolbar(MyToolbarType.ButtonPanel, Math.Min(BlockDefinition.ButtonCount, MyToolbar.DEF_SLOT_COUNT), (BlockDefinition.ButtonCount / MyToolbar.DEF_SLOT_COUNT) + 1); Toolbar.DrawNumbers = false; Toolbar.GetSymbol = (slot) => { var ret = new Sandbox.Graphics.GUI.MyGuiControlGrid.ColoredIcon(); if(Toolbar.SlotToIndex(slot) < BlockDefinition.ButtonCount) { ret.Icon = BlockDefinition.ButtonSymbols[Toolbar.SlotToIndex(slot) % BlockDefinition.ButtonSymbols.Length]; var color = BlockDefinition.ButtonColors[Toolbar.SlotToIndex(slot) % BlockDefinition.ButtonColors.Length]; color.W = 1; ret.Color = color; } return ret; }; Toolbar.Init(ob.Toolbar, this); Toolbar.ItemChanged += Toolbar_ItemChanged; AnyoneCanUse = ob.AnyoneCanUse; SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; ResourceSink.Update(); if (ob.CustomButtonNames != null) { m_customButtonNames = ob.CustomButtonNames; } NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME | MyEntityUpdateEnum.EACH_FRAME; UseObjectsComponent.GetInteractiveObjects<MyUseObjectPanelButton>(m_buttonsUseObjects); }
private void CurrentToolbar_SlotActivated(MyToolbar toolbar, MyToolbar.SlotArgs args) { if (!(toolbar.GetItemAtIndex(toolbar.SlotToIndex(args.SlotNumber.Value)) is MyToolbarItemBot)) BotToSpawn = null; if (!(toolbar.GetItemAtIndex(toolbar.SlotToIndex(args.SlotNumber.Value)) is MyToolbarItemAiCommand)) CommandDefinition = null; }
private void UpdateItemIcon(MyToolbar toolbar, MyToolbar.IndexArgs args) { if (toolbar.IsValidIndex(args.ItemIndex)) { var slot = toolbar.IndexToSlot(args.ItemIndex); if (slot != -1) m_toolbarItemsGrid.GetItemAt(slot).Icon = toolbar.GetItemIcon(args.ItemIndex); } else { for (int i = 0; i < m_toolbarItemsGrid.ColumnsCount; ++i) { m_toolbarItemsGrid.GetItemAt(i).Icon = toolbar.GetItemIcon(toolbar.SlotToIndex(i)); } } }
private void CurrentToolbar_SlotActivated(MyToolbar toolbar, MyToolbar.SlotArgs args) { if (!(toolbar.GetItemAtIndex(toolbar.SlotToIndex(args.SlotNumber.Value)) is MyToolbarItemPrefabThrower)) Enabled = false; }