Пример #1
0
 private void UpdateItemAppearance(MyTerminalBlock block, MyGuiControlListbox.Item item)
 {
     item.Text.Clear().Append(block.CustomName);
     if (!block.IsFunctional)
     {
         item.ColorMask = Vector4.One;
         item.Text.AppendStringBuilder(MyTexts.Get(MySpaceTexts.Terminal_BlockIncomplete));
         item.FontOverride = MyFontEnum.Red;
     }
     else if (!block.HasPlayerAccess(m_controller.Identity.IdentityId))
     {
         item.ColorMask = Vector4.One;
         item.Text.AppendStringBuilder(MyTexts.Get(MySpaceTexts.Terminal_BlockAccessDenied));
         item.FontOverride = MyFontEnum.Red;
     }
     else if (block.ShowInTerminal == false)
     {
         item.ColorMask    = 0.6f * m_colorHelper.GetGridColor(block.CubeGrid).ToVector4();
         item.FontOverride = null;
     }
     else
     {
         item.ColorMask    = m_colorHelper.GetGridColor(block.CubeGrid).ToVector4();
         item.FontOverride = null;
     }
 }
        public override ChangeInfo Update(MyEntity owner, long playerID = 0)
        {
            ChangeInfo changed = base.Update(owner, playerID);

            if (m_block == null)
            {
                TryGetBlock();
            }

            var action = GetCurrentAction();

            bool isValid = m_block != null && action != null && MyCubeGridGroups.Static.Logical.HasSameGroup((owner as MyTerminalBlock).CubeGrid, m_block.CubeGrid);

            changed |= SetEnabled(isValid && m_block.IsFunctional && (m_block.HasPlayerAccess(playerID) || m_block.HasPlayerAccess((owner as MyTerminalBlock).OwnerId)));
            if (m_block != null)
            {
                changed |= SetIcon(m_block.BlockDefinition.Icon);
            }
            if (isValid)
            {
                if (!m_wasValid || ActionChanged)
                {
                    changed |= SetIcon(m_block.BlockDefinition.Icon);
                    changed |= SetSubIcon(action.Icon);
                    changed |= UpdateCustomName(action);
                }
                else if (m_nameChanged)
                {
                    changed |= UpdateCustomName(action);
                }

                m_tmpStringBuilder.Clear();
                action.WriteValue(m_block, m_tmpStringBuilder);
                changed |= SetIconText(m_tmpStringBuilder);
                m_tmpStringBuilder.Clear();
            }

            m_wasValid    = isValid;
            m_nameChanged = false;
            ActionChanged = false;

            return(changed);
        }